void binlensd2(double x1, double x2, double d, double m1, double *y111,
               double *y112, double *y122, double *y222) {
  double m2;
  double del11, del12, x2sq, n1, n2, n1sq, n2sq;
  double sum1, sum2, sum111, sum112, sum122, sum222;
  double del11sq, del12sq;
  m2 = 1.0 - m1;
  if (m2 < 0.0) {
    m2 = 0.0;
    m1 = 1.0;
  }
  del11 = x1 + m2 * d;
  del12 = x1 - m1 * d;
  del11sq = del11 * del11;
  del12sq = del12 * del12;
  x2sq = x2 * x2;
  n1 = del11 * del11 + x2sq;
  n2 = del12 * del12 + x2sq;
  n1sq = n1 * n1;
  n2sq = n2 * n2;
  sum1 = m1 / n1sq * del11 + m2 / n2sq * del12;
  sum2 = m1 / n1sq * x2 + m2 / n2sq * x2;
  sum111 = m1 * del11sq / n1sq * del11 / n1 + m2 * del12sq / n2sq * del12 / n2;
  sum112 = m1 * del11sq / n1sq * x2 / n1 + m2 * del12sq / n2sq * x2 / n2;
  sum122 = m1 * del11 / n1 * x2sq / n1sq + m2 * del12 / n2 * x2sq / n2sq;
  sum222 = m1 * x2 / n1 * x2sq / n1sq + m2 * x2 / n2 * x2sq / n2sq;
  *y111 = 6.0 * sum1 - 8.0 * sum111;
  *y112 = 2.0 * sum2 - 8.0 * sum112;
  *y122 = 2.0 * sum1 - 8.0 * sum122;
  *y222 = 6.0 * sum2 - 8.0 * sum222;
}


