#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int file_2_sudoku(int *sudoku, char *filename) {
  FILE *fp;
  int c;
  int i;
  int error;
  error = 0;
  i = 0;
  fp = fopen(filename, "r");
  if (fp == 0)
    return 1;
  while ((c != EOF)) {
    c = fgetc(fp);
    if ((((c - 48) < 0) || ((c - 48) > 9)) && (c != EOF))
      error = 1;
    *sudoku++ = (c - 48);
    i++;
  }
  if ((i != 82) || (error = 1))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<file_2_sudoku>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1169 <file_2_sudoku+0x49>
movl   $0x1,-0x4(%rbp)
jmp    121b <file_2_sudoku+0xfb>
jmp    116e <file_2_sudoku+0x4e>
mov    -0x24(%rbp),%eax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%eax
je     11e8 <file_2_sudoku+0xc8>
mov    -0x20(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x30,%eax
cmp    $0x0,%eax
jl     11aa <file_2_sudoku+0x8a>
mov    -0x24(%rbp),%eax
sub    $0x30,%eax
cmp    $0x9,%eax
jle    11c3 <file_2_sudoku+0xa3>
mov    -0x24(%rbp),%eax
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%eax
je     11c3 <file_2_sudoku+0xa3>
movl   $0x1,-0x2c(%rbp)
mov    -0x24(%rbp),%ecx
sub    $0x30,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116e <file_2_sudoku+0x4e>
cmpl   $0x52,-0x28(%rbp)
jne    1208 <file_2_sudoku+0xe8>
movl   $0x1,-0x2c(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1208 <file_2_sudoku+0xe8>
jmp    1214 <file_2_sudoku+0xf4>
movl   $0x1,-0x4(%rbp)
jmp    121b <file_2_sudoku+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_2_sudoku>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xece(%rip),%rsi
mov    %rax,%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     1166 <file_2_sudoku+0x46>
mov    %rax,%r14
mov    0x2e9f(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <fgetc@plt>
lea    -0x30(%rax),%ecx
mov    %ecx,(%rbx)
add    $0x4,%rbx
cmp    (%r15),%eax
jne    1150 <file_2_sudoku+0x30>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define i32 @file_2_sudoku(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 0, i32* %9
store i32 0, i32* %8
%10 = load i8*, i8** %5
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %48
15: ; preds = %2
br label %16
16: ; preds = %35, %15
%17 = load i32, i32* %7
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %42
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = call i32 @fgetc(i32* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = sub nsw i32 %23, 48
%25 = icmp slt i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %20
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 48
%29 = icmp sgt i32 %28, 9
br i1 %29, label %30, label %35
30: ; preds = %26, %20
%31 = load i32, i32* %7
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %9
br label %35
35: ; preds = %34, %30, %26
%36 = load i32, i32* %7
%37 = sub nsw i32 %36, 48
%38 = load i32*, i32** %4
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %4
store i32 %37, i32* %38
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %16
42: ; preds = %16
%43 = load i32, i32* %8
%44 = icmp ne i32 %43, 82
br i1 %44, label %46, label %45
45: ; preds = %42
store i32 1, i32* %9
br i1 true, label %46, label %47
46: ; preds = %45, %42
store i32 1, i32* %3
br label %48
47: ; preds = %45
store i32 0, i32* %3
br label %48
48: ; preds = %47, %46, %14
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define i32 @file_2_sudoku(i32* nocapture writeonly %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %12, label %5
5: ; preds = %2, %5
%6 = phi i32* [ %9, %5 ], [ %0, %2 ]
%7 = tail call i32 @fgetc(i32* %3)
%8 = add nsw i32 %7, -48
%9 = getelementptr inbounds i32, i32* %6, i64 1
store i32 %8, i32* %6
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %7, %10
br i1 %11, label %12, label %5
12: ; preds = %5, %2
ret i32 1
}