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

/* Variables and functions */
double *allocateDoubleVector(int);
double correlation(float *, float *, int);
double multipleCorrelation(double **X, double *y, int n, int m, double *b) {
  int i, j;
  double *yprime;
  yprime = allocateDoubleVector(m);
  for (i = 0; i < m; i++) {
    yprime[i] = 0.0;
    for (j = 0; j < n; j++) {
      yprime[i] += b[j] * X[i][j];
    }
  }
  return correlation((float *)y, (float *)yprime, m);
}


x86 assembly (clang, -O0):
<multipleCorrelation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <allocateDoubleVector@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d9 <multipleCorrelation+0xb9>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c6 <multipleCorrelation+0xa6>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1170 <multipleCorrelation+0x50>
jmp    11cb <multipleCorrelation+0xab>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <multipleCorrelation+0x2d>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <correlation@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multipleCorrelation>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r12
mov    %ecx,%edi
call   1030 <allocateDoubleVector@plt>
test   %r15d,%r15d
jle    11dc <multipleCorrelation+0xbc>
mov    %r15d,%r9d
mov    %ebp,%r8d
mov    %r8d,%esi
and    $0xfffffffe,%esi
xor    %edi,%edi
jmp    1169 <multipleCorrelation+0x49>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rdi
cmp    %r9,%rdi
je     11dc <multipleCorrelation+0xbc>
movq   $0x0,(%rax,%rdi,8)
test   %ebp,%ebp
jle    1160 <multipleCorrelation+0x40>
mov    (%r12,%rdi,8),%rdx
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
cmp    $0x1,%ebp
je     11c1 <multipleCorrelation+0xa1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rcx,8),%xmm1
mulsd  (%rdx,%rcx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rdi,8)
movsd  0x8(%rbx,%rcx,8),%xmm0
mulsd  0x8(%rdx,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rdi,8)
add    $0x2,%rcx
cmp    %rcx,%rsi
jne    1190 <multipleCorrelation+0x70>
test   $0x1,%r8b
je     1160 <multipleCorrelation+0x40>
movsd  (%rbx,%rcx,8),%xmm1
mulsd  (%rdx,%rcx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rdi,8)
jmp    1160 <multipleCorrelation+0x40>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %r15d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <correlation@plt>

LLVM IR (-O0):
define double @multipleCorrelation(double** %0, double* %1, i32 %2, i32 %3, double* %4) {
%6 = alloca double**
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
store double** %0, double*** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double* %4, double** %10
%14 = load i32, i32* %9
%15 = call double* @allocateDoubleVector(i32 %14)
store double* %15, double** %13
store i32 0, i32* %11
br label %16
16: ; preds = %54, %5
%17 = load i32, i32* %11
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %57
20: ; preds = %16
%21 = load double*, double** %13
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
store double 0.000000e+00, double* %24
store i32 0, i32* %12
br label %25
25: ; preds = %50, %20
%26 = load i32, i32* %12
%27 = load i32, i32* %8
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %53
29: ; preds = %25
%30 = load double*, double** %10
%31 = load i32, i32* %12
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = load double**, double*** %6
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double*, double** %35, i64 %37
%39 = load double*, double** %38
%40 = load i32, i32* %12
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = load double*, double** %13
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = call double @llvm.fmuladd.f64(double %34, double %43, double %48)
store double %49, double* %47
br label %50
50: ; preds = %29
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
store i32 %52, i32* %12
br label %25
53: ; preds = %25
br label %54
54: ; preds = %53
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %16
57: ; preds = %16
%58 = load double*, double** %7
%59 = bitcast double* %58 to float*
%60 = load double*, double** %13
%61 = bitcast double* %60 to float*
%62 = load i32, i32* %9
%63 = call double @correlation(float* %59, float* %61, i32 %62)
ret double %63
}

LLVM IR (-O2):
define double @multipleCorrelation(double** nocapture %0, double* %1, i32 %2, i32 %3, double* nocapture %4) {
%6 = tail call double* @allocateDoubleVector(i32 %3)
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %52
8: ; preds = %5
%9 = icmp sgt i32 %2, 0
%10 = zext i32 %3 to i64
%11 = zext i32 %2 to i64
%12 = and i64 %11, 1
%13 = icmp eq i32 %2, 1
%14 = and i64 %11, 4294967294
%15 = icmp eq i64 %12, 0
br label %16
16: ; preds = %8, %49
%17 = phi i64 [ 0, %8 ], [ %50, %49 ]
%18 = getelementptr inbounds double, double* %6, i64 %17
store double 0.000000e+00, double* %18
br i1 %9, label %19, label %49
19: ; preds = %16
%20 = getelementptr inbounds double*, double** %0, i64 %17
%21 = load double*, double** %20
br i1 %13, label %40, label %22
22: ; preds = %19, %22
%23 = phi double [ %36, %22 ], [ 0.000000e+00, %19 ]
%24 = phi i64 [ %37, %22 ], [ 0, %19 ]
%25 = phi i64 [ %38, %22 ], [ 0, %19 ]
%26 = getelementptr inbounds double, double* %4, i64 %24
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %21, i64 %24
%29 = load double, double* %28
%30 = tail call double @llvm.fmuladd.f64(double %27, double %29, double %23)
store double %30, double* %18
%31 = or i64 %24, 1
%32 = getelementptr inbounds double, double* %4, i64 %31
%33 = load double, double* %32
%34 = getelementptr inbounds double, double* %21, i64 %31
%35 = load double, double* %34
%36 = tail call double @llvm.fmuladd.f64(double %33, double %35, double %30)
store double %36, double* %18
%37 = add nuw nsw i64 %24, 2
%38 = add i64 %25, 2
%39 = icmp eq i64 %38, %14
br i1 %39, label %40, label %22
40: ; preds = %22, %19
%41 = phi double [ 0.000000e+00, %19 ], [ %36, %22 ]
%42 = phi i64 [ 0, %19 ], [ %37, %22 ]
br i1 %15, label %49, label %43
43: ; preds = %40
%44 = getelementptr inbounds double, double* %4, i64 %42
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %21, i64 %42
%47 = load double, double* %46
%48 = tail call double @llvm.fmuladd.f64(double %45, double %47, double %41)
store double %48, double* %18
br label %49
49: ; preds = %43, %40, %16
%50 = add nuw nsw i64 %17, 1
%51 = icmp eq i64 %50, %10
br i1 %51, label %52, label %16
52: ; preds = %49, %5
%53 = bitcast double* %1 to float*
%54 = bitcast double* %6 to float*
%55 = tail call double @correlation(float* %53, float* %54, i32 %3)
ret double %55
}