x86 assembly (clang, -O0):
<binlensd2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
movsd  0xecc(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1161 <binlensd2+0x61>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
divsd  -0x80(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
divsd  -0x80(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mulsd  -0xb8(%rbp),%xmm0
ff
divsd  -0x78(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0xc0(%rbp),%xmm1
ff
divsd  -0x80(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
divsd  -0x70(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mulsd  -0xb8(%rbp),%xmm0
ff
divsd  -0x78(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0xc0(%rbp),%xmm1
ff
divsd  -0x80(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  -0x70(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
divsd  -0x70(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
divsd  -0x80(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  -0x70(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
divsd  -0x80(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xc67(%rip),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xc38(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xc20(%rip),%xmm1
mulsd  -0xa0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xbe1(%rip),%xmm1
mulsd  -0xa8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xba2(%rip),%xmm1
mulsd  -0xb0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xb73(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binlensd2>:
movsd  0xef8(%rip),%xmm4
movapd %xmm4,%xmm5
subsd  %xmm3,%xmm5
xorpd  %xmm7,%xmm7
xorpd  %xmm15,%xmm15
maxsd  %xmm5,%xmm15
cmpltsd %xmm7,%xmm5
andpd  %xmm5,%xmm4
andnpd %xmm3,%xmm5
orpd   %xmm4,%xmm5
movapd %xmm15,%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm0,%xmm7
mulsd  %xmm5,%xmm2
subsd  %xmm2,%xmm0
movapd %xmm7,%xmm4
mulsd  %xmm7,%xmm4
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm1,%xmm8
mulsd  %xmm1,%xmm8
movapd %xmm4,%xmm11
addsd  %xmm8,%xmm11
movapd %xmm3,%xmm9
addsd  %xmm8,%xmm9
movapd %xmm11,%xmm12
mulsd  %xmm11,%xmm12
movapd %xmm9,%xmm10
mulsd  %xmm9,%xmm10
movapd %xmm5,%xmm14
divsd  %xmm12,%xmm14
movapd %xmm15,%xmm2
divsd  %xmm10,%xmm2
movapd %xmm0,%xmm6
mulsd  %xmm2,%xmm6
movapd %xmm14,%xmm13
mulsd  %xmm7,%xmm13
addsd  %xmm6,%xmm13
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm14
addsd  %xmm2,%xmm14
mulsd  %xmm5,%xmm4
divsd  %xmm12,%xmm4
movapd %xmm7,%xmm6
mulsd  %xmm4,%xmm6
divsd  %xmm11,%xmm6
mulsd  %xmm15,%xmm3
divsd  %xmm10,%xmm3
movapd %xmm0,%xmm2
mulsd  %xmm3,%xmm2
divsd  %xmm9,%xmm2
addsd  %xmm6,%xmm2
mulsd  %xmm1,%xmm4
divsd  %xmm11,%xmm4
mulsd  %xmm1,%xmm3
divsd  %xmm9,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm5,%xmm7
divsd  %xmm11,%xmm7
mulsd  %xmm8,%xmm7
divsd  %xmm12,%xmm7
mulsd  %xmm15,%xmm0
divsd  %xmm9,%xmm0
mulsd  %xmm8,%xmm0
divsd  %xmm10,%xmm0
addsd  %xmm7,%xmm0
mulsd  %xmm1,%xmm5
divsd  %xmm11,%xmm5
mulsd  %xmm8,%xmm5
divsd  %xmm12,%xmm5
mulsd  %xmm1,%xmm15
divsd  %xmm9,%xmm15
mulsd  %xmm8,%xmm15
divsd  %xmm10,%xmm15
addsd  %xmm5,%xmm15
movsd  0xda3(%rip),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xd9f(%rip),%xmm4
movapd %xmm13,%xmm5
mulsd  %xmm4,%xmm5
addsd  %xmm2,%xmm5
movsd  %xmm5,(%rdi)
mulsd  %xmm1,%xmm3
movapd %xmm14,%xmm2
addsd  %xmm14,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsi)
mulsd  %xmm1,%xmm0
addsd  %xmm13,%xmm13
addsd  %xmm0,%xmm13
movsd  %xmm13,(%rdx)
mulsd  %xmm1,%xmm15
mulsd  %xmm4,%xmm14
addsd  %xmm15,%xmm14
movsd  %xmm14,(%rcx)
ret

LLVM IR (-O0):
define void @binlensd2(double %0, double %1, double %2, double %3, double* %4, double* %5, double* %6, double* %7) {
%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
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store double* %7, double** %16
%33 = load double, double* %12
%34 = fsub double 1.000000e+00, %33
store double %34, double* %17
%35 = load double, double* %17
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %37, label %38
37: ; preds = %8
store double 0.000000e+00, double* %17
store double 1.000000e+00, double* %12
br label %38
38: ; preds = %37, %8
%39 = load double, double* %9
%40 = load double, double* %17
%41 = load double, double* %11
%42 = call double @llvm.fmuladd.f64(double %40, double %41, double %39)
store double %42, double* %18
%43 = load double, double* %9
%44 = load double, double* %12
%45 = load double, double* %11
%46 = fneg double %44
%47 = call double @llvm.fmuladd.f64(double %46, double %45, double %43)
store double %47, double* %19
%48 = load double, double* %18
%49 = load double, double* %18
%50 = fmul double %48, %49
store double %50, double* %31
%51 = load double, double* %19
%52 = load double, double* %19
%53 = fmul double %51, %52
store double %53, double* %32
%54 = load double, double* %10
%55 = load double, double* %10
%56 = fmul double %54, %55
store double %56, double* %20
%57 = load double, double* %18
%58 = load double, double* %18
%59 = load double, double* %20
%60 = call double @llvm.fmuladd.f64(double %57, double %58, double %59)
store double %60, double* %21
%61 = load double, double* %19
%62 = load double, double* %19
%63 = load double, double* %20
%64 = call double @llvm.fmuladd.f64(double %61, double %62, double %63)
store double %64, double* %22
%65 = load double, double* %21
%66 = load double, double* %21
%67 = fmul double %65, %66
store double %67, double* %23
%68 = load double, double* %22
%69 = load double, double* %22
%70 = fmul double %68, %69
store double %70, double* %24
%71 = load double, double* %12
%72 = load double, double* %23
%73 = fdiv double %71, %72
%74 = load double, double* %18
%75 = load double, double* %17
%76 = load double, double* %24
%77 = fdiv double %75, %76
%78 = load double, double* %19
%79 = fmul double %77, %78
%80 = call double @llvm.fmuladd.f64(double %73, double %74, double %79)
store double %80, double* %25
%81 = load double, double* %12
%82 = load double, double* %23
%83 = fdiv double %81, %82
%84 = load double, double* %10
%85 = load double, double* %17
%86 = load double, double* %24
%87 = fdiv double %85, %86
%88 = load double, double* %10
%89 = fmul double %87, %88
%90 = call double @llvm.fmuladd.f64(double %83, double %84, double %89)
store double %90, double* %26
%91 = load double, double* %12
%92 = load double, double* %31
%93 = fmul double %91, %92
%94 = load double, double* %23
%95 = fdiv double %93, %94
%96 = load double, double* %18
%97 = fmul double %95, %96
%98 = load double, double* %21
%99 = fdiv double %97, %98
%100 = load double, double* %17
%101 = load double, double* %32
%102 = fmul double %100, %101
%103 = load double, double* %24
%104 = fdiv double %102, %103
%105 = load double, double* %19
%106 = fmul double %104, %105
%107 = load double, double* %22
%108 = fdiv double %106, %107
%109 = fadd double %99, %108
store double %109, double* %27
%110 = load double, double* %12
%111 = load double, double* %31
%112 = fmul double %110, %111
%113 = load double, double* %23
%114 = fdiv double %112, %113
%115 = load double, double* %10
%116 = fmul double %114, %115
%117 = load double, double* %21
%118 = fdiv double %116, %117
%119 = load double, double* %17
%120 = load double, double* %32
%121 = fmul double %119, %120
%122 = load double, double* %24
%123 = fdiv double %121, %122
%124 = load double, double* %10
%125 = fmul double %123, %124
%126 = load double, double* %22
%127 = fdiv double %125, %126
%128 = fadd double %118, %127
store double %128, double* %28
%129 = load double, double* %12
%130 = load double, double* %18
%131 = fmul double %129, %130
%132 = load double, double* %21
%133 = fdiv double %131, %132
%134 = load double, double* %20
%135 = fmul double %133, %134
%136 = load double, double* %23
%137 = fdiv double %135, %136
%138 = load double, double* %17
%139 = load double, double* %19
%140 = fmul double %138, %139
%141 = load double, double* %22
%142 = fdiv double %140, %141
%143 = load double, double* %20
%144 = fmul double %142, %143
%145 = load double, double* %24
%146 = fdiv double %144, %145
%147 = fadd double %137, %146
store double %147, double* %29
%148 = load double, double* %12
%149 = load double, double* %10
%150 = fmul double %148, %149
%151 = load double, double* %21
%152 = fdiv double %150, %151
%153 = load double, double* %20
%154 = fmul double %152, %153
%155 = load double, double* %23
%156 = fdiv double %154, %155
%157 = load double, double* %17
%158 = load double, double* %10
%159 = fmul double %157, %158
%160 = load double, double* %22
%161 = fdiv double %159, %160
%162 = load double, double* %20
%163 = fmul double %161, %162
%164 = load double, double* %24
%165 = fdiv double %163, %164
%166 = fadd double %156, %165
store double %166, double* %30
%167 = load double, double* %25
%168 = load double, double* %27
%169 = fmul double 8.000000e+00, %168
%170 = fneg double %169
%171 = call double @llvm.fmuladd.f64(double 6.000000e+00, double %167, double %170)
%172 = load double*, double** %13
store double %171, double* %172
%173 = load double, double* %26
%174 = load double, double* %28
%175 = fmul double 8.000000e+00, %174
%176 = fneg double %175
%177 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %173, double %176)
%178 = load double*, double** %14
store double %177, double* %178
%179 = load double, double* %25
%180 = load double, double* %29
%181 = fmul double 8.000000e+00, %180
%182 = fneg double %181
%183 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %179, double %182)
%184 = load double*, double** %15
store double %183, double* %184
%185 = load double, double* %26
%186 = load double, double* %30
%187 = fmul double 8.000000e+00, %186
%188 = fneg double %187
%189 = call double @llvm.fmuladd.f64(double 6.000000e+00, double %185, double %188)
%190 = load double*, double** %16
store double %189, double* %190
ret void
}

LLVM IR (-O2):
define void @binlensd2(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = fsub double 1.000000e+00, %3
%10 = fcmp olt double %9, 0.000000e+00
%11 = select i1 %10, double 0.000000e+00, double %9
%12 = select i1 %10, double 1.000000e+00, double %3
%13 = tail call double @llvm.fmuladd.f64(double %11, double %2, double %0)
%14 = fneg double %12
%15 = tail call double @llvm.fmuladd.f64(double %14, double %2, double %0)
%16 = fmul double %13, %13
%17 = fmul double %15, %15
%18 = fmul double %1, %1
%19 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %18)
%20 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %18)
%21 = fmul double %19, %19
%22 = fmul double %20, %20
%23 = fdiv double %12, %21
%24 = fdiv double %11, %22
%25 = fmul double %15, %24
%26 = tail call double @llvm.fmuladd.f64(double %23, double %13, double %25)
%27 = fmul double %24, %1
%28 = tail call double @llvm.fmuladd.f64(double %23, double %1, double %27)
%29 = fmul double %12, %16
%30 = fdiv double %29, %21
%31 = fmul double %13, %30
%32 = fdiv double %31, %19
%33 = fmul double %11, %17
%34 = fdiv double %33, %22
%35 = fmul double %15, %34
%36 = fdiv double %35, %20
%37 = fadd double %32, %36
%38 = fmul double %30, %1
%39 = fdiv double %38, %19
%40 = fmul double %34, %1
%41 = fdiv double %40, %20
%42 = fadd double %39, %41
%43 = fmul double %12, %13
%44 = fdiv double %43, %19
%45 = fmul double %18, %44
%46 = fdiv double %45, %21
%47 = fmul double %11, %15
%48 = fdiv double %47, %20
%49 = fmul double %18, %48
%50 = fdiv double %49, %22
%51 = fadd double %46, %50
%52 = fmul double %12, %1
%53 = fdiv double %52, %19
%54 = fmul double %18, %53
%55 = fdiv double %54, %21
%56 = fmul double %11, %1
%57 = fdiv double %56, %20
%58 = fmul double %18, %57
%59 = fdiv double %58, %22
%60 = fadd double %55, %59
%61 = fmul double %37, -8.000000e+00
%62 = tail call double @llvm.fmuladd.f64(double %26, double 6.000000e+00, double %61)
store double %62, double* %4
%63 = fmul double %42, -8.000000e+00
%64 = tail call double @llvm.fmuladd.f64(double %28, double 2.000000e+00, double %63)
store double %64, double* %5
%65 = fmul double %51, -8.000000e+00
%66 = tail call double @llvm.fmuladd.f64(double %26, double 2.000000e+00, double %65)
store double %66, double* %6
%67 = fmul double %60, -8.000000e+00
%68 = tail call double @llvm.fmuladd.f64(double %28, double 6.000000e+00, double %67)
store double %68, double* %7
ret void
}