#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 */
int /*<<< orphan*/ assert(int);
unsigned long long rng();
unsigned rrng(unsigned low, unsigned high) {
  unsigned long long tmp;
  unsigned res, elements;
  assert(low <= high);
  elements = high - low + 1;
  tmp = rng();
  tmp *= elements;
  tmp >>= 32;
  tmp += low;
  res = tmp;
  do {
  } while (0);
  assert(low <= res);
  assert(res <= high);
  return res;
}


x86 assembly (clang, -O0):
<rrng>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rng@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x20,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x14(%rbp)
jmp    1187 <rrng+0x67>
mov    -0x4(%rbp),%eax
cmp    -0x14(%rbp),%eax
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rrng>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
xor    %edi,%edi
mov    %esi,%ebp
sub    %r15d,%ebp
setae  %dil
call   1030 <assert@plt>
add    $0x1,%ebp
xor    %eax,%eax
call   1040 <rng@plt>
mov    %rax,%rbx
imul   %rbp,%rbx
shr    $0x20,%rbx
add    %r15d,%ebx
xor    %edi,%edi
cmp    %r15d,%ebx
setae  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    %r14d,%ebx
setbe  %dil
call   1030 <assert@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rrng(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = icmp ule i32 %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = sub i32 %13, %14
%16 = add i32 %15, 1
store i32 %16, i32* %7
%17 = call i64 (...) @rng()
store i64 %17, i64* %5
%18 = load i32, i32* %7
%19 = zext i32 %18 to i64
%20 = load i64, i64* %5
%21 = mul i64 %20, %19
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = lshr i64 %22, 32
store i64 %23, i64* %5
%24 = load i32, i32* %3
%25 = zext i32 %24 to i64
%26 = load i64, i64* %5
%27 = add i64 %26, %25
store i64 %27, i64* %5
%28 = load i64, i64* %5
%29 = trunc i64 %28 to i32
store i32 %29, i32* %6
br label %30
30: ; preds = %2
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = load i32, i32* %6
%34 = icmp ule i32 %32, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32, i32* %6
%38 = load i32, i32* %4
%39 = icmp ule i32 %37, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
define i32 @rrng(i32 %0, i32 %1) {
%3 = icmp uge i32 %1, %0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = sub i32 1, %0
%7 = add i32 %6, %1
%8 = tail call i64 (...) @rng()
%9 = zext i32 %7 to i64
%10 = mul i64 %8, %9
%11 = lshr i64 %10, 32
%12 = trunc i64 %11 to i32
%13 = add i32 %12, %0
%14 = icmp uge i32 %13, %0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = icmp ule i32 %13, %1
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
ret i32 %13
}