#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*/);
void random_data(double **data, uint64_t numTimeseries,
                 uint64_t sizeTimeseries) {
  srand(0);
  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    %edi,%edi
call   1030 <srand@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11bf <random_data+0x9f>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11a9 <random_data+0x89>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e6e(%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    1159 <random_data+0x39>
jmp    11ae <random_data+0x8e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1143 <random_data+0x23>
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   1030 <srand@plt>
test   %r14,%r14
je     1190 <random_data+0x70>
mov    0x2ea1(%rip),%r12
xor    %ebx,%ebx
jmp    1159 <random_data+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r14,%rbx
je     1190 <random_data+0x70>
test   %r13,%r13
je     1150 <random_data+0x30>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <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    1160 <random_data+0x40>
jmp    1150 <random_data+0x30>
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 @srand(i32 0)
store i64 0, i64* %7
br label %10
10: ; preds = %35, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %5
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %38
14: ; preds = %10
store i64 0, i64* %8
br label %15
15: ; preds = %31, %14
%16 = load i64, i64* %8
%17 = load i64, i64* %6
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load i64, i64* @RAND_MAX
%23 = sitofp i64 %22 to double
%24 = fdiv double %21, %23
%25 = load double**, double*** %4
%26 = load i64, i64* %7
%27 = getelementptr inbounds double*, double** %25, i64 %26
%28 = load double*, double** %27
%29 = load i64, i64* %8
%30 = getelementptr inbounds double, double* %28, i64 %29
store double %24, double* %30
br label %31
31: ; preds = %19
%32 = load i64, i64* %8
%33 = add i64 %32, 1
store i64 %33, i64* %8
br label %15
34: ; preds = %15
br label %35
35: ; preds = %34
%36 = load i64, i64* %7
%37 = add i64 %36, 1
store i64 %37, i64* %7
br label %10
38: ; preds = %10
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 @srand(i32 0)
%5 = icmp eq i64 %1, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = icmp eq i64 %2, 0
br label %8
8: ; preds = %6, %13
%9 = phi i64 [ 0, %6 ], [ %14, %13 ]
br i1 %7, label %13, label %10
10: ; preds = %8
%11 = getelementptr inbounds double*, double** %0, i64 %9
br label %16
12: ; preds = %13, %3
ret void
13: ; preds = %16, %8
%14 = add nuw i64 %9, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %12, label %8
16: ; preds = %10, %16
%17 = phi i64 [ 0, %10 ], [ %25, %16 ]
%18 = tail call i64 (...) @rand()
%19 = sitofp i64 %18 to double
%20 = load i64, i64* @RAND_MAX
%21 = sitofp i64 %20 to double
%22 = fdiv double %19, %21
%23 = load double*, double** %11
%24 = getelementptr inbounds double, double* %23, i64 %17
store double %22, double* %24
%25 = add nuw i64 %17, 1
%26 = icmp eq i64 %25, %2
br i1 %26, label %13, label %16
}