#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ debug(int *, int *, int *, int *, int *, int *);
scalar_t__ execute(int *, int *, int *, int *, int *, int *, int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ load(int *, int);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ puts(char *);
int scanf(char *, char *);
int main(void) {
  FILE *bootMsgPtr;
  int memory[100] = {0};
  char *genericError = "*** Simpletron execution abnormally terminated ***";
  char *bufferPtr;
  int accumulator = {0};
  int instructionCounter = {00};
  int instructionRegister = {0000};
  int operationCode = {00};
  int operand = {00};
  int debugMode;
  if ((bootMsgPtr = fopen("bootMsg.txt", "r")) == NULL) {
    puts(genericError);
    printf("%s %s %s", "*** ", "bootMsg.txt", "not found ***");
  } else {
    bufferPtr = calloc(80, sizeof(char));
    while (!feof(bootMsgPtr)) {
      fgets(bufferPtr, 80, bootMsgPtr);
      printf("%s", bufferPtr);
    }
    puts("");
    puts("");
    printf("%s", "Run in Debug Mode(type Y)? ");
    if ((debugMode = scanf("%1[Yy]", bufferPtr)) == 1) {
      puts("Now you are in debug mode YHEA!");
    } else {
      scanf("%c", bufferPtr);
      puts("");
    }
    free(bufferPtr);
    load(memory, operand);
    if (0 == execute(memory, &accumulator, &instructionCounter,
                     &instructionRegister, &operationCode, &operand,
                     debugMode)) {
      debug(memory, &accumulator, &instructionCounter, &instructionRegister,
            &operationCode, &operand);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1070 <memset@plt>
lea    0xe14(%rip),%rax
mov    %rax,-0x1a8(%rbp)
movl   $0x0,-0x1b4(%rbp)
movl   $0x0,-0x1b8(%rbp)
movl   $0x0,-0x1bc(%rbp)
movl   $0x0,-0x1c0(%rbp)
movl   $0x0,-0x1c4(%rbp)
lea    0xe07(%rip),%rdi
lea    0xe0c(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    127a <main+0xba>
mov    -0x1a8(%rbp),%rdi
call   1040 <puts@plt>
lea    0xde8(%rip),%rdi
lea    0xdea(%rip),%rsi
lea    0xdcc(%rip),%rdx
lea    0xde1(%rip),%rcx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13f4 <main+0x234>
mov    $0x50,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x1b0(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12ae <main+0xee>
jmp    12dd <main+0x11d>
mov    -0x1b0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1090 <fgets@plt>
mov    -0x1b0(%rbp),%rsi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1290 <main+0xd0>
lea    0xd6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xd5e(%rip),%rdi
call   1040 <puts@plt>
lea    0xd4b(%rip),%rdi
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1b0(%rbp),%rsi
lea    0xd61(%rip),%rdi
call   10c0 <scanf@plt>
mov    %eax,-0x1c8(%rbp)
cmp    $0x1,%eax
jne    133d <main+0x17d>
lea    0xd4d(%rip),%rdi
call   1040 <puts@plt>
jmp    135c <main+0x19c>
mov    -0x1b0(%rbp),%rsi
lea    0xd55(%rip),%rdi
call   10c0 <scanf@plt>
lea    0xcf7(%rip),%rdi
call   1040 <puts@plt>
mov    -0x1b0(%rbp),%rdi
call   1030 <free@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1c4(%rbp),%esi
call   10e0 <load@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1c8(%rbp),%eax
lea    -0x1b4(%rbp),%rsi
lea    -0x1b8(%rbp),%rdx
lea    -0x1bc(%rbp),%rcx
lea    -0x1c0(%rbp),%r8
lea    -0x1c4(%rbp),%r9
mov    %eax,(%rsp)
call   1080 <execute@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    13ef <main+0x22f>
lea    -0x1a0(%rbp),%rdi
lea    -0x1b4(%rbp),%rsi
lea    -0x1b8(%rbp),%rdx
lea    -0x1bc(%rbp),%rcx
lea    -0x1c0(%rbp),%r8
lea    -0x1c4(%rbp),%r9
call   1050 <debug@plt>
jmp    13f4 <main+0x234>
xor    %eax,%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1b0,%rsp
lea    0x20(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1080 <memset@plt>
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe17(%rip),%rdi
lea    0xe1c(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     12d6 <main+0x106>
mov    %rax,%rbx
mov    $0x50,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   10c0 <feof@plt>
test   %eax,%eax
jne    1289 <main+0xb9>
lea    0xdee(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   10c0 <feof@plt>
test   %eax,%eax
je     1260 <main+0x90>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xda3(%rip),%rdi
lea    0xdb2(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdc0(%rip),%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
jne    1307 <main+0x137>
lea    0xdb1(%rip),%rdi
call   1050 <puts@plt>
jmp    1320 <main+0x150>
lea    0xd23(%rip),%rdi
call   1050 <puts@plt>
lea    0xd58(%rip),%rdi
lea    0xd5a(%rip),%rsi
lea    0xd3c(%rip),%rdx
lea    0xd51(%rip),%rcx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1383 <main+0x1b3>
lea    0xd92(%rip),%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   10f0 <load@plt>
mov    %ebx,(%rsp)
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %r14,%rdi
call   1090 <execute@plt>
test   %rax,%rax
jne    1383 <main+0x1b3>
lea    0x20(%rsp),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0xc(%rsp),%r9
call   1060 <debug@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [51 x i8] c"*** Simpletron execution abnormally terminated ***\00"
@.str.1 = [12 x i8] c"bootMsg.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [9 x i8] c"%s %s %s\00"
@.str.4 = [5 x i8] c"*** \00"
@.str.5 = [14 x i8] c"not found ***\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [28 x i8] c"Run in Debug Mode(type Y)? \00"
@.str.9 = [7 x i8] c"%1[Yy]\00"
@.str.10 = [32 x i8] c"Now you are in debug mode YHEA!\00"
@.str.11 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [100 x i32]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = bitcast [100 x i32]* %3 to i8*
store i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%13 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %2
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i8*, i8** %4
%17 = call i32 @puts(i8* %16)
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %59
19: ; preds = %0
%20 = call i8* @calloc(i32 80, i32 1)
store i8* %20, i8** %5
br label %21
21: ; preds = %26, %19
%22 = load i32*, i32** %2
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i32*, i32** %2
%29 = call i32 @fgets(i8* %27, i32 80, i32* %28)
%30 = load i8*, i8** %5
%31 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %30)
br label %21
32: ; preds = %21
%33 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%34 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%36 = load i8*, i8** %5
%37 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %36)
store i32 %37, i32* %11
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
br label %45
41: ; preds = %32
%42 = load i8*, i8** %5
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %42)
%44 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %45
45: ; preds = %41, %39
%46 = load i8*, i8** %5
%47 = call i32 @free(i8* %46)
%48 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%49 = load i32, i32* %10
%50 = call i32 @load(i32* %48, i32 %49)
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%52 = load i32, i32* %11
%53 = call i64 @execute(i32* %51, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32 %52)
%54 = icmp eq i64 0, %53
br i1 %54, label %55, label %58
55: ; preds = %45
%56 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%57 = call i32 @debug(i32* %56, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
br label %58
58: ; preds = %55, %45
br label %59
59: ; preds = %58, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"*** Simpletron execution abnormally terminated ***\00"
@.str.1 = [12 x i8] c"bootMsg.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [9 x i8] c"%s %s %s\00"
@.str.4 = [5 x i8] c"*** \00"
@.str.5 = [14 x i8] c"not found ***\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.8 = [28 x i8] c"Run in Debug Mode(type Y)? \00"
@.str.9 = [7 x i8] c"%1[Yy]\00"
@.str.10 = [32 x i8] c"Now you are in debug mode YHEA!\00"
@.str.11 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [100 x i32]* %1 to i8*
%8 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%11 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %46
18: ; preds = %0
%19 = tail call dereferenceable_or_null(80) i8* @calloc(i32 80, i32 1)
%20 = tail call i32 @feof(i32* %13)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18, %22
%23 = tail call i32 @fgets(i8* %19, i32 80, i32* %13)
%24 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %19)
%25 = tail call i32 @feof(i32* %13)
%26 = icmp eq i32 %25, 0
br i1 %26, label %22, label %27
27: ; preds = %22, %18
%28 = tail call i32 @putchar(i32 10)
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%31 = tail call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %19)
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
br label %38
35: ; preds = %27
%36 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %19)
%37 = tail call i32 @putchar(i32 10)
br label %38
38: ; preds = %35, %33
%39 = tail call i32 @free(i8* %19)
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%41 = call i32 @load(i32* %40, i32 0)
%42 = call i64 @execute(i32* %40, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32 %31)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 @debug(i32* %40, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6)
br label %46
46: ; preds = %38, %44, %15
ret i32 0
}