#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__ abs(int);
int /*<<< orphan*/ assert(int);
int rand();
int /*<<< orphan*/ ssub_is_oor(int, int);
int get_random_int(int lower, int upper) {
  assert(lower < upper);
  assert(!ssub_is_oor(upper, lower));
  assert(abs(upper - lower) <= RAND_MAX);
  return lower + (rand() % (upper - lower));
}


x86 assembly (clang, -O0):
<get_random_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <ssub_is_oor@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%edi
sub    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%rax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x8(%rbp),%ecx
sub    -0x4(%rbp),%ecx
cltd
idiv   %ecx
mov    -0xc(%rbp),%eax
add    %edx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_random_int>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
mov    %esi,%r14d
sub    %ebx,%r14d
setg   %dil
call   1050 <assert@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <ssub_is_oor@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r14d,%edi
call   1030 <abs@plt>
mov    0x2e6a(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
setle  %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r14d
add    %edx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define i32 @get_random_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = icmp slt i32 %5, %6
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = call i32 @ssub_is_oor(i32 %10, i32 %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = sub nsw i32 %17, %18
%20 = call i64 @abs(i32 %19)
%21 = load i64, i64* @RAND_MAX
%22 = icmp sle i64 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %3
%26 = call i32 (...) @rand()
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = sub nsw i32 %27, %28
%30 = srem i32 %26, %29
%31 = add nsw i32 %25, %30
ret i32 %31
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define i32 @get_random_int(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, %0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @ssub_is_oor(i32 %1, i32 %0)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = sub nsw i32 %1, %0
%11 = tail call i64 @abs(i32 %10)
%12 = load i64, i64* @RAND_MAX
%13 = icmp sle i64 %11, %12
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, %10
%18 = add nsw i32 %17, %0
ret i32 %18
}