// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x182a0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x18340
cmpl $0x0, %eax
je 0x175a9
movq -0x8(%rbp), %rdi
callq 0x17210
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rdi
callq 0x182a0
movzbl -0x9(%rbp), %edi
callq 0x171e0
jmp 0x1780e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %edi
callq 0x17e20
cmpl $0x0, %eax
je 0x175cb
movq -0x8(%rbp), %rdi
callq 0x18360
jmp 0x1780e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0x175e8
movq -0x8(%rbp), %rdi
callq 0x18420
jmp 0x1780e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x17636
testb $0x1, 0x2049816(%rip)   # 0x2060e14
jne 0x17628
movq 0x89f1(%rip), %rax      # 0x1fff8
movq (%rax), %rdi
movl 0x2049808(%rip), %edx   # 0x2060e18
leaq 0x4dea(%rip), %rsi      # 0x1c401
movb $0x0, %al
callq 0x31e0
movl $0x1, %edi
callq 0x3280
movq -0x8(%rbp), %rdi
callq 0x18420
jmp 0x1780e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x17653
movq -0x8(%rbp), %rdi
callq 0x18600
jmp 0x1780e
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x159b0
movb %al, -0xa(%rbp)
movq -0x8(%rbp), %rdi
callq 0x182a0
movb %al, -0xb(%rbp)
movzbl -0xa(%rbp), %edi
callq 0x171e0
movsbl -0xb(%rbp), %eax
cmpl $0x28, %eax
je 0x17689
jmp 0x1780e
movq -0x8(%rbp), %rdi
movl $0x28, %esi
callq 0x186d0
movb $0x0, -0xc(%rbp)
movzbl -0xc(%rbp), %eax
movzbl -0xa(%rbp), %ecx
movl %ecx, %edx
leaq 0x39f4(%rip), %rcx      # 0x1b0a0
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jge 0x177ee
cmpb $0x0, -0xc(%rbp)
je 0x176d5
movq -0x8(%rbp), %rdi
callq 0x182a0
movq -0x8(%rbp), %rdi
movl $0x2c, %esi
callq 0x186d0
movq -0x8(%rbp), %rdi
callq 0x182a0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x18340
cmpl $0x0, %eax
je 0x17705
movq -0x8(%rbp), %rdi
callq 0x17210
movzbl %al, %edi
callq 0x171e0
jmp 0x177df
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %edi
callq 0x17e20
cmpl $0x0, %eax
je 0x17727
movq -0x8(%rbp), %rdi
callq 0x18360
jmp 0x177dd
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x17744
movq -0x8(%rbp), %rdi
callq 0x18600
jmp 0x177db
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x159b0
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, %ecx
leaq 0x3a3c(%rip), %rax      # 0x1b1a0
cmpb $0x0, (%rax,%rcx)
jne 0x177b5
movq 0x8887(%rip), %rax      # 0x1fff8
movq (%rax), %rdi
movzbl -0xa(%rbp), %eax
movl %eax, %ecx
leaq 0x8a5f(%rip), %rax      # 0x201e0
movq (%rax,%rcx,8), %rdx
movzbl -0x19(%rbp), %eax
movl %eax, %ecx
leaq 0x8a4e(%rip), %rax      # 0x201e0
movq (%rax,%rcx,8), %rcx
movl 0x204967b(%rip), %r8d   # 0x2060e18
leaq 0x4c9a(%rip), %rsi      # 0x1c43e
movb $0x0, %al
callq 0x31e0
movl $0x1, %edi
callq 0x3280
movzbl -0x19(%rbp), %eax
movl %eax, %ecx
leaq 0x39de(%rip), %rax      # 0x1b1a0
movzbl (%rax,%rcx), %ecx
subl $0x1, %ecx
movzbl -0xc(%rbp), %eax
addl %ecx, %eax
movb %al, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x17560
jmp 0x177dd
jmp 0x177df
jmp 0x177e1
movb -0xc(%rbp), %al
addb $0x1, %al
movb %al, -0xc(%rbp)
jmp 0x1769b
movq -0x8(%rbp), %rdi
callq 0x182a0
movq -0x8(%rbp), %rdi
movl $0x29, %esi
callq 0x186d0
movq -0x8(%rbp), %rdi
callq 0x182a0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)