#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ queens_arrangements(size_t);
int scanf(char *, size_t *);
int /*<<< orphan*/ stdout;
int main(void) {
  printf("Enter board size N (board is NxN)\n");
  printf("> ");
  fflush(stdout);
  size_t n;
  while (scanf("%zu", &n) == 1) {
    printf("There are %llu ways to arrange the queens.\n",
           queens_arrangements(n));
    printf("> ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xea6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11be <main+0x7e>
mov    -0x10(%rbp),%rdi
call   1050 <queens_arrangements@plt>
mov    %eax,%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1179 <main+0x39>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xe7c(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11df <main+0x8f>
lea    0xe6c(%rip),%r14
lea    0xe5e(%rip),%r15
lea    0xe5a(%rip),%r12
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    (%rsp),%rdi
call   1060 <queens_arrangements@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     11b0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter board size N (board is NxN)\0A\00"
@.str.1 = [3 x i8] c"> \00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%zu\00"
@.str.3 = [44 x i8] c"There are %llu ways to arrange the queens.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
br label %7
7: ; preds = %10, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i64, i64* %2
%12 = call i32 @queens_arrangements(i64 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %7
15: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"> \00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%zu\00"
@.str.3 = [44 x i8] c"There are %llu ways to arrange the queens.\0A\00"
@str = [34 x i8] c"Enter board size N (board is NxN)\00"
define i32 @main() {
%1 = alloca i64
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 @fflush(i32 %4)
%6 = bitcast i64* %1 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %0, %9
%10 = load i64, i64* %1
%11 = call i32 @queens_arrangements(i64 %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%15 = icmp eq i32 %14, 1
br i1 %15, label %9, label %16
16: ; preds = %9, %0
ret i32 0
}