int main(void) {
  char ch;
  while ((ch = getchar()) != '\n') {
    switch (ch) {
    case 'A' ... 'C':
      putchar('2');
      break;
    case 'D' ... 'F':
      putchar('3');
      break;
    case 'G' ... 'I':
      putchar('4');
      break;
    case 'J' ... 'L':
      putchar('5');
      break;
    case 'M' ... 'O':
      putchar('6');
      break;
    case 'P' ... 'S':
      putchar('7');
      break;
    case 'T' ... 'V':
      putchar('8');
      break;
    case 'W' ... 'Z':
      putchar('9');
      break;
    default:
      putchar(ch);
      break;
    }
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1207 <main+0xe7>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x19,%eax
ja     11f7 <main+0xd7>
mov    -0x10(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x32,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x33,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x34,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x35,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x36,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x37,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x38,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
mov    $0x39,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1202 <main+0xe2>
movsbl -0x5(%rbp),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    112f <main+0xf>
mov    $0xa,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
shl    $0x18,%eax
cmp    $0xa000000,%eax
jne    1142 <main+0x22>
mov    $0xa,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xeb7(%rip),%rbx
jmp    116a <main+0x4a>
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
shl    $0x18,%eax
cmp    $0xa000000,%eax
je     1132 <main+0x12>
sar    $0x18,%eax
lea    -0x41(%rax),%ecx
cmp    $0x19,%ecx
ja     1150 <main+0x30>
movslq %ecx,%rax
mov    (%rbx,%rax,4),%eax
jmp    1150 <main+0x30>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %31, %0
%4 = call i32 (...) @getchar()
%5 = trunc i32 %4 to i8
store i8 %5, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %32
8: ; preds = %3
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
switch i32 %10, label %27 [
i32 65, label %11
i32 66, label %11
i32 67, label %11
i32 68, label %13
i32 69, label %13
i32 70, label %13
i32 71, label %15
i32 72, label %15
i32 73, label %15
i32 74, label %17
i32 75, label %17
i32 76, label %17
i32 77, label %19
i32 78, label %19
i32 79, label %19
i32 80, label %21
i32 81, label %21
i32 82, label %21
i32 83, label %21
i32 84, label %23
i32 85, label %23
i32 86, label %23
i32 87, label %25
i32 88, label %25
i32 89, label %25
i32 90, label %25
]
11: ; preds = %8, %8, %8
%12 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 50)
br label %31
13: ; preds = %8, %8, %8
%14 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 51)
br label %31
15: ; preds = %8, %8, %8
%16 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 52)
br label %31
17: ; preds = %8, %8, %8
%18 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 53)
br label %31
19: ; preds = %8, %8, %8
%20 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 54)
br label %31
21: ; preds = %8, %8, %8, %8
%22 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 55)
br label %31
23: ; preds = %8, %8, %8
%24 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 56)
br label %31
25: ; preds = %8, %8, %8, %8
%26 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 57)
br label %31
27: ; preds = %8
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
%30 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %29)
br label %31
31: ; preds = %27, %25, %23, %21, %19, %17, %15, %13, %11
br label %3
32: ; preds = %3
%33 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 10)
ret i32 0
}

LLVM IR (-O2):
@switch.table.main = [26 x i32] [i32 50, i32 50, i32 50, i32 51, i32 51, i32 51, i32 52, i32 52, i32 52, i32 53, i32 53, i32 53, i32 54, i32 54, i32 54, i32 55, i32 55, i32 55, i32 55, i32 56, i32 56, i32 56, i32 57, i32 57, i32 57, i32 57]
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = shl i32 %1, 24
%3 = icmp eq i32 %2, 167772160
br i1 %3, label %19, label %4
4: ; preds = %0, %13
%5 = phi i32 [ %17, %13 ], [ %2, %0 ]
%6 = ashr exact i32 %5, 24
%7 = add nsw i32 %6, -65
%8 = icmp ult i32 %7, 26
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds [26 x i32], [26 x i32]* @switch.table.main, i64 0, i64 %10
%12 = load i32, i32* %11
br label %13
13: ; preds = %4, %9
%14 = phi i32 [ %12, %9 ], [ %6, %4 ]
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %14)
%16 = tail call i32 (...) @getchar()
%17 = shl i32 %16, 24
%18 = icmp eq i32 %17, 167772160
br i1 %18, label %19, label %4
19: ; preds = %13, %0
%20 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 10)
ret i32 0
}