// File: /workspace/github_c_makefile_star2_O3/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 0x3464
movq %rdi, %rbx
callq 0x2f9f
testq %rax, %rax
je 0x3464
movq %rax, %r14
leaq 0x3492(%rip), %rbp      # 0x672c
leaq 0x678f(%rip), %r13      # 0x9a30
leaq 0x3466(%rip), %r12      # 0x670e
movl (%r14), %eax
testl %eax, %eax
je 0x32ed
cmpl $0x1, %eax
jne 0x3450
cmpl $0x1, 0x10(%r14)
jne 0x32d9
movq 0x8(%r14), %rdi
callq 0x4e85
leaq 0x3434(%rip), %rdi      # 0x6703
movq %rax, %rsi
xorl %eax, %eax
callq 0x1080
movq 0x8(%r14), %rdi
callq 0x4e85
movq %r12, %rdi
movq %rax, %rsi
jmp 0x3449
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 0x3416
cmpl $0x1, %eax
je 0x33ba
cmpl $0x2, %eax
jne 0x3473
movl 0x20(%rsp), %eax
movq %rbp, %r14
cmpl $0x1, %eax
je 0x335e
movl $0x18, %ecx
movq %rcx, %rdx
addq $0x10, %rcx
cmpq $0x188, %rcx            # imm = 0x188
je 0x335a
cmpl %eax, -0x8(%rdx,%r13)
jne 0x3343
movq (%rdx,%r13), %r14
leaq 0x28(%rsp), %r12
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x3489
movq %rax, %r15
movq 0x28(%r12), %rax
movq %rax, 0x10(%rsp)
movups 0x18(%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x3489
leaq 0x3375(%rip), %rdi      # 0x6713
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1080
leaq 0x3359(%rip), %r12      # 0x670e
jmp 0x3450
movl 0x20(%rsp), %eax
movq %rbp, %r14
cmpl $0x1, %eax
je 0x33e6
movl $0x18, %ecx
movq %rcx, %rdx
addq $0x10, %rcx
cmpq $0x188, %rcx            # imm = 0x188
je 0x33e2
cmpl %eax, -0x8(%rdx,%r13)
jne 0x33cb
movq (%rdx,%r13), %r14
leaq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
callq 0x3489
leaq 0x3318(%rip), %rdi      # 0x671f
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1080
jmp 0x3450
movl 0x20(%rsp), %eax
movq %rbp, %rsi
cmpl $0x1, %eax
je 0x3442
movl $0x18, %ecx
movq %rcx, %rdx
addq $0x10, %rcx
cmpq $0x188, %rcx            # imm = 0x188
je 0x343e
cmpl %eax, -0x8(%rdx,%r13)
jne 0x3427
movq (%rdx,%r13), %rsi
leaq 0x32de(%rip), %rdi      # 0x6727
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
callq 0x2f9f
movq %rax, %r14
testq %rax, %rax
jne 0x32a8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3398(%rip), %rdi      # 0x6812
callq 0x1050
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110