#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 place_next_queen(int queens[8], int column_j, int column[8],
                      int diagonal_up[15], int diagonal_down[15]) {
  for (int row_i = 0; row_i < 8; ++row_i) {
    if (column[row_i] & diagonal_up[7 + column_j - row_i] &
        diagonal_down[column_j + row_i]) {
      queens[column_j] = row_i;
      column[row_i] = 0;
      diagonal_up[7 + column_j - row_i] = 0;
      diagonal_down[column_j + row_i] = 0;
      ++column_j;
      if (column_j == 8) {
        for (int row = 0; row < 8; ++row) {
          printf("%d ", queens[row] + 1);
        }
        printf("\n");
      } else {
        place_next_queen(queens, column_j, column, diagonal_up, diagonal_down);
      }
      --column_j;
      diagonal_down[column_j + row_i] = 1;
      diagonal_up[7 + column_j - row_i] = 1;
      column[row_i] = 1;
    }
  }
}


x86 assembly (clang, -O0):
<place_next_queen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    129a <place_next_queen+0x17a>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x20(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x7,%edx
sub    -0x2c(%rbp),%edx
movslq %edx,%rdx
and    (%rcx,%rdx,4),%eax
mov    -0x28(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    -0x2c(%rbp),%edx
movslq %edx,%rdx
and    (%rcx,%rdx,4),%eax
cmp    $0x0,%eax
je     1287 <place_next_queen+0x167>
mov    -0x2c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x7,%ecx
sub    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jne    122c <place_next_queen+0x10c>
movl   $0x0,-0x30(%rbp)
cmpl   $0x8,-0x30(%rbp)
jge    1219 <place_next_queen+0xf9>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
add    $0x1,%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11e5 <place_next_queen+0xc5>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <place_next_queen+0x124>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <place_next_queen@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x28(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x7,%ecx
sub    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    128c <place_next_queen+0x16c>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1142 <place_next_queen+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<place_next_queen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r12
mov    %rdi,%rbx
movslq %esi,%rax
lea    0x1(%rax),%edx
mov    %rcx,0x10(%rsp)
lea    0x1c(%rcx,%rax,4),%r15
mov    %r8,0x18(%rsp)
mov    %rax,0x20(%rsp)
lea    (%r8,%rax,4),%r14
lea    0xe97(%rip),%rbp
xor    %r13d,%r13d
mov    %edx,0xc(%rsp)
jmp    11c6 <place_next_queen+0x96>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
mov    %r12,%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
call   1050 <place_next_queen@plt>
mov    0xc(%rsp),%edx
movl   $0x1,(%r14,%r13,4)
movl   $0x1,(%r15)
movl   $0x1,(%r12,%r13,4)
add    $0x1,%r13
add    $0xfffffffffffffffc,%r15
cmp    $0x8,%r13
je     1286 <place_next_queen+0x156>
mov    (%r15),%eax
and    (%r12,%r13,4),%eax
test   %eax,(%r14,%r13,4)
je     11b4 <place_next_queen+0x84>
mov    0x20(%rsp),%rax
mov    %r13d,(%rbx,%rax,4)
movl   $0x0,(%r12,%r13,4)
movl   $0x0,(%r15)
movl   $0x0,(%r14,%r13,4)
cmp    $0x8,%edx
jne    1180 <place_next_queen+0x50>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rbx),%esi
add    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1199 <place_next_queen+0x69>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @place_next_queen(i32* %0, i32 %1, i32* %2, i32* %3, i32* %4) {
%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** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
store i32 0, i32* %11
br label %13
13: ; preds = %111, %5
%14 = load i32, i32* %11
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %114
16: ; preds = %13
%17 = load i32*, i32** %8
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32*, i32** %9
%23 = load i32, i32* %7
%24 = add nsw i32 7, %23
%25 = load i32, i32* %11
%26 = sub nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %22, i64 %27
%29 = load i32, i32* %28
%30 = and i32 %21, %29
%31 = load i32*, i32** %10
%32 = load i32, i32* %7
%33 = load i32, i32* %11
%34 = add nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %31, i64 %35
%37 = load i32, i32* %36
%38 = and i32 %30, %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %110
40: ; preds = %16
%41 = load i32, i32* %11
%42 = load i32*, i32** %6
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 %41, i32* %45
%46 = load i32*, i32** %8
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
store i32 0, i32* %49
%50 = load i32*, i32** %9
%51 = load i32, i32* %7
%52 = add nsw i32 7, %51
%53 = load i32, i32* %11
%54 = sub nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %50, i64 %55
store i32 0, i32* %56
%57 = load i32*, i32** %10
%58 = load i32, i32* %7
%59 = load i32, i32* %11
%60 = add nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %57, i64 %61
store i32 0, i32* %62
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
%65 = load i32, i32* %7
%66 = icmp eq i32 %65, 8
br i1 %66, label %67, label %84
67: ; preds = %40
store i32 0, i32* %12
br label %68
68: ; preds = %79, %67
%69 = load i32, i32* %12
%70 = icmp slt i32 %69, 8
br i1 %70, label %71, label %82
71: ; preds = %68
%72 = load i32*, i32** %6
%73 = load i32, i32* %12
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
%77 = add nsw i32 %76, 1
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %71
%80 = load i32, i32* %12
%81 = add nsw i32 %80, 1
store i32 %81, i32* %12
br label %68
82: ; preds = %68
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %90
84: ; preds = %40
%85 = load i32*, i32** %6
%86 = load i32, i32* %7
%87 = load i32*, i32** %8
%88 = load i32*, i32** %9
%89 = load i32*, i32** %10
br label %90
90: ; preds = %84, %82
%91 = load i32, i32* %7
%92 = add nsw i32 %91, -1
store i32 %92, i32* %7
%93 = load i32*, i32** %10
%94 = load i32, i32* %7
%95 = load i32, i32* %11
%96 = add nsw i32 %94, %95
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %93, i64 %97
store i32 1, i32* %98
%99 = load i32*, i32** %9
%100 = load i32, i32* %7
%101 = add nsw i32 7, %100
%102 = load i32, i32* %11
%103 = sub nsw i32 %101, %102
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32, i32* %99, i64 %104
store i32 1, i32* %105
%106 = load i32*, i32** %8
%107 = load i32, i32* %11
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i32, i32* %106, i64 %108
store i32 1, i32* %109
br label %110
110: ; preds = %90, %16
br label %111
111: ; preds = %110
%112 = load i32, i32* %11
%113 = add nsw i32 %112, 1
store i32 %113, i32* %11
br label %13
114: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @place_next_queen(i32* nocapture %0, i32 %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture %4) {
%6 = add nsw i32 %1, 7
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = add nsw i32 %1, 1
%10 = icmp eq i32 %9, 8
%11 = sext i32 %6 to i64
%12 = getelementptr inbounds i32, i32* %0, i64 1
%13 = getelementptr inbounds i32, i32* %0, i64 2
%14 = getelementptr inbounds i32, i32* %0, i64 3
%15 = getelementptr inbounds i32, i32* %0, i64 4
%16 = getelementptr inbounds i32, i32* %0, i64 5
%17 = getelementptr inbounds i32, i32* %0, i64 6
%18 = getelementptr inbounds i32, i32* %0, i64 7
br label %20
19: ; preds = %63
ret void
20: ; preds = %5, %63
%21 = phi i64 [ 0, %5 ], [ %64, %63 ]
%22 = getelementptr inbounds i32, i32* %2, i64 %21
%23 = load i32, i32* %22
%24 = sub nsw i64 %11, %21
%25 = getelementptr inbounds i32, i32* %3, i64 %24
%26 = load i32, i32* %25
%27 = and i32 %26, %23
%28 = add nsw i64 %21, %7
%29 = getelementptr inbounds i32, i32* %4, i64 %28
%30 = load i32, i32* %29
%31 = and i32 %27, %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %63, label %33
33: ; preds = %20
%34 = trunc i64 %21 to i32
store i32 %34, i32* %8
store i32 0, i32* %22
store i32 0, i32* %25
store i32 0, i32* %29
br i1 %10, label %35, label %61
35: ; preds = %33
%36 = load i32, i32* %0
%37 = add nsw i32 %36, 1
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %12
%40 = add nsw i32 %39, 1
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %13
%43 = add nsw i32 %42, 1
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %14
%46 = add nsw i32 %45, 1
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %15
%49 = add nsw i32 %48, 1
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %16
%52 = add nsw i32 %51, 1
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %17
%55 = add nsw i32 %54, 1
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %18
%58 = add nsw i32 %57, 1
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %58)
%60 = tail call i32 @putchar(i32 10)
br label %62
61: ; preds = %33
tail call void @place_next_queen(i32* %0, i32 %9, i32* %2, i32* %3, i32* %4)
br label %62
62: ; preds = %61, %35
store i32 1, i32* %29
store i32 1, i32* %25
store i32 1, i32* %22
br label %63
63: ; preds = %20, %62
%64 = add nuw nsw i64 %21, 1
%65 = icmp eq i64 %64, 8
br i1 %65, label %19, label %20
}