#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double sqrt(double);
void eterms(double *xyz, int n, int direct, double A0, double A1, double A2) {
  int i;
  double x, y, z, w;
  if (direct < 0) {
    for (i = 0; i < n; i++) {
      xyz[i * 3] -= A0;
      xyz[i * 3 + 1] -= A1;
      xyz[i * 3 + 2] -= A2;
    }
  } else if (direct > 0) {
    double d, p, lambda1;
    for (i = 0; i < n; i++) {
      x = xyz[i * 3];
      y = xyz[i * 3 + 1];
      z = xyz[i * 3 + 2];
      d = 1.0 / sqrt(x * x + y * y + z * z);
      w = 2.0 * (A0 * x + A1 * y + A2 * z);
      p = A0 * A0 + A1 * A1 + A2 * A2 - 1.0;
      lambda1 = (-w + sqrt(w * w - 4.0 * p)) / 2.0;
      xyz[i * 3] = lambda1 * d * x + A0;
      xyz[i * 3 + 1] = lambda1 * d * y + A1;
      xyz[i * 3 + 2] = lambda1 * d * z + A2;
    }
  }
}


x86 assembly (clang, -O0):
<eterms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11c1 <eterms+0xb1>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bc <eterms+0xac>
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1142 <eterms+0x32>
jmp    1403 <eterms+0x2f3>
cmpl   $0x0,-0x10(%rbp)
jle    13fe <eterms+0x2ee>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    13f9 <eterms+0x2e9>
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xdaf(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd60(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd31(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  0xced(%rip),%xmm1
mulsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xca8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d2 <eterms+0xc2>
jmp    13fe <eterms+0x2ee>
jmp    1403 <eterms+0x2f3>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eterms>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
movapd %xmm1,0x20(%rsp)
movapd %xmm0,(%rsp)
mov    %rdi,%r15
test   %edx,%edx
js     1302 <eterms+0x1f2>
je     14c5 <eterms+0x3b5>
test   %esi,%esi
jle    14c5 <eterms+0x3b5>
movapd 0x20(%rsp),%xmm4
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
movapd (%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe8d(%rip),%xmm0
mulsd  0xe8d(%rip),%xmm0
movapd %xmm0,0x80(%rsp)
mov    %esi,%eax
unpcklpd %xmm4,%xmm3
movapd %xmm3,0x70(%rsp)
shl    $0x3,%rax
lea    (%rax,%rax,2),%r14
xor    %ebx,%ebx
xorpd  %xmm3,%xmm3
movapd %xmm2,0x40(%rsp)
jmp    1233 <eterms+0x123>
nopl   0x0(%rax)
movsd  %xmm6,0x30(%rsp)
movapd %xmm7,0x60(%rsp)
call   1030 <sqrt@plt>
movapd 0x60(%rsp),%xmm7
movsd  0x30(%rsp),%xmm6
movapd 0x50(%rsp),%xmm5
movsd  0x18(%rsp),%xmm4
xorpd  %xmm3,%xmm3
movapd 0x40(%rsp),%xmm2
movsd  0xe25(%rip),%xmm1
divsd  %xmm6,%xmm1
subsd  %xmm7,%xmm0
mulsd  0xe1d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm5,%xmm1
addpd  0x70(%rsp),%xmm1
movupd %xmm1,(%r15,%rbx,1)
mulsd  %xmm4,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%r15,%rbx,1)
add    $0x18,%rbx
cmp    %rbx,%r14
je     14c5 <eterms+0x3b5>
movupd (%r15,%rbx,1),%xmm5
movsd  0x10(%r15,%rbx,1),%xmm4
movapd %xmm5,%xmm7
unpckhpd %xmm5,%xmm7
movapd %xmm7,%xmm0
mulsd  %xmm7,%xmm0
movapd %xmm5,%xmm1
mulsd  %xmm5,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm3,%xmm0
movsd  %xmm4,0x18(%rsp)
movapd %xmm5,0x50(%rsp)
jb     1290 <eterms+0x180>
xorps  %xmm6,%xmm6
sqrtsd %xmm0,%xmm6
jmp    12bb <eterms+0x1ab>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm7,0x30(%rsp)
call   1030 <sqrt@plt>
movapd 0x30(%rsp),%xmm7
movapd 0x50(%rsp),%xmm5
movsd  0x18(%rsp),%xmm4
xorpd  %xmm3,%xmm3
movapd 0x40(%rsp),%xmm2
movapd %xmm0,%xmm6
mulsd  0x20(%rsp),%xmm7
movapd (%rsp),%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm7,%xmm0
movapd %xmm2,%xmm7
mulsd  %xmm4,%xmm7
addsd  %xmm0,%xmm7
addsd  %xmm7,%xmm7
movapd %xmm7,%xmm0
mulsd  %xmm7,%xmm0
addsd  0x80(%rsp),%xmm0
ucomisd %xmm3,%xmm0
jb     11b0 <eterms+0xa0>
sqrtsd %xmm0,%xmm0
jmp    11e3 <eterms+0xd3>
test   %esi,%esi
jle    14c5 <eterms+0x3b5>
mov    %esi,%eax
cmp    $0x1,%esi
jne    1318 <eterms+0x208>
xor    %ecx,%ecx
jmp    1480 <eterms+0x370>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd (%rsp),%xmm0
unpcklpd %xmm0,%xmm0
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm1,%xmm1
movapd %xmm2,%xmm8
unpcklpd %xmm2,%xmm8
lea    -0x2(%rcx),%rdx
mov    %rdx,%rsi
shr    %rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     14d2 <eterms+0x3c2>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movupd (%r15,%rdx,8),%xmm4
movupd 0x10(%r15,%rdx,8),%xmm5
movupd 0x20(%r15,%rdx,8),%xmm6
movupd 0x30(%r15,%rdx,8),%xmm3
movapd %xmm5,%xmm7
movsd  %xmm4,%xmm7
shufpd $0x1,%xmm6,%xmm4
movsd  %xmm5,%xmm6
subpd  %xmm0,%xmm7
subpd  %xmm1,%xmm4
subpd  %xmm8,%xmm6
movapd %xmm4,%xmm5
unpckhpd %xmm6,%xmm5
shufpd $0x2,%xmm7,%xmm6
unpcklpd %xmm4,%xmm7
movupd %xmm7,(%r15,%rdx,8)
movupd %xmm6,0x10(%r15,%rdx,8)
movupd %xmm5,0x20(%r15,%rdx,8)
movupd 0x50(%r15,%rdx,8),%xmm4
movupd 0x40(%r15,%rdx,8),%xmm5
movapd %xmm5,%xmm6
movsd  %xmm3,%xmm6
shufpd $0x1,%xmm4,%xmm3
movsd  %xmm5,%xmm4
subpd  %xmm0,%xmm6
subpd  %xmm1,%xmm3
subpd  %xmm8,%xmm4
movapd %xmm3,%xmm5
unpckhpd %xmm4,%xmm5
shufpd $0x2,%xmm6,%xmm4
unpcklpd %xmm3,%xmm6
movupd %xmm6,0x30(%r15,%rdx,8)
movupd %xmm4,0x40(%r15,%rdx,8)
movupd %xmm5,0x50(%r15,%rdx,8)
add    $0xc,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1360 <eterms+0x250>
test   $0x1,%sil
je     147b <eterms+0x36b>
movupd (%r15,%rdx,8),%xmm3
movupd 0x10(%r15,%rdx,8),%xmm4
movupd 0x20(%r15,%rdx,8),%xmm5
movapd %xmm4,%xmm6
movsd  %xmm3,%xmm6
shufpd $0x1,%xmm5,%xmm3
movsd  %xmm4,%xmm5
subpd  %xmm0,%xmm6
subpd  %xmm1,%xmm3
subpd  %xmm8,%xmm5
movapd %xmm3,%xmm0
unpckhpd %xmm5,%xmm0
shufpd $0x2,%xmm6,%xmm5
unpcklpd %xmm3,%xmm6
movupd %xmm6,(%r15,%rdx,8)
movupd %xmm5,0x10(%r15,%rdx,8)
movupd %xmm0,0x20(%r15,%rdx,8)
cmp    %rax,%rcx
je     14c5 <eterms+0x3b5>
movapd (%rsp),%xmm0
unpcklpd 0x20(%rsp),%xmm0
movapd %xmm0,(%rsp)
lea    (%rcx,%rcx,2),%rdx
lea    (%r15,%rdx,8),%rdx
add    $0x10,%rdx
sub    %rcx,%rax
nop
movupd -0x10(%rdx),%xmm0
subpd  (%rsp),%xmm0
movupd %xmm0,-0x10(%rdx)
movsd  (%rdx),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,(%rdx)
add    $0x18,%rdx
add    $0xffffffffffffffff,%rax
jne    14a0 <eterms+0x390>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %edx,%edx
test   $0x1,%sil
jne    1424 <eterms+0x314>
jmp    147b <eterms+0x36b>

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

LLVM IR (-O2):
define void @eterms(double* nocapture %0, i32 %1, i32 %2, double %3, double %4, double %5) {
%7 = icmp slt i32 %2, 0
br i1 %7, label %8, label %105
8: ; preds = %6
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %150
10: ; preds = %8
%11 = zext i32 %1 to i64
%12 = icmp eq i32 %1, 1
br i1 %12, label %87, label %13
13: ; preds = %10
%14 = and i64 %11, 4294967294
%15 = insertelement <2 x double> poison, double %3, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = insertelement <2 x double> poison, double %4, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = insertelement <2 x double> poison, double %5, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = add nsw i64 %14, -2
%22 = lshr exact i64 %21, 1
%23 = add nuw i64 %22, 1
%24 = and i64 %23, 1
%25 = icmp eq i64 %21, 0
br i1 %25, label %67, label %26
26: ; preds = %13
%27 = and i64 %23, -2
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %62, %28 ]
%30 = phi i64 [ 0, %26 ], [ %63, %28 ]
%31 = mul nuw nsw i64 %29, 3
%32 = getelementptr inbounds double, double* %0, i64 %31
%33 = bitcast double* %32 to <6 x double>*
%34 = load <6 x double>, <6 x double>* %33
%35 = shufflevector <6 x double> %34, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%36 = shufflevector <6 x double> %34, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%37 = shufflevector <6 x double> %34, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%38 = fsub <2 x double> %35, %16
%39 = fsub <2 x double> %36, %18
%40 = fsub <2 x double> %37, %20
%41 = getelementptr inbounds double, double* %0, i64 %31
%42 = bitcast double* %41 to <6 x double>*
%43 = shufflevector <2 x double> %38, <2 x double> %39, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%44 = shufflevector <2 x double> %40, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%45 = shufflevector <4 x double> %43, <4 x double> %44, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %45, <6 x double>* %42
%46 = or i64 %29, 2
%47 = mul nuw nsw i64 %46, 3
%48 = getelementptr inbounds double, double* %0, i64 %47
%49 = bitcast double* %48 to <6 x double>*
%50 = load <6 x double>, <6 x double>* %49
%51 = shufflevector <6 x double> %50, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%52 = shufflevector <6 x double> %50, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%53 = shufflevector <6 x double> %50, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%54 = fsub <2 x double> %51, %16
%55 = fsub <2 x double> %52, %18
%56 = fsub <2 x double> %53, %20
%57 = getelementptr inbounds double, double* %0, i64 %47
%58 = bitcast double* %57 to <6 x double>*
%59 = shufflevector <2 x double> %54, <2 x double> %55, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%60 = shufflevector <2 x double> %56, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%61 = shufflevector <4 x double> %59, <4 x double> %60, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %61, <6 x double>* %58
%62 = add nuw i64 %29, 4
%63 = add nuw i64 %30, 2
%64 = icmp eq i64 %63, %27
br i1 %64, label %65, label %28
65: ; preds = %28
%66 = mul i64 %62, 3
br label %67
67: ; preds = %65, %13
%68 = phi i64 [ 0, %13 ], [ %66, %65 ]
%69 = icmp eq i64 %24, 0
br i1 %69, label %85, label %70
70: ; preds = %67
%71 = getelementptr inbounds double, double* %0, i64 %68
%72 = bitcast double* %71 to <6 x double>*
%73 = load <6 x double>, <6 x double>* %72
%74 = shufflevector <6 x double> %73, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%75 = shufflevector <6 x double> %73, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%76 = shufflevector <6 x double> %73, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%77 = fsub <2 x double> %74, %16
%78 = fsub <2 x double> %75, %18
%79 = fsub <2 x double> %76, %20
%80 = getelementptr inbounds double, double* %0, i64 %68
%81 = bitcast double* %80 to <6 x double>*
%82 = shufflevector <2 x double> %77, <2 x double> %78, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%83 = shufflevector <2 x double> %79, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%84 = shufflevector <4 x double> %82, <4 x double> %83, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %84, <6 x double>* %81
br label %85
85: ; preds = %67, %70
%86 = icmp eq i64 %14, %11
br i1 %86, label %150, label %87
87: ; preds = %10, %85
%88 = phi i64 [ 0, %10 ], [ %14, %85 ]
%89 = insertelement <2 x double> poison, double %3, i64 0
%90 = insertelement <2 x double> %89, double %4, i64 1
br label %91
91: ; preds = %87, %91
%92 = phi i64 [ %103, %91 ], [ %88, %87 ]
%93 = mul nuw nsw i64 %92, 3
%94 = getelementptr inbounds double, double* %0, i64 %93
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = fsub <2 x double> %96, %90
%98 = bitcast double* %94 to <2 x double>*
store <2 x double> %97, <2 x double>* %98
%99 = add nuw nsw i64 %93, 2
%100 = getelementptr inbounds double, double* %0, i64 %99
%101 = load double, double* %100
%102 = fsub double %101, %5
store double %102, double* %100
%103 = add nuw nsw i64 %92, 1
%104 = icmp eq i64 %103, %11
br i1 %104, label %150, label %91
105: ; preds = %6
%106 = icmp ne i32 %2, 0
%107 = icmp sgt i32 %1, 0
%108 = and i1 %106, %107
br i1 %108, label %109, label %150
109: ; preds = %105
%110 = fmul double %4, %4
%111 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %110)
%112 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %111)
%113 = fadd double %112, -1.000000e+00
%114 = fmul double %113, -4.000000e+00
%115 = zext i32 %1 to i64
%116 = insertelement <2 x double> poison, double %3, i64 0
%117 = insertelement <2 x double> %116, double %4, i64 1
br label %118
118: ; preds = %109, %118
%119 = phi i64 [ 0, %109 ], [ %148, %118 ]
%120 = mul nuw nsw i64 %119, 3
%121 = getelementptr inbounds double, double* %0, i64 %120
%122 = bitcast double* %121 to <2 x double>*
%123 = load <2 x double>, <2 x double>* %122
%124 = add nuw nsw i64 %120, 2
%125 = getelementptr inbounds double, double* %0, i64 %124
%126 = load double, double* %125
%127 = extractelement <2 x double> %123, i64 1
%128 = fmul double %127, %127
%129 = extractelement <2 x double> %123, i64 0
%130 = tail call double @llvm.fmuladd.f64(double %129, double %129, double %128)
%131 = tail call double @llvm.fmuladd.f64(double %126, double %126, double %130)
%132 = tail call double @sqrt(double %131)
%133 = fdiv double 1.000000e+00, %132
%134 = fmul double %127, %4
%135 = tail call double @llvm.fmuladd.f64(double %3, double %129, double %134)
%136 = tail call double @llvm.fmuladd.f64(double %5, double %126, double %135)
%137 = fmul double %136, 2.000000e+00
%138 = tail call double @llvm.fmuladd.f64(double %137, double %137, double %114)
%139 = tail call double @sqrt(double %138)
%140 = fsub double %139, %137
%141 = fmul double %140, 5.000000e-01
%142 = fmul double %133, %141
%143 = insertelement <2 x double> poison, double %142, i64 0
%144 = shufflevector <2 x double> %143, <2 x double> poison, <2 x i32> zeroinitializer
%145 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %144, <2 x double> %123, <2 x double> %117)
%146 = bitcast double* %121 to <2 x double>*
store <2 x double> %145, <2 x double>* %146
%147 = tail call double @llvm.fmuladd.f64(double %142, double %126, double %5)
store double %147, double* %125
%148 = add nuw nsw i64 %119, 1
%149 = icmp eq i64 %148, %115
br i1 %149, label %150, label %118
150: ; preds = %118, %91, %85, %8, %105
ret void
}