#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
void readFile(char *filename, int x[9][9]) {
  FILE *f;
  char buf[160];
  int row, col, i;
  size_t len;
  for (row = 0; row < 9; row++)
    for (col = 0; col < 9; col++)
      x[row][col] = -1;
  f = fopen(filename, "r");
  if (!f) {
    printf("Couldn't open %s\n", filename);
    exit(0);
  }
  row = 0;
  while ((row < 9) && (!feof(f))) {
    fgets(buf, 160, f);
    col = 0;
    for (i = 0; (i < 160) && (col < 9) && (buf[i] != '\n'); i++) {
      if (isdigit(buf[i])) {
        x[row][col] = buf[i] - '0';
        col++;
      }
    }
    if ((col > 0) && (col < 9)) {
      printf("Short read on row %d. Found %d values\n", row, col);
      exit(0);
    }
    if (col == 9)
      row++;
  }
  if (row != 9) {
    printf("Wrong number of rows? Got %d\n", row);
    exit(0);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xc4(%rbp)
cmpl   $0x9,-0xc4(%rbp)
jge    11fe <readFile+0x8e>
movl   $0x0,-0xc8(%rbp)
cmpl   $0x9,-0xc8(%rbp)
jge    11e5 <readFile+0x75>
mov    -0x10(%rbp),%rax
movslq -0xc4(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0xc8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    11a4 <readFile+0x34>
jmp    11ea <readFile+0x7a>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    118d <readFile+0x1d>
mov    -0x8(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1236 <readFile+0xc6>
mov    -0x8(%rbp),%rsi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
movl   $0x0,-0xc4(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0xc4(%rbp)
mov    %al,-0xd9(%rbp)
jge    126c <readFile+0xfc>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xd9(%rbp)
mov    -0xd9(%rbp),%al
test   $0x1,%al
jne    127f <readFile+0x10f>
jmp    13d3 <readFile+0x263>
lea    -0xc0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xa0,%esi
call   1060 <fgets@plt>
movl   $0x0,-0xc8(%rbp)
movl   $0x0,-0xcc(%rbp)
xor    %eax,%eax
cmpl   $0xa0,-0xcc(%rbp)
mov    %al,-0xda(%rbp)
jge    12f0 <readFile+0x180>
xor    %eax,%eax
cmpl   $0x9,-0xc8(%rbp)
mov    %al,-0xda(%rbp)
jge    12f0 <readFile+0x180>
movslq -0xcc(%rbp),%rax
movsbl -0xc0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
setne  %al
mov    %al,-0xda(%rbp)
mov    -0xda(%rbp),%al
test   $0x1,%al
jne    1303 <readFile+0x193>
jmp    1377 <readFile+0x207>
movslq -0xcc(%rbp),%rax
movsbl -0xc0(%rbp,%rax,1),%edi
ff
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     135e <readFile+0x1ee>
movslq -0xcc(%rbp),%rax
movsbl -0xc0(%rbp,%rax,1),%edx
ff
sub    $0x30,%edx
mov    -0x10(%rbp),%rax
movslq -0xc4(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0xc8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    1363 <readFile+0x1f3>
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    12a8 <readFile+0x138>
cmpl   $0x0,-0xc8(%rbp)
jle    13b2 <readFile+0x242>
cmpl   $0x9,-0xc8(%rbp)
jge    13b2 <readFile+0x242>
mov    -0xc4(%rbp),%esi
mov    -0xc8(%rbp),%edx
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
cmpl   $0x9,-0xc8(%rbp)
jne    13ce <readFile+0x25e>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    1240 <readFile+0xd0>
cmpl   $0x9,-0xc4(%rbp)
je     13fb <readFile+0x28b>
mov    -0xc4(%rbp),%esi
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%r13
mov    %rdi,%rbp
mov    $0x144,%edx
mov    %rsi,%rdi
mov    $0xff,%esi
call   1060 <memset@plt>
lea    0xe50(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     12b3 <readFile+0x133>
mov    %rax,%r14
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1281 <readFile+0x101>
mov    %rsp,%rdi
mov    $0xa0,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %r12d,%ebx
xor    %r15d,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%r15,1),%eax
cmp    $0xa,%al
je     1248 <readFile+0xc8>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1236 <readFile+0xb6>
movsbl (%rsp,%r15,1),%eax
add    $0xffffffd0,%eax
movslq %ebp,%rbp
lea    (%rbx,%rbx,8),%rcx
lea    0x0(,%rcx,4),%rcx
add    %r13,%rcx
mov    %eax,(%rcx,%rbp,4)
add    $0x1,%ebp
cmp    $0x9e,%r15
ja     1248 <readFile+0xc8>
add    $0x1,%r15
cmp    $0x9,%ebp
jl     1200 <readFile+0x80>
lea    -0x1(%rbp),%eax
cmp    $0x7,%eax
jbe    1299 <readFile+0x119>
xor    %eax,%eax
cmp    $0x9,%ebp
sete   %al
add    %eax,%r12d
cmp    $0x9,%r12d
jb     11d0 <readFile+0x50>
jne    1281 <readFile+0x101>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb3(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xd74(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xd48(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.2 = [39 x i8] c"Short read on row %d. Found %d values\0A\00"
@.str.3 = [30 x i8] c"Wrong number of rows? Got %d\0A\00"
define void @readFile(i8* %0, [9 x i32]* %1) {
%3 = alloca i8*
%4 = alloca [9 x i32]*
%5 = alloca i32*
%6 = alloca [160 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
store i8* %0, i8** %3
store [9 x i32]* %1, [9 x i32]** %4
store i32 0, i32* %7
br label %11
11: ; preds = %30, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 9
br i1 %13, label %14, label %33
14: ; preds = %11
store i32 0, i32* %8
br label %15
15: ; preds = %26, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 9
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load [9 x i32]*, [9 x i32]** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %19, i64 %21
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [9 x i32], [9 x i32]* %22, i64 0, i64 %24
store i32 -1, i32* %25
br label %26
26: ; preds = %18
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %15
29: ; preds = %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %11
33: ; preds = %11
%34 = load i8*, i8** %3
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %35, i32** %5
%36 = load i32*, i32** %5
%37 = icmp ne i32* %36, null
br i1 %37, label %42, label %38
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %33
store i32 0, i32* %7
br label %43
43: ; preds = %116, %42
%44 = load i32, i32* %7
%45 = icmp slt i32 %44, 9
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32*, i32** %5
%48 = call i32 @feof(i32* %47)
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
br label %51
51: ; preds = %46, %43
%52 = phi i1 [ false, %43 ], [ %50, %46 ]
br i1 %52, label %53, label %117
53: ; preds = %51
%54 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 0
%55 = load i32*, i32** %5
%56 = call i32 @fgets(i8* %54, i32 160, i32* %55)
store i32 0, i32* %8
store i32 0, i32* %9
br label %57
57: ; preds = %96, %53
%58 = load i32, i32* %9
%59 = icmp slt i32 %58, 160
br i1 %59, label %60, label %70
60: ; preds = %57
%61 = load i32, i32* %8
%62 = icmp slt i32 %61, 9
br i1 %62, label %63, label %70
63: ; preds = %60
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 10
br label %70
70: ; preds = %63, %60, %57
%71 = phi i1 [ false, %60 ], [ false, %57 ], [ %69, %63 ]
br i1 %71, label %72, label %99
72: ; preds = %70
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = call i64 @isdigit(i8 signext %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %95
79: ; preds = %72
%80 = load i32, i32* %9
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = sub nsw i32 %84, 48
%86 = load [9 x i32]*, [9 x i32]** %4
%87 = load i32, i32* %7
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [9 x i32], [9 x i32]* %86, i64 %88
%90 = load i32, i32* %8
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [9 x i32], [9 x i32]* %89, i64 0, i64 %91
store i32 %85, i32* %92
%93 = load i32, i32* %8
%94 = add nsw i32 %93, 1
store i32 %94, i32* %8
br label %95
95: ; preds = %79, %72
br label %96
96: ; preds = %95
%97 = load i32, i32* %9
%98 = add nsw i32 %97, 1
store i32 %98, i32* %9
br label %57
99: ; preds = %70
%100 = load i32, i32* %8
%101 = icmp sgt i32 %100, 0
br i1 %101, label %102, label %110
102: ; preds = %99
%103 = load i32, i32* %8
%104 = icmp slt i32 %103, 9
br i1 %104, label %105, label %110
105: ; preds = %102
%106 = load i32, i32* %7
%107 = load i32, i32* %8
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %106, i32 %107)
%109 = call i32 @exit(i32 0)
unreachable
110: ; preds = %102, %99
%111 = load i32, i32* %8
%112 = icmp eq i32 %111, 9
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32, i32* %7
%115 = add nsw i32 %114, 1
store i32 %115, i32* %7
br label %116
116: ; preds = %113, %110
br label %43
117: ; preds = %51
%118 = load i32, i32* %7
%119 = icmp ne i32 %118, 9
br i1 %119, label %120, label %124
120: ; preds = %117
%121 = load i32, i32* %7
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %121)
%123 = call i32 @exit(i32 0)
unreachable
124: ; preds = %117
%125 = load i32*, i32** %5
%126 = call i32 @fclose(i32* %125)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.2 = [39 x i8] c"Short read on row %d. Found %d values\0A\00"
@.str.3 = [30 x i8] c"Wrong number of rows? Got %d\0A\00"
define void @readFile(i8* %0, [9 x i32]* nocapture writeonly %1) {
%3 = bitcast [9 x i32]* %1 to i8*
%4 = alloca [160 x i8]
%5 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, 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 %11
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %2, %47
%12 = phi i32 [ %50, %47 ], [ 0, %2 ]
%13 = call i32 @feof(i32* %6)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %54
15: ; preds = %11
%16 = call i32 @fgets(i8* %5, i32 160, i32* %6)
%17 = zext i32 %12 to i64
br label %18
18: ; preds = %15, %34
%19 = phi i64 [ 0, %15 ], [ %36, %34 ]
%20 = phi i32 [ 0, %15 ], [ %35, %34 ]
%21 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 %19
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 10
br i1 %23, label %40, label %24
24: ; preds = %18
%25 = call i64 @isdigit(i8 signext %22)
%26 = icmp eq i64 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %24
%28 = load i8, i8* %21
%29 = sext i8 %28 to i32
%30 = add nsw i32 %29, -48
%31 = sext i32 %20 to i64
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 %17, i64 %31
store i32 %30, i32* %32
%33 = add nsw i32 %20, 1
br label %34
34: ; preds = %24, %27
%35 = phi i32 [ %33, %27 ], [ %20, %24 ]
%36 = add nuw nsw i64 %19, 1
%37 = icmp ult i64 %19, 159
%38 = icmp slt i32 %35, 9
%39 = select i1 %37, i1 %38, i1 false
br i1 %39, label %18, label %40
40: ; preds = %34, %18
%41 = phi i32 [ %35, %34 ], [ %20, %18 ]
%42 = add i32 %41, -1
%43 = icmp ult i32 %42, 8
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %41)
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %40
%48 = icmp eq i32 %41, 9
%49 = zext i1 %48 to i32
%50 = add nuw nsw i32 %12, %49
%51 = icmp ult i32 %50, 9
br i1 %51, label %11, label %52
52: ; preds = %47
%53 = icmp eq i32 %50, 9
br i1 %53, label %58, label %54
54: ; preds = %11, %52
%55 = phi i32 [ %50, %52 ], [ %12, %11 ]
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %55)
%57 = call i32 @exit(i32 0)
unreachable
58: ; preds = %52
%59 = call i32 @fclose(i32* %6)
ret void
}