// File: /workspace/github_cpp_makefile_star2_O1/baziotis[P]minijava-cpp/parse.cpp
// Function: parse_expr()
static Expression *parse_expr() {
    Expression *e1 = parse_expr_clause();
    assert(e1);
    if (e1->kind == EXPR::UNDEFINED) {
        goto Lerror;
    }
    if (!is_op(token.kind)) {
        // Handle ArrayLength and MessageSend.
        if (match_token(TOK::DOT)) {
            Expression *expr;
            if (is_token(TOK::ID)) {
                const char *id = token.id;
                next_token();
                if(id == length_) {  // ArrayLength
                    expr = new Expression;
                    expr->loc = loc;
                    expr->kind = EXPR::ARR_LEN;
                    expr->e1 = e1;
                } else {  // MessageSend
                    BinaryExpression *be = new BinaryExpression;
                    be->loc = loc;
                    if (!match_token(TOK::LPAR)) {
                        // Maybe don't advance here because of expect_token* ?
                        expect_token_in_rule(TOK::LPAR, "message send expression");
                        be->kind = EXPR::UNDEFINED;
                    } else {
                        be->kind = EXPR::MSG_SEND;
                        be->e1 = e1;
                        be->msd = new MessageSendData;
                        be->msd->id = id;
                        be->msd->expr_list = parse_expr_list();
                        expect_token_in_rule(TOK::RPAR, "message send expression");
                    }
                    expr = be;
                }
            } else {  // Error
                goto Lerror;
            }
            return expr;
        }
        // Simple Primary Expression (or Clause)
        return e1;
    }
    TOK kind;
    BinaryExpression *bin_expr;
    // Note: This is _not_ a loop; We can't have 1 + 2 + 3. But we
    // can have: (1 + 2) + 3
    if (is_op(token.kind)) {
        bin_expr = new BinaryExpression;
        bin_expr->loc = loc;
        bin_expr->e1 = e1;
        kind = token.kind;
        next_token();
        if (kind == TOK::AND_AND) {
            // AndExpression is the only one that can have as operands
            // `Clause`s.
            bin_expr->kind = EXPR::AND;
            bin_expr->e2 = parse_expr_clause();
            assert(bin_expr->e2);
        } else {
            Expression *e2 = parse_expr_primary();
            assert(e2);
            bin_expr->e2 = e2;
            if (e2->kind == EXPR::UNDEFINED) {
                // No type-checking here! We don't start check what the expression is!
                // But, since we got an undefined, we can issue a better message than
                // "expected expression".
                syntax_error("Expected integer expression as a right-hand-side "
                             "expression for operator `", token_name(kind), "`.");
                goto Lerror;
            }
            switch (kind) {
            case TOK::LT:       bin_expr->kind = EXPR::CMP;       break;
            case TOK::PLUS:     bin_expr->kind = EXPR::PLUS;      break;
            case TOK::MINUS:    bin_expr->kind = EXPR::MINUS;     break;
            case TOK::STAR:     bin_expr->kind = EXPR::TIMES;     break;
            case TOK::LBRACKET:
            {
                bin_expr->kind = EXPR::ARR_LOOK;
                expect_token_in_rule(TOK::RBRACKET, "array lookup expression");
            } break;
            default: assert(0);
            }
        }
    }
    return bin_expr;
Lerror:
    Expression *expr = new Expression;
    expr->loc = loc;
    expr->kind = EXPR::UNDEFINED;
    return expr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
callq 0x795c
testq %rax, %rax
je 0x7820
movq %rax, %r14
cmpl $0x0, 0x4(%rax)
je 0x77ea
leaq 0x1214c(%rip), %r13     # 0x19698
movl (%r13), %eax
leal -0x1f(%rax), %ecx
cmpl $0x6, %ecx
jae 0x75c4
movl $0x20, %edi
movl $0x2, %esi
callq 0x23f5
movq %rax, %rbx
leaq 0x1211f(%rip), %rax     # 0x19690
movl (%rax), %eax
movl %eax, (%rbx)
movq %r14, 0x10(%rbx)
movl (%r13), %r14d
callq 0x3a45
cmpl $0x1f, %r14d
jne 0x76af
movl $0x1, 0x4(%rbx)
callq 0x795c
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x780e
leaq 0xa87b(%rip), %rdi      # 0x11e27
leaq 0xa816(%rip), %rsi      # 0x11dc9
leaq 0xa83c(%rip), %rcx      # 0x11df6
movl $0x111, %edx            # imm = 0x111
callq 0x20b0
cmpl $0x1d, %eax
jne 0x76f2
callq 0x3a45
movl (%r13), %ebp
cmpl $0x8, %ebp
jne 0x77e5
movq 0x8(%r13), %r15
callq 0x3a45
cmpq 0x12469(%rip), %r15     # 0x19a58
je 0x7724
movl $0x20, %edi
movl $0x2, %esi
callq 0x23f5
movq %rax, %rbx
leaq 0x12082(%rip), %rax     # 0x19690
movl (%rax), %eax
movl %eax, (%rbx)
cmpl $0x3, (%r13)
jne 0x7751
callq 0x3a45
movl $0x8, 0x4(%rbx)
movq %r14, 0x10(%rbx)
movl $0x20, %edi
movl $0x2, %esi
callq 0x23f5
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, 0x18(%rax)
movq %rax, 0x18(%rbx)
movq %r15, (%rax)
movq %rcx, 0x10(%rsp)
movaps %xmm0, (%rsp)
cmpl $0x19, (%r13)
je 0x77bf
movq %rsp, %r14
callq 0x751c
movq %rax, %r15
movq 0x8(%rsp), %r12
incq %r12
cmpq (%rsp), %r12
jbe 0x7688
movq %r14, %rdi
movq %r12, %rsi
callq 0x7e34
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %r15, (%rcx,%rax,8)
movq %r12, 0x8(%rsp)
movl (%r13), %eax
cmpl $0x1c, %eax
jne 0x77a4
callq 0x3a45
jmp 0x7667
callq 0x79a0
testq %rax, %rax
je 0x783f
movq %rax, 0x18(%rbx)
movl 0x4(%rax), %ebp
testl %ebp, %ebp
je 0x76fa
addl $-0x20, %r14d
cmpl $0x4, %r14d
ja 0x785e
leaq 0xa197(%rip), %rax      # 0x11874
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x2, 0x4(%rbx)
jmp 0x779e
movq %r14, %rbx
jmp 0x780e
movl %r14d, %edi
callq 0x8258
leaq 0xa72b(%rip), %rdi      # 0x11e34
leaq 0x93b2(%rip), %rdx      # 0x10ac2
movq %rax, %rsi
callq 0x787d
movl $0xa, %edi
callq 0x2160
jmp 0x779e
movl $0x18, %edi
movl $0x2, %esi
callq 0x23f5
movq %rax, %rbx
leaq 0x11f53(%rip), %rax     # 0x19690
movl (%rax), %eax
movl %eax, (%rbx)
movl $0x7, 0x4(%rbx)
movq %r14, 0x10(%rbx)
jmp 0x77e5
leaq 0xa6b7(%rip), %rsi      # 0x11e0f
movl $0x3, %edi
callq 0x6622
movl $0x0, 0x4(%rbx)
jmp 0x77e5
movl $0x6, 0x4(%rbx)
leaq 0xa706(%rip), %rsi      # 0x11e7f
movl $0x1b, %edi
callq 0x6622
jmp 0x779e
movl $0x4, 0x4(%rbx)
jmp 0x779e
movl $0x5, 0x4(%rbx)
jmp 0x779e
movl $0x3, 0x4(%rbx)
testl %ebp, %ebp
jne 0x780e
jmp 0x77ea
cmpl $0x19, %eax
je 0x77bf
leaq 0xa6e7(%rip), %rdi      # 0x11e97
callq 0x6775
movl $0xa, %edi
callq 0x2160
movq 0x18(%rbx), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rax)
movaps (%rsp), %xmm0
movups %xmm0, 0x8(%rax)
leaq 0xa634(%rip), %rsi      # 0x11e0f
movl $0x19, %edi
callq 0x6622
cmpl $0x8, %ebp
je 0x780e
movl $0x18, %edi
movl $0x2, %esi
callq 0x23f5
movq %rax, %rbx
leaq 0x11e8d(%rip), %rax     # 0x19690
movl (%rax), %eax
movl %eax, (%rbx)
movl $0x0, 0x4(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb662(%rip), %rdi      # 0x12e89
leaq 0xa59b(%rip), %rsi      # 0x11dc9
leaq 0xa5c1(%rip), %rcx      # 0x11df6
movl $0xd9, %edx
callq 0x20b0
leaq 0xb64a(%rip), %rdi      # 0x12e90
leaq 0xa57c(%rip), %rsi      # 0x11dc9
leaq 0xa5a2(%rip), %rcx      # 0x11df6
movl $0x114, %edx            # imm = 0x114
callq 0x20b0
leaq 0xae4d(%rip), %rdi      # 0x126b2
leaq 0xa55d(%rip), %rsi      # 0x11dc9
leaq 0xa583(%rip), %rcx      # 0x11df6
movl $0x128, %edx            # imm = 0x128
callq 0x20b0