#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__ isSafe(int **, int, int);
int solveNQUtil(int board[4][4], int col) {
  if (col >= 4)
    return 1;
  int i;
  for (i = 0; i < 4; i++) {
    if (isSafe(board, i, col)) {
      board[i][col] = 1;
      if (solveNQUtil(board, col + 1) == 1)
        return 1;
      board[i][col] = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<solveNQUtil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jl     1145 <solveNQUtil+0x25>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <solveNQUtil+0xc1>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    11da <solveNQUtil+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <isSafe@plt>
cmp    $0x0,%rax
je     11c7 <solveNQUtil+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x4,%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 <solveNQUtil@plt>
cmp    $0x1,%eax
jne    11ad <solveNQUtil+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <solveNQUtil+0xc1>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11cc <solveNQUtil+0xac>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <solveNQUtil+0x2c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveNQUtil>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r15d
cmp    $0x3,%esi
jg     1220 <solveNQUtil+0x100>
mov    %esi,%ebp
mov    %rdi,%rbx
movslq %esi,%r12
lea    0x1(%rbp),%r14d
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <isSafe@plt>
test   %rax,%rax
je     1175 <solveNQUtil+0x55>
movl   $0x1,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQUtil@plt>
cmp    $0x1,%eax
je     1220 <solveNQUtil+0x100>
movl   $0x0,(%rbx,%r12,4)
mov    $0x1,%r15d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <isSafe@plt>
test   %rax,%rax
je     11b1 <solveNQUtil+0x91>
movl   $0x1,0x10(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQUtil@plt>
cmp    $0x1,%eax
je     1220 <solveNQUtil+0x100>
movl   $0x0,0x10(%rbx,%r12,4)
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
call   1030 <isSafe@plt>
test   %rax,%rax
je     11e7 <solveNQUtil+0xc7>
movl   $0x1,0x20(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQUtil@plt>
cmp    $0x1,%eax
je     1220 <solveNQUtil+0x100>
movl   $0x0,0x20(%rbx,%r12,4)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
call   1030 <isSafe@plt>
test   %rax,%rax
je     121d <solveNQUtil+0xfd>
movl   $0x1,0x30(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <solveNQUtil@plt>
cmp    $0x1,%eax
je     1220 <solveNQUtil+0x100>
movl   $0x0,0x30(%rbx,%r12,4)
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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