#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 backtrack();
int choice();
int choose(int, int);
scalar_t__ deterministic();
int solve(void) {
  int idx;
  while (1) {
    if (0 == deterministic()) {
      idx = choice();
      if (-1 == idx)
        return 0;
      else if ((idx < 0 || -1 == choose(idx, 1)) && -1 == backtrack())
        return -1;
    } else if (-1 == backtrack())
      return -1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <deterministic@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11d3 <solve+0x93>
mov    $0x0,%al
call   1060 <choice@plt>
mov    %eax,-0x8(%rbp)
mov    $0xffffffff,%eax
cmp    -0x8(%rbp),%eax
jne    1181 <solve+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11ff <solve+0xbf>
cmpl   $0x0,-0x8(%rbp)
jl     11a7 <solve+0x67>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <choose@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11c9 <solve+0x89>
mov    $0x0,%al
call   1050 <backtrack@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11c9 <solve+0x89>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ff <solve+0xbf>
jmp    11ce <solve+0x8e>
jmp    11fa <solve+0xba>
mov    $0x0,%al
call   1050 <backtrack@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11f5 <solve+0xb5>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ff <solve+0xbf>
jmp    11fa <solve+0xba>
jmp    1148 <solve+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve>:
push   %rbx
xor    %ebx,%ebx
jmp    115c <solve+0x1c>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <backtrack@plt>
cmp    $0xffffffff,%eax
je     118b <solve+0x4b>
xor    %eax,%eax
call   1040 <deterministic@plt>
test   %rax,%rax
jne    1150 <solve+0x10>
xor    %eax,%eax
call   1060 <choice@plt>
cmp    $0xffffffff,%eax
je     1190 <solve+0x50>
test   %eax,%eax
js     1150 <solve+0x10>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <choose@plt>
cmp    $0xffffffff,%eax
jne    115c <solve+0x1c>
jmp    1150 <solve+0x10>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @solve() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %0, %29
%4 = call i64 (...) @deterministic()
%5 = icmp eq i64 0, %4
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = call i32 (...) @choice()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 -1, %8
br i1 %9, label %10, label %11
10: ; preds = %6
store i32 0, i32* %1
br label %30
11: ; preds = %6
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 @choose(i32 %15, i32 1)
%17 = icmp eq i32 -1, %16
br i1 %17, label %18, label %22
18: ; preds = %14, %11
%19 = call i32 (...) @backtrack()
%20 = icmp eq i32 -1, %19
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 -1, i32* %1
br label %30
22: ; preds = %18, %14
br label %23
23: ; preds = %22
br label %29
24: ; preds = %3
%25 = call i32 (...) @backtrack()
%26 = icmp eq i32 -1, %25
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 -1, i32* %1
br label %30
28: ; preds = %24
br label %29
29: ; preds = %28, %23
br label %3
30: ; preds = %27, %21, %10
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
define i32 @solve() {
br label %1
1: ; preds = %18, %0
%2 = tail call i64 (...) @deterministic()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = tail call i32 (...) @choice()
%6 = icmp eq i32 %5, -1
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = icmp slt i32 %5, 0
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = tail call i32 @choose(i32 %5, i32 1)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %18
12: ; preds = %9, %7
%13 = tail call i32 (...) @backtrack()
%14 = icmp eq i32 %13, -1
br i1 %14, label %19, label %18
15: ; preds = %1
%16 = tail call i32 (...) @backtrack()
%17 = icmp eq i32 %16, -1
br i1 %17, label %19, label %18
18: ; preds = %15, %12, %9
br label %1
19: ; preds = %15, %12, %4
%20 = phi i32 [ 0, %4 ], [ -1, %12 ], [ -1, %15 ]
ret i32 %20
}