#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*/ decode();
int /*<<< orphan*/ encode();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int choice;
  do {
    printf("\n1. Hide\n");
    printf("2. Read\n");
    printf("3. Exit\n");
    printf("Choice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      if (encode()) {
        printf("All done boys");
      } else {
        printf("Didn't work. Maybe Try again?");
      }
      break;
    case 2:
      if (decode()) {
        printf("Phew All done. Wasn't Bad eh?");
      } else {
        printf("That's some junk right there");
      }
      break;
    case 3:
      printf("kthxbye\n");
      exit(0);
    default:
      printf("Invalid Choice. Try again");
      break;
    }
    getchar();
  } while (choice != 3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11e5 <main+0x85>
jmp    11c3 <main+0x63>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1217 <main+0xb7>
jmp    11d4 <main+0x74>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     1249 <main+0xe9>
jmp    125c <main+0xfc>
mov    $0x0,%al
call   1030 <encode@plt>
cmp    $0x0,%eax
je     1206 <main+0xa6>
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
jmp    1212 <main+0xb2>
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x108>
mov    $0x0,%al
call   1060 <decode@plt>
cmp    $0x0,%eax
je     1238 <main+0xd8>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
jmp    1244 <main+0xe4>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x108>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
cmpl   $0x3,-0x8(%rbp)
jne    116f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf0b(%rip),%r14
lea    0xf0d(%rip),%r15
lea    0xf0e(%rip),%r12
lea    0xe69(%rip),%r13
lea    0xe6b(%rip),%rbx
lea    0x4(%rsp),%rbp
jmp    11de <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <encode@plt>
test   %eax,%eax
lea    0xe4c(%rip),%rdi
lea    0xe53(%rip),%rax
cmove  %rax,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmpl   $0x3,0x4(%rsp)
je     124c <main+0xdc>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11b0 <main+0x40>
cmp    $0x2,%eax
je     1230 <main+0xc0>
lea    0xe55(%rip),%rdi
cmp    $0x3,%eax
jne    11cb <main+0x5b>
jmp    125d <main+0xed>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <decode@plt>
test   %eax,%eax
lea    0xdf8(%rip),%rdi
lea    0xe0f(%rip),%rax
jmp    11c7 <main+0x57>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe42(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"\0A1. Hide\0A\00"
@.str.1 = [9 x i8] c"2. Read\0A\00"
@.str.2 = [9 x i8] c"3. Exit\0A\00"
@.str.3 = [9 x i8] c"Choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [14 x i8] c"All done boys\00"
@.str.6 = [30 x i8] c"Didn't work. Maybe Try again?\00"
@.str.7 = [30 x i8] c"Phew All done. Wasn't Bad eh?\00"
@.str.8 = [29 x i8] c"That's some junk right there\00"
@.str.9 = [9 x i8] c"kthxbye\0A\00"
@.str.10 = [26 x i8] c"Invalid Choice. Try again\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %33, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
switch i32 %9, label %29 [
i32 1, label %10
i32 2, label %18
i32 3, label %26
]
10: ; preds = %3
%11 = call i32 (...) @encode()
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
br label %31
18: ; preds = %3
%19 = call i32 (...) @decode()
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %25
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
br label %31
26: ; preds = %3
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %3
%30 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %31
31: ; preds = %29, %25, %17
%32 = call i32 (...) @getchar()
br label %33
33: ; preds = %31
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 3
br i1 %35, label %3, label %36
36: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [9 x i8] c"Choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [14 x i8] c"All done boys\00"
@.str.6 = [30 x i8] c"Didn't work. Maybe Try again?\00"
@.str.7 = [30 x i8] c"Phew All done. Wasn't Bad eh?\00"
@.str.8 = [29 x i8] c"That's some junk right there\00"
@.str.10 = [26 x i8] c"Invalid Choice. Try again\00"
@str = [9 x i8] c"\0A1. Hide\00"
@str.11 = [8 x i8] c"2. Read\00"
@str.12 = [8 x i8] c"3. Exit\00"
@str.13 = [8 x i8] c"kthxbye\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %21, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
switch i32 %9, label %21 [
i32 1, label %10
i32 2, label %14
i32 3, label %18
]
10: ; preds = %3
%11 = call i32 (...) @encode()
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0)
br label %21
14: ; preds = %3
%15 = call i32 (...) @decode()
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0)
br label %21
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %3, %14, %10
%22 = phi i8* [ %13, %10 ], [ %17, %14 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), %3 ]
%23 = call i32 @printf(i8* dereferenceable(1) %22)
%24 = call i32 (...) @getchar()
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %3
27: ; preds = %21
ret i32 0
}