#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 */
scalar_t__ EOF;
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
void load_board(unsigned char **board, unsigned int rows, unsigned int cols,
                FILE *file) {
  int x, y;
  while (fscanf(file, "%i %i", &x, &y) != EOF) {
    if (x < cols || y < rows) {
      board[x][y] = '1';
    }
  }
}


x86 assembly (clang, -O0):
<load_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xecf(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1030 <fscanf@plt>
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%rax
je     117f <load_board+0x6f>
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jb     1166 <load_board+0x56>
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    117a <load_board+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    1126 <load_board+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_board>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,0x10(%rsp)
lea    0xece(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%rax
jne    115f <load_board+0x4f>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe9a(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r15
jmp    11ad <load_board+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %ecx,%rcx
mov    0x10(%rsp),%rdx
mov    (%rdx,%rax,8),%rax
movb   $0x31,(%rax,%rcx,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1030 <fscanf@plt>
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
je     1150 <load_board+0x40>
movslq 0xc(%rsp),%rax
mov    0x8(%rsp),%ecx
cmp    %ebp,%eax
jb     1180 <load_board+0x70>
cmp    %r14d,%ecx
jae    1190 <load_board+0x80>
jmp    1180 <load_board+0x70>

LLVM IR (-O0):
@.str = [6 x i8] c"%i %i\00"
@EOF = global i64 0
define void @load_board(i8** %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
br label %11
11: ; preds = %33, %4
%12 = load i32*, i32** %8
%13 = call i64 @fscanf(i32* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %10)
%14 = load i64, i64* @EOF
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %11
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = icmp ult i32 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i32, i32* %10
%22 = load i32, i32* %6
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20, %16
%25 = load i8**, i8*** %5
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 49, i8* %32
br label %33
33: ; preds = %24, %20
br label %11
34: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%i %i\00"
@EOF = global i64 0
define void @load_board(i8** nocapture %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %28, label %12
12: ; preds = %4, %24
%13 = load i32, i32* %5
%14 = icmp ult i32 %13, %2
%15 = load i32, i32* %6
%16 = icmp ult i32 %15, %1
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = sext i32 %13 to i64
%20 = getelementptr inbounds i8*, i8** %0, i64 %19
%21 = load i8*, i8** %20
%22 = sext i32 %15 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8 49, i8* %23
br label %24
24: ; preds = %12, %18
%25 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %12
28: ; preds = %24, %4
ret void
}