#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*/ *);
int *fillArray(int *a, int n, int x, int y) {
  srand(time(NULL));
  int i;
  int r;
  for (i = 0; i < n; i++) {
    r = rand() % y;
    a[i] = (r >= x) ? r : r + x;
  }
  return a;
}


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)
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    11b2 <fillArray+0x82>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     118d <fillArray+0x5d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <fillArray+0x66>
mov    -0x1c(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%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    115c <fillArray+0x2c>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r12
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15d,%r15d
jle    1184 <fillArray+0x54>
mov    %r15d,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %r14d
cmp    %ebp,%edx
mov    $0x0,%eax
cmovl  %ebp,%eax
add    %edx,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <fillArray+0x30>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @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 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %9
br label %13
13: ; preds = %36, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = call i32 (...) @rand()
%19 = load i32, i32* %8
%20 = srem i32 %18, %19
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = load i32, i32* %7
%23 = icmp sge i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = load i32, i32* %10
br label %30
26: ; preds = %17
%27 = load i32, i32* %10
%28 = load i32, i32* %7
%29 = add nsw i32 %27, %28
br label %30
30: ; preds = %26, %24
%31 = phi i32 [ %25, %24 ], [ %29, %26 ]
%32 = load i32*, i32** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %30
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %13
39: ; preds = %13
%40 = load i32*, i32** %5
ret i32* %40
}

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