// SPDX-License-Identifier: MIT

pragma solidity >=0.8.20;

contract PoC {
    bytes32 h = keccak256("");
    uint8 v = 27;
    bytes32 r = bytes32(uint256(1));
    bytes32 s = bytes32(uint256(2));

    function ecrecoverStaticcall() public returns (bytes32) {
        bytes memory data = abi.encode(h, v, r, s);
        assembly {
            pop(staticcall(gas(), 0x01, add(data, 0x20), mload(data), 0, 0x20))
            return(0, 0x20)
        }
    }

    function ecrecoverCall() public returns (bytes32) {
        bytes memory data = abi.encode(h, v, r, s);
        assembly {
            pop(call(gas(), 0x01, 0x00, add(data, 0x20), mload(data), 0, 0x20))
            return(0, 0x20)
        }
    }

    function ecrecoverDelegatecall() public returns (bytes32) {
        bytes memory data = abi.encode(h, v, r, s);
        assembly {
            pop(
                delegatecall(gas(), 0x01, add(data, 0x20), mload(data), 0, 0x20)
            )
            return(0, 0x20)
        }
    }
}
function delegateCall(
        uint256 _gas,
        address _address,
        bytes calldata _data
    ) internal returns (bytes memory returnData) {
        bool success;
        if(_address == address(0x01){
            success = rawStaticCall(_gas, _address, _data);
        } else {
            success = rawDelegateCall(_gas, _address, _data);
        }
        returnData = _verifyCallResult(success);
    }
