#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*/ TRUE;
int atoi(char *);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int *nqueens(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdscr;
int main(int argc, char *argv[]) {
  int num_queens, *positions, count;
  if (argc != 2) {
    printf("Usage: %s <number of queens (chess board order)>\n", argv[0]);
    exit(1);
  }
  num_queens = atoi(argv[1]);
  initscr();
  cbreak();
  keypad(stdscr, TRUE);
  positions = nqueens(num_queens);
  free(positions);
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11cd <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe42(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
call   1060 <keypad@plt>
mov    -0x14(%rbp),%edi
call   1080 <nqueens@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11e0 <main+0x50>
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
call   1060 <keypad@plt>
mov    %ebx,%edi
call   1080 <nqueens@plt>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1090 <endwin@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rsi),%rsi
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"Usage: %s <number of queens (chess board order)>\0A\00"
@stdscr = global i32 0
@TRUE = 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*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = call i32 (...) @initscr()
%23 = call i32 (...) @cbreak()
%24 = load i32, i32* @stdscr
%25 = load i32, i32* @TRUE
%26 = call i32 @keypad(i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = call i32* @nqueens(i32 %27)
store i32* %28, i32** %7
%29 = load i32*, i32** %7
%30 = call i32 @free(i32* %29)
%31 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"Usage: %s <number of queens (chess board order)>\0A\00"
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 (...) @initscr()
%13 = tail call i32 (...) @cbreak()
%14 = load i32, i32* @stdscr
%15 = load i32, i32* @TRUE
%16 = tail call i32 @keypad(i32 %14, i32 %15)
%17 = tail call i32* @nqueens(i32 %11)
%18 = tail call i32 @free(i32* %17)
%19 = tail call i32 (...) @endwin()
ret i32 0
}