#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 */
scalar_t__ RAND_MAX;
int /*<<< orphan*/ fatalError(char *);
scalar_t__ memalign(int, unsigned long);
double rand();
double *doubleVector(unsigned long size) {
  unsigned long i;
  double invRND;
  double *X;
  X = (double *)memalign(64, size * sizeof(double));
  if (!X)
    fatalError("Failed to allocate memory for test.");
  invRND = 1.0E0 / (double)RAND_MAX;
  for (i = 0; i < size; i++)
    X[i] = invRND * rand();
  return X;
}


x86 assembly (clang, -O0):
<doubleVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
shl    $0x3,%rsi
mov    $0x40,%edi
call   1030 <memalign@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1169 <doubleVector+0x39>
lea    0xea4(%rip),%rdi
call   1040 <fatalError@plt>
mov    0x2e78(%rip),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xe83(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11d7 <doubleVector+0xa7>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118e <doubleVector+0x5e>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubleVector>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x0(,%rdi,8),%rsi
mov    $0x40,%edi
call   1030 <memalign@plt>
mov    %rax,%r15
test   %rax,%rax
je     115d <doubleVector+0x2d>
test   %r14,%r14
jne    116e <doubleVector+0x3e>
jmp    11ac <doubleVector+0x7c>
lea    0xea4(%rip),%rdi
call   1040 <fatalError@plt>
test   %r14,%r14
je     11ac <doubleVector+0x7c>
mov    0x2e73(%rip),%rax
cvtsi2sdq (%rax),%xmm0
movsd  0xe7e(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1190 <doubleVector+0x60>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Failed to allocate memory for test.\00"
@RAND_MAX = global i64 0
define double* @doubleVector(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca double
%5 = alloca double*
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = mul i64 %6, 8
%8 = call i64 @memalign(i32 64, i64 %7)
%9 = inttoptr i64 %8 to double*
store double* %9, double** %5
%10 = load double*, double** %5
%11 = icmp ne double* %10, null
br i1 %11, label %14, label %12
12: ; preds = %1
%13 = call i32 @fatalError(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %1
%15 = load i64, i64* @RAND_MAX
%16 = sitofp i64 %15 to double
%17 = fdiv double 1.000000e+00, %16
store double %17, double* %4
store i64 0, i64* %3
br label %18
18: ; preds = %29, %14
%19 = load i64, i64* %3
%20 = load i64, i64* %2
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load double, double* %4
%24 = call double (...) @rand()
%25 = fmul double %23, %24
%26 = load double*, double** %5
%27 = load i64, i64* %3
%28 = getelementptr inbounds double, double* %26, i64 %27
store double %25, double* %28
br label %29
29: ; preds = %22
%30 = load i64, i64* %3
%31 = add i64 %30, 1
store i64 %31, i64* %3
br label %18
32: ; preds = %18
%33 = load double*, double** %5
ret double* %33
}

LLVM IR (-O2):
@.str = [36 x i8] c"Failed to allocate memory for test.\00"
@RAND_MAX = global i64 0
define double* @doubleVector(i64 %0) {
%2 = shl i64 %0, 3
%3 = tail call i64 @memalign(i32 64, i64 %2)
%4 = inttoptr i64 %3 to double*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @fatalError(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i64, i64* @RAND_MAX
%10 = sitofp i64 %9 to double
%11 = fdiv double 1.000000e+00, %10
%12 = icmp eq i64 %0, 0
br i1 %12, label %20, label %13
13: ; preds = %8, %13
%14 = phi i64 [ %18, %13 ], [ 0, %8 ]
%15 = tail call double (...) @rand()
%16 = fmul double %11, %15
%17 = getelementptr inbounds double, double* %4, i64 %14
store double %16, double* %17
%18 = add nuw i64 %14, 1
%19 = icmp eq i64 %18, %0
br i1 %19, label %20, label %13
20: ; preds = %13, %8
ret double* %4
}