#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main(void) {
  char ch;
  printf("Enter phone number: ");
  while ((ch = getchar()) != '\n') {
    switch (ch) {
    case 'A':
    case 'a':
    case 'B':
    case 'b':
    case 'C':
    case 'c':
      printf("2");
      break;
    case 'D':
    case 'd':
    case 'E':
    case 'e':
    case 'F':
    case 'f':
      printf("3");
      break;
    case 'G':
    case 'g':
    case 'H':
    case 'h':
    case 'I':
    case 'i':
      printf("4");
      break;
    case 'J':
    case 'j':
    case 'K':
    case 'k':
    case 'L':
    case 'l':
      printf("5");
      break;
    case 'M':
    case 'm':
    case 'N':
    case 'n':
    case 'O':
    case 'o':
      printf("6");
      break;
    case 'P':
    case 'p':
    case 'R':
    case 'r':
    case 'S':
    case 's':
      printf("7");
      break;
    case 'T':
    case 't':
    case 'U':
    case 'u':
    case 'V':
    case 'v':
      printf("8");
      break;
    case 'W':
    case 'w':
    case 'X':
    case 'x':
    case 'Y':
    case 'y':
      printf("9");
      break;
    default:
      putchar(ch);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf9e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1221 <main+0xf1>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x38,%eax
ja     1213 <main+0xe3>
mov    -0x10(%rbp),%rax
lea    0xe7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf67(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xf58(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xf49(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xf3a(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xf2b(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xf1c(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xf0d(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
lea    0xefe(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xec>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    114b <main+0x1b>
lea    0xee1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xfac(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1156 <main+0x26>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xea3(%rip),%rbx
jmp    1180 <main+0x50>
mov    $0x39,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1148 <main+0x18>
movsbl %al,%edi
lea    -0x41(%rdi),%eax
cmp    $0x38,%eax
ja     11c5 <main+0x95>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x32,%edi
jmp    1170 <main+0x40>
mov    $0x33,%edi
jmp    1170 <main+0x40>
mov    $0x34,%edi
jmp    1170 <main+0x40>
mov    $0x35,%edi
jmp    1170 <main+0x40>
mov    $0x36,%edi
jmp    1170 <main+0x40>
mov    $0x37,%edi
jmp    1170 <main+0x40>
mov    $0x38,%edi
jmp    1170 <main+0x40>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [21 x i8] c"Enter 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 i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %30, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %31
8: ; preds = %4
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
switch i32 %10, label %27 [
i32 65, label %11
i32 97, label %11
i32 66, label %11
i32 98, label %11
i32 67, label %11
i32 99, label %11
i32 68, label %13
i32 100, label %13
i32 69, label %13
i32 101, label %13
i32 70, label %13
i32 102, label %13
i32 71, label %15
i32 103, label %15
i32 72, label %15
i32 104, label %15
i32 73, label %15
i32 105, label %15
i32 74, label %17
i32 106, label %17
i32 75, label %17
i32 107, label %17
i32 76, label %17
i32 108, label %17
i32 77, label %19
i32 109, label %19
i32 78, label %19
i32 110, label %19
i32 79, label %19
i32 111, label %19
i32 80, label %21
i32 112, label %21
i32 82, label %21
i32 114, label %21
i32 83, label %21
i32 115, label %21
i32 84, label %23
i32 116, label %23
i32 85, label %23
i32 117, label %23
i32 86, label %23
i32 118, label %23
i32 87, label %25
i32 119, label %25
i32 88, label %25
i32 120, label %25
i32 89, label %25
i32 121, label %25
]
11: ; preds = %8, %8, %8, %8, %8, %8
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
13: ; preds = %8, %8, %8, %8, %8, %8
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
15: ; preds = %8, %8, %8, %8, %8, %8
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %30
17: ; preds = %8, %8, %8, %8, %8, %8
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %30
19: ; preds = %8, %8, %8, %8, %8, %8
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %30
21: ; preds = %8, %8, %8, %8, %8, %8
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %30
23: ; preds = %8, %8, %8, %8, %8, %8
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %30
25: ; preds = %8, %8, %8, %8, %8, %8
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %30
27: ; preds = %8
%28 = load i8, i8* %2
%29 = call i32 @putchar(i8 signext %28)
br label %30
30: ; preds = %27, %25, %23, %21, %19, %17, %15, %13, %11
br label %4
31: ; preds = %4
%32 = 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 = [21 x i8] c"Enter phone number: \00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %28, label %4
4: ; preds = %0, %25
%5 = phi i8 [ %26, %25 ], [ %2, %0 ]
%6 = sext i8 %5 to i32
switch i32 %6, label %23 [
i32 65, label %7
i32 97, label %7
i32 66, label %7
i32 98, label %7
i32 67, label %7
i32 99, label %7
i32 68, label %9
i32 100, label %9
i32 69, label %9
i32 101, label %9
i32 70, label %9
i32 102, label %9
i32 71, label %11
i32 103, label %11
i32 72, label %11
i32 104, label %11
i32 73, label %11
i32 105, label %11
i32 74, label %13
i32 106, label %13
i32 75, label %13
i32 107, label %13
i32 76, label %13
i32 108, label %13
i32 77, label %15
i32 109, label %15
i32 78, label %15
i32 110, label %15
i32 79, label %15
i32 111, label %15
i32 80, label %17
i32 112, label %17
i32 82, label %17
i32 114, label %17
i32 83, label %17
i32 115, label %17
i32 84, label %19
i32 116, label %19
i32 85, label %19
i32 117, label %19
i32 86, label %19
i32 118, label %19
i32 87, label %21
i32 119, label %21
i32 88, label %21
i32 120, label %21
i32 89, label %21
i32 121, label %21
]
7: ; preds = %4, %4, %4, %4, %4, %4
%8 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 50)
br label %25
9: ; preds = %4, %4, %4, %4, %4, %4
%10 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 51)
br label %25
11: ; preds = %4, %4, %4, %4, %4, %4
%12 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 52)
br label %25
13: ; preds = %4, %4, %4, %4, %4, %4
%14 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 53)
br label %25
15: ; preds = %4, %4, %4, %4, %4, %4
%16 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 54)
br label %25
17: ; preds = %4, %4, %4, %4, %4, %4
%18 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 55)
br label %25
19: ; preds = %4, %4, %4, %4, %4, %4
%20 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 56)
br label %25
21: ; preds = %4, %4, %4, %4, %4, %4
%22 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 57)
br label %25
23: ; preds = %4
%24 = tail call i32 @putchar(i8 signext %5)
br label %25
25: ; preds = %23, %21, %19, %17, %15, %13, %11, %9, %7
%26 = tail call signext i8 (...) @getchar()
%27 = icmp eq i8 %26, 10
br i1 %27, label %28, label %4
28: ; preds = %25, %0
%29 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret i32 0
}