int keypress(int sum, char s) {
  switch (s) {
  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 4;
    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):
<keypress>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5a,%eax
ja     127b <keypress+0x17b>
mov    -0x18(%rbp),%rax
lea    0xed2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x4,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x4,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x2,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x3,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x4,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x1,-0x4(%rbp)
jmp    1282 <keypress+0x182>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<keypress>:
add    $0xffffffe0,%esi
cmp    $0x5a,%esi
ja     1130 <keypress+0x30>
mov    $0x1,%eax
lea    0xeec(%rip),%rcx
movslq (%rcx,%rsi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
ret
mov    $0x2,%eax
ret
mov    $0x3,%eax
ret
mov    $0x4,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @keypress(i32 %0, i8 signext %1) {
%3 = sext i8 %1 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 = %2
br label %23
5: ; preds = %2
br label %23
6: ; preds = %2
br label %23
7: ; preds = %2
br label %23
8: ; preds = %2
br label %23
9: ; preds = %2
br label %23
10: ; preds = %2
br label %23
11: ; preds = %2
br label %23
12: ; preds = %2
br label %23
13: ; preds = %2
br label %23
14: ; preds = %2
br label %23
15: ; preds = %2
br label %23
16: ; preds = %2
br label %23
17: ; preds = %2
br label %23
18: ; preds = %2
br label %23
19: ; preds = %2
br label %23
20: ; preds = %2
br label %23
21: ; preds = %2
br label %23
22: ; preds = %2
br label %23
23: ; preds = %2, %2, %2, %2, %2, %2, %2, %2, %2, %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 ], [ 4, %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, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ]
ret i32 %24
}