#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 print_2D_array(int **array, int max_size, bool debug) {
  const char QUEEN_CHAR[] = "Q";
  for (int i = 0; i < max_size; i++) {
    for (int j = 0; j < max_size; j++) {
      if (debug) {
        printf("%i  ", array[i][j]);
      } else {
        if (array[i][j] == 0) {
          printf(" %s ", QUEEN_CHAR);
        } else {
          printf(" \u2593 ");
        }
      }
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_2D_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0xed7(%rip),%ax
mov    %ax,-0x12(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f6 <print_2D_array+0xe6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11da <print_2D_array+0xca>
cmpl   $0x0,-0x10(%rbp)
je     1183 <print_2D_array+0x73>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <print_2D_array+0xb7>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11b4 <print_2D_array+0xa4>
lea    -0x12(%rbp),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <print_2D_array+0xb2>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <print_2D_array+0xb7>
jmp    11cc <print_2D_array+0xbc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <print_2D_array+0x37>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <print_2D_array+0x24>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_2D_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movw   $0x51,0x6(%rsp)
test   %esi,%esi
jle    11b8 <print_2D_array+0x98>
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %esi,%r14d
lea    0xeb7(%rip),%r13
xor    %r15d,%r15d
jmp    1163 <print_2D_array+0x43>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    %r14,%r15
je     11b8 <print_2D_array+0x98>
xor    %r12d,%r12d
jmp    1183 <print_2D_array+0x63>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r14
je     1150 <print_2D_array+0x30>
mov    (%rbx,%r15,8),%rax
mov    (%rax,%r12,4),%esi
test   %ebp,%ebp
jne    1170 <print_2D_array+0x50>
test   %esi,%esi
je     11a3 <print_2D_array+0x83>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117a <print_2D_array+0x5a>
lea    0xe5b(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117a <print_2D_array+0x5a>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%i \00"
@.str.1 = [5 x i8] c" %s \00"
@.str.2 = [6 x i8] c" \E2\96\93 \00"
define void @print_2D_array(i32** nocapture %0, i32 %1, i32 %2) {
%4 = alloca i16
%5 = bitcast i16* %4 to i8*
store i16 81, i16* %4
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = icmp eq i32 %2, 0
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %15, %7
%11 = phi i64 [ 0, %7 ], [ %17, %15 ]
%12 = getelementptr inbounds i32*, i32** %0, i64 %11
br label %19
13: ; preds = %15, %3
%14 = call i32 @putchar(i32 10)
ret void
15: ; preds = %32
%16 = call i32 @putchar(i32 10)
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %13, label %10
19: ; preds = %10, %32
%20 = phi i64 [ 0, %10 ], [ %33, %32 ]
%21 = load i32*, i32** %12
%22 = getelementptr inbounds i32, i32* %21, i64 %20
%23 = load i32, i32* %22
br i1 %8, label %26, label %24
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %32
26: ; preds = %19
%27 = icmp eq i32 %23, 0
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i16* %4)
br label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %24, %30, %28
%33 = add nuw nsw i64 %20, 1
%34 = icmp eq i64 %33, %9
br i1 %34, label %15, label %19
}