#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*/ *);
void randNum(int arr[], int size, int max, int min) {
  srand(time(NULL));
  max -= min;
  for (int k = size - 1; k >= 0; k--)
    arr[k] = rand() % max + min;
}


x86 assembly (clang, -O0):
<randNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     119a <randNum+0x6a>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0x10(%rbp)
add    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1169 <randNum+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randNum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %esi,%r15d
mov    %rdi,%r12
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15d,%r15d
jle    118f <randNum+0x5f>
sub    %r14d,%r13d
mov    %r15d,%ebx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x2(%rbx),%ebp
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %r13d
add    %r14d,%edx
mov    %edx,(%r12,%rbp,4)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1170 <randNum+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @randNum(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = sub nsw i32 %2, %3
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = zext i32 %1 to i64
br label %12
11: ; preds = %12, %4
ret void
12: ; preds = %9, %12
%13 = phi i64 [ %10, %9 ], [ %14, %12 ]
%14 = add nsw i64 %13, -1
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, %7
%17 = add nsw i32 %16, %3
%18 = and i64 %14, 4294967295
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %17, i32* %19
%20 = icmp ugt i64 %13, 1
br i1 %20, label %12, label %11
}