#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 input;
  printf("Enter phone number: ");
  while ((input = getchar()) != '\n') {
    switch (input) {
    case 'A':
    case 'B':
    case 'C':
      putchar('2');
      break;
    case 'D':
    case 'E':
    case 'F':
      putchar('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    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     121d <main+0xed>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x18,%eax
ja     120f <main+0xdf>
mov    -0x10(%rbp),%rax
lea    0xe7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x32,%edi
call   1030 <putchar@plt>
jmp    1218 <main+0xe8>
mov    $0x33,%edi
call   1030 <putchar@plt>
jmp    1218 <main+0xe8>
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    114b <main+0x1b>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf2c(%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    $0x18,%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"4\00"
@.str.2 = [2 x i8] c"5\00"
@.str.3 = [2 x i8] c"6\00"
@.str.4 = [2 x i8] c"7\00"
@.str.5 = [2 x i8] c"8\00"
@.str.6 = [2 x i8] c"9\00"
@.str.7 = [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 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 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
]
11: ; preds = %8, %8, %8
%12 = call i32 @putchar(i8 signext 50)
br label %30
13: ; preds = %8, %8, %8
%14 = call i32 @putchar(i8 signext 51)
br label %30
15: ; preds = %8, %8, %8
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
17: ; preds = %8, %8, %8
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
19: ; preds = %8, %8, %8
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %30
21: ; preds = %8, %8, %8
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %30
23: ; preds = %8, %8, %8
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %30
25: ; preds = %8, %8, %8
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, 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.7, 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 66, label %7
i32 67, label %7
i32 68, label %9
i32 69, label %9
i32 70, label %9
i32 71, label %11
i32 72, label %11
i32 73, label %11
i32 74, label %13
i32 75, label %13
i32 76, label %13
i32 77, label %15
i32 78, label %15
i32 79, label %15
i32 80, label %17
i32 82, label %17
i32 83, label %17
i32 84, label %19
i32 85, label %19
i32 86, label %19
i32 87, label %21
i32 88, label %21
i32 89, label %21
]
7: ; preds = %4, %4, %4
%8 = tail call i32 @putchar(i8 signext 50)
br label %25
9: ; preds = %4, %4, %4
%10 = tail call i32 @putchar(i8 signext 51)
br label %25
11: ; preds = %4, %4, %4
%12 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 52)
br label %25
13: ; preds = %4, %4, %4
%14 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 53)
br label %25
15: ; preds = %4, %4, %4
%16 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 54)
br label %25
17: ; preds = %4, %4, %4
%18 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 55)
br label %25
19: ; preds = %4, %4, %4
%20 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 56)
br label %25
21: ; preds = %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
}