// File: /workspace/github_c_makefile_star2_O1/wjmelements[P]evm/src/scan.c
// Function: parseDecimal
op_t parseDecimal(const char **iter, int negative) {
    uint64_t words[4] = {0,0,0,0};
    while (isDecimal(**iter)) {
        // multiply number by 10
        for (uint8_t i = 4; i --> 0;) {
            // long multiplication
            uint64_t s0, s1, s2, s3;

            uint64_t x = lo32(words[i]) * 10;
            s0 = lo32(x);

            x = hi32(words[i]) * 10 + hi32(x);
            s1 = lo32(x);
            s2 = hi32(x);

            x = s1;
            s1 = lo32(x);

            x = s2 + hi32(x);
            s2 = lo32(x);
            s3 = hi32(x);

            words[i] = s1 << 32 | s0;
            uint64_t carry = s3 << 32 | s2;
            // add carry
            for (uint8_t j = i + 1; j < 4; j++) {
                words[j] += carry;
                if (carry > words[j]) {
                    carry = 1;
                } else break;
            }
        }
        uint8_t digit = *((*iter)++) - '0';
        // add digit
        for (uint8_t i = 0; i < 4; i++) {
            words[i] += digit;
            if (digit > words[i]) {
                digit = 1;
            } else break;
        }
    }
    if (negative) {
        // negate via -x = ~x + 1
        for (uint8_t i = 4; i --> 0;) {
            words[i] = ~words[i];
        }
        // add 1 with carry
        for (uint8_t i = 0; !++words[i++];);
    }
    uint64_t isNonzero = words[0] | words[1] | words[2] | words[3];
    if (!isNonzero) {
        return PUSH0;
    }
    uint8_t start = 0;
    // determine start
    for (uint8_t i = 4; i --> 0;) {
        for (uint8_t j = 8; j --> 0;) {
            uint64_t shift = j * 8;
            uint8_t byte = (words[i] & (0xffllu << shift)) >> shift;
            if (byte) {
                start = i * 8 + j;
                i = 0; // break outer
                break;
            }
        }
    }
    for (uint8_t i = 0; i < 4; i++) {
        for (uint8_t j = 0; j < 8; j++) {
            if (i * 8 + j > start) {
                break;
            }
            uint64_t shift = j * 8;
            uint8_t byte = (words[i] & (0xffllu << shift)) >> shift;
            scanstackPush(byte);
        }
    }
    return (op_t) PUSH1 + start;
}

// Assembly:
pushq %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x10(%rsp)
movaps %xmm0, -0x20(%rsp)
movq (%rdi), %rcx
movb (%rcx), %al
leal -0x3a(%rax), %edx
cmpb $-0xa, %dl
setb %dl
cmpb $0x2d, %al
setne %al
testb %dl, %al
jne 0xff7d
movq %rcx, %rax
movl $0x4, %ecx
movl $0x3, %edx
movq -0x20(%rsp,%rdx,8), %r8
movl %r8d, %r9d
addq %r9, %r9
leaq (%r9,%r9,4), %r9
movl %r9d, %r10d
shrq $0x20, %r8
leaq (%r8,%r8,4), %r8
shrq $0x20, %r9
leaq (%r9,%r8,2), %r8
movq %r8, %r9
shlq $0x20, %r9
orq %r10, %r9
movq %r9, -0x20(%rsp,%rdx,8)
testb $-0x4, %cl
jne 0xff33
shrq $0x20, %r8
movq %rcx, %r9
addq %r8, -0x20(%rsp,%r9,8)
jae 0xff33
leaq 0x1(%r9), %r10
movl $0x1, %r8d
cmpq $0x3, %r9
movq %r10, %r9
jb 0xff19
decq %rcx
subq $0x1, %rdx
jae 0xfedc
leaq 0x1(%rax), %rcx
movq %rcx, (%rdi)
movb (%rax), %al
addb $-0x30, %al
movzbl %al, %edx
xorl %eax, %eax
addq %rdx, -0x20(%rsp,%rax,8)
jae 0xff65
leaq 0x1(%rax), %r8
movl $0x1, %edx
cmpq $0x3, %rax
movq %r8, %rax
jb 0xff4c
movb (%rcx), %al
leal -0x3a(%rax), %edx
cmpb $-0xa, %dl
setae %dl
cmpb $0x2d, %al
sete %al
orb %dl, %al
jne 0xfecf
testl %esi, %esi
je 0xff9f
movl $0x3, %eax
notq -0x20(%rsp,%rax,8)
addq $-0x1, %rax
jb 0xff86
xorl %eax, %eax
movzbl %al, %ecx
incb %al
incq -0x20(%rsp,%rcx,8)
je 0xff93
movq -0x18(%rsp), %rax
orq -0x20(%rsp), %rax
orq -0x10(%rsp), %rax
orq -0x8(%rsp), %rax
je 0x10069
movb $0x4, %dl
xorl %esi, %esi
xorl %eax, %eax
decb %dl
movl $0x38, %edi
movb $0x7, %r8b
cmpq $-0x8, %rdi
je 0x10001
movzbl %dl, %edx
movq -0x20(%rsp,%rdx,8), %r9
movl %edi, %ecx
andb $-0x8, %cl
shrq %cl, %r9
leal (,%rdx,8), %ecx
addb %r8b, %cl
addq $-0x8, %rdi
decb %r8b
movzbl %cl, %ecx
movzbl %al, %eax
testb %r9b, %r9b
cmovnel %ecx, %eax
cmovnel %esi, %edx
je 0xffc9
testb %dl, %dl
jne 0xffbf
movb 0x2049e20(%rip), %r9b   # 0x2059e2c
movzbl %al, %edx
xorl %esi, %esi
leaq 0x204f638(%rip), %rdi   # 0x205f650
xorl %r8d, %r8d
movq %rsi, %r10
xorl %ecx, %ecx
movl %r9d, %r11d
cmpq %rdx, %r10
ja 0x10055
movq -0x20(%rsp,%r8,8), %rbx
shrq %cl, %rbx
leal 0x1(%r11), %r9d
movb %r9b, 0x2049df1(%rip)   # 0x2059e2c
movzbl %r11b, %r11d
movb %bl, (%r11,%rdi)
addq $0x8, %rcx
incq %r10
movl %r9d, %r11d
cmpq $0x40, %rcx
jne 0x10023
jmp 0x10058
movl %r11d, %r9d
incq %r8
addq $0x8, %rsi
cmpq $0x4, %r8
jne 0x1001b
addb $0x60, %al
jmp 0x1006b
movb $0x5f, %al
popq %rbx
retq