#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 toupper(char);
int main(void) {
  char ch;
  printf("\nenter the alphabet: ");
  while ((ch = getchar()) != '\n') {
    switch (toupper(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 '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(ch);
    }
  }
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf0e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1236 <main+0xf6>
movsbl -0x5(%rbp),%edi
call   1040 <toupper@plt>
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x18,%eax
ja     1228 <main+0xe8>
mov    -0x10(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed3(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xec4(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xeb5(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xea6(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xe97(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
jmp    1231 <main+0xf1>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    115b <main+0x1b>
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xf09(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
jne    1181 <main+0x31>
lea    0xf08(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe78(%rip),%r14
jmp    11a0 <main+0x50>
mov    $0x39,%edi
nop
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     116b <main+0x1b>
movsbl %al,%ebx
mov    %ebx,%edi
call   1040 <toupper@plt>
add    $0xffffffbf,%eax
cmp    $0x18,%eax
ja     11ec <main+0x9c>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    $0x32,%edi
jmp    1190 <main+0x40>
mov    $0x33,%edi
jmp    1190 <main+0x40>
mov    $0x34,%edi
jmp    1190 <main+0x40>
mov    $0x35,%edi
jmp    1190 <main+0x40>
mov    $0x36,%edi
jmp    1190 <main+0x40>
mov    $0x37,%edi
jmp    1190 <main+0x40>
mov    $0x38,%edi
jmp    1190 <main+0x40>
mov    %ebx,%edi
jmp    1190 <main+0x40>

LLVM IR (-O0):
@.str = [22 x i8] c"\0Aenter the alphabet: \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"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 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 = call i32 @toupper(i8 signext %9)
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 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
13: ; preds = %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
%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
%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
%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
%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
%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
%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 ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"\0Aenter the alphabet: \00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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 = tail call i32 @toupper(i8 signext %5)
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 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 50)
br label %25
9: ; preds = %4, %4, %4
%10 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}