#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_board(int **board) {
  int i, j;
  printf(" 0 1 2\n");
  for (i = 0; i < 3; i++) {
    printf("%d", i);
    for (j = 0; j < 3; j++) {
      if (board[i][j] == 'O')
        printf("O");
      if (board[i][j] == 'X')
        printf("X");
      if (board[i][j] != 'O' && board[i][j] != 'X')
        printf(" ");
      printf("|");
    }
    printf(" %d\n", i);
  }
  printf(" 0 1 2\n");
}


x86 assembly (clang, -O0):
<print_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    122a <print_board+0x11a>
mov    -0xc(%rbp),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    120b <print_board+0xfb>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x4f,(%rax,%rcx,4)
jne    1185 <print_board+0x75>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x58,(%rax,%rcx,4)
jne    11ad <print_board+0x9d>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x4f,(%rax,%rcx,4)
je     11ef <print_board+0xdf>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x58,(%rax,%rcx,4)
je     11ef <print_board+0xdf>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <print_board+0x43>
mov    -0xc(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <print_board+0x21>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_board>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb2(%rip),%r14
lea    0xeae(%rip),%r15
xor    %ebx,%ebx
jmp    1184 <print_board+0x54>
nopl   0x0(%rax)
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x3,%rbx
je     12b8 <print_board+0x188>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12,%rbx,8),%rax
mov    (%rax),%eax
cmp    $0x4f,%eax
je     11b0 <print_board+0x80>
cmp    $0x58,%eax
je     11c5 <print_board+0x95>
cmp    $0x4f,%eax
jne    11da <print_board+0xaa>
jmp    11e9 <print_board+0xb9>
nopw   0x0(%rax,%rax,1)
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    (%rax),%eax
cmp    $0x58,%eax
jne    11a0 <print_board+0x70>
mov    $0x58,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    (%rax),%eax
cmp    $0x4f,%eax
je     11e9 <print_board+0xb9>
cmp    $0x58,%eax
je     11e9 <print_board+0xb9>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    0x4(%rax),%eax
cmp    $0x4f,%eax
je     1210 <print_board+0xe0>
cmp    $0x58,%eax
je     1226 <print_board+0xf6>
cmp    $0x4f,%eax
jne    123c <print_board+0x10c>
jmp    124b <print_board+0x11b>
nopl   0x0(%rax,%rax,1)
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    0x4(%rax),%eax
cmp    $0x58,%eax
jne    1204 <print_board+0xd4>
mov    $0x58,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    0x4(%rax),%eax
cmp    $0x4f,%eax
je     124b <print_board+0x11b>
cmp    $0x58,%eax
je     124b <print_board+0x11b>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    0x8(%rax),%eax
cmp    $0x4f,%eax
je     1270 <print_board+0x140>
cmp    $0x58,%eax
je     1286 <print_board+0x156>
cmp    $0x4f,%eax
jne    12a0 <print_board+0x170>
jmp    1160 <print_board+0x30>
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    0x8(%rax),%eax
cmp    $0x58,%eax
jne    1266 <print_board+0x136>
mov    $0x58,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,8),%rax
mov    0x8(%rax),%eax
cmp    $0x4f,%eax
je     1160 <print_board+0x30>
cmp    $0x58,%eax
je     1160 <print_board+0x30>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1160 <print_board+0x30>
lea    0xd49(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

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

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