#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 */
int /*<<< orphan*/ assert(int);
scalar_t__ floor(double);
unsigned int ya_random();
double random_double(double base, double limit, double epsilon) {
  double range = 0.0;
  unsigned int steps = 0;
  assert(base < limit);
  assert(epsilon > 0.0);
  range = limit - base;
  steps = (unsigned int)(floor(range / epsilon));
  return base + ((ya_random() % steps) * epsilon);
}


x86 assembly (clang, -O0):
<random_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
call   1030 <ya_random@plt>
mov    -0x34(%rbp),%edx
movsd  -0x30(%rbp),%xmm1
mov    -0x24(%rbp),%ecx
div    %ecx
mov    %edx,%eax
cvtsi2sd %rax,%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_double>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
ucomisd %xmm0,%xmm1
seta   %dil
call   1040 <assert@plt>
xorpd  %xmm0,%xmm0
xor    %edi,%edi
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %dil
call   1040 <assert@plt>
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
call   1050 <floor@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <ya_random@plt>
xor    %edx,%edx
div    %ebx
xorps  %xmm0,%xmm0
cvtsi2sd %rdx,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @random_double(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
%9 = load double, double* %4
%10 = load double, double* %5
%11 = fcmp olt double %9, %10
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load double, double* %6
%15 = fcmp ogt double %14, 0.000000e+00
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load double, double* %5
%19 = load double, double* %4
%20 = fsub double %18, %19
store double %20, double* %7
%21 = load double, double* %7
%22 = load double, double* %6
%23 = fdiv double %21, %22
%24 = call i64 @floor(double %23)
%25 = trunc i64 %24 to i32
store i32 %25, i32* %8
%26 = load double, double* %4
%27 = call i32 (...) @ya_random()
%28 = load i32, i32* %8
%29 = urem i32 %27, %28
%30 = uitofp i32 %29 to double
%31 = load double, double* %6
%32 = call double @llvm.fmuladd.f64(double %30, double %31, double %26)
ret double %32
}

LLVM IR (-O2):
define double @random_double(double %0, double %1, double %2) {
%4 = fcmp olt double %0, %1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = fcmp ogt double %2, 0.000000e+00
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = fsub double %1, %0
%11 = fdiv double %10, %2
%12 = tail call i64 @floor(double %11)
%13 = trunc i64 %12 to i32
%14 = tail call i32 (...) @ya_random()
%15 = urem i32 %14, %13
%16 = uitofp i32 %15 to double
%17 = tail call double @llvm.fmuladd.f64(double %16, double %2, double %0)
ret double %17
}