#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*/ FreeMemory();
int /*<<< orphan*/ LoadGame(char *, int /*<<< orphan*/ *);
scalar_t__ RunGame();
int /*<<< orphan*/ StopGame();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("Level 9 Interpreter\n\n");
  if (argc != 2) {
    printf("Use: %s <gamefile>\n", argv[0]);
    return 0;
  }
  if (!LoadGame(argv[1], NULL)) {
    printf("Error: Unable to open game file\n");
    return 0;
  }
  while (RunGame())
    ;
  StopGame();
  FreeMemory();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x4f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1203 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <LoadGame@plt>
cmp    $0x0,%eax
jne    11d3 <main+0x83>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1203 <main+0xb3>
jmp    11d8 <main+0x88>
mov    $0x0,%al
call   1050 <RunGame@plt>
cmp    $0x0,%rax
je     11ee <main+0x9e>
jmp    11d8 <main+0x88>
mov    $0x0,%al
call   1070 <StopGame@plt>
mov    $0x0,%al
call   1060 <FreeMemory@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebp
jne    11ac <main+0x4c>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
call   1030 <LoadGame@plt>
test   %eax,%eax
je     11bf <main+0x5f>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <RunGame@plt>
test   %rax,%rax
jne    1190 <main+0x30>
xor    %eax,%eax
call   1080 <StopGame@plt>
xor    %eax,%eax
call   1070 <FreeMemory@plt>
jmp    11cb <main+0x6b>
mov    (%rbx),%rsi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cb <main+0x6b>
lea    0xe63(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Level 9 Interpreter\0A\0A\00"
@.str.1 = [20 x i8] c"Use: %s <gamefile>\0A\00"
@.str.2 = [33 x i8] c"Error: Unable to open game file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %3
br label %30
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @LoadGame(i8* %17, i32* null)
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %30
22: ; preds = %14
br label %23
23: ; preds = %26, %22
%24 = call i64 (...) @RunGame()
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23
br label %23
27: ; preds = %23
%28 = call i32 (...) @StopGame()
%29 = call i32 (...) @FreeMemory()
store i32 0, i32* %3
br label %30
30: ; preds = %27, %20, %9
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"Use: %s <gamefile>\0A\00"
@str = [21 x i8] c"Level 9 Interpreter\0A\00"
@str.3 = [32 x i8] c"Error: Unable to open game file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %21
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @LoadGame(i8* %10, i32* null)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.3, i64 0, i64 0))
br label %21
15: ; preds = %8, %15
%16 = tail call i64 (...) @RunGame()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %15
18: ; preds = %15
%19 = tail call i32 (...) @StopGame()
%20 = tail call i32 (...) @FreeMemory()
br label %21
21: ; preds = %18, %13, %5
ret i32 0
}