#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 */
scalar_t__ malloc(unsigned int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
unsigned int time(int /*<<< orphan*/ *);
unsigned int *generateRandomIntArray(unsigned int length) {
  unsigned int *array;
  array = (unsigned int *)malloc(length * sizeof(unsigned int));
  for (unsigned int i = 0; i < length; ++i) {
    srand(time(NULL) * (i + 1));
    array[i] = rand() % 100 + 1;
  }
  return array;
}


x86 assembly (clang, -O0):
<generateRandomIntArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11b3 <generateRandomIntArray+0x73>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <generateRandomIntArray+0x24>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateRandomIntArray>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
je     11b9 <generateRandomIntArray+0x79>
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
call   1040 <time@plt>
lea    0x1(%rbx),%r12
mov    %r12d,%edi
imul   %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%r15,%rbx,4)
mov    %r12,%rbx
cmp    %r12,%r14
jne    1170 <generateRandomIntArray+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32* @generateRandomIntArray(i32 %0) {
%2 = shl i32 %0, 2
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to i32*
%5 = icmp eq i32 %0, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = zext i32 %0 to i64
br label %9
8: ; preds = %9, %1
ret i32* %4
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %12, %9 ]
%11 = tail call i32 @time(i32* null)
%12 = add nuw nsw i64 %10, 1
%13 = trunc i64 %12 to i32
%14 = mul i32 %11, %13
%15 = tail call i32 @srand(i32 %14)
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 100
%18 = add nsw i32 %17, 1
%19 = getelementptr inbounds i32, i32* %4, i64 %10
store i32 %18, i32* %19
%20 = icmp eq i64 %12, %7
br i1 %20, label %8, label %9
}