#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*/ time_t;

/* Variables and functions */
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int *get_random_arr(int len) {
  int *arr = (int *)malloc(sizeof(int) * len);
  time_t t;
  srand((unsigned)time(&t));
  for (int i = 0; i < len; i++)
    arr[i] = rand() % 10000 + 1;
  return arr;
}


x86 assembly (clang, -O0):
<get_random_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ac <get_random_arr+0x6c>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1175 <get_random_arr+0x35>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_random_arr>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
lea    0xc(%rsp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r14d,%r14d
jle    11b7 <get_random_arr+0x77>
mov    %r14d,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2c,%rcx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <get_random_arr+0x40>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @get_random_arr(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%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** %3
%12 = call i64 @time(i32* %4)
%13 = trunc i64 %12 to i32
%14 = call i32 @srand(i32 %13)
store i32 0, i32* %5
br label %15
15: ; preds = %27, %1
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 10000
%22 = add nsw i32 %21, 1
%23 = load i32*, i32** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
br label %27
27: ; preds = %19
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %15
30: ; preds = %15
%31 = load i32*, i32** %3
ret i32* %31
}

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