void mlr_get_linear_regression_ols(unsigned long long n, double sumx,
                                   double sumx2, double sumxy, double sumy,
                                   double *pm, double *pb) {
  double D = n * sumx2 - sumx * sumx;
  double m = (n * sumxy - sumx * sumy) / D;
  double b = (-sumx * sumxy + sumx2 * sumy) / D;
  *pm = m;
  *pb = b;
}


x86 assembly (clang, -O0):
<mlr_get_linear_regression_ols>:
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)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
movq   -0x8(%rbp),%xmm0
movaps 0xed0(%rip),%xmm2
punpckldq %xmm2,%xmm0
movapd 0xed4(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
addsd  %xmm3,%xmm0
movsd  -0x18(%rbp),%xmm4
movsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm3
mulsd  %xmm4,%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm0,-0x40(%rbp)
movq   -0x8(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlr_get_linear_regression_ols>:
movq   %rdi,%xmm4
punpckldq 0xef3(%rip),%xmm4
subpd  0xefb(%rip),%xmm4
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
addsd  %xmm4,%xmm5
movapd %xmm0,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm5,%xmm6
mulsd  %xmm1,%xmm6
subsd  %xmm4,%xmm6
movapd %xmm0,%xmm4
mulsd  %xmm3,%xmm4
mulsd  %xmm2,%xmm5
subsd  %xmm4,%xmm5
divsd  %xmm6,%xmm5
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
divsd  %xmm6,%xmm1
movsd  %xmm5,(%rsi)
movsd  %xmm1,(%rdx)
ret

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

LLVM IR (-O2):
define void @mlr_get_linear_regression_ols(i64 %0, double %1, double %2, double %3, double %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = uitofp i64 %0 to double
%9 = fneg double %1
%10 = fmul double %9, %1
%11 = tail call double @llvm.fmuladd.f64(double %8, double %2, double %10)
%12 = fmul double %9, %4
%13 = tail call double @llvm.fmuladd.f64(double %8, double %3, double %12)
%14 = fdiv double %13, %11
%15 = fmul double %2, %4
%16 = tail call double @llvm.fmuladd.f64(double %9, double %3, double %15)
%17 = fdiv double %16, %11
store double %14, double* %5
store double %17, double* %6
ret void
}