// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r14
pushq %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x10(%rsp)
movaps %xmm0, -0x20(%rsp)
movq (%rdi), %rdx
movabsq $0x4, %rax
movabsq $0x1, %rcx
movb (%rdx), %r8b
leal -0x3a(%r8), %r9d
cmpb $-0xa, %r9b
setb %r9b
cmpb $0x2d, %r8b
setne %r8b
testb %r9b, %r8b
jne 0xcd8e
xorl %r8d, %r8d
movq %rax, %r9
subq $0x1, %r9
jb 0xcd60
movzbl %r9b, %r11d
movq -0x20(%rsp,%r11,8), %r10
movl %r10d, %ebx
imulq $0xa, %rbx, %rbx
movl %ebx, %r14d
shrq $0x20, %r10
imulq $0xa, %r10, %r10
shrq $0x20, %rbx
addq %r10, %rbx
movq %rbx, %r10
shrq $0x20, %r10
shlq $0x20, %rbx
orq %r14, %rbx
movq %rbx, -0x20(%rsp,%r11,8)
movq %r8, %r11
testq %r11, %r11
je 0xcd5a
addq %r10, (%rsp,%r11)
leaq 0x8(%r11), %r11
movq %rcx, %r10
jb 0xcd48
addq $-0x8, %r8
jmp 0xcd0a
leaq 0x1(%rdx), %r8
movq %r8, (%rdi)
movb (%rdx), %dl
addb $-0x30, %dl
movzbl %dl, %edx
xorl %r9d, %r9d
cmpq $0x4, %r9
je 0xcd86
addq %rdx, -0x20(%rsp,%r9,8)
leaq 0x1(%r9), %r9
movq %rcx, %rdx
jb 0xcd72
movq %r8, %rdx
jmp 0xcce4
testl %esi, %esi
je 0xcdbd
movabsq $0x3, %rax
cmpq $-0x1, %rax
je 0xcdaf
movzbl %al, %ecx
notq -0x20(%rsp,%rcx,8)
decq %rax
jmp 0xcd9c
xorl %eax, %eax
movzbl %al, %ecx
incb %al
incq -0x20(%rsp,%rcx,8)
je 0xcdb1
movdqa -0x20(%rsp), %xmm0
por -0x10(%rsp), %xmm0
pxor %xmm1, %xmm1
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %eax
xorl $0xf, %eax
je 0xce9e
movb $0x4, %dl
xorl %eax, %eax
movabsq $0x38, %rsi
leal (,%rdx,8), %edi
subb $0x1, %dl
jb 0xce32
movzbl %dl, %ecx
movq -0x20(%rsp,%rcx,8), %r9
movl %edi, %r8d
movq %rsi, %rcx
leaq -0x8(%rcx), %r10
cmpq $-0x10, %r10
je 0xce25
andb $-0x8, %cl
movq %r9, %r11
shrq %cl, %r11
decb %r8b
movq %r10, %rcx
testb %r11b, %r11b
je 0xce05
jmp 0xce2b
addb $-0x8, %dil
jmp 0xcdf2
xorl %edx, %edx
movl %r8d, %eax
jmp 0xcdeb
movb 0x2049ff4(%rip), %dl    # 0x2056e2c
movzbl %al, %esi
xorl %edi, %edi
leaq 0x204f80c(%rip), %r8    # 0x205c650
xorl %r9d, %r9d
cmpq $0x4, %r9
je 0xce9a
movzbl %dl, %edx
xorl %ecx, %ecx
xorl %r10d, %r10d
cmpq $0x7, %r10
ja 0xce8e
leaq (%rdi,%r10), %r11
cmpq %rsi, %r11
ja 0xce8e
movq -0x20(%rsp,%r9,8), %r11
shrq %cl, %r11
leaq (%rdx,%r10), %rbx
leal (%rdx,%r10), %ebp
incb %bpl
movb %bpl, 0x2049fae(%rip)   # 0x2056e2c
movzbl %bl, %ebx
movb %r11b, (%rbx,%r8)
incq %r10
addq $0x8, %rcx
jmp 0xce55
incq %r9
addq $0x8, %rdi
addl %r10d, %edx
jmp 0xce47
addb $0x60, %al
jmp 0xcea0
movb $0x5f, %al
popq %rbx
popq %r14
popq %rbp
retq