// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x20, %rsp
callq 0x6b15
testq %rax, %rax
je 0x6a55
movq %rax, %r14
cmpl $0x0, 0x4(%rax)
je 0x69c4
leaq 0x11e87(%rip), %r15     # 0x18698
movl (%r15), %eax
addl $-0x1f, %eax
cmpl $0x6, %eax
jae 0x6880
pushq $0x20
popq %rdi
callq 0x6f0a
movq %rax, %rbx
leaq 0x11e62(%rip), %rax     # 0x18690
movl (%rax), %eax
movl %eax, (%rbx)
movq %r14, 0x10(%rbx)
movl (%r15), %r14d
callq 0x351d
cmpl $0x1f, %r14d
jne 0x6962
movl $0x1, 0x4(%rbx)
callq 0x6b15
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x69de
leaq 0x9517(%rip), %rdi      # 0xfd7f
leaq 0x94ca(%rip), %rsi      # 0xfd39
leaq 0x94d8(%rip), %rcx      # 0xfd4e
movl $0x111, %edx            # imm = 0x111
callq 0x20b0
pushq $0x1d
popq %rdi
callq 0x5d0d
testb %al, %al
je 0x69a1
cmpl $0x8, (%r15)
jne 0x69c4
movq 0x8(%r15), %r12
callq 0x351d
cmpq 0x121ae(%rip), %r12     # 0x18a58
je 0x69ee
pushq $0x20
popq %rdi
callq 0x6f0a
movq %rax, %rbx
leaq 0x11dce(%rip), %rax     # 0x18690
movl (%rax), %eax
movl %eax, (%rbx)
pushq $0x3
popq %rdi
callq 0x5d0d
testb %al, %al
je 0x6a11
movl $0x8, 0x4(%rbx)
movq %r14, 0x10(%rbx)
pushq $0x20
popq %rdi
callq 0x6f0a
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rax, 0x18(%rbx)
movq %r12, (%rax)
andq $0x0, 0x10(%rsp)
movaps %xmm0, (%rsp)
cmpl $0x19, (%r15)
je 0x693f
movq %rsp, %r14
pushq $0x1c
popq %rbp
callq 0x67e3
movq %r14, %rdi
movq %rax, %rsi
callq 0x6f12
cmpl $0x19, (%r15)
je 0x693f
movl %ebp, %edi
callq 0x5d0d
testb %al, %al
jne 0x6912
leaq 0x94b5(%rip), %rdi      # 0xfdef
callq 0x5de2
movq 0x18(%rbx), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rax)
movaps (%rsp), %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x940c(%rip), %rsi      # 0xfd67
pushq $0x19
jmp 0x6a32
callq 0x6b50
testq %rax, %rax
je 0x6a74
movq %rax, 0x18(%rbx)
cmpl $0x0, 0x4(%rax)
je 0x69a6
addl $-0x20, %r14d
cmpl $0x4, %r14d
ja 0x6a93
leaq 0x8e55(%rip), %rax      # 0xf7e4
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x2, 0x4(%rbx)
jmp 0x69de
movq %r14, %rbx
jmp 0x69de
movl %r14d, %edi
callq 0x735c
leaq 0x93d7(%rip), %rdi      # 0xfd8c
leaq 0x8056(%rip), %rdx      # 0xea12
movq %rax, %rsi
callq 0x6b06
pushq $0x18
popq %rdi
callq 0x6f0a
movq %rax, %rbx
leaq 0x11cba(%rip), %rax     # 0x18690
movl (%rax), %eax
movl %eax, (%rbx)
andl $0x0, 0x4(%rbx)
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x18
popq %rdi
callq 0x6f0a
movq %rax, %rbx
leaq 0x11c90(%rip), %rax     # 0x18690
movl (%rax), %eax
movl %eax, (%rbx)
movl $0x7, 0x4(%rbx)
movq %r14, 0x10(%rbx)
jmp 0x69de
leaq 0x934f(%rip), %rsi      # 0xfd67
pushq $0x3
popq %rdi
callq 0x5d30
jmp 0x69da
movl $0x6, 0x4(%rbx)
leaq 0x93a7(%rip), %rsi      # 0xfdd7
pushq $0x1b
popq %rdi
callq 0x5d30
jmp 0x69de
movl $0x4, 0x4(%rbx)
jmp 0x69de
movl $0x5, 0x4(%rbx)
jmp 0x69de
movl $0x3, 0x4(%rbx)
jmp 0x69de
leaq 0xa38e(%rip), %rdi      # 0x10dea
leaq 0x92d6(%rip), %rsi      # 0xfd39
leaq 0x92e4(%rip), %rcx      # 0xfd4e
movl $0xd9, %edx
callq 0x20b0
leaq 0xa376(%rip), %rdi      # 0x10df1
leaq 0x92b7(%rip), %rsi      # 0xfd39
leaq 0x92c5(%rip), %rcx      # 0xfd4e
movl $0x114, %edx            # imm = 0x114
callq 0x20b0
leaq 0x9b78(%rip), %rdi      # 0x10612
leaq 0x9298(%rip), %rsi      # 0xfd39
leaq 0x92a6(%rip), %rcx      # 0xfd4e
movl $0x128, %edx            # imm = 0x128
callq 0x20b0