#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 /*<<< orphan*/ Swap(int *, int, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int GenRandArr(int *Arr, int N, int LowerRange, int HigherRange) {
  srand(time(NULL));
  int MaxSize = N;
  int i = 0, r = 0;
  for (i = 0; i < MaxSize; i++) {
    Arr[i] = LowerRange + (rand() % (HigherRange - LowerRange));
  }
  while (MaxSize > 0) {
    r = rand() % MaxSize;
    if (r != MaxSize - 1)
      Swap(Arr, r, MaxSize - 1);
    MaxSize--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<GenRandArr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c2 <GenRandArr+0x82>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x14(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x24(%rbp),%edx
add    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1180 <GenRandArr+0x40>
jmp    11c7 <GenRandArr+0x87>
cmpl   $0x0,-0x18(%rbp)
jle    1210 <GenRandArr+0xd0>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1202 <GenRandArr+0xc2>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1040 <Swap@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <GenRandArr+0x87>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenRandArr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r14
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %ebx,%ebx
jle    118f <GenRandArr+0x4f>
sub    %r15d,%r12d
mov    %ebx,%r13d
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r12d
add    %r15d,%edx
mov    %edx,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <GenRandArr+0x30>
test   %ebx,%ebx
jg     11a8 <GenRandArr+0x68>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x1(%rbx),%eax
cmp    $0x1,%eax
jbe    118f <GenRandArr+0x4f>
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %ebx
add    $0xffffffff,%ebx
cmp    %edx,%ebx
je     11a0 <GenRandArr+0x60>
mov    %r14,%rdi
mov    %edx,%esi
mov    %ebx,%edx
call   1040 <Swap@plt>
jmp    11a0 <GenRandArr+0x60>

LLVM IR (-O0):
define i32 @GenRandArr(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
%11 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
%14 = load i32, i32* %6
store i32 %14, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %10
br label %15
15: ; preds = %31, %4
%16 = load i32, i32* %10
%17 = load i32, i32* %9
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i32, i32* %7
%21 = call i32 (...) @rand()
%22 = load i32, i32* %8
%23 = load i32, i32* %7
%24 = sub nsw i32 %22, %23
%25 = srem i32 %21, %24
%26 = add nsw i32 %20, %25
%27 = load i32*, i32** %5
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %26, i32* %30
br label %31
31: ; preds = %19
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %15
34: ; preds = %15
br label %35
35: ; preds = %52, %34
%36 = load i32, i32* %9
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %55
38: ; preds = %35
%39 = call i32 (...) @rand()
%40 = load i32, i32* %9
%41 = srem i32 %39, %40
store i32 %41, i32* %11
%42 = load i32, i32* %11
%43 = load i32, i32* %9
%44 = sub nsw i32 %43, 1
%45 = icmp ne i32 %42, %44
br i1 %45, label %46, label %52
46: ; preds = %38
%47 = load i32*, i32** %5
%48 = load i32, i32* %11
%49 = load i32, i32* %9
%50 = sub nsw i32 %49, 1
%51 = call i32 @Swap(i32* %47, i32 %48, i32 %50)
br label %52
52: ; preds = %46, %38
%53 = load i32, i32* %9
%54 = add nsw i32 %53, -1
store i32 %54, i32* %9
br label %35
55: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
define i32 @GenRandArr(i32* %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 %30
8: ; preds = %4
%9 = sub nsw i32 %3, %2
%10 = zext i32 %1 to i64
br label %12
11: ; preds = %12
br i1 %7, label %20, label %30
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %18, %12 ]
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, %9
%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, %10
br i1 %19, label %11, label %12
20: ; preds = %11, %28
%21 = phi i32 [ %24, %28 ], [ %1, %11 ]
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, %21
%24 = add nsw i32 %21, -1
%25 = icmp eq i32 %23, %24
br i1 %25, label %28, label %26
26: ; preds = %20
%27 = tail call i32 @Swap(i32* %0, i32 %23, i32 %24)
br label %28
28: ; preds = %26, %20
%29 = icmp ugt i32 %21, 1
br i1 %29, label %20, label %30
30: ; preds = %28, %4, %11
ret i32 0
}