#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 printGrid(int grid[]) {
  for (int y = 0; y < 9; y++) {
    for (int x = 0; x < 9; x++) {
      if (grid[x + y * 9]) {
        printf("%i", grid[x + y * 9]);
      } else {
        printf(" ");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    11bb <printGrid+0xab>
movl   $0x0,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jge    119f <printGrid+0x8f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   $0x9,-0xc(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     117e <printGrid+0x6e>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   $0x9,-0xc(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118c <printGrid+0x7c>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1191 <printGrid+0x81>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <printGrid+0x24>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <printGrid+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printGrid>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x20,%ebx
lea    0xecc(%rip),%r14
jmp    1165 <printGrid+0x45>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x24,%rbx
cmp    $0x164,%rbx
je     1285 <printGrid+0x165>
mov    -0x20(%r15,%rbx,1),%esi
test   %esi,%esi
je     1180 <printGrid+0x60>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118a <printGrid+0x6a>
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x1c(%r15,%rbx,1),%esi
test   %esi,%esi
je     11a0 <printGrid+0x80>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11aa <printGrid+0x8a>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x18(%r15,%rbx,1),%esi
test   %esi,%esi
je     11c0 <printGrid+0xa0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ca <printGrid+0xaa>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x14(%r15,%rbx,1),%esi
test   %esi,%esi
je     11e0 <printGrid+0xc0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ea <printGrid+0xca>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%r15,%rbx,1),%esi
test   %esi,%esi
je     1200 <printGrid+0xe0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120a <printGrid+0xea>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0xc(%r15,%rbx,1),%esi
test   %esi,%esi
je     1220 <printGrid+0x100>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122a <printGrid+0x10a>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%r15,%rbx,1),%esi
test   %esi,%esi
je     1240 <printGrid+0x120>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    124a <printGrid+0x12a>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x4(%r15,%rbx,1),%esi
test   %esi,%esi
je     1260 <printGrid+0x140>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    126a <printGrid+0x14a>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,1),%esi
test   %esi,%esi
je     1140 <printGrid+0x20>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    114a <printGrid+0x2a>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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