void mlr_get_cov_matrix(unsigned long long n, double sumx, double sumx2,
                        double sumy, double sumy2, double sumxy,
                        double Q[2][2]) {
  double denominator = n - 1;
  Q[0][0] = (sumx2 - sumx * sumx / n) / denominator;
  Q[0][1] = (sumxy - sumx * sumy / n) / denominator;
  Q[1][0] = Q[0][1];
  Q[1][1] = (sumy2 - sumy * sumy / n) / denominator;
}


x86 assembly (clang, -O0):
<mlr_get_cov_matrix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
movq   %rax,%xmm0
movaps 0xec7(%rip),%xmm4
punpckldq %xmm4,%xmm0
movapd 0xecb(%rip),%xmm3
subpd  %xmm3,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm1
movq   -0x8(%rbp),%xmm2
punpckldq %xmm4,%xmm2
subpd  %xmm3,%xmm2
movaps %xmm2,%xmm5
unpckhpd %xmm2,%xmm2
addsd  %xmm5,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movq   -0x8(%rbp),%xmm2
punpckldq %xmm4,%xmm2
subpd  %xmm3,%xmm2
movaps %xmm2,%xmm5
unpckhpd %xmm2,%xmm2
addsd  %xmm5,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x38(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm1
movq   -0x8(%rbp),%xmm2
punpckldq %xmm4,%xmm2
subpd  %xmm3,%xmm2
movaps %xmm2,%xmm3
unpckhpd %xmm2,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x18(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlr_get_cov_matrix>:
lea    -0x1(%rdi),%rax
movq   %rax,%xmm6
movdqa 0xeee(%rip),%xmm8
punpckldq %xmm8,%xmm6
movapd 0xef1(%rip),%xmm7
subpd  %xmm7,%xmm6
movapd %xmm6,%xmm5
unpckhpd %xmm6,%xmm5
addpd  %xmm6,%xmm5
movq   %rdi,%xmm6
punpckldq %xmm8,%xmm6
subpd  %xmm7,%xmm6
movapd %xmm6,%xmm7
unpckhpd %xmm6,%xmm7
addpd  %xmm6,%xmm7
movapd %xmm0,%xmm6
unpcklpd %xmm0,%xmm6
unpcklpd %xmm2,%xmm0
mulpd  %xmm6,%xmm0
mulsd  %xmm2,%xmm2
divsd  %xmm7,%xmm2
unpcklpd %xmm7,%xmm7
divpd  %xmm7,%xmm0
unpcklpd %xmm4,%xmm1
subpd  %xmm0,%xmm1
subsd  %xmm2,%xmm3
divsd  %xmm5,%xmm3
unpcklpd %xmm5,%xmm5
divpd  %xmm5,%xmm1
movupd %xmm1,(%rsi)
movhpd %xmm1,0x10(%rsi)
movsd  %xmm3,0x18(%rsi)
ret

LLVM IR (-O0):
define void @mlr_get_cov_matrix(i64 %0, double %1, double %2, double %3, double %4, double %5, [2 x double]* %6) {
%8 = alloca i64
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca [2 x double]*
%15 = alloca double
store i64 %0, i64* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store [2 x double]* %6, [2 x double]** %14
%16 = load i64, i64* %8
%17 = sub i64 %16, 1
%18 = uitofp i64 %17 to double
store double %18, double* %15
%19 = load double, double* %10
%20 = load double, double* %9
%21 = load double, double* %9
%22 = fmul double %20, %21
%23 = load i64, i64* %8
%24 = uitofp i64 %23 to double
%25 = fdiv double %22, %24
%26 = fsub double %19, %25
%27 = load double, double* %15
%28 = fdiv double %26, %27
%29 = load [2 x double]*, [2 x double]** %14
%30 = getelementptr inbounds [2 x double], [2 x double]* %29, i64 0
%31 = getelementptr inbounds [2 x double], [2 x double]* %30, i64 0, i64 0
store double %28, double* %31
%32 = load double, double* %13
%33 = load double, double* %9
%34 = load double, double* %11
%35 = fmul double %33, %34
%36 = load i64, i64* %8
%37 = uitofp i64 %36 to double
%38 = fdiv double %35, %37
%39 = fsub double %32, %38
%40 = load double, double* %15
%41 = fdiv double %39, %40
%42 = load [2 x double]*, [2 x double]** %14
%43 = getelementptr inbounds [2 x double], [2 x double]* %42, i64 0
%44 = getelementptr inbounds [2 x double], [2 x double]* %43, i64 0, i64 1
store double %41, double* %44
%45 = load [2 x double]*, [2 x double]** %14
%46 = getelementptr inbounds [2 x double], [2 x double]* %45, i64 0
%47 = getelementptr inbounds [2 x double], [2 x double]* %46, i64 0, i64 1
%48 = load double, double* %47
%49 = load [2 x double]*, [2 x double]** %14
%50 = getelementptr inbounds [2 x double], [2 x double]* %49, i64 1
%51 = getelementptr inbounds [2 x double], [2 x double]* %50, i64 0, i64 0
store double %48, double* %51
%52 = load double, double* %12
%53 = load double, double* %11
%54 = load double, double* %11
%55 = fmul double %53, %54
%56 = load i64, i64* %8
%57 = uitofp i64 %56 to double
%58 = fdiv double %55, %57
%59 = fsub double %52, %58
%60 = load double, double* %15
%61 = fdiv double %59, %60
%62 = load [2 x double]*, [2 x double]** %14
%63 = getelementptr inbounds [2 x double], [2 x double]* %62, i64 1
%64 = getelementptr inbounds [2 x double], [2 x double]* %63, i64 0, i64 1
store double %61, double* %64
ret void
}

LLVM IR (-O2):
define void @mlr_get_cov_matrix(i64 %0, double %1, double %2, double %3, double %4, double %5, [2 x double]* nocapture writeonly %6) {
%8 = add i64 %0, -1
%9 = uitofp i64 %8 to double
%10 = uitofp i64 %0 to double
%11 = insertelement <2 x double> poison, double %1, i64 0
%12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> zeroinitializer
%13 = insertelement <2 x double> %11, double %3, i64 1
%14 = fmul <2 x double> %12, %13
%15 = insertelement <2 x double> poison, double %10, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x double> %14, %16
%18 = insertelement <2 x double> poison, double %2, i64 0
%19 = insertelement <2 x double> %18, double %5, i64 1
%20 = fsub <2 x double> %19, %17
%21 = insertelement <2 x double> poison, double %9, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x double> %20, %22
%24 = bitcast [2 x double]* %6 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
%25 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 1, i64 0
%26 = extractelement <2 x double> %23, i64 1
store double %26, double* %25
%27 = fmul double %3, %3
%28 = fdiv double %27, %10
%29 = fsub double %4, %28
%30 = fdiv double %29, %9
%31 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 1, i64 1
store double %30, double* %31
ret void
}