2019-09-11 09:42:59 +00:00
|
|
|
{
|
|
|
|
sstore(0, array_sum(calldataload(0)))
|
|
|
|
|
|
|
|
function array_sum(x) -> sum {
|
|
|
|
let length := calldataload(x)
|
|
|
|
for { let i := 0 } lt(i, length) { i := add(i, 1) } {
|
|
|
|
sum := add(sum, array_load(x, i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function array_load(x, i) -> v {
|
|
|
|
let len := calldataload(x)
|
|
|
|
if iszero(lt(i, len)) { revert(0, 0) }
|
|
|
|
let data := add(x, 0x20)
|
|
|
|
v := calldataload(add(data, mul(i, 0x20)))
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 11:18:50 +00:00
|
|
|
// ====
|
|
|
|
// EVMVersion: >=istanbul
|
2019-09-11 09:42:59 +00:00
|
|
|
// ----
|
2020-03-17 22:31:56 +00:00
|
|
|
// step: fullSuite
|
|
|
|
//
|
2019-09-11 09:42:59 +00:00
|
|
|
// {
|
|
|
|
// {
|
|
|
|
// let _1 := calldataload(0)
|
|
|
|
// let sum := 0
|
2019-11-27 09:44:40 +00:00
|
|
|
// let length := calldataload(_1)
|
2019-09-11 09:42:59 +00:00
|
|
|
// let i := sum
|
2019-11-27 09:44:40 +00:00
|
|
|
// for { } lt(i, length) { i := add(i, 1) }
|
2019-09-11 09:42:59 +00:00
|
|
|
// {
|
2021-03-11 11:18:50 +00:00
|
|
|
// sum := add(sum, calldataload(add(add(_1, shl(5, i)), 0x20)))
|
2019-09-11 09:42:59 +00:00
|
|
|
// }
|
|
|
|
// sstore(0, sum)
|
|
|
|
// }
|
|
|
|
// }
|