#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*/ clearScreen();
int /*<<< orphan*/ printf(char *, ...);
void printGrid(char **grid, int size) {
  int i;
  int k;
  clearScreen();
  for (i = 0; i < size; i++) {
    printf("%d\t", i);
    for (k = 0; k < size; k++) {
      printf("%c", grid[i][k]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <clearScreen@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b9 <printGrid+0x99>
mov    -0x10(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <printGrid+0x7d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <printGrid+0x41>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <printGrid+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printGrid>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r15
xor    %eax,%eax
call   1050 <clearScreen@plt>
test   %ebx,%ebx
jle    1199 <printGrid+0x69>
mov    %ebx,%r12d
lea    0xead(%rip),%r14
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebx,%ebx
nop
mov    (%r15,%r13,8),%rax
movsbl (%rax,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <printGrid+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
cmp    %r12,%r13
jne    1160 <printGrid+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @printGrid(i8** nocapture %0, i32 %1) {
%3 = tail call i32 (...) @clearScreen()
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %25
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %21, %5
%8 = phi i64 [ 0, %5 ], [ %23, %21 ]
%9 = trunc i64 %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i8*, i8** %0, i64 %8
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %19, %12 ]
%14 = load i8*, i8** %11
%15 = getelementptr inbounds i8, i8* %14, i64 %13
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = tail call i32 @putchar(i32 %17)
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %21, label %12
21: ; preds = %12
%22 = tail call i32 @putchar(i32 10)
%23 = add nuw nsw i64 %8, 1
%24 = icmp eq i64 %23, %6
br i1 %24, label %25, label %7
25: ; preds = %21, %2
ret void
}