#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 printArray(int *array, size_t size) {
  int x;
  int numInRow = 0;
  printf("[");
  for (x = 0; x < size; x++) {
    if (numInRow == 10) {
      printf("\n ");
      numInRow = 0;
    }
    printf("%d ", array[x]);
    numInRow++;
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1199 <printArray+0x89>
cmpl   $0xa,-0x18(%rbp)
jne    1169 <printArray+0x59>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <printArray+0x2c>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%r14
mov    $0x5b,%edi
call   1030 <putchar@plt>
test   %r13,%r13
je     119d <printArray+0x6d>
lea    0xea9(%rip),%r15
lea    0xea5(%rip),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    118a <printArray+0x5a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
add    $0x1,%rbx
cmp    %rbx,%r13
je     119d <printArray+0x6d>
cmp    $0xa,%ebp
jne    1170 <printArray+0x40>
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1170 <printArray+0x40>
lea    0xe63(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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