char *get_lc_type(int type) {
  static char *lc_table[] = {"unknown",
                             "LC_SEGMENT",
                             "LC_SYMTAB",
                             "LC_SYMSEG",
                             "LC_THREAD",
                             "LC_UNIXTHREAD",
                             "LC_LOADFVMLIB",
                             "LC_IDFVMLIB",
                             "LC_IDENT",
                             "LC_FVMFILE",
                             "LC_PREPAGE",
                             "LC_DYSYMTAB",
                             "LC_LOAD_DYLIB",
                             "LC_ID_DYLIB",
                             "LC_LOAD_DYLINKER",
                             "LC_ID_DYLINKER",
                             "LC_PREBOUND_DYLIB",
                             "LC_ROUTINES",
                             "LC_SUB_FRAMEWORK",
                             "LC_SUB_UMBRELLA",
                             "LC_SUB_CLIENT",
                             "LC_SUB_LIBRARY",
                             "LC_TWOLEVEL_HINTS",
                             "LC_PREBIND_CKSUM",
                             "LC_LOAD_WEAK_DYLIB",
                             "LC_SEGMENT_64",
                             "LC_ROUTINES_64",
                             "LC_UUID",
                             "LC_RPATH",
                             "LC_CODE_SIGNATURE",
                             "LC_SEGMENT_SPLIT_INFO",
                             "LC_REEXPORT_DYLIB",
                             "LC_LAZY_LOAD_DYLIB",
                             "LC_ENCRYPTION_INFO 0x21",
                             "LC_DYLD_INFO"};
  if (type == (0x18 | 0x80000000))
    return "LC_LOAD_WEAK_DYLIB";
  if (type == (0x1c | 0x80000000))
    return "LC_RPATH";
  if (type == (0x1f | 0x80000000))
    return "LC_REEXPORT_DYLIB";
  if (type == (0x22 | 0x80000000))
    return "LC_DYLD_INFO_ONLY";
  if ((type < 0) || (type > 0x22))
    return "unknown";
  return lc_table[type];
}


