// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %r8, 0x18(%rsp)
movq %rdi, %rbp
movq 0x1f8(%rdi), %rax
testq %rax, %rax
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
je 0x18a51
xorl %esi, %esi
btl $0x4, 0x24(%rax)
adcl $0x0, %esi
movq (%rax), %rax
testq %rax, %rax
jne 0x18a39
shll $0x5, %esi
addl $0x34, %esi
jmp 0x18a56
movl $0x34, %esi
movl %ecx, 0x28(%rsp)
movsbl %cl, %edx
movq %rbp, %rdi
callq 0x184fc
movq %rbp, %rdi
callq 0x180e2
movq %rbp, %rdi
callq 0x171ac
movl %eax, 0x24(%rsp)
leaq 0x16ca0(%rip), %rsi     # 0x2f720
movq %rbp, %rdi
xorl %edx, %edx
movl $0x4, %ecx
callq 0x17082
movq %rbp, %rdi
callq 0x175e7
cmpl $0x0, 0x240(%rbp)
movq %rbp, 0x8(%rsp)
je 0x18d1b
xorl %r14d, %r14d
cmpb $0x1, 0x16d5d(%rip)     # 0x2f810
movq %rbp, %rdi
sete %bpl
xorl %r12d, %r12d
cmpb $0x2, 0x6e(%rdi)
sete %r12b
leaq 0x16d94(%rip), %rax     # 0x2f860
movq (%rax,%r12,8), %rsi
xorl %r15d, %r15d
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
je 0x18aeb
movq 0x78(%rax), %r15
leaq 0x16d7e(%rip), %rax     # 0x2f870
movq (%rax,%r12,8), %rsi
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
je 0x18b15
movq 0x78(%rax), %rbx
movb %bpl, %r14b
movq %r14, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq 0x1c0(%rax), %r14
cmpq $0x0, (%r14)
je 0x18c16
movq 0x98(%r14), %r13
movq (%r13), %rax
testq %rax, %rax
je 0x18c0e
movq %rax, %rbp
movb 0x39(%r13), %al
testb %al, %al
js 0x18bab
cmpb $0x40, %al
jb 0x18c02
testq %rbx, %rbx
jne 0x18b7f
leaq 0x16d0a(%rip), %rax     # 0x2f870
movq (%rax,%r12,8), %rdx
leaq 0xaec9(%rip), %rdi      # 0x23a3a
leaq 0xaead(%rip), %rsi      # 0x23a25
xorl %eax, %eax
callq 0x52b0
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq 0x20(%rsp), %r8
movl %r12d, %r9d
pushq 0x18(%rsp)
callq 0x18f62
addq $0x10, %rsp
addq %rax, %rbx
jmp 0x18bfa
testq %r15, %r15
jne 0x18bd0
leaq 0x16ca9(%rip), %rax     # 0x2f860
movq (%rax,%r12,8), %rdx
leaq 0xae78(%rip), %rdi      # 0x23a3a
leaq 0xae5c(%rip), %rsi      # 0x23a25
xorl %eax, %eax
callq 0x52b0
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq 0x20(%rsp), %r8
movl %r12d, %r9d
pushq 0x18(%rsp)
callq 0x18f62
addq $0x10, %rsp
addq %rax, %r15
movq %r13, %rdi
callq 0x6789
movq (%rbp), %rax
movq %rbp, %r13
jmp 0x18b3e
movq (%r14), %r14
jmp 0x18b29
leaq 0xa7e0(%rip), %rsi      # 0x233fd
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
je 0x18cff
movq 0x78(%rax), %r13
leaq 0x16b08(%rip), %rdi     # 0x2f750
callq 0x676f
testq %rax, %rax
je 0x18c75
leaq 0x16af7(%rip), %rbx     # 0x2f750
movq %r13, %r14
movups 0x20(%rax), %xmm0
movups %xmm0, (%r14)
addq $0x10, %r14
movq %rbx, %rdi
callq 0x676f
testq %rax, %rax
jne 0x18c5c
leaq 0x1ac44(%rip), %rdi     # 0x338c0
callq 0x676f
testq %rax, %rax
movq 0x10(%rsp), %rbx
je 0x18d1b
movq %rax, %r14
movq 0x10(%r14), %rdi
callq 0x16084
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 0x6a19
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 0x16a6c
movzwl %ax, %edx
movl %ebx, %edi
movq %r12, %rsi
callq 0x6a05
leaq 0x1abd0(%rip), %rdi     # 0x338c0
callq 0x676f
movq %rax, %r14
testq %rax, %rax
jne 0x18c92
jmp 0x18d1b
leaq 0xad34(%rip), %rdi      # 0x23a3a
leaq 0xad18(%rip), %rsi      # 0x23a25
leaq 0xa6e9(%rip), %rdx      # 0x233fd
xorl %eax, %eax
callq 0x52b0
leaq 0x169fe(%rip), %rbx     # 0x2f720
movq %rbp, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x17082
movl 0x16a11(%rip), %eax     # 0x2f748
movl %eax, 0x16a0f(%rip)     # 0x2f74c
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x17082
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x17082
cmpl $0x0, 0x60(%rbp)
je 0x18d74
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
callq 0x17abe
movq 0x1c0(%rbp), %rbx
cmpq $0x0, (%rbx)
movq 0x30(%rsp), %r13
je 0x18d9a
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xb7c8
movq (%rbx), %rbx
cmpq $0x0, (%rbx)
jne 0x18d86
callq 0x17fe5
movzwl 0x1ab79(%rip), %r15d    # 0x33920
callq 0x17f11
movq 0x1ab75(%rip), %r14     # 0x33928
movl 0x1ab67(%rip), %ebx     # 0x33920
leal 0x2(%rbx), %eax
leaq (%rax,%rax,4), %rax
leaq (%r14,%rax,8), %rax
movq %rax, 0x1ab5d(%rip)     # 0x33928
leal 0x1(%rbx), %edi
callq 0x18080
callq 0x17f7b
movq 0x8(%rsp), %rax
movl 0x58(%rax), %ebp
movq 0x8(%rsp), %rdi
callq 0xcc6b
movzwl 0x1ab2e(%rip), %r10d    # 0x33920
xorl %r11d, %r11d
cmpb $0x1, 0x28(%rsp)
sete %r11b
subq $0x8, %rsp
cmpl $0x1, %ebp
movq 0x10(%rsp), %rbp
movl $0x3, %esi
sbbl $0x0, %esi
movzwl 0x2c(%rsp), %r12d
movzwl 0x34(%rsp), %edx
movq %r13, %rdi
movl %eax, %ecx
movl $0x34, %r8d
movl %r14d, %r9d
pushq %r11
pushq %r15
pushq %r10
pushq %r12
pushq $0x0
callq 0x16b2f
addq $0x30, %rsp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x16cdd
movq %rbp, %rdi
movq %r13, %rsi
callq 0x18608
movq %r13, %rdi
callq 0x1878a
leaq 0x1697d(%rip), %rsi     # 0x2f7e0
movq %r13, %rdi
callq 0x1874c
movq %r13, %rdi
callq 0x5190
movq %r13, %rdi
movl $0x2, %esi
movl %eax, %edx
callq 0x6d55
movl 0x1aaa0(%rip), %edx     # 0x33928
movq %rbp, %rdi
movq %r13, %rsi
movl %ebx, %ecx
callq 0x16e0c
leaq 0x16884(%rip), %rsi     # 0x2f720
movq %r13, %rdi
callq 0x187c4
leaq 0x168d5(%rip), %rsi     # 0x2f780
movq %r13, %rdi
callq 0x1874c
cmpl $0x0, 0x60(%rbp)
je 0x18ee9
movq %r13, %rdi
callq 0x5190
movq %r13, %rdi
movl $0x2, %esi
movl %eax, %edx
callq 0x6d55
movq %rbp, %rdi
movq %r13, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x187fc
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq