#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*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, long);
scalar_t__ solve(char **);
int main(int argc, char *argv[]) {
  FILE *file;
  char board[9][11];
  long sum = 0;
  int i;
  if ((file = fopen("sudoku.txt", "rb")) == NULL) {
    perror("cant open input file");
    return 1;
  }
  while (fgets(board[0], 11, file)) {
    for (i = 0; i < 9; ++i)
      fgets(board[i], 11, file);
    sum += solve(board);
  }
  printf("sum is %ld\n", sum);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x88(%rbp)
lea    0xe75(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bd <main+0x5d>
lea    0xe62(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1268 <main+0x108>
jmp    11c2 <main+0x62>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xb,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1245 <main+0xe5>
movl   $0x0,-0x8c(%rbp)
cmpl   $0x9,-0x8c(%rbp)
jge    1229 <main+0xc9>
movslq -0x8c(%rbp),%rax
lea    -0x80(%rbp),%rdi
imul   $0xb,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
mov    $0xb,%esi
call   1060 <fgets@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    11e8 <main+0x88>
lea    -0x80(%rbp),%rdi
call   1030 <solve@plt>
add    -0x88(%rbp),%rax
mov    %rax,-0x88(%rbp)
jmp    11c2 <main+0x62>
mov    -0x88(%rbp),%rsi
lea    0xdd0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe8b(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12ab <main+0x14b>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0xb,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1280 <main+0x120>
lea    0x42(%rsp),%r12
lea    0x4d(%rsp),%rbp
lea    0x58(%rsp),%r14
xor    %r13d,%r13d
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0xb(%rsp),%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0x16(%rsp),%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0x21(%rsp),%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0x2c(%rsp),%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0x37(%rsp),%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r12,%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
call   1030 <solve@plt>
add    %rax,%r13
mov    %r15,%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11c0 <main+0x60>
jmp    1283 <main+0x123>
xor    %r13d,%r13d
lea    0xd99(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd5c(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    129c <main+0x13c>

LLVM IR (-O0):
@.str = [11 x i8] c"sudoku.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [21 x i8] c"cant open input file\00"
@.str.3 = [12 x i8] c"sum is %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [9 x [11 x i8]]
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%10 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %6
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %46
14: ; preds = %2
br label %15
15: ; preds = %35, %14
%16 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %7, i64 0, i64 0
%17 = getelementptr inbounds [11 x i8], [11 x i8]* %16, i64 0, i64 0
%18 = load i32*, i32** %6
%19 = call i64 @fgets(i8* %17, i32 11, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %41
21: ; preds = %15
store i32 0, i32* %9
br label %22
22: ; preds = %32, %21
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 9
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %7, i64 0, i64 %27
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %28, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = call i64 @fgets(i8* %29, i32 11, i32* %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %22
35: ; preds = %22
%36 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %7, i64 0, i64 0
%37 = bitcast [11 x i8]* %36 to i8**
%38 = call i64 @solve(i8** %37)
%39 = load i64, i64* %8
%40 = add nsw i64 %39, %38
store i64 %40, i64* %8
br label %15
41: ; preds = %15
%42 = load i64, i64* %8
%43 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 %42)
%44 = load i32*, i32** %6
%45 = call i32 @fclose(i32* %44)
store i32 0, i32* %3
br label %46
46: ; preds = %41, %12
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [11 x i8] c"sudoku.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [21 x i8] c"cant open input file\00"
@.str.3 = [12 x i8] c"sum is %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [9 x [11 x i8]]
%4 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %20, label %7
7: ; preds = %2
%8 = call i64 @fgets(i8* %4, i32 11, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %37, label %10
10: ; preds = %7
%11 = bitcast [9 x [11 x i8]]* %3 to i8**
%12 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 1, i64 0
%13 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 2, i64 0
%14 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 3, i64 0
%15 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 4, i64 0
%16 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 5, i64 0
%17 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 6, i64 0
%18 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 7, i64 0
%19 = getelementptr inbounds [9 x [11 x i8]], [9 x [11 x i8]]* %3, i64 0, i64 8, i64 0
br label %22
20: ; preds = %2
%21 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %41
22: ; preds = %10, %22
%23 = phi i64 [ 0, %10 ], [ %34, %22 ]
%24 = call i64 @fgets(i8* %4, i32 11, i32* %5)
%25 = call i64 @fgets(i8* %12, i32 11, i32* %5)
%26 = call i64 @fgets(i8* %13, i32 11, i32* %5)
%27 = call i64 @fgets(i8* %14, i32 11, i32* %5)
%28 = call i64 @fgets(i8* %15, i32 11, i32* %5)
%29 = call i64 @fgets(i8* %16, i32 11, i32* %5)
%30 = call i64 @fgets(i8* %17, i32 11, i32* %5)
%31 = call i64 @fgets(i8* %18, i32 11, i32* %5)
%32 = call i64 @fgets(i8* %19, i32 11, i32* %5)
%33 = call i64 @solve(i8** %11)
%34 = add nsw i64 %33, %23
%35 = call i64 @fgets(i8* %4, i32 11, i32* %5)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %22
37: ; preds = %22, %7
%38 = phi i64 [ 0, %7 ], [ %34, %22 ]
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 %38)
%40 = call i32 @fclose(i32* %5)
br label %41
41: ; preds = %37, %20
%42 = phi i32 [ 1, %20 ], [ 0, %37 ]
ret i32 %42
}