#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 uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void read_puzzle(char *filename, uint8_t (*board)[9][9]) {
  FILE *f = fopen(filename, "r");
  int c, row, col;
  uint8_t v;
  for (row = 0; row < 9; row++) {
    for (col = 0; col < 9; col++) {
      c = fgetc(f);
      if (EOF == c) {
      }
      if ((char)c == '.') {
        v = (0);
      } else if ((char)c == ' ') {
        v = (0);
      } else if ((char)c < '1' || (char)c > '9') {
        v = (0);
      } else {
        v = (uint8_t)(c - '0');
      }
      (*board)[row][col] = v;
      if (v != (0)) {
        (*board)[row][col] |= 0x80;
      }
    }
    while (1 == 1) {
      c = fgetc(f);
      if (c == '\r')
        continue;
      if (c == '\n')
        continue;
      ungetc(c, f);
      break;
    }
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<read_puzzle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x9,-0x20(%rbp)
jge    12bf <read_puzzle+0x17f>
movl   $0x0,-0x24(%rbp)
cmpl   $0x9,-0x24(%rbp)
jge    1271 <read_puzzle+0x131>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
jne    11a9 <read_puzzle+0x69>
jmp    11a9 <read_puzzle+0x69>
mov    -0x1c(%rbp),%eax
movsbl %al,%eax
cmp    $0x2e,%eax
jne    11c4 <read_puzzle+0x84>
movl   $0x0,-0x28(%rbp)
jmp    121c <read_puzzle+0xdc>
mov    -0x1c(%rbp),%eax
movsbl %al,%eax
cmp    $0x20,%eax
jne    11df <read_puzzle+0x9f>
movl   $0x0,-0x28(%rbp)
jmp    1217 <read_puzzle+0xd7>
mov    -0x1c(%rbp),%eax
movsbl %al,%eax
cmp    $0x31,%eax
jl     11fd <read_puzzle+0xbd>
mov    -0x1c(%rbp),%eax
movsbl %al,%eax
cmp    $0x39,%eax
jle    1209 <read_puzzle+0xc9>
movl   $0x0,-0x28(%rbp)
jmp    1212 <read_puzzle+0xd2>
mov    -0x1c(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x28(%rbp)
jmp    1217 <read_puzzle+0xd7>
jmp    121c <read_puzzle+0xdc>
mov    -0x28(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
cmpl   $0x0,-0x28(%rbp)
je     125e <read_puzzle+0x11e>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
or     $0x80,%edx
mov    %edx,(%rax,%rcx,4)
jmp    1263 <read_puzzle+0x123>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <read_puzzle+0x3c>
jmp    1276 <read_puzzle+0x136>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xd,-0x1c(%rbp)
jne    1291 <read_puzzle+0x151>
jmp    1276 <read_puzzle+0x136>
cmpl   $0xa,-0x1c(%rbp)
jne    12a0 <read_puzzle+0x160>
jmp    1276 <read_puzzle+0x136>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <ungetc@plt>
jmp    12b1 <read_puzzle+0x171>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <read_puzzle+0x2b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_puzzle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
xor    %r15d,%r15d
mov    %r14,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    119e <read_puzzle+0x5e>
cs nopw 0x0(%rax,%rax,1)
lea    (%r15,%r15,8),%rax
lea    (%r14,%rax,4),%rax
lea    (%rax,%rbp,4),%rcx
xor    %eax,%eax
mov    %eax,(%rcx)
add    $0x1,%rbp
add    $0x4,%rbx
cmp    $0x24,%rbx
je     11e0 <read_puzzle+0xa0>
mov    %r13,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
shl    $0x18,%ecx
cmp    $0x20000000,%ecx
je     1180 <read_puzzle+0x40>
cmp    $0x2e000000,%ecx
je     1180 <read_puzzle+0x40>
add    $0xc6ffffff,%ecx
cmp    $0xf7fffffe,%ecx
jbe    1180 <read_puzzle+0x40>
add    $0xffffffd0,%eax
lea    (%r12,%rbx,1),%rcx
test   %eax,%eax
je     118c <read_puzzle+0x4c>
or     $0x80,%eax
jmp    118e <read_puzzle+0x4e>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     11e0 <read_puzzle+0xa0>
cmp    $0xd,%eax
je     11e0 <read_puzzle+0xa0>
mov    %eax,%edi
mov    %r13,%rsi
call   1050 <ungetc@plt>
add    $0x1,%r15
add    $0x24,%r12
cmp    $0x9,%r15
jne    1170 <read_puzzle+0x30>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define void @read_puzzle(i8* %0, [9 x [9 x i32]]* %1) {
%3 = alloca i8*
%4 = alloca [9 x [9 x i32]]*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store [9 x [9 x i32]]* %1, [9 x [9 x i32]]** %4
%10 = load i8*, i8** %3
%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
store i32 0, i32* %7
br label %12
12: ; preds = %95, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 9
br i1 %14, label %15, label %98
15: ; preds = %12
store i32 0, i32* %8
br label %16
16: ; preds = %76, %15
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 9
br i1 %18, label %19, label %79
19: ; preds = %16
%20 = load i32*, i32** %5
%21 = call i32 @fgetc(i32* %20)
store i32 %21, i32* %6
%22 = load i32, i32* @EOF
%23 = load i32, i32* %6
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %19
br label %26
26: ; preds = %25, %19
%27 = load i32, i32* %6
%28 = trunc i32 %27 to i8
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 46
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 0, i32* %9
br label %54
32: ; preds = %26
%33 = load i32, i32* %6
%34 = trunc i32 %33 to i8
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 32
br i1 %36, label %37, label %38
37: ; preds = %32
store i32 0, i32* %9
br label %53
38: ; preds = %32
%39 = load i32, i32* %6
%40 = trunc i32 %39 to i8
%41 = sext i8 %40 to i32
%42 = icmp slt i32 %41, 49
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = load i32, i32* %6
%45 = trunc i32 %44 to i8
%46 = sext i8 %45 to i32
%47 = icmp sgt i32 %46, 57
br i1 %47, label %48, label %49
48: ; preds = %43, %38
store i32 0, i32* %9
br label %52
49: ; preds = %43
%50 = load i32, i32* %6
%51 = sub nsw i32 %50, 48
store i32 %51, i32* %9
br label %52
52: ; preds = %49, %48
br label %53
53: ; preds = %52, %37
br label %54
54: ; preds = %53, %31
%55 = load i32, i32* %9
%56 = load [9 x [9 x i32]]*, [9 x [9 x i32]]** %4
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %56, i64 0, i64 %58
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [9 x i32], [9 x i32]* %59, i64 0, i64 %61
store i32 %55, i32* %62
%63 = load i32, i32* %9
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %75
65: ; preds = %54
%66 = load [9 x [9 x i32]]*, [9 x [9 x i32]]** %4
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %66, i64 0, i64 %68
%70 = load i32, i32* %8
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [9 x i32], [9 x i32]* %69, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = or i32 %73, 128
store i32 %74, i32* %72
br label %75
75: ; preds = %65, %54
br label %76
76: ; preds = %75
%77 = load i32, i32* %8
%78 = add nsw i32 %77, 1
store i32 %78, i32* %8
br label %16
79: ; preds = %16
br label %80
80: ; preds = %79, %85, %89
%81 = load i32*, i32** %5
%82 = call i32 @fgetc(i32* %81)
store i32 %82, i32* %6
%83 = load i32, i32* %6
%84 = icmp eq i32 %83, 13
br i1 %84, label %85, label %86
85: ; preds = %80
br label %80
86: ; preds = %80
%87 = load i32, i32* %6
%88 = icmp eq i32 %87, 10
br i1 %88, label %89, label %90
89: ; preds = %86
br label %80
90: ; preds = %86
%91 = load i32, i32* %6
%92 = load i32*, i32** %5
%93 = call i32 @ungetc(i32 %91, i32* %92)
br label %94
94: ; preds = %90
br label %95
95: ; preds = %94
%96 = load i32, i32* %7
%97 = add nsw i32 %96, 1
store i32 %97, i32* %7
br label %12
98: ; preds = %12
%99 = load i32*, i32** %5
%100 = call i32 @fclose(i32* %99)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define void @read_puzzle(i8* nocapture %0, [9 x [9 x i32]]* nocapture writeonly %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %2, %30
%5 = phi i64 [ 0, %2 ], [ %32, %30 ]
br label %6
6: ; preds = %4, %22
%7 = phi i64 [ 0, %4 ], [ %25, %22 ]
%8 = tail call i32 @fgetc(i32* %3)
%9 = shl i32 %8, 24
switch i32 %9, label %10 [
i32 771751936, label %14
i32 536870912, label %14
]
10: ; preds = %6
%11 = add i32 %9, -956301313
%12 = icmp ult i32 %11, -134217729
%13 = add nsw i32 %8, -48
br i1 %12, label %14, label %16
14: ; preds = %6, %6, %10
%15 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %5, i64 %7
br label %20
16: ; preds = %10
%17 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %5, i64 %7
%18 = icmp eq i32 %13, 0
%19 = or i32 %13, 128
br i1 %18, label %20, label %22
20: ; preds = %14, %16
%21 = phi i32* [ %15, %14 ], [ %17, %16 ]
br label %22
22: ; preds = %16, %20
%23 = phi i32* [ %21, %20 ], [ %17, %16 ]
%24 = phi i32 [ 0, %20 ], [ %19, %16 ]
store i32 %24, i32* %23
%25 = add nuw nsw i64 %7, 1
%26 = icmp eq i64 %25, 9
br i1 %26, label %27, label %6
27: ; preds = %22, %29
%28 = tail call i32 @fgetc(i32* %3)
switch i32 %28, label %30 [
i32 13, label %29
i32 10, label %29
]
29: ; preds = %27, %27
br label %27
30: ; preds = %27
%31 = tail call i32 @ungetc(i32 %28, i32* %3)
%32 = add nuw nsw i64 %5, 1
%33 = icmp eq i64 %32, 9
br i1 %33, label %34, label %4
34: ; preds = %30
%35 = tail call i32 @fclose(i32* %3)
ret void
}