#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 */
scalar_t__ RAND_MAX;
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
int time(int /*<<< orphan*/);
double rnd(double low, double high, long inc) {
  double r, s;
  static long ever = 0;
  long i;
  if (high <= low)
    return (low);
  if (!ever) {
    srand((unsigned int)((time(0) << 16) + (time(0) >> 16)));
    ever = 1;
  }
  do {
    r = 0;
    s = (double)RAND_MAX;
    for (i = 0; i < 4; i++) {
      r += (double)rand() / s;
      s *= ((double)RAND_MAX + 1);
    }
  } while (r > 1 || (r == 0 && (inc == 0 || inc == 2)) || (r >= 1 && inc <= 1));
  return r * (high - low) + low;
}


x86 assembly (clang, -O0):
<rnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1169 <rnd+0x39>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d4 <rnd+0x1a4>
cmpq   $0x0,0x2ecf(%rip)
jne    11a3 <rnd+0x73>
xor    %edi,%edi
call   1040 <time@plt>
shl    $0x10,%eax
mov    %eax,-0x3c(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    -0x3c(%rbp),%edi
sar    $0x10,%eax
add    %eax,%edi
call   1030 <srand@plt>
movq   $0x1,0x2e9d(%rip)
jmp    11a8 <rnd+0x78>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e31(%rip),%rax
cvtsi2sdq (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x4,-0x38(%rbp)
jge    1222 <rnd+0xf2>
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %rax,%xmm0
divsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2df2(%rip),%rax
cvtsi2sdq (%rax),%xmm0
movsd  0xdfd(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11c9 <rnd+0x99>
jmp    1227 <rnd+0xf7>
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%al
movsd  0xdca(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x3d(%rbp)
ja     12a8 <rnd+0x178>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    127b <rnd+0x14b>
jp     127b <rnd+0x14b>
mov    $0x1,%al
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x3d(%rbp)
je     12a8 <rnd+0x178>
mov    $0x1,%al
cmpq   $0x2,-0x20(%rbp)
mov    %al,-0x3d(%rbp)
je     12a8 <rnd+0x178>
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
movsd  0xd76(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x3e(%rbp)
jb     12a2 <rnd+0x172>
cmpq   $0x1,-0x20(%rbp)
setle  %al
mov    %al,-0x3e(%rbp)
mov    -0x3e(%rbp),%al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    11a8 <rnd+0x78>
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnd>:
ucomisd %xmm1,%xmm0
jae    12f2 <rnd+0x1c2>
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
cmpb   $0x0,0x2ee6(%rip)
jne    1182 <rnd+0x52>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
xor    %edi,%edi
call   1040 <time@plt>
sar    $0x10,%eax
add    %eax,%ebp
mov    %ebp,%edi
call   1030 <srand@plt>
movb   $0x1,0x2ebe(%rip)
mov    0x2e5f(%rip),%rbp
nopl   0x0(%rax)
cmp    $0x2,%r14
setl   %bl
test   $0xfffffffffffffffd,%r14
sete   %r15b
xorps  %xmm0,%xmm0
cvtsi2sdq 0x0(%rbp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sdq 0x0(%rbp),%xmm1
movsd  0xe17(%rip),%xmm0
addsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdq 0x0(%rbp),%xmm0
addsd  0xdd3(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdq 0x0(%rbp),%xmm0
addsd  0xd93(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd 0xd6e(%rip),%xmm0
setnp  %cl
sete   %al
and    %cl,%al
and    %r15b,%al
movsd  0xd53(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %cl
ucomisd %xmm1,%xmm0
ja     1190 <rnd+0x60>
and    %cl,%bl
test   %al,%al
jne    1190 <rnd+0x60>
test   %bl,%bl
jne    1190 <rnd+0x60>
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
subsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@rnd.ever = internal global i64 0
@RAND_MAX = global i64 0
define double @rnd(double %0, double %1, i64 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i64
%8 = alloca double
%9 = alloca double
%10 = alloca i64
store double %0, double* %5
store double %1, double* %6
store i64 %2, i64* %7
%11 = load double, double* %6
%12 = load double, double* %5
%13 = fcmp ole double %11, %12
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load double, double* %5
store double %15, double* %4
br label %78
16: ; preds = %3
%17 = load i64, i64* @rnd.ever
%18 = icmp ne i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = call i32 @time(i32 0)
%21 = shl i32 %20, 16
%22 = call i32 @time(i32 0)
%23 = ashr i32 %22, 16
%24 = add nsw i32 %21, %23
%25 = call i32 @srand(i32 %24)
store i64 1, i64* @rnd.ever
br label %26
26: ; preds = %19, %16
br label %27
27: ; preds = %69, %26
store double 0.000000e+00, double* %8
%28 = load i64, i64* @RAND_MAX
%29 = sitofp i64 %28 to double
store double %29, double* %9
store i64 0, i64* %10
br label %30
30: ; preds = %45, %27
%31 = load i64, i64* %10
%32 = icmp slt i64 %31, 4
br i1 %32, label %33, label %48
33: ; preds = %30
%34 = call i64 (...) @rand()
%35 = sitofp i64 %34 to double
%36 = load double, double* %9
%37 = fdiv double %35, %36
%38 = load double, double* %8
%39 = fadd double %38, %37
store double %39, double* %8
%40 = load i64, i64* @RAND_MAX
%41 = sitofp i64 %40 to double
%42 = fadd double %41, 1.000000e+00
%43 = load double, double* %9
%44 = fmul double %43, %42
store double %44, double* %9
br label %45
45: ; preds = %33
%46 = load i64, i64* %10
%47 = add nsw i64 %46, 1
store i64 %47, i64* %10
br label %30
48: ; preds = %30
br label %49
49: ; preds = %48
%50 = load double, double* %8
%51 = fcmp ogt double %50, 1.000000e+00
br i1 %51, label %69, label %52
52: ; preds = %49
%53 = load double, double* %8
%54 = fcmp oeq double %53, 0.000000e+00
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = load i64, i64* %7
%57 = icmp eq i64 %56, 0
br i1 %57, label %69, label %58
58: ; preds = %55
%59 = load i64, i64* %7
%60 = icmp eq i64 %59, 2
br i1 %60, label %69, label %61
61: ; preds = %58, %52
%62 = load double, double* %8
%63 = fcmp oge double %62, 1.000000e+00
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i64, i64* %7
%66 = icmp sle i64 %65, 1
br label %67
67: ; preds = %64, %61
%68 = phi i1 [ false, %61 ], [ %66, %64 ]
br label %69
69: ; preds = %67, %58, %55, %49
%70 = phi i1 [ true, %58 ], [ true, %55 ], [ true, %49 ], [ %68, %67 ]
br i1 %70, label %27, label %71
71: ; preds = %69
%72 = load double, double* %8
%73 = load double, double* %6
%74 = load double, double* %5
%75 = fsub double %73, %74
%76 = load double, double* %5
%77 = call double @llvm.fmuladd.f64(double %72, double %75, double %76)
store double %77, double* %4
br label %78
78: ; preds = %71, %14
%79 = load double, double* %4
ret double %79
}

LLVM IR (-O2):
@rnd.ever = internal unnamed_addr global i1 false
@RAND_MAX = global i64 0
define double @rnd(double %0, double %1, i64 %2) {
%4 = fcmp ugt double %1, %0
br i1 %4, label %5, label %59
5: ; preds = %3
%6 = load i1, i1* @rnd.ever
br i1 %6, label %14, label %7
7: ; preds = %5
%8 = tail call i32 @time(i32 0)
%9 = shl i32 %8, 16
%10 = tail call i32 @time(i32 0)
%11 = ashr i32 %10, 16
%12 = add nsw i32 %11, %9
%13 = tail call i32 @srand(i32 %12)
store i1 true, i1* @rnd.ever
br label %14
14: ; preds = %7, %5
%15 = and i64 %2, -3
%16 = icmp eq i64 %15, 0
%17 = icmp slt i64 %2, 2
br label %18
18: ; preds = %18, %14
%19 = load i64, i64* @RAND_MAX
%20 = sitofp i64 %19 to double
%21 = tail call i64 (...) @rand()
%22 = sitofp i64 %21 to double
%23 = fdiv double %22, %20
%24 = fadd double %23, 0.000000e+00
%25 = load i64, i64* @RAND_MAX
%26 = sitofp i64 %25 to double
%27 = fadd double %26, 1.000000e+00
%28 = fmul double %27, %20
%29 = tail call i64 (...) @rand()
%30 = sitofp i64 %29 to double
%31 = fdiv double %30, %28
%32 = fadd double %24, %31
%33 = load i64, i64* @RAND_MAX
%34 = sitofp i64 %33 to double
%35 = fadd double %34, 1.000000e+00
%36 = fmul double %28, %35
%37 = tail call i64 (...) @rand()
%38 = sitofp i64 %37 to double
%39 = fdiv double %38, %36
%40 = fadd double %32, %39
%41 = load i64, i64* @RAND_MAX
%42 = sitofp i64 %41 to double
%43 = fadd double %42, 1.000000e+00
%44 = fmul double %36, %43
%45 = tail call i64 (...) @rand()
%46 = sitofp i64 %45 to double
%47 = fdiv double %46, %44
%48 = fadd double %40, %47
%49 = fcmp ogt double %48, 1.000000e+00
%50 = fcmp oeq double %48, 0.000000e+00
%51 = and i1 %16, %50
%52 = or i1 %49, %51
%53 = fcmp oge double %48, 1.000000e+00
%54 = and i1 %17, %53
%55 = or i1 %52, %54
br i1 %55, label %18, label %56
56: ; preds = %18
%57 = fsub double %1, %0
%58 = tail call double @llvm.fmuladd.f64(double %48, double %57, double %0)
br label %59
59: ; preds = %3, %56
%60 = phi double [ %58, %56 ], [ %0, %3 ]
ret double %60
}