#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double random_number(int min_num, int max_num) {
  int result = 0, low_num = 0, hi_num = 0;
  if (min_num < max_num) {
    low_num = min_num;
    hi_num = max_num + 1;
  } else {
    low_num = max_num + 1;
    hi_num = min_num;
  }
  srand(time(NULL));
  result = (double)(rand() % (hi_num - low_num)) + low_num;
  return result;
}


x86 assembly (clang, -O0):
<random_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1173 <random_number+0x43>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <random_number+0x52>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x14(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_number>:
push   %rbp
push   %rbx
push   %rax
lea    0x1(%rsi),%ebx
cmp    %esi,%edi
mov    %ebx,%ebp
cmovl  %edi,%ebp
cmovge %edi,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
sub    %ebp,%ebx
cltd
idiv   %ebx
add    %ebp,%edx
cvtsi2sd %edx,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @random_number(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %3
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %7
br label %19
15: ; preds = %2
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
%18 = load i32, i32* %3
store i32 %18, i32* %7
br label %19
19: ; preds = %15, %11
%20 = call i32 @time(i32* null)
%21 = call i32 @srand(i32 %20)
%22 = call i32 (...) @rand()
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = sub nsw i32 %23, %24
%26 = srem i32 %22, %25
%27 = sitofp i32 %26 to double
%28 = load i32, i32* %6
%29 = sitofp i32 %28 to double
%30 = fadd double %27, %29
%31 = fptosi double %30 to i32
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = sitofp i32 %32 to double
ret double %33
}

LLVM IR (-O2):
define double @random_number(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, %1
%4 = add nsw i32 %1, 1
%5 = select i1 %3, i32 %0, i32 %4
%6 = select i1 %3, i32 %4, i32 %0
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32 (...) @rand()
%10 = sub nsw i32 %6, %5
%11 = srem i32 %9, %10
%12 = add i32 %5, %11
%13 = sitofp i32 %12 to double
ret double %13
}