#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*/ printf(char *, ...);
void putboard(int rows[8]) {
  static int s = 0;
  int x, y;
  printf("\nSolution #%d:\n---------------------------------\n", ++s);
  for (y = 0; y < 8; ++y) {
    for (x = 0; x < 8; ++x)
      printf(x == rows[y] ? "| Q " : "|   ");
    printf("|\n---------------------------------\n");
  }
}


x86 assembly (clang, -O0):
<putboard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2f0a(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2f01(%rip)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    11ae <putboard+0x9e>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1192 <putboard+0x82>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
mov    (%rax,%rdx,4),%edx
lea    0xec7(%rip),%rdi
lea    0xebb(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <putboard+0x41>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <putboard+0x30>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putboard>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r13
mov    0x2f02(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2ef9(%rip)
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee2(%rip),%r15
lea    0xee0(%rip),%r12
lea    0xede(%rip),%r14
xor    %ebx,%ebx
cmpl   $0x0,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x1,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x2,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x3,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x4,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x5,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x6,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x7,0x0(%r13,%rbx,4)
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0x1,%rbx
cmp    $0x8,%rbx
jne    1160 <putboard+0x40>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@putboard.s = internal global i32 0
@.str = [50 x i8] c"\0ASolution #%d:\0A---------------------------------\0A\00"
@.str.1 = [5 x i8] c"| Q \00"
@.str.2 = [5 x i8] c"| \00"
@.str.3 = [37 x i8] c"|\0A---------------------------------\0A\00"
define void @putboard(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32, i32* @putboard.s
%6 = add nsw i32 %5, 1
store i32 %6, i32* @putboard.s
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %4
br label %8
8: ; preds = %31, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %34
11: ; preds = %8
store i32 0, i32* %3
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i32, i32* %3
%17 = load i32*, i32** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %16, %21
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%25 = call i32 (i8*, ...) @printf(i8* %24)
br label %26
26: ; preds = %15
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %8
34: ; preds = %8
ret void
}

LLVM IR (-O2):
@putboard.s = internal unnamed_addr global i32 0
@.str = [50 x i8] c"\0ASolution #%d:\0A---------------------------------\0A\00"
@.str.1 = [5 x i8] c"| Q \00"
@.str.2 = [5 x i8] c"| \00"
@str = [36 x i8] c"|\0A---------------------------------\00"
define void @putboard(i32* nocapture %0) {
%2 = load i32, i32* @putboard.s
%3 = add nsw i32 %2, 1
store i32 %3, i32* @putboard.s
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %5
5: ; preds = %1, %5
%6 = phi i64 [ 0, %1 ], [ %41, %5 ]
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10)
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 1
%14 = select i1 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14)
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 2
%18 = select i1 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %18)
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 3
%22 = select i1 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22)
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 4
%26 = select i1 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %26)
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, 5
%30 = select i1 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %30)
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 6
%34 = select i1 %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34)
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 7
%38 = select i1 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %38)
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%41 = add nuw nsw i64 %6, 1
%42 = icmp eq i64 %41, 8
br i1 %42, label %43, label %5
43: ; preds = %5
ret void
}