#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__ calloc(int, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int *getRandomVector(int n) {
  int *a = (int *)calloc(100, sizeof(int));
  srand(time(NULL));
  for (int i = 0; i < n; ++i) {
    a[i] = rand();
  }
  return a;
}


x86 assembly (clang, -O0):
<getRandomVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x64,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a3 <getRandomVector+0x63>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,%edx
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    1175 <getRandomVector+0x35>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRandomVector>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0x64,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %ebp,%ebp
jle    1184 <getRandomVector+0x44>
mov    %ebp,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <getRandomVector+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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