#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();
float *floatVector(unsigned long size) {
  unsigned long i;
  double invRND;
  float *X;
  X = (float *)memalign(64, size * sizeof(float));
  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):
<floatVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
shl    $0x2,%rsi
mov    $0x40,%edi
call   1030 <memalign@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1169 <floatVector+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    11db <floatVector+0xab>
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
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118e <floatVector+0x5e>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floatVector>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x0(,%rdi,4),%rsi
mov    $0x40,%edi
call   1030 <memalign@plt>
mov    %rax,%r15
test   %rax,%rax
je     115d <floatVector+0x2d>
test   %r14,%r14
jne    116e <floatVector+0x3e>
jmp    11b0 <floatVector+0x80>
lea    0xea4(%rip),%rdi
call   1040 <fatalError@plt>
test   %r14,%r14
je     11b0 <floatVector+0x80>
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
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1190 <floatVector+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 float* @floatVector(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca double
%5 = alloca float*
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = mul i64 %6, 4
%8 = call i64 @memalign(i32 64, i64 %7)
%9 = inttoptr i64 %8 to float*
store float* %9, float** %5
%10 = load float*, float** %5
%11 = icmp ne float* %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 = %30, %14
%19 = load i64, i64* %3
%20 = load i64, i64* %2
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load double, double* %4
%24 = call double (...) @rand()
%25 = fmul double %23, %24
%26 = fptrunc double %25 to float
%27 = load float*, float** %5
%28 = load i64, i64* %3
%29 = getelementptr inbounds float, float* %27, i64 %28
store float %26, float* %29
br label %30
30: ; preds = %22
%31 = load i64, i64* %3
%32 = add i64 %31, 1
store i64 %32, i64* %3
br label %18
33: ; preds = %18
%34 = load float*, float** %5
ret float* %34
}

LLVM IR (-O2):
@.str = [36 x i8] c"Failed to allocate memory for test.\00"
@RAND_MAX = global i64 0
define float* @floatVector(i64 %0) {
%2 = shl i64 %0, 2
%3 = tail call i64 @memalign(i32 64, i64 %2)
%4 = inttoptr i64 %3 to float*
%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 %21, label %13
13: ; preds = %8, %13
%14 = phi i64 [ %19, %13 ], [ 0, %8 ]
%15 = tail call double (...) @rand()
%16 = fmul double %11, %15
%17 = fptrunc double %16 to float
%18 = getelementptr inbounds float, float* %4, i64 %14
store float %17, float* %18
%19 = add nuw i64 %14, 1
%20 = icmp eq i64 %19, %0
br i1 %20, label %21, label %13
21: ; preds = %13, %8
ret float* %4
}