#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 printBoard(unsigned char *a, unsigned int rows, unsigned int cols) {
  unsigned int j = 0;
  unsigned int k = 0;
  for (j = 0; j <= rows; j++) {
    for (k = 0; k <= cols; k++) {
      printf("%c ", a[j * cols + k]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     11a2 <printBoard+0x92>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
ja     1186 <printBoard+0x76>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <printBoard+0x3a>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <printBoard+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBoard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,0x4(%rsp)
mov    %rdi,%r12
lea    0xec5(%rip),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%rbp,1),%eax
movzbl (%r12,%rax,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
cmp    %ebx,%r14d
jbe    1150 <printBoard+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
add    %ebx,%ebp
cmp    0x4(%rsp),%r13d
jbe    1140 <printBoard+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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