#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__ is_safe(int *, int, int);
int /*<<< orphan*/ putboard(int *);
void eight_queens_helper(int rows[8], int y) {
  int x;
  for (x = 0; x < 8; ++x) {
    if (is_safe(rows, x, y)) {
      rows[y] = x;
      if (y == 7)
        putboard(rows);
      else
        eight_queens_helper(rows, y + 1);
    }
  }
}


x86 assembly (clang, -O0):
<eight_queens_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    11b6 <eight_queens_helper+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <is_safe@plt>
cmp    $0x0,%rax
je     11a3 <eight_queens_helper+0x73>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
cmpl   $0x7,-0xc(%rbp)
jne    118f <eight_queens_helper+0x5f>
mov    -0x8(%rbp),%rdi
call   1050 <putboard@plt>
jmp    119e <eight_queens_helper+0x6e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
call   1040 <eight_queens_helper@plt>
jmp    11a3 <eight_queens_helper+0x73>
jmp    11a8 <eight_queens_helper+0x78>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <eight_queens_helper+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eight_queens_helper>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movslq %esi,%r14
lea    0x1(%r14),%r15d
xor    %esi,%esi
mov    %r14d,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1186 <eight_queens_helper+0x56>
movl   $0x0,(%rbx,%r14,4)
mov    %rbx,%rdi
cmp    $0x7,%r14d
jne    11b1 <eight_queens_helper+0x81>
call   1050 <putboard@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     11e0 <eight_queens_helper+0xb0>
movl   $0x1,(%rbx,%r14,4)
jmp    11a7 <eight_queens_helper+0x77>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     11e0 <eight_queens_helper+0xb0>
movl   $0x1,(%rbx,%r14,4)
cmp    $0x7,%ebp
jne    11d5 <eight_queens_helper+0xa5>
mov    %rbx,%rdi
call   1050 <putboard@plt>
jmp    11e0 <eight_queens_helper+0xb0>
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     11e0 <eight_queens_helper+0xb0>
movl   $0x1,(%rbx,%r14,4)
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1227 <eight_queens_helper+0xf7>
movl   $0x2,(%rbx,%r14,4)
mov    %rbx,%rdi
cmp    $0x7,%ebp
jne    1252 <eight_queens_helper+0x122>
call   1050 <putboard@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1281 <eight_queens_helper+0x151>
movl   $0x3,(%rbx,%r14,4)
jmp    1248 <eight_queens_helper+0x118>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1281 <eight_queens_helper+0x151>
movl   $0x3,(%rbx,%r14,4)
cmp    $0x7,%ebp
jne    1276 <eight_queens_helper+0x146>
mov    %rbx,%rdi
call   1050 <putboard@plt>
jmp    1281 <eight_queens_helper+0x151>
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1281 <eight_queens_helper+0x151>
movl   $0x3,(%rbx,%r14,4)
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     12c8 <eight_queens_helper+0x198>
movl   $0x4,(%rbx,%r14,4)
mov    %rbx,%rdi
cmp    $0x7,%ebp
jne    12f3 <eight_queens_helper+0x1c3>
call   1050 <putboard@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1322 <eight_queens_helper+0x1f2>
movl   $0x5,(%rbx,%r14,4)
jmp    12e9 <eight_queens_helper+0x1b9>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1322 <eight_queens_helper+0x1f2>
movl   $0x5,(%rbx,%r14,4)
cmp    $0x7,%ebp
jne    1317 <eight_queens_helper+0x1e7>
mov    %rbx,%rdi
call   1050 <putboard@plt>
jmp    1322 <eight_queens_helper+0x1f2>
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1322 <eight_queens_helper+0x1f2>
movl   $0x5,(%rbx,%r14,4)
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     1369 <eight_queens_helper+0x239>
movl   $0x6,(%rbx,%r14,4)
mov    %rbx,%rdi
cmp    $0x7,%ebp
jne    139c <eight_queens_helper+0x26c>
call   1050 <putboard@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     13d5 <eight_queens_helper+0x2a5>
movl   $0x7,(%rbx,%r14,4)
jmp    138a <eight_queens_helper+0x25a>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     13d5 <eight_queens_helper+0x2a5>
movl   $0x7,(%rbx,%r14,4)
cmp    $0x7,%ebp
jne    13c0 <eight_queens_helper+0x290>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <putboard@plt>
mov    %r15d,%esi
call   1040 <eight_queens_helper@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %ebp,%edx
call   1030 <is_safe@plt>
test   %rax,%rax
je     13d5 <eight_queens_helper+0x2a5>
movl   $0x7,(%rbx,%r14,4)
mov    %rbx,%rdi
mov    %r15d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <eight_queens_helper@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @eight_queens_helper(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %32, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %35
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = call i64 @is_safe(i32* %10, i32 %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %31
15: ; preds = %9
%16 = load i32, i32* %5
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %16, i32* %20
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 7
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32*, i32** %3
%25 = call i32 @putboard(i32* %24)
br label %30
26: ; preds = %15
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
br label %30
30: ; preds = %26, %23
br label %31
31: ; preds = %30, %9
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %6
35: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @eight_queens_helper(i32* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = icmp eq i32 %1, 7
%6 = add nsw i32 %1, 1
%7 = tail call i64 @is_safe(i32* %0, i32 0, i32 %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %4
br i1 %5, label %13, label %18
10: ; preds = %2
%11 = tail call i64 @is_safe(i32* %0, i32 1, i32 %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %26, label %22
13: ; preds = %9
%14 = tail call i32 @putboard(i32* %0)
%15 = tail call i64 @is_safe(i32* %0, i32 1, i32 %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %13
store i32 1, i32* %4
br label %24
18: ; preds = %9
tail call void @eight_queens_helper(i32* %0, i32 %6)
%19 = tail call i64 @is_safe(i32* %0, i32 1, i32 %1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %18
store i32 1, i32* %4
br label %23
22: ; preds = %10
store i32 1, i32* %4
br i1 %5, label %24, label %23
23: ; preds = %21, %22
tail call void @eight_queens_helper(i32* %0, i32 %6)
br label %26
24: ; preds = %17, %22
%25 = tail call i32 @putboard(i32* %0)
br label %26
26: ; preds = %13, %18, %24, %23, %10
%27 = tail call i64 @is_safe(i32* %0, i32 2, i32 %1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %26
store i32 2, i32* %4
br i1 %5, label %33, label %38
30: ; preds = %26
%31 = tail call i64 @is_safe(i32* %0, i32 3, i32 %1)
%32 = icmp eq i64 %31, 0
br i1 %32, label %46, label %42
33: ; preds = %29
%34 = tail call i32 @putboard(i32* %0)
%35 = tail call i64 @is_safe(i32* %0, i32 3, i32 %1)
%36 = icmp eq i64 %35, 0
br i1 %36, label %46, label %37
37: ; preds = %33
store i32 3, i32* %4
br label %44
38: ; preds = %29
tail call void @eight_queens_helper(i32* %0, i32 %6)
%39 = tail call i64 @is_safe(i32* %0, i32 3, i32 %1)
%40 = icmp eq i64 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %38
store i32 3, i32* %4
br label %43
42: ; preds = %30
store i32 3, i32* %4
br i1 %5, label %44, label %43
43: ; preds = %41, %42
tail call void @eight_queens_helper(i32* %0, i32 %6)
br label %46
44: ; preds = %37, %42
%45 = tail call i32 @putboard(i32* %0)
br label %46
46: ; preds = %33, %38, %44, %43, %30
%47 = tail call i64 @is_safe(i32* %0, i32 4, i32 %1)
%48 = icmp eq i64 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %46
store i32 4, i32* %4
br i1 %5, label %53, label %58
50: ; preds = %46
%51 = tail call i64 @is_safe(i32* %0, i32 5, i32 %1)
%52 = icmp eq i64 %51, 0
br i1 %52, label %66, label %62
53: ; preds = %49
%54 = tail call i32 @putboard(i32* %0)
%55 = tail call i64 @is_safe(i32* %0, i32 5, i32 %1)
%56 = icmp eq i64 %55, 0
br i1 %56, label %66, label %57
57: ; preds = %53
store i32 5, i32* %4
br label %64
58: ; preds = %49
tail call void @eight_queens_helper(i32* %0, i32 %6)
%59 = tail call i64 @is_safe(i32* %0, i32 5, i32 %1)
%60 = icmp eq i64 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %58
store i32 5, i32* %4
br label %63
62: ; preds = %50
store i32 5, i32* %4
br i1 %5, label %64, label %63
63: ; preds = %61, %62
tail call void @eight_queens_helper(i32* %0, i32 %6)
br label %66
64: ; preds = %57, %62
%65 = tail call i32 @putboard(i32* %0)
br label %66
66: ; preds = %53, %58, %64, %63, %50
%67 = tail call i64 @is_safe(i32* %0, i32 6, i32 %1)
%68 = icmp eq i64 %67, 0
br i1 %68, label %70, label %69
69: ; preds = %66
store i32 6, i32* %4
br i1 %5, label %73, label %78
70: ; preds = %66
%71 = tail call i64 @is_safe(i32* %0, i32 7, i32 %1)
%72 = icmp eq i64 %71, 0
br i1 %72, label %86, label %82
73: ; preds = %69
%74 = tail call i32 @putboard(i32* %0)
%75 = tail call i64 @is_safe(i32* %0, i32 7, i32 %1)
%76 = icmp eq i64 %75, 0
br i1 %76, label %86, label %77
77: ; preds = %73
store i32 7, i32* %4
br label %84
78: ; preds = %69
tail call void @eight_queens_helper(i32* %0, i32 %6)
%79 = tail call i64 @is_safe(i32* %0, i32 7, i32 %1)
%80 = icmp eq i64 %79, 0
br i1 %80, label %86, label %81
81: ; preds = %78
store i32 7, i32* %4
br label %83
82: ; preds = %70
store i32 7, i32* %4
br i1 %5, label %84, label %83
83: ; preds = %81, %82
tail call void @eight_queens_helper(i32* %0, i32 %6)
br label %86
84: ; preds = %77, %82
%85 = tail call i32 @putboard(i32* %0)
br label %86
86: ; preds = %73, %78, %84, %83, %70
ret void
}