#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__ genrand_int32();
unsigned long random_unsigned_long_in_range(const unsigned long min,
                                            const unsigned long max) {
  double rand_num = (double)genrand_int32() / (double)(0xffffffff);
  return (max - min + 1) * rand_num + min;
}


x86 assembly (clang, -O0):
<random_unsigned_long_in_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1030 <genrand_int32@plt>
cvtsi2sd %rax,%xmm0
movsd  0xecc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
add    $0x1,%rcx
movq   %rcx,%xmm0
movaps 0xeb8(%rip),%xmm4
punpckldq %xmm4,%xmm0
movapd 0xebc(%rip),%xmm3
subpd  %xmm3,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %rax,%xmm1
punpckldq %xmm4,%xmm1
subpd  %xmm3,%xmm1
movaps %xmm1,%xmm3
unpckhpd %xmm1,%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xe59(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_unsigned_long_in_range>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <genrand_int32@plt>
cvtsi2sd %rax,%xmm0
divsd  0xed2(%rip),%xmm0
sub    %r14,%rbx
add    $0x1,%rbx
movq   %rbx,%xmm1
movdqa 0xece(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xed2(%rip),%xmm3
subpd  %xmm3,%xmm1
movapd %xmm1,%xmm4
unpckhpd %xmm1,%xmm4
addsd  %xmm1,%xmm4
mulsd  %xmm0,%xmm4
movq   %r14,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm3,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
cvttsd2si %xmm1,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
subsd  0xe75(%rip),%xmm1
cvttsd2si %xmm1,%rax
and    %rdx,%rax
or     %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @random_unsigned_long_in_range(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = call i64 (...) @genrand_int32()
%7 = sitofp i64 %6 to double
%8 = fdiv double %7, 0x41EFFFFFFFE00000
store double %8, double* %5
%9 = load i64, i64* %4
%10 = load i64, i64* %3
%11 = sub i64 %9, %10
%12 = add i64 %11, 1
%13 = uitofp i64 %12 to double
%14 = load double, double* %5
%15 = load i64, i64* %3
%16 = uitofp i64 %15 to double
%17 = call double @llvm.fmuladd.f64(double %13, double %14, double %16)
%18 = fptoui double %17 to i64
ret i64 %18
}

LLVM IR (-O2):
define i64 @random_unsigned_long_in_range(i64 %0, i64 %1) {
%3 = tail call i64 (...) @genrand_int32()
%4 = sitofp i64 %3 to double
%5 = fdiv double %4, 0x41EFFFFFFFE00000
%6 = sub i64 1, %0
%7 = add i64 %6, %1
%8 = uitofp i64 %7 to double
%9 = uitofp i64 %0 to double
%10 = tail call double @llvm.fmuladd.f64(double %8, double %5, double %9)
%11 = fptoui double %10 to i64
ret i64 %11
}