// File: /workspace/github_c_makefile_star2_O2/takoeight0821[P]hoc_nyan/src/emit.c
// Function: emit_x86
void emit_x86(Program* prog) {
  puts(".intel_syntax noprefix");

  puts(".data");
  for (GVar* gvar = prog->globals; gvar != NULL; gvar = gvar->next) {
    if (gvar->init != NULL && !gvar->is_extern) {
      printf("%s:\n", gvar->name);
      emit_const(gvar->type, gvar->init);
    } else if (gvar->inits != NULL && !gvar->is_extern) {
      printf("%s:\n", gvar->name);
      for (size_t i = 0; i < gvar->inits->length; i++) {
        emit_const(gvar->type->ptr_to, gvar->inits->ptr[i]);
      }
    }
  }

  puts(".bss");
  for (GVar* gvar = prog->globals; gvar != NULL; gvar = gvar->next) {
    if (gvar->init == NULL && gvar->inits == NULL && !gvar->is_extern) {
      printf("%s:\n", gvar->name);
      emit(".zero %zu", size_of(gvar->type));
    }
  }

  puts(".text");
  for (size_t i = 0; i < prog->funcs->length; i++) {
    emit_function(prog->funcs->ptr[i]);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x963b(%rip), %rdi      # 0xc148
callq 0x2050
leaq 0xa2a2(%rip), %rdi      # 0xcdbb
callq 0x2050
movq %rbx, (%rsp)
leaq 0x8(%rbx), %r12
leaq 0x9632(%rip), %r14      # 0xc15f
movq %r12, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x2ba4
cmpq $0x0, 0x18(%r15)
je 0x2b46
cmpb $0x0, 0x28(%r15)
je 0x2b87
cmpq $0x0, 0x20(%r15)
je 0x2b30
cmpb $0x0, 0x28(%r15)
jne 0x2b30
movq 0x8(%r15), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
xorl %ebx, %ebx
movq 0x20(%r15), %rax
cmpq 0x10(%rax), %rbx
jae 0x2b30
movq 0x10(%r15), %rcx
movq 0x18(%rcx), %rdi
movq (%rax), %rax
movq (%rax,%rbx,8), %rsi
callq 0x2e61
incq %rbx
jmp 0x2b64
movq 0x8(%r15), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
callq 0x2e61
jmp 0x2b30
leaq 0xa21e(%rip), %rdi      # 0xcdc9
callq 0x2050
leaq 0x95a8(%rip), %r14      # 0xc15f
leaq 0x95a6(%rip), %r15      # 0xc164
movq (%r12), %r12
testq %r12, %r12
je 0x2c07
cmpq $0x0, 0x18(%r12)
jne 0x2bbe
cmpq $0x0, 0x20(%r12)
jne 0x2bbe
cmpb $0x0, 0x28(%r12)
jne 0x2bbe
movq 0x8(%r12), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
movq 0x10(%r12), %rdi
callq 0x75fe
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x2f5b
jmp 0x2bbe
leaq 0xa1d1(%rip), %rdi      # 0xcddf
callq 0x2050
leaq 0x9545(%rip), %rbx      # 0xc15f
xorl %r14d, %r14d
movq (%rsp), %rax
movq (%rax), %rax
cmpq 0x10(%rax), %r14
jae 0x2e52
movq (%rax), %rax
movq (%rax,%r14,8), %r12
leaq 0x95ad(%rip), %rdi      # 0xc1e9
xorl %eax, %eax
callq 0x3002
cmpq $0x0, 0x10(%r12)
je 0x2e2e
leaq 0x95b9(%rip), %rdi      # 0xc20f
callq 0x30af
movq %rax, 0xf4a6(%rip)      # 0x12108
cmpb $0x0, 0x28(%r12)
jne 0x2c7c
movq (%r12), %rsi
leaq 0x959e(%rip), %rdi      # 0xc213
xorl %eax, %eax
callq 0x20a0
movq (%r12), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20a0
leaq 0x958e(%rip), %rdi      # 0xc21f
xorl %eax, %eax
callq 0x2f5b
leaq 0x9589(%rip), %rdi      # 0xc228
xorl %eax, %eax
callq 0x2f5b
cmpb $0x1, 0x29(%r12)
jne 0x2d97
movq 0x18(%r12), %rax
movl 0x10(%rax), %eax
movl %eax, 0xf454(%rip)      # 0x12114
leaq 0x958f(%rip), %rdi      # 0xc256
movl $0xb0, %esi
xorl %eax, %eax
callq 0x2f5b
leaq 0x9588(%rip), %rdi      # 0xc262
xorl %eax, %eax
callq 0x2f5b
leaq 0x9589(%rip), %rdi      # 0xc271
xorl %eax, %eax
callq 0x2f5b
leaq 0x958e(%rip), %rdi      # 0xc284
xorl %eax, %eax
callq 0x2f5b
leaq 0x9594(%rip), %rdi      # 0xc298
xorl %eax, %eax
callq 0x2f5b
leaq 0x959a(%rip), %rdi      # 0xc2ac
xorl %eax, %eax
callq 0x2f5b
leaq 0x959f(%rip), %rdi      # 0xc2bf
xorl %eax, %eax
callq 0x2f5b
leaq 0x95a4(%rip), %rdi      # 0xc2d2
xorl %eax, %eax
callq 0x2f5b
leaq 0x95ae(%rip), %rdi      # 0xc2ea
xorl %eax, %eax
callq 0x2f5b
leaq 0x95b8(%rip), %rdi      # 0xc302
xorl %eax, %eax
callq 0x2f5b
leaq 0x95c2(%rip), %rdi      # 0xc31a
xorl %eax, %eax
callq 0x2f5b
leaq 0x95cc(%rip), %rdi      # 0xc332
xorl %eax, %eax
callq 0x2f5b
leaq 0x95d7(%rip), %rdi      # 0xc34b
xorl %eax, %eax
callq 0x2f5b
leaq 0x95e2(%rip), %rdi      # 0xc364
xorl %eax, %eax
callq 0x2f5b
leaq 0x95ed(%rip), %rdi      # 0xc37d
xorl %eax, %eax
callq 0x2f5b
movq 0x20(%r12), %rsi
leaq 0x9492(%rip), %rdi      # 0xc235
xorl %eax, %eax
callq 0x2f5b
leaq 0x937f(%rip), %rbp      # 0xc130
xorl %ebx, %ebx
movq 0x18(%r12), %rax
cmpq 0x10(%rax), %rbx
jae 0x2dee
movq (%rax), %rax
movq (%rax,%rbx,8), %r13
movq %r13, %rdi
callq 0x30cf
movl (%rbp), %r15d
movq 0x10(%r13), %rdi
callq 0x75fe
movl %r15d, %edi
movq %rax, %rsi
callq 0x3111
incq %rbx
addq $0x4, %rbp
jmp 0x2db3
movq 0x10(%r12), %rdi
callq 0x314a
movq 0xf309(%rip), %rsi      # 0x12108
leaq 0x9359(%rip), %rbx      # 0xc15f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20a0
leaq 0x942b(%rip), %rdi      # 0xc242
xorl %eax, %eax
callq 0x2f5b
leaq 0x9423(%rip), %rdi      # 0xc248
xorl %eax, %eax
callq 0x2f5b
jmp 0x2e3c
leaq 0x93c3(%rip), %rdi      # 0xc1f8
xorl %eax, %eax
callq 0x3002
leaq 0x93bf(%rip), %rdi      # 0xc202
xorl %eax, %eax
callq 0x3002
incq %r14
jmp 0x2c1d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq