// File: /workspace/github_c_makefile_star2_O0/alexj136[P]minijit/src/typecheck.c
// Function: check_Expr
TypeCheckResult *check_Expr(Expr *expr, TypeVector *symbol_table) {
    if(Expr_isInt(expr)) {
        return TypeCheckSuccess_init(IntType_init());
    }
    else if(Expr_isAdd(expr) || Expr_isSub(expr)) {
        TypeCheckResult *lhs_res = check_Expr(Add_lhs(expr), symbol_table);
        TypeCheckResult *rhs_res = check_Expr(Add_rhs(expr), symbol_table);

        // Success case
        if(TypeCheckResult_isTypeForm(lhs_res, typeInt) &&
                TypeCheckResult_isTypeForm(rhs_res, typeInt)) {

            TypeCheckResult_free(lhs_res);
            return rhs_res;
        }

        // Fail case
        TypeErrorVector *errors = TypeErrorVector_init();
        if(!(lhs_res->success)) {
            TypeErrorVector_append_all(errors, lhs_res->errors);
        }
        if(!(rhs_res->success)) {
            TypeErrorVector_append_all(errors, rhs_res->errors);
        }

        TypeCheckResult_free(lhs_res);
        TypeCheckResult_free(rhs_res);
        return TypeCheckFail_init(errors);
    }
    else if(Expr_isCall(expr)) {}
    else if(Expr_isVar(expr)) {
        return TypeCheckSuccess_init(
                Type_copy(TypeVector_get(symbol_table, Var_name(expr))));
    }
    else { ERROR("Unrecognised Expr type"); }
    NOT_IMPLEMENTED;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3ef0, %rsp           # imm = 0x3EF0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x19052
callq 0x16de0
movq %rax, %rdi
callq 0x187e0
movq %rax, -0x8(%rbp)
jmp 0x19305
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
je 0x19068
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1912f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x19020
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x19020
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x18880
cmpl $0x0, %eax
je 0x190ce
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x18880
cmpl $0x0, %eax
je 0x190ce
movq -0x20(%rbp), %rdi
callq 0x188c0
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x19305
callq 0x16f10
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x190f1
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x171c0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1910b
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x171c0
movq -0x20(%rbp), %rdi
callq 0x188c0
movq -0x28(%rbp), %rdi
callq 0x188c0
movq -0x30(%rbp), %rdi
callq 0x18830
movq %rax, -0x8(%rbp)
jmp 0x19305
movq -0x10(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x1913d
jmp 0x19238
movq -0x10(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x1916f
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x15ad0
movq %rax, %rdi
callq 0x16e20
movq %rax, %rdi
callq 0x187e0
movq %rax, -0x8(%rbp)
jmp 0x19305
jmp 0x19171
leaq 0xae8c(%rip), %rdi      # 0x24004
leaq 0xc0bb(%rip), %rsi      # 0x2523a
movl $0xce, %edx
leaq 0xc2b5(%rip), %rcx      # 0x25440
movb $0x0, %al
callq 0x60f0
leaq 0xae93(%rip), %rdi      # 0x2402c
leaq 0xc2ab(%rip), %rsi      # 0x2544b
movb $0x0, %al
callq 0x60f0
leaq -0x1f70(%rbp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x60d0
movl %eax, -0x1f74(%rbp)
leaq -0x1f70(%rbp), %rdi
movl -0x1f74(%rbp), %esi
callq 0x60a0
movq %rax, -0x1f80(%rbp)
leaq 0xae6d(%rip), %rdi      # 0x2404b
movb $0x0, %al
callq 0x60f0
movl $0x0, -0x1f84(%rbp)
movl -0x1f84(%rbp), %eax
cmpl -0x1f74(%rbp), %eax
jge 0x1922e
movq -0x1f80(%rbp), %rax
movslq -0x1f84(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xae16(%rip), %rdi      # 0x2402c
movb $0x0, %al
callq 0x60f0
movl -0x1f84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f84(%rbp)
jmp 0x191ef
movl $0x1, %edi
callq 0x61a0
jmp 0x1923a
jmp 0x1923c
jmp 0x1923e
leaq 0xadbf(%rip), %rdi      # 0x24004
leaq 0xbfee(%rip), %rsi      # 0x2523a
movl $0xcf, %edx
leaq 0xc1e8(%rip), %rcx      # 0x25440
movb $0x0, %al
callq 0x60f0
leaq 0xadc6(%rip), %rdi      # 0x2402c
leaq 0xc191(%rip), %rsi      # 0x253fe
movb $0x0, %al
callq 0x60f0
leaq -0x3ed0(%rbp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x60d0
movl %eax, -0x3ed4(%rbp)
leaq -0x3ed0(%rbp), %rdi
movl -0x3ed4(%rbp), %esi
callq 0x60a0
movq %rax, -0x3ee0(%rbp)
leaq 0xada0(%rip), %rdi      # 0x2404b
movb $0x0, %al
callq 0x60f0
movl $0x0, -0x3ee4(%rbp)
movl -0x3ee4(%rbp), %eax
cmpl -0x3ed4(%rbp), %eax
jge 0x192fb
movq -0x3ee0(%rbp), %rax
movslq -0x3ee4(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xad49(%rip), %rdi      # 0x2402c
movb $0x0, %al
callq 0x60f0
movl -0x3ee4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3ee4(%rbp)
jmp 0x192bc
movl $0x1, %edi
callq 0x61a0
movq -0x8(%rbp), %rax
addq $0x3ef0, %rsp           # imm = 0x3EF0
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)