#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 findEmptyIndex(int *);
scalar_t__ isPossible(int *, int, int);
int solveWithBacktracking(int *grid) {
  int index = findEmptyIndex(grid);
  int i;
  if (index == -1) {
    return 1;
  }
  for (i = 1; i <= 9; i++) {
    if (isPossible(grid, index, i)) {
      grid[index] = i;
      if (solveWithBacktracking(grid)) {
        return 1;
      }
      grid[index] = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<solveWithBacktracking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <findEmptyIndex@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    115e <solveWithBacktracking+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    11dd <solveWithBacktracking+0xad>
movl   $0x1,-0x18(%rbp)
cmpl   $0x9,-0x18(%rbp)
jg     11d6 <solveWithBacktracking+0xa6>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <isPossible@plt>
cmp    $0x0,%rax
je     11c3 <solveWithBacktracking+0x93>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
call   1030 <solveWithBacktracking@plt>
cmp    $0x0,%eax
je     11b4 <solveWithBacktracking+0x84>
movl   $0x1,-0x4(%rbp)
jmp    11dd <solveWithBacktracking+0xad>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11c8 <solveWithBacktracking+0x98>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <solveWithBacktracking+0x35>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveWithBacktracking>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <findEmptyIndex@plt>
cmp    $0xffffffff,%eax
je     1320 <solveWithBacktracking+0x1f0>
mov    %eax,%ebp
movslq %eax,%r15
mov    $0x1,%r14d
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     1187 <solveWithBacktracking+0x57>
movl   $0x1,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     11bb <solveWithBacktracking+0x8b>
movl   $0x2,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     11ef <solveWithBacktracking+0xbf>
movl   $0x3,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     1223 <solveWithBacktracking+0xf3>
movl   $0x4,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x5,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     1257 <solveWithBacktracking+0x127>
movl   $0x5,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x6,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     128b <solveWithBacktracking+0x15b>
movl   $0x6,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x7,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     12bb <solveWithBacktracking+0x18b>
movl   $0x7,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x8,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     12eb <solveWithBacktracking+0x1bb>
movl   $0x8,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x9,%edx
call   1040 <isPossible@plt>
test   %rax,%rax
je     131b <solveWithBacktracking+0x1eb>
movl   $0x9,(%rbx,%r15,4)
mov    %rbx,%rdi
call   1030 <solveWithBacktracking@plt>
test   %eax,%eax
jne    1326 <solveWithBacktracking+0x1f6>
movl   $0x0,(%rbx,%r15,4)
xor    %r14d,%r14d
jmp    1326 <solveWithBacktracking+0x1f6>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @solveWithBacktracking(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @findEmptyIndex(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %41
11: ; preds = %1
store i32 1, i32* %5
br label %12
12: ; preds = %37, %11
%13 = load i32, i32* %5
%14 = icmp sle i32 %13, 9
br i1 %14, label %15, label %40
15: ; preds = %12
%16 = load i32*, i32** %3
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i64 @isPossible(i32* %16, i32 %17, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %36
21: ; preds = %15
%22 = load i32, i32* %5
%23 = load i32*, i32** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
%27 = load i32*, i32** %3
%28 = call i32 @solveWithBacktracking(i32* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %21
store i32 1, i32* %2
br label %41
31: ; preds = %21
%32 = load i32*, i32** %3
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 0, i32* %35
br label %36
36: ; preds = %31, %15
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %12
40: ; preds = %12
store i32 0, i32* %2
br label %41
41: ; preds = %40, %30, %10
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
define i32 @solveWithBacktracking(i32* %0) {
%2 = tail call i32 @findEmptyIndex(i32* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %69, label %4
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = tail call i64 @isPossible(i32* %0, i32 %2, i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
store i32 1, i32* %6
%10 = tail call i32 @solveWithBacktracking(i32* %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %69
12: ; preds = %9
store i32 0, i32* %6
br label %13
13: ; preds = %4, %12
%14 = tail call i64 @isPossible(i32* %0, i32 %2, i32 2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
store i32 2, i32* %6
%17 = tail call i32 @solveWithBacktracking(i32* %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %69
19: ; preds = %16
store i32 0, i32* %6
br label %20
20: ; preds = %19, %13
%21 = tail call i64 @isPossible(i32* %0, i32 %2, i32 3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
store i32 3, i32* %6
%24 = tail call i32 @solveWithBacktracking(i32* %0)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %69
26: ; preds = %23
store i32 0, i32* %6
br label %27
27: ; preds = %26, %20
%28 = tail call i64 @isPossible(i32* %0, i32 %2, i32 4)
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
store i32 4, i32* %6
%31 = tail call i32 @solveWithBacktracking(i32* %0)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %69
33: ; preds = %30
store i32 0, i32* %6
br label %34
34: ; preds = %33, %27
%35 = tail call i64 @isPossible(i32* %0, i32 %2, i32 5)
%36 = icmp eq i64 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %34
store i32 5, i32* %6
%38 = tail call i32 @solveWithBacktracking(i32* %0)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %69
40: ; preds = %37
store i32 0, i32* %6
br label %41
41: ; preds = %40, %34
%42 = tail call i64 @isPossible(i32* %0, i32 %2, i32 6)
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
store i32 6, i32* %6
%45 = tail call i32 @solveWithBacktracking(i32* %0)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %69
47: ; preds = %44
store i32 0, i32* %6
br label %48
48: ; preds = %47, %41
%49 = tail call i64 @isPossible(i32* %0, i32 %2, i32 7)
%50 = icmp eq i64 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %48
store i32 7, i32* %6
%52 = tail call i32 @solveWithBacktracking(i32* %0)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %69
54: ; preds = %51
store i32 0, i32* %6
br label %55
55: ; preds = %54, %48
%56 = tail call i64 @isPossible(i32* %0, i32 %2, i32 8)
%57 = icmp eq i64 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %55
store i32 8, i32* %6
%59 = tail call i32 @solveWithBacktracking(i32* %0)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %69
61: ; preds = %58
store i32 0, i32* %6
br label %62
62: ; preds = %61, %55
%63 = tail call i64 @isPossible(i32* %0, i32 %2, i32 9)
%64 = icmp eq i64 %63, 0
br i1 %64, label %69, label %65
65: ; preds = %62
store i32 9, i32* %6
%66 = tail call i32 @solveWithBacktracking(i32* %0)
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %65
store i32 0, i32* %6
br label %69
69: ; preds = %9, %16, %23, %30, %37, %44, %51, %58, %65, %68, %62, %1
%70 = phi i32 [ 1, %1 ], [ 1, %9 ], [ 1, %16 ], [ 1, %23 ], [ 1, %30 ], [ 1, %37 ], [ 1, %44 ], [ 1, %51 ], [ 1, %58 ], [ 1, %65 ], [ 0, %68 ], [ 0, %62 ]
ret i32 %70
}