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

/* Variables and functions */
int atoi(char *);
char *checkSudoku(int *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  char *str;
  int lineNum = 0;
  int index;
  int *array;
  int arrayIndex;
  int square;
  if (argc < 2) {
    printf("Argument not present\n");
    exit(1);
  }
  fp = fopen(argv[1], "r");
  if (NULL == fp) {
    printf("File not present\n");
    exit(1);
  }
  while ((read = getline(&line, &len, fp)) != -1) {
    if (lineNum != 0) {
      printf("\n");
    }
    lineNum++;
    index = 0;
    str = strtok(line, ";");
    if (!str) {
      continue;
    }
    square = atoi(str);
    array = (int *)malloc(square * square * sizeof(int));
    if (array == NULL) {
      printf("malloc failed\n");
      exit(1);
    }
    arrayIndex = 0;
    str = strtok(NULL, ",");
    while (str) {
      array[arrayIndex++] = atoi(str);
      str = strtok(NULL, ",");
    }
    printf("%s", checkSudoku(array, square));
    free(array);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ef <main+0x4f>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe18(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    122b <main+0x8b>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1230 <main+0x90>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10b0 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     136a <main+0x1ca>
cmpl   $0x0,-0x3c(%rbp)
je     1265 <main+0xc5>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1299 <main+0xf9>
jmp    1230 <main+0x90>
mov    -0x38(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
imul   -0x50(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12e0 <main+0x140>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x4c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd49(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     133f <main+0x19f>
mov    -0x38(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edx
mov    -0x48(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x4c(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd0a(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x38(%rbp)
jmp    12fb <main+0x15b>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%esi
call   1050 <checkSudoku@plt>
mov    %rax,%rsi
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    1230 <main+0x90>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
cmp    $0x1,%edi
jle    1322 <main+0x162>
mov    0x8(%rsi),%rdi
lea    0xe0c(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     132b <main+0x16b>
mov    %rax,%r13
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   10d0 <getline@plt>
cmp    $0xffffffff,%eax
je     12f3 <main+0x133>
lea    0xddd(%rip),%rbx
xor    %r15d,%r15d
jmp    1273 <main+0xb3>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <checkSudoku@plt>
lea    0xdc4(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x1,%r15d
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r13,%rdx
call   10d0 <getline@plt>
cmp    $0xffffffff,%eax
je     12f3 <main+0x133>
test   %r15d,%r15d
je     1282 <main+0xc2>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x8(%rsp),%rdi
lea    0xd74(%rip),%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     1254 <main+0x94>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%edi
imul   %eax,%edi
shl    $0x2,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     130c <main+0x14c>
mov    %rax,%r12
xor    %edi,%edi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     1230 <main+0x70>
mov    %r12,%rbp
xchg   %ax,%ax
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,0x0(%rbp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
add    $0x4,%rbp
test   %rax,%rax
jne    12d0 <main+0x110>
jmp    1230 <main+0x70>
mov    %r13,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf6(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xcff(%rip),%rdi
jmp    1313 <main+0x153>
lea    0xce5(%rip),%rdi
jmp    1313 <main+0x153>

LLVM IR (-O0):
@.str = [22 x i8] c"Argument not present\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"File not present\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [2 x i8] c";\00"
@.str.5 = [15 x i8] c"malloc failed\0A\00"
@.str.6 = [2 x i8] c",\00"
@.str.7 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i64 0, i64* %8
store i32 0, i32* %11
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp eq i32* null, %26
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %21
br label %32
32: ; preds = %79, %48, %31
%33 = load i32*, i32** %6
%34 = call i32 @getline(i8** %7, i64* %8, i32* %33)
store i32 %34, i32* %9
%35 = icmp ne i32 %34, -1
br i1 %35, label %36, label %86
36: ; preds = %32
%37 = load i32, i32* %11
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
store i32 0, i32* %12
%44 = load i8*, i8** %7
%45 = call i8* @strtok(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %45, i8** %10
%46 = load i8*, i8** %10
%47 = icmp ne i8* %46, null
br i1 %47, label %49, label %48
48: ; preds = %41
br label %32
49: ; preds = %41
%50 = load i8*, i8** %10
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %15
%52 = load i32, i32* %15
%53 = load i32, i32* %15
%54 = mul nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = mul i64 %55, 4
%57 = trunc i64 %56 to i32
%58 = call i64 @malloc(i32 %57)
%59 = inttoptr i64 %58 to i32*
store i32* %59, i32** %13
%60 = load i32*, i32** %13
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %65
62: ; preds = %49
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %49
store i32 0, i32* %14
%66 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %66, i8** %10
br label %67
67: ; preds = %70, %65
%68 = load i8*, i8** %10
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %79
70: ; preds = %67
%71 = load i8*, i8** %10
%72 = call i32 @atoi(i8* %71)
%73 = load i32*, i32** %13
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
store i32 %75, i32* %14
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i32, i32* %73, i64 %76
store i32 %72, i32* %77
%78 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %78, i8** %10
br label %67
79: ; preds = %67
%80 = load i32*, i32** %13
%81 = load i32, i32* %15
%82 = call i8* @checkSudoku(i32* %80, i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %82)
%84 = load i32*, i32** %13
%85 = call i32 @free(i32* %84)
br label %32
86: ; preds = %32
%87 = load i32*, i32** %6
%88 = call i32 @fclose(i32* %87)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c";\00"
@.str.6 = [2 x i8] c",\00"
@.str.7 = [3 x i8] c"%s\00"
@str = [14 x i8] c"malloc failed\00"
@str.8 = [17 x i8] c"File not present\00"
@str.9 = [21 x i8] c"Argument not present\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32 @getline(i8** %3, i64* %4, i32* %14)
%18 = icmp eq i32 %17, -1
br i1 %18, label %60, label %22
19: ; preds = %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %16, %57
%23 = phi i32 [ %28, %57 ], [ 0, %16 ]
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 @putchar(i32 10)
br label %27
27: ; preds = %25, %22
%28 = add nuw nsw i32 %23, 1
%29 = load i8*, i8** %3
%30 = call i8* @strtok(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %57, label %32
32: ; preds = %27
%33 = call i32 @atoi(i8* %30)
%34 = shl i32 %33, 2
%35 = mul i32 %34, %33
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i32*
%38 = icmp eq i64 %36, 0
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %32
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %53, label %45
45: ; preds = %42, %45
%46 = phi i64 [ %49, %45 ], [ 0, %42 ]
%47 = phi i8* [ %51, %45 ], [ %43, %42 ]
%48 = call i32 @atoi(i8* %47)
%49 = add nuw i64 %46, 1
%50 = getelementptr inbounds i32, i32* %37, i64 %46
store i32 %48, i32* %50
%51 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %45
53: ; preds = %45, %42
%54 = call i8* @checkSudoku(i32* %37, i32 %33)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %54)
%56 = call i32 @free(i32* %37)
br label %57
57: ; preds = %53, %27
%58 = call i32 @getline(i8** %3, i64* %4, i32* %14)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %22
60: ; preds = %57, %16
%61 = call i32 @fclose(i32* %14)
ret i32 0
}