#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__ isAttacked(int *, int);
int /*<<< orphan*/ print(int **, int *);
int /*<<< orphan*/ zeroIt(int **);
void solve(int q[], int col, int chess[][8]) {
  if (col == 8) {
    print(chess, q);
    zeroIt(chess);
  } else {
    int i = 0;
    for (i = 0; i < 8; i++) {
      q[col] = i;
      if (isAttacked(q, col)) {
        solve(q, col + 1, chess);
      }
    }
  }
  return;
}


x86 assembly (clang, -O0):
<solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x8,-0xc(%rbp)
jne    1178 <solve+0x38>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <print@plt>
mov    -0x18(%rbp),%rdi
call   1060 <zeroIt@plt>
jmp    11df <solve+0x9f>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11da <solve+0x9a>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <isAttacked@plt>
cmp    $0x0,%rax
je     11c7 <solve+0x87>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rdx
call   1030 <solve@plt>
jmp    11cc <solve+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <solve+0x46>
jmp    11df <solve+0x9f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
cmp    $0x8,%esi
jne    116e <solve+0x2e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <print@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <zeroIt@plt>
mov    %esi,%ebp
movslq %esi,%r12
lea    0x1(%rbp),%r15d
movl   $0x0,(%rbx,%r12,4)
mov    %rbx,%rdi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     119a <solve+0x5a>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x1,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     11bf <solve+0x7f>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x2,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     11e4 <solve+0xa4>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x3,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     1209 <solve+0xc9>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x4,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     122e <solve+0xee>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x5,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     1253 <solve+0x113>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x6,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     1278 <solve+0x138>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <solve@plt>
movl   $0x7,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <isAttacked@plt>
test   %rax,%rax
je     12a5 <solve+0x165>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <solve@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @solve(i32* %0, i32 %1, [8 x i32]* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [8 x i32]*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store [8 x i32]* %2, [8 x i32]** %6
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 8
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = load [8 x i32]*, [8 x i32]** %6
%12 = bitcast [8 x i32]* %11 to i32**
%13 = load i32*, i32** %4
%14 = call i32 @print(i32** %12, i32* %13)
%15 = load [8 x i32]*, [8 x i32]** %6
%16 = bitcast [8 x i32]* %15 to i32**
%17 = call i32 @zeroIt(i32** %16)
br label %42
18: ; preds = %3
store i32 0, i32* %7
store i32 0, i32* %7
br label %19
19: ; preds = %38, %18
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 8
br i1 %21, label %22, label %41
22: ; preds = %19
%23 = load i32, i32* %7
%24 = load i32*, i32** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 %23, i32* %27
%28 = load i32*, i32** %4
%29 = load i32, i32* %5
%30 = call i64 @isAttacked(i32* %28, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %22
%33 = load i32*, i32** %4
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = load [8 x i32]*, [8 x i32]** %6
br label %37
37: ; preds = %32, %22
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %19
41: ; preds = %19
br label %42
42: ; preds = %41, %10
ret void
}

LLVM IR (-O2):
define void @solve(i32* %0, i32 %1, [8 x i32]* %2) {
%4 = icmp eq i32 %1, 8
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = sext i32 %1 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = add nsw i32 %1, 1
store i32 0, i32* %7
%9 = tail call i64 @isAttacked(i32* %0, i32 %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %15
11: ; preds = %3
%12 = bitcast [8 x i32]* %2 to i32**
%13 = tail call i32 @print(i32** %12, i32* %0)
%14 = tail call i32 @zeroIt(i32** %12)
br label %44
15: ; preds = %5
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %16
16: ; preds = %5, %15
store i32 1, i32* %7
%17 = tail call i64 @isAttacked(i32* %0, i32 %1)
%18 = icmp eq i64 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %20
20: ; preds = %19, %16
store i32 2, i32* %7
%21 = tail call i64 @isAttacked(i32* %0, i32 %1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %20
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %24
24: ; preds = %23, %20
store i32 3, i32* %7
%25 = tail call i64 @isAttacked(i32* %0, i32 %1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %28
28: ; preds = %27, %24
store i32 4, i32* %7
%29 = tail call i64 @isAttacked(i32* %0, i32 %1)
%30 = icmp eq i64 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %28
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %32
32: ; preds = %31, %28
store i32 5, i32* %7
%33 = tail call i64 @isAttacked(i32* %0, i32 %1)
%34 = icmp eq i64 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %32
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %36
36: ; preds = %35, %32
store i32 6, i32* %7
%37 = tail call i64 @isAttacked(i32* %0, i32 %1)
%38 = icmp eq i64 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %36
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %40
40: ; preds = %39, %36
store i32 7, i32* %7
%41 = tail call i64 @isAttacked(i32* %0, i32 %1)
%42 = icmp eq i64 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %40
tail call void @solve(i32* %0, i32 %8, [8 x i32]* %2)
br label %44
44: ; preds = %40, %43, %11
ret void
}