#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 */
typedef int i;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_grid(char board[3][3]) {
  int i, j;
  printf("\n\n");
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      if (board[i][j] == '\0') {
        printf("%2d ", 3 * (i) + (j + 1));
      } else {
        printf(" %c ", board[i][j]);
      }
      if (j != 3) {
        printf("|");
      }
    }
    if (i != 3) {
      printf("\n-------------------\n");
    }
  }
}


x86 assembly (clang, -O0):
<print_grid>:
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    1206 <print_grid+0xf6>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    11db <print_grid+0xcb>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    118b <print_grid+0x7b>
imul   $0x3,-0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    %eax,%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b0 <print_grid+0xa0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x10(%rbp)
je     11c8 <print_grid+0xb8>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <print_grid+0xbd>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <print_grid+0x32>
cmpl   $0x3,-0xc(%rbp)
je     11f3 <print_grid+0xe3>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f8 <print_grid+0xe8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <print_grid+0x21>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_grid>:
push   %rbx
mov    %rdi,%rbx
lea    0xecf(%rip),%rdi
call   1040 <puts@plt>
movsbl (%rbx),%esi
test   %esi,%esi
je     1150 <print_grid+0x20>
lea    0xeb7(%rip),%rdi
jmp    115c <print_grid+0x2c>
lea    0xea9(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movsbl 0x1(%rbx),%esi
test   %esi,%esi
je     117e <print_grid+0x4e>
lea    0xe89(%rip),%rdi
jmp    118a <print_grid+0x5a>
lea    0xe7b(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movsbl 0x2(%rbx),%esi
test   %esi,%esi
je     11ac <print_grid+0x7c>
lea    0xe5b(%rip),%rdi
jmp    11b8 <print_grid+0x88>
lea    0xe4d(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
lea    0xe3c(%rip),%rdi
call   1040 <puts@plt>
movsbl 0x3(%rbx),%esi
test   %esi,%esi
je     11e6 <print_grid+0xb6>
lea    0xe21(%rip),%rdi
jmp    11f2 <print_grid+0xc2>
lea    0xe13(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movsbl 0x4(%rbx),%esi
test   %esi,%esi
je     1214 <print_grid+0xe4>
lea    0xdf3(%rip),%rdi
jmp    1220 <print_grid+0xf0>
lea    0xde5(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movsbl 0x5(%rbx),%esi
test   %esi,%esi
je     1242 <print_grid+0x112>
lea    0xdc5(%rip),%rdi
jmp    124e <print_grid+0x11e>
lea    0xdb7(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
lea    0xda6(%rip),%rdi
call   1040 <puts@plt>
movsbl 0x6(%rbx),%esi
test   %esi,%esi
je     127c <print_grid+0x14c>
lea    0xd8b(%rip),%rdi
jmp    1288 <print_grid+0x158>
lea    0xd7d(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movsbl 0x7(%rbx),%esi
test   %esi,%esi
je     12aa <print_grid+0x17a>
lea    0xd5d(%rip),%rdi
jmp    12b6 <print_grid+0x186>
lea    0xd4f(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movsbl 0x8(%rbx),%esi
test   %esi,%esi
je     12d8 <print_grid+0x1a8>
lea    0xd2f(%rip),%rdi
jmp    12e4 <print_grid+0x1b4>
lea    0xd21(%rip),%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
lea    0xd10(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

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

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