#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__ check_solution(int *);
int convert_bitwise(long);
long poss_matches(int *, int);
int /*<<< orphan*/ printf(char *);
int recursive_iterate(int board[]) {
  for (int i = 0; i < 81; i++) {
    if (0 == board[i]) {
      long remaining_matches = poss_matches(board, i);
      if (!remaining_matches) {
        return 0;
      }
      while (remaining_matches) {
        int first_match = convert_bitwise(remaining_matches);
        remaining_matches = remaining_matches ^ (1 << (first_match - 1));
        board[i] = first_match;
        if (check_solution(board)) {
          printf("Board is solved!\n");
          return 99;
        } else {
          int solution = recursive_iterate(board);
          if (99 == solution) {
            return solution;
          }
          if (0 == solution) {
            board[i] = 0;
          }
        }
      }
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<recursive_iterate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x51,-0x14(%rbp)
jge    1281 <recursive_iterate+0x131>
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
xor    %eax,%eax
cmp    (%rcx,%rdx,4),%eax
jne    126e <recursive_iterate+0x11e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <poss_matches@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a7 <recursive_iterate+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1288 <recursive_iterate+0x138>
jmp    11ac <recursive_iterate+0x5c>
cmpq   $0x0,-0x20(%rbp)
je     1262 <recursive_iterate+0x112>
mov    -0x20(%rbp),%rdi
call   1050 <convert_bitwise@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
xor    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
call   1030 <check_solution@plt>
cmp    $0x0,%rax
je     1219 <recursive_iterate+0xc9>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
movl   $0x63,-0x4(%rbp)
jmp    1288 <recursive_iterate+0x138>
mov    -0x10(%rbp),%rdi
call   1070 <recursive_iterate@plt>
mov    %eax,-0x28(%rbp)
mov    $0x63,%eax
cmp    -0x28(%rbp),%eax
jne    123e <recursive_iterate+0xee>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1288 <recursive_iterate+0x138>
xor    %eax,%eax
cmp    -0x28(%rbp),%eax
jne    1258 <recursive_iterate+0x108>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    125d <recursive_iterate+0x10d>
jmp    11ac <recursive_iterate+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1288 <recursive_iterate+0x138>
jmp    1273 <recursive_iterate+0x123>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1163 <recursive_iterate+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursive_iterate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    $0x2,%ebx
cmpl   $0x0,-0x8(%r15,%rbx,4)
je     1189 <recursive_iterate+0x39>
cmpl   $0x0,-0x4(%r15,%rbx,4)
je     118f <recursive_iterate+0x3f>
cmpl   $0x0,(%r15,%rbx,4)
je     1193 <recursive_iterate+0x43>
add    $0x3,%rbx
cmp    $0x53,%rbx
jne    1160 <recursive_iterate+0x10>
xor    %r14d,%r14d
jmp    120b <recursive_iterate+0xbb>
add    $0xfffffffffffffffe,%rbx
jmp    1193 <recursive_iterate+0x43>
add    $0xffffffffffffffff,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
call   1060 <poss_matches@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     120b <recursive_iterate+0xbb>
mov    %rax,%rbp
mov    %ebx,%r12d
jmp    11c0 <recursive_iterate+0x70>
nopl   (%rax)
movl   $0x0,(%r15,%r12,4)
movslq %ebx,%rax
xor    %rax,%rbp
je     120b <recursive_iterate+0xbb>
mov    %rbp,%rdi
call   1050 <convert_bitwise@plt>
lea    -0x1(%rax),%ecx
mov    $0x1,%ebx
shl    %cl,%ebx
mov    %eax,(%r15,%r12,4)
mov    %r15,%rdi
call   1040 <check_solution@plt>
test   %rax,%rax
jne    11f9 <recursive_iterate+0xa9>
mov    %r15,%rdi
call   1070 <recursive_iterate@plt>
test   %eax,%eax
je     11b0 <recursive_iterate+0x60>
cmp    $0x63,%eax
jne    11b8 <recursive_iterate+0x68>
mov    %eax,%r14d
jmp    120b <recursive_iterate+0xbb>
lea    0xe00(%rip),%rdi
call   1030 <puts@plt>
mov    $0x63,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Board is solved!\0A\00"
define i32 @recursive_iterate(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %4
br label %8
8: ; preds = %67, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 81
br i1 %10, label %11, label %70
11: ; preds = %8
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 0, %16
br i1 %17, label %18, label %66
18: ; preds = %11
%19 = load i32*, i32** %3
%20 = load i32, i32* %4
%21 = call i64 @poss_matches(i32* %19, i32 %20)
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = icmp ne i64 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %18
store i32 0, i32* %2
br label %71
25: ; preds = %18
br label %26
26: ; preds = %64, %25
%27 = load i64, i64* %5
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %65
29: ; preds = %26
%30 = load i64, i64* %5
%31 = call i32 @convert_bitwise(i64 %30)
store i32 %31, i32* %6
%32 = load i64, i64* %5
%33 = load i32, i32* %6
%34 = sub nsw i32 %33, 1
%35 = shl i32 1, %34
%36 = sext i32 %35 to i64
%37 = xor i64 %32, %36
store i64 %37, i64* %5
%38 = load i32, i32* %6
%39 = load i32*, i32** %3
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
%43 = load i32*, i32** %3
%44 = call i64 @check_solution(i32* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %29
%47 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 99, i32* %2
br label %71
48: ; preds = %29
%49 = load i32*, i32** %3
%50 = call i32 @recursive_iterate(i32* %49)
store i32 %50, i32* %7
%51 = load i32, i32* %7
%52 = icmp eq i32 99, %51
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = load i32, i32* %7
store i32 %54, i32* %2
br label %71
55: ; preds = %48
%56 = load i32, i32* %7
%57 = icmp eq i32 0, %56
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = load i32*, i32** %3
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
store i32 0, i32* %62
br label %63
63: ; preds = %58, %55
br label %64
64: ; preds = %63
br label %26
65: ; preds = %26
store i32 0, i32* %2
br label %71
66: ; preds = %11
br label %67
67: ; preds = %66
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %8
70: ; preds = %8
store i32 0, i32* %2
br label %71
71: ; preds = %70, %65, %53, %46, %24
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@str = [17 x i8] c"Board is solved!\00"
define i32 @recursive_iterate(i32* %0) {
br label %2
2: ; preds = %40, %1
%3 = phi i64 [ 0, %1 ], [ %41, %40 ]
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %30
7: ; preds = %35, %30, %2
%8 = phi i64 [ %3, %2 ], [ %31, %30 ], [ %36, %35 ]
%9 = trunc i64 %8 to i32
%10 = and i64 %8, 4294967295
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = tail call i64 @poss_matches(i32* %0, i32 %9)
%13 = icmp eq i64 %12, 0
br i1 %13, label %43, label %14
14: ; preds = %7, %28
%15 = phi i64 [ %20, %28 ], [ %12, %7 ]
%16 = tail call i32 @convert_bitwise(i64 %15)
%17 = add nsw i32 %16, -1
%18 = shl nuw i32 1, %17
%19 = sext i32 %18 to i64
%20 = xor i64 %15, %19
store i32 %16, i32* %11
%21 = tail call i64 @check_solution(i32* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %14
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %43
25: ; preds = %14
%26 = tail call i32 @recursive_iterate(i32* %0)
switch i32 %26, label %28 [
i32 99, label %43
i32 0, label %27
]
27: ; preds = %25
store i32 0, i32* %11
br label %28
28: ; preds = %27, %25
%29 = icmp eq i64 %20, 0
br i1 %29, label %43, label %14
30: ; preds = %2
%31 = add nuw nsw i64 %3, 1
%32 = getelementptr inbounds i32, i32* %0, i64 %31
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %7, label %35
35: ; preds = %30
%36 = add nuw nsw i64 %3, 2
%37 = getelementptr inbounds i32, i32* %0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 0
br i1 %39, label %7, label %40
40: ; preds = %35
%41 = add nuw nsw i64 %3, 3
%42 = icmp eq i64 %41, 81
br i1 %42, label %43, label %2
43: ; preds = %40, %28, %25, %23, %7
%44 = phi i32 [ 99, %23 ], [ 0, %7 ], [ 0, %28 ], [ %26, %25 ], [ 0, %40 ]
ret i32 %44
}