#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 */
char *FileLoad(char *, int /*<<< orphan*/ *, char *);
int GetSimParamI(char *, int /*<<< orphan*/);
int /*<<< orphan*/ MySrand(unsigned long);
int /*<<< orphan*/ ParseQueryString(char *);
int /*<<< orphan*/ StartBattle(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ time(int /*<<< orphan*/ *);
void main(int argc, char **argv) {
  char filename[1024];
  char *battle_data;
  if (argc < 2)
    return;
  ParseQueryString(argv[1]);
  {
    int battle_id = GetSimParamI("battle_id", 0);
    if (battle_id == 0)
      return;
    sprintf(filename, "battledata/battle_%i.txt", battle_id);
    battle_data = FileLoad(filename, NULL, "rt");
    MySrand((unsigned long)time(NULL));
    StartBattle(battle_data, battle_id);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1191 <main+0x21>
jmp    121e <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <ParseQueryString@plt>
lea    0xe5b(%rip),%rdi
xor    %esi,%esi
call   1050 <GetSimParamI@plt>
mov    %eax,-0x41c(%rbp)
cmpl   $0x0,-0x41c(%rbp)
jne    11c4 <main+0x54>
jmp    121e <main+0xae>
lea    -0x410(%rbp),%rdi
mov    -0x41c(%rbp),%edx
lea    0xe32(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    0xe34(%rip),%rdx
call   1030 <FileLoad@plt>
mov    %rax,-0x418(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,%rdi
call   1070 <MySrand@plt>
mov    -0x418(%rbp),%rdi
mov    -0x41c(%rbp),%esi
call   1090 <StartBattle@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
cmp    $0x2,%edi
jl     11dd <main+0x6d>
mov    0x8(%rsi),%rdi
call   1040 <ParseQueryString@plt>
lea    0xe71(%rip),%rdi
xor    %esi,%esi
call   1050 <GetSimParamI@plt>
test   %eax,%eax
je     11dd <main+0x6d>
mov    %eax,%ebx
lea    0xe67(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %eax,%edx
call   1080 <sprintf@plt>
lea    0xe6c(%rip),%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <FileLoad@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rdi
call   1070 <MySrand@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1090 <StartBattle@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"battle_id\00"
@.str.1 = [25 x i8] c"battledata/battle_%i.txt\00"
@.str.2 = [3 x i8] c"rt\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
br label %31
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @ParseQueryString(i8* %14)
%16 = call i32 @GetSimParamI(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %11
br label %31
20: ; preds = %11
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* %7
%23 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i8* @FileLoad(i8* %24, i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %25, i8** %6
%26 = call i64 @time(i32* null)
%27 = call i32 @MySrand(i64 %26)
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = call i32 @StartBattle(i8* %28, i32 %29)
br label %31
31: ; preds = %20, %19, %10
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"battle_id\00"
@.str.1 = [25 x i8] c"battledata/battle_%i.txt\00"
@.str.2 = [3 x i8] c"rt\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @ParseQueryString(i8* %8)
%10 = tail call i32 @GetSimParamI(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %6
%13 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%14 = call i8* @FileLoad(i8* %4, i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = call i64 @time(i32* null)
%16 = call i32 @MySrand(i64 %15)
%17 = call i32 @StartBattle(i8* %14, i32 %10)
br label %18
18: ; preds = %12, %6, %2
ret void
}