Created
May 1, 2018 18:21
-
-
Save D-Nice/402efade561e9880cb2edf189b168cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract t { | |
function getFirstCsv() returns (string c) { | |
string memory _s = "1525452452,2,3,4,5"; | |
//return 1; | |
assembly { | |
/*mstore(add(mload(0x40), 0x20), mload(_s)) | |
mstore(add(mload(0x40), 0x40), mload(add(_s, 0x20))) | |
mstore(mload(0x40), 0x20) | |
return(mload(0x40), 0x60)*/ | |
let x := 0 | |
let i := 0 | |
let iso := 0x100000000000000000000000000000000000000000000000000000000000000 | |
let s_len := mload(_s) | |
for { } lt(i, s_len) { } { | |
x := div(mul(mload(add(_s, 0x20)), exp(0x100, i)), iso) | |
if eq(x, 0x2c) { | |
let amp := exp(0x100, sub(0x20, i)) | |
mstore(add(c, 0x20), mul(div(mload(add(_s, 0x20)), amp), amp)) | |
let free := mload(0x40) | |
mstore(add(free, 0x20), i) | |
mstore(add(free, 0x40), mload(add(c, 0x20))) | |
mstore(free, 0x20) | |
return(free, 0x60) | |
} | |
i := add(i, 1) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment