#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 rand_double();
void rand_array_f64(double *out, const unsigned int len, const double a,
                    const double b) {
  unsigned int i;
  double delta;
  delta = b - a;
  for (i = 0; i < len; i++) {
    out[i] = a + (rand_double() * delta);
  }
}


x86 assembly (clang, -O0):
<rand_array_f64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1188 <rand_array_f64+0x78>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1030 <rand_double@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113f <rand_array_f64+0x2f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_array_f64>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
test   %esi,%esi
je     1161 <rand_array_f64+0x51>
mov    %rdi,%r14
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %esi,%r15d
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <rand_double@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <rand_array_f64+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rand_array_f64(double* %0, i32 %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double, double* %8
%12 = load double, double* %7
%13 = fsub double %11, %12
store double %13, double* %10
store i32 0, i32* %9
br label %14
14: ; preds = %27, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load double, double* %7
%20 = call double (...) @rand_double()
%21 = load double, double* %10
%22 = call double @llvm.fmuladd.f64(double %20, double %21, double %19)
%23 = load double*, double** %5
%24 = load i32, i32* %9
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %18
%28 = load i32, i32* %9
%29 = add i32 %28, 1
store i32 %29, i32* %9
br label %14
30: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @rand_array_f64(double* nocapture writeonly %0, i32 %1, double %2, double %3) {
%5 = fsub double %3, %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = tail call double (...) @rand_double()
%12 = tail call double @llvm.fmuladd.f64(double %11, double %5, double %2)
%13 = getelementptr inbounds double, double* %0, i64 %10
store double %12, double* %13
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %4
ret void
}