Skip to content

Instantly share code, notes, and snippets.

@leonardoalt
Last active September 21, 2022 10:28
Show Gist options
  • Save leonardoalt/aa3a6d54183920ab7ae52ab243a88e0d to your computer and use it in GitHub Desktop.
Save leonardoalt/aa3a6d54183920ab7ae52ab243a88e0d to your computer and use it in GitHub Desktop.
{
/// @src 0:0:261 "contract Token {..."
mstore(64, memoryguard(128))
if iszero(lt(calldatasize(), 4))
{
let selector := shift_right_224_unsigned(calldataload(0))
switch selector
case 0xa9059cbb
{
// transfer(address,uint256)
external_fun_transfer_38()
}
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_uint160(value) -> cleaned {
cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffff)
}
function cleanup_t_address(value) -> cleaned {
cleaned := cleanup_t_uint160(value)
}
function validator_revert_t_address(value) {
if iszero(eq(value, cleanup_t_address(value))) { revert(0, 0) }
}
function abi_decode_t_address(offset, end) -> value {
value := calldataload(offset)
validator_revert_t_address(value)
}
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_addresst_uint256(headStart, dataEnd) -> value0, value1 {
if slt(sub(dataEnd, headStart), 64) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() }
{
let offset := 0
value0 := abi_decode_t_address(add(headStart, offset), dataEnd)
}
{
let offset := 32
value1 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
}
}
function abi_encode_tuple__to__fromStack(headStart ) -> tail {
tail := add(headStart, 0)
}
function external_fun_transfer_38() {
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
let param_0, param_1 := abi_decode_tuple_t_addresst_uint256(4, calldatasize())
fun_transfer_38(param_0, param_1)
let memPos := allocate_unbounded()
let memEnd := abi_encode_tuple__to__fromStack(memPos )
return(memPos, sub(memEnd, memPos))
}
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0)
}
function identity(value) -> ret {
ret := value
}
function convert_t_uint160_to_t_uint160(value) -> converted {
converted := cleanup_t_uint160(identity(cleanup_t_uint160(value)))
}
function convert_t_uint160_to_t_address(value) -> converted {
converted := convert_t_uint160_to_t_uint160(value)
}
function convert_t_address_to_t_address(value) -> converted {
converted := convert_t_uint160_to_t_address(value)
}
function mapping_index_access_t_mapping$_t_address_$_t_uint256_$_of_t_address(slot , key) -> dataSlot {
mstore(0, convert_t_address_to_t_address(key))
mstore(0x20, slot)
dataSlot := keccak256(0, 0x40)
}
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))
}
function panic_error_0x11() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x11)
revert(0, 0x24)
}
function checked_sub_t_uint256(x, y) -> diff {
x := cleanup_t_uint256(x)
y := cleanup_t_uint256(y)
diff := sub(x, y)
if gt(diff, x) { panic_error_0x11() }
}
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 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)))
}
function checked_add_t_uint256(x, y) -> sum {
x := cleanup_t_uint256(x)
y := cleanup_t_uint256(y)
sum := add(x, y)
if gt(x, sum) { panic_error_0x11() }
}
/// @ast-id 38
/// @src 0:135:259 "function transfer(address to, uint amt) external {..."
function fun_transfer_38(var_to_19, var_amt_21) {
/// @src 0:219:222 "amt"
let _1 := var_amt_21
let expr_28 := _1
/// @src 0:194:203 "balanceOf"
let _2_slot := 0x00
let expr_24_slot := _2_slot
/// @src 0:204:214 "msg.sender"
let expr_26 := caller()
/// @src 0:194:215 "balanceOf[msg.sender]"
let _3 := mapping_index_access_t_mapping$_t_address_$_t_uint256_$_of_t_address(expr_24_slot,expr_26)
/// @src 0:194:222 "balanceOf[msg.sender] -= amt"
let _4 := read_from_storage_split_offset_0_t_uint256(_3)
let expr_29 := checked_sub_t_uint256(_4, expr_28)
update_storage_value_offset_0t_uint256_to_t_uint256(_3, expr_29)
/// @src 0:249:252 "amt"
let _5 := var_amt_21
let expr_34 := _5
/// @src 0:232:241 "balanceOf"
let _6_slot := 0x00
let expr_31_slot := _6_slot
/// @src 0:242:244 "to"
let _7 := var_to_19
let expr_32 := _7
/// @src 0:232:245 "balanceOf[to]"
let _8 := mapping_index_access_t_mapping$_t_address_$_t_uint256_$_of_t_address(expr_31_slot,expr_32)
/// @src 0:232:252 "balanceOf[to] += amt"
let _9 := read_from_storage_split_offset_0_t_uint256(_8)
let expr_35 := checked_add_t_uint256(_9, expr_34)
update_storage_value_offset_0t_uint256_to_t_uint256(_8, expr_35)
}
/// @src 0:0:261 "contract Token {..."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment