// File: /workspace/github_c_makefile_star2_O3/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 0x1718
movq %rdi, %r14
cmpq $0x0, (%rdi)
je 0x1718
callq 0x2ea0
movq %rax, %r13
movq (%r14), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rdi)
addq $0x10, %rdi
leaq 0x28(%rsp), %rsi
callq 0x309c
testb %al, %al
je 0x16bf
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 0x16a3
cmpq $0x0, (%rbx)
je 0x16d1
callq 0x2ea0
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 0x2f0b
callq 0x2ea0
movq %rax, %r15
movl $0x8, %edi
movl $0x5, %esi
callq 0x1ec9
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f0b
movl $0x1, %edi
movl $0x6, %esi
movl $0x5, %edx
callq 0x1f66
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f0b
movq 0x28(%rbx), %rsi
movl $0x2, %edi
movl $0x6, %edx
callq 0x200e
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f0b
movl $0x8, %edi
movl $0x2, %esi
callq 0x1ec9
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f0b
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x1581
cmpl $0x0, 0x18(%rdi)
je 0x1581
movq %rbp, 0x60(%rsp)
movq (%rdi), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rdi)
addq $0x10, %rdi
movq %r12, %rsi
callq 0x309c
testb %al, %al
movq %r15, %rbp
je 0x156f
leaq 0x4bc4(%rip), %r15      # 0x60c0
movq 0x20(%rbx), %rax
movq (%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x3183
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 0x2f0b
movq 0x18(%rbx), %rdi
addq $0x10, %rdi
leaq 0x30(%rsp), %rsi
callq 0x309c
addq $0x4, %r15
testb %al, %al
jne 0x14fc
movq 0x58(%rsp), %r14
movq 0x50(%rsp), %r13
movq %rbp, %r15
movq 0x60(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2f51
leaq 0x4c37(%rip), %rdi      # 0x61ca
callq 0x1734
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 0x2f9f
testq %rax, %rax
je 0x1608
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rax, %rdi
callq 0x17ad
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2f51
jmp 0x15d2
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2f0b
callq 0x2ea0
movq %rax, %r12
movl $0x8, %edi
movl $0x2, %esi
callq 0x1ec9
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f0b
movl $0x1, %edi
movl $0x5, %esi
movl $0x6, %edx
callq 0x1f66
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f0b
movl $0x9, %edi
movl $0x5, %esi
callq 0x1ec9
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f0b
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2f51
movl $0x3, %edi
callq 0x1e43
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2f0b
testq %rbp, %rbp
je 0x16ed
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2f51
leaq 0x30(%rsp), %r12
movq (%r14), %rax
movq (%rax), %rdi
addq $0x10, %rdi
leaq 0x28(%rsp), %rsi
callq 0x309c
testb %al, %al
jne 0x13f6
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a5c(%rip), %rdi      # 0x6134
leaq 0x4a8f(%rip), %rsi      # 0x616e
leaq 0x4ac3(%rip), %rcx      # 0x61a9
movl $0x32d, %edx            # imm = 0x32D
jmp 0x1707
leaq 0x4a40(%rip), %rdi      # 0x6134
leaq 0x4a73(%rip), %rsi      # 0x616e
leaq 0x4a8e(%rip), %rcx      # 0x6190
movl $0x360, %edx            # imm = 0x360
xorl %eax, %eax
callq 0x1080
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
leaq 0x4a15(%rip), %rdi      # 0x6134
leaq 0x4a48(%rip), %rsi      # 0x616e
leaq 0x4a47(%rip), %rcx      # 0x6174
movl $0x354, %edx            # imm = 0x354
jmp 0x1707