#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*/ assert(double *);
double daysPastEpoch(double);
double *malloc(int);
double *convertDatesToDays(unsigned nObservations, double *dates) {
  double *days = malloc(sizeof(double) * nObservations);
  assert(days);
  for (unsigned i = 0; i < nObservations; i++) {
    days[i] = daysPastEpoch(dates[i]);
  }
  return days;
}


x86 assembly (clang, -O0):
<convertDatesToDays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1198 <convertDatesToDays+0x68>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <daysPastEpoch@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1161 <convertDatesToDays+0x31>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertDatesToDays>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1030 <assert@plt>
test   %r15d,%r15d
je     117a <convertDatesToDays+0x4a>
mov    %r15d,%r15d
xor    %ebx,%ebx
movsd  (%r14,%rbx,8),%xmm0
call   1050 <daysPastEpoch@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <convertDatesToDays+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @convertDatesToDays(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call double* @malloc(i32 %10)
store double* %11, double** %5
%12 = load double*, double** %5
%13 = call i32 @assert(double* %12)
store i32 0, i32* %6
br label %14
14: ; preds = %29, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load double*, double** %4
%20 = load i32, i32* %6
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = call double @daysPastEpoch(double %23)
%25 = load double*, double** %5
%26 = load i32, i32* %6
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
store double %24, double* %28
br label %29
29: ; preds = %18
%30 = load i32, i32* %6
%31 = add i32 %30, 1
store i32 %31, i32* %6
br label %14
32: ; preds = %14
%33 = load double*, double** %5
ret double* %33
}

LLVM IR (-O2):
define double* @convertDatesToDays(i32 %0, double* nocapture %1) {
%3 = shl i32 %0, 3
%4 = tail call double* @malloc(i32 %3)
%5 = tail call i32 @assert(double* %4)
%6 = icmp eq i32 %0, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %10
9: ; preds = %10, %2
ret double* %4
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %16, %10 ]
%12 = getelementptr inbounds double, double* %1, i64 %11
%13 = load double, double* %12
%14 = tail call double @daysPastEpoch(double %13)
%15 = getelementptr inbounds double, double* %4, i64 %11
store double %14, double* %15
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %9, label %10
}