#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_grid(int array[]) {
  int i = 0;
  int *p = array;
  while (p < &array[81]) {
    i++;
    if (*p == 0) {
      printf("_ ");
      p++;
    } else
      printf("%i ", *p++);
    if ((i % 9) == 0)
      printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_grid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x144,%rcx
cmp    %rcx,%rax
jae    11be <print_grid+0xae>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1178 <print_grid+0x68>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    1197 <print_grid+0x87>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b9 <print_grid+0xa9>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112b <print_grid+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_grid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    $0x1,%ebp
lea    0xec6(%rip),%r14
lea    0xec2(%rip),%r15
xor    %ebx,%ebx
jmp    115c <print_grid+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
mov    %r13,%rbx
cmp    $0x51,%r13
je     11a3 <print_grid+0x83>
mov    %ebp,%eax
imul   $0x38e38e39,%rax,%r13
shr    $0x21,%r13
mov    (%r12,%rbx,4),%esi
test   %esi,%esi
je     1180 <print_grid+0x60>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118a <print_grid+0x6a>
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%r13,%r13,8),%eax
lea    0x1(%rbx),%r13
cmp    %ebx,%eax
jne    1150 <print_grid+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <print_grid+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"_ \00"
@.str.1 = [4 x i8] c"%i \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_grid(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
store i32* %0, i32** %2
store i32 0, i32* %3
%5 = load i32*, i32** %2
store i32* %5, i32** %4
br label %6
6: ; preds = %32, %1
%7 = load i32*, i32** %4
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 81
%10 = icmp ult i32* %7, %9
br i1 %10, label %11, label %33
11: ; preds = %6
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = load i32*, i32** %4
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %4
br label %26
21: ; preds = %11
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %4
%24 = load i32, i32* %22
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %17
%27 = load i32, i32* %3
%28 = srem i32 %27, 9
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
br label %6
33: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"_ \00"
@.str.1 = [4 x i8] c"%i \00"
define void @print_grid(i32* nocapture %0) {
br label %2
2: ; preds = %1, %18
%3 = phi i64 [ 0, %1 ], [ %5, %18 ]
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = add nuw nsw i64 %3, 1
%6 = trunc i64 %5 to i32
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
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))
br label %13
11: ; preds = %2
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %13
13: ; preds = %11, %9
%14 = urem i32 %6, 9
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @putchar(i32 10)
br label %18
18: ; preds = %16, %13
%19 = icmp eq i64 %5, 81
br i1 %19, label %20, label %2
20: ; preds = %18
ret void
}