// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_writeexec
void elf32_writeexec(struct GlobalVars *gv,FILE *f,uint16_t m,int8_t endian,
                     uint8_t (*reloc_vlink2elf)(struct Reloc *))
/* creates an ELF32 executable file (page-aligned with absolute addresses) */
{
  uint32_t sh_off,shstrndx,stabndx,phnum;
  struct LinkedSection *ls;

  elf32_initoutput(gv,elf32_headersize(gv),endian);
  elf32_makestabs(gv);
  phnum = elf32_segmentcheck(gv);
  elf32_stdsymtab(gv,STB_LOCAL,STT_FILE);

  elf32_makeshdrs(gv);
  elf32_makedynamic(gv,reloc_vlink2elf);

  elf32_stdsymtab(gv,STB_LOCAL,0);
  elf32symlist.global_index = elf32symlist.nextindex;
  elf32_stdsymtab(gv,STB_WEAK,0);
  elf32_stdsymtab(gv,STB_GLOBAL,0);

  if (gv->keep_relocs)
    elf32_addrelocs(gv,reloc_vlink2elf);
  for (ls=(struct LinkedSection *)gv->lnksec.first;
       ls->n.next!=NULL; ls=(struct LinkedSection *)ls->n.next) {
    calc_relocs(gv,ls);
  }

  elf32_makestabstr();
  shstrndx = elf32shdridx;
  elf32_makeshstrtab();
  sh_off = elf32offset;
  stabndx = elf32shdridx;
  elf32offset += (elf32shdridx+2) * sizeof(struct Elf32_Shdr);
  elf32_makesymtab(elf32shdridx+1);
  elf32_makestrtab();

  elf32_header(f,gv->dest_sharedobj?ET_DYN:ET_EXEC,m,
               (uint32_t)entry_address(gv),sizeof(struct Elf32_Ehdr),sh_off,0,
               phnum,elf32shdridx,shstrndx,endian==_BIG_ENDIAN_);
  elf32_writephdrs(gv,f);
  elf32_writesegments(gv,f);
  elf32_writestabstr(f);
  elf32_writestrtab(f,&elf32shstrlist);
  fwrite_align(f,2,ftell(f));
  elf32_writeshdrs(gv,f,elf32offset,stabndx);
  elf32_writesymtab(f,&elf32symlist);
  elf32_writestrtab(f,&elf32stringlist);
  if (gv->keep_relocs) {
    fwrite_align(f,2,ftell(f));
    elf32_writerelocs(gv,f);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, 0x38(%rsp)
movq %rdi, %rbp
movq 0x1f8(%rdi), %rax
testq %rax, %rax
movq %rsi, 0x50(%rsp)
movl %edx, 0x4c(%rsp)
je 0x188f5
xorl %esi, %esi
btl $0x4, 0x24(%rax)
adcl $0x0, %esi
movq (%rax), %rax
testq %rax, %rax
jne 0x188dd
shll $0x5, %esi
addl $0x34, %esi
jmp 0x188fa
movl $0x34, %esi
movl %ecx, 0x48(%rsp)
movsbl %cl, %edx
movq %rbp, %rdi
callq 0x18383
movq %rbp, %rdi
callq 0x17f61
movq %rbp, %rdi
callq 0x16ff1
movl %eax, 0x44(%rsp)
leaq 0x16dfc(%rip), %rsi     # 0x2f720
movq %rbp, %rdi
xorl %edx, %edx
movl $0x4, %ecx
callq 0x16ec3
movq %rbp, %rdi
callq 0x17437
cmpl $0x0, 0x240(%rbp)
je 0x18bef
xorl %r13d, %r13d
cmpb $0x1, 0x16ebe(%rip)     # 0x2f810
sete %r14b
xorl %r12d, %r12d
cmpb $0x2, 0x6e(%rbp)
sete %r12b
leaq 0x16ef8(%rip), %rax     # 0x2f860
movq (%rax,%r12,8), %rsi
xorl %r15d, %r15d
movq %rbp, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbe13
testq %rax, %rax
je 0x1898a
movq 0x78(%rax), %r15
leaq 0x16edf(%rip), %rax     # 0x2f870
movq (%rax,%r12,8), %rsi
xorl %ebx, %ebx
movq %rbp, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbe13
testq %rax, %rax
je 0x189b2
movq 0x78(%rax), %rbx
movb %r14b, %r13b
movl %r13d, 0x2c(%rsp)
movq %rbp, 0x30(%rsp)
movq 0x1c0(%rbp), %r14
movq (%r14), %rax
testq %rax, %rax
je 0x18ae4
movq 0x98(%r14), %r13
movq (%r13), %rcx
testq %rcx, %rcx
je 0x18ad9
movq %rcx, %rbp
movb 0x39(%r13), %al
testb %al, %al
js 0x18a18
cmpb $0x40, %al
jb 0x18ac6
testq %rbx, %rbx
je 0x18a7a
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
jmp 0x18aae
testq %r15, %r15
je 0x18a34
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
jmp 0x18a68
leaq 0x16e25(%rip), %rax     # 0x2f860
movq (%rax,%r12,8), %rdx
leaq 0xafd4(%rip), %rdi      # 0x23a1a
leaq 0xafb8(%rip), %rsi      # 0x23a05
xorl %eax, %eax
callq 0x52b0
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movq 0x38(%rsp), %r8
movl %r12d, %r9d
callq 0x18e2f
addq %rax, %r15
jmp 0x18abe
leaq 0x16def(%rip), %rax     # 0x2f870
movq (%rax,%r12,8), %rdx
leaq 0xaf8e(%rip), %rdi      # 0x23a1a
leaq 0xaf72(%rip), %rsi      # 0x23a05
xorl %eax, %eax
callq 0x52b0
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movq 0x38(%rsp), %r8
movl %r12d, %r9d
callq 0x18e2f
addq %rax, %rbx
movq %r13, %rdi
callq 0x6759
movq (%rbp), %rcx
movq %rbp, %r13
testq %rcx, %rcx
jne 0x189e6
movq (%r14), %rax
movq %rax, %r14
movq (%rax), %rax
jmp 0x189c9
leaq 0xa8f2(%rip), %rsi      # 0x233dd
movq 0x30(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbe13
testq %rax, %rax
je 0x18bce
movq 0x78(%rax), %r13
leaq 0x16c3d(%rip), %rdi     # 0x2f750
callq 0x673f
testq %rax, %rax
je 0x18b40
leaq 0x16c2c(%rip), %rbx     # 0x2f750
movq %r13, %r14
movups 0x20(%rax), %xmm0
movups %xmm0, (%r14)
addq $0x10, %r14
movq %rbx, %rdi
callq 0x673f
testq %rax, %rax
jne 0x18b27
leaq 0x1ad79(%rip), %rdi     # 0x338c0
callq 0x673f
testq %rax, %rax
movq 0x30(%rsp), %rbp
movl 0x2c(%rsp), %ebx
je 0x18bef
movq %rax, %r14
movq 0x10(%r14), %rdi
callq 0x15ece
movl %eax, %r15d
movl 0x18(%r14), %eax
shlq $0x4, %rax
leaq (%rax,%r13), %rsi
addq $0x4, %rsi
movq 0x10(%r14), %rax
movl 0x30(%rax), %edx
movl %ebx, %edi
callq 0x69a0
movl 0x18(%r14), %eax
shlq $0x4, %rax
leaq (%rax,%r13), %r12
addq $0xe, %r12
movq 0x10(%r14), %rsi
movzbl %r15b, %edx
movq %rbp, %rdi
callq 0x168be
movzwl %ax, %edx
movl %ebx, %edi
movq %r12, %rsi
callq 0x698b
leaq 0x1ad01(%rip), %rdi     # 0x338c0
callq 0x673f
movq %rax, %r14
testq %rax, %rax
jne 0x18b61
jmp 0x18bef
leaq 0xae45(%rip), %rdi      # 0x23a1a
leaq 0xae29(%rip), %rsi      # 0x23a05
leaq 0xa7fa(%rip), %rdx      # 0x233dd
xorl %eax, %eax
callq 0x52b0
movq 0x30(%rsp), %rbp
leaq 0x16b2a(%rip), %rbx     # 0x2f720
movq %rbp, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16ec3
movl 0x16b3d(%rip), %eax     # 0x2f748
movl %eax, 0x16b3b(%rip)     # 0x2f74c
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x16ec3
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x16ec3
cmpl $0x0, 0x60(%rbp)
movq %rbp, %r12
je 0x18c4b
movq %r12, %rdi
movq 0x38(%rsp), %rsi
callq 0x1793a
movq 0x1c0(%r12), %rbx
cmpq $0x0, (%rbx)
je 0x18c69
movq %r12, %rdi
movq %rbx, %rsi
callq 0xb6e6
movq (%rbx), %rbx
jmp 0x18c53
callq 0x17e63
movzwl 0x1acab(%rip), %ebp     # 0x33920
callq 0x17d8f
movq 0x1aca7(%rip), %r14     # 0x33928
movl 0x1ac99(%rip), %ebx     # 0x33920
leal 0x2(%rbx), %eax
leaq (%rax,%rax,4), %rax
leaq (%r14,%rax,8), %rax
movq %rax, 0x1ac8f(%rip)     # 0x33928
leal 0x1(%rbx), %edi
callq 0x17eff
callq 0x17df9
movl 0x58(%r12), %r15d
movq %r12, %rdi
callq 0xcbe5
movzwl 0x1ac66(%rip), %ecx     # 0x33920
xorl %edx, %edx
cmpb $0x1, 0x48(%rsp)
sete %dl
movl %edx, 0x20(%rsp)
movl %ebp, 0x18(%rsp)
movl %ecx, 0x10(%rsp)
movzwl 0x44(%rsp), %ecx
movl %ecx, 0x8(%rsp)
cmpl $0x1, %r15d
movl $0x3, %esi
sbbl $0x0, %esi
movl $0x0, (%rsp)
movzwl 0x4c(%rsp), %edx
movq 0x50(%rsp), %r15
movq %r15, %rdi
movl %eax, %ecx
movl $0x34, %r8d
movl %r14d, %r9d
callq 0x1697e
movq %r12, %rdi
movq %r15, %rsi
callq 0x16b1e
movq %r12, %rdi
movq %r15, %rsi
callq 0x1848f
movq %r15, %rdi
callq 0x1862e
leaq 0x16ab2(%rip), %rsi     # 0x2f7e0
movq %r15, %rdi
callq 0x185f0
movq %r15, %rdi
callq 0x5190
movq %r15, %rdi
movl $0x2, %esi
movl %eax, %edx
callq 0x6ce0
movl 0x1abd5(%rip), %edx     # 0x33928
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %ecx
callq 0x16c4d
leaq 0x169b9(%rip), %rsi     # 0x2f720
movq %r15, %rdi
callq 0x18668
leaq 0x16a0a(%rip), %rsi     # 0x2f780
movq %r15, %rdi
callq 0x185f0
cmpl $0x0, 0x60(%r12)
je 0x18db6
movq %r15, %rdi
callq 0x5190
movq %r15, %rdi
movl $0x2, %esi
movl %eax, %edx
callq 0x6ce0
movq %r12, %rdi
movq %r15, %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x186a0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq