// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
callq 0x7848
testq %rax, %rax
je 0x7708
movq %rax, %r14
cmpl $0x0, 0x4(%rax)
je 0x7620
leaq 0x13246(%rip), %r13     # 0x1a698
movl (%r13), %eax
leal -0x1f(%rax), %ecx
cmpl $0x6, %ecx
jae 0x74ca
movl $0x20, %edi
movl $0x2, %esi
callq 0x23ef
movq %rax, %rbx
leaq 0x13219(%rip), %rax     # 0x1a690
movl (%rax), %eax
movl %eax, (%rbx)
movq %r14, 0x10(%rbx)
movl (%r13), %r14d
callq 0x3a62
cmpl $0x1f, %r14d
jne 0x75b4
movl $0x1, 0x4(%rbx)
callq 0x7848
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x7644
leaq 0xb83d(%rip), %rdi      # 0x12cef
leaq 0xb7f0(%rip), %rsi      # 0x12ca9
leaq 0xb7fe(%rip), %rcx      # 0x12cbe
movl $0x111, %edx            # imm = 0x111
callq 0x20b0
cmpl $0x1d, %eax
jne 0x75f3
callq 0x3a62
cmpl $0x8, (%r13)
jne 0x7620
movq 0x8(%r13), %r15
callq 0x3a62
cmpq 0x13565(%rip), %r15     # 0x1aa58
je 0x7655
movl $0x20, %edi
movl $0x2, %esi
callq 0x23ef
movq %rax, %rbx
leaq 0x1317e(%rip), %rax     # 0x1a690
movl (%rax), %eax
movl %eax, (%rbx)
cmpl $0x3, (%r13)
jne 0x767f
callq 0x3a62
movl $0x8, 0x4(%rbx)
movq %r14, 0x10(%rbx)
movl $0x20, %edi
movl $0x2, %esi
callq 0x23ef
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 0x76dd
movq %rsp, %r14
callq 0x7423
movq %rax, %r15
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %r12
cmpq (%rsp), %r12
jbe 0x7592
movq %r14, %rdi
movq %r12, %rsi
callq 0x7d2a
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %r15, (%rcx,%rax,8)
movq %r12, 0x8(%rsp)
movl (%r13), %eax
cmpl $0x1c, %eax
jne 0x76c2
callq 0x3a62
jmp 0x756b
callq 0x788c
testq %rax, %rax
je 0x7727
movq %rax, 0x18(%rbx)
cmpl $0x0, 0x4(%rax)
je 0x75f8
addl $-0x20, %r14d
cmpl $0x4, %r14d
ja 0x7746
leaq 0xb173(%rip), %rax      # 0x12754
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x2, 0x4(%rbx)
jmp 0x7644
movq %r14, %rbx
jmp 0x7644
movl %r14d, %edi
callq 0x8150
leaq 0xb6f5(%rip), %rdi      # 0x12cfc
leaq 0xa430(%rip), %rdx      # 0x11a3e
movq %rax, %rsi
callq 0x7765
movl $0xa, %edi
callq 0x2160
movl $0x18, %edi
movl $0x2, %esi
callq 0x23ef
movq %rax, %rbx
leaq 0x13057(%rip), %rax     # 0x1a690
movl (%rax), %eax
movl %eax, (%rbx)
movl $0x0, 0x4(%rbx)
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x18, %edi
movl $0x2, %esi
callq 0x23ef
movq %rax, %rbx
leaq 0x13022(%rip), %rax     # 0x1a690
movl (%rax), %eax
movl %eax, (%rbx)
movl $0x7, 0x4(%rbx)
movq %r14, 0x10(%rbx)
jmp 0x7644
leaq 0xb651(%rip), %rsi      # 0x12cd7
movl $0x3, %edi
callq 0x6606
jmp 0x763d
movl $0x6, 0x4(%rbx)
leaq 0xb6a7(%rip), %rsi      # 0x12d47
movl $0x1b, %edi
jmp 0x76fe
movl $0x4, 0x4(%rbx)
jmp 0x7644
movl $0x5, 0x4(%rbx)
jmp 0x7644
movl $0x3, 0x4(%rbx)
jmp 0x7644
cmpl $0x19, %eax
je 0x76dd
leaq 0xb691(%rip), %rdi      # 0x12d5f
callq 0x675d
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 0xb5de(%rip), %rsi      # 0x12cd7
movl $0x19, %edi
callq 0x6606
jmp 0x7644
leaq 0xc6eb(%rip), %rdi      # 0x13dfa
leaq 0xb593(%rip), %rsi      # 0x12ca9
leaq 0xb5a1(%rip), %rcx      # 0x12cbe
movl $0xd9, %edx
callq 0x20b0
leaq 0xc6d3(%rip), %rdi      # 0x13e01
leaq 0xb574(%rip), %rsi      # 0x12ca9
leaq 0xb582(%rip), %rcx      # 0x12cbe
movl $0x114, %edx            # imm = 0x114
callq 0x20b0
leaq 0xbed5(%rip), %rdi      # 0x13622
leaq 0xb555(%rip), %rsi      # 0x12ca9
leaq 0xb563(%rip), %rcx      # 0x12cbe
movl $0x128, %edx            # imm = 0x128
callq 0x20b0