#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 */
struct timeb {
  unsigned int time;
  scalar_t__ millitm;
};

/* Variables and functions */
int /*<<< orphan*/ ftime(struct timeb *);
int rand();
scalar_t__ random();
int /*<<< orphan*/ srand(scalar_t__);
int random_int(int min, int max) {
  struct timeb t;
  ftime(&t);
  srand((unsigned int)1000 * t.time + t.millitm + 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    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <ftime@plt>
imul   $0x3e8,-0x18(%rbp),%eax
mov    %eax,%eax
add    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <random@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
call   1030 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
imul   $0x343fd,%eax,%eax
add    $0x269ec3,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x1c(%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    -0x20(%rbp),%eax
add    %edx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%r14d
mov    %rsp,%rdi
call   1050 <ftime@plt>
imul   $0x3e8,(%rsp),%ebx
add    0x8(%rsp),%rbx
xor    %eax,%eax
call   1040 <random@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <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
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeb = type { i32, i64 }
define i32 @random_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.timeb
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 @ftime(%struct.timeb* %5)
%8 = getelementptr inbounds %struct.timeb, %struct.timeb* %5, i32 0, i32 0
%9 = load i32, i32* %8
%10 = mul i32 1000, %9
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds %struct.timeb, %struct.timeb* %5, i32 0, i32 1
%13 = load i64, i64* %12
%14 = add nsw i64 %11, %13
%15 = call i64 (...) @random()
%16 = add nsw i64 %14, %15
%17 = call i32 @srand(i64 %16)
%18 = call i32 (...) @rand()
%19 = mul nsw i32 214013, %18
%20 = add nsw i32 %19, 2531011
store i32 %20, i32* %6
%21 = load i32, i32* %3
%22 = load i32, i32* %6
%23 = load i32, i32* %6
%24 = lshr i32 %23, 15
%25 = xor i32 %22, %24
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = sub nsw i32 %26, %27
%29 = add nsw i32 %28, 1
%30 = urem i32 %25, %29
%31 = add i32 %21, %30
ret i32 %31
}

LLVM IR (-O2):
%struct.timeb = type { i32, i64 }
define i32 @random_int(i32 %0, i32 %1) {
%3 = alloca %struct.timeb
%4 = bitcast %struct.timeb* %3 to i8*
%5 = call i32 @ftime(%struct.timeb* %3)
%6 = getelementptr inbounds %struct.timeb, %struct.timeb* %3, i64 0, i32 0
%7 = load i32, i32* %6
%8 = mul i32 %7, 1000
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds %struct.timeb, %struct.timeb* %3, i64 0, i32 1
%11 = load i64, i64* %10
%12 = add nsw i64 %11, %9
%13 = call i64 (...) @random()
%14 = add nsw i64 %12, %13
%15 = call i32 @srand(i64 %14)
%16 = call i32 (...) @rand()
%17 = mul nsw i32 %16, 214013
%18 = add nsw i32 %17, 2531011
%19 = lshr i32 %18, 15
%20 = xor i32 %19, %18
%21 = sub i32 1, %0
%22 = add i32 %21, %1
%23 = urem i32 %20, %22
%24 = add i32 %23, %0
ret i32 %24
}