#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 printDoubleArray(double *arr, size_t len) {
  int i;
  for (i = 0; i < len; ++i) {
    printf("%f", arr[i]);
    if (i != len - 1) {
      printf(", ");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printDoubleArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1186 <printDoubleArray+0x76>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeb7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movslq -0x14(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
je     1173 <printDoubleArray+0x63>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1178 <printDoubleArray+0x68>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <printDoubleArray+0x17>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDoubleArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     117a <printDoubleArray+0x5a>
mov    %rsi,%r13
mov    %rdi,%r14
lea    -0x1(%rsi),%rbx
lea    0xebf(%rip),%r15
lea    0xebb(%rip),%r12
xor    %ebp,%ebp
jmp    1159 <printDoubleArray+0x39>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%r13
je     117a <printDoubleArray+0x5a>
movsd  (%r14,%rbp,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    %rbp,%rbx
je     1150 <printDoubleArray+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1150 <printDoubleArray+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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