#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ load_board_cells(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ load_board_header(int /*<<< orphan*/ *);
int /*<<< orphan*/ throw_error(char *, char const *);
void load_board(char const filename[], int use_brief) {
  FILE *fp;
  fp = fopen(filename, "r");
  if (!fp)
    throw_error("Unable to open %s for reading", filename);
  load_board_header(fp);
  load_board_cells(fp, use_brief);
  fclose(fp);
}


x86 assembly (clang, -O0):
<load_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <load_board+0x3e>
mov    -0x8(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1070 <throw_error@plt>
mov    -0x18(%rbp),%rdi
call   1050 <load_board_header@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <load_board_cells@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_board>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117d <load_board+0x2d>
lea    0xe8d(%rip),%rdi
mov    %rbp,%rsi
call   1070 <throw_error@plt>
mov    %rbx,%rdi
call   1050 <load_board_header@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <load_board_cells@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [30 x i8] c"Unable to open %s for reading\00"
define void @load_board(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = icmp ne i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @throw_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %2
%14 = load i32*, i32** %5
%15 = call i32 @load_board_header(i32* %14)
%16 = load i32*, i32** %5
%17 = load i32, i32* %4
%18 = call i32 @load_board_cells(i32* %16, i32 %17)
%19 = load i32*, i32** %5
%20 = call i32 @fclose(i32* %19)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [30 x i8] c"Unable to open %s for reading\00"
define void @load_board(i8* %0, i32 %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @throw_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @load_board_header(i32* %3)
%9 = tail call i32 @load_board_cells(i32* %3, i32 %1)
%10 = tail call i32 @fclose(i32* %3)
ret void
}