#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*/ CPU();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ header_print(char *);
int /*<<< orphan*/ init_ram(int);
int /*<<< orphan*/ line_print();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_bin_file(char *);
int /*<<< orphan*/ show_ram(int /*<<< orphan*/, int);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int ram_seed;
  char *filename;
  if (argc > 2) {
    if (sscanf(argv[2], "%i", &ram_seed) != 1) {
      fprintf(stderr, "Error - seed not integer\n");
    }
  } else {
    ram_seed = 0;
  }
  init_ram(ram_seed);
  filename = argv[1];
  read_bin_file(filename);
  CPU();
  line_print();
  printf("End of Execution.\n");
  header_print("RAM STATE");
  show_ram(0, 31);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11eb <main+0x5b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe41(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
je     11e6 <main+0x56>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11f2 <main+0x62>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <init_ram@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <read_bin_file@plt>
mov    $0x0,%al
call   10a0 <CPU@plt>
mov    $0x0,%al
call   1040 <line_print@plt>
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
lea    0xe00(%rip),%rdi
call   1090 <header_print@plt>
xor    %edi,%edi
mov    $0x1f,%esi
call   1070 <show_ram@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jl     11ce <main+0x3e>
mov    0x10(%rbx),%rdi
lea    0xe58(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
je     11d6 <main+0x46>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d6 <main+0x46>
movl   $0x0,0xc(%rsp)
mov    0xc(%rsp),%edi
call   1060 <init_ram@plt>
mov    0x8(%rbx),%rdi
call   10b0 <read_bin_file@plt>
xor    %eax,%eax
call   10a0 <CPU@plt>
xor    %eax,%eax
call   1040 <line_print@plt>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe14(%rip),%rdi
call   1090 <header_print@plt>
xor    %edi,%edi
mov    $0x1f,%esi
call   1070 <show_ram@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Error - seed not integer\0A\00"
@.str.2 = [19 x i8] c"End of Execution.\0A\00"
@.str.3 = [10 x i8] c"RAM STATE\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16, %10
br label %21
20: ; preds = %2
store i32 0, i32* %6
br label %21
21: ; preds = %20, %19
%22 = load i32, i32* %6
%23 = call i32 @init_ram(i32 %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = call i32 @read_bin_file(i8* %27)
%29 = call i32 (...) @CPU()
%30 = call i32 (...) @line_print()
%31 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @header_print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @show_ram(i32 0, i32 31)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Error - seed not integer\0A\00"
@.str.3 = [10 x i8] c"RAM STATE\00"
@str = [18 x i8] c"End of Execution.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %15
14: ; preds = %2
store i32 0, i32* %3
br label %15
15: ; preds = %6, %11, %14
%16 = load i32, i32* %3
%17 = call i32 @init_ram(i32 %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @read_bin_file(i8* %19)
%21 = call i32 (...) @CPU()
%22 = call i32 (...) @line_print()
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%24 = call i32 @header_print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @show_ram(i32 0, i32 31)
ret i32 0
}