#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 canPlaceQueen(int **, int, int /*<<< orphan*/);
int /*<<< orphan*/ constructBoard(int **, int);
int **malloc(int);
int /*<<< orphan*/ printBoard(int **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int dimension;
  int success;
  printf("What is the dimension of the board? ");
  scanf("%d", &dimension);
  printf("\n\n");
  int sizeOfInt = 0;
  int **board = malloc(sizeof(int *) * dimension);
  constructBoard(board, dimension);
  success = canPlaceQueen(board, dimension, 0);
  if (success) {
    printf("Placement was successful.\n\n");
    printBoard(board, dimension);
  } else
    printf("Placement was unsuccessful.\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xeaf(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <constructBoard@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
xor    %edx,%edx
call   1040 <canPlaceQueen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11f5 <main+0x95>
lea    0xe49(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <printBoard@plt>
jmp    1201 <main+0xa1>
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rdi
call   1060 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
lea    0xec6(%rip),%rdi
call   1050 <puts@plt>
mov    0x4(%rsp),%ebx
lea    0x0(,%rbx,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %ebx,%esi
call   1090 <constructBoard@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
xor    %edx,%edx
call   1040 <canPlaceQueen@plt>
test   %eax,%eax
je     11e6 <main+0x76>
lea    0xe72(%rip),%rdi
call   1050 <puts@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1030 <printBoard@plt>
jmp    11f2 <main+0x82>
lea    0xe3b(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"What is the dimension of the board? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [28 x i8] c"Placement was successful.\0A\0A\00"
@.str.4 = [30 x i8] c"Placement was unsuccessful.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i32** @malloc(i32 %12)
store i32** %13, i32*** %5
%14 = load i32**, i32*** %5
%15 = load i32, i32* %2
%16 = call i32 @constructBoard(i32** %14, i32 %15)
%17 = load i32**, i32*** %5
%18 = load i32, i32* %2
%19 = call i32 @canPlaceQueen(i32** %17, i32 %18, i32 0)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32**, i32*** %5
%25 = load i32, i32* %2
%26 = call i32 @printBoard(i32** %24, i32 %25)
br label %29
27: ; preds = %0
%28 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [37 x i8] c"What is the dimension of the board? \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [2 x i8] c"\0A\00"
@str.5 = [29 x i8] c"Placement was unsuccessful.\0A\00"
@str.6 = [27 x i8] c"Placement was successful.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = shl i32 %6, 3
%8 = call i32** @malloc(i32 %7)
%9 = call i32 @constructBoard(i32** %8, i32 %6)
%10 = load i32, i32* %1
%11 = call i32 @canPlaceQueen(i32** %8, i32 %10, i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = call i32 @printBoard(i32** %8, i32 %15)
br label %19
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
ret i32 0
}