#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__ can_place_opt(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void place_opt(int *array, int row) {
  if (row == 8) {
    for (int i = 0; i < 8; i++) {
      printf("%d ", array[i]);
    }
    printf("\n\n");
    return;
  }
  for (int col = 0; col < 8; col++) {
    if (can_place_opt(array, row, col)) {
      array[row] = col;
      place_opt(array, row + 1);
    }
  }
}


x86 assembly (clang, -O0):
<place_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jne    1194 <place_opt+0x64>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    1181 <place_opt+0x51>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1150 <place_opt+0x20>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ee <place_opt+0xbe>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11ee <place_opt+0xbe>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <can_place_opt@plt>
cmp    $0x0,%rax
je     11db <place_opt+0xab>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
call   1030 <place_opt@plt>
jmp    11e0 <place_opt+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <place_opt+0x6b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<place_opt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0x8,%esi
jne    11d7 <place_opt+0x97>
mov    (%rbx),%esi
lea    0xea4(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3c(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    %esi,%ebp
movslq %esi,%r15
lea    0x1(%rbp),%r14d
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     1202 <place_opt+0xc2>
movl   $0x0,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     1229 <place_opt+0xe9>
movl   $0x1,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     1250 <place_opt+0x110>
movl   $0x2,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     1277 <place_opt+0x137>
movl   $0x3,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     129e <place_opt+0x15e>
movl   $0x4,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x5,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     12c5 <place_opt+0x185>
movl   $0x5,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x6,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     12ec <place_opt+0x1ac>
movl   $0x6,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <place_opt@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x7,%edx
call   1060 <can_place_opt@plt>
test   %rax,%rax
je     131d <place_opt+0x1dd>
movl   $0x7,(%rbx,%r15,4)
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <place_opt@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define void @place_opt(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 8
br i1 %8, label %9, label %25
9: ; preds = %2
store i32 0, i32* %5
br label %10
10: ; preds = %20, %9
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32*, i32** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %10
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %48
25: ; preds = %2
store i32 0, i32* %6
br label %26
26: ; preds = %45, %25
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 8
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = load i32*, i32** %3
%31 = load i32, i32* %4
%32 = load i32, i32* %6
%33 = call i64 @can_place_opt(i32* %30, i32 %31, i32 %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %44
35: ; preds = %29
%36 = load i32, i32* %6
%37 = load i32*, i32** %3
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %36, i32* %40
%41 = load i32*, i32** %3
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
br label %44
44: ; preds = %35, %29
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %26
48: ; preds = %23, %26
ret void
}

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