#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int main(void) {
  int input;
  printf("Enter an alphanumeric phone number: ");
  while ((input = getchar()) != '\n') {
    switch (input) {
    case 'A':
    case 'B':
    case 'C':
      printf("2");
      break;
    case 'D':
    case 'E':
    case 'F':
      printf("3");
      break;
    case 'G':
    case 'H':
    case 'I':
      printf("4");
      break;
    case 'J':
    case 'K':
    case 'L':
      printf("5");
      break;
    case 'M':
    case 'N':
    case 'O':
      printf("6");
      break;
    case 'P':
    case 'R':
    case 'S':
      printf("7");
      break;
    case 'T':
    case 'U':
    case 'V':
      printf("8");
      break;
    case 'W':
    case 'X':
    case 'Y':
      printf("9");
      break;
    default:
      putchar(input);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf1e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     121c <main+0xec>
mov    -0x8(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x18,%eax
ja     120f <main+0xdf>
mov    -0x10(%rbp),%rax
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xefb(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xeec(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xedd(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xe7>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    114b <main+0x1b>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0x1008(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rbx
jmp    1150 <main+0x20>
mov    $0x39,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    -0xa(%rax),%ecx
cmp    $0x4f,%ecx
ja     11bc <main+0x8c>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    $0x32,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0x33,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0x34,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0x35,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0x36,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0x37,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0x38,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter an alphanumeric phone number: \00"
@.str.1 = [2 x i8] c"2\00"
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [2 x i8] c"4\00"
@.str.4 = [2 x i8] c"5\00"
@.str.5 = [2 x i8] c"6\00"
@.str.6 = [2 x i8] c"7\00"
@.str.7 = [2 x i8] c"8\00"
@.str.8 = [2 x i8] c"9\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %28, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %29
7: ; preds = %4
%8 = load i32, i32* %2
switch i32 %8, label %25 [
i32 65, label %9
i32 66, label %9
i32 67, label %9
i32 68, label %11
i32 69, label %11
i32 70, label %11
i32 71, label %13
i32 72, label %13
i32 73, label %13
i32 74, label %15
i32 75, label %15
i32 76, label %15
i32 77, label %17
i32 78, label %17
i32 79, label %17
i32 80, label %19
i32 82, label %19
i32 83, label %19
i32 84, label %21
i32 85, label %21
i32 86, label %21
i32 87, label %23
i32 88, label %23
i32 89, label %23
]
9: ; preds = %7, %7, %7
%10 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
11: ; preds = %7, %7, %7
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
13: ; preds = %7, %7, %7
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %28
15: ; preds = %7, %7, %7
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %28
17: ; preds = %7, %7, %7
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %28
19: ; preds = %7, %7, %7
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %28
21: ; preds = %7, %7, %7
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %28
23: ; preds = %7, %7, %7
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %28
25: ; preds = %7
%26 = load i32, i32* %2
%27 = call i32 @putchar(i32 %26)
br label %28
28: ; preds = %25, %23, %21, %19, %17, %15, %13, %11, %9
br label %4
29: ; preds = %4
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter an alphanumeric phone number: \00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %22, %0
%3 = tail call i32 (...) @getchar()
switch i32 %3, label %20 [
i32 10, label %23
i32 65, label %4
i32 66, label %4
i32 67, label %4
i32 68, label %6
i32 69, label %6
i32 70, label %6
i32 71, label %8
i32 72, label %8
i32 73, label %8
i32 74, label %10
i32 75, label %10
i32 76, label %10
i32 77, label %12
i32 78, label %12
i32 79, label %12
i32 80, label %14
i32 82, label %14
i32 83, label %14
i32 84, label %16
i32 85, label %16
i32 86, label %16
i32 87, label %18
i32 88, label %18
i32 89, label %18
]
4: ; preds = %2, %2, %2
%5 = tail call i32 @putchar(i32 50)
br label %22
6: ; preds = %2, %2, %2
%7 = tail call i32 @putchar(i32 51)
br label %22
8: ; preds = %2, %2, %2
%9 = tail call i32 @putchar(i32 52)
br label %22
10: ; preds = %2, %2, %2
%11 = tail call i32 @putchar(i32 53)
br label %22
12: ; preds = %2, %2, %2
%13 = tail call i32 @putchar(i32 54)
br label %22
14: ; preds = %2, %2, %2
%15 = tail call i32 @putchar(i32 55)
br label %22
16: ; preds = %2, %2, %2
%17 = tail call i32 @putchar(i32 56)
br label %22
18: ; preds = %2, %2, %2
%19 = tail call i32 @putchar(i32 57)
br label %22
20: ; preds = %2
%21 = tail call i32 @putchar(i32 %3)
br label %22
22: ; preds = %20, %18, %16, %14, %12, %10, %8, %6, %4
br label %2
23: ; preds = %2
%24 = tail call i32 @putchar(i32 10)
ret i32 0
}