// File: /workspace/github_c_makefile_star2_O3/wjmelements[P]evm/src/scan.c
// Function: scanOp
static void scanOp(const char **iter) {
    scanWaste(iter);
    if (isConstant(*iter)) {
        op_t op = parseConstant(iter);
        scanWaste(iter);
        scanstackPush(op);
        return;
    }
    if (isLowerCase(**iter)) {
        scanLabel(iter);
        return;
    }
    if (**iter == '{' ) {
        scanDataSection(iter);
        return;
    }
    if (**iter == ',') {
        if (!inDataSection) {
            fprintf(stderr, "Found unexpected comma when scanning for next op at line %u\n", lineNumber);
            exit(1);
        }
        scanDataSection(iter);
        return;
    }
    if (**iter == '#') {
        scanDataLen(iter);
        return;
    }
    op_t op = parseOp(*iter, iter);
    char next = scanWaste(iter);
    scanstackPush(op);
    if (next != '(') {
        return;
    }
    scanChar(iter, '(');
    for (uint8_t i = 0; i < argCount[op]; i++) {
        if (i) {
            scanWaste(iter);
            scanChar(iter, ',');
        }
        scanWaste(iter);
        if (isConstant(*iter)) {
            scanstackPush(parseConstant(iter));
        } else if (isLowerCase(**iter)) {
            scanLabel(iter);
        } else if (**iter == '#') {
            scanDataLen(iter);
        } else {
            const char *end;
            op_t next = parseOp(*iter, &end);
            // TODO maybe next can be read from stack after scanOp instead of parsing twice
            if (!retCount[next]) {
                fprintf(stderr, "When reading args for op %s found unexpected op %s, at line %u", opString[op], opString[next], lineNumber);
                exit(1);
            }
            i += (retCount[next] - 1);
            scanOp(iter);
        }
    }
    scanWaste(iter);
    scanChar(iter, ')');
    scanWaste(iter);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rax
movl 0x204905f(%rip), %edi   # 0x2058e28
movabsq $0x400330800000000, %r12 # imm = 0x400330800000000
movzbl (%rax), %ecx
cmpq $0x3a, %rcx
ja 0xfde8
cmpq $0x2f, %rcx
je 0xfe30
btq %rcx, %r12
jb 0xfe4c
cmpl $0x7b, %ecx
je 0xfe4c
cmpl $0x7d, %ecx
je 0xfe4c
leal -0x3a(%rcx), %edx
cmpb $-0xb, %dl
ja 0xfe4c
leal -0x5b(%rcx), %esi
cmpb $-0x1b, %sil
ja 0xfe4c
leal -0x7b(%rcx), %esi
cmpb $-0x1a, %sil
setae %sil
testl %ecx, %ecx
sete %r8b
orb %sil, %r8b
jne 0xfe2b
cmpl $0xa, %ecx
jne 0xfe26
incl %edi
movl %edi, 0x2049002(%rip)   # 0x2058e28
incq %rax
jmp 0xfe47
cmpl $0x2f, %ecx
jne 0xfe4f
incq %rax
movq %rax, (%rbx)
cmpb $0xa, (%rax)
leaq 0x1(%rax), %rax
jne 0xfe33
incl %edi
movl %edi, 0x2048fe1(%rip)   # 0x2058e28
movq %rax, (%rbx)
jmp 0xfdd3
leal -0x3a(%rcx), %edx
cmpb $-0xa, %dl
setb %dl
cmpl $0x2d, %ecx
setne %sil
testb %dl, %sil
je 0xff37
leal -0x7b(%rcx), %edx
cmpb $-0x1a, %dl
jae 0xffee
cmpl $0x23, %ecx
je 0x10027
cmpl $0x2c, %ecx
je 0x10004
cmpl $0x7b, %ecx
je 0x10011
movq %rax, %rdi
movq %rbx, %rsi
callq 0xed10
movl %eax, %ebp
movq (%rbx), %rcx
movl 0x2048f86(%rip), %eax   # 0x2058e28
movzbl (%rcx), %edx
cmpq $0x3a, %rdx
ja 0xfebb
cmpq $0x2f, %rdx
je 0xff18
btq %rdx, %r12
jb 0x1003d
cmpl $0x7b, %edx
je 0x1003d
cmpl $0x7d, %edx
je 0x1003d
leal -0x3a(%rdx), %esi
cmpb $-0xb, %sil
ja 0x10246
leal -0x5b(%rdx), %esi
cmpb $-0x1a, %sil
jae 0x10246
leal -0x7b(%rdx), %esi
cmpb $-0x1a, %sil
setae %sil
testb %dl, %dl
sete %dil
orb %sil, %dil
jne 0xff0f
cmpb $0xa, %dl
jne 0xff0a
incl %eax
movl %eax, 0x2048f1e(%rip)   # 0x2058e28
incq %rcx
jmp 0xff2f
cmpb $0x2f, %dl
jne 0x1003d
incq %rcx
movq %rcx, (%rbx)
cmpb $0xa, (%rcx)
leaq 0x1(%rcx), %rcx
jne 0xff1b
incl %eax
movl %eax, 0x2048ef9(%rip)   # 0x2058e28
movq %rcx, (%rbx)
jmp 0xfea2
movq %rbx, %rdi
callq 0xfa32
movq (%rbx), %rdx
movl 0x2048ee0(%rip), %ecx   # 0x2058e28
movzbl (%rdx), %esi
cmpq $0x3a, %rsi
ja 0xff5d
cmpq $0x2f, %rsi
je 0xffa9
btq %rsi, %r12
jb 0xffc5
cmpl $0x7b, %esi
je 0xffc5
cmpl $0x7d, %esi
je 0xffc5
leal -0x3a(%rsi), %edi
cmpb $-0xb, %dil
ja 0xffc5
leal -0x5b(%rsi), %edi
cmpb $-0x1b, %dil
ja 0xffc5
leal -0x7b(%rsi), %edi
cmpb $-0x1a, %dil
setae %dil
testb %sil, %sil
sete %r8b
orb %dil, %r8b
jne 0xffa3
cmpb $0xa, %sil
jne 0xff9e
incl %ecx
movl %ecx, 0x2048e8a(%rip)   # 0x2058e28
incq %rdx
jmp 0xffc0
cmpb $0x2f, %sil
jne 0xffc5
incq %rdx
movq %rdx, (%rbx)
cmpb $0xa, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0xffac
incl %ecx
movl %ecx, 0x2048e68(%rip)   # 0x2058e28
movq %rdx, (%rbx)
jmp 0xff48
movzbl 0x2048e60(%rip), %ecx   # 0x2058e2c
leal 0x1(%rcx), %edx
movb %dl, 0x2048e57(%rip)    # 0x2058e2c
leaq 0x204e674(%rip), %rdx   # 0x205e650
movb %al, (%rcx,%rdx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x106e0
cmpb $0x0, 0x2048e19(%rip)   # 0x2058e24
je 0x1026e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x108ca
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c56
movzbl 0x2048de8(%rip), %eax   # 0x2058e2c
leal 0x1(%rax), %ecx
movb %cl, 0x2048ddf(%rip)    # 0x2058e2c
leaq 0x204e5fc(%rip), %r13   # 0x205e650
movb %bpl, (%rax,%r13)
cmpb $0x28, %dl
jne 0xffdf
movq %rbx, %rdi
movl $0x28, %esi
callq 0x10e15
movzbl %bpl, %r14d
leaq 0x2e6b(%rip), %rax      # 0x12ee0
movb (%rax,%r14), %bpl
testb %bpl, %bpl
je 0x10224
xorl %r15d, %r15d
testb %r15b, %r15b
je 0x1011e
movq (%rbx), %rcx
movl 0x2048d91(%rip), %eax   # 0x2058e28
movzbl (%rcx), %edx
cmpq $0x3a, %rdx
ja 0x100ac
cmpq $0x2f, %rdx
je 0x100f5
btq %rdx, %r12
jb 0x10111
cmpl $0x7b, %edx
je 0x10111
cmpl $0x7d, %edx
je 0x10111
leal -0x3a(%rdx), %esi
cmpb $-0xb, %sil
ja 0x10111
leal -0x5b(%rdx), %esi
cmpb $-0x1b, %sil
ja 0x10111
leal -0x7b(%rdx), %esi
cmpb $-0x1a, %sil
setae %sil
testb %dl, %dl
sete %dil
orb %sil, %dil
jne 0x100f0
cmpb $0xa, %dl
jne 0x100eb
incl %eax
movl %eax, 0x2048d3d(%rip)   # 0x2058e28
incq %rcx
jmp 0x1010c
cmpb $0x2f, %dl
jne 0x10111
incq %rcx
movq %rcx, (%rbx)
cmpb $0xa, (%rcx)
leaq 0x1(%rcx), %rcx
jne 0x100f8
incl %eax
movl %eax, 0x2048d1c(%rip)   # 0x2058e28
movq %rcx, (%rbx)
jmp 0x10097
movq %rbx, %rdi
movl $0x2c, %esi
callq 0x10e15
movq (%rbx), %rdi
movl 0x2048d01(%rip), %eax   # 0x2058e28
movzbl (%rdi), %ecx
cmpq $0x3a, %rcx
ja 0x1013c
cmpq $0x2f, %rcx
je 0x10184
btq %rcx, %r12
jb 0x101a0
cmpl $0x7b, %ecx
je 0x101a0
cmpl $0x7d, %ecx
je 0x101a0
leal -0x3a(%rcx), %edx
cmpb $-0xb, %dl
ja 0x101a0
leal -0x5b(%rcx), %esi
cmpb $-0x1b, %sil
ja 0x101a0
leal -0x7b(%rcx), %esi
cmpb $-0x1a, %sil
setae %sil
testb %cl, %cl
sete %r8b
orb %sil, %r8b
jne 0x1017f
cmpb $0xa, %cl
jne 0x1017a
incl %eax
movl %eax, 0x2048cae(%rip)   # 0x2058e28
incq %rdi
jmp 0x1019b
cmpb $0x2f, %cl
jne 0x101a3
incq %rdi
movq %rdi, (%rbx)
cmpb $0xa, (%rdi)
leaq 0x1(%rdi), %rdi
jne 0x10187
incl %eax
movl %eax, 0x2048c8d(%rip)   # 0x2058e28
movq %rdi, (%rbx)
jmp 0x10127
leal -0x3a(%rcx), %edx
cmpb $-0xa, %dl
setb %al
cmpb $0x2d, %cl
setne %dl
testb %al, %dl
je 0x101c9
leal -0x7b(%rcx), %eax
cmpb $-0x1a, %al
jae 0x101e7
cmpb $0x23, %cl
jne 0x101f1
movq %rbx, %rdi
callq 0x10c56
jmp 0x10218
movq %rbx, %rdi
callq 0xfa32
movzbl 0x2048c54(%rip), %ecx   # 0x2058e2c
leal 0x1(%rcx), %edx
movb %dl, 0x2048c4b(%rip)    # 0x2058e2c
movb %al, (%rcx,%r13)
jmp 0x10218
movq %rbx, %rdi
callq 0x106e0
jmp 0x10218
movq %rsp, %rsi
callq 0xed10
movzbl %al, %esi
leaq 0x2ddd(%rip), %rax      # 0x12fe0
movb (%rax,%rsi), %al
testb %al, %al
je 0x10266
addb %al, %r15b
decb %r15b
movq %rbx, %rdi
callq 0xfdb2
incb %r15b
cmpb %bpl, %r15b
jb 0x10085
movq %rbx, %rdi
callq 0x1064c
movq %rbx, %rdi
movl $0x29, %esi
callq 0x10e15
movq %rbx, %rdi
callq 0x1064c
jmp 0xffdf
movzbl 0x2048bdf(%rip), %eax   # 0x2058e2c
leal 0x1(%rax), %ecx
movb %cl, 0x2048bd6(%rip)    # 0x2058e2c
leaq 0x204e3f3(%rip), %rcx   # 0x205e650
movb %bpl, (%rax,%rcx)
jmp 0xffdf
movq %r14, %rdi
callq 0x41f9
callq 0x41d6