void regression(x, y, num_pts, slope, intercept) double *x;
double *y;
int num_pts;
double *slope;
double *intercept;
{
  int i;
  double sum_x, sum_y;
  double sum_xy, sum_sq_x;
  double val1, val2;
  double delta = .900E-7;
  sum_x = sum_y = sum_xy = sum_sq_x = 0.0;
  for (i = 0; i < num_pts; i++) {
    sum_x += *x;
    sum_y += *y;
    sum_xy += (*x * *y);
    sum_sq_x += (*x * *x);
    x++;
    y++;
  }
  if (num_pts == 1) {
    *slope = 0.0;
    *intercept = 0.0;
  } else {
    val1 = fabs((sum_y * sum_sq_x) - (sum_x * sum_xy));
    val2 = fabs(((float)num_pts * sum_sq_x) - (sum_x * sum_x));
    if (fabs(val1 - val2) < delta)
      *intercept = 0.0;
    else
      *intercept = val1 / val2;
    val1 = fabs(((float)num_pts * sum_xy) - (sum_x * sum_y));
    val2 = fabs(((float)num_pts * sum_sq_x) - (sum_x * sum_x));
    if (fabs(val1 - val2) < delta)
      *slope = 0.0;
    else
      *slope = val1 / val2;
  }
}


