#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 /*<<< orphan*/ getCandidates(int *, int *);
scalar_t__ isSolution(int, int);
int /*<<< orphan*/ printSolution(int *, int);
int /*<<< orphan*/ printf(char *);
void backtrack(bool *a, int k, int n) {
  bool candidates[2];
  int c;
  int i;
  if (isSolution(k, n)) {
    printSolution(a, k);
    printf("\n");
  } else {
    k = k + 1;
    getCandidates(candidates, &c);
    for (i = 0; i < c; i++) {
      a[k] = candidates[i];
      backtrack(a, k, n);
    }
  }
}


x86 assembly (clang, -O0):
<backtrack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <isSolution@plt>
cmp    $0x0,%rax
je     1194 <backtrack+0x44>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <printSolution@plt>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
jmp    11f2 <backtrack+0xa2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <getCandidates@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ed <backtrack+0x9d>
movslq -0x20(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <backtrack@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b1 <backtrack+0x61>
jmp    11f2 <backtrack+0xa2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backtrack>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r12
mov    %esi,%edi
mov    %edx,%esi
call   1050 <isSolution@plt>
test   %rax,%rax
je     1194 <backtrack+0x44>
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <printSolution@plt>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1040 <getCandidates@plt>
cmpl   $0x0,0x4(%rsp)
jle    11e3 <backtrack+0x93>
add    $0x1,%r14d
movslq %r14d,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp,%rbx,4),%eax
mov    %eax,(%r12,%rbp,4)
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1060 <backtrack@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <backtrack+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @backtrack(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i64 @isSolution(i32 %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = call i32 @printSolution(i32* %15, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %44
19: ; preds = %3
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%23 = call i32 @getCandidates(i32* %22, i32* %8)
store i32 0, i32* %9
br label %24
24: ; preds = %40, %19
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = load i32*, i32** %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
%37 = load i32*, i32** %4
%38 = load i32, i32* %5
%39 = load i32, i32* %6
br label %40
40: ; preds = %28
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %24
43: ; preds = %24
br label %44
44: ; preds = %43, %14
ret void
}

LLVM IR (-O2):
define void @backtrack(i32* %0, i32 %1, i32 %2) {
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = bitcast [2 x i32]* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = tail call i64 @isSolution(i32 %1, i32 %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = tail call i32 @printSolution(i32* %0, i32 %1)
%12 = tail call i32 @putchar(i32 10)
br label %30
13: ; preds = %3
%14 = add nsw i32 %1, 1
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%16 = call i32 @getCandidates(i32* %15, i32* %5)
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %13
%20 = sext i32 %14 to i64
%21 = getelementptr inbounds i32, i32* %0, i64 %20
br label %22
22: ; preds = %19, %22
%23 = phi i64 [ 0, %19 ], [ %26, %22 ]
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 %23
%25 = load i32, i32* %24
store i32 %25, i32* %21
%26 = add nuw nsw i64 %23, 1
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %22, label %30
30: ; preds = %22, %13, %10
ret void
}