#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 */
scalar_t__ KEY_F(int);
scalar_t__ LINES;
int /*<<< orphan*/ board(int /*<<< orphan*/, int, int, int, int, int, int);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ getch();
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ mvprintw(scalar_t__, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int print(int *positions, int num_queens) {
  int count;
  int y = 2, x = 2, w = 4, h = 2;
  static int solution = 1;
  mvprintw(0, 0, "Solution No: %d", solution++);
  board(stdscr, y, x, num_queens, num_queens, w, h);
  for (count = 1; count <= num_queens; ++count) {
    int tempy = y + (count - 1) * h + h / 2;
    int tempx = x + (positions[count] - 1) * w + w / 2;
    mvaddch(tempy, tempx, '*');
  }
  refresh();
  mvprintw(LINES - 2, 0, "Press Any Key to See next solution (F1 to Exit)");
  if (getch() == KEY_F(1)) {
    endwin();
    exit(0);
  }
  clear();
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
mov    0x2ea7(%rip),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,0x2e9c(%rip)
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xe27(%rip),%rdx
mov    $0x0,%al
call   10b0 <mvprintw@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x28(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <board@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     128c <print+0xfc>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
sub    $0x1,%ecx
imul   -0x24(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    $0x2a,%edx
call   1080 <mvaddch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120c <print+0x7c>
mov    $0x0,%al
call   1050 <refresh@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
xor    %esi,%esi
lea    0xd66(%rip),%rdx
mov    $0x0,%al
call   10b0 <mvprintw@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    %rax,-0x40(%rbp)
mov    $0x1,%edi
call   1030 <KEY_F@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jne    12e4 <print+0x154>
mov    $0x0,%al
call   1070 <endwin@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   10a0 <clear@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x2ec5(%rip),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0x2ebc(%rip)
lea    0xe4d(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10b0 <mvprintw@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
movl   $0x2,(%rsp)
mov    $0x2,%esi
mov    $0x2,%edx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    $0x4,%r9d
call   1040 <board@plt>
test   %ebp,%ebp
jle    121d <print+0x8d>
mov    %ebp,%eax
lea    (%rax,%rax,1),%rbp
add    $0x2,%rbp
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,2),%esi
shl    $0x2,%esi
lea    0x1(%rbx),%edi
mov    $0x2a,%edx
call   1080 <mvaddch@plt>
add    $0x2,%rbx
cmp    %rbx,%rbp
jne    1200 <print+0x70>
xor    %eax,%eax
call   1050 <refresh@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xdd7(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10b0 <mvprintw@plt>
xor    %eax,%eax
call   1060 <getch@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1030 <KEY_F@plt>
cmp    %rax,%rbx
je     126a <print+0xda>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    10a0 <clear@plt>
xor    %eax,%eax
call   1070 <endwin@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@print.solution = internal global i32 1
@.str = [16 x i8] c"Solution No: %d\00"
@stdscr = global i32 0
@LINES = global i64 0
@.str.1 = [48 x i8] c"Press Any Key to See next solution (F1 to Exit)\00"
define i32 @print(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 2, i32* %7
store i32 2, i32* %8
store i32 4, i32* %9
store i32 2, i32* %10
%13 = load i32, i32* @print.solution
%14 = add nsw i32 %13, 1
store i32 %14, i32* @print.solution
%15 = call i32 (i64, i32, i8*, ...) @mvprintw(i64 0, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = load i32, i32* @stdscr
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = load i32, i32* %5
%20 = load i32, i32* %5
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = call i32 @board(i32 %16, i32 %17, i32 %18, i32 %19, i32 %20, i32 %21, i32 %22)
store i32 1, i32* %6
br label %24
24: ; preds = %54, %2
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %57
28: ; preds = %24
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = sub nsw i32 %30, 1
%32 = load i32, i32* %10
%33 = mul nsw i32 %31, %32
%34 = add nsw i32 %29, %33
%35 = load i32, i32* %10
%36 = sdiv i32 %35, 2
%37 = add nsw i32 %34, %36
store i32 %37, i32* %11
%38 = load i32, i32* %8
%39 = load i32*, i32** %4
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = sub nsw i32 %43, 1
%45 = load i32, i32* %9
%46 = mul nsw i32 %44, %45
%47 = add nsw i32 %38, %46
%48 = load i32, i32* %9
%49 = sdiv i32 %48, 2
%50 = add nsw i32 %47, %49
store i32 %50, i32* %12
%51 = load i32, i32* %11
%52 = load i32, i32* %12
%53 = call i32 @mvaddch(i32 %51, i32 %52, i8 signext 42)
br label %54
54: ; preds = %28
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %24
57: ; preds = %24
%58 = call i32 (...) @refresh()
%59 = load i64, i64* @LINES
%60 = sub nsw i64 %59, 2
%61 = call i32 (i64, i32, i8*, ...) @mvprintw(i64 %60, i32 0, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%62 = call i64 (...) @getch()
%63 = call i64 @KEY_F(i32 1)
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %68
65: ; preds = %57
%66 = call i32 (...) @endwin()
%67 = call i32 @exit(i32 0)
unreachable
68: ; preds = %57
%69 = call i32 (...) @clear()
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@print.solution = internal unnamed_addr global i32 1
@.str = [16 x i8] c"Solution No: %d\00"
@stdscr = global i32 0
@LINES = global i64 0
@.str.1 = [48 x i8] c"Press Any Key to See next solution (F1 to Exit)\00"
define i32 @print(i32* nocapture %0, i32 %1) {
%3 = load i32, i32* @print.solution
%4 = add nsw i32 %3, 1
store i32 %4, i32* @print.solution
%5 = tail call i32 (i64, i32, i8*, ...) @mvprintw(i64 0, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3)
%6 = load i32, i32* @stdscr
%7 = tail call i32 @board(i32 %6, i32 2, i32 2, i32 %1, i32 %1, i32 4, i32 2)
%8 = icmp slt i32 %1, 1
br i1 %8, label %23, label %9
9: ; preds = %2
%10 = add nuw i32 %1, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 1, %9 ], [ %21, %12 ]
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = shl i32 %15, 2
%17 = trunc i64 %13 to i32
%18 = shl i32 %17, 1
%19 = or i32 %18, 1
%20 = tail call i32 @mvaddch(i32 %19, i32 %16, i8 signext 42)
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %11
br i1 %22, label %23, label %12
23: ; preds = %12, %2
%24 = tail call i32 (...) @refresh()
%25 = load i64, i64* @LINES
%26 = add nsw i64 %25, -2
%27 = tail call i32 (i64, i32, i8*, ...) @mvprintw(i64 %26, i32 0, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i64 (...) @getch()
%29 = tail call i64 @KEY_F(i32 1)
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = tail call i32 (...) @endwin()
%33 = tail call i32 @exit(i32 0)
unreachable
34: ; preds = %23
%35 = tail call i32 (...) @clear()
ret i32 undef
}