x86 assembly (clang, -O0):
<regression>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e5 <regression+0xe5>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114b <regression+0x4b>
cmpl   $0x1,-0x14(%rbp)
jne    120a <regression+0x10a>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    13b3 <regression+0x2b3>
movsd  -0x40(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movaps 0xdcc(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movaps 0xd85(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm1
subsd  -0x60(%rbp),%xmm1
movaps 0xd6b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c8 <regression+0x1c8>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12da <regression+0x1da>
movsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
cvtsi2ssl -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movaps 0xcf8(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movaps 0xcb1(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm1
subsd  -0x60(%rbp),%xmm1
movaps 0xc97(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    139c <regression+0x29c>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    13ae <regression+0x2ae>
movsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13b3 <regression+0x2b3>
pop    %rbp
ret

x86 assembly (clang, -O2):
<regression>:
test   %edx,%edx
jle    111f <regression+0x1f>
cmp    $0x1,%edx
jne    112c <regression+0x2c>
xorpd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
test   $0x1,%dl
jne    119a <regression+0x9a>
jmp    11b2 <regression+0xb2>
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
jmp    11ce <regression+0xce>
mov    %edx,%r9d
and    $0xfffffffe,%r9d
xorpd  %xmm2,%xmm2
xor    %eax,%eax
xor    %r10d,%r10d
xorpd  %xmm1,%xmm1
movsd  (%rdi,%rax,8),%xmm3
movsd  0x8(%rdi,%rax,8),%xmm0
movapd %xmm3,%xmm4
movhpd (%rsi,%rax,8),%xmm4
addpd  %xmm4,%xmm1
unpcklpd %xmm3,%xmm3
mulpd  %xmm4,%xmm3
movapd %xmm0,%xmm4
movhpd 0x8(%rsi,%rax,8),%xmm4
addpd  %xmm2,%xmm3
addpd  %xmm4,%xmm1
unpcklpd %xmm0,%xmm0
movapd %xmm0,%xmm2
mulpd  %xmm4,%xmm2
addpd  %xmm3,%xmm2
add    $0xfffffffffffffff0,%r10
add    $0x2,%rax
cmp    %eax,%r9d
jne    1140 <regression+0x40>
sub    %r10,%rdi
sub    %r10,%rsi
test   $0x1,%dl
je     11b2 <regression+0xb2>
movsd  (%rdi),%xmm0
movapd %xmm0,%xmm4
movhpd (%rsi),%xmm4
addpd  %xmm4,%xmm1
unpcklpd %xmm0,%xmm0
movapd %xmm2,%xmm3
cmp    $0x1,%edx
jne    11c6 <regression+0xc6>
movq   $0x0,(%rcx)
movq   $0x0,(%r8)
ret
mulpd  %xmm4,%xmm0
addpd  %xmm3,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm1,%xmm3
unpckhpd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
subsd  %xmm2,%xmm3
movapd 0xe0e(%rip),%xmm4
andpd  %xmm4,%xmm3
xorps  %xmm2,%xmm2
cvtsi2ss %edx,%xmm2
cvtss2sd %xmm2,%xmm2
movapd %xmm1,%xmm5
unpcklpd %xmm1,%xmm5
mulpd  %xmm1,%xmm5
movlhps %xmm2,%xmm2
mulpd  %xmm0,%xmm2
subpd  %xmm5,%xmm2
andpd  %xmm4,%xmm2
movapd %xmm3,%xmm5
subsd  %xmm2,%xmm5
andpd  %xmm4,%xmm5
xorpd  %xmm1,%xmm1
movsd  0xddc(%rip),%xmm0
ucomisd %xmm5,%xmm0
ja     1242 <regression+0x142>
divsd  %xmm2,%xmm3
movapd %xmm3,%xmm1
movsd  %xmm1,(%r8)
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
andpd  0xda1(%rip),%xmm3
ucomisd %xmm3,%xmm0
jbe    126d <regression+0x16d>
movq   $0x0,(%rcx)
ret
divsd  %xmm2,%xmm1
movsd  %xmm1,(%rcx)
ret

LLVM IR (-O0):
define void @regression(double* %0, double* %1, i32 %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
store double 0x3E7828C0BE769DC1, double* %18
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %12
store i32 0, i32* %11
br label %19
19: ; preds = %48, %5
%20 = load i32, i32* %11
%21 = load i32, i32* %8
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %51
23: ; preds = %19
%24 = load double*, double** %6
%25 = load double, double* %24
%26 = load double, double* %12
%27 = fadd double %26, %25
store double %27, double* %12
%28 = load double*, double** %7
%29 = load double, double* %28
%30 = load double, double* %13
%31 = fadd double %30, %29
store double %31, double* %13
%32 = load double*, double** %6
%33 = load double, double* %32
%34 = load double*, double** %7
%35 = load double, double* %34
%36 = load double, double* %14
%37 = call double @llvm.fmuladd.f64(double %33, double %35, double %36)
store double %37, double* %14
%38 = load double*, double** %6
%39 = load double, double* %38
%40 = load double*, double** %6
%41 = load double, double* %40
%42 = load double, double* %15
%43 = call double @llvm.fmuladd.f64(double %39, double %41, double %42)
store double %43, double* %15
%44 = load double*, double** %6
%45 = getelementptr inbounds double, double* %44, i32 1
store double* %45, double** %6
%46 = load double*, double** %7
%47 = getelementptr inbounds double, double* %46, i32 1
store double* %47, double** %7
br label %48
48: ; preds = %23
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %19
51: ; preds = %19
%52 = load i32, i32* %8
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load double*, double** %9
store double 0.000000e+00, double* %55
%56 = load double*, double** %10
store double 0.000000e+00, double* %56
br label %124
57: ; preds = %51
%58 = load double, double* %13
%59 = load double, double* %15
%60 = load double, double* %12
%61 = load double, double* %14
%62 = fmul double %60, %61
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double %58, double %59, double %63)
%65 = call double @llvm.fabs.f64(double %64)
store double %65, double* %16
%66 = load i32, i32* %8
%67 = sitofp i32 %66 to float
%68 = fpext float %67 to double
%69 = load double, double* %15
%70 = load double, double* %12
%71 = load double, double* %12
%72 = fmul double %70, %71
%73 = fneg double %72
%74 = call double @llvm.fmuladd.f64(double %68, double %69, double %73)
%75 = call double @llvm.fabs.f64(double %74)
store double %75, double* %17
%76 = load double, double* %16
%77 = load double, double* %17
%78 = fsub double %76, %77
%79 = call double @llvm.fabs.f64(double %78)
%80 = load double, double* %18
%81 = fcmp olt double %79, %80
br i1 %81, label %82, label %84
82: ; preds = %57
%83 = load double*, double** %10
store double 0.000000e+00, double* %83
br label %89
84: ; preds = %57
%85 = load double, double* %16
%86 = load double, double* %17
%87 = fdiv double %85, %86
%88 = load double*, double** %10
store double %87, double* %88
br label %89
89: ; preds = %84, %82
%90 = load i32, i32* %8
%91 = sitofp i32 %90 to float
%92 = fpext float %91 to double
%93 = load double, double* %14
%94 = load double, double* %12
%95 = load double, double* %13
%96 = fmul double %94, %95
%97 = fneg double %96
%98 = call double @llvm.fmuladd.f64(double %92, double %93, double %97)
%99 = call double @llvm.fabs.f64(double %98)
store double %99, double* %16
%100 = load i32, i32* %8
%101 = sitofp i32 %100 to float
%102 = fpext float %101 to double
%103 = load double, double* %15
%104 = load double, double* %12
%105 = load double, double* %12
%106 = fmul double %104, %105
%107 = fneg double %106
%108 = call double @llvm.fmuladd.f64(double %102, double %103, double %107)
%109 = call double @llvm.fabs.f64(double %108)
store double %109, double* %17
%110 = load double, double* %16
%111 = load double, double* %17
%112 = fsub double %110, %111
%113 = call double @llvm.fabs.f64(double %112)
%114 = load double, double* %18
%115 = fcmp olt double %113, %114
br i1 %115, label %116, label %118
116: ; preds = %89
%117 = load double*, double** %9
store double 0.000000e+00, double* %117
br label %123
118: ; preds = %89
%119 = load double, double* %16
%120 = load double, double* %17
%121 = fdiv double %119, %120
%122 = load double*, double** %9
store double %121, double* %122
br label %123
123: ; preds = %118, %116
br label %124
124: ; preds = %123, %54
ret void
}

LLVM IR (-O2):
define void @regression(double* nocapture %0, double* nocapture %1, i32 %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %63
7: ; preds = %5
%8 = and i32 %2, 1
%9 = icmp eq i32 %2, 1
br i1 %9, label %38, label %10
10: ; preds = %7
%11 = and i32 %2, -2
br label %12
12: ; preds = %12, %10
%13 = phi double* [ %0, %10 ], [ %34, %12 ]
%14 = phi double* [ %1, %10 ], [ %35, %12 ]
%15 = phi <2 x double> [ zeroinitializer, %10 ], [ %33, %12 ]
%16 = phi <2 x double> [ zeroinitializer, %10 ], [ %31, %12 ]
%17 = phi i32 [ 0, %10 ], [ %36, %12 ]
%18 = load double, double* %13
%19 = load double, double* %14
%20 = insertelement <2 x double> poison, double %18, i64 0
%21 = insertelement <2 x double> %20, double %19, i64 1
%22 = fadd <2 x double> %16, %21
%23 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%24 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %21, <2 x double> %15)
%25 = getelementptr inbounds double, double* %13, i64 1
%26 = getelementptr inbounds double, double* %14, i64 1
%27 = load double, double* %25
%28 = load double, double* %26
%29 = insertelement <2 x double> poison, double %27, i64 0
%30 = insertelement <2 x double> %29, double %28, i64 1
%31 = fadd <2 x double> %22, %30
%32 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%33 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %30, <2 x double> %24)
%34 = getelementptr inbounds double, double* %13, i64 2
%35 = getelementptr inbounds double, double* %14, i64 2
%36 = add i32 %17, 2
%37 = icmp eq i32 %36, %11
br i1 %37, label %38, label %12
38: ; preds = %12, %7
%39 = phi <2 x double> [ undef, %7 ], [ %24, %12 ]
%40 = phi <2 x double> [ undef, %7 ], [ %30, %12 ]
%41 = phi <2 x double> [ undef, %7 ], [ %31, %12 ]
%42 = phi <2 x double> [ undef, %7 ], [ %32, %12 ]
%43 = phi double* [ %0, %7 ], [ %34, %12 ]
%44 = phi double* [ %1, %7 ], [ %35, %12 ]
%45 = phi <2 x double> [ zeroinitializer, %7 ], [ %33, %12 ]
%46 = phi <2 x double> [ zeroinitializer, %7 ], [ %31, %12 ]
%47 = icmp eq i32 %8, 0
br i1 %47, label %55, label %48
48: ; preds = %38
%49 = load double, double* %43
%50 = load double, double* %44
%51 = insertelement <2 x double> poison, double %49, i64 0
%52 = insertelement <2 x double> %51, double %50, i64 1
%53 = fadd <2 x double> %46, %52
%54 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
br label %55
55: ; preds = %38, %48
%56 = phi <2 x double> [ %39, %38 ], [ %45, %48 ]
%57 = phi <2 x double> [ %40, %38 ], [ %52, %48 ]
%58 = phi <2 x double> [ %41, %38 ], [ %53, %48 ]
%59 = phi <2 x double> [ %42, %38 ], [ %54, %48 ]
%60 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %59, <2 x double> %57, <2 x double> %56)
%61 = icmp eq i32 %2, 1
br i1 %61, label %62, label %63
62: ; preds = %55
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
br label %96
63: ; preds = %5, %55
%64 = phi <2 x double> [ %60, %55 ], [ zeroinitializer, %5 ]
%65 = phi <2 x double> [ %58, %55 ], [ zeroinitializer, %5 ]
%66 = extractelement <2 x double> %65, i64 0
%67 = fneg double %66
%68 = extractelement <2 x double> %64, i64 1
%69 = fmul double %68, %67
%70 = extractelement <2 x double> %64, i64 0
%71 = extractelement <2 x double> %65, i64 1
%72 = tail call double @llvm.fmuladd.f64(double %71, double %70, double %69)
%73 = tail call double @llvm.fabs.f64(double %72)
%74 = sitofp i32 %2 to float
%75 = fpext float %74 to double
%76 = insertelement <2 x double> poison, double %67, i64 0
%77 = shufflevector <2 x double> %76, <2 x double> poison, <2 x i32> zeroinitializer
%78 = fmul <2 x double> %65, %77
%79 = insertelement <2 x double> poison, double %75, i64 0
%80 = shufflevector <2 x double> %79, <2 x double> poison, <2 x i32> zeroinitializer
%81 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %80, <2 x double> %64, <2 x double> %78)
%82 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %81)
%83 = extractelement <2 x double> %82, i64 0
%84 = fsub double %73, %83
%85 = tail call double @llvm.fabs.f64(double %84)
%86 = fcmp olt double %85, 0x3E7828C0BE769DC1
%87 = fdiv double %73, %83
%88 = select i1 %86, double 0.000000e+00, double %87
store double %88, double* %4
%89 = extractelement <2 x double> %82, i64 1
%90 = fsub double %89, %83
%91 = tail call double @llvm.fabs.f64(double %90)
%92 = fcmp olt double %91, 0x3E7828C0BE769DC1
br i1 %92, label %93, label %94
93: ; preds = %63
store double 0.000000e+00, double* %3
br label %96
94: ; preds = %63
%95 = fdiv double %89, %83
store double %95, double* %3
br label %96
96: ; preds = %93, %94, %62
ret void
}