const char *s_result_name(int result) {
  static const char *table[] = {
      "PD", "OK", "RF", "ML", "OL", "TL", "RT", "AT", "IE",
  };
  return table[result];
}


x86 assembly (clang, -O0):
<s_result_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2f1e(%rip),%rax
mov    (%rax,%rcx,8),%rax
pop    %rbp
ret

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

LLVM IR (-O0):
@s_result_name.table = internal global [9 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 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 ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0)]
@.str = [3 x i8] c"PD\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"RF\00"
@.str.3 = [3 x i8] c"ML\00"
@.str.4 = [3 x i8] c"OL\00"
@.str.5 = [3 x i8] c"TL\00"
@.str.6 = [3 x i8] c"RT\00"
@.str.7 = [3 x i8] c"AT\00"
@.str.8 = [3 x i8] c"IE\00"
define i8* @s_result_name(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds [9 x i8*], [9 x i8*]* @s_result_name.table, i64 0, i64 %4
%6 = load i8*, i8** %5
ret i8* %6
}

LLVM IR (-O2):
@reltable.s_result_name = internal unnamed_addr constant [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.s_result_name to i64)) to i32)]
@.str = [3 x i8] c"PD\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"RF\00"
@.str.3 = [3 x i8] c"ML\00"
@.str.4 = [3 x i8] c"OL\00"
@.str.5 = [3 x i8] c"TL\00"
@.str.6 = [3 x i8] c"RT\00"
@.str.7 = [3 x i8] c"AT\00"
@.str.8 = [3 x i8] c"IE\00"
define i8* @s_result_name(i32 %0) {
%2 = sext i32 %0 to i64
%3 = shl i64 %2, 2
%4 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.s_result_name to i8*), i64 %3)
ret i8* %4
}