#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;
scalar_t__ rand();
int _random_int_in_range(size_t min, size_t max) {
  double scaled = (double)rand() / RAND_MAX;
  int random = (max - min + 1) * scaled + min;
  return random;
}


x86 assembly (clang, -O0):
<_random_int_in_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1030 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2eb5(%rip),%rax
movsd  (%rax),%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 0xea5(%rip),%xmm4
punpckldq %xmm4,%xmm0
movapd 0xea9(%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
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_random_int_in_range>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2ebb(%rip),%rax
divsd  (%rax),%xmm0
sub    %r14,%rbx
add    $0x1,%rbx
movq   %rbx,%xmm1
movdqa 0xebb(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xebf(%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,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @_random_int_in_range(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = call i64 (...) @rand()
%8 = sitofp i64 %7 to double
%9 = load double, double* @RAND_MAX
%10 = fdiv double %8, %9
store double %10, double* %5
%11 = load i64, i64* %4
%12 = load i64, i64* %3
%13 = sub i64 %11, %12
%14 = add i64 %13, 1
%15 = uitofp i64 %14 to double
%16 = load double, double* %5
%17 = load i64, i64* %3
%18 = uitofp i64 %17 to double
%19 = call double @llvm.fmuladd.f64(double %15, double %16, double %18)
%20 = fptosi double %19 to i32
store i32 %20, i32* %6
%21 = load i32, i32* %6
ret i32 %21
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @_random_int_in_range(i64 %0, i64 %1) {
%3 = tail call i64 (...) @rand()
%4 = sitofp i64 %3 to double
%5 = load double, double* @RAND_MAX
%6 = fdiv double %4, %5
%7 = sub i64 1, %0
%8 = add i64 %7, %1
%9 = uitofp i64 %8 to double
%10 = uitofp i64 %0 to double
%11 = tail call double @llvm.fmuladd.f64(double %9, double %6, double %10)
%12 = fptosi double %11 to i32
ret i32 %12
}