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


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

x86 assembly (clang, -O2):
<solve>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
cmp    $0x8,%esi
jne    114d <solve+0x1d>
mov    %rbx,%rdi
call   1050 <print_board@plt>
jmp    130c <solve+0x1dc>
mov    %esi,%ebp
movslq %esi,%r15
lea    0x1(%rbp),%r14d
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    1187 <solve+0x57>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    11bf <solve+0x8f>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,0x4(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0x4(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    11f7 <solve+0xc7>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,0x8(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0x8(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    122f <solve+0xff>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,0xc(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0xc(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    1267 <solve+0x137>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,0x10(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0x10(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x5,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    129f <solve+0x16f>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,0x14(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0x14(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x6,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    12d7 <solve+0x1a7>
mov    %r15,%r12
shl    $0x5,%r12
movl   $0x1,0x18(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0x18(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x7,%edx
call   1040 <conflict@plt>
test   %rax,%rax
jne    130c <solve+0x1dc>
shl    $0x5,%r15
movl   $0x1,0x1c(%rbx,%r15,1)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <solve@plt>
movl   $0x0,0x1c(%rbx,%r15,1)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @solve([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 @print_board(i32** %11)
store i32 0, i32* %3
br label %47
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* %5
%21 = load i32, i32* %6
%22 = call i64 @conflict(i32** %19, i32 %20, i32 %21)
%23 = icmp eq 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* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %25, i64 %27
%29 = load i32, i32* %6
%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 @solve([8 x i32]* %32, i32 %34)
%36 = load [8 x i32]*, [8 x i32]** %4
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [8 x i32], [8 x i32]* %36, i64 %38
%40 = load i32, i32* %6
%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 = %9, %14
%48 = load i32, i32* %3
ret i32 %48
}

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