#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(int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int *_test_data(size_t size) {
  srand(time(NULL));
  size_t i;
  int *result = (int *)malloc(sizeof(int) * size);
  for (i = 0; i < size; ++i) {
    result[i] = rand();
  }
  return result;
}


x86 assembly (clang, -O0):
<_test_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11aa <_test_data+0x6a>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1177 <_test_data+0x37>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_test_data>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %r14,%r14
je     1184 <_test_data+0x44>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1170 <_test_data+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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