#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*/ printf(char *, ...);
char ***solveNQueens(int, int *);
int main(int argc, char *argv[]) {
  char solutions[2][4][5] = {{".Q..", "...Q", "Q...", "..Q."},
                             {
                                 "..Q.",
                                 "Q...",
                                 "...Q",
                                 ".Q..",
                             }};
  int size;
  char ***answer = solveNQueens(4, &size);
  if (!(size == 2)) {
    printf("assert fail: %s\n", "size == 2");
  };
  for (int i = 0; i < size; ++i) {
    for (int j = 0; j < 4; ++j) {
      for (int k = 0; k < 4; ++k) {
        if (!(answer[i][j][k] == solutions[i][j][k])) {
          printf("assert fail: %s\n", "test");
        };
      }
    }
  }
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
mov    $0x4,%edi
lea    -0x44(%rbp),%rsi
call   1050 <solveNQueens@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x2,-0x44(%rbp)
je     118c <main+0x5c>
lea    0xeaa(%rip),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1255 <main+0x125>
movl   $0x0,-0x58(%rbp)
cmpl   $0x4,-0x58(%rbp)
jge    1242 <main+0x112>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    122f <main+0xff>
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x5c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movslq -0x54(%rbp),%rdx
lea    -0x40(%rbp),%rcx
imul   $0x14,%rdx,%rdx
add    %rdx,%rcx
movslq -0x58(%rbp),%rdx
imul   $0x5,%rdx,%rdx
add    %rdx,%rcx
movslq -0x5c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     121c <main+0xec>
lea    0xe1a(%rip),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11b7 <main+0x87>
jmp    1234 <main+0x104>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11a6 <main+0x76>
jmp    1247 <main+0x117>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1193 <main+0x63>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xc(%rsp),%rsi
mov    $0x4,%edi
call   1050 <solveNQueens@plt>
mov    %rax,%r13
cmpl   $0x2,0xc(%rsp)
je     1177 <main+0x47>
lea    0xeca(%rip),%rdi
lea    0xed4(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    124e <main+0x11e>
lea    0xe85(%rip),%rbp
lea    0xea3(%rip),%r14
lea    0xeb7(%rip),%r15
xor    %ebx,%ebx
jmp    11ab <main+0x7b>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
mov    0x10(%rsp),%rbp
add    $0x14,%rbp
cmp    %rax,%rbx
jge    124e <main+0x11e>
mov    %rbp,0x10(%rsp)
xor    %r12d,%r12d
jmp    11ce <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12
add    $0x5,%rbp
cmp    $0x4,%r12
je     1190 <main+0x60>
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r12,8),%rax
movzbl (%rax),%ecx
cmp    -0x3(%rbp),%cl
je     11f5 <main+0xc5>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r12,8),%rax
movzbl 0x1(%rax),%ecx
cmp    -0x2(%rbp),%cl
je     1214 <main+0xe4>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r12,8),%rax
movzbl 0x2(%rax),%ecx
cmp    -0x1(%rbp),%cl
je     1233 <main+0x103>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r12,8),%rax
movzbl 0x3(%rax),%eax
cmp    0x0(%rbp),%al
je     11c0 <main+0x90>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xdf3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.solutions = [2 x [4 x [5 x i8]]] [[4 x [5 x i8]] [[5 x i8] c".Q..\00", [5 x i8] c"...Q\00", [5 x i8] c"Q...\00", [5 x i8] c"..Q.\00"], [4 x [5 x i8]] [[5 x i8] c"..Q.\00", [5 x i8] c"Q...\00", [5 x i8] c"...Q\00", [5 x i8] c".Q..\00"]]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [10 x i8] c"size == 2\00"
@.str.2 = [5 x i8] c"test\00"
@.str.3 = [21 x i8] c"everything is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x [4 x [5 x i8]]]
%7 = alloca i32
%8 = alloca i8***
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [2 x [4 x [5 x i8]]]* %6 to i8*
%13 = call i8*** @solveNQueens(i32 4, i32* %7)
store i8*** %13, i8**** %8
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 2
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
store i32 0, i32* %9
br label %19
19: ; preds = %69, %18
%20 = load i32, i32* %9
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %72
23: ; preds = %19
store i32 0, i32* %10
br label %24
24: ; preds = %65, %23
%25 = load i32, i32* %10
%26 = icmp slt i32 %25, 4
br i1 %26, label %27, label %68
27: ; preds = %24
store i32 0, i32* %11
br label %28
28: ; preds = %61, %27
%29 = load i32, i32* %11
%30 = icmp slt i32 %29, 4
br i1 %30, label %31, label %64
31: ; preds = %28
%32 = load i8***, i8**** %8
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8**, i8*** %32, i64 %34
%36 = load i8**, i8*** %35
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* %11
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [2 x [4 x [5 x i8]]], [2 x [4 x [5 x i8]]]* %6, i64 0, i64 %47
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %48, i64 0, i64 %50
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [5 x i8], [5 x i8]* %51, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %45, %56
br i1 %57, label %60, label %58
58: ; preds = %31
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %60
60: ; preds = %58, %31
br label %61
61: ; preds = %60
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
br label %28
64: ; preds = %28
br label %65
65: ; preds = %64
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %24
68: ; preds = %24
br label %69
69: ; preds = %68
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %19
72: ; preds = %19
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.solutions = [2 x [4 x [5 x i8]]] [[4 x [5 x i8]] [[5 x i8] c".Q..\00", [5 x i8] c"...Q\00", [5 x i8] c"Q...\00", [5 x i8] c"..Q.\00"], [4 x [5 x i8]] [[5 x i8] c"..Q.\00", [5 x i8] c"Q...\00", [5 x i8] c"...Q\00", [5 x i8] c".Q..\00"]]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [10 x i8] c"size == 2\00"
@.str.2 = [5 x i8] c"test\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i8*** @solveNQueens(i32 4, i32* %3)
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2, %8
br label %13
13: ; preds = %12, %27
%14 = phi i64 [ %28, %27 ], [ 0, %12 ]
%15 = getelementptr inbounds i8**, i8*** %5, i64 %14
br label %18
16: ; preds = %27, %8
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i32 0
18: ; preds = %13, %70
%19 = phi i64 [ 0, %13 ], [ %71, %70 ]
%20 = load i8**, i8*** %15
%21 = getelementptr inbounds i8*, i8** %20, i64 %19
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = getelementptr inbounds [2 x [4 x [5 x i8]]], [2 x [4 x [5 x i8]]]* @__const.main.solutions, i64 0, i64 %14, i64 %19, i64 0
%25 = load i8, i8* %24
%26 = icmp eq i8 %23, %25
br i1 %26, label %37, label %32
27: ; preds = %70
%28 = add nuw nsw i64 %14, 1
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %13, label %16
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%34 = load i8**, i8*** %15
%35 = getelementptr inbounds i8*, i8** %34, i64 %19
%36 = load i8*, i8** %35
br label %37
37: ; preds = %18, %32
%38 = phi i8* [ %22, %18 ], [ %36, %32 ]
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = getelementptr inbounds [2 x [4 x [5 x i8]]], [2 x [4 x [5 x i8]]]* @__const.main.solutions, i64 0, i64 %14, i64 %19, i64 1
%42 = load i8, i8* %41
%43 = icmp eq i8 %40, %42
br i1 %43, label %49, label %44
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%46 = load i8**, i8*** %15
%47 = getelementptr inbounds i8*, i8** %46, i64 %19
%48 = load i8*, i8** %47
br label %49
49: ; preds = %44, %37
%50 = phi i8* [ %48, %44 ], [ %38, %37 ]
%51 = getelementptr inbounds i8, i8* %50, i64 2
%52 = load i8, i8* %51
%53 = getelementptr inbounds [2 x [4 x [5 x i8]]], [2 x [4 x [5 x i8]]]* @__const.main.solutions, i64 0, i64 %14, i64 %19, i64 2
%54 = load i8, i8* %53
%55 = icmp eq i8 %52, %54
br i1 %55, label %61, label %56
56: ; preds = %49
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%58 = load i8**, i8*** %15
%59 = getelementptr inbounds i8*, i8** %58, i64 %19
%60 = load i8*, i8** %59
br label %61
61: ; preds = %56, %49
%62 = phi i8* [ %60, %56 ], [ %50, %49 ]
%63 = getelementptr inbounds i8, i8* %62, i64 3
%64 = load i8, i8* %63
%65 = getelementptr inbounds [2 x [4 x [5 x i8]]], [2 x [4 x [5 x i8]]]* @__const.main.solutions, i64 0, i64 %14, i64 %19, i64 3
%66 = load i8, i8* %65
%67 = icmp eq i8 %64, %66
br i1 %67, label %70, label %68
68: ; preds = %61
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %70
70: ; preds = %68, %61
%71 = add nuw nsw i64 %19, 1
%72 = icmp eq i64 %71, 4
br i1 %72, label %27, label %18
}