char *decode_file_type(int x) {
  char *file_type[] = {"Unknown", "MZ-exe",    "PE",  "ELF",
                       "Macho",   "FAT Macho", "FAT", "FAT16",
                       "FAT32",   "EXT",       "MBR"};
  return file_type[x];
}


x86 assembly (clang, -O0):
<decode_file_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c9a(%rip),%rsi
mov    $0x58,%edx
call   1030 <memcpy@plt>
movslq -0x4(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_file_type>:
movslq %edi,%rax
lea    0xf2e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [7 x i8] c"MZ-exe\00"
@.str.2 = [3 x i8] c"PE\00"
@.str.3 = [4 x i8] c"ELF\00"
@.str.4 = [6 x i8] c"Macho\00"
@.str.5 = [10 x i8] c"FAT Macho\00"
@.str.6 = [4 x i8] c"FAT\00"
@.str.7 = [6 x i8] c"FAT16\00"
@.str.8 = [6 x i8] c"FAT32\00"
@.str.9 = [4 x i8] c"EXT\00"
@.str.10 = [4 x i8] c"MBR\00"
@__const.decode_file_type.file_type = [11 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0)]
define i8* @decode_file_type(i32 %0) {
%2 = alloca i32
%3 = alloca [11 x i8*]
store i32 %0, i32* %2
%4 = bitcast [11 x i8*]* %3 to i8*
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [11 x i8*], [11 x i8*]* %3, i64 0, i64 %6
%8 = load i8*, i8** %7
ret i8* %8
}

LLVM IR (-O2):
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [7 x i8] c"MZ-exe\00"
@.str.2 = [3 x i8] c"PE\00"
@.str.3 = [4 x i8] c"ELF\00"
@.str.4 = [6 x i8] c"Macho\00"
@.str.5 = [10 x i8] c"FAT Macho\00"
@.str.6 = [4 x i8] c"FAT\00"
@.str.7 = [6 x i8] c"FAT16\00"
@.str.8 = [6 x i8] c"FAT32\00"
@.str.9 = [4 x i8] c"EXT\00"
@.str.10 = [4 x i8] c"MBR\00"
@reltable.decode_file_type = [11 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.8 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([11 x i32]* @reltable.decode_file_type to i64)) to i32)]
define i8* @decode_file_type(i32 %0) {
%2 = sext i32 %0 to i64
%3 = shl i64 %2, 2
%4 = call i8* @llvm.load.relative.i64(i8* bitcast ([11 x i32]* @reltable.decode_file_type to i8*), i64 %3)
ret i8* %4
}