#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 uint64_t;
typedef double uint32_t;

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ topCorrelations(double *, double *, int, double *, double *,
                                   int);
void correlation_data_flow(uint64_t numTimesteps, uint64_t numTimeseries,
                           uint64_t windowSize, double *precalculations,
                           double *data_pairs, double *correlations,
                           uint32_t *indices) {
  uint64_t numCorrelations = (numTimeseries * (numTimeseries - 1)) / 2;
  uint64_t index_correlation;
  double *sums_xy = (double *)calloc(numCorrelations, sizeof(double));
  double *correlations_step = (double *)calloc(numCorrelations, sizeof(double));
  uint32_t *indices_step =
      (uint32_t *)calloc(2 * numCorrelations, sizeof(uint32_t));
  double *correlations_top = (double *)malloc((10) * sizeof(double));
  uint32_t *indices_top = (uint32_t *)malloc(2 * (10) * sizeof(uint32_t));
  for (uint64_t s = 0; s < numTimesteps; s++) {
    index_correlation = 0;
    for (uint64_t i = 0; i < numTimeseries; i++) {
      double old_x = data_pairs[2 * s * numTimeseries + 2 * i + 1];
      double new_x = data_pairs[2 * s * numTimeseries + 2 * i];
      for (uint64_t j = i + 1; j < numTimeseries; j++) {
        double old_y = data_pairs[2 * s * numTimeseries + 2 * j + 1];
        double new_y = data_pairs[2 * s * numTimeseries + 2 * j];
        sums_xy[index_correlation] += new_x * new_y - old_x * old_y;
        correlations_step[index_correlation] =
            (windowSize * sums_xy[index_correlation] -
             precalculations[2 * s * numTimeseries + 2 * i] *
                 precalculations[2 * s * numTimeseries + 2 * j]) *
            precalculations[2 * s * numTimeseries + 2 * i + 1] *
            precalculations[2 * s * numTimeseries + 2 * j + 1];
        indices_step[2 * index_correlation] = j;
        indices_step[2 * index_correlation + 1] = i;
        index_correlation++;
      }
    }
    topCorrelations(correlations_step, indices_step, numCorrelations,
                    correlations_top, indices_top, (10));
    memcpy(&correlations[s * (10)], correlations_top, (10) * sizeof(double));
    memcpy(&indices[2 * s * (10)], indices_top, 2 * (10) * sizeof(uint32_t));
  }
  free(sums_xy);
  free(correlations_step);
  free(indices_step);
  free(correlations_top);
  free(indices_top);
}


