double bestfit(double sx, double sy, double h11, double h12, double h22,
               double *cx, double *cy) {
  double a, su, uu, cu, w2;
  a = 0;
  *cy = 0;
  if (h22 > 1e-20 * h11) {
    a = h12 / h22;
    *cy = sy / h22;
  }
  su = sx - a * sy;
  uu = h11 - 2 * a * h12 + a * a * h22;
  cu = 0;
  if (uu > 1e-20 * h11)
    cu = su / uu;
  w2 = *cy * *cy * h22;
  w2 += cu * cu * uu;
  *cx = cu;
  *cy -= a * cu;
  return w2;
}


x86 assembly (clang, -O0):
<bestfit>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x38(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  0xebb(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1175 <bestfit+0x75>
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe53(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xdf1(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    122d <bestfit+0x12d>
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
movq   %xmm0,%rcx
movabs $0x8000000000000000,%rdx
xor    %rdx,%rcx
movq   %rcx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<bestfit>:
movsd  0xef7(%rip),%xmm8
mulsd  %xmm2,%xmm8
xorpd  %xmm5,%xmm5
ucomisd %xmm8,%xmm4
jbe    112d <bestfit+0x2d>
movapd %xmm1,%xmm5
unpcklpd %xmm3,%xmm5
movapd %xmm4,%xmm6
unpcklpd %xmm4,%xmm6
divpd  %xmm6,%xmm5
movlpd %xmm5,(%rsi)
movapd %xmm5,%xmm7
unpckhpd %xmm5,%xmm7
movapd 0xece(%rip),%xmm9
xorpd  %xmm7,%xmm9
movsd  0xeb9(%rip),%xmm6
mulsd  %xmm7,%xmm6
mulsd  %xmm3,%xmm6
addsd  %xmm2,%xmm6
mulsd  %xmm7,%xmm7
mulsd  %xmm4,%xmm7
addsd  %xmm6,%xmm7
xorpd  %xmm2,%xmm2
ucomisd %xmm8,%xmm7
jbe    1183 <bestfit+0x83>
mulsd  %xmm9,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm7,%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm5,%xmm5
mulsd  %xmm4,%xmm5
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm7,%xmm0
addsd  %xmm5,%xmm0
movsd  %xmm2,(%rdi)
mulsd  %xmm2,%xmm9
addsd  (%rsi),%xmm9
movsd  %xmm9,(%rsi)
ret

LLVM IR (-O0):
define double @bestfit(double %0, double %1, double %2, double %3, double %4, double* %5, double* %6) {
%8 = alloca double
%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
%18 = alloca double
%19 = alloca double
store double %0, double* %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
store double 0.000000e+00, double* %15
%20 = load double*, double** %14
store double 0.000000e+00, double* %20
%21 = load double, double* %12
%22 = load double, double* %10
%23 = fmul double 0x3BC79CA10C924223, %22
%24 = fcmp ogt double %21, %23
br i1 %24, label %25, label %33
25: ; preds = %7
%26 = load double, double* %11
%27 = load double, double* %12
%28 = fdiv double %26, %27
store double %28, double* %15
%29 = load double, double* %9
%30 = load double, double* %12
%31 = fdiv double %29, %30
%32 = load double*, double** %14
store double %31, double* %32
br label %33
33: ; preds = %25, %7
%34 = load double, double* %8
%35 = load double, double* %15
%36 = load double, double* %9
%37 = fneg double %35
%38 = call double @llvm.fmuladd.f64(double %37, double %36, double %34)
store double %38, double* %16
%39 = load double, double* %10
%40 = load double, double* %15
%41 = fmul double 2.000000e+00, %40
%42 = load double, double* %11
%43 = fneg double %41
%44 = call double @llvm.fmuladd.f64(double %43, double %42, double %39)
%45 = load double, double* %15
%46 = load double, double* %15
%47 = fmul double %45, %46
%48 = load double, double* %12
%49 = call double @llvm.fmuladd.f64(double %47, double %48, double %44)
store double %49, double* %17
store double 0.000000e+00, double* %18
%50 = load double, double* %17
%51 = load double, double* %10
%52 = fmul double 0x3BC79CA10C924223, %51
%53 = fcmp ogt double %50, %52
br i1 %53, label %54, label %58
54: ; preds = %33
%55 = load double, double* %16
%56 = load double, double* %17
%57 = fdiv double %55, %56
store double %57, double* %18
br label %58
58: ; preds = %54, %33
%59 = load double*, double** %14
%60 = load double, double* %59
%61 = load double*, double** %14
%62 = load double, double* %61
%63 = fmul double %60, %62
%64 = load double, double* %12
%65 = fmul double %63, %64
store double %65, double* %19
%66 = load double, double* %18
%67 = load double, double* %18
%68 = fmul double %66, %67
%69 = load double, double* %17
%70 = load double, double* %19
%71 = call double @llvm.fmuladd.f64(double %68, double %69, double %70)
store double %71, double* %19
%72 = load double, double* %18
%73 = load double*, double** %13
store double %72, double* %73
%74 = load double, double* %15
%75 = load double, double* %18
%76 = load double*, double** %14
%77 = load double, double* %76
%78 = fneg double %74
%79 = call double @llvm.fmuladd.f64(double %78, double %75, double %77)
store double %79, double* %76
%80 = load double, double* %19
ret double %80
}

LLVM IR (-O2):
define double @bestfit(double %0, double %1, double %2, double %3, double %4, double* nocapture writeonly %5, double* nocapture %6) {
%8 = fmul double %2, 0x3BC79CA10C924223
%9 = fcmp olt double %8, %4
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = insertelement <2 x double> poison, double %1, i64 0
%12 = insertelement <2 x double> %11, double %3, i64 1
%13 = insertelement <2 x double> poison, double %4, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = fdiv <2 x double> %12, %14
br label %16
16: ; preds = %10, %7
%17 = phi <2 x double> [ %15, %10 ], [ zeroinitializer, %7 ]
%18 = extractelement <2 x double> %17, i64 0
store double %18, double* %6
%19 = extractelement <2 x double> %17, i64 1
%20 = fneg double %19
%21 = fmul double %19, -2.000000e+00
%22 = tail call double @llvm.fmuladd.f64(double %21, double %3, double %2)
%23 = fmul double %19, %19
%24 = tail call double @llvm.fmuladd.f64(double %23, double %4, double %22)
%25 = fcmp ogt double %24, %8
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = tail call double @llvm.fmuladd.f64(double %20, double %1, double %0)
%28 = fdiv double %27, %24
br label %29
29: ; preds = %26, %16
%30 = phi double [ %28, %26 ], [ 0.000000e+00, %16 ]
%31 = fmul <2 x double> %17, %17
%32 = extractelement <2 x double> %31, i64 0
%33 = fmul double %32, %4
%34 = fmul double %30, %30
%35 = tail call double @llvm.fmuladd.f64(double %34, double %24, double %33)
store double %30, double* %5
%36 = load double, double* %6
%37 = tail call double @llvm.fmuladd.f64(double %20, double %30, double %36)
store double %37, double* %6
ret double %35
}