#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 */
double drand48();
int lrand48();
void fill_float_array(float *array, double min_range, double max_range) {
  for (int i = 0; i < 1024; i++) {
    double tmp = drand48();
    tmp *= (lrand48() % 2) ? 1.0 : max_range;
    while (tmp < min_range) {
      tmp = drand48() * max_range;
    }
    array[i] = (float)tmp;
  }
}


x86 assembly (clang, -O0):
<fill_float_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jge    11e7 <fill_float_array+0xc7>
mov    $0x0,%al
call   1040 <drand48@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <lrand48@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1180 <fill_float_array+0x60>
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    118a <fill_float_array+0x6a>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c3 <fill_float_array+0xa3>
mov    $0x0,%al
call   1040 <drand48@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1199 <fill_float_array+0x79>
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <fill_float_array+0x1d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_float_array>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps %xmm0,%xmm2
mov    %rdi,%r14
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
jmp    1157 <fill_float_array+0x37>
nopl   0x0(%rax)
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x400,%rbx
je     11be <fill_float_array+0x9e>
xor    %eax,%eax
call   1040 <drand48@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <lrand48@plt>
movsd  0x8(%rsp),%xmm0
test   $0x1,%al
je     117d <fill_float_array+0x5d>
movsd  0xe83(%rip),%xmm0
movsd  0x10(%rsp),%xmm3
mulsd  %xmm0,%xmm3
movsd  (%rsp),%xmm2
ucomisd %xmm3,%xmm2
movapd %xmm3,%xmm0
jbe    1140 <fill_float_array+0x20>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <drand48@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
ja     11a0 <fill_float_array+0x80>
jmp    1140 <fill_float_array+0x20>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @fill_float_array(float* %0, double %1, double %2) {
%4 = alloca float*
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
store float* %0, float** %4
store double %1, double* %5
store double %2, double* %6
store i32 0, i32* %7
br label %9
9: ; preds = %39, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 1024
br i1 %11, label %12, label %42
12: ; preds = %9
%13 = call double (...) @drand48()
store double %13, double* %8
%14 = call i32 (...) @lrand48()
%15 = srem i32 %14, 2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
br label %20
18: ; preds = %12
%19 = load double, double* %6
br label %20
20: ; preds = %18, %17
%21 = phi double [ 1.000000e+00, %17 ], [ %19, %18 ]
%22 = load double, double* %8
%23 = fmul double %22, %21
store double %23, double* %8
br label %24
24: ; preds = %28, %20
%25 = load double, double* %8
%26 = load double, double* %5
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = call double (...) @drand48()
%30 = load double, double* %6
%31 = fmul double %29, %30
store double %31, double* %8
br label %24
32: ; preds = %24
%33 = load double, double* %8
%34 = fptrunc double %33 to float
%35 = load float*, float** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %35, i64 %37
store float %34, float* %38
br label %39
39: ; preds = %32
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %9
42: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @fill_float_array(float* nocapture writeonly %0, double %1, double %2) {
br label %5
4: ; preds = %18
ret void
5: ; preds = %3, %18
%6 = phi i64 [ 0, %3 ], [ %22, %18 ]
%7 = tail call double (...) @drand48()
%8 = tail call i32 (...) @lrand48()
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, double %2, double 1.000000e+00
%12 = fmul double %7, %11
%13 = fcmp olt double %12, %1
br i1 %13, label %14, label %18
14: ; preds = %5, %14
%15 = tail call double (...) @drand48()
%16 = fmul double %15, %2
%17 = fcmp olt double %16, %1
br i1 %17, label %14, label %18
18: ; preds = %14, %5
%19 = phi double [ %12, %5 ], [ %16, %14 ]
%20 = fptrunc double %19 to float
%21 = getelementptr inbounds float, float* %0, i64 %6
store float %20, float* %21
%22 = add nuw nsw i64 %6, 1
%23 = icmp eq i64 %22, 1024
br i1 %23, label %4, label %5
}