#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;
double random();
double randValDouble(double min, double max) {
  if (min == 0.0 && max == 0.0)
    return 0.0;
  double val = min + ((max - min) * random() / (RAND_MAX + 1.0));
  return val;
}


x86 assembly (clang, -O0):
<randValDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115f <randValDouble+0x4f>
jp     115f <randValDouble+0x4f>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115f <randValDouble+0x4f>
jp     115f <randValDouble+0x4f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ba <randValDouble+0xaa>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
movsd  0xe68(%rip),%xmm2
mov    0x2e49(%rip),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randValDouble>:
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    112d <randValDouble+0x1d>
jp     112d <randValDouble+0x1d>
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm1
jne    112d <randValDouble+0x1d>
jp     112d <randValDouble+0x1d>
ret
sub    $0x18,%rsp
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
movsd  %xmm2,0x10(%rsp)
call   1030 <random@plt>
mulsd  0x8(%rsp),%xmm0
mov    0x2e93(%rip),%rax
movsd  (%rax),%xmm1
addsd  0xe9f(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define double @randValDouble(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load double, double* %5
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9
store double 0.000000e+00, double* %3
br label %25
13: ; preds = %9, %2
%14 = load double, double* %4
%15 = load double, double* %5
%16 = load double, double* %4
%17 = fsub double %15, %16
%18 = call double (...) @random()
%19 = fmul double %17, %18
%20 = load double, double* @RAND_MAX
%21 = fadd double %20, 1.000000e+00
%22 = fdiv double %19, %21
%23 = fadd double %14, %22
store double %23, double* %6
%24 = load double, double* %6
store double %24, double* %3
br label %25
25: ; preds = %13, %12
%26 = load double, double* %3
ret double %26
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define double @randValDouble(double %0, double %1) {
%3 = fcmp oeq double %0, 0.000000e+00
%4 = fcmp oeq double %1, 0.000000e+00
%5 = and i1 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = fsub double %1, %0
%8 = tail call double (...) @random()
%9 = fmul double %7, %8
%10 = load double, double* @RAND_MAX
%11 = fadd double %10, 1.000000e+00
%12 = fdiv double %9, %11
%13 = fadd double %12, %0
br label %14
14: ; preds = %2, %6
%15 = phi double [ %13, %6 ], [ 0.000000e+00, %2 ]
ret double %15
}