#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 */
typedef int /*<<< orphan*/ clock_t;

/* Variables and functions */
int /*<<< orphan*/ clock();
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int *malloc(int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
unsigned int *create_random_array(unsigned int count) {
  clock_t start_t, end_t;
  start_t = clock();
  unsigned int i;
  int *array = malloc(sizeof(int) * count);
  srand((unsigned)time(NULL));
  for (i = 0; i <= count; i++) {
    array[i] = rand();
  }
  end_t = clock();
  double total_t = difftime(end_t, start_t);
  return array;
}


x86 assembly (clang, -O0):
<create_random_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
ja     11cb <create_random_array+0x6b>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119e <create_random_array+0x3e>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <difftime@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_random_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%r14d
lea    0x0(,%r15,4),%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <rand@plt>
mov    %ebx,%ecx
mov    %eax,0x0(%rbp,%rcx,4)
add    $0x1,%ebx
cmp    %r15d,%ebx
jbe    11a0 <create_random_array+0x40>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%edi
mov    %r14d,%esi
call   1040 <difftime@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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