double sample_uniform(double x, double range[2], double finetune) {
  double w[2], xnew;
  w[0] = x - (range[1] - range[0]) * finetune / 2;
  w[1] = x + (range[1] - range[0]) * finetune / 2;
  xnew = ((w[0]) + ((w[1]) - (w[0])) * rndu());
  xnew = reflect(xnew, range[0], range[1]);
  return (xnew);
}


x86 assembly (clang, -O0):
<sample_uniform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xea7(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xe77(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1040 <rndu@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    $0x3,%al
call   1030 <reflect@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_uniform>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  0x8(%rdi),%xmm2
subsd  (%rdi),%xmm2
mulsd  %xmm1,%xmm2
mulsd  0xec3(%rip),%xmm2
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <rndu@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm2
mov    $0x3,%al
call   1030 <reflect@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @sample_uniform(double %0, double* %1, double %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double
%7 = alloca [2 x double]
%8 = alloca double
store double %0, double* %4
store double* %1, double** %5
store double %2, double* %6
%9 = load double, double* %4
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = load double, double* %11
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = fsub double %12, %15
%17 = load double, double* %6
%18 = fmul double %16, %17
%19 = fdiv double %18, 2.000000e+00
%20 = fsub double %9, %19
%21 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
store double %20, double* %21
%22 = load double, double* %4
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = fsub double %25, %28
%30 = load double, double* %6
%31 = fmul double %29, %30
%32 = fdiv double %31, 2.000000e+00
%33 = fadd double %22, %32
%34 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
store double %33, double* %34
%35 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%36 = load double, double* %35
%37 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
%38 = load double, double* %37
%39 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%40 = load double, double* %39
%41 = fsub double %38, %40
%42 = call i32 (...) @rndu()
%43 = sitofp i32 %42 to double
%44 = call double @llvm.fmuladd.f64(double %41, double %43, double %36)
store double %44, double* %8
%45 = load double, double* %8
%46 = load double*, double** %5
%47 = getelementptr inbounds double, double* %46, i64 0
%48 = load double, double* %47
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 1
%51 = load double, double* %50
%52 = call i32 (double, double, double, ...) bitcast (i32 (...)* @reflect to i32 (double, double, double, ...)*)(double %45, double %48, double %51)
%53 = sitofp i32 %52 to double
store double %53, double* %8
%54 = load double, double* %8
ret double %54
}

LLVM IR (-O2):
define double @sample_uniform(double %0, double* nocapture %1, double %2) {
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = load double, double* %4
%6 = load double, double* %1
%7 = fsub double %5, %6
%8 = fmul double %7, %2
%9 = fmul double %8, 5.000000e-01
%10 = fsub double %0, %9
%11 = fadd double %9, %0
%12 = fsub double %11, %10
%13 = tail call i32 (...) @rndu()
%14 = sitofp i32 %13 to double
%15 = tail call double @llvm.fmuladd.f64(double %12, double %14, double %10)
%16 = load double, double* %1
%17 = load double, double* %4
%18 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @reflect to i32 (double, double, double, ...)*)(double %15, double %16, double %17)
%19 = sitofp i32 %18 to double
ret double %19
}