const char *index_print(char index) {
  static char def[2];
  switch (index) {
  case '.':
    return "period";
  case ',':
    return "comma";
  case '/':
    return "slash";
  case '&':
    return "amp";
  case '-':
    return "minus";
  case '!':
    return "bang";
  case '$':
    return "dollar";
  case '%':
    return "percent";
  default:
    def[0] = index;
    def[1] = '\0';
    return def;
  }
}


x86 assembly (clang, -O0):
<index_print>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffdf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xe,%eax
ja     11b4 <index_print+0xb4>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf01(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xef8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xeee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xee4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xed8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xec3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
lea    0xeba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <index_print+0xcf>
mov    -0x9(%rbp),%al
mov    %al,0x2e64(%rip)
movb   $0x0,0x2e5e(%rip)
lea    0x2e56(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_print>:
lea    -0x21(%rdi),%eax
cmp    $0xf,%eax
jae    1112 <index_print+0x12>
mov    $0x7839,%ecx
bt     %eax,%ecx
jb     1128 <index_print+0x28>
mov    %dil,0x2f08(%rip)
lea    0x2f01(%rip),%rax
movb   $0x0,0x2efb(%rip)
ret
cltq
lea    0xf03(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@index_print.def = internal global [2 x i8] zeroinitializer
@.str = [7 x i8] c"period\00"
@.str.1 = [6 x i8] c"comma\00"
@.str.2 = [6 x i8] c"slash\00"
@.str.3 = [4 x i8] c"amp\00"
@.str.4 = [6 x i8] c"minus\00"
@.str.5 = [5 x i8] c"bang\00"
@.str.6 = [7 x i8] c"dollar\00"
@.str.7 = [8 x i8] c"percent\00"
define i8* @index_print(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %14 [
i32 46, label %6
i32 44, label %7
i32 47, label %8
i32 38, label %9
i32 45, label %10
i32 33, label %11
i32 36, label %12
i32 37, label %13
]
6: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
br label %16
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %16
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %16
9: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %16
10: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %16
11: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %16
12: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %16
13: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %16
14: ; preds = %1
%15 = load i8, i8* %3
store i8 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @index_print.def, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @index_print.def, i64 0, i64 1)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @index_print.def, i64 0, i64 0), i8** %2
br label %16
16: ; preds = %14, %13, %12, %11, %10, %9, %8, %7, %6
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@index_print.def = internal global [2 x i8] zeroinitializer
@.str = [7 x i8] c"period\00"
@.str.1 = [6 x i8] c"comma\00"
@.str.2 = [6 x i8] c"slash\00"
@.str.3 = [4 x i8] c"amp\00"
@.str.4 = [6 x i8] c"minus\00"
@.str.5 = [5 x i8] c"bang\00"
@.str.6 = [7 x i8] c"dollar\00"
@.str.7 = [8 x i8] c"percent\00"
@reltable.index_print = [15 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([15 x i32]* @reltable.index_print to i64)) to i32)]
define i8* @index_print(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -33
%4 = icmp ult i32 %3, 15
br i1 %4, label %6, label %5
5: ; preds = %6, %1
store i8 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @index_print.def, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @index_print.def, i64 0, i64 1)
br label %15
6: ; preds = %1
%7 = trunc i32 %3 to i16
%8 = lshr i16 30777, %7
%9 = and i16 %8, 1
%10 = icmp eq i16 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %6
%12 = sext i32 %3 to i64
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([15 x i32]* @reltable.index_print to i8*), i64 %13)
br label %15
15: ; preds = %11, %5
%16 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @index_print.def, i64 0, i64 0), %5 ], [ %14, %11 ]
ret i8* %16
}