char *athame_get_mode_text(char *mode) {
  switch (mode[0]) {
  case 'i':
    return "INSERT";
  case 'n':
    return "NORMAL";
  case 'v':
    return "VISUAL";
  case 'V':
    return "VISUAL LINE";
  case 's':
    return "SELECT";
  case 'S':
    return "SELECT LINE";
  case 'R':
    return "REPLACE";
  case 'c':
    return "COMMAND";
  default:
    return "";
  }
}


x86 assembly (clang, -O0):
<athame_get_mode_text>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffae,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x24,%eax
ja     11b5 <athame_get_mode_text+0xb5>
mov    -0x18(%rbp),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf58(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf46(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf3d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf39(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf24(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <athame_get_mode_text+0xc0>
lea    0xf1b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<athame_get_mode_text>:
movsbl (%rdi),%ecx
add    $0xffffffae,%ecx
cmp    $0x24,%ecx
ja     1132 <athame_get_mode_text+0x32>
lea    0xf82(%rip),%rax
lea    0xee7(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf9f(%rip),%rax
ret
lea    0xf8b(%rip),%rax
ret
lea    0xf9e(%rip),%rax
ret
lea    0xf68(%rip),%rax
ret
lea    0xf87(%rip),%rax
ret
lea    0xf4a(%rip),%rax
ret
lea    0xf5c(%rip),%rax
ret
lea    0xf41(%rip),%rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"INSERT\00"
@.str.1 = [7 x i8] c"NORMAL\00"
@.str.2 = [7 x i8] c"VISUAL\00"
@.str.3 = [12 x i8] c"VISUAL LINE\00"
@.str.4 = [7 x i8] c"SELECT\00"
@.str.5 = [12 x i8] c"SELECT LINE\00"
@.str.6 = [8 x i8] c"REPLACE\00"
@.str.7 = [8 x i8] c"COMMAND\00"
@.str.8 = [1 x i8] zeroinitializer
define i8* @athame_get_mode_text(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %16 [
i32 105, label %8
i32 110, label %9
i32 118, label %10
i32 86, label %11
i32 115, label %12
i32 83, label %13
i32 82, label %14
i32 99, label %15
]
8: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
br label %17
9: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %17
10: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %17
11: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %17
12: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %17
13: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %17
14: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %17
15: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %17
16: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@.str = [7 x i8] c"INSERT\00"
@.str.1 = [7 x i8] c"NORMAL\00"
@.str.2 = [7 x i8] c"VISUAL\00"
@.str.3 = [12 x i8] c"VISUAL LINE\00"
@.str.4 = [7 x i8] c"SELECT\00"
@.str.5 = [12 x i8] c"SELECT LINE\00"
@.str.6 = [8 x i8] c"REPLACE\00"
@.str.7 = [8 x i8] c"COMMAND\00"
@.str.8 = [1 x i8] zeroinitializer
define i8* @athame_get_mode_text(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %11 [
i32 105, label %12
i32 110, label %4
i32 118, label %5
i32 86, label %6
i32 115, label %7
i32 83, label %8
i32 82, label %9
i32 99, label %10
]
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
br label %12
11: ; preds = %1
br label %12
12: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4
%13 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %13
}