#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;
int /*<<< orphan*/ assert(int);
double rand();
int prng_stdlib_get_number_in_range(const int low, const int high) {
  assert(low <= high);
  if (low == high)
    return low;
  int upper_range_boundary = high - low + 1;
  int random =
      (int)((double)upper_range_boundary * (rand() / (RAND_MAX + 1.0)));
  return random + low;
}


x86 assembly (clang, -O0):
<prng_stdlib_get_number_in_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1158 <prng_stdlib_get_number_in_range+0x38>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a8 <prng_stdlib_get_number_in_range+0x88>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm2
mov    0x2e5c(%rip),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prng_stdlib_get_number_in_range>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
cmp    %ebx,%esi
setge  %dil
call   1030 <assert@plt>
mov    %ebp,%eax
sub    %ebx,%eax
je     116f <prng_stdlib_get_number_in_range+0x4f>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x2e94(%rip),%rax
movsd  (%rax),%xmm1
addsd  0xea0(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%ebp
add    %ebx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @prng_stdlib_get_number_in_range(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = icmp sle i32 %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = load i32, i32* %4
store i32 %17, i32* %3
br label %34
18: ; preds = %2
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = sub nsw i32 %19, %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to double
%25 = call double (...) @rand()
%26 = load double, double* @RAND_MAX
%27 = fadd double %26, 1.000000e+00
%28 = fdiv double %25, %27
%29 = fmul double %24, %28
%30 = fptosi double %29 to i32
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = load i32, i32* %4
%33 = add nsw i32 %31, %32
store i32 %33, i32* %3
br label %34
34: ; preds = %18, %16
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @prng_stdlib_get_number_in_range(i32 %0, i32 %1) {
%3 = icmp sge i32 %1, %0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp eq i32 %1, %0
br i1 %6, label %18, label %7
7: ; preds = %2
%8 = sub i32 1, %0
%9 = add i32 %8, %1
%10 = sitofp i32 %9 to double
%11 = tail call double (...) @rand()
%12 = load double, double* @RAND_MAX
%13 = fadd double %12, 1.000000e+00
%14 = fdiv double %11, %13
%15 = fmul double %14, %10
%16 = fptosi double %15 to i32
%17 = add nsw i32 %16, %0
br label %18
18: ; preds = %2, %7
%19 = phi i32 [ %17, %7 ], [ %1, %2 ]
ret i32 %19
}