#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 get_value(int, int, int, char *);
scalar_t__ new_puzzle(char *);
int /*<<< orphan*/ porcelain_cleanup();
void test_porcelain(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 cell_index = 0; cell_index < 9; ++cell_index) {
          int a = get_value(choice, choice_index, cell_index, puzzle_key);
        }
      }
    }
    porcelain_cleanup();
  }
}


x86 assembly (clang, -O0):
<test_porcelain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <new_puzzle@plt>
cmp    $0x0,%rax
je     11d2 <test_porcelain+0xa2>
movl   $0x1,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jg     11cb <test_porcelain+0x9b>
movl   $0x0,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jge    11b8 <test_porcelain+0x88>
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    11a5 <test_porcelain+0x75>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rcx
call   1050 <get_value@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <test_porcelain+0x48>
jmp    11aa <test_porcelain+0x7a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1167 <test_porcelain+0x37>
jmp    11bd <test_porcelain+0x8d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <test_porcelain+0x26>
mov    $0x0,%al
call   1030 <porcelain_cleanup@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_porcelain>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <new_puzzle@plt>
test   %rax,%rax
je     1219 <test_porcelain+0xe9>
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
xor    %edx,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x4,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x5,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x6,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x7,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x8,%edx
mov    %r14,%rcx
call   1050 <get_value@plt>
add    $0x1,%ebx
cmp    $0x9,%ebx
jne    1160 <test_porcelain+0x30>
add    $0x1,%ebp
cmp    $0x4,%ebp
jne    1150 <test_porcelain+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_porcelain(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 %41
10: ; preds = %1
store i32 1, i32* %3
br label %11
11: ; preds = %36, %10
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 3
br i1 %13, label %14, label %39
14: ; preds = %11
store i32 0, i32* %4
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 9
br i1 %17, label %18, label %35
18: ; preds = %15
store i32 0, i32* %5
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %5
%21 = icmp slt 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 @get_value(i32 %23, i32 %24, i32 %25, i8* %26)
store i32 %27, i32* %6
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
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %15
35: ; preds = %15
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %11
39: ; preds = %11
%40 = call i32 (...) @porcelain_cleanup()
br label %41
41: ; preds = %39, %1
ret void
}

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