#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 uint64_t;

/* Variables and functions */
scalar_t__ RAND_MAX;
scalar_t__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void random_data(double **data, uint64_t numTimeseries,
                 uint64_t sizeTimeseries) {
  srand(time(NULL));
  for (uint64_t i = 0; i < numTimeseries; i++) {
    for (uint64_t j = 0; j < sizeTimeseries; j++) {
      data[i][j] = ((double)rand() / (double)RAND_MAX);
    }
  }
}


x86 assembly (clang, -O0):
<random_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11d8 <random_data+0xa8>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c2 <random_data+0x92>
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e55(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1172 <random_data+0x42>
jmp    11c7 <random_data+0x97>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <random_data+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r14,%r14
je     11b0 <random_data+0x80>
mov    0x2e8a(%rip),%r12
xor    %ebx,%ebx
jmp    1179 <random_data+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %r14,%rbx
je     11b0 <random_data+0x80>
test   %r13,%r13
je     1170 <random_data+0x40>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r12),%xmm1
divsd  %xmm1,%xmm0
mov    (%r15,%rbx,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <random_data+0x50>
jmp    1170 <random_data+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @random_data(double** %0, i64 %1, i64 %2) {
%4 = alloca double**
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store double** %0, double*** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
store i64 0, i64* %7
br label %11
11: ; preds = %36, %3
%12 = load i64, i64* %7
%13 = load i64, i64* %5
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
store i64 0, i64* %8
br label %16
16: ; preds = %32, %15
%17 = load i64, i64* %8
%18 = load i64, i64* %6
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = call i64 (...) @rand()
%22 = sitofp i64 %21 to double
%23 = load i64, i64* @RAND_MAX
%24 = sitofp i64 %23 to double
%25 = fdiv double %22, %24
%26 = load double**, double*** %4
%27 = load i64, i64* %7
%28 = getelementptr inbounds double*, double** %26, i64 %27
%29 = load double*, double** %28
%30 = load i64, i64* %8
%31 = getelementptr inbounds double, double* %29, i64 %30
store double %25, double* %31
br label %32
32: ; preds = %20
%33 = load i64, i64* %8
%34 = add i64 %33, 1
store i64 %34, i64* %8
br label %16
35: ; preds = %16
br label %36
36: ; preds = %35
%37 = load i64, i64* %7
%38 = add i64 %37, 1
store i64 %38, i64* %7
br label %11
39: ; preds = %11
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @random_data(double** nocapture %0, i64 %1, i64 %2) {
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = icmp eq i64 %1, 0
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = icmp eq i64 %2, 0
br label %9
9: ; preds = %7, %14
%10 = phi i64 [ 0, %7 ], [ %15, %14 ]
br i1 %8, label %14, label %11
11: ; preds = %9
%12 = getelementptr inbounds double*, double** %0, i64 %10
br label %17
13: ; preds = %14, %3
ret void
14: ; preds = %17, %9
%15 = add nuw i64 %10, 1
%16 = icmp eq i64 %15, %1
br i1 %16, label %13, label %9
17: ; preds = %11, %17
%18 = phi i64 [ 0, %11 ], [ %26, %17 ]
%19 = tail call i64 (...) @rand()
%20 = sitofp i64 %19 to double
%21 = load i64, i64* @RAND_MAX
%22 = sitofp i64 %21 to double
%23 = fdiv double %20, %22
%24 = load double*, double** %12
%25 = getelementptr inbounds double, double* %24, i64 %18
store double %23, double* %25
%26 = add nuw i64 %18, 1
%27 = icmp eq i64 %26, %2
br i1 %27, label %14, label %17
}