x86 assembly (clang, -O0):
<correlation_data_flow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
shl    $0x1,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x48(%rbp)
mov    $0x50,%edi
call   1070 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0xa0,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1482 <correlation_data_flow+0x332>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1413 <correlation_data_flow+0x2c3>
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x60(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x60(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1400 <correlation_data_flow+0x2b0>
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x74(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x74(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm2
ff
movsd  -0x68(%rbp),%xmm1
mulsd  -0x80(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0xc(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x60(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x74(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x60(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x5c(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x74(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x74(%rbp),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x60(%rbp),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    125c <correlation_data_flow+0x10c>
jmp    1405 <correlation_data_flow+0x2b5>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11fe <correlation_data_flow+0xae>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    $0xa,%r9d
call   1040 <topCorrelations@plt>
mov    -0x28(%rbp),%rdi
imul   $0xa,-0x5c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x50(%rbp),%rsi
mov    $0x50,%edx
call   1060 <memcpy@plt>
mov    0x10(%rbp),%rdi
mov    -0x5c(%rbp),%eax
shl    $0x1,%eax
imul   $0xa,%eax,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x58(%rbp),%rsi
mov    $0xa0,%edx
call   1060 <memcpy@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11e4 <correlation_data_flow+0x94>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<correlation_data_flow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r9,0x70(%rsp)
mov    %r8,%rbx
mov    %rcx,%r14
mov    %edx,%r13d
mov    %edi,%r15d
mov    0xe0(%rsp),%rax
mov    %rax,0x68(%rsp)
lea    -0x1(%rsi),%eax
mov    %rsi,0x8(%rsp)
imul   %esi,%eax
mov    %eax,%r12d
shr    $0x1f,%r12d
add    %eax,%r12d
mov    %r12d,%ebp
sar    %ebp
mov    %ebp,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,0x40(%rsp)
mov    %ebp,0x2c(%rsp)
mov    %ebp,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,0x20(%rsp)
and    $0xfffffffe,%r12d
mov    %r12d,%edi
mov    %rbx,%rbp
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    $0x50,%edi
call   1070 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    $0xa0,%edi
call   1070 <malloc@plt>
mov    %rax,0x30(%rsp)
test   %r15d,%r15d
jle    146a <correlation_data_flow+0x31a>
cvtsi2sd %r13d,%xmm5
mov    0x8(%rsp),%rax
movslq %eax,%rcx
mov    %rcx,0x80(%rsp)
mov    %r15d,%ecx
mov    %rcx,0x58(%rsp)
mov    %eax,%edx
add    %eax,%eax
mov    %rax,0x50(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
movapd 0xdce(%rip),%xmm6
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    %rdx,0x48(%rsp)
movsd  %xmm5,0x60(%rsp)
jmp    12f1 <correlation_data_flow+0x1a1>
nopl   0x0(%rax)
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    0x2c(%rsp),%edx
mov    0x38(%rsp),%r15
mov    %r15,%rcx
mov    0x30(%rsp),%r12
mov    %r12,%r8
mov    $0xa,%r9d
call   1040 <topCorrelations@plt>
mov    0x10(%rsp),%r13
lea    0x0(%r13,%r13,1),%eax
lea    (%rax,%rax,4),%eax
mov    0x70(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    %r15,%rsi
mov    $0x50,%edx
call   1060 <memcpy@plt>
lea    0x0(,%r13,4),%eax
lea    (%rax,%rax,4),%eax
mov    0x68(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    %r12,%rsi
mov    $0xa0,%edx
call   1060 <memcpy@plt>
movapd 0xd3d(%rip),%xmm6
mov    0x48(%rsp),%rdx
movsd  0x60(%rsp),%xmm5
add    $0x1,%r13
mov    0x18(%rsp),%rax
add    0x50(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %r13,0x10(%rsp)
cmp    0x58(%rsp),%r13
je     146a <correlation_data_flow+0x31a>
cmpl   $0x0,0x8(%rsp)
jle    1250 <correlation_data_flow+0x100>
mov    0x10(%rsp),%rax
imul   0x8(%rsp),%eax
add    %eax,%eax
cltq
mov    %rax,0x78(%rsp)
xor    %ecx,%ecx
mov    $0x1,%r10d
mov    0x18(%rsp),%rsi
xor    %edi,%edi
jmp    1341 <correlation_data_flow+0x1f1>
mov    0x90(%rsp),%r10
add    $0x1,%r10
add    $0x2,%rsi
mov    0x88(%rsp),%rcx
cmp    %rdx,%rcx
je     1250 <correlation_data_flow+0x100>
lea    0x1(%rcx),%rax
cmp    0x80(%rsp),%rax
mov    %r10,0x90(%rsp)
mov    %rax,0x88(%rsp)
jge    1320 <correlation_data_flow+0x1d0>
mov    0x78(%rsp),%rax
lea    (%rax,%rcx,2),%rax
mov    %rax,%rdx
or     $0x1,%rdx
mov    %rax,0xa0(%rsp)
movsd  0x0(%rbp,%rax,8),%xmm0
mov    %rdx,0x98(%rsp)
movsd  0x0(%rbp,%rdx,8),%xmm1
xorpd  %xmm6,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
movslq %edi,%r11
mov    0x40(%rsp),%rax
lea    (%rax,%r11,8),%r13
mov    0x20(%rsp),%rax
lea    (%rax,%r11,8),%r15
add    %r11d,%r11d
xor    %r8d,%r8d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rsi,%r8,1),%r9d
add    $0x2,%r9d
lea    0x3(%rsi,%r8,1),%r12d
movslq %r12d,%rax
movslq %r9d,%rdx
movsd  0x0(%rbp,%rax,8),%xmm3
mulsd  %xmm1,%xmm3
movsd  0x0(%rbp,%rdx,8),%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
addsd  0x0(%r13,%r8,4),%xmm4
movsd  %xmm4,0x0(%r13,%r8,4)
movsd  (%r14,%rdx,8),%xmm3
mov    0x48(%rsp),%rdx
mov    0xa0(%rsp),%rcx
mulsd  (%r14,%rcx,8),%xmm3
mulsd  %xmm5,%xmm4
subsd  %xmm3,%xmm4
mov    0x98(%rsp),%rcx
mulsd  (%r14,%rcx,8),%xmm4
mulsd  (%r14,%rax,8),%xmm4
movsd  %xmm4,(%r15,%r8,4)
xorps  %xmm3,%xmm3
cvtsi2sd %r10d,%xmm3
lea    (%r11,%r8,1),%rax
cltq
movsd  %xmm3,(%rbx,%rax,8)
add    $0x1,%eax
cltq
movsd  %xmm2,(%rbx,%rax,8)
add    $0x1,%r10
add    $0x2,%r8
add    $0x1,%edi
cmp    %r10,%rdx
jne    13c0 <correlation_data_flow+0x270>
jmp    1320 <correlation_data_flow+0x1d0>
mov    0x40(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @correlation_data_flow(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca i32
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca i32
%27 = alloca double
%28 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%29 = load i32, i32* %9
%30 = load i32, i32* %9
%31 = sub nsw i32 %30, 1
%32 = mul nsw i32 %29, %31
%33 = sdiv i32 %32, 2
store i32 %33, i32* %15
%34 = load i32, i32* %15
%35 = call i64 @calloc(i32 %34, i32 8)
%36 = inttoptr i64 %35 to double*
store double* %36, double** %17
%37 = load i32, i32* %15
%38 = call i64 @calloc(i32 %37, i32 8)
%39 = inttoptr i64 %38 to double*
store double* %39, double** %18
%40 = load i32, i32* %15
%41 = mul nsw i32 2, %40
%42 = call i64 @calloc(i32 %41, i32 8)
%43 = inttoptr i64 %42 to double*
store double* %43, double** %19
%44 = call i64 @malloc(i32 80)
%45 = inttoptr i64 %44 to double*
store double* %45, double** %20
%46 = call i64 @malloc(i32 160)
%47 = inttoptr i64 %46 to double*
store double* %47, double** %21
store i32 0, i32* %22
br label %48
48: ; preds = %232, %7
%49 = load i32, i32* %22
%50 = load i32, i32* %8
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %235
52: ; preds = %48
store i32 0, i32* %16
store i32 0, i32* %23
br label %53
53: ; preds = %207, %52
%54 = load i32, i32* %23
%55 = load i32, i32* %9
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %210
57: ; preds = %53
%58 = load double*, double** %12
%59 = load i32, i32* %22
%60 = mul nsw i32 2, %59
%61 = load i32, i32* %9
%62 = mul nsw i32 %60, %61
%63 = load i32, i32* %23
%64 = mul nsw i32 2, %63
%65 = add nsw i32 %62, %64
%66 = add nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %58, i64 %67
%69 = load double, double* %68
store double %69, double* %24
%70 = load double*, double** %12
%71 = load i32, i32* %22
%72 = mul nsw i32 2, %71
%73 = load i32, i32* %9
%74 = mul nsw i32 %72, %73
%75 = load i32, i32* %23
%76 = mul nsw i32 2, %75
%77 = add nsw i32 %74, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %70, i64 %78
%80 = load double, double* %79
store double %80, double* %25
%81 = load i32, i32* %23
%82 = add nsw i32 %81, 1
store i32 %82, i32* %26
br label %83
83: ; preds = %203, %57
%84 = load i32, i32* %26
%85 = load i32, i32* %9
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %206
87: ; preds = %83
%88 = load double*, double** %12
%89 = load i32, i32* %22
%90 = mul nsw i32 2, %89
%91 = load i32, i32* %9
%92 = mul nsw i32 %90, %91
%93 = load i32, i32* %26
%94 = mul nsw i32 2, %93
%95 = add nsw i32 %92, %94
%96 = add nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %88, i64 %97
%99 = load double, double* %98
store double %99, double* %27
%100 = load double*, double** %12
%101 = load i32, i32* %22
%102 = mul nsw i32 2, %101
%103 = load i32, i32* %9
%104 = mul nsw i32 %102, %103
%105 = load i32, i32* %26
%106 = mul nsw i32 2, %105
%107 = add nsw i32 %104, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %100, i64 %108
%110 = load double, double* %109
store double %110, double* %28
%111 = load double, double* %25
%112 = load double, double* %28
%113 = load double, double* %24
%114 = load double, double* %27
%115 = fmul double %113, %114
%116 = fneg double %115
%117 = call double @llvm.fmuladd.f64(double %111, double %112, double %116)
%118 = load double*, double** %17
%119 = load i32, i32* %16
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double, double* %118, i64 %120
%122 = load double, double* %121
%123 = fadd double %122, %117
store double %123, double* %121
%124 = load i32, i32* %10
%125 = sitofp i32 %124 to double
%126 = load double*, double** %17
%127 = load i32, i32* %16
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %126, i64 %128
%130 = load double, double* %129
%131 = load double*, double** %11
%132 = load i32, i32* %22
%133 = mul nsw i32 2, %132
%134 = load i32, i32* %9
%135 = mul nsw i32 %133, %134
%136 = load i32, i32* %23
%137 = mul nsw i32 2, %136
%138 = add nsw i32 %135, %137
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds double, double* %131, i64 %139
%141 = load double, double* %140
%142 = load double*, double** %11
%143 = load i32, i32* %22
%144 = mul nsw i32 2, %143
%145 = load i32, i32* %9
%146 = mul nsw i32 %144, %145
%147 = load i32, i32* %26
%148 = mul nsw i32 2, %147
%149 = add nsw i32 %146, %148
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %142, i64 %150
%152 = load double, double* %151
%153 = fmul double %141, %152
%154 = fneg double %153
%155 = call double @llvm.fmuladd.f64(double %125, double %130, double %154)
%156 = load double*, double** %11
%157 = load i32, i32* %22
%158 = mul nsw i32 2, %157
%159 = load i32, i32* %9
%160 = mul nsw i32 %158, %159
%161 = load i32, i32* %23
%162 = mul nsw i32 2, %161
%163 = add nsw i32 %160, %162
%164 = add nsw i32 %163, 1
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds double, double* %156, i64 %165
%167 = load double, double* %166
%168 = fmul double %155, %167
%169 = load double*, double** %11
%170 = load i32, i32* %22
%171 = mul nsw i32 2, %170
%172 = load i32, i32* %9
%173 = mul nsw i32 %171, %172
%174 = load i32, i32* %26
%175 = mul nsw i32 2, %174
%176 = add nsw i32 %173, %175
%177 = add nsw i32 %176, 1
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %169, i64 %178
%180 = load double, double* %179
%181 = fmul double %168, %180
%182 = load double*, double** %18
%183 = load i32, i32* %16
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds double, double* %182, i64 %184
store double %181, double* %185
%186 = load i32, i32* %26
%187 = sitofp i32 %186 to double
%188 = load double*, double** %19
%189 = load i32, i32* %16
%190 = mul nsw i32 2, %189
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds double, double* %188, i64 %191
store double %187, double* %192
%193 = load i32, i32* %23
%194 = sitofp i32 %193 to double
%195 = load double*, double** %19
%196 = load i32, i32* %16
%197 = mul nsw i32 2, %196
%198 = add nsw i32 %197, 1
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds double, double* %195, i64 %199
store double %194, double* %200
%201 = load i32, i32* %16
%202 = add nsw i32 %201, 1
store i32 %202, i32* %16
br label %203
203: ; preds = %87
%204 = load i32, i32* %26
%205 = add nsw i32 %204, 1
store i32 %205, i32* %26
br label %83
206: ; preds = %83
br label %207
207: ; preds = %206
%208 = load i32, i32* %23
%209 = add nsw i32 %208, 1
store i32 %209, i32* %23
br label %53
210: ; preds = %53
%211 = load double*, double** %18
%212 = load double*, double** %19
%213 = load i32, i32* %15
%214 = load double*, double** %20
%215 = load double*, double** %21
%216 = call i32 @topCorrelations(double* %211, double* %212, i32 %213, double* %214, double* %215, i32 10)
%217 = load double*, double** %13
%218 = load i32, i32* %22
%219 = mul nsw i32 %218, 10
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds double, double* %217, i64 %220
%222 = load double*, double** %20
%223 = call i32 @memcpy(double* %221, double* %222, i32 80)
%224 = load double*, double** %14
%225 = load i32, i32* %22
%226 = mul nsw i32 2, %225
%227 = mul nsw i32 %226, 10
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds double, double* %224, i64 %228
%230 = load double*, double** %21
%231 = call i32 @memcpy(double* %229, double* %230, i32 160)
br label %232
232: ; preds = %210
%233 = load i32, i32* %22
%234 = add nsw i32 %233, 1
store i32 %234, i32* %22
br label %48
235: ; preds = %48
%236 = load double*, double** %17
%237 = call i32 @free(double* %236)
%238 = load double*, double** %18
%239 = call i32 @free(double* %238)
%240 = load double*, double** %19
%241 = call i32 @free(double* %240)
%242 = load double*, double** %20
%243 = call i32 @free(double* %242)
%244 = load double*, double** %21
%245 = call i32 @free(double* %244)
ret void
}

LLVM IR (-O2):
define void @correlation_data_flow(i32 %0, i32 %1, i32 %2, double* nocapture %3, double* nocapture %4, double* %5, double* %6) {
%8 = add nsw i32 %1, -1
%9 = mul nsw i32 %8, %1
%10 = sdiv i32 %9, 2
%11 = tail call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to double*
%13 = tail call i64 @calloc(i32 %10, i32 8)
%14 = inttoptr i64 %13 to double*
%15 = shl nsw i32 %10, 1
%16 = tail call i64 @calloc(i32 %15, i32 8)
%17 = inttoptr i64 %16 to double*
%18 = tail call i64 @malloc(i32 80)
%19 = inttoptr i64 %18 to double*
%20 = tail call i64 @malloc(i32 160)
%21 = inttoptr i64 %20 to double*
%22 = icmp sgt i32 %0, 0
br i1 %22, label %23, label %36
23: ; preds = %7
%24 = icmp sgt i32 %1, 0
%25 = sitofp i32 %2 to double
%26 = sext i32 %1 to i64
%27 = zext i32 %0 to i64
%28 = zext i32 %1 to i64
br label %29
29: ; preds = %23, %48
%30 = phi i64 [ 0, %23 ], [ %58, %48 ]
br i1 %24, label %31, label %48
31: ; preds = %29
%32 = trunc i64 %30 to i32
%33 = shl i32 %32, 1
%34 = mul nsw i32 %33, %1
%35 = sext i32 %34 to i64
br label %60
36: ; preds = %48, %7
%37 = tail call i32 @free(double* %12)
%38 = tail call i32 @free(double* %14)
%39 = tail call i32 @free(double* %17)
%40 = tail call i32 @free(double* %19)
%41 = tail call i32 @free(double* %21)
ret void
42: ; preds = %80
%43 = trunc i64 %118 to i32
br label %44
44: ; preds = %42, %60
%45 = phi i32 [ %63, %60 ], [ %43, %42 ]
%46 = add nuw nsw i64 %62, 1
%47 = icmp eq i64 %69, %28
br i1 %47, label %48, label %60
48: ; preds = %44, %29
%49 = tail call i32 @topCorrelations(double* %14, double* %17, i32 %10, double* %19, double* %21, i32 10)
%50 = mul i64 %30, 10
%51 = and i64 %50, 4294967294
%52 = getelementptr inbounds double, double* %5, i64 %51
%53 = tail call i32 @memcpy(double* %52, double* %19, i32 80)
%54 = mul i64 %30, 20
%55 = and i64 %54, 4294967292
%56 = getelementptr inbounds double, double* %6, i64 %55
%57 = tail call i32 @memcpy(double* %56, double* %21, i32 160)
%58 = add nuw nsw i64 %30, 1
%59 = icmp eq i64 %58, %27
br i1 %59, label %36, label %29
60: ; preds = %31, %44
%61 = phi i64 [ 0, %31 ], [ %69, %44 ]
%62 = phi i64 [ 1, %31 ], [ %46, %44 ]
%63 = phi i32 [ 0, %31 ], [ %45, %44 ]
%64 = shl nuw nsw i64 %61, 1
%65 = add nsw i64 %64, %35
%66 = or i64 %65, 1
%67 = getelementptr inbounds double, double* %4, i64 %65
%68 = load double, double* %67
%69 = add nuw nsw i64 %61, 1
%70 = icmp slt i64 %69, %26
br i1 %70, label %71, label %44
71: ; preds = %60
%72 = getelementptr inbounds double, double* %4, i64 %66
%73 = load double, double* %72
%74 = fneg double %73
%75 = getelementptr inbounds double, double* %3, i64 %65
%76 = getelementptr inbounds double, double* %3, i64 %66
%77 = trunc i64 %61 to i32
%78 = sitofp i32 %77 to double
%79 = sext i32 %63 to i64
br label %80
80: ; preds = %71, %80
%81 = phi i64 [ %62, %71 ], [ %119, %80 ]
%82 = phi i64 [ %79, %71 ], [ %118, %80 ]
%83 = trunc i64 %81 to i32
%84 = shl nuw nsw i32 %83, 1
%85 = add nsw i32 %84, %34
%86 = or i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %4, i64 %87
%89 = load double, double* %88
%90 = sext i32 %85 to i64
%91 = getelementptr inbounds double, double* %4, i64 %90
%92 = load double, double* %91
%93 = fmul double %89, %74
%94 = tail call double @llvm.fmuladd.f64(double %68, double %92, double %93)
%95 = getelementptr inbounds double, double* %12, i64 %82
%96 = load double, double* %95
%97 = fadd double %96, %94
store double %97, double* %95
%98 = load double, double* %75
%99 = getelementptr inbounds double, double* %3, i64 %90
%100 = load double, double* %99
%101 = fneg double %98
%102 = fmul double %100, %101
%103 = tail call double @llvm.fmuladd.f64(double %25, double %97, double %102)
%104 = load double, double* %76
%105 = fmul double %104, %103
%106 = getelementptr inbounds double, double* %3, i64 %87
%107 = load double, double* %106
%108 = fmul double %107, %105
%109 = getelementptr inbounds double, double* %14, i64 %82
store double %108, double* %109
%110 = sitofp i32 %83 to double
%111 = trunc i64 %82 to i32
%112 = shl nsw i32 %111, 1
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %17, i64 %113
store double %110, double* %114
%115 = or i32 %112, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %17, i64 %116
store double %78, double* %117
%118 = add nsw i64 %82, 1
%119 = add nuw nsw i64 %81, 1
%120 = icmp eq i64 %119, %28
br i1 %120, label %42, label %80
}