#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 *, ...);
int /*<<< orphan*/ system(char *);
void printGrid(int grid[9][9]) {
  int x, y;
  system("cls");
  for (y = 0; y < 9; ++y) {
    for (x = 0; x < 25; ++x)
      if ((y % 3) == 0)
        printf("-");
    printf("\n");
    for (x = 0; x < 9; ++x) {
      if ((x % 3) == 0)
        printf("| ");
      if (grid[x][y] == 0)
        printf("  ");
      else if (grid[x][y] == 10)
        printf("X ");
      else
        printf("%d ", grid[x][y]);
    }
    printf("|\n");
  }
  for (x = 0; x < 25; ++x)
    printf("-");
  return;
}


x86 assembly (clang, -O0):
<printGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jge    1288 <printGrid+0x168>
movl   $0x0,-0xc(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    118f <printGrid+0x6f>
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117c <printGrid+0x5c>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1181 <printGrid+0x61>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <printGrid+0x30>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    126c <printGrid+0x14c>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d0 <printGrid+0xb0>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1200 <printGrid+0xe0>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1259 <printGrid+0x139>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0xa,(%rax,%rcx,4)
jne    1230 <printGrid+0x110>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1254 <printGrid+0x134>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1259 <printGrid+0x139>
jmp    125e <printGrid+0x13e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <printGrid+0x84>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <printGrid+0x1f>
movl   $0x0,-0xc(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    12b5 <printGrid+0x195>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    128f <printGrid+0x16f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printGrid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeab(%rip),%rdi
call   1050 <system@plt>
lea    0xea3(%rip),%r14
xor    %r12d,%r12d
jmp    118e <printGrid+0x4e>
cs nopw 0x0(%rax,%rax,1)
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r12
add    $0x4,%rbx
cmp    $0x9,%r12
je     1329 <printGrid+0x1e9>
imul   $0xaaaaaaab,%r12d,%eax
cmp    $0x55555555,%eax
ja     129a <printGrid+0x15a>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xfffffffffffffebc,%r15
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    12e0 <printGrid+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xd40(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xff,%bpl
add    $0x1,%r13b
add    $0x24,%r15
je     1170 <printGrid+0x30>
movzbl %r13b,%eax
imul   $0xab,%eax,%eax
shr    $0x9,%eax
lea    (%rax,%rax,2),%eax
add    %bpl,%al
jne    12ff <printGrid+0x1bf>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x144(%rbx,%r15,1),%esi
cmp    $0xa,%esi
je     1320 <printGrid+0x1e0>
test   %esi,%esi
je     12c0 <printGrid+0x180>
lea    0xcf6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12ce <printGrid+0x18e>
lea    0xce3(%rip),%rdi
jmp    12c7 <printGrid+0x187>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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