#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 */

/* Type definitions */

/* Variables and functions */
size_t EI_DATA;
size_t EI_OSABI;
size_t EI_VERSION;
#define ELFDATA2LSB 145
#define ELFDATA2MSB 144
#define ELFDATANONE 143
#define ELFDATANUM 142
#define ELFOSABI_AIX 141
#define ELFOSABI_ARM 140
#define ELFOSABI_ARM_AEABI 139
#define ELFOSABI_FREEBSD 138
#define ELFOSABI_GNU 137
#define ELFOSABI_HPUX 136
#define ELFOSABI_IRIX 135
#define ELFOSABI_MODESTO 134
#define ELFOSABI_NETBSD 133
#define ELFOSABI_NONE 132
#define ELFOSABI_OPENBSD 131
#define ELFOSABI_SOLARIS 130
#define ELFOSABI_STANDALONE 129
#define ELFOSABI_TRU64 128
int /*<<< orphan*/ printf(char *);
void parse_e_ident(unsigned char *e_ident) {
  switch (e_ident[EI_DATA]) {
  case ELFDATANONE:
    printf(" and does not have a valid machine archetecture\n");
    break;
  case ELFDATA2LSB:
    printf(" in little endian 2's compiment.\n");
    break;
  case ELFDATA2MSB:
    printf(" in big endian 2's compliment.\n");
    break;
  case ELFDATANUM:
    printf(" and I need to look up 0x03 spec.\n");
    break;
  }
  if (e_ident[EI_VERSION] == 0x01) {
    printf("ELF Version 1.\n");
  }
  printf("Target operating system: ");
  switch (e_ident[EI_OSABI]) {
  case ELFOSABI_NONE:
    printf("UNIX System V ABI.\n");
    break;
  case ELFOSABI_HPUX:
    printf("HP-UX.\n");
    break;
  case ELFOSABI_NETBSD:
    printf("NetBSD.\n");
    break;
  case ELFOSABI_GNU:
    printf("GNU/Linux.\n");
    break;
  case ELFOSABI_SOLARIS:
    printf("Sun Solaris.\n");
    break;
  case ELFOSABI_AIX:
    printf("IBM AIX.\n");
    break;
  case ELFOSABI_IRIX:
    printf("SGI Irix.\n");
    break;
  case ELFOSABI_FREEBSD:
    printf("FreeBSD.\n");
    break;
  case ELFOSABI_TRU64:
    printf("Compaq TRU64 UNIX.\n");
    break;
  case ELFOSABI_MODESTO:
    printf("Novell Modesto.\n");
    break;
  case ELFOSABI_OPENBSD:
    printf("OpenBSD.\n");
    break;
  case ELFOSABI_ARM_AEABI:
    printf("ARM EABI.\n");
    break;
  case ELFOSABI_ARM:
    printf("ARM.\n");
    break;
  case ELFOSABI_STANDALONE:
    printf("Stanalone (embedded) application.\n");
    break;
  }
}


