#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 main(void) {
  char ch;
  printf("enter the phone number\n");
  while ((ch = getchar()) != 'Z') {
    switch (ch) {
    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 'O':
    case 'M':
    case 'N':
      printf("6");
      break;
    case 'P':
    case 'S':
    case 'R':
      printf("7");
      break;
    case 'U':
    case 'T':
    case 'V':
      printf("8");
      break;
    case 'W':
    case 'X':
    case 'Y':
      printf("9");
      break;
    default:
      printf("%c", ch);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x5a,%eax
je     122c <main+0x10c>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x18,%eax
ja     1215 <main+0xf5>
mov    -0x10(%rbp),%rax
lea    0xe8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
movsbl -0x5(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x5a,%al
jne    1155 <main+0x25>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1feffff,%ebx
lea    0xeb7(%rip),%r14
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x5a,%al
je     114b <main+0x1b>
movsbl %al,%edi
lea    -0x41(%rdi),%eax
cmp    $0x18,%eax
ja     1170 <main+0x40>
bt     %eax,%ebx
jae    1170 <main+0x40>
cltq
mov    (%r14,%rax,4),%edi
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [24 x i8] c"enter the phone number\0A\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 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %31, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 90
br i1 %7, label %8, label %32
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 79, label %19
i32 77, label %19
i32 78, label %19
i32 80, label %21
i32 83, label %21
i32 82, label %21
i32 85, label %23
i32 84, 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 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
13: ; preds = %8, %8, %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %31
15: ; preds = %8, %8, %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %31
17: ; preds = %8, %8, %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %31
19: ; preds = %8, %8, %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %31
21: ; preds = %8, %8, %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %31
23: ; preds = %8, %8, %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %31
25: ; preds = %8, %8, %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %31
27: ; preds = %8
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %27, %25, %23, %21, %19, %17, %15, %13, %11
br label %4
32: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@str = [23 x i8] c"enter the phone number\00"
@switch.table.main = [25 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 50, i32 55, i32 55, i32 56, i32 56, i32 56, i32 57, i32 57, i32 57]
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 90
br i1 %3, label %22, label %4
4: ; preds = %0, %17
%5 = phi i8 [ %20, %17 ], [ %2, %0 ]
%6 = sext i8 %5 to i32
%7 = add nsw i32 %6, -65
%8 = icmp ult i32 %7, 25
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = lshr i32 33488895, %7
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = sext i32 %7 to i64
%15 = getelementptr inbounds [25 x i32], [25 x i32]* @switch.table.main, i64 0, i64 %14
%16 = load i32, i32* %15
br label %17
17: ; preds = %4, %9, %13
%18 = phi i32 [ %16, %13 ], [ %6, %9 ], [ %6, %4 ]
%19 = tail call i32 @putchar(i32 %18)
%20 = tail call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 90
br i1 %21, label %22, label %4
22: ; preds = %17, %0
ret i32 0
}