int calculator(char *letter) {
  switch (*letter) {
  case 'a':
    return 1;
    break;
  case 'b':
    return 2;
    break;
  case 'c':
    return 3;
    break;
  case 'd':
    return 1;
    break;
  case 'e':
    return 2;
    break;
  case 'f':
    return 3;
    break;
  case 'g':
    return 1;
    break;
  case 'h':
    return 2;
    break;
  case 'i':
    return 3;
    break;
  case 'j':
    return 1;
    break;
  case 'k':
    return 2;
    break;
  case 'l':
    return 3;
    break;
  case 'm':
    return 1;
    break;
  case 'n':
    return 2;
    break;
  case 'o':
    return 3;
    break;
  case 'p':
    return 1;
    break;
  case 'q':
    return 2;
    break;
  case 'r':
    return 3;
    break;
  case 's':
    return 4;
    break;
  case 't':
    return 1;
    break;
  case 'u':
    return 2;
    break;
  case 'v':
    return 3;
    break;
  case 'w':
    return 1;
    break;
  case 'x':
    return 2;
    break;
  case 'y':
    return 3;
    break;
  case 'z':
    return 4;
    break;
  case ' ':
    return 1;
    break;
  default:
    return 0;
    break;
  }
}


x86 assembly (clang, -O0):
<calculator>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5a,%eax
ja     1279 <calculator+0x179>
mov    -0x18(%rbp),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x4,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x2,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x3,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x4,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x1,-0x4(%rbp)
jmp    1280 <calculator+0x180>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculator>:
movsbl (%rdi),%ecx
add    $0xffffffe0,%ecx
cmp    $0x5a,%ecx
ja     1133 <calculator+0x33>
mov    $0x1,%eax
lea    0xee9(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
ret
mov    $0x2,%eax
ret
mov    $0x3,%eax
ret
mov    $0x4,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @calculator(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
switch i32 %6, label %34 [
i32 97, label %7
i32 98, label %8
i32 99, label %9
i32 100, label %10
i32 101, label %11
i32 102, label %12
i32 103, label %13
i32 104, label %14
i32 105, label %15
i32 106, label %16
i32 107, label %17
i32 108, label %18
i32 109, label %19
i32 110, label %20
i32 111, label %21
i32 112, label %22
i32 113, label %23
i32 114, label %24
i32 115, label %25
i32 116, label %26
i32 117, label %27
i32 118, label %28
i32 119, label %29
i32 120, label %30
i32 121, label %31
i32 122, label %32
i32 32, label %33
]
7: ; preds = %1
store i32 1, i32* %2
br label %35
8: ; preds = %1
store i32 2, i32* %2
br label %35
9: ; preds = %1
store i32 3, i32* %2
br label %35
10: ; preds = %1
store i32 1, i32* %2
br label %35
11: ; preds = %1
store i32 2, i32* %2
br label %35
12: ; preds = %1
store i32 3, i32* %2
br label %35
13: ; preds = %1
store i32 1, i32* %2
br label %35
14: ; preds = %1
store i32 2, i32* %2
br label %35
15: ; preds = %1
store i32 3, i32* %2
br label %35
16: ; preds = %1
store i32 1, i32* %2
br label %35
17: ; preds = %1
store i32 2, i32* %2
br label %35
18: ; preds = %1
store i32 3, i32* %2
br label %35
19: ; preds = %1
store i32 1, i32* %2
br label %35
20: ; preds = %1
store i32 2, i32* %2
br label %35
21: ; preds = %1
store i32 3, i32* %2
br label %35
22: ; preds = %1
store i32 1, i32* %2
br label %35
23: ; preds = %1
store i32 2, i32* %2
br label %35
24: ; preds = %1
store i32 3, i32* %2
br label %35
25: ; preds = %1
store i32 4, i32* %2
br label %35
26: ; preds = %1
store i32 1, i32* %2
br label %35
27: ; preds = %1
store i32 2, i32* %2
br label %35
28: ; preds = %1
store i32 3, i32* %2
br label %35
29: ; preds = %1
store i32 1, i32* %2
br label %35
30: ; preds = %1
store i32 2, i32* %2
br label %35
31: ; preds = %1
store i32 3, i32* %2
br label %35
32: ; preds = %1
store i32 4, i32* %2
br label %35
33: ; preds = %1
store i32 1, i32* %2
br label %35
34: ; preds = %1
store i32 0, i32* %2
br label %35
35: ; preds = %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @calculator(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %22 [
i32 97, label %23
i32 98, label %4
i32 99, label %5
i32 100, label %23
i32 101, label %6
i32 102, label %7
i32 103, label %23
i32 104, label %8
i32 105, label %9
i32 106, label %23
i32 107, label %10
i32 108, label %11
i32 109, label %23
i32 110, label %12
i32 111, label %13
i32 112, label %23
i32 113, label %14
i32 114, label %15
i32 115, label %16
i32 116, label %23
i32 117, label %17
i32 118, label %18
i32 119, label %23
i32 120, label %19
i32 121, label %20
i32 122, label %21
i32 32, label %23
]
4: ; preds = %1
br label %23
5: ; preds = %1
br label %23
6: ; preds = %1
br label %23
7: ; preds = %1
br label %23
8: ; preds = %1
br label %23
9: ; preds = %1
br label %23
10: ; preds = %1
br label %23
11: ; preds = %1
br label %23
12: ; preds = %1
br label %23
13: ; preds = %1
br label %23
14: ; preds = %1
br label %23
15: ; preds = %1
br label %23
16: ; preds = %1
br label %23
17: ; preds = %1
br label %23
18: ; preds = %1
br label %23
19: ; preds = %1
br label %23
20: ; preds = %1
br label %23
21: ; preds = %1
br label %23
22: ; preds = %1
br label %23
23: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
%24 = phi i32 [ 0, %22 ], [ 4, %21 ], [ 3, %20 ], [ 2, %19 ], [ 3, %18 ], [ 2, %17 ], [ 4, %16 ], [ 3, %15 ], [ 2, %14 ], [ 3, %13 ], [ 2, %12 ], [ 3, %11 ], [ 2, %10 ], [ 3, %9 ], [ 2, %8 ], [ 3, %7 ], [ 2, %6 ], [ 3, %5 ], [ 2, %4 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ]
ret i32 %24
}