#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 */
scalar_t__ fillSudoku(int **, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  int puzzle[9][9] = {{0, 0, 0, 0, 0, 0, 0, 9, 0}, {1, 9, 0, 4, 7, 0, 6, 0, 8},
                      {0, 5, 2, 8, 1, 9, 4, 0, 7}, {2, 0, 0, 0, 4, 8, 0, 0, 0},
                      {0, 0, 9, 0, 0, 0, 5, 0, 0}, {0, 0, 0, 7, 5, 0, 0, 0, 9},
                      {9, 0, 7, 3, 6, 4, 1, 8, 0}, {5, 0, 6, 0, 8, 1, 0, 7, 4},
                      {0, 8, 0, 0, 0, 0, 0, 0, 0}};
  if (fillSudoku(puzzle, 0, 0)) {
    printf("\n+-----+-----+-----+\n");
    for (i = 1; i < 10; ++i) {
      for (j = 1; j < 10; ++j)
        printf("|%d", puzzle[i - 1][j - 1]);
      printf("|\n");
      if (i % 3 == 0)
        printf("+-----+-----+-----+\n");
    }
  } else
    printf("\n\nNO SOLUTION\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x150(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x144,%edx
call   1040 <memcpy@plt>
lea    -0x150(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <fillSudoku@plt>
cmp    $0x0,%rax
je     122b <main+0xfb>
lea    0xfc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1226 <main+0xf6>
movl   $0x1,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11e3 <main+0xb3>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x150(%rbp),%rax
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xf8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119a <main+0x6a>
lea    0xf74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1213 <main+0xe3>
lea    0xf39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <main+0xe8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1189 <main+0x59>
jmp    1239 <main+0x109>
lea    0xf2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
lea    0xea8(%rip),%rsi
mov    %rsp,%rbx
mov    $0x144,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <fillSudoku@plt>
test   %rax,%rax
je     127a <main+0x13a>
lea    0xfd3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r13d
mov    $0x1,%ebx
mov    $0x20,%ebp
lea    0xfa4(%rip),%r12
lea    0xfc5(%rip),%r14
jmp    11c8 <main+0x88>
nopl   0x0(%rax)
add    $0xffffffff,%r13d
add    $0x1,%ebx
add    $0x24,%rbp
cmp    $0x164,%rbp
je     1286 <main+0x146>
mov    %ebx,%eax
mov    $0xaaaaaaab,%ecx
imul   %rcx,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%r15d
mov    -0x20(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x1c(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x18(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x14(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x10(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0xc(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x8(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x4(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
add    %r13d,%r15d
jne    11b0 <main+0x70>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
jmp    11b0 <main+0x70>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.puzzle = [9 x [9 x i32]] [[9 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 9, i32 0], [9 x i32] [i32 1, i32 9, i32 0, i32 4, i32 7, i32 0, i32 6, i32 0, i32 8], [9 x i32] [i32 0, i32 5, i32 2, i32 8, i32 1, i32 9, i32 4, i32 0, i32 7], [9 x i32] [i32 2, i32 0, i32 0, i32 0, i32 4, i32 8, i32 0, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 9, i32 0, i32 0, i32 0, i32 5, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 0, i32 7, i32 5, i32 0, i32 0, i32 0, i32 9], [9 x i32] [i32 9, i32 0, i32 7, i32 3, i32 6, i32 4, i32 1, i32 8, i32 0], [9 x i32] [i32 5, i32 0, i32 6, i32 0, i32 8, i32 1, i32 0, i32 7, i32 4], [9 x i32] [i32 0, i32 8, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]]
@.str = [22 x i8] c"\0A+-----+-----+-----+\0A\00"
@.str.1 = [4 x i8] c"|%d\00"
@.str.2 = [3 x i8] c"|\0A\00"
@.str.3 = [21 x i8] c"+-----+-----+-----+\0A\00"
@.str.4 = [16 x i8] c"\0A\0ANO SOLUTION\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x [9 x i32]]
store i32 0, i32* %1
%5 = bitcast [9 x [9 x i32]]* %4 to i8*
%6 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %4, i64 0, i64 0
%7 = bitcast [9 x i32]* %6 to i32**
%8 = call i64 @fillSudoku(i32** %7, i32 0, i32 0)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %45
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %12
12: ; preds = %41, %10
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %44
15: ; preds = %12
store i32 1, i32* %3
br label %16
16: ; preds = %30, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = load i32, i32* %2
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %4, i64 0, i64 %22
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [9 x i32], [9 x i32]* %23, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %19
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %16
33: ; preds = %16
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* %2
%36 = srem i32 %35, 3
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %33
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %12
44: ; preds = %12
br label %47
45: ; preds = %0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %44
ret i32 0
}

LLVM IR (-O2):
@__const.main.puzzle = [9 x [9 x i32]] [[9 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 9, i32 0], [9 x i32] [i32 1, i32 9, i32 0, i32 4, i32 7, i32 0, i32 6, i32 0, i32 8], [9 x i32] [i32 0, i32 5, i32 2, i32 8, i32 1, i32 9, i32 4, i32 0, i32 7], [9 x i32] [i32 2, i32 0, i32 0, i32 0, i32 4, i32 8, i32 0, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 9, i32 0, i32 0, i32 0, i32 5, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 0, i32 7, i32 5, i32 0, i32 0, i32 0, i32 9], [9 x i32] [i32 9, i32 0, i32 7, i32 3, i32 6, i32 4, i32 1, i32 8, i32 0], [9 x i32] [i32 5, i32 0, i32 6, i32 0, i32 8, i32 1, i32 0, i32 7, i32 4], [9 x i32] [i32 0, i32 8, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]]
@.str.1 = [4 x i8] c"|%d\00"
@str = [15 x i8] c"\0A\0ANO SOLUTION\0A\00"
@str.5 = [21 x i8] c"\0A+-----+-----+-----+\00"
@str.6 = [2 x i8] c"|\00"
@str.7 = [20 x i8] c"+-----+-----+-----+\00"
define i32 @main() {
%1 = alloca [9 x [9 x i32]]
%2 = bitcast [9 x [9 x i32]]* %1 to i8*
%3 = bitcast [9 x [9 x i32]]* %1 to i32**
%4 = call i64 @fillSudoku(i32** %3, i32 0, i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %47, label %6
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %8
8: ; preds = %6, %44
%9 = phi i64 [ 1, %6 ], [ %45, %44 ]
%10 = add nsw i64 %9, -1
%11 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 0
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 1
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 2
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 3
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 4
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 5
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 6
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 7
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %1, i64 0, i64 %10, i64 8
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%39 = trunc i64 %9 to i32
%40 = urem i32 %39, 3
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %8
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
br label %44
44: ; preds = %8, %42
%45 = add nuw nsw i64 %9, 1
%46 = icmp eq i64 %45, 10
br i1 %46, label %49, label %8
47: ; preds = %0
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %44, %47
ret i32 0
}