// File: /workspace/github_cpp_makefile_star2_O1/baziotis[P]minijava-cpp/typecheck.cpp
// Function: track_while_assignment_for_expr(Expression*, Array<WhileAssign, (MEM)4>)
bool track_while_assignment_for_expr(Expression *expr, FuncArr<WhileAssign> track_buf) {
    switch (expr->kind) {
    case EXPR::ID:
    {
        for (WhileAssign& wa : track_buf) {
            Local *local = wa.local;
            if (expr->id == local->id) {
                if (!wa.used) {
                    if (!wa.assigned) {
                        wa.used = 1;
                    } else {
                        wa.used = 2;
                    }
                }
                break;
            }
        }
    } break;
    case EXPR::ARR_ALLOC:
    case EXPR::ARR_LEN:
    case EXPR::NOT:
    {
        track_while_assignment_for_expr(expr->e1, track_buf);
    } break;
    case EXPR::AND:
    case EXPR::CMP:
    case EXPR::PLUS:
    case EXPR::MINUS:
    case EXPR::TIMES:
    case EXPR::ARR_LOOK:
    {
        BinaryExpression *be = (BinaryExpression *) expr;
        track_while_assignment_for_expr(be->e1, track_buf);
        track_while_assignment_for_expr(be->e2, track_buf);
    } break;
    case EXPR::MSG_SEND:
    {
        BinaryExpression *be = (BinaryExpression *) expr;
        track_while_assignment_for_expr(be->e1, track_buf);
        for (Expression *e : be->msd->expr_list) {
            track_while_assignment_for_expr(e, track_buf);
        }
    } break;
    default: break;
    }
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
leaq 0x90(%rsp), %r15
xorl %ebx, %ebx
leaq 0x4659(%rip), %r12      # 0x123fc
movl 0x4(%r14), %eax
decl %eax
cmpl $0xd, %eax
ja 0xdeb8
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x10(%r14), %rdi
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xdd81
movq 0x18(%r14), %r14
movups (%r15), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x30(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%r15)
jmp 0xde15
movq 0x10(%r14), %r14
movq 0x10(%r15), %rax
movq %rax, 0x50(%rsp)
movups (%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
andb %bl, %bpl
movb $0x1, %bl
jmp 0xdda3
movq 0x10(%r14), %rdi
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xdd81
movq 0x18(%r14), %rax
movq 0x10(%rax), %r14
testq %r14, %r14
je 0xdeb8
movq 0x18(%rax), %r12
shlq $0x3, %r14
xorl %r13d, %r13d
movq (%r12,%r13), %rdi
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xdd81
addq $0x8, %r13
cmpq %r13, %r14
jne 0xde4e
jmp 0xdeb8
movq 0x8(%r15), %rdx
testq %rdx, %rdx
je 0xdeb8
movq 0x10(%r15), %rax
movq 0x10(%r14), %rsi
shlq $0x4, %rdx
xorl %ecx, %ecx
movq (%rax,%rcx), %rdi
cmpq (%rdi), %rsi
je 0xde9e
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0xde8a
jmp 0xdeb8
movb 0x8(%rax,%rcx), %dl
testb $0xc, %dl
jne 0xdeb8
testb $0x3, %dl
je 0xdeb1
orb $0x8, %dl
jmp 0xdeb4
orb $0x4, %dl
movb %dl, 0x8(%rax,%rcx)
andb %bpl, %bl
andb $0x1, %bl
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq