#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__ isPermissible(int **, int, int);
int /*<<< orphan*/ printBoard(int **);
int solveNQueens(int board[8][8], int column) {
  if (column == 8) {
    printBoard(board);
    return 1;
  }
  int row;
  for (row = 0; row < 8; row++) {
    if (isPermissible(board, row, column)) {
      board[row][column] = 1;
      solveNQueens(board, column + 1);
      board[row][column] = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<solveNQueens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jne    115e <solveNQueens+0x2e>
mov    -0x10(%rbp),%rdi
call   1030 <printBoard@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <solveNQueens+0xb5>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11de <solveNQueens+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <isPermissible@plt>
cmp    $0x0,%rax
je     11cb <solveNQueens+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <solveNQueens@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11d0 <solveNQueens+0xa0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <solveNQueens+0x35>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveNQueens>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0x8,%esi
jne    1151 <solveNQueens+0x21>
mov    %rbx,%rdi
call   1030 <printBoard@plt>
mov    $0x1,%ebp
jmp    12f7 <solveNQueens+0x1c7>
mov    %esi,%ebp
movslq %esi,%r15
lea    0x1(%rbp),%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     1186 <solveNQueens+0x56>
movl   $0x1,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     11b7 <solveNQueens+0x87>
movl   $0x1,0x20(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0x20(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     11e8 <solveNQueens+0xb8>
movl   $0x1,0x40(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0x40(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     1219 <solveNQueens+0xe9>
movl   $0x1,0x60(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0x60(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     1250 <solveNQueens+0x120>
movl   $0x1,0x80(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0x80(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     1287 <solveNQueens+0x157>
movl   $0x1,0xa0(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0xa0(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
test   %rax,%rax
je     12be <solveNQueens+0x18e>
movl   $0x1,0xc0(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0xc0(%rbx,%r15,4)
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %ebp,%edx
call   1050 <isPermissible@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12f7 <solveNQueens+0x1c7>
movl   $0x1,0xe0(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQueens@plt>
movl   $0x0,0xe0(%rbx,%r15,4)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @solveNQueens([8 x i32]* %0, i32 %1) {
%3 = icmp eq i32 %1, 8
%4 = bitcast [8 x i32]* %0 to i32**
br i1 %3, label %10, label %5
5: ; preds = %2
%6 = sext i32 %1 to i64
%7 = add nsw i32 %1, 1
%8 = tail call i64 @isPermissible(i32** %4, i32 0, i32 %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %12
10: ; preds = %2
%11 = tail call i32 @printBoard(i32** %4)
br label %57
12: ; preds = %5
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 0, i64 %6
store i32 1, i32* %13
%14 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %13
br label %15
15: ; preds = %5, %12
%16 = tail call i64 @isPermissible(i32** %4, i32 1, i32 %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 1, i64 %6
store i32 1, i32* %19
%20 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %19
br label %21
21: ; preds = %18, %15
%22 = tail call i64 @isPermissible(i32** %4, i32 2, i32 %1)
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 2, i64 %6
store i32 1, i32* %25
%26 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %25
br label %27
27: ; preds = %24, %21
%28 = tail call i64 @isPermissible(i32** %4, i32 3, i32 %1)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 3, i64 %6
store i32 1, i32* %31
%32 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %31
br label %33
33: ; preds = %30, %27
%34 = tail call i64 @isPermissible(i32** %4, i32 4, i32 %1)
%35 = icmp eq i64 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 4, i64 %6
store i32 1, i32* %37
%38 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %37
br label %39
39: ; preds = %36, %33
%40 = tail call i64 @isPermissible(i32** %4, i32 5, i32 %1)
%41 = icmp eq i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 5, i64 %6
store i32 1, i32* %43
%44 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %43
br label %45
45: ; preds = %42, %39
%46 = tail call i64 @isPermissible(i32** %4, i32 6, i32 %1)
%47 = icmp eq i64 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 6, i64 %6
store i32 1, i32* %49
%50 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %49
br label %51
51: ; preds = %48, %45
%52 = tail call i64 @isPermissible(i32** %4, i32 7, i32 %1)
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 7, i64 %6
store i32 1, i32* %55
%56 = tail call i32 @solveNQueens([8 x i32]* %0, i32 %7)
store i32 0, i32* %55
br label %57
57: ; preds = %51, %54, %10
%58 = phi i32 [ 1, %10 ], [ 0, %54 ], [ 0, %51 ]
ret i32 %58
}