#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 check_board();
int /*<<< orphan*/ reset_constraints();
int /*<<< orphan*/ reset_tabu_list();
int /*<<< orphan*/ set_tabu();
int solve_constraint(int);
int /*<<< orphan*/ sort_constraints(int);
int /*<<< orphan*/ update_constraints(int);
void solve_board() {
  int result = check_board();
  if (result != -1) {
    return;
  }
  sort_constraints(0);
  int num_tries = 0;
  int i = -1;
  while (++i < 9 * 3) {
    int result = solve_constraint(i);
    if (result == 1) {
      return;
    } else if (result == 0) {
      num_tries++;
      if (num_tries == 1000) {
        reset_tabu_list();
        num_tries = 0;
      } else {
        set_tabu();
      }
      reset_constraints();
      sort_constraints(0);
      i = -1;
    } else {
      update_constraints(i);
      sort_constraints(i + 1);
    }
  }
}


x86 assembly (clang, -O0):
<solve_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1080 <check_board@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     1191 <solve_board+0x21>
jmp    1243 <solve_board+0xd3>
xor    %edi,%edi
call   1050 <sort_constraints@plt>
movl   $0x0,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x1b,%eax
jge    1243 <solve_board+0xd3>
mov    -0xc(%rbp),%edi
call   1070 <solve_constraint@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11d2 <solve_board+0x62>
jmp    1243 <solve_board+0xd3>
cmpl   $0x0,-0x10(%rbp)
jne    1226 <solve_board+0xb6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jne    1205 <solve_board+0x95>
mov    $0x0,%al
call   1060 <reset_tabu_list@plt>
movl   $0x0,-0x8(%rbp)
jmp    120c <solve_board+0x9c>
mov    $0x0,%al
call   1090 <set_tabu@plt>
mov    $0x0,%al
call   1030 <reset_constraints@plt>
xor    %edi,%edi
call   1050 <sort_constraints@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    1239 <solve_board+0xc9>
mov    -0xc(%rbp),%edi
call   1040 <update_constraints@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1050 <sort_constraints@plt>
jmp    123e <solve_board+0xce>
jmp    11a6 <solve_board+0x36>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_board>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <check_board@plt>
cmp    $0xffffffff,%eax
je     118e <solve_board+0x1e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1050 <sort_constraints@plt>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    11cc <solve_board+0x5c>
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <reset_tabu_list@plt>
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <reset_constraints@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%ebp
mov    %r15d,%edi
call   1050 <sort_constraints@plt>
lea    0x1(%rbp),%ebx
cmp    $0x1a,%ebp
jge    1183 <solve_board+0x13>
mov    %ebx,%edi
call   1070 <solve_constraint@plt>
test   %eax,%eax
je     11f0 <solve_board+0x80>
cmp    $0x1,%eax
je     1183 <solve_board+0x13>
mov    %ebx,%edi
call   1040 <update_constraints@plt>
add    $0x2,%ebp
mov    %ebp,%r15d
jmp    11ba <solve_board+0x4a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
cmp    $0x3e8,%r14d
je     11a1 <solve_board+0x31>
xor    %eax,%eax
call   1090 <set_tabu@plt>
jmp    11ab <solve_board+0x3b>

LLVM IR (-O0):
define void @solve_board() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @check_board()
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %0
br label %44
9: ; preds = %0
%10 = call i32 @sort_constraints(i32 0)
store i32 0, i32* %2
store i32 -1, i32* %3
br label %11
11: ; preds = %43, %9
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = icmp slt i32 %13, 27
br i1 %14, label %15, label %44
15: ; preds = %11
%16 = load i32, i32* %3
%17 = call i32 @solve_constraint(i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %15
br label %44
21: ; preds = %15
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 1000
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (...) @reset_tabu_list()
store i32 0, i32* %2
br label %33
31: ; preds = %24
%32 = call i32 (...) @set_tabu()
br label %33
33: ; preds = %31, %29
%34 = call i32 (...) @reset_constraints()
%35 = call i32 @sort_constraints(i32 0)
store i32 -1, i32* %3
br label %42
36: ; preds = %21
%37 = load i32, i32* %3
%38 = call i32 @update_constraints(i32 %37)
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
%41 = call i32 @sort_constraints(i32 %40)
br label %42
42: ; preds = %36, %33
br label %43
43: ; preds = %42
br label %11
44: ; preds = %8, %20, %11
ret void
}

LLVM IR (-O2):
define void @solve_board() {
%1 = tail call i32 (...) @check_board()
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %30
3: ; preds = %0
%4 = tail call i32 @sort_constraints(i32 0)
br label %5
5: ; preds = %3, %23
%6 = phi i32 [ 0, %3 ], [ %28, %23 ]
%7 = phi i32 [ -1, %3 ], [ %26, %23 ]
%8 = phi i32 [ 0, %3 ], [ %25, %23 ]
%9 = tail call i32 @solve_constraint(i32 %6)
switch i32 %9, label %20 [
i32 1, label %30
i32 0, label %10
]
10: ; preds = %5
%11 = add nsw i32 %8, 1
%12 = icmp eq i32 %11, 1000
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (...) @reset_tabu_list()
br label %17
15: ; preds = %10
%16 = tail call i32 (...) @set_tabu()
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ 0, %13 ], [ %11, %15 ]
%19 = tail call i32 (...) @reset_constraints()
br label %23
20: ; preds = %5
%21 = tail call i32 @update_constraints(i32 %6)
%22 = add nsw i32 %7, 2
br label %23
23: ; preds = %20, %17
%24 = phi i32 [ %22, %20 ], [ 0, %17 ]
%25 = phi i32 [ %8, %20 ], [ %18, %17 ]
%26 = phi i32 [ %6, %20 ], [ -1, %17 ]
%27 = tail call i32 @sort_constraints(i32 %24)
%28 = add nsw i32 %26, 1
%29 = icmp slt i32 %26, 26
br i1 %29, label %5, label %30
30: ; preds = %5, %23, %0
ret void
}