// File: /workspace/github_cpp_makefile_star2_O1/philpoore[P]Math/./src/Parser.cpp
// Function: Parser::parseExpr(int)
AstExpr* Parser::parseExpr(int precedence_level) {
    AstExpr* left;
    consumeWhiteSpace();
    if (peekIs(TOKEN_EOF) || peekIs(TOKEN_RCURLY)) {
        return nullptr;
    } else if (peekIs(TOKEN_LPAREN)) {
        expect(TOKEN_LPAREN);
        left = parseExpr();
        expect(TOKEN_RPAREN, "Unmatched parentheses");
    } else {
        left = parseSubExpr();
    }

    while (true) {
        consumeWhiteSpace();
        Token t = peek();
        if (t.type == TOKEN_SEMI) {
            break;
        }
        if (!t.isBinOp()) {
            break;
        }

        int p = precedence(Token_to_bin_op(t.type));

        if (p <= precedence_level) {
            break;
        }

        Token bin_op_token = consume();
        AstBinaryOp* bin_op = new AstBinaryOp(bin_op_token.type);

        bin_op->left = left;
        bin_op->right = parseExpr(p);
        assert(bin_op->right != nullptr);
        left = (AstExpr*)bin_op;
    }
    return left;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %esi, -0x34(%rbp)
movq %rdi, %r14
callq 0x8970
movq %r14, %rdi
movl $0x112, %esi            # imm = 0x112
callq 0x838c
testb %al, %al
jne 0x9685
movq %r14, %rdi
movl $0x10d, %esi            # imm = 0x10D
callq 0x838c
testb %al, %al
je 0x9692
movq $0x0, -0x30(%rbp)
jmp 0x991d
movq %r14, %rdi
movl $0x10a, %esi            # imm = 0x10A
callq 0x838c
testb %al, %al
je 0x97ac
leaq -0xc8(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x3df4(%rip), %rdx      # 0xd4ad
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movq %rdx, %rsi
callq 0xb59a
leaq -0x138(%rbp), %rdi
movq %r14, %rsi
movl $0x10a, %edx            # imm = 0x10A
movq %rbx, %rcx
callq 0x8468
leaq -0x120(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9701
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x3240
movq -0xd8(%rbp), %rdi
cmpq %r15, %rdi
je 0x971c
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x3240
movq %r14, %rdi
movl $0xffffd8f1, %esi       # imm = 0xFFFFD8F1
callq 0x9644
movq %rax, %rbx
leaq -0xa8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x3c7b(%rip), %rsi      # 0xd3ba
leaq 0x3c89(%rip), %rdx      # 0xd3cf
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
callq 0xb59a
leaq -0x108(%rbp), %rdi
movq %r14, %rsi
movl $0x10b, %edx            # imm = 0x10B
movq %r15, %rcx
callq 0x8468
leaq -0xf0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x978b
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x3240
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
movq %rbx, -0x30(%rbp)
je 0x97b8
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x3240
jmp 0x97b8
movq %r14, %rdi
callq 0x9f60
movq %rax, -0x30(%rbp)
leaq -0x80(%rbp), %r12
movq %r14, %rdi
callq 0x8970
movslq 0x1c(%r14), %rax
movq (%r14), %rbx
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movl (%rbx,%r15), %eax
movl %eax, -0x98(%rbp)
movq %r12, -0x90(%rbp)
movq 0x8(%rbx,%r15), %rsi
movq 0x10(%rbx,%r15), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %rdi
callq 0xb374
movq 0x28(%rbx,%r15), %rax
movq %rax, -0x70(%rbp)
movl -0x98(%rbp), %eax
addl $0xfffffefc, %eax       # imm = 0xFFFFFEFC
cmpl $0x5, %eax
ja 0x98f9
movl $0xfffffff5, %ecx       # imm = 0xFFFFFFF5
cmoval %ecx, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x5, %eax
ja 0x983a
movl %eax, %eax
leaq 0x38e2(%rip), %rcx      # 0xd118
movl (%rcx,%rax,4), %r13d
cmpl -0x34(%rbp), %r13d
jle 0x98f9
movslq 0x1c(%r14), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x1c(%r14)
movq (%r14), %r15
leaq (%rax,%rax,2), %rbx
shlq $0x4, %rbx
movl (%r15,%rbx), %eax
movl %eax, -0x68(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x8(%r15,%rbx), %rsi
movq 0x10(%r15,%rbx), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0xb374
addq %rbx, %r15
movq 0x28(%r15), %rax
movq %rax, -0x40(%rbp)
movl $0x18, %edi
callq 0x3230
movq %rax, %r15
movl -0x68(%rbp), %eax
movl $0x5, (%r15)
leal -0x104(%rax), %ecx
addl $0xffffff06, %eax       # imm = 0xFFFFFF06
cmpl $0x6, %ecx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovael %ecx, %eax
movl %eax, 0x4(%r15)
movq -0x30(%rbp), %rax
movq %rax, 0x8(%r15)
movq %r14, %rdi
movl %r13d, %esi
callq 0x9644
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x9933
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x98f0
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3240
movb $0x1, %r13b
movq %r15, -0x30(%rbp)
jmp 0x98fc
xorl %r13d, %r13d
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x9914
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3240
testb %r13b, %r13b
jne 0x97bc
movq -0x30(%rbp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3acd(%rip), %rdi      # 0xd407
leaq 0x3adf(%rip), %rsi      # 0xd420
leaq 0x3ae9(%rip), %rcx      # 0xd431
movl $0x104, %edx            # imm = 0x104
callq 0x3170
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
je 0x99bb
movq -0xa8(%rbp), %rsi
jmp 0x99b3
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r15, %rdi
je 0x99bb
movq -0xc8(%rbp), %rsi
jmp 0x99b3
movq %rax, %rbx
jmp 0x99a3
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x99a3
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3240
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x99bb
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3240
movq %rbx, %rdi
callq 0x3370
nop