#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int *e_ident;
  int e_ehsize;
  int e_phentsize;
  int e_shentsize;
  int /*<<< orphan*/ e_shstrndx;
  int /*<<< orphan*/ e_shnum;
  int /*<<< orphan*/ e_phnum;
  int /*<<< orphan*/ e_flags;
  int /*<<< orphan*/ e_shoff;
  int /*<<< orphan*/ e_phoff;
  int /*<<< orphan*/ e_entry;
  int /*<<< orphan*/ e_version;
  int /*<<< orphan*/ e_machine;
  int /*<<< orphan*/ e_type;
};
typedef int /*<<< orphan*/ Elf64_Shdr;
typedef int /*<<< orphan*/ Elf64_Phdr;
typedef TYPE_1__ Elf64_Ehdr;

/* Variables and functions */
size_t EI_ABIVERSION;
size_t EI_CLASS;
size_t EI_DATA;
size_t EI_MAG0;
size_t EI_MAG1;
size_t EI_MAG2;
size_t EI_MAG3;
int EI_NIDENT;
size_t EI_OSABI;
size_t EI_VERSION;
int /*<<< orphan*/ beginblock(int);
int /*<<< orphan*/ endblock();
char *getcountstr(int /*<<< orphan*/, int);
int getindexfromoffset(int /*<<< orphan*/);
char *getoffsetstr(int /*<<< orphan*/, int);
char *getsectionid(int /*<<< orphan*/);
char *getsizestr(int, int);
int /*<<< orphan*/ out(char *);
char *straddress(int /*<<< orphan*/);
char *strchar(int);
char *strdec(int);
char *strdefbyte(int, char *);
char *strdefflags(int /*<<< orphan*/, char *);
char *strdefint(int /*<<< orphan*/, char *);
char *strhex(int);
void outehdr64(void const *ptr, long size, int ndx) {
  Elf64_Ehdr const *ehdr = ptr;
  int phndx, shndx, i;
  (void)size;
  (void)ndx;
  beginblock(1);
  beginblock(0);
  (out(strchar(ehdr->e_ident[EI_MAG0])));
  (out(strchar(ehdr->e_ident[EI_MAG1])));
  (out(strchar(ehdr->e_ident[EI_MAG2])));
  (out(strchar(ehdr->e_ident[EI_MAG3])));
  (out(strdefbyte(ehdr->e_ident[EI_CLASS], "ELFCLASS")));
  (out(strdefbyte(ehdr->e_ident[EI_DATA], "ELFDATA")));
  (out(strdefbyte(ehdr->e_ident[EI_VERSION], "EV_")));
  (out(strdefbyte(ehdr->e_ident[EI_OSABI], "ELFOSABI_")));
  (out(strdec(ehdr->e_ident[EI_ABIVERSION])));
  for (i = EI_ABIVERSION + 1; i < EI_NIDENT; ++i)
    (out(strhex(ehdr->e_ident[i])));
  endblock();
  (out(strdefint(ehdr->e_type, "ET_")));
  (out(strdefint(ehdr->e_machine, "EM_")));
  (out(strdefint(ehdr->e_version, "EV_")));
  (out(straddress(ehdr->e_entry)));
  phndx = getindexfromoffset(ehdr->e_phoff);
  shndx = getindexfromoffset(ehdr->e_shoff);
  out(getoffsetstr(ehdr->e_phoff, phndx));
  out(getoffsetstr(ehdr->e_shoff, shndx));
  (out(strdefflags(ehdr->e_flags, "EH_")));
  if (ehdr->e_ehsize == sizeof(Elf64_Ehdr))
    out("sizeof(Elf64_Ehdr)");
  else
    (out(strdec(ehdr->e_ehsize)));
  if (ehdr->e_phentsize == sizeof(Elf64_Phdr))
    out("sizeof(Elf64_Phdr)");
  else
    out(getsizestr(ehdr->e_phentsize, phndx));
  out(getcountstr(ehdr->e_phnum, phndx));
  if (ehdr->e_shentsize == sizeof(Elf64_Shdr))
    out("sizeof(Elf64_Shdr)");
  else
    out(getsizestr(ehdr->e_shentsize, shndx));
  out(getcountstr(ehdr->e_shnum, shndx));
  out(getsectionid(ehdr->e_shstrndx));
  endblock();
}


