#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__ new_puzzle(char *);
int /*<<< orphan*/ porcelain_cleanup();
int /*<<< orphan*/ single_occupant_algorithm(int, int, int, char *);
int /*<<< orphan*/ single_spot_algorithm(int, int, int, char *);
void test_algorithms(char *puzzle_key) {
  if (new_puzzle(puzzle_key)) {
    for (int choice = 1; choice <= 3; ++choice) {
      for (int choice_index = 0; choice_index < 9; ++choice_index) {
        for (int value = 1; value <= 9; ++value) {
          single_spot_algorithm(choice, choice_index, value, puzzle_key);
        }
        for (int cell_index = 0; cell_index < 9; ++cell_index) {
          single_occupant_algorithm(choice, choice_index, cell_index,
                                    puzzle_key);
        }
      }
    }
    porcelain_cleanup();
  }
}


x86 assembly (clang, -O0):
<test_algorithms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <new_puzzle@plt>
cmp    $0x0,%rax
je     1210 <test_algorithms+0xd0>
movl   $0x1,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jg     1209 <test_algorithms+0xc9>
movl   $0x0,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jge    11f6 <test_algorithms+0xb6>
movl   $0x1,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jg     11b2 <test_algorithms+0x72>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rcx
call   1040 <single_spot_algorithm@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <test_algorithms+0x48>
movl   $0x0,-0x18(%rbp)
cmpl   $0x9,-0x18(%rbp)
jge    11e3 <test_algorithms+0xa3>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rcx
call   1060 <single_occupant_algorithm@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b9 <test_algorithms+0x79>
jmp    11e8 <test_algorithms+0xa8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <test_algorithms+0x37>
jmp    11fb <test_algorithms+0xbb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <test_algorithms+0x26>
mov    $0x0,%al
call   1030 <porcelain_cleanup@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_algorithms>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1050 <new_puzzle@plt>
test   %rax,%rax
je     12c2 <test_algorithms+0x182>
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x4,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x5,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x6,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x7,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x8,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x9,%edx
mov    %r14,%rcx
call   1040 <single_spot_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
xor    %edx,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x4,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x5,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x6,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x7,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x8,%edx
mov    %r14,%rcx
call   1060 <single_occupant_algorithm@plt>
add    $0x1,%ebx
cmp    $0x9,%ebx
jne    1170 <test_algorithms+0x30>
add    $0x1,%ebp
cmp    $0x4,%ebp
jne    1160 <test_algorithms+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <porcelain_cleanup@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @test_algorithms(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @new_puzzle(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %54
10: ; preds = %1
store i32 1, i32* %3
br label %11
11: ; preds = %49, %10
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 3
br i1 %13, label %14, label %52
14: ; preds = %11
store i32 0, i32* %4
br label %15
15: ; preds = %45, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 9
br i1 %17, label %18, label %48
18: ; preds = %15
store i32 1, i32* %5
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %5
%21 = icmp sle i32 %20, 9
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = load i8*, i8** %2
%27 = call i32 @single_spot_algorithm(i32 %23, i32 %24, i32 %25, i8* %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %19
31: ; preds = %19
store i32 0, i32* %6
br label %32
32: ; preds = %41, %31
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 9
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = load i32, i32* %6
%39 = load i8*, i8** %2
%40 = call i32 @single_occupant_algorithm(i32 %36, i32 %37, i32 %38, i8* %39)
br label %41
41: ; preds = %35
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %32
44: ; preds = %32
br label %45
45: ; preds = %44
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %15
48: ; preds = %15
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %11
52: ; preds = %11
%53 = call i32 (...) @porcelain_cleanup()
br label %54
54: ; preds = %52, %1
ret void
}

LLVM IR (-O2):
define void @test_algorithms(i8* %0) {
%2 = tail call i64 @new_puzzle(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %33, label %4
4: ; preds = %1, %30
%5 = phi i32 [ %31, %30 ], [ 1, %1 ]
br label %8
6: ; preds = %30
%7 = tail call i32 (...) @porcelain_cleanup()
br label %33
8: ; preds = %4, %8
%9 = phi i32 [ 0, %4 ], [ %28, %8 ]
%10 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 1, i8* %0)
%11 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 2, i8* %0)
%12 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 3, i8* %0)
%13 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 4, i8* %0)
%14 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 5, i8* %0)
%15 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 6, i8* %0)
%16 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 7, i8* %0)
%17 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 8, i8* %0)
%18 = tail call i32 @single_spot_algorithm(i32 %5, i32 %9, i32 9, i8* %0)
%19 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 0, i8* %0)
%20 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 1, i8* %0)
%21 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 2, i8* %0)
%22 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 3, i8* %0)
%23 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 4, i8* %0)
%24 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 5, i8* %0)
%25 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 6, i8* %0)
%26 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 7, i8* %0)
%27 = tail call i32 @single_occupant_algorithm(i32 %5, i32 %9, i32 8, i8* %0)
%28 = add nuw nsw i32 %9, 1
%29 = icmp eq i32 %28, 9
br i1 %29, label %30, label %8
30: ; preds = %8
%31 = add nuw nsw i32 %5, 1
%32 = icmp eq i32 %31, 4
br i1 %32, label %6, label %4
33: ; preds = %6, %1
ret void
}