void least_squares(double *a, double *b, int n, double sxx, double sxy,
                   double sx, double sy) {
  *b = (n * sxy - sx * sy) / (n * sxx - sx * sx);
  *a = (sy - *b * sx) / n;
}


x86 assembly (clang, -O0):
<least_squares>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
movsd  %xmm3,-0x38(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm2
mulsd  -0x30(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x30(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<least_squares>:
cvtsi2sd %edx,%xmm4
movapd %xmm2,%xmm5
mulsd  %xmm3,%xmm5
mulsd  %xmm4,%xmm1
subsd  %xmm5,%xmm1
movapd %xmm2,%xmm5
mulsd  %xmm2,%xmm5
mulsd  %xmm4,%xmm0
subsd  %xmm5,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi)
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm3
divsd  %xmm4,%xmm3
movsd  %xmm3,(%rdi)
ret

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

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