#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 draw_board(char board[][3]) {
  int i = 0;
  int j = 0;
  printf("      1   2   3\n\n");
  for (i = 0; i < 3; i++) {
    printf(" %d    ", i + 1);
    for (j = 0; j < 3; j++) {
      printf("%c ", board[i][j]);
      if (j != 2)
        printf("| ");
    }
    printf("\n");
    if (i != 2)
      printf("    ----+---+----\n");
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<draw_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11f7 <draw_board+0xe7>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    11be <draw_board+0xae>
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    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x10(%rbp)
je     11ab <draw_board+0x9b>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b0 <draw_board+0xa0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <draw_board+0x54>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0xc(%rbp)
je     11e4 <draw_board+0xd4>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e9 <draw_board+0xd9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <draw_board+0x2f>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_board>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rbx
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb1(%rip),%r12
mov    %r12,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl (%rbx),%esi
lea    0xea0(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe93(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x1(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x2(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe66(%rip),%r13
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x3(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x5(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x6(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x7(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [8 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [3 x i8] c"| \00"
@str = [17 x i8] c" 1 2 3\0A\00"
@str.6 = [18 x i8] c" ----+---+----\00"
define void @draw_board([3 x i8]* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 0, i64 0
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 0, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 0, i64 2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 2)
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 1, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 1, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 1, i64 2
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = tail call i32 @putchar(i32 10)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 3)
%38 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 2, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%43 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 2, i64 1
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%48 = getelementptr inbounds [3 x i8], [3 x i8]* %0, i64 2, i64 2
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = tail call i32 @putchar(i32 10)
%53 = tail call i32 @putchar(i32 10)
ret void
}