// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x4d9b
jmp 0x4f4c
movq -0x8(%rbp), %rdi
callq 0x47d0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4f4c
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x4e07
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x4de4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7bf0
movq %rax, %rsi
leaq 0x48e7(%rip), %rdi      # 0x96c4
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7bf0
movq %rax, %rsi
leaq 0x48d4(%rip), %rdi      # 0x96cf
movb $0x0, %al
callq 0x1070
jmp 0x4f3a
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x4f38
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
leaq -0x48(%rbp), %rdi
movl $0x38, %edx
callq 0x10d0
cmpl $0x2, -0x44(%rbp)
jne 0x4eaa
movl -0x48(%rbp), %edi
callq 0x4f60
movq %rax, -0x58(%rbp)
leaq -0x48(%rbp), %rax
addq $0x8, %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x4fe0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rax
addq $0x20, %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x4fe0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq 0x4836(%rip), %rdi      # 0x96d4
movb $0x0, %al
callq 0x1070
jmp 0x4f36
cmpl $0x1, -0x44(%rbp)
jne 0x4ef9
movl -0x48(%rbp), %edi
callq 0x4f60
movq %rax, -0x60(%rbp)
leaq -0x48(%rbp), %rax
addq $0x8, %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x4fe0
movq -0x60(%rbp), %rsi
movq %rax, %rdx
leaq 0x47f0(%rip), %rdi      # 0x96e0
movb $0x0, %al
callq 0x1070
jmp 0x4f34
cmpl $0x0, -0x44(%rbp)
jne 0x4f1a
movl -0x48(%rbp), %edi
callq 0x4f60
movq %rax, %rsi
leaq 0x47d7(%rip), %rdi      # 0x96e8
movb $0x0, %al
callq 0x1070
jmp 0x4f32
leaq 0x47cc(%rip), %rdi      # 0x96ed
movb $0x0, %al
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
jmp 0x4f34
jmp 0x4f36
jmp 0x4f3a
jmp 0x4f3a
movq -0x8(%rbp), %rdi
callq 0x47d0
movq %rax, -0x10(%rbp)
jmp 0x4da8
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)