const char *gp_htype_name(int htype) {
  static char *htype_name[] = {"GP_ERROR",      "GP_SINGLE",   "GP_DOUBLE",
                               "GP_THREE",      "GP_STRAIGHT", "GP_D_STRAIGHT",
                               "GP_T_STRAIGHT", "GP_THREE_P1", "GP_THREE_P2",
                               "GP_PLANE",      "GP_FOUR",     "GP_FOUR_P3",
                               "GP_BOMB"};
  if (htype <= 12)
    return htype_name[htype];
  else
    return htype_name[0];
}


x86 assembly (clang, -O0):
<gp_htype_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jg     1129 <gp_htype_name+0x29>
movslq -0xc(%rbp),%rcx
lea    0x2f14(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1134 <gp_htype_name+0x34>
mov    0x2f00(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gp_htype_name>:
cmp    $0xc,%edi
jg     1117 <gp_htype_name+0x17>
movslq %edi,%rax
lea    0xef1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf16(%rip),%rax
ret

LLVM IR (-O0):
@gp_htype_name.htype_name = internal global [13 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 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 ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 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 ([12 x i8], [12 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0)]
@.str = [9 x i8] c"GP_ERROR\00"
@.str.1 = [10 x i8] c"GP_SINGLE\00"
@.str.2 = [10 x i8] c"GP_DOUBLE\00"
@.str.3 = [9 x i8] c"GP_THREE\00"
@.str.4 = [12 x i8] c"GP_STRAIGHT\00"
@.str.5 = [14 x i8] c"GP_D_STRAIGHT\00"
@.str.6 = [14 x i8] c"GP_T_STRAIGHT\00"
@.str.7 = [12 x i8] c"GP_THREE_P1\00"
@.str.8 = [12 x i8] c"GP_THREE_P2\00"
@.str.9 = [9 x i8] c"GP_PLANE\00"
@.str.10 = [8 x i8] c"GP_FOUR\00"
@.str.11 = [11 x i8] c"GP_FOUR_P3\00"
@.str.12 = [8 x i8] c"GP_BOMB\00"
define i8* @gp_htype_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sle i32 %4, 12
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [13 x i8*], [13 x i8*]* @gp_htype_name.htype_name, i64 0, i64 %8
%10 = load i8*, i8** %9
store i8* %10, i8** %2
br label %13
11: ; preds = %1
%12 = load i8*, i8** getelementptr inbounds ([13 x i8*], [13 x i8*]* @gp_htype_name.htype_name, i64 0, i64 0)
store i8* %12, i8** %2
br label %13
13: ; preds = %11, %6
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@reltable.gp_htype_name = internal unnamed_addr constant [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.gp_htype_name to i64)) to i32)]
@.str = [9 x i8] c"GP_ERROR\00"
@.str.1 = [10 x i8] c"GP_SINGLE\00"
@.str.2 = [10 x i8] c"GP_DOUBLE\00"
@.str.3 = [9 x i8] c"GP_THREE\00"
@.str.4 = [12 x i8] c"GP_STRAIGHT\00"
@.str.5 = [14 x i8] c"GP_D_STRAIGHT\00"
@.str.6 = [14 x i8] c"GP_T_STRAIGHT\00"
@.str.7 = [12 x i8] c"GP_THREE_P1\00"
@.str.8 = [12 x i8] c"GP_THREE_P2\00"
@.str.9 = [9 x i8] c"GP_PLANE\00"
@.str.10 = [8 x i8] c"GP_FOUR\00"
@.str.11 = [11 x i8] c"GP_FOUR_P3\00"
@.str.12 = [8 x i8] c"GP_BOMB\00"
define i8* @gp_htype_name(i32 %0) {
%2 = icmp slt i32 %0, 13
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = shl i64 %4, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.gp_htype_name to i8*), i64 %5)
br label %7
7: ; preds = %1, %3
%8 = phi i8* [ %6, %3 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}