#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
char toupper(char);
int main() {
  char inputbuffer[200];
  int number;
  char letter;
  do {
    printf("\n(E)ncode or (D)ecode : ");
    scanf("%200s", inputbuffer);
    switch (toupper(inputbuffer[0])) {
    case 'D':
      printf("Type the Message to decode.\n");
      do {
        scanf("%d", &number);
        scanf("%c", &letter);
        printf("%c", number);
      } while (letter != '\n');
      break;
    case 'E':
      printf("Type the Message to encode\n");
      do {
        scanf("%c", &letter);
      } while (letter == '\n');
      while (letter != '\n') {
        printf("%d ", letter);
        scanf("%c", &letter);
      }
      break;
    default:
      printf("Invalid option\n");
    }
    printf("\nAgain? (Y/N) : ");
    scanf("%200s", inputbuffer);
  } while ((toupper(inputbuffer[0]) != 'N') &&
           (toupper(inputbuffer[0]) != 'Q'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xdd(%rbp)
call   1040 <printf@plt>
mov    -0xdd(%rbp),%al
lea    0xeb6(%rip),%rdi
lea    -0xd0(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0xd0(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
mov    %eax,-0xdc(%rbp)
sub    $0x44,%eax
je     11a6 <main+0x76>
jmp    1192 <main+0x62>
mov    -0xdc(%rbp),%eax
sub    $0x45,%eax
je     1207 <main+0xd7>
jmp    1283 <main+0x153>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0xd4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe6f(%rip),%rdi
lea    -0xd5(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xd4(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0xd5(%rbp),%eax
cmp    $0xa,%eax
jne    11b4 <main+0x84>
jmp    1291 <main+0x161>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe23(%rip),%rdi
lea    -0xd5(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0xd5(%rbp),%eax
cmp    $0xa,%eax
je     1215 <main+0xe5>
jmp    123f <main+0x10f>
movsbl -0xd5(%rbp),%eax
cmp    $0xa,%eax
je     127e <main+0x14e>
movsbl -0xd5(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd4(%rip),%rdi
lea    -0xd5(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    123f <main+0x10f>
jmp    1291 <main+0x161>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xd0(%rbp),%rsi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0xd0(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x4e,%ecx
mov    %al,-0xde(%rbp)
je     12ef <main+0x1bf>
movsbl -0xd0(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x51,%eax
setne  %al
mov    %al,-0xde(%rbp)
mov    -0xde(%rbp),%al
test   $0x1,%al
jne    1142 <main+0x12>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0x10(%rsp),%r13
lea    0xeb5(%rip),%rbx
lea    0xb(%rsp),%rbp
lea    0xeac(%rip),%r12
lea    0xe9f(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe74(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsbl 0x10(%rsp),%edi
call   1040 <toupper@plt>
movsbl %al,%eax
cmp    $0x45,%eax
je     1210 <main+0xc0>
cmp    $0x44,%eax
jne    1270 <main+0x120>
lea    0xe84(%rip),%rdi
call   1050 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1030 <putchar@plt>
cmpb   $0xa,0xb(%rsp)
jne    11e0 <main+0x90>
jmp    127c <main+0x12c>
nopl   0x0(%rax)
lea    0xe23(%rip),%rdi
call   1050 <puts@plt>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movzbl 0xb(%rsp),%eax
cmp    $0xa,%al
je     1220 <main+0xd0>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movzbl 0xb(%rsp),%eax
cmp    $0xa,%al
jne    1240 <main+0xf0>
jmp    127c <main+0x12c>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdfa(%rip),%rdi
call   1050 <puts@plt>
lea    0xda6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd88(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsbl 0x10(%rsp),%edi
call   1040 <toupper@plt>
cmp    $0x4e,%al
je     12bb <main+0x16b>
movsbl 0x10(%rsp),%edi
call   1040 <toupper@plt>
cmp    $0x51,%al
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0A(E)ncode or (D)ecode : \00"
@.str.1 = [6 x i8] c"%200s\00"
@.str.2 = [29 x i8] c"Type the Message to decode.\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [28 x i8] c"Type the Message to encode\0A\00"
@.str.6 = [4 x i8] c"%d \00"
@.str.7 = [16 x i8] c"Invalid option\0A\00"
@.str.8 = [17 x i8] c"\0AAgain? (Y/N) : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
br label %5
5: ; preds = %62, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%10 = load i8, i8* %9
%11 = call signext i8 @toupper(i8 signext %10)
%12 = sext i8 %11 to i32
switch i32 %12, label %44 [
i32 68, label %13
i32 69, label %25
]
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %20, %13
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %15, label %24
24: ; preds = %20
br label %46
25: ; preds = %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %29, %25
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %29
29: ; preds = %27
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %27, label %33
33: ; preds = %29
br label %34
34: ; preds = %38, %33
%35 = load i8, i8* %4
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 10
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i8, i8* %4
%40 = sext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %40)
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %34
43: ; preds = %34
br label %46
44: ; preds = %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %46
46: ; preds = %44, %43, %24
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%48 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%49 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %46
%51 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%52 = load i8, i8* %51
%53 = call signext i8 @toupper(i8 signext %52)
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 78
br i1 %55, label %56, label %62
56: ; preds = %50
%57 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%58 = load i8, i8* %57
%59 = call signext i8 @toupper(i8 signext %58)
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 81
br label %62
62: ; preds = %56, %50
%63 = phi i1 [ false, %50 ], [ %61, %56 ]
br i1 %63, label %5, label %64
64: ; preds = %62
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0A(E)ncode or (D)ecode : \00"
@.str.1 = [6 x i8] c"%200s\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.6 = [4 x i8] c"%d \00"
@.str.8 = [17 x i8] c"\0AAgain? (Y/N) : \00"
@str = [27 x i8] c"Type the Message to encode\00"
@str.9 = [28 x i8] c"Type the Message to decode.\00"
@str.10 = [15 x i8] c"Invalid option\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca i32
%3 = alloca i8
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
br label %6
6: ; preds = %42, %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = load i8, i8* %4
%10 = call signext i8 @toupper(i8 signext %9)
%11 = sext i8 %10 to i32
switch i32 %11, label %34 [
i32 68, label %12
i32 69, label %21
]
12: ; preds = %6
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0))
br label %14
14: ; preds = %14, %12
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%17 = load i32, i32* %2
%18 = call i32 @putchar(i32 %17)
%19 = load i8, i8* %3
%20 = icmp eq i8 %19, 10
br i1 %20, label %36, label %14
21: ; preds = %6
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %23, %21
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%25 = load i8, i8* %3
%26 = icmp eq i8 %25, 10
br i1 %26, label %23, label %27
27: ; preds = %23, %27
%28 = phi i8 [ %32, %27 ], [ %25, %23 ]
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%32 = load i8, i8* %3
%33 = icmp eq i8 %32, 10
br i1 %33, label %36, label %27
34: ; preds = %6
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0))
br label %36
36: ; preds = %27, %14, %34
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%39 = load i8, i8* %4
%40 = call signext i8 @toupper(i8 signext %39)
%41 = icmp eq i8 %40, 78
br i1 %41, label %46, label %42
42: ; preds = %36
%43 = load i8, i8* %4
%44 = call signext i8 @toupper(i8 signext %43)
%45 = icmp eq i8 %44, 81
br i1 %45, label %46, label %6
46: ; preds = %36, %42
ret i32 0
}