#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 */
struct gamehandle {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ load_creatures(struct gamehandle *, int /*<<< orphan*/ *);
int /*<<< orphan*/ load_map(int /*<<< orphan*/ *);
int /*<<< orphan*/ load_pc(struct gamehandle *, int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
int load_game(struct gamehandle *myrill) {
  FILE *load;
  load = fopen("myrill.save", "r");
  if (load == NULL)
    return (0);
  load_map(load);
  load_pc(myrill, load);
  load_creatures(myrill, load);
  fclose(load);
  unlink("myrill.save");
  return (1);
}


x86 assembly (clang, -O0):
<load_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119a <load_game+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <load_game+0x79>
mov    -0x18(%rbp),%rdi
call   1070 <load_map@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <load_pc@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <load_creatures@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe33(%rip),%rdi
call   1030 <unlink@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_game>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe92(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11bb <load_game+0x5b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <load_map@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <load_pc@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <load_creatures@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe51(%rip),%rdi
call   1030 <unlink@plt>
mov    $0x1,%eax
jmp    11bd <load_game+0x5d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.gamehandle = type { i32 }
@.str = [12 x i8] c"myrill.save\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @load_game(%struct.gamehandle* %0) {
%2 = alloca i32
%3 = alloca %struct.gamehandle*
%4 = alloca i32*
store %struct.gamehandle* %0, %struct.gamehandle** %3
%5 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
%6 = load i32*, i32** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %21
9: ; preds = %1
%10 = load i32*, i32** %4
%11 = call i32 @load_map(i32* %10)
%12 = load %struct.gamehandle*, %struct.gamehandle** %3
%13 = load i32*, i32** %4
%14 = call i32 @load_pc(%struct.gamehandle* %12, i32* %13)
%15 = load %struct.gamehandle*, %struct.gamehandle** %3
%16 = load i32*, i32** %4
%17 = call i32 @load_creatures(%struct.gamehandle* %15, i32* %16)
%18 = load i32*, i32** %4
%19 = call i32 @fclose(i32* %18)
%20 = call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %21
21: ; preds = %9, %8
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
%struct.gamehandle = type { i32 }
@.str = [12 x i8] c"myrill.save\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @load_game(%struct.gamehandle* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 @load_map(i32* %2)
%6 = tail call i32 @load_pc(%struct.gamehandle* %0, i32* %2)
%7 = tail call i32 @load_creatures(%struct.gamehandle* %0, i32* %2)
%8 = tail call i32 @fclose(i32* %2)
%9 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %1, %4
%11 = phi i32 [ 1, %4 ], [ 0, %1 ]
ret i32 %11
}