x86 assembly (clang, -O0):
<get_lc_type>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x80000018,-0xc(%rbp)
jne    1124 <get_lc_type+0x24>
lea    0x1022(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <get_lc_type+0xb2>
cmpl   $0x8000001c,-0xc(%rbp)
jne    1141 <get_lc_type+0x41>
lea    0x103d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <get_lc_type+0xb2>
cmpl   $0x8000001f,-0xc(%rbp)
jne    115e <get_lc_type+0x5e>
lea    0x1051(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <get_lc_type+0xb2>
cmpl   $0x80000022,-0xc(%rbp)
jne    117b <get_lc_type+0x7b>
lea    0x107e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <get_lc_type+0xb2>
cmpl   $0x0,-0xc(%rbp)
jl     118f <get_lc_type+0x8f>
cmpl   $0x22,-0xc(%rbp)
jle    119f <get_lc_type+0x9f>
lea    0xe6a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <get_lc_type+0xb2>
movslq -0xc(%rbp),%rcx
lea    0x2e86(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_lc_type>:
lea    0x7fffffe8(%rdi),%ecx
cmp    $0xa,%ecx
ja     112a <get_lc_type+0x2a>
lea    0x10e3(%rip),%rax
lea    0xee7(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0x1104(%rip),%rax
ret
cmp    $0x22,%edi
jbe    1147 <get_lc_type+0x47>
lea    0xf82(%rip),%rax
ret
lea    0x1120(%rip),%rax
ret
lea    0x1162(%rip),%rax
ret
mov    %edi,%eax
lea    0xedc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@get_lc_type.lc_table = internal global [35 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.32, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.33, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.34, i32 0, i32 0)]
@.str = [8 x i8] c"unknown\00"
@.str.1 = [11 x i8] c"LC_SEGMENT\00"
@.str.2 = [10 x i8] c"LC_SYMTAB\00"
@.str.3 = [10 x i8] c"LC_SYMSEG\00"
@.str.4 = [10 x i8] c"LC_THREAD\00"
@.str.5 = [14 x i8] c"LC_UNIXTHREAD\00"
@.str.6 = [14 x i8] c"LC_LOADFVMLIB\00"
@.str.7 = [12 x i8] c"LC_IDFVMLIB\00"
@.str.8 = [9 x i8] c"LC_IDENT\00"
@.str.9 = [11 x i8] c"LC_FVMFILE\00"
@.str.10 = [11 x i8] c"LC_PREPAGE\00"
@.str.11 = [12 x i8] c"LC_DYSYMTAB\00"
@.str.12 = [14 x i8] c"LC_LOAD_DYLIB\00"
@.str.13 = [12 x i8] c"LC_ID_DYLIB\00"
@.str.14 = [17 x i8] c"LC_LOAD_DYLINKER\00"
@.str.15 = [15 x i8] c"LC_ID_DYLINKER\00"
@.str.16 = [18 x i8] c"LC_PREBOUND_DYLIB\00"
@.str.17 = [12 x i8] c"LC_ROUTINES\00"
@.str.18 = [17 x i8] c"LC_SUB_FRAMEWORK\00"
@.str.19 = [16 x i8] c"LC_SUB_UMBRELLA\00"
@.str.20 = [14 x i8] c"LC_SUB_CLIENT\00"
@.str.21 = [15 x i8] c"LC_SUB_LIBRARY\00"
@.str.22 = [18 x i8] c"LC_TWOLEVEL_HINTS\00"
@.str.23 = [17 x i8] c"LC_PREBIND_CKSUM\00"
@.str.24 = [19 x i8] c"LC_LOAD_WEAK_DYLIB\00"
@.str.25 = [14 x i8] c"LC_SEGMENT_64\00"
@.str.26 = [15 x i8] c"LC_ROUTINES_64\00"
@.str.27 = [8 x i8] c"LC_UUID\00"
@.str.28 = [9 x i8] c"LC_RPATH\00"
@.str.29 = [18 x i8] c"LC_CODE_SIGNATURE\00"
@.str.30 = [22 x i8] c"LC_SEGMENT_SPLIT_INFO\00"
@.str.31 = [18 x i8] c"LC_REEXPORT_DYLIB\00"
@.str.32 = [19 x i8] c"LC_LAZY_LOAD_DYLIB\00"
@.str.33 = [24 x i8] c"LC_ENCRYPTION_INFO 0x21\00"
@.str.34 = [13 x i8] c"LC_DYLD_INFO\00"
@.str.35 = [18 x i8] c"LC_DYLD_INFO_ONLY\00"
define i8* @get_lc_type(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, -2147483624
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.24, i64 0, i64 0), i8** %2
br label %31
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -2147483620
br i1 %9, label %10, label %11
10: ; preds = %7
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i64 0, i64 0), i8** %2
br label %31
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, -2147483617
br i1 %13, label %14, label %15
14: ; preds = %11
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.31, i64 0, i64 0), i8** %2
br label %31
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, -2147483614
br i1 %17, label %18, label %19
18: ; preds = %15
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.35, i64 0, i64 0), i8** %2
br label %31
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* %3
%24 = icmp sgt i32 %23, 34
br i1 %24, label %25, label %26
25: ; preds = %22, %19
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %31
26: ; preds = %22
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [35 x i8*], [35 x i8*]* @get_lc_type.lc_table, i64 0, i64 %28
%30 = load i8*, i8** %29
store i8* %30, i8** %2
br label %31
31: ; preds = %26, %25, %18, %14, %10, %6
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@reltable.get_lc_type = internal unnamed_addr constant [35 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.1 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.4 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.6 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.8 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.9 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.10 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.11 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.12 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.13 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.14 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.15 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.16 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.17 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.18 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.19 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.20 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.21 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.22 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.23 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.24 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.25 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.26 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.27 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.28 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.29 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.30 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.31 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.32 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.33 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.34 to i64), i64 ptrtoint ([35 x i32]* @reltable.get_lc_type to i64)) to i32)]
@.str = [8 x i8] c"unknown\00"
@.str.1 = [11 x i8] c"LC_SEGMENT\00"
@.str.2 = [10 x i8] c"LC_SYMTAB\00"
@.str.3 = [10 x i8] c"LC_SYMSEG\00"
@.str.4 = [10 x i8] c"LC_THREAD\00"
@.str.5 = [14 x i8] c"LC_UNIXTHREAD\00"
@.str.6 = [14 x i8] c"LC_LOADFVMLIB\00"
@.str.7 = [12 x i8] c"LC_IDFVMLIB\00"
@.str.8 = [9 x i8] c"LC_IDENT\00"
@.str.9 = [11 x i8] c"LC_FVMFILE\00"
@.str.10 = [11 x i8] c"LC_PREPAGE\00"
@.str.11 = [12 x i8] c"LC_DYSYMTAB\00"
@.str.12 = [14 x i8] c"LC_LOAD_DYLIB\00"
@.str.13 = [12 x i8] c"LC_ID_DYLIB\00"
@.str.14 = [17 x i8] c"LC_LOAD_DYLINKER\00"
@.str.15 = [15 x i8] c"LC_ID_DYLINKER\00"
@.str.16 = [18 x i8] c"LC_PREBOUND_DYLIB\00"
@.str.17 = [12 x i8] c"LC_ROUTINES\00"
@.str.18 = [17 x i8] c"LC_SUB_FRAMEWORK\00"
@.str.19 = [16 x i8] c"LC_SUB_UMBRELLA\00"
@.str.20 = [14 x i8] c"LC_SUB_CLIENT\00"
@.str.21 = [15 x i8] c"LC_SUB_LIBRARY\00"
@.str.22 = [18 x i8] c"LC_TWOLEVEL_HINTS\00"
@.str.23 = [17 x i8] c"LC_PREBIND_CKSUM\00"
@.str.24 = [19 x i8] c"LC_LOAD_WEAK_DYLIB\00"
@.str.25 = [14 x i8] c"LC_SEGMENT_64\00"
@.str.26 = [15 x i8] c"LC_ROUTINES_64\00"
@.str.27 = [8 x i8] c"LC_UUID\00"
@.str.28 = [9 x i8] c"LC_RPATH\00"
@.str.29 = [18 x i8] c"LC_CODE_SIGNATURE\00"
@.str.30 = [22 x i8] c"LC_SEGMENT_SPLIT_INFO\00"
@.str.31 = [18 x i8] c"LC_REEXPORT_DYLIB\00"
@.str.32 = [19 x i8] c"LC_LAZY_LOAD_DYLIB\00"
@.str.33 = [24 x i8] c"LC_ENCRYPTION_INFO 0x21\00"
@.str.34 = [13 x i8] c"LC_DYLD_INFO\00"
@.str.35 = [18 x i8] c"LC_DYLD_INFO_ONLY\00"
define i8* @get_lc_type(i32 %0) {
switch i32 %0, label %5 [
i32 -2147483624, label %11
i32 -2147483620, label %2
i32 -2147483617, label %3
i32 -2147483614, label %4
]
2: ; preds = %1
br label %11
3: ; preds = %1
br label %11
4: ; preds = %1
br label %11
5: ; preds = %1
%6 = icmp ugt i32 %0, 34
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = zext i32 %0 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([35 x i32]* @reltable.get_lc_type to i8*), i64 %9)
br label %11
11: ; preds = %5, %1, %7, %4, %3, %2
%12 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i64 0, i64 0), %2 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.31, i64 0, i64 0), %3 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.35, i64 0, i64 0), %4 ], [ %10, %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.24, i64 0, i64 0), %1 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %5 ]
ret i8* %12
}