// File: /workspace/github_c_makefile_star2_O1/yutopp[P]cc/asm_x86_64.c
// Function: asm_x86_64_fprint
void asm_x86_64_fprint(FILE* fp, ASM_X86_64* a) {
	fprintf(fp, ".file	\"simple_00.c\"\n"); // TODO
	fprintf(fp, ".text\n");                  // TODO

    for(size_t i=0; i<vector_len(a->insts); ++i) {
        ASM_X86_64_Inst* inst = vector_at(a->insts, i);
        switch(inst->kind) {
        case ASM_X86_64_INST_KIND_SECTION:
            fprintf(fp, "\t");
            fprintf(fp, ".section\t%s\n", inst->value.section.name);
            break;

        case ASM_X86_64_INST_KIND_STRING:
            fprintf(fp, "\t");
            fprintf(fp, ".string\t\"%s\"\n", inst->value.string.s);
            break;

        case ASM_X86_64_INST_KIND_TEXT:
            fprintf(fp, "\t");
            fprintf(fp, ".text\n");
            break;

        case ASM_X86_64_INST_KIND_GLOBAL:
            fprintf(fp, "\t");
            fprintf(fp, ".globl\t%s\n", inst->value.global.name);
            break;

        case ASM_X86_64_INST_KIND_TYPE:
            fprintf(fp, "\t");
            fprintf(fp, ".type\t%s, %s\n", inst->value.type.name, inst->value.type.type);
            break;

        case ASM_X86_64_INST_KIND_LABEL:
            fprintf(fp, "%s:\n", inst->value.label.name);
            break;

        case ASM_X86_64_INST_KIND_OP:
        {
            fprintf(fp, "\t");
            ASM_X86_64_Value* args = inst->value.op.args;
            switch(inst->value.op.op) {
            case ASM_X86_64_OP_PUSHQ:
                fprint_inst_op(fp, "pushq", 1, &args[0]);
                break;

            case ASM_X86_64_OP_POPQ:
                fprint_inst_op(fp, "popq", 1, &args[0]);
                break;

            case ASM_X86_64_OP_MOVQ:
                fprint_inst_op(fp, "movq", 2, &args[1], &args[0]);
                break;

            case ASM_X86_64_OP_ADDQ:
                fprint_inst_op(fp, "addq", 2, &args[1], &args[0]);
                break;

            case ASM_X86_64_OP_SUBQ:
                fprint_inst_op(fp, "subq", 2, &args[1], &args[0]);
                break;

            case ASM_X86_64_OP_LEAQ:
                fprint_inst_op(fp, "leaq", 2, &args[1], &args[0]);
                break;

            case ASM_X86_64_OP_CALL:
                fprint_inst_op(fp, "call", 1, &args[0]);
                break;

            case ASM_X86_64_OP_CMPQ:
                fprint_inst_op(fp, "cmp", 2, &args[1], &args[0]);
                break;

            case ASM_X86_64_OP_JMP:
                fprint_inst_op(fp, "jmp", 1, &args[0]);
                break;

            case ASM_X86_64_OP_JE:
                fprint_inst_op(fp, "je", 1, &args[0]);
                break;

            case ASM_X86_64_OP_RET:
                fprint_inst_op(fp, "ret", 0);
                break;

            default:
                assert(0); // TODO: error handling...
            }
            break;
        }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x28fd(%rip), %rdi      # 0x7a28
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x11b0
leaq 0x28f9(%rip), %rdi      # 0x7a3d
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x11b0
movq (%rbx), %rdi
callq 0x322b
testq %rax, %rax
je 0x5365
leaq 0x27f2(%rip), %r15      # 0x7960
leaq 0x2807(%rip), %r12      # 0x797c
xorl %r13d, %r13d
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x3216
movq %rax, %rbp
movl (%rax), %eax
cmpq $0x6, %rax
ja 0x525a
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl $0x9, %edi
movq %r14, %rsi
callq 0x10f0
movq 0x8(%rbp), %rdx
movq %r14, %rdi
leaq 0x288e(%rip), %rsi      # 0x7a44
jmp 0x5253
movl $0x9, %edi
movq %r14, %rsi
callq 0x10f0
movq 0x8(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq %r14, %rdi
leaq 0x2890(%rip), %rsi      # 0x7a6a
xorl %eax, %eax
callq 0x1110
jmp 0x525a
movl $0x9, %edi
movq %r14, %rsi
callq 0x10f0
movl $0x6, %esi
movl $0x1, %edx
leaq 0x283c(%rip), %rdi      # 0x7a3d
movq %r14, %rcx
callq 0x11b0
jmp 0x525a
movl $0x9, %edi
movq %r14, %rsi
callq 0x10f0
movq 0x8(%rbp), %rdx
movq %r14, %rdi
leaq 0x2839(%rip), %rsi      # 0x7a5f
jmp 0x5253
movl $0x9, %edi
movq %r14, %rsi
callq 0x10f0
movq 0x8(%rbp), %rdx
movq %r14, %rdi
leaq 0x280e(%rip), %rsi      # 0x7a51
jmp 0x5253
movq 0x8(%rbp), %rdx
movq %r14, %rdi
leaq 0x22af(%rip), %rsi      # 0x7502
xorl %eax, %eax
callq 0x1110
incq %r13
movq (%rbx), %rdi
callq 0x322b
cmpq %rax, %r13
jb 0x5178
jmp 0x5365
movl $0x9, %edi
movq %r14, %rsi
callq 0x10f0
movl 0x8(%rbp), %eax
cmpq $0xb, %rax
ja 0x5374
leaq 0x10(%rbp), %r8
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq %r14, %rdi
leaq 0x27d4(%rip), %rsi      # 0x7a78
jmp 0x5351
movq %r14, %rdi
leaq 0x27f1(%rip), %rsi      # 0x7aa4
jmp 0x5351
movq %r14, %rdi
leaq 0x27e5(%rip), %rsi      # 0x7aa7
xorl %edx, %edx
xorl %eax, %eax
callq 0x5393
jmp 0x525a
movq %r14, %rdi
leaq 0x27c9(%rip), %rsi      # 0x7aa0
jmp 0x5351
addq $0x28, %rbp
movq %r14, %rdi
leaq 0x27a6(%rip), %rsi      # 0x7a8d
jmp 0x5327
addq $0x28, %rbp
movq %r14, %rdi
leaq 0x279b(%rip), %rsi      # 0x7a92
jmp 0x5327
addq $0x28, %rbp
movq %r14, %rdi
leaq 0x277c(%rip), %rsi      # 0x7a83
jmp 0x5327
addq $0x28, %rbp
movq %r14, %rdi
leaq 0x2785(%rip), %rsi      # 0x7a9c
jmp 0x5327
addq $0x28, %rbp
movq %r14, %rdi
leaq 0x2761(%rip), %rsi      # 0x7a88
movl $0x2, %edx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x5393
jmp 0x525a
movq %r14, %rdi
leaq 0x2739(%rip), %rsi      # 0x7a7e
jmp 0x5351
movq %r14, %rdi
leaq 0x2746(%rip), %rsi      # 0x7a97
movl $0x1, %edx
movq %r8, %rcx
xorl %eax, %eax
callq 0x5393
jmp 0x525a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24b3(%rip), %rdi      # 0x782e
leaq 0x2729(%rip), %rsi      # 0x7aab
leaq 0x272f(%rip), %rcx      # 0x7ab8
movl $0x14b, %edx            # imm = 0x14B
callq 0x10d0