#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 fillArray(int *v, int n, int min, int max) {
  int i, range;
  range = max - min;
  srand(time(NULL));
  for (i = 0; i < n; i++) {
    v[i] = (rand() % (range + 1)) + min;
  }
  return;
}


x86 assembly (clang, -O0):
<fillArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <fillArray+0x6d>
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
add    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <fillArray+0x35>
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @fillArray(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 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = sub i32 1, %2
%10 = add i32 %9, %3
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %18, %12 ]
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, %10
%16 = add nsw i32 %15, %2
%17 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %16, i32* %17
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12, %4
ret void
}