#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*/ b64Decode();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(void) {
  int pid;
  char ch;
  setbuf(stdin, 0);
  setbuf(stdout, 0);
  setbuf(stderr, 0);
  printf("I am a simple program\n");
  printf("So what should I do?\n");
  while (1) {
    printf("\nMay be I can know if you give me some data[Y/N]\n");
    if (getchar() == 'Y') {
      ch = getchar();
      while (ch != '\n' && ch != 0)
        ;
    } else {
      break;
    }
    pid = fork();
    if (pid == 0) {
      b64Decode();
      printf("\nback\n");
      exit(0);
    } else if (pid > 0) {
      wait(NULL);
    } else if (pid == -1) {
      puts("Something Wrong");
      exit(0);
    }
  }
  printf("At last I did some thing (:\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
lea    0xe3a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe45(%rip),%rdi
call   1060 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%eax
cmp    $0x59,%eax
jne    1239 <main+0xb9>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xa(%rbp)
je     121f <main+0x9f>
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    122f <main+0xaf>
jmp    1234 <main+0xb4>
jmp    1200 <main+0x80>
jmp    123e <main+0xbe>
jmp    12b0 <main+0x130>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    126c <main+0xec>
mov    $0x0,%al
call   1040 <b64Decode@plt>
lea    0xdff(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1284 <main+0x104>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <wait@plt>
jmp    12a6 <main+0x126>
cmpl   $0xffffffff,-0x8(%rbp)
jne    12a1 <main+0x121>
lea    0xdd1(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    12a6 <main+0x126>
jmp    12ab <main+0x12b>
jmp    11d7 <main+0x57>
lea    0xdbf(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x59,%al
jne    1232 <main+0xc2>
lea    0xe64(%rip),%rbx
jmp    11fa <main+0x8a>
nopl   0x0(%rax)
xor    %edi,%edi
call   1080 <wait@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x59,%al
jne    1232 <main+0xc2>
xor    %eax,%eax
call   1060 <getchar@plt>
test   %al,%al
je     1209 <main+0x99>
cmp    $0xa,%al
jne    1230 <main+0xc0>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     1242 <main+0xd2>
jg     11e0 <main+0x70>
cmp    $0xffffffff,%eax
jne    11e7 <main+0x77>
lea    0xdde(%rip),%rdi
jmp    1250 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
jmp    1230 <main+0xc0>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1040 <b64Decode@plt>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"I am a simple program\0A\00"
@.str.1 = [22 x i8] c"So what should I do?\0A\00"
@.str.2 = [50 x i8] c"\0AMay be I can know if you give me some data[Y/N]\0A\00"
@.str.3 = [7 x i8] c"\0Aback\0A\00"
@.str.4 = [16 x i8] c"Something Wrong\00"
@.str.5 = [29 x i8] c"At last I did some thing (:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
%4 = load i32, i32* @stdin
%5 = call i32 @setbuf(i32 %4, i32 0)
%6 = load i32, i32* @stdout
%7 = call i32 @setbuf(i32 %6, i32 0)
%8 = load i32, i32* @stderr
%9 = call i32 @setbuf(i32 %8, i32 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %0, %53
%13 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%14 = call signext i8 (...) @getchar()
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 89
br i1 %16, label %17, label %31
17: ; preds = %12
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %3
br label %19
19: ; preds = %29, %17
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ false, %19 ], [ %26, %23 ]
br i1 %28, label %29, label %30
29: ; preds = %27
br label %19
30: ; preds = %27
br label %32
31: ; preds = %12
br label %54
32: ; preds = %30
%33 = call i32 (...) @fork()
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = call i32 (...) @b64Decode()
%38 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %32
%41 = load i32, i32* %2
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @wait(i32* null)
br label %52
45: ; preds = %40
%46 = load i32, i32* %2
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %45
br label %52
52: ; preds = %51, %43
br label %53
53: ; preds = %52
br label %12
54: ; preds = %31
%55 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str.4 = [16 x i8] c"Something Wrong\00"
@str = [22 x i8] c"I am a simple program\00"
@str.6 = [21 x i8] c"So what should I do?\00"
@str.7 = [49 x i8] c"\0AMay be I can know if you give me some data[Y/N]\00"
@str.8 = [28 x i8] c"At last I did some thing (:\00"
@str.9 = [6 x i8] c"\0Aback\00"
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @setbuf(i32 %1, i32 0)
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32 0)
%5 = load i32, i32* @stderr
%6 = tail call i32 @setbuf(i32 %5, i32 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.7, i64 0, i64 0))
%10 = tail call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 89
br i1 %11, label %12, label %35
12: ; preds = %0, %31
%13 = tail call signext i8 (...) @getchar()
switch i8 %13, label %14 [
i8 10, label %15
i8 0, label %15
]
14: ; preds = %12, %14
br label %14
15: ; preds = %12, %12
%16 = tail call i32 (...) @fork()
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 (...) @b64Decode()
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.9, i64 0, i64 0))
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %15
%23 = icmp sgt i32 %16, 0
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = tail call i32 @wait(i32* null)
br label %31
26: ; preds = %22
%27 = icmp eq i32 %16, -1
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%30 = tail call i32 @exit(i32 0)
unreachable
31: ; preds = %24, %26
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.7, i64 0, i64 0))
%33 = tail call signext i8 (...) @getchar()
%34 = icmp eq i8 %33, 89
br i1 %34, label %12, label %35
35: ; preds = %31, %0
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}