#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*/ game_run(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ writeOutputFile(char *, char *, int);
int main(int argc, char *argv[]) {
  int status = 0;
  if (argc == 2) {
    char output[8192];
    memset(output, 0, 8192);
    game_run(argv[1], output, 8192);
    if (strlen(output) > 0) {
      char outFile[256];
      memset(outFile, 0, 256);
      strcpy(outFile, argv[1]);
      strcat(outFile, ".out");
      writeOutputFile(outFile, output, 8192);
    }
  } else {
    printf("%s", "Usage: game <input file>\n");
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1233 <main+0xc3>
lea    -0x2020(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x2020(%rbp),%rsi
mov    $0x2000,%edx
call   1080 <game_run@plt>
lea    -0x2020(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    122e <main+0xbe>
lea    -0x2120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
lea    -0x2120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x2120(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x2120(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <writeOutputFile@plt>
jmp    1246 <main+0xd6>
lea    0xdcb(%rip),%rdi
lea    0xdc7(%rip),%rsi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x2120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x2108,%rsp
cmp    $0x2,%edi
jne    11fb <main+0x8b>
mov    %rsi,%rbx
lea    0x100(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1070 <memset@plt>
mov    0x8(%rbx),%rdi
mov    %r14,%rsi
mov    $0x2000,%edx
call   1080 <game_run@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    120e <main+0x9e>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe24(%rip),%rsi
mov    %r14,%rdi
call   1090 <strcat@plt>
lea    0x100(%rsp),%rsi
mov    %r14,%rdi
mov    $0x2000,%edx
call   1060 <writeOutputFile@plt>
jmp    120e <main+0x9e>
lea    0xe03(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x2108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c".out\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Usage: game <input file>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8192 x i8]
%8 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %36
11: ; preds = %2
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 8192)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%18 = call i32 @game_run(i8* %16, i8* %17, i32 8192)
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %11
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 256)
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcpy(i8* %25, i8* %28)
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%34 = call i32 @writeOutputFile(i8* %32, i8* %33, i32 8192)
br label %35
35: ; preds = %22, %11
br label %38
36: ; preds = %2
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %35
%39 = load i32, i32* %6
ret i32 %39
}

LLVM IR (-O2):
@.str = [5 x i8] c".out\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Usage: game <input file>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8192 x i8]
%4 = alloca [256 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 8192)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @game_run(i8* %10, i8* %7, i32 8192)
%12 = call i64 @strlen(i8* %7)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %6
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 256)
%17 = load i8*, i8** %9
%18 = call i32 @strcpy(i8* %15, i8* %17)
%19 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @writeOutputFile(i8* %15, i8* %7, i32 8192)
br label %21
21: ; preds = %14, %6
br label %24
22: ; preds = %2
%23 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
ret i32 0
}