#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(char *board) {
  printf("\n\n");
  int row = 0;
  for (int i = 1; i < 10; i++) {
    if (board[i - 1] == 1)
      printf(" x ");
    else if (board[i - 1] == -1)
      printf(" o ");
    else
      printf("   ");
    if (i % 3 == 0 && i != 0 && i != 9) {
      if (row == 0)
        printf("\t 0 | 1 | 2");
      if (row == 1)
        printf("\t 3 | 4 | 5");
      printf("\n-----------\t-----------\n");
      row++;
    } else if (i != 9)
      printf("|");
  }
  if (row == 2)
    printf("\t 6 | 7 | 8");
  printf("\n\n");
}


x86 assembly (clang, -O0):
<print_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1243 <print_board+0x133>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    116b <print_board+0x5b>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
jmp    11a7 <print_board+0x97>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xffffffff,%eax
jne    1196 <print_board+0x86>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11a2 <print_board+0x92>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
jmp    11a7 <print_board+0x97>
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1215 <print_board+0x105>
cmpl   $0x0,-0x10(%rbp)
je     1215 <print_board+0x105>
cmpl   $0x9,-0x10(%rbp)
je     1215 <print_board+0x105>
cmpl   $0x0,-0xc(%rbp)
jne    11e5 <print_board+0xd5>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11fb <print_board+0xeb>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1230 <print_board+0x120>
cmpl   $0x9,-0x10(%rbp)
je     122b <print_board+0x11b>
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
jmp    1230 <print_board+0x120>
jmp    1235 <print_board+0x125>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <print_board+0x26>
cmpl   $0x2,-0xc(%rbp)
jne    1259 <print_board+0x149>
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
lea    0xda0(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_board>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xeeb(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    $0xff,%bpl
mov    $0x1,%r12b
lea    0xea7(%rip),%r14
xor    %r13d,%r13d
jmp    1181 <print_board+0x51>
xchg   %ax,%ax
call   1050 <printf@plt>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r13d
add    $0xff,%bpl
add    $0x1,%r12b
add    $0x1,%rbx
movzbl (%r15,%rbx,1),%eax
lea    0xe77(%rip),%rdi
cmp    $0xff,%al
je     1198 <print_board+0x68>
lea    0xe70(%rip),%rdi
cmp    $0x1,%al
cmove  %r14,%rdi
call   1050 <printf@plt>
cmp    $0x8,%rbx
je     11e0 <print_board+0xb0>
movzbl %r12b,%eax
imul   $0xab,%eax,%eax
shr    $0x9,%eax
lea    (%rax,%rax,2),%eax
add    %bpl,%al
jne    11e0 <print_board+0xb0>
lea    0xe47(%rip),%rdi
test   %r13d,%r13d
je     1160 <print_board+0x30>
cmp    $0x1,%r13d
jne    1165 <print_board+0x35>
lea    0xe41(%rip),%rdi
jmp    1160 <print_board+0x30>
nopl   0x0(%rax)
cmp    $0x8,%rbx
je     11f2 <print_board+0xc2>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    1175 <print_board+0x45>
cmp    $0x2,%r13d
jne    1204 <print_board+0xd4>
lea    0xe25(%rip),%rdi
call   1050 <printf@plt>
lea    0xe25(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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