#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;
scalar_t__ rand();
int /*<<< orphan*/ td_fast_renorm(double const, double const, double const,
                                  double, double *, double *, double *);
void td_random(double *x) {
  const double eps = 2.220446049250313e-16;
  const double dd_eps = 4.930380657631324e-32;
  const double first = ((double)rand()) / RAND_MAX;
  const double second = ((double)rand()) / RAND_MAX;
  const double third = ((double)rand()) / RAND_MAX;
  td_fast_renorm(first, eps * second, dd_eps * third, 0.0, &x[0], &x[1], &x[2]);
}


x86 assembly (clang, -O0):
<td_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xed4(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e8f(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e73(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e57(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe4c(%rip),%xmm2
mulsd  -0x30(%rbp),%xmm2
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
mov    -0x8(%rbp),%rdx
add    $0x10,%rdx
xorps  %xmm3,%xmm3
call   1030 <td_fast_renorm@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<td_random>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2eab(%rip),%r14
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)
xor    %eax,%eax
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm2
divsd  (%r14),%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  0xe7f(%rip),%xmm1
mulsd  0xe7f(%rip),%xmm2
lea    0x8(%rbx),%rsi
lea    0x10(%rbx),%rdx
xorps  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <td_fast_renorm@plt>

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @td_random(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double* %0, double** %2
store double 0x3CB0000000000000, double* %3
store double 0x3970000000000000, double* %4
%8 = call i64 (...) @rand()
%9 = sitofp i64 %8 to double
%10 = load double, double* @RAND_MAX
%11 = fdiv double %9, %10
store double %11, double* %5
%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* %6
%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* %7
%20 = load double, double* %5
%21 = load double, double* %6
%22 = fmul double 0x3CB0000000000000, %21
%23 = load double, double* %7
%24 = fmul double 0x3970000000000000, %23
%25 = load double*, double** %2
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double*, double** %2
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double*, double** %2
%30 = getelementptr inbounds double, double* %29, i64 2
%31 = call i32 @td_fast_renorm(double %20, double %22, double %24, double 0.000000e+00, double* %26, double* %28, double* %30)
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @td_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 = fmul double %9, 0x3CB0000000000000
%15 = fmul double %13, 0x3970000000000000
%16 = getelementptr inbounds double, double* %0, i64 1
%17 = getelementptr inbounds double, double* %0, i64 2
%18 = tail call i32 @td_fast_renorm(double %5, double %14, double %15, double 0.000000e+00, double* %0, double* %16, double* %17)
ret void
}