// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_header
void elf32_header(FILE *f,uint16_t type,uint16_t mach,uint32_t entry,
                  uint32_t phoff,uint32_t shoff,uint32_t flags,uint16_t phnum,
                  uint16_t shnum,uint16_t shstrndx,bool be)
/* write 32-bit ELF header */
{
  struct Elf32_Ehdr eh;

  memset(&eh,0,sizeof(struct Elf32_Ehdr));
  strncpy((char *)eh.e_ident,ELFid,4);
  eh.e_ident[EI_CLASS] = ELFCLASS32;
  eh.e_ident[EI_DATA] = be ? ELFDATA2MSB : ELFDATA2LSB;
  eh.e_ident[EI_VERSION] = ELF_VER;
  write16(be,eh.e_type,type);
  write16(be,eh.e_machine,mach);
  write32(be,eh.e_version,ELF_VER);
  write32(be,eh.e_entry,entry);
  write32(be,eh.e_phoff,phoff);
  write32(be,eh.e_shoff,shoff);
  write32(be,eh.e_flags,flags);
  write16(be,eh.e_ehsize,sizeof(struct Elf32_Ehdr));
  write16(be,eh.e_phentsize,phnum ? sizeof(struct Elf32_Phdr):0);
  write16(be,eh.e_phnum,phnum);
  write16(be,eh.e_shentsize,shnum ? sizeof(struct Elf32_Shdr):0);
  write16(be,eh.e_shnum,shnum);
  write16(be,eh.e_shstrndx,shstrndx);
  fwritex(f,&eh,sizeof(struct Elf32_Ehdr));
}

// Assembly:
subq $0x58, %rsp
movw %dx, %ax
movw %si, %dx
movl 0x80(%rsp), %esi
movw 0x78(%rsp), %si
movw 0x70(%rsp), %si
movw 0x68(%rsp), %si
movl 0x60(%rsp), %esi
movq %rdi, 0x50(%rsp)
movw %dx, 0x4e(%rsp)
movw %ax, 0x4c(%rsp)
movl %ecx, 0x48(%rsp)
movl %r8d, 0x44(%rsp)
movl %r9d, 0x40(%rsp)
leaq 0xc(%rsp), %rdi
xorl %esi, %esi
movl $0x34, %edx
callq 0x5100
leaq 0xc(%rsp), %rdi
leaq 0x1c632(%rip), %rsi     # 0x40340
movl $0x4, %edx
callq 0x5040
movb $0x1, 0x10(%rsp)
movl 0x80(%rsp), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, 0x11(%rsp)
movb $0x1, 0x12(%rsp)
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x10, %rsi
movzwl 0x4e(%rsp), %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x12, %rsi
movzwl 0x4c(%rsp), %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x14, %rsi
movl $0x1, %edx
callq 0x8130
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x18, %rsi
movl 0x48(%rsp), %edx
callq 0x8130
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x1c, %rsi
movl 0x44(%rsp), %edx
callq 0x8130
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x20, %rsi
movl 0x40(%rsp), %edx
callq 0x8130
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x24, %rsi
movl 0x60(%rsp), %edx
callq 0x8130
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x28, %rsi
movl $0x34, %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x2a, %rsi
movzwl 0x68(%rsp), %edx
xorl %eax, %eax
movl $0x20, %ecx
cmpl $0x0, %edx
cmovneq %rcx, %rax
movzwl %ax, %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x2c, %rsi
movzwl 0x68(%rsp), %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x2e, %rsi
movzwl 0x70(%rsp), %edx
xorl %eax, %eax
movl $0x28, %ecx
cmpl $0x0, %edx
cmovneq %rcx, %rax
movzwl %ax, %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x30, %rsi
movzwl 0x70(%rsp), %edx
callq 0x80e0
movl 0x80(%rsp), %edi
leaq 0xc(%rsp), %rsi
addq $0x32, %rsi
movzwl 0x78(%rsp), %edx
callq 0x80e0
movq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rsi
movl $0x34, %edx
callq 0x8470
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)