#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(size_t);
size_t rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int *newArray(size_t size) {
  int *array = (int *)malloc(size * sizeof(int));
  int on;
  srand((unsigned)time(NULL));
  for (on = 0; on < size; on++) {
    array[on] = rand() % (size * 10);
  }
  return array;
}


x86 assembly (clang, -O0):
<newArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
shl    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11ac <newArray+0x6c>
mov    $0x0,%al
call   1060 <rand@plt>
imul   $0xa,-0x8(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <newArray+0x34>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newArray>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0x0(,%rdi,4),%rdi
call   1050 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15,%r15
je     11ac <newArray+0x6c>
lea    (%r15,%r15,1),%rax
lea    (%rax,%rax,4),%r12
xor    %ebx,%ebx
jmp    1192 <newArray+0x52>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r12
mov    %edx,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
je     11ac <newArray+0x6c>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%rcx
or     %r12,%rcx
shr    $0x20,%rcx
jne    1180 <newArray+0x40>
xor    %edx,%edx
div    %r12d
jmp    1185 <newArray+0x45>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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