#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*/ dfs(int, int /*<<< orphan*/, int *, char ***, int *, int *);
void *malloc(int);
char ***solveNQueens(int n, int *returnSize, int **returnColumnSizes) {
  int row = 0, col = 0, sum = 0;
  char ***solutions = malloc(1000 * sizeof(char **));
  *returnColumnSizes = malloc(1000 * sizeof(int));
  int *stack = malloc(n * sizeof(int));
  *returnSize = 0;
  dfs(n, 0, stack, solutions, returnSize, *returnColumnSizes);
  return solutions;
}


x86 assembly (clang, -O0):
<solveNQueens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x1f40,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0xfa0,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%rax
mov    (%rax),%r9
xor    %esi,%esi
call   1040 <dfs@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveNQueens>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r13d
mov    $0x1f40,%edi
call   1030 <malloc@plt>
mov    %rax,%r12
mov    $0xfa0,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %rax,(%r14)
lea    0x0(,%r13,4),%edi
call   1030 <malloc@plt>
movl   $0x0,(%r15)
mov    %r13d,%edi
xor    %esi,%esi
mov    %rax,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %rbx,%r9
call   1040 <dfs@plt>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8*** @solveNQueens(i32 %0, i32* %1, i32** %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8***
%11 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32** %2, i32*** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%12 = call i8* @malloc(i32 8000)
%13 = bitcast i8* %12 to i8***
store i8*** %13, i8**** %10
%14 = call i8* @malloc(i32 4000)
%15 = bitcast i8* %14 to i32*
%16 = load i32**, i32*** %6
store i32* %15, i32** %16
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i8* @malloc(i32 %20)
%22 = bitcast i8* %21 to i32*
store i32* %22, i32** %11
%23 = load i32*, i32** %5
store i32 0, i32* %23
%24 = load i32, i32* %4
%25 = load i32*, i32** %11
%26 = load i8***, i8**** %10
%27 = load i32*, i32** %5
%28 = load i32**, i32*** %6
%29 = load i32*, i32** %28
%30 = call i32 @dfs(i32 %24, i32 0, i32* %25, i8*** %26, i32* %27, i32* %29)
%31 = load i8***, i8**** %10
ret i8*** %31
}

LLVM IR (-O2):
define i8*** @solveNQueens(i32 %0, i32* %1, i32** nocapture writeonly %2) {
%4 = tail call dereferenceable_or_null(8000) i8* @malloc(i32 8000)
%5 = bitcast i8* %4 to i8***
%6 = tail call dereferenceable_or_null(4000) i8* @malloc(i32 4000)
%7 = bitcast i32** %2 to i8**
store i8* %6, i8** %7
%8 = shl i32 %0, 2
%9 = tail call i8* @malloc(i32 %8)
%10 = bitcast i8* %9 to i32*
store i32 0, i32* %1
%11 = bitcast i8* %6 to i32*
%12 = tail call i32 @dfs(i32 %0, i32 0, i32* %10, i8*** %5, i32* %1, i32* %11)
ret i8*** %5
}