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


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11a4 <printArray+0x94>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xebb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1191 <printArray+0x81>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe87(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <printArray+0x48>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <printArray+0xa2>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    119f <printArray+0x7f>
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  (%r12),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%r14
cmp    $0x1,%ebp
je     11a6 <printArray+0x86>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xe92(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  (%r12,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <printArray+0x60>
jmp    11a6 <printArray+0x86>
lea    0xe62(%rip),%r14
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

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

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