// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/t_aout.c
// Function: aoutstd_writeexec
void aoutstd_writeexec(struct GlobalVars *gv,FILE *f)
/* creates a standard a.out paged executable file */
{
  uint32_t mid = fff[gv->dest_format]->id;
  int be = (int)fff[gv->dest_format]->endianess;
  struct LinkedSection *sections[3];

  if (be < 0)
    be = gv->endianess;
  aout_initwrite(gv,sections);
  if (sections[0] == NULL)  /* this requires a .text section! */
    error(97,fff[gv->dest_format]->tname,TEXTNAME);
  aout_addsymlist(gv,sections,BIND_GLOBAL,0,be);
  aout_addsymlist(gv,sections,BIND_WEAK,0,be);
  aout_addsymlist(gv,sections,BIND_LOCAL,0,be);
  aout_debugsyms(gv,be);
  calc_relocs(gv,sections[0]);
  calc_relocs(gv,sections[1]);

  aout_header(f,ZMAGIC,mid,isPIC(sections) ? EX_PIC : 0, /* @@@ DYNAMIC? */
              aout_getpagedsize(gv,sections,0),
              aout_getpagedsize(gv,sections,1),
              aout_getpagedsize(gv,sections,2),
              aoutsymlist.nextindex * sizeof(struct nlist32),
              (uint32_t)entry_address(gv),0,0,be);
  aout_pagedsection(gv,f,sections,0);
  aout_pagedsection(gv,f,sections,1);
  aout_writesymbols(f);
  aout_writestrings(f,be);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x18(%rsp)
movq %rdi, %r14
movzbl 0x50(%rdi), %eax
leaq 0x134d9(%rip), %r12     # 0x2f190
movq (%r12,%rax,8), %rax
movb 0xaa(%rax), %bl
testb %bl, %bl
jns 0x1bccc
movb 0x202(%r14), %bl
movl 0xa4(%rax), %eax
movl %eax, 0x4(%rsp)
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1acd9
cmpq $0x0, (%r15)
jne 0x1bd09
movzbl 0x50(%r14), %eax
movq (%r12,%rax,8), %rax
movq (%rax), %rsi
leaq 0x48a1(%rip), %rdx      # 0x205a0
pushq $0x61
popq %rdi
xorl %eax, %eax
callq 0x6c19
movsbl %bl, %r15d
leaq 0x20(%rsp), %r12
pushq $0x1
popq %rbx
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1ad58
pushq $0x2
popq %rbp
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1ad58
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1ad58
movq %r14, %rdi
movl %r15d, %esi
callq 0x1afd8
movq (%r12), %rsi
movq %r14, %rdi
callq 0xb170
movq 0x8(%r12), %rsi
movq %r14, %rdi
callq 0xb170
movq %r12, %rdi
callq 0x1bc38
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
shll $0x4, %r13d
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1b617
movl %eax, (%rsp)
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x1b617
movl %eax, %ebx
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x1b617
movq %rax, 0x10(%rsp)
imull $0xc, 0x18179(%rip), %eax # 0x33f38
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0xc472
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movl $0x10b, %esi            # imm = 0x10B
movl 0x4(%rsp), %edx
movl %r13d, %ecx
movl (%rsp), %r8d
movl %ebx, %r9d
pushq %r15
pushq $0x0
pushq $0x0
pushq %rax
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq 0x1b53f
addq $0x30, %rsp
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x1b74c
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
pushq $0x1
popq %rcx
callq 0x1b74c
movq %rbp, %rdi
callq 0x1b827
movq %rbp, %rdi
movl %r15d, %esi
callq 0x1b861
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq