LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: expr_to_instrs
static list_t *expr_to_instrs(expr_t *expr, env_t *env) {
    if (!expr) {
        UNREACHABLE("expr_to_instrs: expr is invalid\n");
    }

    debug("expr to instrs\n");
    if (expr->type == PRIMARY) {
        return primary_to_instrs(expr->primary, env);
    }

    if (expr->type == UNARY_OP) {
        return unary_to_instrs(expr->unary, env);
    }

    if (expr->type == BIN_OP) {
        return binop_to_instrs(expr->bin, env);
    }

    if (expr->type == TERNARY) {
        return ternary_to_instrs(expr->ternary, env);
    }

    if (expr->type == ASSIGN) {
        return assign_to_instrs(expr->assign, env);
    }

    if (expr->type == NULL_EXPR) {
        return list_new();
    }

    UNREACHABLE("unhandled expression\n");
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2a94
jmp 0x2a69
leaq 0x6594(%rip), %rdi      # 0x9004
leaq 0x65c7(%rip), %rsi      # 0x903e
movl $0x252, %edx            # imm = 0x252
leaq 0x67ec(%rip), %rcx      # 0x926f
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
jmp 0x2a96
jmp 0x2a98
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2abb
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2e20
movq %rax, -0x8(%rbp)
jmp 0x2b82
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2ade
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x3050
movq %rax, -0x8(%rbp)
jmp 0x2b82
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x2b01
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x3310
movq %rax, -0x8(%rbp)
jmp 0x2b82
movq -0x10(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x2b21
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x3da0
movq %rax, -0x8(%rbp)
jmp 0x2b82
movq -0x10(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x2b41
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x3f00
movq %rax, -0x8(%rbp)
jmp 0x2b82
movq -0x10(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x2b55
callq 0x45f0
movq %rax, -0x8(%rbp)
jmp 0x2b82
jmp 0x2b57
leaq 0x64a6(%rip), %rdi      # 0x9004
leaq 0x64d9(%rip), %rsi      # 0x903e
movl $0x26e, %edx            # imm = 0x26E
leaq 0x671f(%rip), %rcx      # 0x9290
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: instr_label
static output_t *instr_label(opcode_t op, string_t *label) {
    if (op != OP_JMP && op != OP_JE && op != OP_JNE && op != OP_CALL) {
        UNREACHABLE("intsr_label: not a jmp or call opcode\n");
    }

    if (!label) {
        UNREACHABLE("intsr_label: null label\n");
    }

    output_t *out = malloc(sizeof(output_t));
    out->type = OUTPUT_INSTR;
 
    out->instr.num_args = op_to_num_args(op);
    if (out->instr.num_args != 1) {
        UNREACHABLE("instr_label: opcode has wrong number of args, not even sure how this happens\n");
    }

    out->instr.op = op;
    out->instr.src.type = OPERAND_LABEL;
    out->instr.src.label = label;
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x14, -0x4(%rbp)
je 0x2be4
cmpl $0x15, -0x4(%rbp)
je 0x2be4
cmpl $0x16, -0x4(%rbp)
je 0x2be4
cmpl $0x17, -0x4(%rbp)
je 0x2be4
jmp 0x2bb9
leaq 0x6444(%rip), %rdi      # 0x9004
leaq 0x6477(%rip), %rsi      # 0x903e
movl $0xb4, %edx
leaq 0x696e(%rip), %rcx      # 0x9541
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
cmpq $0x0, -0x10(%rbp)
jne 0x2c18
jmp 0x2bed
leaq 0x6410(%rip), %rdi      # 0x9004
leaq 0x6443(%rip), %rsi      # 0x903e
movl $0xb8, %edx
leaq 0x6961(%rip), %rcx      # 0x9568
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movl $0x40, %edi
callq 0x10e0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x4(%rbp), %edi
callq 0x29c0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0xc(%rax)
je 0x2c78
jmp 0x2c4d
leaq 0x63b0(%rip), %rdi      # 0x9004
leaq 0x63e3(%rip), %rsi      # 0x903e
movl $0xc0, %edx
leaq 0x691a(%rip), %rcx      # 0x9581
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movl -0x4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x4, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: block_or_single_to_instrs
static list_t *block_or_single_to_instrs(block_or_single_t *block_or_single, context_t context) {
    list_t *ret = list_new();
    if (block_or_single->type == SINGLE) {
        list_concat(ret, stmt_to_instrs(block_or_single->single, context));
    } else {
        list_concat(ret, block_to_instrs(block_or_single->block, context));
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x45f0
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2d1f
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x18e0
movq -0x20(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
jmp 0x2d66
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x2d70
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x10(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: block_to_instrs
static list_t *block_to_instrs(block_t *block, context_t context) {
    list_t *ret = list_new();
    stmt_t *curr_stmt = list_pop(block->stmts);
    context.env = block->env;
    for (; curr_stmt; curr_stmt = list_pop(block->stmts)) {
        list_concat(ret, stmt_to_instrs(curr_stmt, context));
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x45f0
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x47d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x18(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x2e0c
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x18e0
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x47d0
movq %rax, -0x18(%rbp)
jmp 0x2db0
movq -0x10(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: ternary_to_instrs
static list_t *ternary_to_instrs(ternary_t *ternary, env_t *env) {
    debug("ternary\n");
    list_t *ret = list_new();
    string_t *els_label = unique_label("else");
    string_t *post_cond_label = unique_label("post_cond");

    list_concat(ret, expr_to_instrs(ternary->cond, env));

    list_push(ret, instr_i2r(OP_CMP, 0, REG_RAX));
    list_push(ret, instr_label(OP_JE, els_label));

    list_concat(ret, expr_to_instrs(ternary->then, env));
    list_push(ret, instr_label(OP_JMP, post_cond_label));

    list_push(ret, new_label(els_label, LABEL_STATIC));
    list_concat(ret, expr_to_instrs(ternary->els, env));
    list_push(ret, new_label(post_cond_label, LABEL_STATIC));
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
jmp 0x3db2
callq 0x45f0
movq %rax, -0x18(%rbp)
leaq 0x53e6(%rip), %rdi      # 0x91a8
callq 0x1830
movq %rax, -0x20(%rbp)
leaq 0x53cc(%rip), %rdi      # 0x919e
callq 0x1830
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a50
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x4, %edi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x2810
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rsi
movl $0x15, %edi
callq 0x2b90
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a50
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rsi
movl $0x14, %edi
callq 0x2b90
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x1660
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a50
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x1660
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: assign_to_instrs
static list_t *assign_to_instrs(assign_t *assign, env_t *env) {
    debug("Found assignment statement\n");
    if (!is_valid_assign_lhs(assign->lhs)) {
        UNREACHABLE("assign_to_instrs: invalid lhs to assignment statement\n");
    }

    list_t *ret = list_new();
    list_concat(ret, expr_to_instrs(assign->rhs, env));
    var_info_t *var_info = env_get_declared(env, assign->lhs->primary->var);
    if (!var_info) {
        UNREACHABLE("assign_to_instrs: variable is used before declaration");
    }
    output_t *mov = instr_r2m(OP_MOV, REG_RAX, var_info->home);
    list_push(ret, mov);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
jmp 0x3f12
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x4400
testb $0x1, %al
jne 0x3f4f
jmp 0x3f24
leaq 0x50d9(%rip), %rdi      # 0x9004
leaq 0x510c(%rip), %rsi      # 0x903e
movl $0x241, %edx            # imm = 0x241
leaq 0x55cc(%rip), %rcx      # 0x950a
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
callq 0x45f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a50
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4520
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3fcd
jmp 0x3fa2
leaq 0x505b(%rip), %rdi      # 0x9004
leaq 0x508e(%rip), %rsi      # 0x903e
movl $0x248, %edx            # imm = 0x248
leaq 0x5463(%rip), %rcx      # 0x941f
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
movq 0x10(%rax), %rcx
movl $0x1, %esi
movl %esi, %edi
callq 0x2900
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: instr_m2r
static output_t *instr_m2r(opcode_t op, mem_loc_t src, reg_t dst) {
    if (op != OP_MOV) {
        // TODO find instrs where this is illegal
        UNREACHABLE("instr_m2r is only legal for MOV opcode for now\n");
    }
    output_t *out = malloc(sizeof(output_t)); 
    out->instr.num_args = op_to_num_args(op);
    if (out->instr.num_args != 2) {
        UNREACHABLE("instr_m2r requires opcode that uses 2 args\n");
    }

    out->type = OUTPUT_INSTR;
    out->instr.op = op;

    out->instr.src.type = OPERAND_MEM_LOC;
    out->instr.src.mem = src;

    out->instr.dst.type = OPERAND_REG;
    out->instr.dst.reg = dst;
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %esi, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movl %edi, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
cmpl $0x1, -0x14(%rbp)
je 0x4048
jmp 0x401d
leaq 0x4fe0(%rip), %rdi      # 0x9004
leaq 0x5013(%rip), %rsi      # 0x903e
movl $0x8c, %edx
leaq 0x531c(%rip), %rcx      # 0x9353
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movl $0x40, %edi
callq 0x10e0
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %edi
callq 0x29c0
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
cmpl $0x2, 0xc(%rax)
je 0x409e
jmp 0x4073
leaq 0x4f8a(%rip), %rdi      # 0x9004
leaq 0x4fbd(%rip), %rsi      # 0x903e
movl $0x91, %edx
leaq 0x52f6(%rip), %rcx      # 0x9383
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x28(%rax)
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x20(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: fn_caller_prepare
static list_t *fn_caller_prepare(list_t *params, env_t *env) {
    debug("fn_caller_prepare\n");
    list_t *ret = list_new();

    // Push all caller save regs onto the stack
    list_push(ret, instr_r(OP_PUSH, REG_R10));
    list_push(ret, instr_r(OP_PUSH, REG_R11));
    for (int i = 0; i < 6; i++) {
        list_push(ret, instr_r(OP_PUSH, ordered_param_regs[i]));
    }

    if (!params || !params->len)
        return ret;

    if (params->len > 6) {
        UNREACHABLE("fn_caller_before: Don't support more than 6 parameters yet\n");
    }

    // Generate code for each parameter and put it into the correct register 
    int param_number = 0;
    expr_t *param_expr = list_pop(params);
    for (; param_expr; param_expr = list_pop(params)) {
        debug("dealing with param %d\n", param_number);
        list_concat(ret, expr_to_instrs(param_expr, env));
        list_push(ret, instr_r2r(OP_MOV, REG_RAX, ordered_param_regs[param_number++]));
    }

    debug("prepare done\n");
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
jmp 0x4102
callq 0x45f0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x8, %edi
movl $0xb, %esi
callq 0x2650
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x8, %edi
movl $0xc, %esi
callq 0x2650
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movl $0x0, -0x24(%rbp)
cmpl $0x6, -0x24(%rbp)
jge 0x4195
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movslq -0x24(%rbp), %rcx
leaq 0x549f(%rip), %rax      # 0x9610
movl (%rax,%rcx,4), %esi
movl $0x8, %edi
callq 0x2650
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4158
cmpq $0x0, -0x10(%rbp)
je 0x41a6
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x41b3
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x427d
movq -0x10(%rbp), %rax
cmpl $0x6, 0x18(%rax)
jle 0x41ea
jmp 0x41bf
leaq 0x4e3e(%rip), %rdi      # 0x9004
leaq 0x4e71(%rip), %rsi      # 0x903e
movl $0xf2, %edx
leaq 0x51d6(%rip), %rcx      # 0x93af
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x47d0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4271
jmp 0x4207
jmp 0x4209
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2a50
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x4740
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x28(%rbp)
movslq %eax, %rcx
leaq 0x53c9(%rip), %rax      # 0x9610
movl (%rax,%rcx,4), %edx
movl $0x1, %esi
movl %esi, %edi
callq 0x2720
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x10(%rbp), %rdi
callq 0x47d0
movq %rax, -0x30(%rbp)
jmp 0x41fe
jmp 0x4273
jmp 0x4275
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: fn_caller_restore
static list_t *fn_caller_restore(void) {
    debug("fn_caller_restore\n");
    list_t *ret = list_new();
    for (int i = 5; i >= 0; i--) {
        list_push(ret, instr_r(OP_POP, ordered_param_regs[i]));
    }

    list_push(ret, instr_r(OP_POP, REG_R11));
    list_push(ret, instr_r(OP_POP, REG_R10));
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
jmp 0x429a
callq 0x45f0
movq %rax, -0x8(%rbp)
movl $0x5, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jl 0x42e7
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x534d(%rip), %rax      # 0x9610
movl (%rax,%rcx,4), %esi
movl $0x9, %edi
callq 0x2650
movq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x42aa
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x9, %edi
movl $0xc, %esi
callq 0x2650
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x9, %edi
movl $0xb, %esi
callq 0x2650
movq -0x20(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/asm.c
// Function: instr_i2m
static output_t *instr_i2m(opcode_t op, imm_t src, mem_loc_t dst) {
    output_t *out = malloc(sizeof(output_t)); 
    out->instr.num_args = op_to_num_args(op);
    if (out->instr.num_args != 2) {
        UNREACHABLE("instr_r2m requires opcode that uses 2 args\n");
    }

    out->type = OUTPUT_INSTR;
    out->instr.op = op;

    out->instr.src.type = OPERAND_IMM;
    out->instr.src.imm = src;

    out->instr.dst.type = OPERAND_MEM_LOC;
    out->instr.dst.mem = dst;
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edx, -0x10(%rbp)
movq %rcx, -0x8(%rbp)
movl %edi, -0x14(%rbp)
movq %rsi, -0x20(%rbp)
movl $0x40, %edi
callq 0x10e0
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %edi
callq 0x29c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rax
cmpl $0x2, 0xc(%rax)
je 0x43ac
jmp 0x4381
leaq 0x4c7c(%rip), %rdi      # 0x9004
leaq 0x4caf(%rip), %rsi      # 0x903e
movl $0x7b, %edx
leaq 0x4db3(%rip), %rcx      # 0x914e
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x28(%rbp), %rax
movl $0x3, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rcx
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/env.c
// Function: env_new
env_t *env_new(env_t *parent) {
    env_t *new_env = malloc(sizeof(env_t));
    if (!new_env)
        return NULL;

    new_env->parent = parent;
    new_env->children = list_new();
    new_env->homes = map_new();

    if (parent)
        list_push(parent->children, new_env);

    return new_env;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x18, %edi
callq 0x10e0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x445b
movq $0x0, -0x8(%rbp)
jmp 0x44a6
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
callq 0x45f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
callq 0x4b40
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x10(%rbp)
je 0x449e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x46a0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/env.c
// Function: env_get
var_info_t *env_get(env_t *env, string_t *var) {
    var_info_t *ret = NULL;
    while (env) {
        if ((ret = map_get(env->homes, var)))
            return ret;
        env = env->parent;
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4501
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x4ba0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x44f3
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4509
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x44c8
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/env.c
// Function: env_get_declared
var_info_t *env_get_declared(env_t *env, string_t *var) {
    var_info_t *ret = NULL;
    while (env) {
        if ((ret = map_get(env->homes, var)) && ret->declared)
            return ret;
        env = env->parent;
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x457b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x4ba0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x456d
movq -0x20(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x456d
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4583
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x4538
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/env.c
// Function: env_add
void env_add(env_t *env, string_t *name, builtin_type_t type, bool declared) {
    var_info_t *info = malloc(sizeof(var_info_t)); 
    info->type = type;
    info->declared = declared;
    map_set(env->homes, name, info);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
andb $0x1, %al
movb %al, -0x15(%rbp)
movl $0x20, %edi
callq 0x10e0
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movb -0x15(%rbp), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x18(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x4c90
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_new
list_t *list_new(void) {
    list_t *list = malloc(sizeof(list_t));
    if (list_init(list) < 0)
        return NULL;
    return list;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x20, %edi
callq 0x10e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4630
cmpl $0x0, %eax
jge 0x461e
movq $0x0, -0x8(%rbp)
jmp 0x4626
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_init
int list_init(list_t *list) {
    if (!list)
        return -1;
    list->len = 0;
    list->head = list->tail = malloc(sizeof(list_node_t));
    list->head->next = NULL;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x464c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4689
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_push
int list_push(list_t *list, void *data) {
    if (!data)
        return -1;

    list_node_t *new_node = malloc(sizeof(list_node_t));
    if (!new_node)
        return -1;

    new_node->data = data;
    new_node->next = NULL;
    list->tail->next = new_node;
    list->tail = list->tail->next;
    list->len++;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x46c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x472d
movl $0x10, %edi
callq 0x10e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x46de
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x472d
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_concat
int list_concat(list_t *l1, list_t *l2) {
    if (!l1 || !l2)
        return -1;

    l1->tail->next = l2->head->next;
    if (l2->len)
        l1->tail = l2->tail;
    l1->len += l2->len;
    free(l2->head);
    free(l2);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x475e
cmpq $0x0, -0x18(%rbp)
jne 0x4767
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x47c5
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x4798
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x10(%rbp), %rax
addl 0x18(%rax), %ecx
movl %ecx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x1030
movq -0x18(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_pop
void *list_pop(list_t *list) {
    if (!list)
        return NULL;
    if (list->len == 0)
        return NULL;
    assert(list->head->next);
    list_node_t *removed = list->head->next;
    void *ret_data = removed->data;
    list->head->next = removed->next;
    list->len--;
    if (list->len == 0)
        list->tail = NULL;

    free(removed);
    return ret_data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x47f0
movq $0x0, -0x8(%rbp)
jmp 0x4897
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x4807
movq $0x0, -0x8(%rbp)
jmp 0x4897
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x4817
jmp 0x4836
leaq 0x4e0a(%rip), %rdi      # 0x9628
leaq 0x4e14(%rip), %rsi      # 0x9639
movl $0x39, %edx
leaq 0x4e0f(%rip), %rcx      # 0x9640
callq 0x1090
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x4886
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_peek
void *list_peek(list_t *list) {
    if (!list)
        return NULL;
    if (!list->len)
        return NULL;
    assert(list->head->next);
    return list->head->next->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x48cd
movq $0x0, -0x8(%rbp)
jmp 0x4922
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x48e1
movq $0x0, -0x8(%rbp)
jmp 0x4922
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x48f1
jmp 0x4910
leaq 0x4d30(%rip), %rdi      # 0x9628
leaq 0x4d3a(%rip), %rsi      # 0x9639
movl $0x4a, %edx
leaq 0x4d4e(%rip), %rcx      # 0x9659
callq 0x1090
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: list_free
void list_free(list_t *list) {
    if (!list)
        return;
    void *data;
    while ((data = list_pop(list))) {
        // assume it's heap allocated
        free(data);
    }
    assert(list->head->next == list->tail);
    free(list->head);
    free(list);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x4945
jmp 0x49b0
jmp 0x4947
movq -0x8(%rbp), %rdi
callq 0x47d0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4965
movq -0x10(%rbp), %rdi
callq 0x1030
jmp 0x4947
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x497c
jmp 0x499b
leaq 0x4cf0(%rip), %rdi      # 0x9673
leaq 0x4caf(%rip), %rsi      # 0x9639
movl $0x57, %edx
leaq 0x4cfc(%rip), %rcx      # 0x9692
callq 0x1090
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x1030
movq -0x8(%rbp), %rdi
callq 0x1030
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/list.c
// Function: _list_iterate
inline bool __list_iterate(list_node_t **node, void **data) {
    if (*node == NULL)
        return false;

    *data = (*node)->data;
    *node = (*node)->next;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x49dc
movb $0x0, -0x1(%rbp)
jmp 0x4a03
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/main.c
// Function: main
int main(int argc, char **argv) {
    if (argc != 2) {
        usage();
        return -1;
    }
   
    char *filename = argv[1];
    string_t *input = file_to_string(filename);
    if (!input || !input->len)
        return -1;

    debug("Tokenizing...\n");
    list_t *tokens = tokenize(input);
    if (!tokens || !tokens->len)
        return -1;

    debug("Parsing...\n");
    program_t *prog = parse(tokens);
    if (!prog || !prog->fn_defs)
        return -1;

    /*
     * TODO - do variable allocation here.
     */
    debug("Allocating variable homes...\n");
    alloc_homes(prog);

    debug("Generating asm...\n");
    list_t *instrs = gen_asm(prog);
    if (!instrs || !instrs->len)
        return -1;

    debug("Outputting asm...\n");
    print_asm(instrs);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
je 0x4a5d
callq 0x4a10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b33
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7980
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4a87
movq -0x20(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x4a93
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b33
jmp 0x4a95
jmp 0x4a97
movq -0x20(%rbp), %rdi
callq 0x7d10
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4ab5
movq -0x28(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x4abe
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b33
jmp 0x4ac0
jmp 0x4ac2
movq -0x28(%rbp), %rdi
callq 0x51e0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4ae0
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4ae9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b33
jmp 0x4aeb
jmp 0x4aed
movq -0x30(%rbp), %rdi
callq 0x1230
jmp 0x4af8
movq -0x30(%rbp), %rdi
callq 0x13a0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x4b16
movq -0x38(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x4b1f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b33
jmp 0x4b21
jmp 0x4b23
movq -0x38(%rbp), %rdi
callq 0x4d80
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/map.c
// Function: map_new
map_t *map_new(void) {
    map_t *ret = malloc(sizeof(map_t)); 
    if (!ret)
        return NULL;
    ret->pairs = list_new();
    if (!ret->pairs)
        return NULL;
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x8, %edi
callq 0x10e0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4b67
movq $0x0, -0x8(%rbp)
jmp 0x4b92
callq 0x45f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4b8a
movq $0x0, -0x8(%rbp)
jmp 0x4b92
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/map.c
// Function: map_get
void *map_get(map_t *map, string_t *key) {
    if (!map)
        return NULL;
    pair_t *pair = map_get_pair_from_key(map, key);
    return pair ? pair->value : NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4bc1
movq $0x0, -0x8(%rbp)
jmp 0x4bf7
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4c10
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4be7
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x4bef
xorl %eax, %eax
movq %rax, -0x28(%rbp)
jmp 0x4bef
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/map.c
// Function: map_get_pair_from_key
static pair_t *map_get_pair_from_key(map_t *map, string_t *key) {
    pair_t *pair;
    list_for_each(map->pairs, pair) {
        if (string_eq(key, pair->key) == 0) {
            return pair;
        }
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x10, %rdi
leaq -0x20(%rbp), %rsi
callq 0x49c0
testb $0x1, %al
jne 0x4c53
jmp 0x4c74
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
callq 0x7c70
cmpl $0x0, %eax
jne 0x4c72
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4c7c
jmp 0x4c39
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/map.c
// Function: map_set
int map_set(map_t *map, string_t *key, void *value) {
    if (!map)
        return -1;

    // Overwrite the value if the key already exists in the map
    pair_t *pair = map_get_pair_from_key(map, key);
    if (pair) {
        pair->value = value;
        return 0;
    }
   
    pair = malloc(sizeof(pair_t));
    if (!pair)
        return -1;
    pair->key = key;
    pair->value = value;
    list_push(map->pairs, pair);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4cb4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d2d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4c10
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4ce1
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4d2d
movl $0x10, %edi
callq 0x10e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4cff
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d2d
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x46a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/output.c
// Function: op_to_string
static char *op_to_string(opcode_t op) {
    int i = 0;
    while (op_pairs[i].string != NULL) {
        if (op == op_pairs[i].op) {
            return op_pairs[i].string;
        }
        i++;
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x7ab7(%rip), %rax      # 0xca30
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x4fc7
movl -0xc(%rbp), %eax
movslq -0x10(%rbp), %rdx
leaq 0x7a9b(%rip), %rcx      # 0xca30
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x4fbc
movslq -0x10(%rbp), %rcx
leaq 0x7a85(%rip), %rax      # 0xca30
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x4fcf
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4f6e
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/output.c
// Function: operand_to_string
static char *operand_to_string(operand_t operand) {
    if (operand.type == OPERAND_REG) {
        return reg_to_string(operand.reg);
    }

    if (operand.type == OPERAND_LABEL) {
        return string_get(operand.label);
    }

    if (operand.type == OPERAND_VAR) {
        UNREACHABLE("VARs should not be in output\n");
    }

    string_t string;
    char buf[100];
    if (string_init(&string) < 0)
        return NULL;
    
    if (operand.type == OPERAND_IMM) {
        snprintf(buf, 100, "$%ld", operand.imm);
    } else if (operand.type == OPERAND_MEM_LOC) {
        snprintf(buf, 100, "%ld(%s)", operand.mem.offset, reg_to_string(operand.mem.reg));
    }
    string_append(&string, buf, strlen(buf));
    return string_get(&string);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpl $0x0, (%rax)
jne 0x5013
movq -0x88(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x5160
movq %rax, -0x8(%rbp)
jmp 0x5146
movq -0x88(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x5038
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7bf0
movq %rax, -0x8(%rbp)
jmp 0x5146
movq -0x88(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x5071
jmp 0x5046
leaq 0x3fb7(%rip), %rdi      # 0x9004
leaq 0x471b(%rip), %rsi      # 0x976f
movl $0x5c, %edx
leaq 0x4718(%rip), %rcx      # 0x9778
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
leaq -0x18(%rbp), %rdi
callq 0x7af0
cmpl $0x0, %eax
jge 0x508c
movq $0x0, -0x8(%rbp)
jmp 0x5146
movq -0x88(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x50bc
movq -0x88(%rbp), %rax
leaq -0x80(%rbp), %rdi
movq 0x8(%rax), %rcx
movl $0x64, %esi
leaq 0x46e3(%rip), %rdx      # 0x9796
movb $0x0, %al
callq 0x1080
jmp 0x5113
movq -0x88(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x5111
movq -0x88(%rbp), %rax
leaq -0x80(%rbp), %rcx
movq %rcx, -0x98(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x90(%rbp)
movl 0x8(%rax), %edi
callq 0x5160
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rcx
movq %rax, %r8
movl $0x64, %esi
leaq 0x4691(%rip), %rdx      # 0x979b
movb $0x0, %al
callq 0x1080
jmp 0x5113
leaq -0x80(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x1060
movq -0xa0(%rbp), %rsi
movl %eax, %edx
leaq -0x18(%rbp), %rdi
callq 0x7a80
leaq -0x18(%rbp), %rdi
callq 0x7bf0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/output.c
// Function: reg_to_string
static char *reg_to_string(reg_t reg) {
    int i = 0;
    while (reg_pairs[i].string != NULL) {
        if (reg == reg_pairs[i].reg) {
            return reg_pairs[i].string;
        }
        i++;
    }
    debug("reg_to_string failed: reg = %d\n", (int)reg);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x7a37(%rip), %rax      # 0xcbb0
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x51c7
movl -0xc(%rbp), %eax
movslq -0x10(%rbp), %rdx
leaq 0x7a1b(%rip), %rcx      # 0xcbb0
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x51bc
movslq -0x10(%rbp), %rcx
leaq 0x7a05(%rip), %rax      # 0xcbb0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x51d3
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x516e
jmp 0x51c9
jmp 0x51cb
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/parse.c
// Function: parse
program_t *parse(list_t *tokens) {
    program = malloc(sizeof(program_t));
    program->fn_defs = map_new();
    global_env = env_new(NULL);

    while (tokens->len) {
        fn_def_t *next_fn = parse_fn_declaration(tokens);
        fn_def_t *prev_decl = map_get(program->fn_defs, next_fn->name);

        if (!prev_decl) {
            // This is the first declaration, which we need to put in the map
            map_set(program->fn_defs, next_fn->name, next_fn);
            prev_decl = next_fn; 
        } else if (!fn_def_is_equal(next_fn, prev_decl)) {
            UNREACHABLE("Compilation error: Function declarations don't match\n");
        }

        if (!match(tokens, TOK_SEMICOLON)) {
            // This means that we have a body for the function declaration
            if (prev_decl->stmts != NULL) {
                UNREACHABLE("Compilation error: Function redefined\n");
            }

            // We have a definition with statements, so parse the statements and update
            // definition in the map.
            next_fn->stmts = parse_stmt_list(tokens, next_fn->env);
            map_set(program->fn_defs, next_fn->name, next_fn);
        }
    }
    return program;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x8, %edi
callq 0x10e0
movq %rax, 0x7ebb(%rip)      # 0xd0b8
callq 0x4b40
movq %rax, %rcx
movq 0x7eac(%rip), %rax      # 0xd0b8
movq %rcx, (%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x4430
movq %rax, 0x7e91(%rip)      # 0xd0b0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x5344
movq -0x8(%rbp), %rdi
callq 0x5360
movq %rax, -0x10(%rbp)
movq 0x7e77(%rip), %rax      # 0xd0b8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x4ba0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x527f
movq 0x7e56(%rip), %rax      # 0xd0b8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x4c90
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x52bf
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5500
testb $0x1, %al
jne 0x52bd
jmp 0x5292
leaq 0x3d6b(%rip), %rdi      # 0x9004
leaq 0x4541(%rip), %rsi      # 0x97e1
movl $0x3a3, %edx            # imm = 0x3A3
leaq 0x453d(%rip), %rcx      # 0x97e9
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
jmp 0x52bf
movq -0x8(%rbp), %rdi
movl $0x12, %esi
callq 0x56a0
testb $0x1, %al
jne 0x533f
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x5309
jmp 0x52de
leaq 0x3d1f(%rip), %rdi      # 0x9004
leaq 0x44f5(%rip), %rsi      # 0x97e1
movl $0x3a9, %edx            # imm = 0x3A9
leaq 0x4527(%rip), %rcx      # 0x981f
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x56f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x7d8c(%rip), %rax      # 0xd0b8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x4c90
jmp 0x521f
movq 0x7d6d(%rip), %rax      # 0xd0b8
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/parse.c
// Function: match
static bool match(list_t *tokens, token_type_t expectation) {
    token_t *next = list_peek(tokens);
    if (!next || next->type != expectation) {
        return false;
    }
    debug("Found expected\n");
    list_pop(tokens);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x48b0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x56ce
movq -0x20(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
je 0x56d4
movb $0x0, -0x1(%rbp)
jmp 0x56e5
jmp 0x56d6
jmp 0x56d8
movq -0x10(%rbp), %rdi
callq 0x47d0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/parse.c
// Function: parse_stmt_list
static list_t *parse_stmt_list(list_t *tokens, env_t *env) {
    expect_next(tokens, TOK_OPEN_BRACE);
    list_t *stmt_list = list_new();
    token_t *curr;
    debug("parsing statement list\n");
    while ((curr = list_peek(tokens)) && curr->type != TOK_CLOSE_BRACE) {
        list_push(stmt_list, parse_stmt(tokens, env));
    }
    debug("done parsing statement list\n");
    expect_next(tokens, TOK_CLOSE_BRACE);
    return stmt_list;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0xc, %esi
callq 0x5800
callq 0x45f0
movq %rax, -0x18(%rbp)
jmp 0x5719
jmp 0x571b
movq -0x8(%rbp), %rdi
callq 0x48b0
movq %rax, %rcx
movq %rcx, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x21(%rbp)
je 0x5743
movq -0x20(%rbp), %rax
cmpl $0xd, (%rax)
setne %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x574c
jmp 0x576f
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x58e0
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x46a0
jmp 0x571b
jmp 0x5771
jmp 0x5773
movq -0x8(%rbp), %rdi
movl $0xd, %esi
callq 0x5800
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/johnvtan[P]ccccc/parse.c
// Function: token_to_builtin_type
static builtin_type_t token_to_builtin_type(token_type_t t) {
    switch (t) {
        case TOK_INT_TYPE:
            return TYPE_INT;
        case TOK_VOID_TYPE:
            return TYPE_VOID;
        default:
            UNREACHABLE("token_to_builtin_type: Trying to parse unrecognized type\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0xc(%rbp)
subl $0x5, %eax
je 0x57b2
jmp 0x57a8
movl -0xc(%rbp), %eax
subl $0x7, %eax
je 0x57bb
jmp 0x57c4
movl $0x1, -0x4(%rbp)
jmp 0x57f1
movl $0x3, -0x4(%rbp)
jmp 0x57f1
jmp 0x57c6
leaq 0x3837(%rip), %rdi      # 0x9004
leaq 0x400d(%rip), %rsi      # 0x97e1
movl $0x41, %edx
leaq 0x40a6(%rip), %rcx      # 0x9886
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)