#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*/ fail(char *, int, int);
int lcg_knuth_rand();
int randombounds(int a, int b) {
  if (b < a)
    fail("the interval [%d, %d] is empty!", a, b);
  if (b == a)
    return b;
  return a + lcg_knuth_rand() % (b - a + 1);
}


x86 assembly (clang, -O0):
<randombounds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    114c <randombounds+0x2c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb9(%rip),%rdi
call   1030 <fail@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1163 <randombounds+0x43>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1184 <randombounds+0x64>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <lcg_knuth_rand@plt>
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randombounds>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
cmp    %edi,%esi
jge    113e <randombounds+0x1e>
lea    0xecc(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <fail@plt>
mov    %ebp,%ebx
sub    %r14d,%ebx
je     1157 <randombounds+0x37>
xor    %eax,%eax
call   1040 <lcg_knuth_rand@plt>
add    $0x1,%ebx
cltd
idiv   %ebx
mov    %edx,%ebp
add    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"the interval [%d, %d] is empty!\00"
define i32 @randombounds(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i32 @fail(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
br label %13
13: ; preds = %9, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32, i32* %5
store i32 %18, i32* %3
br label %28
19: ; preds = %13
%20 = load i32, i32* %4
%21 = call i32 (...) @lcg_knuth_rand()
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = sub nsw i32 %22, %23
%25 = add nsw i32 %24, 1
%26 = srem i32 %21, %25
%27 = add nsw i32 %20, %26
store i32 %27, i32* %3
br label %28
28: ; preds = %19, %17
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [32 x i8] c"the interval [%d, %d] is empty!\00"
define i32 @randombounds(i32 %0, i32 %1) {
%3 = icmp slt i32 %1, %0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @fail(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %6
6: ; preds = %4, %2
%7 = icmp eq i32 %1, %0
br i1 %7, label %14, label %8
8: ; preds = %6
%9 = tail call i32 (...) @lcg_knuth_rand()
%10 = sub i32 1, %0
%11 = add i32 %10, %1
%12 = srem i32 %9, %11
%13 = add nsw i32 %12, %0
br label %14
14: ; preds = %6, %8
%15 = phi i32 [ %13, %8 ], [ %1, %6 ]
ret i32 %15
}