// File: /workspace/github_c_makefile_star2_O1/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 0x11a1f(%rip), %r15     # 0x2f180
movq (%r15,%rax,8), %rax
movb 0xaa(%rax), %bpl
testb %bpl, %bpl
jns 0x1d778
movb 0x202(%r14), %bpl
movl 0xa4(%rax), %eax
movl %eax, 0x4(%rsp)
leaq 0x20(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1c6bb
cmpq $0x0, (%rbx)
jne 0x1d7b7
movzbl 0x50(%r14), %eax
movq (%r15,%rax,8), %rax
movq (%rax), %rsi
leaq 0x4df5(%rip), %rdx      # 0x225a0
movl $0x61, %edi
xorl %eax, %eax
callq 0x6f84
movsbl %bpl, %r15d
leaq 0x20(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1c73d
movq %r14, %rdi
movq %r12, %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1c73d
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1c73d
movq %r14, %rdi
movl %r15d, %esi
callq 0x1c99d
movq (%r12), %rsi
movq %r14, %rdi
callq 0xb7c8
movq 0x8(%r12), %rsi
movq %r14, %rdi
callq 0xb7c8
movq %r12, %rdi
callq 0x1d6e1
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
shll $0x4, %r13d
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1d04e
movl %eax, (%rsp)
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x1d04e
movl %eax, %ebp
movq %r14, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0x1d04e
movq %rax, 0x10(%rsp)
movl 0x162d6(%rip), %eax     # 0x33b48
shll $0x2, %eax
leal (%rax,%rax,2), %eax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0xcc6b
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movl $0x10b, %esi            # imm = 0x10B
movl 0x4(%rsp), %edx
movl %r13d, %ecx
movl (%rsp), %r8d
movl %ebp, %r9d
pushq %r15
xorl %r10d, %r10d
pushq %r10
pushq %r10
pushq %rax
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq 0x1cf74
addq $0x30, %rsp
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x1d185
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl $0x1, %ecx
callq 0x1d185
movq %rbx, %rdi
callq 0x1d262
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1d2aa
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq