#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 */
int ELF64_ST_TYPE(unsigned char);
#define STT_COMMON 139
#define STT_FILE 138
#define STT_FUNC 137
#define STT_HIOS 136
#define STT_HIPROC 135
#define STT_LOOS 134
#define STT_LOPROC 133
#define STT_NOTYPE 132
#define STT_NUM 131
#define STT_OBJECT 130
#define STT_SECTION 129
#define STT_TLS 128
const char *st_type_lookup(unsigned char c) {
  switch (ELF64_ST_TYPE(c)) {
  case STT_NOTYPE:
    return "STT_NOTYPE";
  case STT_OBJECT:
    return "STT_OBJECT";
  case STT_FUNC:
    return "STT_FUNC";
  case STT_SECTION:
    return "STT_SECTION";
  case STT_FILE:
    return "STT_FILE";
  case STT_COMMON:
    return "STT_COMMON";
  case STT_TLS:
    return "STT_TLS";
  case STT_NUM:
    return "STT_NUM";
  case STT_LOOS:
    return "STT_LOOS/STT_GNU";
  case STT_HIOS:
    return "STT_HIOS";
  case STT_LOPROC:
    return "STT_LOPROC";
  case STT_HIPROC:
    return "STT_HIPROC";
  default:
    return "(UNKNOWN)";
  }
  return "(UNKNOWN)";
}


x86 assembly (clang, -O0):
<st_type_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%edi
call   1030 <ELF64_ST_TYPE@plt>
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xb,%eax
ja     120d <st_type_lookup+0xfd>
mov    -0x18(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xed7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xed2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xec7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xea0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <st_type_lookup+0x108>
lea    0xe9b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<st_type_lookup>:
push   %rax
call   1030 <ELF64_ST_TYPE@plt>
add    $0xffffff80,%eax
cmp    $0xb,%eax
ja     1130 <st_type_lookup+0x20>
cltq
lea    0xf65(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xf48(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"STT_NOTYPE\00"
@.str.1 = [11 x i8] c"STT_OBJECT\00"
@.str.2 = [9 x i8] c"STT_FUNC\00"
@.str.3 = [12 x i8] c"STT_SECTION\00"
@.str.4 = [9 x i8] c"STT_FILE\00"
@.str.5 = [11 x i8] c"STT_COMMON\00"
@.str.6 = [8 x i8] c"STT_TLS\00"
@.str.7 = [8 x i8] c"STT_NUM\00"
@.str.8 = [17 x i8] c"STT_LOOS/STT_GNU\00"
@.str.9 = [9 x i8] c"STT_HIOS\00"
@.str.10 = [11 x i8] c"STT_LOPROC\00"
@.str.11 = [11 x i8] c"STT_HIPROC\00"
@.str.12 = [10 x i8] c"(UNKNOWN)\00"
define i8* @st_type_lookup(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i32 @ELF64_ST_TYPE(i8 zeroext %4)
switch i32 %5, label %18 [
i32 132, label %6
i32 130, label %7
i32 137, label %8
i32 129, label %9
i32 138, label %10
i32 139, label %11
i32 128, label %12
i32 131, label %13
i32 134, label %14
i32 136, label %15
i32 133, label %16
i32 135, label %17
]
6: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
7: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %19
8: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %19
9: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %19
10: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %19
11: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %19
12: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %19
13: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %19
14: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %19
15: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %19
16: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %19
17: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %19
18: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [11 x i8] c"STT_NOTYPE\00"
@.str.1 = [11 x i8] c"STT_OBJECT\00"
@.str.2 = [9 x i8] c"STT_FUNC\00"
@.str.3 = [12 x i8] c"STT_SECTION\00"
@.str.4 = [9 x i8] c"STT_FILE\00"
@.str.5 = [11 x i8] c"STT_COMMON\00"
@.str.6 = [8 x i8] c"STT_TLS\00"
@.str.7 = [8 x i8] c"STT_NUM\00"
@.str.8 = [17 x i8] c"STT_LOOS/STT_GNU\00"
@.str.9 = [9 x i8] c"STT_HIOS\00"
@.str.10 = [11 x i8] c"STT_LOPROC\00"
@.str.11 = [11 x i8] c"STT_HIPROC\00"
@.str.12 = [10 x i8] c"(UNKNOWN)\00"
@reltable.st_type_lookup = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.st_type_lookup to i64)) to i32)]
define i8* @st_type_lookup(i8 zeroext %0) {
%2 = tail call i32 @ELF64_ST_TYPE(i8 zeroext %0)
%3 = add i32 %2, -128
%4 = icmp ult i32 %3, 12
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.st_type_lookup to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), %1 ]
ret i8* %10
}