#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__ clock();
int rand();
scalar_t__ random();
int /*<<< orphan*/ srandom(scalar_t__);
scalar_t__ time(int /*<<< orphan*/);
int random_int(int min, int max) {
  srandom(time(0) + clock() + random());
  unsigned int s_seed = 214013 * rand() + 2531011;
  return min + (s_seed ^ s_seed >> 15) % (max - min + 1);
}


x86 assembly (clang, -O0):
<random_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <random@plt>
mov    -0x18(%rbp),%rdi
add    %rax,%rdi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1070 <rand@plt>
imul   $0x343fd,%eax,%eax
add    $0x269ec3,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
shr    $0xf,%ecx
xor    %ecx,%eax
mov    -0x8(%rbp),%ecx
sub    -0x4(%rbp),%ecx
add    $0x1,%ecx
xor    %edx,%edx
div    %ecx
mov    -0x10(%rbp),%eax
add    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_int>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
add    %rax,%rbx
xor    %eax,%eax
call   1060 <random@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1070 <rand@plt>
imul   $0x343fd,%eax,%ecx
add    $0x269ec3,%ecx
mov    %ecx,%eax
shr    $0xf,%eax
xor    %ecx,%eax
sub    %r14d,%ebp
add    $0x1,%ebp
xor    %edx,%edx
div    %ebp
add    %edx,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @random_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i64 @time(i32 0)
%7 = call i64 (...) @clock()
%8 = add nsw i64 %6, %7
%9 = call i64 (...) @random()
%10 = add nsw i64 %8, %9
%11 = call i32 @srandom(i64 %10)
%12 = call i32 (...) @rand()
%13 = mul nsw i32 214013, %12
%14 = add nsw i32 %13, 2531011
store i32 %14, i32* %5
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = load i32, i32* %5
%18 = lshr i32 %17, 15
%19 = xor i32 %16, %18
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = sub nsw i32 %20, %21
%23 = add nsw i32 %22, 1
%24 = urem i32 %19, %23
%25 = add i32 %15, %24
ret i32 %25
}

LLVM IR (-O2):
define i32 @random_int(i32 %0, i32 %1) {
%3 = tail call i64 @time(i32 0)
%4 = tail call i64 (...) @clock()
%5 = add nsw i64 %4, %3
%6 = tail call i64 (...) @random()
%7 = add nsw i64 %5, %6
%8 = tail call i32 @srandom(i64 %7)
%9 = tail call i32 (...) @rand()
%10 = mul nsw i32 %9, 214013
%11 = add nsw i32 %10, 2531011
%12 = lshr i32 %11, 15
%13 = xor i32 %12, %11
%14 = sub i32 1, %0
%15 = add i32 %14, %1
%16 = urem i32 %13, %15
%17 = add i32 %16, %0
ret i32 %17
}