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! *
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
object "Arraysum_33" {
|
|
|
|
code {
|
|
|
|
{
|
2020-07-02 10:48:20 +00:00
|
|
|
mstore(64, memoryguard(0x80))
|
2020-07-03 14:20:27 +00:00
|
|
|
if callvalue() { revert(0, 0) }
|
|
|
|
let _1 := datasize("Arraysum_33_deployed")
|
|
|
|
codecopy(0, dataoffset("Arraysum_33_deployed"), _1)
|
|
|
|
return(0, _1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object "Arraysum_33_deployed" {
|
|
|
|
code {
|
|
|
|
{
|
2020-07-02 10:48:20 +00:00
|
|
|
mstore(64, memoryguard(0x80))
|
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-07-06 11:55:09 +00:00
|
|
|
if gt(vloc_i, not(1)) { revert(_1, _1) }
|
|
|
|
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))
|
|
|
|
if gt(vloc_sum, not(_3)) { revert(_1, _1) }
|
|
|
|
vloc_sum := add(vloc_sum, _3)
|
2020-07-03 14:20:27 +00:00
|
|
|
}
|
|
|
|
let memPos := allocateMemory(_1)
|
2020-08-06 19:44:50 +00:00
|
|
|
return(memPos, sub(abi_encode_uint(memPos, _1), 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)
|
|
|
|
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) }
|
|
|
|
mstore(64, newFreePtr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|