#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 printBoard(int **board, int board_size) {
  int i, j;
  char player1 = 'O';
  char player2 = 'X';
  char empty = '-';
  printf("\n");
  for (i = 0; i < board_size; i++) {
    for (j = 0; j < board_size; j++) {
      if (board[i][j] == 1)
        printf("%c ", player1);
      else if (board[i][j] == 2)
        printf("%c ", player2);
      else if (board[i][j] == 0)
        printf("%c ", empty);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x4f,-0x15(%rbp)
movb   $0x58,-0x16(%rbp)
movb   $0x2d,-0x17(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1226 <printBoard+0x116>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120a <printBoard+0xfa>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1190 <printBoard+0x80>
movsbl -0x15(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <printBoard+0xe7>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x2,(%rax,%rcx,4)
jne    11c1 <printBoard+0xb1>
movsbl -0x16(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <printBoard+0xe2>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11ed <printBoard+0xdd>
movsbl -0x17(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <printBoard+0xe2>
jmp    11f7 <printBoard+0xe7>
jmp    11fc <printBoard+0xec>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <printBoard+0x43>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <printBoard+0x30>
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
mov    %esi,%ebp
mov    %rdi,%r12
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    11a7 <printBoard+0x87>
mov    %ebp,%r13d
lea    0xebc(%rip),%r15
lea    0xeb1(%rip),%r14
xor    %ebx,%ebx
jmp    1173 <printBoard+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r13,%rbx
je     11a7 <printBoard+0x87>
xor    %ebp,%ebp
jmp    1189 <printBoard+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r13
je     1160 <printBoard+0x40>
mov    (%r12,%rbx,8),%rax
movslq (%rax,%rbp,4),%rax
cmp    $0x2,%rax
ja     1180 <printBoard+0x60>
mov    (%r15,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <printBoard+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%c \00"
@switch.table.printBoard = [3 x i32] [i32 45, i32 79, i32 88]
define void @printBoard(i32** nocapture %0, i32 %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %28
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %24, %5
%8 = phi i64 [ 0, %5 ], [ %26, %24 ]
%9 = getelementptr inbounds i32*, i32** %0, i64 %8
br label %10
10: ; preds = %7, %21
%11 = phi i64 [ 0, %7 ], [ %22, %21 ]
%12 = load i32*, i32** %9
%13 = getelementptr inbounds i32, i32* %12, i64 %11
%14 = load i32, i32* %13
%15 = icmp ult i32 %14, 3
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = sext i32 %14 to i64
%18 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.printBoard, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %10, %16
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %6
br i1 %23, label %24, label %10
24: ; preds = %21
%25 = tail call i32 @putchar(i32 10)
%26 = add nuw nsw i64 %8, 1
%27 = icmp eq i64 %26, %6
br i1 %27, label %28, label %7
28: ; preds = %24, %2
ret void
}