#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(double *a, int n) {
  for (int i = 4; i < (n * n) + 4; i++) {
    if ((i - 4) % n == 0)
      printf("\n");
    printf("%.2f ", a[i]);
  }
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    $0x4,%ecx
cmp    %ecx,%eax
jge    1185 <printArray+0x75>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    115c <printArray+0x4c>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe92(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <printArray+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%eax
imul   %esi,%eax
test   %eax,%eax
je     1180 <printArray+0x60>
mov    %esi,%r12d
mov    %rdi,%r14
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0xebe(%rip),%r15
jmp    116a <printArray+0x4a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x20(%r14,%rbx,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1180 <printArray+0x60>
mov    %ebx,%eax
cltd
idiv   %r12d
test   %edx,%edx
jne    1150 <printArray+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <printArray+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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