#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 */
typedef int Elf32_Half;

/* Variables and functions */
#define ET_CORE 134
#define ET_DYN 133
#define ET_EXEC 132
#define ET_HIPROC 131
#define ET_LOPROC 130
#define ET_NONE 129
#define ET_REL 128
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *);
int display_type(Elf32_Half type) {
  switch (type) {
  case ET_NONE:
    printf(" NONE");
    break;
  case ET_REL:
    printf(" relocatable");
    break;
  case ET_EXEC:
    printf("executable");
    break;
  case ET_DYN:
    printf("shared object");
    break;
  case ET_CORE:
    printf("core");
    break;
  case ET_LOPROC:
    printf("processor specific LO type");
    break;
  case ET_HIPROC:
    printf("processor specific HI type");
    break;
  default:
    printf("UNKNOWN");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<display_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11bb <display_type+0xab>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <display_type+0xb7>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_type>:
push   %rax
add    $0xffffff80,%edi
cmp    $0x6,%edi
ja     112c <display_type+0x1c>
movslq %edi,%rax
lea    0xf4d(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1133 <display_type+0x23>
lea    0xf34(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c" NONE\00"
@.str.1 = [13 x i8] c" relocatable\00"
@.str.2 = [11 x i8] c"executable\00"
@.str.3 = [14 x i8] c"shared object\00"
@.str.4 = [5 x i8] c"core\00"
@.str.5 = [27 x i8] c"processor specific LO type\00"
@.str.6 = [27 x i8] c"processor specific HI type\00"
@.str.7 = [8 x i8] c"UNKNOWN\00"
@EXIT_SUCCESS = global i32 0
define i32 @display_type(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %18 [
i32 129, label %4
i32 128, label %6
i32 132, label %8
i32 133, label %10
i32 134, label %12
i32 130, label %14
i32 131, label %16
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %20
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %20
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %20
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %20
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %20
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %20
18: ; preds = %1
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12, %10, %8, %6, %4
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

LLVM IR (-O2):
@.str = [6 x i8] c" NONE\00"
@.str.1 = [13 x i8] c" relocatable\00"
@.str.2 = [11 x i8] c"executable\00"
@.str.3 = [14 x i8] c"shared object\00"
@.str.4 = [5 x i8] c"core\00"
@.str.5 = [27 x i8] c"processor specific LO type\00"
@.str.6 = [27 x i8] c"processor specific HI type\00"
@.str.7 = [8 x i8] c"UNKNOWN\00"
@EXIT_SUCCESS = global i32 0
@reltable.display_type = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.display_type to i64)) to i32)]
define i32 @display_type(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 7
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.display_type to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), %1 ]
%10 = tail call i32 @printf(i8* dereferenceable(1) %9)
%11 = load i32, i32* @EXIT_SUCCESS
ret i32 %11
}