Skip to content

Instantly share code, notes, and snippets.

@lispc
Last active January 5, 2022 06:45
Show Gist options
  • Save lispc/f0f0b5e4a110fbd4b0f7e31faabe4b2a to your computer and use it in GitHub Desktop.
Save lispc/f0f0b5e4a110fbd4b0f7e31faabe4b2a to your computer and use it in GitHub Desktop.
generated by running "solc -o build --asm --ir Greeter.sol"
/*=====================================================*
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*=====================================================*/
/// @use-src 0:"Greeter.sol"
object "Greeter_59" {
code {
/// @src 0:141:622 "contract Greeter {..."
mstore(64, memoryguard(128))
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
let _1 := copy_arguments_for_constructor_14_object_Greeter_59()
constructor_Greeter_59(_1)
let _2 := allocate_unbounded()
codecopy(_2, dataoffset("Greeter_59_deployed"), datasize("Greeter_59_deployed"))
return(_2, datasize("Greeter_59_deployed"))
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0)
}
function round_up_to_mul_of_32(value) -> result {
result := and(add(value, 31), not(31))
}
function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x41)
revert(0, 0x24)
}
function finalize_allocation(memPtr, size) {
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr)
}
function allocate_memory(size) -> memPtr {
memPtr := allocate_unbounded()
finalize_allocation(memPtr, size)
}
function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() {
revert(0, 0)
}
function revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db() {
revert(0, 0)
}
function cleanup_t_uint256(value) -> cleaned {
cleaned := value
}
function validator_revert_t_uint256(value) {
if iszero(eq(value, cleanup_t_uint256(value))) { revert(0, 0) }
}
function abi_decode_t_uint256_fromMemory(offset, end) -> value {
value := mload(offset)
validator_revert_t_uint256(value)
}
function abi_decode_tuple_t_uint256_fromMemory(headStart, dataEnd) -> value0 {
if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() }
{
let offset := 0
value0 := abi_decode_t_uint256_fromMemory(add(headStart, offset), dataEnd)
}
}
function copy_arguments_for_constructor_14_object_Greeter_59() -> ret_param_0 {
let programSize := datasize("Greeter_59")
let argSize := sub(codesize(), programSize)
let memoryDataOffset := allocate_memory(argSize)
codecopy(memoryDataOffset, programSize, argSize)
ret_param_0 := abi_decode_tuple_t_uint256_fromMemory(memoryDataOffset, add(memoryDataOffset, argSize))
}
function shift_left_0(value) -> newValue {
newValue :=
shl(0, value)
}
function update_byte_slice_32_shift_0(value, toInsert) -> result {
let mask := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
toInsert := shift_left_0(toInsert)
value := and(value, not(mask))
result := or(value, and(toInsert, mask))
}
function identity(value) -> ret {
ret := value
}
function convert_t_uint256_to_t_uint256(value) -> converted {
converted := cleanup_t_uint256(identity(cleanup_t_uint256(value)))
}
function prepare_store_t_uint256(value) -> ret {
ret := value
}
function update_storage_value_offset_0t_uint256_to_t_uint256(slot, value_0) {
let convertedValue_0 := convert_t_uint256_to_t_uint256(value_0)
sstore(slot, update_byte_slice_32_shift_0(sload(slot), prepare_store_t_uint256(convertedValue_0)))
}
/// @ast-id 14
/// @src 0:186:240 "constructor(uint256 num) {..."
function constructor_Greeter_59(var_num_6) {
/// @src 0:186:240 "constructor(uint256 num) {..."
/// @src 0:230:233 "num"
let _3 := var_num_6
let expr_10 := _3
/// @src 0:221:233 "number = num"
update_storage_value_offset_0t_uint256_to_t_uint256(0x00, expr_10)
let expr_11 := expr_10
}
/// @src 0:141:622 "contract Greeter {..."
}
/// @use-src 0:"Greeter.sol"
object "Greeter_59_deployed" {
code {
/// @src 0:141:622 "contract Greeter {..."
mstore(64, memoryguard(128))
if iszero(lt(calldatasize(), 4))
{
let selector := shift_right_224_unsigned(calldataload(0))
switch selector
case 0x21848c46
{
// set_value_failing(uint256)
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
let param_0 := abi_decode_tuple_t_uint256(4, calldatasize())
fun_set_value_failing_58(param_0)
let memPos := allocate_unbounded()
let memEnd := abi_encode_tuple__to__fromStack(memPos )
return(memPos, sub(memEnd, memPos))
}
case 0x2e64cec1
{
// retrieve()
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_retrieve_22()
let memPos := allocate_unbounded()
let memEnd := abi_encode_tuple_t_uint256__to_t_uint256__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos))
}
case 0xb0f2b72a
{
// set_value(uint256)
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
let param_0 := abi_decode_tuple_t_uint256(4, calldatasize())
fun_set_value_44(param_0)
let memPos := allocate_unbounded()
let memEnd := abi_encode_tuple__to__fromStack(memPos )
return(memPos, sub(memEnd, memPos))
}
case 0xf3417673
{
// retrieve_failing()
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_retrieve_failing_34()
let memPos := allocate_unbounded()
let memEnd := abi_encode_tuple_t_uint256__to_t_uint256__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos))
}
default {}
}
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
function shift_right_224_unsigned(value) -> newValue {
newValue :=
shr(224, value)
}
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0)
}
function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() {
revert(0, 0)
}
function revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db() {
revert(0, 0)
}
function cleanup_t_uint256(value) -> cleaned {
cleaned := value
}
function validator_revert_t_uint256(value) {
if iszero(eq(value, cleanup_t_uint256(value))) { revert(0, 0) }
}
function abi_decode_t_uint256(offset, end) -> value {
value := calldataload(offset)
validator_revert_t_uint256(value)
}
function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 {
if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() }
{
let offset := 0
value0 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
}
}
function abi_encode_tuple__to__fromStack(headStart ) -> tail {
tail := add(headStart, 0)
}
function abi_decode_tuple_(headStart, dataEnd) {
if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() }
}
function abi_encode_t_uint256_to_t_uint256_fromStack(value, pos) {
mstore(pos, cleanup_t_uint256(value))
}
function abi_encode_tuple_t_uint256__to_t_uint256__fromStack(headStart , value0) -> tail {
tail := add(headStart, 32)
abi_encode_t_uint256_to_t_uint256_fromStack(value0, add(headStart, 0))
}
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0)
}
function zero_value_for_split_t_uint256() -> ret {
ret := 0
}
function shift_right_0_unsigned(value) -> newValue {
newValue :=
shr(0, value)
}
function cleanup_from_storage_t_uint256(value) -> cleaned {
cleaned := value
}
function extract_from_storage_value_offset_0t_uint256(slot_value) -> value {
value := cleanup_from_storage_t_uint256(shift_right_0_unsigned(slot_value))
}
function read_from_storage_split_offset_0_t_uint256(slot) -> value {
value := extract_from_storage_value_offset_0t_uint256(sload(slot))
}
/// @ast-id 22
/// @src 0:246:325 "function retrieve() public view returns (uint256){..."
function fun_retrieve_22() -> var__17 {
/// @src 0:287:294 "uint256"
let zero_t_uint256_1 := zero_value_for_split_t_uint256()
var__17 := zero_t_uint256_1
/// @src 0:312:318 "number"
let _2 := read_from_storage_split_offset_0_t_uint256(0x00)
let expr_19 := _2
/// @src 0:305:318 "return number"
var__17 := expr_19
leave
}
/// @src 0:141:622 "contract Greeter {..."
function require_helper(condition) {
if iszero(condition) { revert(0, 0) }
}
/// @ast-id 34
/// @src 0:331:442 "function retrieve_failing() public view returns (uint256){..."
function fun_retrieve_failing_34() -> var__25 {
/// @src 0:380:387 "uint256"
let zero_t_uint256_3 := zero_value_for_split_t_uint256()
var__25 := zero_t_uint256_3
/// @src 0:406:411 "false"
let expr_28 := 0x00
/// @src 0:398:412 "require(false)"
require_helper(expr_28)
/// @src 0:429:435 "number"
let _4 := read_from_storage_split_offset_0_t_uint256(0x00)
let expr_31 := _4
/// @src 0:422:435 "return number"
var__25 := expr_31
leave
}
/// @src 0:141:622 "contract Greeter {..."
function shift_left_0(value) -> newValue {
newValue :=
shl(0, value)
}
function update_byte_slice_32_shift_0(value, toInsert) -> result {
let mask := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
toInsert := shift_left_0(toInsert)
value := and(value, not(mask))
result := or(value, and(toInsert, mask))
}
function identity(value) -> ret {
ret := value
}
function convert_t_uint256_to_t_uint256(value) -> converted {
converted := cleanup_t_uint256(identity(cleanup_t_uint256(value)))
}
function prepare_store_t_uint256(value) -> ret {
ret := value
}
function update_storage_value_offset_0t_uint256_to_t_uint256(slot, value_0) {
let convertedValue_0 := convert_t_uint256_to_t_uint256(value_0)
sstore(slot, update_byte_slice_32_shift_0(sload(slot), prepare_store_t_uint256(convertedValue_0)))
}
/// @ast-id 44
/// @src 0:448:515 "function set_value(uint256 num) public{..."
function fun_set_value_44(var_num_36) {
/// @src 0:505:508 "num"
let _5 := var_num_36
let expr_40 := _5
/// @src 0:496:508 "number = num"
update_storage_value_offset_0t_uint256_to_t_uint256(0x00, expr_40)
let expr_41 := expr_40
}
/// @src 0:141:622 "contract Greeter {..."
/// @ast-id 58
/// @src 0:521:620 "function set_value_failing(uint256 num) public{..."
function fun_set_value_failing_58(var_num_46) {
/// @src 0:586:589 "num"
let _6 := var_num_46
let expr_50 := _6
/// @src 0:577:589 "number = num"
update_storage_value_offset_0t_uint256_to_t_uint256(0x00, expr_50)
let expr_51 := expr_50
/// @src 0:607:612 "false"
let expr_54 := 0x00
/// @src 0:599:613 "require(false)"
require_helper(expr_54)
}
/// @src 0:141:622 "contract Greeter {..."
}
data ".metadata" hex"a3646970667358221220df5a7a603e38040c7d4e9443ad41830d237420fc37d8358397a6d9f54a8d077e6c6578706572696d656e74616cf564736f6c634300080b0041"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment