// File: /workspace/github_c_makefile_star2_O3/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 0xa713(%rip), %rdi      # 0xe148
callq 0x2050
leaq 0xb352(%rip), %rdi      # 0xed93
callq 0x2050
movq %rbx, (%rsp)
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x3ada
leaq 0xa701(%rip), %r14      # 0xe15f
cmpq $0x0, 0x18(%rbx)
je 0x3a6b
cmpb $0x0, 0x28(%rbx)
je 0x3ab7
cmpq $0x0, 0x20(%rbx)
je 0x3ad2
cmpb $0x0, 0x28(%rbx)
jne 0x3ad2
movq 0x8(%rbx), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
movq 0x20(%rbx), %rax
cmpq $0x0, 0x10(%rax)
je 0x3ad2
xorl %r15d, %r15d
movq 0x10(%rbx), %rcx
movq 0x18(%rcx), %rdi
movq (%rax), %rax
movq (%rax,%r15,8), %rsi
callq 0x3df3
incq %r15
movq 0x20(%rbx), %rax
cmpq 0x10(%rax), %r15
jb 0x3a94
jmp 0x3ad2
movq 0x8(%rbx), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0x3df3
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x3a5e
leaq 0xb2c0(%rip), %rdi      # 0xeda1
callq 0x2050
movq (%rsp), %rax
movq 0x8(%rax), %rbx
testq %rbx, %rbx
je 0x3b41
leaq 0xa665(%rip), %r14      # 0xe15f
leaq 0xa663(%rip), %r15      # 0xe164
cmpq $0x0, 0x18(%rbx)
jne 0x3b39
cmpq $0x0, 0x20(%rbx)
jne 0x3b39
cmpb $0x0, 0x28(%rbx)
jne 0x3b39
movq 0x8(%rbx), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
movq 0x10(%rbx), %rdi
callq 0x9bf4
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x3eed
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x3b01
leaq 0xb26f(%rip), %rdi      # 0xedb7
callq 0x2050
movq (%rsp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x3de4
leaq 0xa5f9(%rip), %r14      # 0xe15f
xorl %ebx, %ebx
movq (%rax), %rax
movq (%rax,%rbx,8), %r12
leaq 0xa673(%rip), %rdi      # 0xe1e9
xorl %eax, %eax
callq 0x3f98
cmpq $0x0, 0x10(%r12)
je 0x3db4
movl 0xf581(%rip), %edx      # 0x13110
leal 0x1(%rdx), %eax
movl %eax, 0xf578(%rip)      # 0x13110
leaq 0xa6b0(%rip), %rdi      # 0xe24f
leaq 0xa669(%rip), %rsi      # 0xe20f
xorl %eax, %eax
callq 0xd86a
movq %rax, 0xf554(%rip)      # 0x13108
cmpb $0x0, 0x28(%r12)
jne 0x3bce
movq (%r12), %rsi
leaq 0xa64c(%rip), %rdi      # 0xe213
xorl %eax, %eax
callq 0x20a0
movq (%r12), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
leaq 0xa63c(%rip), %rdi      # 0xe21f
xorl %eax, %eax
callq 0x3eed
leaq 0xa637(%rip), %rdi      # 0xe228
xorl %eax, %eax
callq 0x3eed
cmpb $0x1, 0x29(%r12)
jne 0x3ce9
movq 0x18(%r12), %rax
movl 0x10(%rax), %eax
movl %eax, 0xf502(%rip)      # 0x13114
leaq 0xa63d(%rip), %rdi      # 0xe256
movl $0xb0, %esi
xorl %eax, %eax
callq 0x3eed
leaq 0xa636(%rip), %rdi      # 0xe262
xorl %eax, %eax
callq 0x3eed
leaq 0xa637(%rip), %rdi      # 0xe271
xorl %eax, %eax
callq 0x3eed
leaq 0xa63c(%rip), %rdi      # 0xe284
xorl %eax, %eax
callq 0x3eed
leaq 0xa642(%rip), %rdi      # 0xe298
xorl %eax, %eax
callq 0x3eed
leaq 0xa648(%rip), %rdi      # 0xe2ac
xorl %eax, %eax
callq 0x3eed
leaq 0xa64d(%rip), %rdi      # 0xe2bf
xorl %eax, %eax
callq 0x3eed
leaq 0xa652(%rip), %rdi      # 0xe2d2
xorl %eax, %eax
callq 0x3eed
leaq 0xa65c(%rip), %rdi      # 0xe2ea
xorl %eax, %eax
callq 0x3eed
leaq 0xa666(%rip), %rdi      # 0xe302
xorl %eax, %eax
callq 0x3eed
leaq 0xa670(%rip), %rdi      # 0xe31a
xorl %eax, %eax
callq 0x3eed
leaq 0xa67a(%rip), %rdi      # 0xe332
xorl %eax, %eax
callq 0x3eed
leaq 0xa685(%rip), %rdi      # 0xe34b
xorl %eax, %eax
callq 0x3eed
leaq 0xa690(%rip), %rdi      # 0xe364
xorl %eax, %eax
callq 0x3eed
leaq 0xa69b(%rip), %rdi      # 0xe37d
xorl %eax, %eax
callq 0x3eed
movq 0x20(%r12), %rsi
leaq 0xa540(%rip), %rdi      # 0xe235
xorl %eax, %eax
callq 0x3eed
movq 0x18(%r12), %rax
cmpq $0x0, 0x10(%rax)
je 0x3d74
leaq 0xa421(%rip), %r15      # 0xe130
xorl %r14d, %r14d
movq (%rax), %rax
movq (%rax,%r14,8), %r13
movq %r13, %rdi
callq 0x4047
movl (%r15), %ebp
movq 0x10(%r13), %rdi
callq 0x9bf4
leaq 0xecac(%rip), %rcx      # 0x129e0
cmpq $0x4, %rax
je 0x3d41
leaq 0xebff(%rip), %rcx      # 0x12940
cmpq $0x1, %rax
leaq 0xec44(%rip), %rax      # 0x12990
cmoveq %rax, %rcx
movq (%rcx,%rbp,8), %rsi
leaq 0xa67c(%rip), %rdi      # 0xe3d7
xorl %eax, %eax
callq 0x3eed
incq %r14
movq 0x18(%r12), %rax
addq $0x4, %r15
cmpq 0x10(%rax), %r14
jb 0x3d12
movq 0x10(%r12), %rdi
callq 0x4097
movq 0xf383(%rip), %rsi      # 0x13108
leaq 0xa3d3(%rip), %r14      # 0xe15f
movq %r14, %rdi
xorl %eax, %eax
callq 0x20a0
leaq 0xa4a5(%rip), %rdi      # 0xe242
xorl %eax, %eax
callq 0x3eed
leaq 0xa49d(%rip), %rdi      # 0xe248
xorl %eax, %eax
callq 0x3eed
jmp 0x3dc2
leaq 0xa43d(%rip), %rdi      # 0xe1f8
xorl %eax, %eax
callq 0x3f98
leaq 0xa439(%rip), %rdi      # 0xe202
xorl %eax, %eax
callq 0x3f98
incq %rbx
movq (%rsp), %rax
movq (%rax), %rax
cmpq 0x10(%rax), %rbx
jb 0x3b68
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq