double mlr_get_cov(unsigned long long n, double sumx, double sumy,
                   double sumxy) {
  double meanx = sumx / n;
  double meany = sumy / n;
  double numerator = sumxy - meanx * sumy - meany * sumx + n * meanx * meany;
  double denominator = n - 1;
  return numerator / denominator;
}


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

x86 assembly (clang, -O2):
<mlr_get_cov>:
movq   %rdi,%xmm3
movdqa 0xef3(%rip),%xmm4
punpckldq %xmm4,%xmm3
movapd 0xef7(%rip),%xmm5
subpd  %xmm5,%xmm3
movapd %xmm3,%xmm6
unpckhpd %xmm3,%xmm6
addsd  %xmm3,%xmm6
movapd %xmm0,%xmm3
divsd  %xmm6,%xmm3
movapd %xmm3,%xmm7
mulsd  %xmm1,%xmm7
divsd  %xmm6,%xmm1
subsd  %xmm7,%xmm2
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm2
mulsd  %xmm6,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
add    $0xffffffffffffffff,%rdi
movq   %rdi,%xmm0
punpckldq %xmm4,%xmm0
subpd  %xmm5,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
ret

LLVM IR (-O0):
define double @mlr_get_cov(i64 %0, double %1, double %2, double %3) {
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i64 %0, i64* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%13 = load double, double* %6
%14 = load i64, i64* %5
%15 = uitofp i64 %14 to double
%16 = fdiv double %13, %15
store double %16, double* %9
%17 = load double, double* %7
%18 = load i64, i64* %5
%19 = uitofp i64 %18 to double
%20 = fdiv double %17, %19
store double %20, double* %10
%21 = load double, double* %8
%22 = load double, double* %9
%23 = load double, double* %7
%24 = fneg double %22
%25 = call double @llvm.fmuladd.f64(double %24, double %23, double %21)
%26 = load double, double* %10
%27 = load double, double* %6
%28 = fneg double %26
%29 = call double @llvm.fmuladd.f64(double %28, double %27, double %25)
%30 = load i64, i64* %5
%31 = uitofp i64 %30 to double
%32 = load double, double* %9
%33 = fmul double %31, %32
%34 = load double, double* %10
%35 = call double @llvm.fmuladd.f64(double %33, double %34, double %29)
store double %35, double* %11
%36 = load i64, i64* %5
%37 = sub i64 %36, 1
%38 = uitofp i64 %37 to double
store double %38, double* %12
%39 = load double, double* %11
%40 = load double, double* %12
%41 = fdiv double %39, %40
ret double %41
}

LLVM IR (-O2):
define double @mlr_get_cov(i64 %0, double %1, double %2, double %3) {
%5 = uitofp i64 %0 to double
%6 = fdiv double %1, %5
%7 = fdiv double %2, %5
%8 = fneg double %6
%9 = tail call double @llvm.fmuladd.f64(double %8, double %2, double %3)
%10 = fneg double %7
%11 = tail call double @llvm.fmuladd.f64(double %10, double %1, double %9)
%12 = fmul double %6, %5
%13 = tail call double @llvm.fmuladd.f64(double %12, double %7, double %11)
%14 = add i64 %0, -1
%15 = uitofp i64 %14 to double
%16 = fdiv double %13, %15
ret double %16
}