#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_MAX;
int /*<<< orphan*/ pd_add_pd_d(double *, double const, double *);
scalar_t__ rand();
void pd_random(double *x) {
  const double eps = 2.220446049250313e-16;
  const double eps2 = eps * eps;
  const double eps3 = eps * eps2;
  const double eps4 = eps * eps3;
  const double r0 = ((double)rand()) / RAND_MAX;
  const double r1 = ((double)rand()) / RAND_MAX;
  const double r2 = ((double)rand()) / RAND_MAX;
  const double r3 = ((double)rand()) / RAND_MAX;
  const double r4 = ((double)rand()) / RAND_MAX;
  x[0] = r0;
  x[1] = 0.0;
  x[2] = 0.0;
  x[3] = 0.0;
  x[4] = 0.0;
  pd_add_pd_d(x, r1 * eps, x);
  pd_add_pd_d(x, r2 * eps2, x);
  pd_add_pd_d(x, r3 * eps3, x);
  pd_add_pd_d(x, r4 * eps4, x);
}


x86 assembly (clang, -O0):
<pd_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xee4(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeba(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e75(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e59(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e3d(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e21(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e05(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rdi
movsd  0xde3(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rsi
call   1030 <pd_add_pd_d@plt>
mov    -0x8(%rbp),%rdi
movsd  0xdc1(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rsi
call   1030 <pd_add_pd_d@plt>
mov    -0x8(%rbp),%rdi
movsd  0xd9f(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rsi
call   1030 <pd_add_pd_d@plt>
mov    -0x8(%rbp),%rdi
movsd  0xd7d(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rsi
call   1030 <pd_add_pd_d@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pd_random>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2eab(%rip),%r14
divsd  (%r14),%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm1
mulsd  0xe44(%rip),%xmm1
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rbx)
movups %xmm0,0x8(%rbx)
mov    %rbx,%rdi
movapd %xmm1,%xmm0
mov    %rbx,%rsi
call   1030 <pd_add_pd_d@plt>
movsd  0x18(%rsp),%xmm0
mulsd  0xe1a(%rip),%xmm0
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <pd_add_pd_d@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xe09(%rip),%xmm0
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <pd_add_pd_d@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xdf8(%rip),%xmm0
mov    %rbx,%rdi
mov    %rbx,%rsi
add    $0x28,%rsp
pop    %rbx
pop    %r14
jmp    1030 <pd_add_pd_d@plt>

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @pd_random(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double* %0, double** %2
store double 0x3CB0000000000000, double* %3
store double 0x3970000000000000, double* %4
store double 0x3630000000000000, double* %5
store double 0x32F0000000000000, double* %6
%12 = call i64 (...) @rand()
%13 = sitofp i64 %12 to double
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
store double %15, double* %7
%16 = call i64 (...) @rand()
%17 = sitofp i64 %16 to double
%18 = load double, double* @RAND_MAX
%19 = fdiv double %17, %18
store double %19, double* %8
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load double, double* @RAND_MAX
%23 = fdiv double %21, %22
store double %23, double* %9
%24 = call i64 (...) @rand()
%25 = sitofp i64 %24 to double
%26 = load double, double* @RAND_MAX
%27 = fdiv double %25, %26
store double %27, double* %10
%28 = call i64 (...) @rand()
%29 = sitofp i64 %28 to double
%30 = load double, double* @RAND_MAX
%31 = fdiv double %29, %30
store double %31, double* %11
%32 = load double, double* %7
%33 = load double*, double** %2
%34 = getelementptr inbounds double, double* %33, i64 0
store double %32, double* %34
%35 = load double*, double** %2
%36 = getelementptr inbounds double, double* %35, i64 1
store double 0.000000e+00, double* %36
%37 = load double*, double** %2
%38 = getelementptr inbounds double, double* %37, i64 2
store double 0.000000e+00, double* %38
%39 = load double*, double** %2
%40 = getelementptr inbounds double, double* %39, i64 3
store double 0.000000e+00, double* %40
%41 = load double*, double** %2
%42 = getelementptr inbounds double, double* %41, i64 4
store double 0.000000e+00, double* %42
%43 = load double*, double** %2
%44 = load double, double* %8
%45 = fmul double %44, 0x3CB0000000000000
%46 = load double*, double** %2
%47 = call i32 @pd_add_pd_d(double* %43, double %45, double* %46)
%48 = load double*, double** %2
%49 = load double, double* %9
%50 = fmul double %49, 0x3970000000000000
%51 = load double*, double** %2
%52 = call i32 @pd_add_pd_d(double* %48, double %50, double* %51)
%53 = load double*, double** %2
%54 = load double, double* %10
%55 = fmul double %54, 0x3630000000000000
%56 = load double*, double** %2
%57 = call i32 @pd_add_pd_d(double* %53, double %55, double* %56)
%58 = load double*, double** %2
%59 = load double, double* %11
%60 = fmul double %59, 0x32F0000000000000
%61 = load double*, double** %2
%62 = call i32 @pd_add_pd_d(double* %58, double %60, double* %61)
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @pd_random(double* %0) {
%2 = tail call i64 (...) @rand()
%3 = sitofp i64 %2 to double
%4 = load double, double* @RAND_MAX
%5 = fdiv double %3, %4
%6 = tail call i64 (...) @rand()
%7 = sitofp i64 %6 to double
%8 = load double, double* @RAND_MAX
%9 = fdiv double %7, %8
%10 = tail call i64 (...) @rand()
%11 = sitofp i64 %10 to double
%12 = load double, double* @RAND_MAX
%13 = fdiv double %11, %12
%14 = tail call i64 (...) @rand()
%15 = sitofp i64 %14 to double
%16 = load double, double* @RAND_MAX
%17 = fdiv double %15, %16
%18 = tail call i64 (...) @rand()
%19 = sitofp i64 %18 to double
%20 = load double, double* @RAND_MAX
%21 = fdiv double %19, %20
store double %5, double* %0
%22 = getelementptr inbounds double, double* %0, i64 1
%23 = fmul double %9, 0x3CB0000000000000
%24 = bitcast double* %22 to i8*
%25 = tail call i32 @pd_add_pd_d(double* %0, double %23, double* %0)
%26 = fmul double %13, 0x3970000000000000
%27 = tail call i32 @pd_add_pd_d(double* %0, double %26, double* %0)
%28 = fmul double %17, 0x3630000000000000
%29 = tail call i32 @pd_add_pd_d(double* %0, double %28, double* %0)
%30 = fmul double %21, 0x32F0000000000000
%31 = tail call i32 @pd_add_pd_d(double* %0, double %30, double* %0)
ret void
}