#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 */
typedef unsigned long u_long;

/* Variables and functions */
float RAND_MAX;
scalar_t__ rand();
unsigned long hasard(unsigned long min, unsigned long max) {
  return (u_long)(min + ((float)rand() / RAND_MAX * (max - min + 1)));
}


x86 assembly (clang, -O0):
<hasard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x18(%rbp)
test   %rax,%rax
movss  %xmm0,-0x14(%rbp)
js     115d <hasard+0x4d>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
xor    %eax,%eax
call   1030 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e6e(%rip),%rax
movss  (%rax),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x20(%rbp)
test   %rax,%rax
movss  %xmm0,-0x1c(%rbp)
js     11cf <hasard+0xbf>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x28(%rbp),%xmm1
movss  -0x24(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttss2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movss  0xe03(%rip),%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasard>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rdi,%rdi
js     1126 <hasard+0x16>
cvtsi2ss %r14,%xmm0
jmp    113e <hasard+0x2e>
mov    %r14,%rax
shr    %rax
mov    %r14d,%ecx
and    $0x1,%ecx
or     %rax,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2e8e(%rip),%rax
divss  (%rax),%xmm0
sub    %r14,%rbx
add    $0x1,%rbx
js     116e <hasard+0x5e>
cvtsi2ss %rbx,%xmm1
jmp    1183 <hasard+0x73>
mov    %rbx,%rax
shr    %rax
and    $0x1,%ebx
or     %rax,%rbx
cvtsi2ss %rbx,%xmm1
addss  %xmm1,%xmm1
mulss  %xmm1,%xmm0
addss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
subss  0xe5f(%rip),%xmm0
cvttss2si %xmm0,%rax
and    %rdx,%rax
or     %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
define i64 @hasard(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = uitofp i64 %5 to float
%7 = call i64 (...) @rand()
%8 = sitofp i64 %7 to float
%9 = load float, float* @RAND_MAX
%10 = fdiv float %8, %9
%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 float
%16 = call float @llvm.fmuladd.f32(float %10, float %15, float %6)
%17 = fptoui float %16 to i64
ret i64 %17
}

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