#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 *malloc(int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int *arrGen(int size) {
  if (size <= 0) {
    return NULL;
  }
  int *arr = malloc(sizeof(int) * size);
  if (arr == NULL) {
    return NULL;
  }
  srand(time(NULL));
  int ind;
  arr[0] = rand() % 100;
  for (ind = 1; ind < size; ind++) {
    arr[ind] = arr[ind - 1] + (rand() % 100) + 1;
  }
  return arr;
}


x86 assembly (clang, -O0):
<arrGen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1162 <arrGen+0x22>
movq   $0x0,-0x8(%rbp)
jmp    1212 <arrGen+0xd2>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118d <arrGen+0x4d>
movq   $0x0,-0x8(%rbp)
jmp    1212 <arrGen+0xd2>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120a <arrGen+0xca>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x20(%rbp),%edx
add    %eax,%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b9 <arrGen+0x79>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arrGen>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11e8 <arrGen+0xa8>
mov    %edi,%r14d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11e8 <arrGen+0xa8>
mov    %rax,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
mov    %r12d,(%r15)
cmp    $0x2,%r14d
jb     11eb <arrGen+0xab>
mov    %r14d,%r14d
mov    $0x1,%ebx
nop
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
sub    %ecx,%eax
add    %eax,%r12d
add    $0x1,%r12d
mov    %r12d,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11b0 <arrGen+0x70>
jmp    11eb <arrGen+0xab>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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