x86 assembly (clang, -O0):
<parse_e_ident>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2eb9(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
add    $0xffffff72,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1195 <parse_e_ident+0x85>
mov    -0x10(%rbp),%rax
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <parse_e_ident+0x85>
lea    0xf0b(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <parse_e_ident+0x85>
lea    0xf1c(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <parse_e_ident+0x85>
lea    0xf2b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x2e38(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    11bc <parse_e_ident+0xac>
lea    0xf27(%rip),%rdi
call   1030 <printf@plt>
lea    0xf2b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x2e15(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xd,%eax
ja     12e9 <parse_e_ident+0x1d9>
mov    -0x18(%rbp),%rax
lea    0xe19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf01(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xf04(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xefb(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xef3(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
jmp    12e9 <parse_e_ident+0x1d9>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_e_ident>:
push   %rbx
mov    %rdi,%rbx
mov    0x2eb5(%rip),%rax
mov    (%rax),%rax
mov    (%rdi,%rax,1),%al
add    $0x72,%al
cmp    $0x3,%al
ja     114e <parse_e_ident+0x2e>
movsbq %al,%rax
lea    0x102e(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
cmpb   $0x1,(%rbx,%rax,1)
jne    116a <parse_e_ident+0x4a>
lea    0xf8a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
movsbq (%rbx,%rax,1),%rax
xor    $0xffffffffffffff80,%rax
cmp    $0xd,%al
ja     11a1 <parse_e_ident+0x81>
lea    0xfec(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rbx
jmp    1030 <puts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@EI_DATA = global i64 0
@.str = [49 x i8] c" and does not have a valid machine archetecture\0A\00"
@.str.1 = [34 x i8] c" in little endian 2's compiment.\0A\00"
@.str.2 = [32 x i8] c" in big endian 2's compliment.\0A\00"
@.str.3 = [35 x i8] c" and I need to look up 0x03 spec.\0A\00"
@EI_VERSION = global i64 0
@.str.4 = [16 x i8] c"ELF Version 1.\0A\00"
@.str.5 = [26 x i8] c"Target operating system: \00"
@EI_OSABI = global i64 0
@.str.6 = [20 x i8] c"UNIX System V ABI.\0A\00"
@.str.7 = [8 x i8] c"HP-UX.\0A\00"
@.str.8 = [9 x i8] c"NetBSD.\0A\00"
@.str.9 = [12 x i8] c"GNU/Linux.\0A\00"
@.str.10 = [14 x i8] c"Sun Solaris.\0A\00"
@.str.11 = [10 x i8] c"IBM AIX.\0A\00"
@.str.12 = [11 x i8] c"SGI Irix.\0A\00"
@.str.13 = [10 x i8] c"FreeBSD.\0A\00"
@.str.14 = [20 x i8] c"Compaq TRU64 UNIX.\0A\00"
@.str.15 = [17 x i8] c"Novell Modesto.\0A\00"
@.str.16 = [10 x i8] c"OpenBSD.\0A\00"
@.str.17 = [11 x i8] c"ARM EABI.\0A\00"
@.str.18 = [6 x i8] c"ARM.\0A\00"
@.str.19 = [35 x i8] c"Stanalone (embedded) application.\0A\00"
define void @parse_e_ident(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i64, i64* @EI_DATA
%5 = getelementptr inbounds i8, i8* %3, i64 %4
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
switch i32 %7, label %16 [
i32 143, label %8
i32 145, label %10
i32 144, label %12
i32 142, label %14
]
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %16
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %16
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %1, %14, %12, %10, %8
%17 = load i8*, i8** %2
%18 = load i64, i64* @EI_VERSION
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %16
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%27 = load i8*, i8** %2
%28 = load i64, i64* @EI_OSABI
%29 = getelementptr inbounds i8, i8* %27, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
switch i32 %31, label %60 [
i32 132, label %32
i32 136, label %34
i32 133, label %36
i32 137, label %38
i32 130, label %40
i32 141, label %42
i32 135, label %44
i32 138, label %46
i32 128, label %48
i32 134, label %50
i32 131, label %52
i32 139, label %54
i32 140, label %56
i32 129, label %58
]
32: ; preds = %25
%33 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %60
34: ; preds = %25
%35 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %60
36: ; preds = %25
%37 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %60
38: ; preds = %25
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %60
40: ; preds = %25
%41 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %60
42: ; preds = %25
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
br label %60
44: ; preds = %25
%45 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br label %60
46: ; preds = %25
%47 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0))
br label %60
48: ; preds = %25
%49 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
br label %60
50: ; preds = %25
%51 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
br label %60
52: ; preds = %25
%53 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
br label %60
54: ; preds = %25
%55 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0))
br label %60
56: ; preds = %25
%57 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
br label %60
58: ; preds = %25
%59 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.19, i64 0, i64 0))
br label %60
60: ; preds = %25, %58, %56, %54, %52, %50, %48, %46, %44, %42, %40, %38, %36, %34, %32
ret void
}

LLVM IR (-O2):
@EI_DATA = global i64 0
@EI_VERSION = global i64 0
@.str.5 = [26 x i8] c"Target operating system: \00"
@EI_OSABI = global i64 0
@str = [34 x i8] c" and I need to look up 0x03 spec.\00"
@str.20 = [34 x i8] c"Stanalone (embedded) application.\00"
@str.21 = [5 x i8] c"ARM.\00"
@str.22 = [10 x i8] c"ARM EABI.\00"
@str.23 = [9 x i8] c"OpenBSD.\00"
@str.24 = [16 x i8] c"Novell Modesto.\00"
@str.25 = [19 x i8] c"Compaq TRU64 UNIX.\00"
@str.26 = [9 x i8] c"FreeBSD.\00"
@str.27 = [10 x i8] c"SGI Irix.\00"
@str.28 = [9 x i8] c"IBM AIX.\00"
@str.29 = [13 x i8] c"Sun Solaris.\00"
@str.30 = [11 x i8] c"GNU/Linux.\00"
@str.31 = [8 x i8] c"NetBSD.\00"
@str.32 = [7 x i8] c"HP-UX.\00"
@str.33 = [19 x i8] c"UNIX System V ABI.\00"
@str.34 = [15 x i8] c"ELF Version 1.\00"
@str.35 = [31 x i8] c" in big endian 2's compliment.\00"
@str.36 = [33 x i8] c" in little endian 2's compiment.\00"
@str.37 = [48 x i8] c" and does not have a valid machine archetecture\00"
@reltable.parse_e_ident = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @str to i64), i64 ptrtoint ([4 x i32]* @reltable.parse_e_ident to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([48 x i8]* @str.37 to i64), i64 ptrtoint ([4 x i32]* @reltable.parse_e_ident to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str.35 to i64), i64 ptrtoint ([4 x i32]* @reltable.parse_e_ident to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @str.36 to i64), i64 ptrtoint ([4 x i32]* @reltable.parse_e_ident to i64)) to i32)]
@reltable.parse_e_ident.39 = [14 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.25 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @str.20 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.29 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.23 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.33 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @str.31 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.24 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.27 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.32 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.30 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.26 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.22 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.21 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.28 to i64), i64 ptrtoint ([14 x i32]* @reltable.parse_e_ident.39 to i64)) to i32)]
define void @parse_e_ident(i8* nocapture %0) {
%2 = load i64, i64* @EI_DATA
%3 = getelementptr inbounds i8, i8* %0, i64 %2
%4 = load i8, i8* %3
%5 = add i8 %4, 114
%6 = icmp ult i8 %5, 4
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = sext i8 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.parse_e_ident to i8*), i64 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %1, %7
%13 = load i64, i64* @EI_VERSION
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.34, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%21 = load i64, i64* @EI_OSABI
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = xor i8 %23, -128
%25 = icmp ult i8 %24, 14
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = sext i8 %24 to i64
%28 = shl i64 %27, 2
%29 = call i8* @llvm.load.relative.i64(i8* bitcast ([14 x i32]* @reltable.parse_e_ident.39 to i8*), i64 %28)
%30 = tail call i32 @puts(i8* dereferenceable(1) %29)
br label %31
31: ; preds = %19, %26
ret void
}