// File: /workspace/github_c_makefile_star2_O1/johnvtan[P]ccccc/output.c
// Function: print_asm
void print_asm(list_t *output) {
    if (!output)
        return;

    output_t *curr = list_pop(output);
    for (; curr; curr = list_pop(output)) {
        if (curr->type == OUTPUT_LABEL) {
            if (curr->label.linkage == LABEL_GLOBAL) {
                printf(".globl %s\n", string_get(curr->label.name));
            }
            printf("%s:\n", string_get(curr->label.name));
            continue;
        }

        if (curr->type == OUTPUT_INSTR) {
            instr_t instr = curr->instr;
            if (instr.num_args == 2) {
                printf("\t%s %s, %s\n", op_to_string(instr.op), operand_to_string(instr.src), operand_to_string(instr.dst));
            } else if (instr.num_args == 1) {
                printf("\t%s %s\n", op_to_string(instr.op), operand_to_string(instr.src));
            } else if (instr.num_args == 0) {
                printf("\t%s\n", op_to_string(instr.op));
            } else {
                printf("BAD NUM ARGS\n");
                exit(-1);
            }
            continue;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
je 0x34d0
movq %rdi, %rbx
callq 0x2ffb
testq %rax, %rax
je 0x34d0
movq %rax, %r14
leaq 0x3484(%rip), %rbp      # 0x677a
leaq 0x6733(%rip), %r13      # 0x9a30
leaq 0x3458(%rip), %r12      # 0x675c
movl (%r14), %eax
testl %eax, %eax
je 0x3349
cmpl $0x1, %eax
jne 0x345e
cmpl $0x1, 0x10(%r14)
jne 0x3335
movq 0x8(%r14), %rdi
callq 0x4f2b
leaq 0x3426(%rip), %rdi      # 0x6751
movq %rax, %rsi
xorl %eax, %eax
callq 0x1080
movq 0x8(%r14), %rdi
callq 0x4f2b
movq %r12, %rdi
movq %rax, %rsi
jmp 0x3457
movups 0x8(%r14), %xmm0
movups 0x18(%r14), %xmm1
movups 0x28(%r14), %xmm2
movaps %xmm0, 0x20(%rsp)
movq 0x38(%r14), %rax
movq %rax, 0x50(%rsp)
movaps %xmm2, 0x40(%rsp)
movaps %xmm1, 0x30(%rsp)
movl 0x24(%rsp), %eax
testl %eax, %eax
je 0x33ed
cmpl $0x1, %eax
je 0x33bf
cmpl $0x2, %eax
jne 0x34df
movl 0x20(%rsp), %eax
movq %rbp, %r14
cmpl $0x1, %eax
je 0x3477
movl $0x10, %ecx
leaq 0x10(%rcx), %rdx
cmpq $0x180, %rdx            # imm = 0x180
je 0x3474
cmpl %eax, (%rcx,%r13)
movq %rdx, %rcx
jne 0x339b
movq -0x8(%rdx,%r13), %r14
jmp 0x3477
movl 0x20(%rsp), %eax
movq %rbp, %r14
cmpl $0x1, %eax
je 0x341e
movl $0x10, %ecx
leaq 0x10(%rcx), %rdx
cmpq $0x180, %rdx            # imm = 0x180
je 0x341b
cmpl %eax, (%rcx,%r13)
movq %rdx, %rcx
jne 0x33d0
movq -0x8(%rdx,%r13), %r14
jmp 0x341e
movl 0x20(%rsp), %eax
movq %rbp, %rsi
cmpl $0x1, %eax
je 0x3450
movl $0x10, %ecx
leaq 0x10(%rcx), %rdx
cmpq $0x180, %rdx            # imm = 0x180
je 0x344e
cmpl %eax, (%rcx,%r13)
movq %rdx, %rcx
jne 0x33fe
movq -0x8(%rdx,%r13), %rsi
jmp 0x3450
xorl %r14d, %r14d
leaq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
callq 0x34f5
leaq 0x332e(%rip), %rdi      # 0x676d
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1080
jmp 0x345e
xorl %esi, %esi
leaq 0x331e(%rip), %rdi      # 0x6775
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
callq 0x2ffb
movq %rax, %r14
testq %rax, %rax
jne 0x3304
jmp 0x34d0
xorl %r14d, %r14d
leaq 0x28(%rsp), %r12
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x34f5
movq %rax, %r15
movq 0x28(%r12), %rax
movq %rax, 0x10(%rsp)
movups 0x18(%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x34f5
leaq 0x32aa(%rip), %rdi      # 0x6761
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1080
leaq 0x328e(%rip), %r12      # 0x675c
jmp 0x345e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x337a(%rip), %rdi      # 0x6860
callq 0x1050
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110