#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 */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
char *processRoom(int /*<<< orphan*/ *, char *);
int main() {
  int game_over = 0;
  char *current_room = "0001";
  FILE *adventure_file = fopen("adventure.csv", "r");
  printf("WELCOME TO JORK, the hyperinteractive text game\n");
  while (!game_over) {
    current_room = processRoom(adventure_file, current_room);
    if (!current_room) {
      game_over = 1;
    }
  }
  printf("THE GAME IS OVER. GO HOME.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118a <main+0x5a>
jmp    11b2 <main+0x82>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <processRoom@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ad <main+0x7d>
movl   $0x1,-0x8(%rbp)
jmp    1174 <main+0x44>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xecd(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%rax
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <processRoom@plt>
test   %rax,%rax
jne    1160 <main+0x30>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0001\00"
@.str.1 = [14 x i8] c"adventure.csv\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [49 x i8] c"WELCOME TO JORK, the hyperinteractive text game\0A\00"
@.str.4 = [28 x i8] c"THE GAME IS OVER. GO HOME.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 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* %5, i32** %4
%6 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32*, i32** %4
%13 = load i8*, i8** %3
%14 = call i8* @processRoom(i32* %12, i8* %13)
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %11
store i32 1, i32* %2
br label %18
18: ; preds = %17, %11
br label %7
19: ; preds = %7
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"0001\00"
@.str.1 = [14 x i8] c"adventure.csv\00"
@.str.2 = [2 x i8] c"r\00"
@str = [48 x i8] c"WELCOME TO JORK, the hyperinteractive text game\00"
@str.5 = [27 x i8] c"THE GAME IS OVER. GO HOME.\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %0 ], [ %5, %3 ]
%5 = tail call i8* @processRoom(i32* %1, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %3
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}