#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_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int e_ehsize;
  int e_type;
  int e_machine;
  int e_version;
  int e_entry;
  int e_phnum;
  int e_phentsize;
  int e_shnum;
  int e_shentsize;
  int e_shoff;
};
typedef TYPE_1__ Elf32_Ehdr;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
void elf_header_print_info(Elf32_Ehdr *elf_header) {
  if (!elf_header)
    fprintf(stderr, "Error: No elf header\n");
  else {
    printf("[+] Elf header size      : %d\n", elf_header->e_ehsize);
    printf("[+] Elf object type      : %x\n", elf_header->e_type);
    printf("[+] Machine              : %x\n", elf_header->e_machine);
    printf("[+] Elf version          : %x\n", elf_header->e_version);
    printf("[+] Program entry point  : 0x%08x\n", elf_header->e_entry);
    printf("[+] Program header count : %d\n", elf_header->e_phnum);
    printf("[+] Program header size  : %d\n", elf_header->e_phentsize);
    printf("[+] Section header count : %d\n", elf_header->e_shnum);
    printf("[+] Section header size  : %d\n", elf_header->e_shentsize);
    printf("[+] Section offset       : %d\n", elf_header->e_shoff);
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<elf_header_print_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1161 <elf_header_print_info+0x31>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1228 <elf_header_print_info+0xf8>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xee8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%esi
lea    0xef4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
lea    0xf00(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%esi
lea    0xf0c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x24(%rax),%esi
lea    0xf18(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elf_header_print_info>:
push   %rbx
test   %rdi,%rdi
je     11dd <elf_header_print_info+0xad>
mov    %rdi,%rbx
mov    (%rdi),%esi
lea    0xed0(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xee0(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xef0(%rip),%rdi
call   1040 <printf@plt>
mov    0xc(%rbx),%esi
lea    0xf00(%rip),%rdi
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
lea    0xf10(%rip),%rdi
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
lea    0xf24(%rip),%rdi
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
lea    0xf34(%rip),%rdi
call   1040 <printf@plt>
mov    0x1c(%rbx),%esi
lea    0xf44(%rip),%rdi
call   1040 <printf@plt>
mov    0x20(%rbx),%esi
lea    0xf54(%rip),%rdi
call   1040 <printf@plt>
mov    0x24(%rbx),%esi
lea    0xf64(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
pop    %rbx
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"Error: No elf header\0A\00"
@.str.1 = [31 x i8] c"[+] Elf header size : %d\0A\00"
@.str.2 = [31 x i8] c"[+] Elf object type : %x\0A\00"
@.str.3 = [31 x i8] c"[+] Machine : %x\0A\00"
@.str.4 = [31 x i8] c"[+] Elf version : %x\0A\00"
@.str.5 = [35 x i8] c"[+] Program entry point : 0x%08x\0A\00"
@.str.6 = [31 x i8] c"[+] Program header count : %d\0A\00"
@.str.7 = [31 x i8] c"[+] Program header size : %d\0A\00"
@.str.8 = [31 x i8] c"[+] Section header count : %d\0A\00"
@.str.9 = [31 x i8] c"[+] Section header size : %d\0A\00"
@.str.10 = [31 x i8] c"[+] Section offset : %d\0A\00"
define void @elf_header_print_info(%struct.TYPE_3__* %0) {
%2 = alloca %struct.TYPE_3__*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %2
%3 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%4 = icmp ne %struct.TYPE_3__* %3, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %50
8: ; preds = %1
%9 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 2
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 4
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 5
%31 = load i32, i32* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %31)
%33 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %33, i32 0, i32 6
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i32 0, i32 7
%39 = load i32, i32* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %39)
%41 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %41, i32 0, i32 8
%43 = load i32, i32* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %43)
%45 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%46 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %45, i32 0, i32 9
%47 = load i32, i32* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %47)
%49 = call i32 @putchar(i8 signext 10)
br label %50
50: ; preds = %8, %5
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"Error: No elf header\0A\00"
@.str.1 = [31 x i8] c"[+] Elf header size : %d\0A\00"
@.str.2 = [31 x i8] c"[+] Elf object type : %x\0A\00"
@.str.3 = [31 x i8] c"[+] Machine : %x\0A\00"
@.str.4 = [31 x i8] c"[+] Elf version : %x\0A\00"
@.str.5 = [35 x i8] c"[+] Program entry point : 0x%08x\0A\00"
@.str.6 = [31 x i8] c"[+] Program header count : %d\0A\00"
@.str.7 = [31 x i8] c"[+] Program header size : %d\0A\00"
@.str.8 = [31 x i8] c"[+] Section header count : %d\0A\00"
@.str.9 = [31 x i8] c"[+] Section header size : %d\0A\00"
@.str.10 = [31 x i8] c"[+] Section offset : %d\0A\00"
define void @elf_header_print_info(%struct.TYPE_3__* %0) {
%2 = icmp eq %struct.TYPE_3__* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %38
6: ; preds = %1
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%11 = load i32, i32* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%14 = load i32, i32* %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 3
%17 = load i32, i32* %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 4
%20 = load i32, i32* %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 5
%23 = load i32, i32* %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 6
%26 = load i32, i32* %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 7
%29 = load i32, i32* %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 8
%32 = load i32, i32* %31
%33 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 9
%35 = load i32, i32* %34
%36 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %35)
%37 = tail call i32 @putchar(i8 signext 10)
br label %38
38: ; preds = %6, %3
ret void
}