#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_matrix(char *, int, int **);
int main(int argc, char **argv) {
  FILE *fp1;
  int ch1, size = 0;
  fp1 = fopen("binary_sudoku_puzzle.txt", "r");
  if (fp1 == NULL) {
    printf("Cannot open binary_sudoku_puzzle.txt for reading\n");
    return (1);
  } else {
    ch1 = getc(fp1);
    while ((ch1 != EOF) && (ch1 != '\n')) {
      ch1 = getc(fp1);
      size++;
    }
    fclose(fp1);
    int matrix[size][size];
    read_matrix("binary_sudoku_puzzle.txt", size, matrix);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe8c(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a7 <main+0x57>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x107>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
mov    0x2e29(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x39(%rbp)
je     11d4 <main+0x84>
cmpl   $0xa,-0x1c(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11e4 <main+0x94>
jmp    11fe <main+0xae>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b3 <main+0x63>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rsp,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,%rsp
mov    %rcx,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%esi
lea    0xdbc(%rip),%rdi
call   1050 <read_matrix@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe9e(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ef <main+0x9f>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <getc@plt>
xor    %r14d,%r14d
mov    $0x0,%ebx
cmp    $0xa,%eax
je     11b6 <main+0x66>
mov    0x2e56(%rip),%r12
mov    $0x0,%ebx
cmp    (%r12),%eax
je     11b6 <main+0x66>
xor    %ebx,%ebx
nop
mov    %r15,%rdi
call   1070 <getc@plt>
add    $0x1,%ebx
cmp    $0xa,%eax
je     11b6 <main+0x66>
cmp    (%r12),%eax
jne    11a0 <main+0x50>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rsp,%r15
mov    %ebx,%eax
imul   %rax,%rax
mov    %rsp,%rdx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
lea    0xe1d(%rip),%rdi
mov    %ebx,%esi
call   1050 <read_matrix@plt>
mov    %r15,%rsp
jmp    1201 <main+0xb1>
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"binary_sudoku_puzzle.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [50 x i8] c"Cannot open binary_sudoku_puzzle.txt for reading\0A\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%12 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %49
17: ; preds = %2
%18 = load i32*, i32** %6
%19 = call i32 @getc(i32* %18)
store i32 %19, i32* %7
br label %20
20: ; preds = %29, %17
%21 = load i32, i32* %7
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 10
br label %27
27: ; preds = %24, %20
%28 = phi i1 [ false, %20 ], [ %26, %24 ]
br i1 %28, label %29, label %34
29: ; preds = %27
%30 = load i32*, i32** %6
%31 = call i32 @getc(i32* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %20
34: ; preds = %27
%35 = load i32*, i32** %6
%36 = call i32 @fclose(i32* %35)
%37 = load i32, i32* %8
%38 = zext i32 %37 to i64
%39 = load i32, i32* %8
%40 = zext i32 %39 to i64
%41 = call i8* @llvm.stacksave()
store i8* %41, i8** %9
%42 = mul nuw i64 %38, %40
%43 = alloca i32, i64 %42
store i64 %38, i64* %10
store i64 %40, i64* %11
%44 = load i32, i32* %8
%45 = bitcast i32* %43 to i32**
%46 = call i32 @read_matrix(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %44, i32** %45)
%47 = load i8*, i8** %9
br label %48
48: ; preds = %34
store i32 0, i32* %3
br label %49
49: ; preds = %48, %15
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [25 x i8] c"binary_sudoku_puzzle.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@str = [49 x i8] c"Cannot open binary_sudoku_puzzle.txt for reading\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
br label %30
7: ; preds = %2
%8 = tail call i32 @getc(i32* %3)
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
%11 = icmp ne i32 %8, 10
%12 = and i1 %11, %10
br i1 %12, label %13, label %21
13: ; preds = %7, %13
%14 = phi i32 [ %16, %13 ], [ 0, %7 ]
%15 = tail call i32 @getc(i32* %3)
%16 = add nuw nsw i32 %14, 1
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %15, %17
%19 = icmp ne i32 %15, 10
%20 = and i1 %19, %18
br i1 %20, label %13, label %21
21: ; preds = %13, %7
%22 = phi i32 [ 0, %7 ], [ %16, %13 ]
%23 = tail call i32 @fclose(i32* %3)
%24 = zext i32 %22 to i64
%25 = tail call i8* @llvm.stacksave()
%26 = mul nuw nsw i64 %24, %24
%27 = alloca i32, i64 %26
%28 = bitcast i32* %27 to i32**
%29 = call i32 @read_matrix(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %22, i32** %28)
br label %30
30: ; preds = %21, %5
%31 = phi i32 [ 1, %5 ], [ 0, %21 ]
ret i32 %31
}