#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 size_t int32_t;

/* Variables and functions */
scalar_t__ malloc(size_t);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int32_t *cr_rnd_arr(size_t len, int32_t cnt) {
  int32_t i;
  int32_t *rnd_arr;
  srand(time(NULL));
  rnd_arr = (int32_t *)malloc(len * sizeof(int32_t));
  for (i = 0; i < len; i++) {
    rnd_arr[i] = (int32_t)(rand() % (2 * cnt) - cnt);
  }
  return rnd_arr;
}


x86 assembly (clang, -O0):
<cr_rnd_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x8(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11be <cr_rnd_arr+0x7e>
mov    $0x0,%al
call   1060 <rand@plt>
cltq
mov    -0x10(%rbp),%rcx
shl    $0x1,%rcx
xor    %edx,%edx
div    %rcx
sub    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <cr_rnd_arr+0x39>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cr_rnd_arr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    0x0(,%r15,8),%rdi
call   1050 <malloc@plt>
mov    %rax,%r12
test   %r15,%r15
je     11b5 <cr_rnd_arr+0x75>
lea    (%r14,%r14,1),%r13
xor    %ebx,%ebx
jmp    1198 <cr_rnd_arr+0x58>
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rax
xor    %edx,%edx
div    %r13
sub    %r14,%rdx
mov    %rdx,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
je     11b5 <cr_rnd_arr+0x75>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rcx
mov    %rcx,%rdx
or     %r13,%rdx
shr    $0x20,%rdx
jne    1180 <cr_rnd_arr+0x40>
xor    %edx,%edx
div    %r13d
jmp    1188 <cr_rnd_arr+0x48>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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