// File: /workspace/github_c_makefile_star2_O1/johnvtan[P]ccccc/asm.c
// Function: gen_asm
list_t *gen_asm(program_t *prog) {
    if (!prog || !prog->fn_defs) {
        UNREACHABLE("gen_asm: malformed program\n");
    }
    debug("=====================Generating ASM=====================\n");
    list_t *output = list_new();

    pair_t *fn_pair;
    map_for_each(prog->fn_defs, fn_pair) {
        fn_def_t *fn_def = fn_pair->value;
        if (!fn_def->stmts)
            continue;
        list_t *fn_instrs = fn_def_to_asm(fn_def);
        if (!fn_instrs) {
            UNREACHABLE("gen_asm: null fn_instrs\n");
        }
        list_concat(output, fn_instrs);
    }
    debug("length: %d\n", output->len);
    return output;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
testq %rdi, %rdi
je 0x1733
movq %rdi, %r14
cmpq $0x0, (%rdi)
je 0x1733
callq 0x2efc
movq %rax, %r13
movq (%r14), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq (%r14), %rax
movq (%rax), %rdi
addq $0x10, %rdi
leaq 0x28(%rsp), %rsi
callq 0x30f8
testb %al, %al
je 0x16da
leaq 0x30(%rsp), %r12
movq %r14, 0x58(%rsp)
movq %r13, 0x50(%rsp)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rbx
cmpq $0x0, 0x10(%rbx)
je 0x16be
testq %rbx, %rbx
je 0x16ec
cmpq $0x0, (%rbx)
je 0x16ec
callq 0x2efc
movq %rax, %rbp
movq (%rbx), %r15
movl $0x40, %edi
callq 0x10e0
movl $0x1, %ecx
movl %ecx, (%rax)
movq %r15, 0x8(%rax)
movl %ecx, 0x10(%rax)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2f67
callq 0x2efc
movq %rax, %r15
movl $0x8, %edi
movl $0x5, %esi
callq 0x1ee4
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f67
movl $0x1, %edi
movl $0x6, %esi
movl $0x5, %edx
callq 0x1f81
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f67
movq 0x28(%rbx), %rsi
movl $0x2, %edi
movl $0x6, %edx
callq 0x2029
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f67
movl $0x8, %edi
movl $0x2, %esi
callq 0x1ee4
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f67
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x159c
cmpl $0x0, 0x18(%rdi)
je 0x159c
movq %rbp, 0x60(%rsp)
movq (%rdi), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rdi)
addq $0x10, %rdi
movq %r12, %rsi
callq 0x30f8
testb %al, %al
movq %r15, %rbp
je 0x158a
leaq 0x4ba9(%rip), %r15      # 0x60c0
movq 0x20(%rbx), %rax
movq (%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x31df
movl (%r15), %r13d
movl 0x8(%rax), %r14d
movq 0x10(%rax), %r12
movl $0x40, %edi
callq 0x10e0
xorl %ecx, %ecx
movl %ecx, (%rax)
movabsq $0x200000001, %rdx      # imm = 0x200000001
movq %rdx, 0x8(%rax)
movl %ecx, 0x10(%rax)
movl %r13d, 0x18(%rax)
movl $0x1, 0x28(%rax)
movl %r14d, 0x30(%rax)
movq %r12, 0x38(%rax)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2f67
movq 0x18(%rbx), %rdi
addq $0x10, %rdi
leaq 0x30(%rsp), %rsi
callq 0x30f8
addq $0x4, %r15
testb %al, %al
jne 0x1517
movq 0x58(%rsp), %r14
movq 0x50(%rsp), %r13
movq %rbp, %r15
movq 0x60(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2fad
leaq 0x4c1c(%rip), %rdi      # 0x61ca
callq 0x174f
movq %rax, %r15
movl $0x40, %edi
callq 0x10e0
movq %rax, %r12
movl $0x1, (%rax)
movq %r15, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq %r15, 0x30(%rsp)
leaq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq 0x20(%rbx), %rax
movq %rax, 0x48(%rsp)
movq 0x10(%rbx), %rdi
callq 0x2ffb
testq %rax, %rax
je 0x1623
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rax, %rdi
callq 0x17c8
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2fad
jmp 0x15ed
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2f67
callq 0x2efc
movq %rax, %r12
movl $0x8, %edi
movl $0x2, %esi
callq 0x1ee4
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f67
movl $0x1, %edi
movl $0x5, %esi
movl $0x6, %edx
callq 0x1f81
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f67
movl $0x9, %edi
movl $0x5, %esi
callq 0x1ee4
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f67
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2fad
movl $0x3, %edi
callq 0x1e5e
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2f67
testq %rbp, %rbp
je 0x1708
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2fad
leaq 0x30(%rsp), %r12
movq (%r14), %rax
movq (%rax), %rdi
addq $0x10, %rdi
leaq 0x28(%rsp), %rsi
callq 0x30f8
testb %al, %al
jne 0x1408
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a41(%rip), %rdi      # 0x6134
leaq 0x4a74(%rip), %rsi      # 0x616e
leaq 0x4aa8(%rip), %rcx      # 0x61a9
movl $0x32d, %edx            # imm = 0x32D
jmp 0x1722
leaq 0x4a25(%rip), %rdi      # 0x6134
leaq 0x4a58(%rip), %rsi      # 0x616e
leaq 0x4a73(%rip), %rcx      # 0x6190
movl $0x360, %edx            # imm = 0x360
xorl %eax, %eax
callq 0x1080
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
leaq 0x49fa(%rip), %rdi      # 0x6134
leaq 0x4a2d(%rip), %rsi      # 0x616e
leaq 0x4a2c(%rip), %rcx      # 0x6174
movl $0x354, %edx            # imm = 0x354
jmp 0x1722