#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 get(int **, int, int);
int /*<<< orphan*/ printf(char *);
void printBoard(int **board, int dimension) {
  int i, j;
  for (i = 0; i <= dimension; i++) {
    printf("--");
  }
  printf("\n");
  for (i = 0; i < dimension; i++) {
    printf("|");
    for (j = 0; j < dimension; j++) {
      int value = get(board, i, j);
      if (value == 0) {
        printf(" .");
      } else if (value == 1) {
        printf(" Q");
      }
    }
    printf("|\n");
  }
  for (i = 0; i <= dimension; i++) {
    printf("--");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     115c <printBoard+0x3c>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <printBoard+0x16>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120f <printBoard+0xef>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f5 <printBoard+0xd5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <get@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11c7 <printBoard+0xa7>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
jmp    11e2 <printBoard+0xc2>
cmpl   $0x1,-0x18(%rbp)
jne    11dd <printBoard+0xbd>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    11e2 <printBoard+0xc2>
jmp    11e7 <printBoard+0xc7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <printBoard+0x6e>
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <printBoard+0x4f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     123c <printBoard+0x11c>
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1216 <printBoard+0xf6>
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBoard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
js     1230 <printBoard+0xf0>
mov    %esi,%r12d
mov    %rdi,%r14
mov    $0xffffffff,%ebp
lea    0xe9b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1170 <printBoard+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r12d,%r12d
jle    120a <printBoard+0xca>
xor    %ebp,%ebp
lea    0xe6b(%rip),%r13
lea    0xe67(%rip),%r15
jmp    11c4 <printBoard+0x84>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
je     120a <printBoard+0xca>
mov    $0x7c,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    11ed <printBoard+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r12d
je     11b0 <printBoard+0x70>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1060 <get@plt>
mov    %r13,%rdi
test   %eax,%eax
je     11e0 <printBoard+0xa0>
cmp    $0x1,%eax
jne    11e5 <printBoard+0xa5>
mov    %r15,%rdi
jmp    11e0 <printBoard+0xa0>
test   %r12d,%r12d
js     123a <printBoard+0xfa>
add    $0x1,%r12d
lea    0xde6(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <printf@plt>
add    $0xffffffff,%r12d
jne    1220 <printBoard+0xe0>
jmp    123a <printBoard+0xfa>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"--\00"
@.str.3 = [3 x i8] c" .\00"
@.str.4 = [3 x i8] c" Q\00"
@str = [2 x i8] c"|\00"
define void @printBoard(i32** %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @putchar(i32 10)
br label %37
6: ; preds = %2, %6
%7 = phi i32 [ %9, %6 ], [ 0, %2 ]
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = add nuw i32 %7, 1
%10 = icmp eq i32 %7, %1
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = tail call i32 @putchar(i32 10)
%13 = icmp sgt i32 %1, 0
br i1 %13, label %15, label %14
14: ; preds = %28, %11
br i1 %3, label %37, label %32
15: ; preds = %11, %28
%16 = phi i32 [ %30, %28 ], [ 0, %11 ]
%17 = tail call i32 @putchar(i32 124)
br label %18
18: ; preds = %15, %25
%19 = phi i32 [ %26, %25 ], [ 0, %15 ]
%20 = tail call i32 @get(i32** %0, i32 %16, i32 %19)
switch i32 %20, label %25 [
i32 0, label %22
i32 1, label %21
]
21: ; preds = %18
br label %22
22: ; preds = %18, %21
%23 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %21 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %18 ]
%24 = tail call i32 @printf(i8* dereferenceable(1) %23)
br label %25
25: ; preds = %22, %18
%26 = add nuw nsw i32 %19, 1
%27 = icmp eq i32 %26, %1
br i1 %27, label %28, label %18
28: ; preds = %25
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%30 = add nuw nsw i32 %16, 1
%31 = icmp eq i32 %30, %1
br i1 %31, label %14, label %15
32: ; preds = %14, %32
%33 = phi i32 [ %35, %32 ], [ 0, %14 ]
%34 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%35 = add nuw i32 %33, 1
%36 = icmp eq i32 %33, %1
br i1 %36, label %37, label %32
37: ; preds = %32, %4, %14
%38 = tail call i32 @putchar(i32 10)
ret void
}