#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 */

/* Variables and functions */
int /*<<< orphan*/ check_grid(int **);
int count_missing(int **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fill_grid(int **, int /*<<< orphan*/);
int /*<<< orphan*/ ft_printf(char *, ...);
int /*<<< orphan*/ grid_clear(int **);
int /*<<< orphan*/ load_line(int **, char *);
int /*<<< orphan*/ show_grid(int **);
int main(int argc, char *argv[]) {
  int missing;
  int sudoku[9][9];
  if (argc > 1) {
    ft_printf("loading user grid\n");
    grid_clear(sudoku);
    load_line(sudoku, argv[1]);
    if (!check_grid(sudoku)) {
      show_grid(sudoku);
      ft_printf("invalid user grid\n");
      exit(0);
    }
  } else {
    ft_printf("loading default grid\n");
    load_line(sudoku, "78036000000601090200340260780950420106090107010720680550"
                      "8603700304090500000025048");
  }
  show_grid(sudoku);
  missing = count_missing(sudoku);
  ft_printf("missing: %i\n", missing);
  fill_grid(sudoku, 0);
  show_grid(sudoku);
  missing = count_missing(sudoku);
  ft_printf("missing: %i\n", missing);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    120c <main+0x8c>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1070 <ft_printf@plt>
lea    -0x160(%rbp),%rdi
call   1030 <grid_clear@plt>
lea    -0x160(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   10a0 <load_line@plt>
lea    -0x160(%rbp),%rdi
call   1040 <check_grid@plt>
cmp    $0x0,%eax
jne    1207 <main+0x87>
lea    -0x160(%rbp),%rdi
call   1080 <show_grid@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1070 <ft_printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    122d <main+0xad>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1070 <ft_printf@plt>
lea    -0x160(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   10a0 <load_line@plt>
lea    -0x160(%rbp),%rdi
call   1080 <show_grid@plt>
lea    -0x160(%rbp),%rdi
call   1060 <count_missing@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1070 <ft_printf@plt>
lea    -0x160(%rbp),%rdi
xor    %esi,%esi
call   1050 <fill_grid@plt>
lea    -0x160(%rbp),%rdi
call   1080 <show_grid@plt>
lea    -0x160(%rbp),%rdi
call   1060 <count_missing@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1070 <ft_printf@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x148,%rsp
cmp    $0x2,%edi
jl     11e0 <main+0x60>
mov    %rsi,%rbx
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1070 <ft_printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <grid_clear@plt>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   10a0 <load_line@plt>
mov    %r14,%rdi
call   1040 <check_grid@plt>
test   %eax,%eax
jne    11fd <main+0x7d>
mov    %rsp,%rdi
call   1080 <show_grid@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1070 <ft_printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1070 <ft_printf@plt>
lea    0xe47(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <load_line@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <show_grid@plt>
mov    %rbx,%rdi
call   1060 <count_missing@plt>
lea    0xe77(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <ft_printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <fill_grid@plt>
mov    %rbx,%rdi
call   1080 <show_grid@plt>
mov    %rbx,%rdi
call   1060 <count_missing@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <ft_printf@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"loading user grid\0A\00"
@.str.1 = [19 x i8] c"invalid user grid\0A\00"
@.str.2 = [22 x i8] c"loading default grid\0A\00"
@.str.3 = [82 x i8] c"780360000006010902003402607809504201060901070107206805508603700304090500000025048\00"
@.str.4 = [13 x i8] c"missing: %i\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 [9 x i32]]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %32
10: ; preds = %2
%11 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%13 = bitcast [9 x i32]* %12 to i32**
%14 = call i32 @grid_clear(i32** %13)
%15 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%16 = bitcast [9 x i32]* %15 to i32**
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @load_line(i32** %16, i8* %19)
%21 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%22 = bitcast [9 x i32]* %21 to i32**
%23 = call i32 @check_grid(i32** %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %10
%26 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%27 = bitcast [9 x i32]* %26 to i32**
%28 = call i32 @show_grid(i32** %27)
%29 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %10
br label %37
32: ; preds = %2
%33 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%34 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%35 = bitcast [9 x i32]* %34 to i32**
%36 = call i32 @load_line(i32** %35, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %32, %31
%38 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%39 = bitcast [9 x i32]* %38 to i32**
%40 = call i32 @show_grid(i32** %39)
%41 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%42 = bitcast [9 x i32]* %41 to i32**
%43 = call i32 @count_missing(i32** %42)
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%47 = bitcast [9 x i32]* %46 to i32**
%48 = call i32 @fill_grid(i32** %47, i32 0)
%49 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%50 = bitcast [9 x i32]* %49 to i32**
%51 = call i32 @show_grid(i32** %50)
%52 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%53 = bitcast [9 x i32]* %52 to i32**
%54 = call i32 @count_missing(i32** %53)
store i32 %54, i32* %6
%55 = load i32, i32* %6
%56 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"loading user grid\0A\00"
@.str.1 = [19 x i8] c"invalid user grid\0A\00"
@.str.2 = [22 x i8] c"loading default grid\0A\00"
@.str.3 = [82 x i8] c"780360000006010902003402607809504201060901070107206805508603700304090500000025048\00"
@.str.4 = [13 x i8] c"missing: %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [9 x [9 x i32]]
%4 = bitcast [9 x [9 x i32]]* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %19
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = bitcast [9 x [9 x i32]]* %3 to i32**
%9 = call i32 @grid_clear(i32** %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @load_line(i32** %8, i8* %11)
%13 = call i32 @check_grid(i32** %8)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %6
%16 = call i32 @show_grid(i32** %8)
%17 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %2
%20 = tail call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%21 = bitcast [9 x [9 x i32]]* %3 to i32**
%22 = call i32 @load_line(i32** %21, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %6, %19
%24 = bitcast [9 x [9 x i32]]* %3 to i32**
%25 = call i32 @show_grid(i32** %24)
%26 = call i32 @count_missing(i32** %24)
%27 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 @fill_grid(i32** %24, i32 0)
%29 = call i32 @show_grid(i32** %24)
%30 = call i32 @count_missing(i32** %24)
%31 = call i32 (i8*, ...) @ft_printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %30)
ret i32 0
}