// File: /workspace/github_c_makefile_star2_O2/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)
movl %ecx, %ebp
movl %edx, 0x4c(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdi, %rbx
callq 0x1559c
movq %rbx, %rdi
movl %eax, %esi
movl %ebp, 0x48(%rsp)
movl %ebp, %edx
callq 0x16fc0
movq %rbx, %rdi
callq 0x16bef
movq %rbx, %rdi
callq 0x15d58
movl %eax, 0x44(%rsp)
pushq $0x4
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x15c40
movq %rbx, %rdi
callq 0x1618f
movq %rbx, 0x30(%rsp)
cmpl $0x0, 0x240(%rbx)
je 0x17716
movl $0x0, 0x2c(%rsp)
cmpb $0x1, 0x18332(%rip)     # 0x2f820
sete %bpl
xorl %r12d, %r12d
movq 0x30(%rsp), %r14
cmpb $0x2, 0x6e(%r14)
sete %r12b
leaq 0x18366(%rip), %rax     # 0x2f870
movq (%rax,%r12,8), %rsi
xorl %r15d, %r15d
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
je 0x1752c
movq 0x78(%rax), %r15
leaq 0x1834d(%rip), %rax     # 0x2f880
movq (%rax,%r12,8), %rsi
xorl %ebx, %ebx
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
je 0x17554
movq 0x78(%rax), %rbx
movl 0x2c(%rsp), %eax
movb %bpl, %al
movl %eax, 0x2c(%rsp)
leaq 0x1c0(%r14), %r13
movq (%r13), %r13
cmpq $0x0, (%r13)
je 0x17637
movq 0x98(%r13), %rbp
movq %rbp, %r14
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x17566
movb 0x39(%r14), %al
testb %al, %al
js 0x175e0
cmpb $0x40, %al
jb 0x1757c
testq %rbx, %rbx
jne 0x175b9
leaq 0x182e0(%rip), %rax     # 0x2f880
movq (%rax,%r12,8), %rdx
leaq 0xa48f(%rip), %rdi      # 0x21a3a
leaq 0xa473(%rip), %rsi      # 0x21a25
xorl %eax, %eax
callq 0x6b2c
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq 0x38(%rsp), %r8
movl %r12d, %r9d
callq 0x17939
addq %rax, %rbx
jmp 0x1762a
testq %r15, %r15
jne 0x17605
leaq 0x18284(%rip), %rax     # 0x2f870
movq (%rax,%r12,8), %rdx
leaq 0xa443(%rip), %rdi      # 0x21a3a
leaq 0xa427(%rip), %rsi      # 0x21a25
xorl %eax, %eax
callq 0x6b2c
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq 0x38(%rsp), %r8
movl %r12d, %r9d
callq 0x17939
addq %rax, %r15
movq %r14, %rdi
callq 0x6444
jmp 0x1757c
leaq 0x9dbf(%rip), %rsi      # 0x213fd
movq 0x30(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
je 0x176fa
movq 0x78(%rax), %r13
leaq 0x180fa(%rip), %rbx     # 0x2f760
movq %r13, %r14
movq %rbx, %rdi
callq 0x642a
testq %rax, %rax
je 0x17684
movups 0x20(%rax), %xmm0
movups %xmm0, (%r14)
addq $0x10, %r14
jmp 0x17669
leaq 0x1c625(%rip), %rbx     # 0x33cb0
movl 0x2c(%rsp), %ebp
movq %rbx, %rdi
callq 0x642a
testq %rax, %rax
je 0x17716
movq %rax, %r14
movq 0x10(%rax), %rdi
callq 0x14d27
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 %ebp, %edi
callq 0x6681
movl 0x18(%r14), %eax
shlq $0x4, %rax
leaq (%rax,%r13), %r12
addq $0xe, %r12
movq 0x10(%r14), %rsi
movzbl %r15b, %edx
movq 0x30(%rsp), %rdi
callq 0x1568a
movzwl %ax, %edx
movl %ebp, %edi
movq %r12, %rsi
callq 0x666c
jmp 0x1768f
leaq 0xa339(%rip), %rdi      # 0x21a3a
leaq 0xa31d(%rip), %rsi      # 0x21a25
leaq 0x9cee(%rip), %rdx      # 0x213fd
xorl %eax, %eax
callq 0x6b2c
movq 0x30(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x15c40
movl 0x1802b(%rip), %eax     # 0x2f758
movl %eax, 0x18029(%rip)     # 0x2f75c
pushq $0x2
popq %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x15c40
pushq $0x1
popq %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x15c40
cmpl $0x0, 0x60(%r13)
je 0x17761
movq %r13, %rdi
movq 0x38(%rsp), %rsi
callq 0x165e9
leaq 0x1c0(%r13), %rbx
movq 0x50(%rsp), %r12
movq (%rbx), %rbx
cmpq $0x0, (%rbx)
je 0x17783
movq %r13, %rdi
movq %rbx, %rsi
callq 0xb170
jmp 0x1776d
callq 0x16af1
movzwl 0x1c581(%rip), %ebp     # 0x33d10
callq 0x16a0d
movq 0x1c57d(%rip), %r14     # 0x33d18
movl 0x1c56f(%rip), %ebx     # 0x33d10
leal 0x2(%rbx), %eax
imulq $0x28, %rax, %rax
addq %r14, %rax
movq %rax, 0x1c566(%rip)     # 0x33d18
leal 0x1(%rbx), %edi
callq 0x16b8f
callq 0x16a7f
movl 0x58(%r13), %r15d
movq %r13, %rdi
callq 0xc472
movzwl 0x1c53e(%rip), %ecx     # 0x33d10
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)
andl $0x0, (%rsp)
cmpl $0x1, %r15d
pushq $0x3
popq %rsi
sbbl $0x0, %esi
movzwl 0x4c(%rsp), %edx
pushq $0x34
popq %r8
movq %r12, %rdi
movl %eax, %ecx
movl %r14d, %r9d
callq 0x15748
movq %r13, %rdi
movq %r12, %rsi
callq 0x158de
movq %r13, %rdi
movq %r12, %rsi
callq 0x170bd
movq %r12, %rdi
callq 0x1722b
leaq 0x17fb6(%rip), %rsi     # 0x2f7f0
movq %r12, %rdi
callq 0x171f0
movq %r12, %rdi
callq 0x5190
pushq $0x2
popq %rsi
movq %r12, %rdi
movl %eax, %edx
callq 0x693c
movl 0x1c4bb(%rip), %edx     # 0x33d18
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %ecx
callq 0x15a0f
leaq 0x17ebf(%rip), %rsi     # 0x2f730
movq %r12, %rdi
callq 0x17261
leaq 0x17f10(%rip), %rsi     # 0x2f790
movq %r12, %rdi
callq 0x171f0
cmpl $0x0, 0x60(%r13)
je 0x178bd
movq %r12, %rdi
callq 0x5190
pushq $0x2
popq %rsi
movq %r12, %rdi
movl %eax, %edx
callq 0x693c
movq %r13, %rdi
movq %r12, %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17297
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq