2020-07-03 14:20:27 +00:00
|
|
|
Optimized IR:
|
|
|
|
/*******************************************************
|
|
|
|
* WARNING *
|
|
|
|
* Solidity to Yul compilation is still EXPERIMENTAL *
|
|
|
|
* It can result in LOSS OF FUNDS or worse *
|
|
|
|
* !USE AT YOUR OWN RISK! *
|
|
|
|
*******************************************************/
|
|
|
|
|
2020-11-26 21:33:36 +00:00
|
|
|
object "Arraysum_34" {
|
2020-07-03 14:20:27 +00:00
|
|
|
code {
|
|
|
|
{
|
2020-10-15 14:25:15 +00:00
|
|
|
mstore(64, 128)
|
2020-07-03 14:20:27 +00:00
|
|
|
if callvalue() { revert(0, 0) }
|
2020-11-26 21:33:36 +00:00
|
|
|
let _1 := datasize("Arraysum_34_deployed")
|
|
|
|
codecopy(0, dataoffset("Arraysum_34_deployed"), _1)
|
2020-07-03 14:20:27 +00:00
|
|
|
return(0, _1)
|
|
|
|
}
|
|
|
|
}
|
2020-11-26 21:33:36 +00:00
|
|
|
object "Arraysum_34_deployed" {
|
2020-07-03 14:20:27 +00:00
|
|
|
code {
|
|
|
|
{
|
2020-10-15 14:25:15 +00:00
|
|
|
mstore(64, 128)
|
2020-07-03 14:20:27 +00:00
|
|
|
if iszero(lt(calldatasize(), 4))
|
|
|
|
{
|
|
|
|
let _1 := 0
|
|
|
|
if eq(0x81d73423, shr(224, calldataload(_1)))
|
|
|
|
{
|
|
|
|
if callvalue() { revert(_1, _1) }
|
|
|
|
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) }
|
|
|
|
let vloc_sum := _1
|
|
|
|
let vloc_i := _1
|
|
|
|
let _2 := sload(_1)
|
|
|
|
for { }
|
|
|
|
lt(vloc_i, _2)
|
|
|
|
{
|
2020-09-24 13:45:45 +00:00
|
|
|
if gt(vloc_i, not(1)) { invalid() }
|
2020-07-06 11:55:09 +00:00
|
|
|
vloc_i := add(vloc_i, 1)
|
2020-07-03 14:20:27 +00:00
|
|
|
}
|
|
|
|
{
|
2020-07-06 11:55:09 +00:00
|
|
|
mstore(_1, _1)
|
|
|
|
let _3 := sload(add(keccak256(_1, 0x20), vloc_i))
|
2020-09-24 13:45:45 +00:00
|
|
|
if gt(vloc_sum, not(_3)) { invalid() }
|
2020-07-06 11:55:09 +00:00
|
|
|
vloc_sum := add(vloc_sum, _3)
|
2020-07-03 14:20:27 +00:00
|
|
|
}
|
|
|
|
let memPos := allocateMemory(_1)
|
2020-10-08 10:47:47 +00:00
|
|
|
return(memPos, sub(abi_encode_uint(memPos, vloc_sum), memPos))
|
2020-07-03 14:20:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
revert(0, 0)
|
|
|
|
}
|
2020-08-06 19:44:50 +00:00
|
|
|
function abi_encode_uint(headStart, value0) -> tail
|
2020-07-03 14:20:27 +00:00
|
|
|
{
|
|
|
|
tail := add(headStart, 32)
|
|
|
|
mstore(headStart, value0)
|
|
|
|
}
|
|
|
|
function allocateMemory(size) -> memPtr
|
|
|
|
{
|
|
|
|
memPtr := mload(64)
|
|
|
|
let newFreePtr := add(memPtr, size)
|
2020-09-24 13:45:45 +00:00
|
|
|
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { invalid() }
|
2020-07-03 14:20:27 +00:00
|
|
|
mstore(64, newFreePtr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|