x86 assembly (clang, -O0):
<outehdr64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
call   10b0 <beginblock@plt>
xor    %edi,%edi
call   10b0 <beginblock@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2db6(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2d4d(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2d6c(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2d13(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2cfa(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd45(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2cea(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd26(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2cba(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd06(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2ca2(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xce2(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2c82(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   1090 <strdec@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x2c68(%rip),%rax
mov    (%rax),%rax
add    $0x1,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2c6c(%rip),%rcx
cmp    (%rcx),%eax
jge    13ad <outehdr64+0x1bd>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1060 <strhex@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1372 <outehdr64+0x182>
mov    $0x0,%al
call   1070 <endblock@plt>
mov    -0x20(%rbp),%rax
mov    0x38(%rax),%edi
lea    0xc5d(%rip),%rsi
call   1040 <strdefint@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x34(%rax),%edi
lea    0xc46(%rip),%rsi
call   1040 <strdefint@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x30(%rax),%edi
lea    0xc19(%rip),%rsi
call   1040 <strdefint@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x2c(%rax),%edi
call   1110 <straddress@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%edi
call   1030 <getindexfromoffset@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    0x24(%rax),%edi
call   1030 <getindexfromoffset@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%edi
mov    -0x24(%rbp),%esi
call   10c0 <getoffsetstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x24(%rax),%edi
mov    -0x28(%rbp),%esi
call   10c0 <getoffsetstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%edi
lea    0xbb4(%rip),%rsi
call   1050 <strdefflags@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
movslq 0x8(%rax),%rax
cmp    $0x40,%rax
jne    14a3 <outehdr64+0x2b3>
lea    0xb92(%rip),%rdi
call   1100 <out@plt>
jmp    14b7 <outehdr64+0x2c7>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%edi
call   1090 <strdec@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
movslq 0xc(%rax),%rax
cmp    $0x4,%rax
jne    14da <outehdr64+0x2ea>
lea    0xb6e(%rip),%rdi
call   1100 <out@plt>
jmp    14f1 <outehdr64+0x301>
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x24(%rbp),%esi
call   1080 <getsizestr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x1c(%rax),%edi
mov    -0x24(%rbp),%esi
call   10e0 <getcountstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
movslq 0x10(%rax),%rax
cmp    $0x4,%rax
jne    152b <outehdr64+0x33b>
lea    0xb30(%rip),%rdi
call   1100 <out@plt>
jmp    1542 <outehdr64+0x352>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x28(%rbp),%esi
call   1080 <getsizestr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x28(%rbp),%esi
call   10e0 <getcountstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%edi
call   10a0 <getsectionid@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    $0x0,%al
call   1070 <endblock@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outehdr64>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0x1,%edi
call   10b0 <beginblock@plt>
xor    %edi,%edi
call   10b0 <beginblock@plt>
mov    (%r15),%rax
mov    0x2dcb(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2d66(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2d89(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2d34(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   10f0 <strchar@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2d1f(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd6a(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2d13(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd4f(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2ce7(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd33(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2cd3(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xd13(%rip),%rsi
call   10d0 <strdefbyte@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%r15),%rax
mov    0x2cb7(%rip),%rbx
mov    (%rbx),%rcx
mov    (%rax,%rcx,4),%edi
call   1090 <strdec@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    (%rbx),%eax
add    $0x1,%eax
mov    0x2cb0(%rip),%rbp
cmp    0x0(%rbp),%eax
jge    135c <outehdr64+0x16c>
movslq %eax,%rbx
mov    (%r15),%rax
mov    (%rax,%rbx,4),%edi
call   1060 <strhex@plt>
mov    %rax,%rdi
call   1100 <out@plt>
add    $0x1,%rbx
cmp    %ebx,0x0(%rbp)
jg     1340 <outehdr64+0x150>
xor    %eax,%eax
call   1070 <endblock@plt>
mov    0x38(%r15),%edi
lea    0xcb1(%rip),%rsi
call   1040 <strdefint@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x34(%r15),%edi
lea    0xc9d(%rip),%rsi
call   1040 <strdefint@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x30(%r15),%edi
lea    0xc73(%rip),%rsi
call   1040 <strdefint@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x2c(%r15),%edi
call   1110 <straddress@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x28(%r15),%edi
call   1030 <getindexfromoffset@plt>
mov    %eax,%ebp
mov    0x24(%r15),%edi
call   1030 <getindexfromoffset@plt>
mov    %eax,%r14d
mov    0x28(%r15),%edi
mov    %ebp,%esi
call   10c0 <getoffsetstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x24(%r15),%edi
mov    %r14d,%esi
call   10c0 <getoffsetstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x20(%r15),%edi
lea    0xc22(%rip),%rsi
call   1050 <strdefflags@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x8(%r15),%edi
cmp    $0x40,%edi
jne    1424 <outehdr64+0x234>
lea    0xc09(%rip),%rdi
jmp    142c <outehdr64+0x23c>
call   1090 <strdec@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0xc(%r15),%edi
cmp    $0x4,%edi
jne    1443 <outehdr64+0x253>
lea    0xbfd(%rip),%rdi
jmp    144d <outehdr64+0x25d>
mov    %ebp,%esi
call   1080 <getsizestr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x1c(%r15),%edi
mov    %ebp,%esi
call   10e0 <getcountstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x10(%r15),%edi
cmp    $0x4,%edi
jne    1477 <outehdr64+0x287>
lea    0xbdc(%rip),%rdi
jmp    1482 <outehdr64+0x292>
mov    %r14d,%esi
call   1080 <getsizestr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x18(%r15),%edi
mov    %r14d,%esi
call   10e0 <getcountstr@plt>
mov    %rax,%rdi
call   1100 <out@plt>
mov    0x14(%r15),%edi
call   10a0 <getsectionid@plt>
mov    %rax,%rdi
call   1100 <out@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <endblock@plt>

LLVM IR (-O0):
%struct.TYPE_2__ = type { i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@EI_MAG0 = global i64 0
@EI_MAG1 = global i64 0
@EI_MAG2 = global i64 0
@EI_MAG3 = global i64 0
@EI_CLASS = global i64 0
@.str = [9 x i8] c"ELFCLASS\00"
@EI_DATA = global i64 0
@.str.1 = [8 x i8] c"ELFDATA\00"
@EI_VERSION = global i64 0
@.str.2 = [4 x i8] c"EV_\00"
@EI_OSABI = global i64 0
@.str.3 = [10 x i8] c"ELFOSABI_\00"
@EI_ABIVERSION = global i64 0
@EI_NIDENT = global i32 0
@.str.4 = [4 x i8] c"ET_\00"
@.str.5 = [4 x i8] c"EM_\00"
@.str.6 = [4 x i8] c"EH_\00"
@.str.7 = [19 x i8] c"sizeof(Elf64_Ehdr)\00"
@.str.8 = [19 x i8] c"sizeof(Elf64_Phdr)\00"
@.str.9 = [19 x i8] c"sizeof(Elf64_Shdr)\00"
define void @outehdr64(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca %struct.TYPE_2__*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to %struct.TYPE_2__*
store %struct.TYPE_2__* %12, %struct.TYPE_2__** %7
%13 = load i64, i64* %5
%14 = load i32, i32* %6
%15 = call i32 @beginblock(i32 1)
%16 = call i32 @beginblock(i32 0)
%17 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
%19 = load i32*, i32** %18
%20 = load i64, i64* @EI_MAG0
%21 = getelementptr inbounds i32, i32* %19, i64 %20
%22 = load i32, i32* %21
%23 = call i8* @strchar(i32 %22)
%24 = call i32 @out(i8* %23)
%25 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
%27 = load i32*, i32** %26
%28 = load i64, i64* @EI_MAG1
%29 = getelementptr inbounds i32, i32* %27, i64 %28
%30 = load i32, i32* %29
%31 = call i8* @strchar(i32 %30)
%32 = call i32 @out(i8* %31)
%33 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 0
%35 = load i32*, i32** %34
%36 = load i64, i64* @EI_MAG2
%37 = getelementptr inbounds i32, i32* %35, i64 %36
%38 = load i32, i32* %37
%39 = call i8* @strchar(i32 %38)
%40 = call i32 @out(i8* %39)
%41 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
%43 = load i32*, i32** %42
%44 = load i64, i64* @EI_MAG3
%45 = getelementptr inbounds i32, i32* %43, i64 %44
%46 = load i32, i32* %45
%47 = call i8* @strchar(i32 %46)
%48 = call i32 @out(i8* %47)
%49 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%50 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %49, i32 0, i32 0
%51 = load i32*, i32** %50
%52 = load i64, i64* @EI_CLASS
%53 = getelementptr inbounds i32, i32* %51, i64 %52
%54 = load i32, i32* %53
%55 = call i8* @strdefbyte(i32 %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%56 = call i32 @out(i8* %55)
%57 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%58 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %57, i32 0, i32 0
%59 = load i32*, i32** %58
%60 = load i64, i64* @EI_DATA
%61 = getelementptr inbounds i32, i32* %59, i64 %60
%62 = load i32, i32* %61
%63 = call i8* @strdefbyte(i32 %62, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%64 = call i32 @out(i8* %63)
%65 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%66 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %65, i32 0, i32 0
%67 = load i32*, i32** %66
%68 = load i64, i64* @EI_VERSION
%69 = getelementptr inbounds i32, i32* %67, i64 %68
%70 = load i32, i32* %69
%71 = call i8* @strdefbyte(i32 %70, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%72 = call i32 @out(i8* %71)
%73 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%74 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %73, i32 0, i32 0
%75 = load i32*, i32** %74
%76 = load i64, i64* @EI_OSABI
%77 = getelementptr inbounds i32, i32* %75, i64 %76
%78 = load i32, i32* %77
%79 = call i8* @strdefbyte(i32 %78, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%80 = call i32 @out(i8* %79)
%81 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%82 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %81, i32 0, i32 0
%83 = load i32*, i32** %82
%84 = load i64, i64* @EI_ABIVERSION
%85 = getelementptr inbounds i32, i32* %83, i64 %84
%86 = load i32, i32* %85
%87 = call i8* @strdec(i32 %86)
%88 = call i32 @out(i8* %87)
%89 = load i64, i64* @EI_ABIVERSION
%90 = add i64 %89, 1
%91 = trunc i64 %90 to i32
store i32 %91, i32* %10
br label %92
92: ; preds = %106, %3
%93 = load i32, i32* %10
%94 = load i32, i32* @EI_NIDENT
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %109
96: ; preds = %92
%97 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%98 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %97, i32 0, i32 0
%99 = load i32*, i32** %98
%100 = load i32, i32* %10
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i32, i32* %99, i64 %101
%103 = load i32, i32* %102
%104 = call i8* @strhex(i32 %103)
%105 = call i32 @out(i8* %104)
br label %106
106: ; preds = %96
%107 = load i32, i32* %10
%108 = add nsw i32 %107, 1
store i32 %108, i32* %10
br label %92
109: ; preds = %92
%110 = call i32 (...) @endblock()
%111 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%112 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %111, i32 0, i32 13
%113 = load i32, i32* %112
%114 = call i8* @strdefint(i32 %113, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%115 = call i32 @out(i8* %114)
%116 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%117 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %116, i32 0, i32 12
%118 = load i32, i32* %117
%119 = call i8* @strdefint(i32 %118, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%120 = call i32 @out(i8* %119)
%121 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%122 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %121, i32 0, i32 11
%123 = load i32, i32* %122
%124 = call i8* @strdefint(i32 %123, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%125 = call i32 @out(i8* %124)
%126 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%127 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %126, i32 0, i32 10
%128 = load i32, i32* %127
%129 = call i8* @straddress(i32 %128)
%130 = call i32 @out(i8* %129)
%131 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%132 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %131, i32 0, i32 9
%133 = load i32, i32* %132
%134 = call i32 @getindexfromoffset(i32 %133)
store i32 %134, i32* %8
%135 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%136 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %135, i32 0, i32 8
%137 = load i32, i32* %136
%138 = call i32 @getindexfromoffset(i32 %137)
store i32 %138, i32* %9
%139 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%140 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %139, i32 0, i32 9
%141 = load i32, i32* %140
%142 = load i32, i32* %8
%143 = call i8* @getoffsetstr(i32 %141, i32 %142)
%144 = call i32 @out(i8* %143)
%145 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%146 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %145, i32 0, i32 8
%147 = load i32, i32* %146
%148 = load i32, i32* %9
%149 = call i8* @getoffsetstr(i32 %147, i32 %148)
%150 = call i32 @out(i8* %149)
%151 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%152 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %151, i32 0, i32 7
%153 = load i32, i32* %152
%154 = call i8* @strdefflags(i32 %153, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%155 = call i32 @out(i8* %154)
%156 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%157 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %156, i32 0, i32 1
%158 = load i32, i32* %157
%159 = sext i32 %158 to i64
%160 = icmp eq i64 %159, 64
br i1 %160, label %161, label %163
161: ; preds = %109
%162 = call i32 @out(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %169
163: ; preds = %109
%164 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%165 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %164, i32 0, i32 1
%166 = load i32, i32* %165
%167 = call i8* @strdec(i32 %166)
%168 = call i32 @out(i8* %167)
br label %169
169: ; preds = %163, %161
%170 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%171 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %170, i32 0, i32 2
%172 = load i32, i32* %171
%173 = sext i32 %172 to i64
%174 = icmp eq i64 %173, 4
br i1 %174, label %175, label %177
175: ; preds = %169
%176 = call i32 @out(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %184
177: ; preds = %169
%178 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%179 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %178, i32 0, i32 2
%180 = load i32, i32* %179
%181 = load i32, i32* %8
%182 = call i8* @getsizestr(i32 %180, i32 %181)
%183 = call i32 @out(i8* %182)
br label %184
184: ; preds = %177, %175
%185 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%186 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %185, i32 0, i32 6
%187 = load i32, i32* %186
%188 = load i32, i32* %8
%189 = call i8* @getcountstr(i32 %187, i32 %188)
%190 = call i32 @out(i8* %189)
%191 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%192 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %191, i32 0, i32 3
%193 = load i32, i32* %192
%194 = sext i32 %193 to i64
%195 = icmp eq i64 %194, 4
br i1 %195, label %196, label %198
196: ; preds = %184
%197 = call i32 @out(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %205
198: ; preds = %184
%199 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%200 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %199, i32 0, i32 3
%201 = load i32, i32* %200
%202 = load i32, i32* %9
%203 = call i8* @getsizestr(i32 %201, i32 %202)
%204 = call i32 @out(i8* %203)
br label %205
205: ; preds = %198, %196
%206 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%207 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %206, i32 0, i32 5
%208 = load i32, i32* %207
%209 = load i32, i32* %9
%210 = call i8* @getcountstr(i32 %208, i32 %209)
%211 = call i32 @out(i8* %210)
%212 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%213 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %212, i32 0, i32 4
%214 = load i32, i32* %213
%215 = call i8* @getsectionid(i32 %214)
%216 = call i32 @out(i8* %215)
%217 = call i32 (...) @endblock()
ret void
}

LLVM IR (-O2):
@EI_MAG0 = global i64 0
@EI_MAG1 = global i64 0
@EI_MAG2 = global i64 0
@EI_MAG3 = global i64 0
@EI_CLASS = global i64 0
@.str = [9 x i8] c"ELFCLASS\00"
@EI_DATA = global i64 0
@.str.1 = [8 x i8] c"ELFDATA\00"
@EI_VERSION = global i64 0
@.str.2 = [4 x i8] c"EV_\00"
@EI_OSABI = global i64 0
@.str.3 = [10 x i8] c"ELFOSABI_\00"
@EI_ABIVERSION = global i64 0
@EI_NIDENT = global i32 0
@.str.4 = [4 x i8] c"ET_\00"
@.str.5 = [4 x i8] c"EM_\00"
@.str.6 = [4 x i8] c"EH_\00"
@.str.7 = [19 x i8] c"sizeof(Elf64_Ehdr)\00"
@.str.8 = [19 x i8] c"sizeof(Elf64_Phdr)\00"
@.str.9 = [19 x i8] c"sizeof(Elf64_Shdr)\00"
define void @outehdr64(i8* nocapture %0, i64 %1, i32 %2) {
%4 = tail call i32 @beginblock(i32 1)
%5 = tail call i32 @beginblock(i32 0)
%6 = bitcast i8* %0 to i32**
%7 = load i32*, i32** %6
%8 = load i64, i64* @EI_MAG0
%9 = getelementptr inbounds i32, i32* %7, i64 %8
%10 = load i32, i32* %9
%11 = tail call i8* @strchar(i32 %10)
%12 = tail call i32 @out(i8* %11)
%13 = load i32*, i32** %6
%14 = load i64, i64* @EI_MAG1
%15 = getelementptr inbounds i32, i32* %13, i64 %14
%16 = load i32, i32* %15
%17 = tail call i8* @strchar(i32 %16)
%18 = tail call i32 @out(i8* %17)
%19 = load i32*, i32** %6
%20 = load i64, i64* @EI_MAG2
%21 = getelementptr inbounds i32, i32* %19, i64 %20
%22 = load i32, i32* %21
%23 = tail call i8* @strchar(i32 %22)
%24 = tail call i32 @out(i8* %23)
%25 = load i32*, i32** %6
%26 = load i64, i64* @EI_MAG3
%27 = getelementptr inbounds i32, i32* %25, i64 %26
%28 = load i32, i32* %27
%29 = tail call i8* @strchar(i32 %28)
%30 = tail call i32 @out(i8* %29)
%31 = load i32*, i32** %6
%32 = load i64, i64* @EI_CLASS
%33 = getelementptr inbounds i32, i32* %31, i64 %32
%34 = load i32, i32* %33
%35 = tail call i8* @strdefbyte(i32 %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%36 = tail call i32 @out(i8* %35)
%37 = load i32*, i32** %6
%38 = load i64, i64* @EI_DATA
%39 = getelementptr inbounds i32, i32* %37, i64 %38
%40 = load i32, i32* %39
%41 = tail call i8* @strdefbyte(i32 %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%42 = tail call i32 @out(i8* %41)
%43 = load i32*, i32** %6
%44 = load i64, i64* @EI_VERSION
%45 = getelementptr inbounds i32, i32* %43, i64 %44
%46 = load i32, i32* %45
%47 = tail call i8* @strdefbyte(i32 %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%48 = tail call i32 @out(i8* %47)
%49 = load i32*, i32** %6
%50 = load i64, i64* @EI_OSABI
%51 = getelementptr inbounds i32, i32* %49, i64 %50
%52 = load i32, i32* %51
%53 = tail call i8* @strdefbyte(i32 %52, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%54 = tail call i32 @out(i8* %53)
%55 = load i32*, i32** %6
%56 = load i64, i64* @EI_ABIVERSION
%57 = getelementptr inbounds i32, i32* %55, i64 %56
%58 = load i32, i32* %57
%59 = tail call i8* @strdec(i32 %58)
%60 = tail call i32 @out(i8* %59)
%61 = load i64, i64* @EI_ABIVERSION
%62 = trunc i64 %61 to i32
%63 = add i32 %62, 1
%64 = load i32, i32* @EI_NIDENT
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %79
66: ; preds = %3
%67 = sext i32 %63 to i64
br label %68
68: ; preds = %66, %68
%69 = phi i64 [ %67, %66 ], [ %75, %68 ]
%70 = load i32*, i32** %6
%71 = getelementptr inbounds i32, i32* %70, i64 %69
%72 = load i32, i32* %71
%73 = tail call i8* @strhex(i32 %72)
%74 = tail call i32 @out(i8* %73)
%75 = add nsw i64 %69, 1
%76 = trunc i64 %75 to i32
%77 = load i32, i32* @EI_NIDENT
%78 = icmp sgt i32 %77, %76
br i1 %78, label %68, label %79
79: ; preds = %68, %3
%80 = tail call i32 (...) @endblock()
%81 = getelementptr inbounds i8, i8* %0, i64 56
%82 = bitcast i8* %81 to i32*
%83 = load i32, i32* %82
%84 = tail call i8* @strdefint(i32 %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%85 = tail call i32 @out(i8* %84)
%86 = getelementptr inbounds i8, i8* %0, i64 52
%87 = bitcast i8* %86 to i32*
%88 = load i32, i32* %87
%89 = tail call i8* @strdefint(i32 %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%90 = tail call i32 @out(i8* %89)
%91 = getelementptr inbounds i8, i8* %0, i64 48
%92 = bitcast i8* %91 to i32*
%93 = load i32, i32* %92
%94 = tail call i8* @strdefint(i32 %93, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%95 = tail call i32 @out(i8* %94)
%96 = getelementptr inbounds i8, i8* %0, i64 44
%97 = bitcast i8* %96 to i32*
%98 = load i32, i32* %97
%99 = tail call i8* @straddress(i32 %98)
%100 = tail call i32 @out(i8* %99)
%101 = getelementptr inbounds i8, i8* %0, i64 40
%102 = bitcast i8* %101 to i32*
%103 = load i32, i32* %102
%104 = tail call i32 @getindexfromoffset(i32 %103)
%105 = getelementptr inbounds i8, i8* %0, i64 36
%106 = bitcast i8* %105 to i32*
%107 = load i32, i32* %106
%108 = tail call i32 @getindexfromoffset(i32 %107)
%109 = load i32, i32* %102
%110 = tail call i8* @getoffsetstr(i32 %109, i32 %104)
%111 = tail call i32 @out(i8* %110)
%112 = load i32, i32* %106
%113 = tail call i8* @getoffsetstr(i32 %112, i32 %108)
%114 = tail call i32 @out(i8* %113)
%115 = getelementptr inbounds i8, i8* %0, i64 32
%116 = bitcast i8* %115 to i32*
%117 = load i32, i32* %116
%118 = tail call i8* @strdefflags(i32 %117, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%119 = tail call i32 @out(i8* %118)
%120 = getelementptr inbounds i8, i8* %0, i64 8
%121 = bitcast i8* %120 to i32*
%122 = load i32, i32* %121
%123 = icmp eq i32 %122, 64
br i1 %123, label %126, label %124
124: ; preds = %79
%125 = tail call i8* @strdec(i32 %122)
br label %126
126: ; preds = %79, %124
%127 = phi i8* [ %125, %124 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %79 ]
%128 = tail call i32 @out(i8* %127)
%129 = getelementptr inbounds i8, i8* %0, i64 12
%130 = bitcast i8* %129 to i32*
%131 = load i32, i32* %130
%132 = icmp eq i32 %131, 4
br i1 %132, label %135, label %133
133: ; preds = %126
%134 = tail call i8* @getsizestr(i32 %131, i32 %104)
br label %135
135: ; preds = %126, %133
%136 = phi i8* [ %134, %133 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), %126 ]
%137 = tail call i32 @out(i8* %136)
%138 = getelementptr inbounds i8, i8* %0, i64 28
%139 = bitcast i8* %138 to i32*
%140 = load i32, i32* %139
%141 = tail call i8* @getcountstr(i32 %140, i32 %104)
%142 = tail call i32 @out(i8* %141)
%143 = getelementptr inbounds i8, i8* %0, i64 16
%144 = bitcast i8* %143 to i32*
%145 = load i32, i32* %144
%146 = icmp eq i32 %145, 4
br i1 %146, label %149, label %147
147: ; preds = %135
%148 = tail call i8* @getsizestr(i32 %145, i32 %108)
br label %149
149: ; preds = %135, %147
%150 = phi i8* [ %148, %147 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), %135 ]
%151 = tail call i32 @out(i8* %150)
%152 = getelementptr inbounds i8, i8* %0, i64 24
%153 = bitcast i8* %152 to i32*
%154 = load i32, i32* %153
%155 = tail call i8* @getcountstr(i32 %154, i32 %108)
%156 = tail call i32 @out(i8* %155)
%157 = getelementptr inbounds i8, i8* %0, i64 20
%158 = bitcast i8* %157 to i32*
%159 = load i32, i32* %158
%160 = tail call i8* @getsectionid(i32 %159)
%161 = tail call i32 @out(i8* %160)
%162 = tail call i32 (...) @endblock()
ret void
}