#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 /*<<< orphan*/ assert(int *);
int *malloc(int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
generate_data(int **data, long numberofitems) {
  long i;
  *data = malloc(sizeof(int) * numberofitems);
  assert(*data);
  srand(time(NULL));
  for (i = 0; i < numberofitems; i++)
    (*data)[i] = rand();
}


x86 assembly (clang, -O0):
<generate_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11d3 <generate_data+0x83>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    119d <generate_data+0x4d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_data>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x0(,%rsi,4),%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
call   1040 <assert@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15,%r15
jle    11a6 <generate_data+0x56>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
mov    (%r14),%rcx
mov    %eax,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <generate_data+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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