#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 */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
scalar_t__ alloca(int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ nqueens(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ usage(char *);
double wctime();
int main(int argc, char *argv[]) {
  if (1 == argc) {
    usage(argv[0]);
    exit(1);
  }
  int n = atoi(argv[1]);
  char *a = (char *)alloca(n * sizeof(char));
  printf("running queens %d sequentially...\n", n);
  double t1 = wctime();
  uint64_t res = nqueens(n, 0, a);
  double t2 = wctime();
  printf("Result: Q(%d) = %llu\n", n, res);
  printf("Time: %f\n", t2 - t1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    11aa <main+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <alloca@plt>
mov    %rax,-0x20(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1090 <wctime@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rdx
xor    %esi,%esi
call   1050 <nqueens@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1090 <wctime@plt>
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
mov    -0x2c(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
lea    0xe09(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
je     120d <main+0x9d>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <alloca@plt>
mov    %rax,%r14
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
call   1090 <wctime@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1050 <nqueens@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1090 <wctime@plt>
movsd  %xmm0,(%rsp)
lea    0xe48(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    (%rsi),%rdi
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"running queens %d sequentially...\0A\00"
@.str.1 = [22 x i8] c"Result: Q(%d) = %llu\0A\00"
@.str.2 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca double
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 1, %11
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @usage(i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 1
%27 = trunc i64 %26 to i32
%28 = call i64 @alloca(i32 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %7
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %31)
%33 = call double (...) @wctime()
store double %33, double* %8
%34 = load i32, i32* %6
%35 = load i8*, i8** %7
%36 = call i32 @nqueens(i32 %34, i32 0, i8* %35)
store i32 %36, i32* %9
%37 = call double (...) @wctime()
store double %37, double* %10
%38 = load i32, i32* %6
%39 = sitofp i32 %38 to double
%40 = load i32, i32* %9
%41 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %39, i32 %40)
%42 = load double, double* %10
%43 = load double, double* %8
%44 = fsub double %42, %43
%45 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"running queens %d sequentially...\0A\00"
@.str.1 = [22 x i8] c"Result: Q(%d) = %llu\0A\00"
@.str.2 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(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 i64 @alloca(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = sitofp i32 %11 to double
%15 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %14)
%16 = tail call double (...) @wctime()
%17 = tail call i32 @nqueens(i32 %11, i32 0, i8* %13)
%18 = tail call double (...) @wctime()
%19 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %14, i32 %17)
%20 = fsub double %18, %16
%21 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %20)
ret i32 0
}