#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 EXIT_SUCCESS;
int cntQueenPair(int, int **);
int /*<<< orphan*/ freeMat(int, int **);
int /*<<< orphan*/ getInt(int, int *);
int /*<<< orphan*/ getQueenPos(int, int **);
int **matAlloc(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int size, **queenPos;
  getInt(1, &size);
  queenPos = matAlloc(size * size + 1, 2);
  getQueenPos(size, queenPos);
  printf("%d", cntQueenPair(size, queenPos));
  freeMat(size * size, queenPos);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
call   1080 <getInt@plt>
mov    -0x14(%rbp),%edi
imul   -0x14(%rbp),%edi
add    $0x1,%edi
mov    $0x2,%esi
call   1050 <matAlloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <getQueenPos@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <cntQueenPair@plt>
mov    %eax,%esi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
imul   -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <freeMat@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1080 <getInt@plt>
mov    0xc(%rsp),%edi
imul   %edi,%edi
add    $0x1,%edi
mov    $0x2,%esi
call   1050 <matAlloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
mov    %rax,%rsi
call   1030 <getQueenPos@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1070 <cntQueenPair@plt>
lea    0xe56(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
imul   %edi,%edi
mov    %rbx,%rsi
call   1060 <freeMat@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @getInt(i32 1, i32* %6)
%9 = load i32, i32* %6
%10 = load i32, i32* %6
%11 = mul nsw i32 %9, %10
%12 = add nsw i32 %11, 1
%13 = call i32** @matAlloc(i32 %12, i32 2)
store i32** %13, i32*** %7
%14 = load i32, i32* %6
%15 = load i32**, i32*** %7
%16 = call i32 @getQueenPos(i32 %14, i32** %15)
%17 = load i32, i32* %6
%18 = load i32**, i32*** %7
%19 = call i32 @cntQueenPair(i32 %17, i32** %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %6
%22 = load i32, i32* %6
%23 = mul nsw i32 %21, %22
%24 = load i32**, i32*** %7
%25 = call i32 @freeMat(i32 %23, i32** %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @getInt(i32 1, i32* %3)
%6 = load i32, i32* %3
%7 = mul nsw i32 %6, %6
%8 = add nuw nsw i32 %7, 1
%9 = call i32** @matAlloc(i32 %8, i32 2)
%10 = load i32, i32* %3
%11 = call i32 @getQueenPos(i32 %10, i32** %9)
%12 = load i32, i32* %3
%13 = call i32 @cntQueenPair(i32 %12, i32** %9)
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, %15
%17 = call i32 @freeMat(i32 %16, i32** %9)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}