#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 *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, char *);
int load_puzzle(int pzl[][9]) {
  char filename[] = "sudoku_puzzle.txt";
  FILE *fptr;
  int pzl_i;
  int n;
  int i;
  if ((fptr = fopen(filename, "r")) == NULL) {
    printf("Unable to open file: %s\n", filename);
    return -1;
  }
  for (i = 0; i < 9; i++) {
    pzl_i = 0;
    while (fscanf(fptr, "%d", &n) > 0) {
      pzl[i][pzl_i++] = n;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<load_puzzle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1197 <load_puzzle+0x67>
lea    -0x30(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <load_puzzle+0xdf>
movl   $0x0,-0x44(%rbp)
cmpl   $0x9,-0x44(%rbp)
jge    1208 <load_puzzle+0xd8>
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe73(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x0,%rax
jle    11f5 <load_puzzle+0xc5>
mov    -0x40(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
mov    -0x3c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x3c(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11af <load_puzzle+0x7f>
jmp    11fa <load_puzzle+0xca>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    119e <load_puzzle+0x6e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_puzzle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x74,0x20(%rsp)
lea    0xeb7(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d7 <load_puzzle+0xa7>
mov    %rax,%rbx
xor    %r13d,%r13d
lea    0xeb6(%rip),%r15
lea    0xc(%rsp),%r12
jmp    118e <load_puzzle+0x5e>
xchg   %ax,%ax
add    $0x1,%r13
add    $0x24,%r14
cmp    $0x9,%r13
je     11d0 <load_puzzle+0xa0>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
test   %rax,%rax
jle    1180 <load_puzzle+0x50>
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%eax
mov    %eax,0x0(%rbp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
add    $0x4,%rbp
test   %rax,%rax
jg     11b0 <load_puzzle+0x80>
jmp    1180 <load_puzzle+0x50>
mov    $0x1,%eax
jmp    11ed <load_puzzle+0xbd>
lea    0xe36(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.load_puzzle.filename = [18 x i8] c"sudoku_puzzle.txt\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Unable to open file: %s\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @load_puzzle([9 x i32]* %0) {
%2 = alloca i32
%3 = alloca [9 x i32]*
%4 = alloca [18 x i8]
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [9 x i32]* %0, [9 x i32]** %3
%9 = bitcast [18 x i8]* %4 to i8*
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 -1, i32* %2
br label %40
16: ; preds = %1
store i32 0, i32* %8
br label %17
17: ; preds = %36, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 9
br i1 %19, label %20, label %39
20: ; preds = %17
store i32 0, i32* %6
br label %21
21: ; preds = %25, %20
%22 = load i32*, i32** %5
%23 = call i64 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32, i32* %7
%27 = load [9 x i32]*, [9 x i32]** %3
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [9 x i32], [9 x i32]* %27, i64 %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds [9 x i32], [9 x i32]* %30, i64 0, i64 %33
store i32 %26, i32* %34
br label %21
35: ; preds = %21
br label %36
36: ; preds = %35
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %17
39: ; preds = %17
store i32 1, i32* %2
br label %40
40: ; preds = %39, %13
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@__const.load_puzzle.filename = [18 x i8] c"sudoku_puzzle.txt\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Unable to open file: %s\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @load_puzzle([9 x i32]* nocapture writeonly %0) {
%2 = alloca [18 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %24
10: ; preds = %1, %21
%11 = phi i64 [ %22, %21 ], [ 0, %1 ]
%12 = call i64 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10, %14
%15 = phi i64 [ %17, %14 ], [ 0, %10 ]
%16 = load i32, i32* %3
%17 = add nuw i64 %15, 1
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %0, i64 %11, i64 %15
store i32 %16, i32* %18
%19 = call i64 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %14, label %21
21: ; preds = %14, %10
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, 9
br i1 %23, label %24, label %10
24: ; preds = %21, %8
%25 = phi i32 [ -1, %8 ], [ 1, %21 ]
ret i32 %25
}