double swi_edcheb(double x, double *coef, int ncf) {
  double bjpl, xjpl;
  int j;
  double x2, bf, bj, dj, xj, bjp2, xjp2;
  x2 = x * 2.;
  bf = 0.;
  bj = 0.;
  xjp2 = 0.;
  xjpl = 0.;
  bjp2 = 0.;
  bjpl = 0.;
  for (j = ncf - 1; j >= 1; j--) {
    dj = (double)(j + j);
    xj = coef[j] * dj + xjp2;
    bj = x2 * bjpl - bjp2 + xj;
    bf = bjp2;
    bjp2 = bjpl;
    bjpl = bj;
    xjp2 = xjpl;
    xjpl = xj;
  }
  return (bj - bf) * .5;
}


x86 assembly (clang, -O0):
<swi_edcheb>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  0xee8(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jl     1210 <swi_edcheb+0x110>
mov    -0x2c(%rbp),%eax
add    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <swi_edcheb+0x5b>
movsd  -0x48(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
mulsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<swi_edcheb>:
xorpd  %xmm1,%xmm1
cmp    $0x2,%esi
jl     117c <swi_edcheb+0x7c>
addsd  %xmm0,%xmm0
mov    %esi,%eax
add    $0x1,%rax
lea    (%rsi,%rsi,1),%ecx
add    $0xfffffffe,%ecx
xorpd  %xmm3,%xmm3
xorpd  %xmm5,%xmm5
xorpd  %xmm1,%xmm1
xorpd  %xmm2,%xmm2
nopl   0x0(%rax)
lea    -0x2(%rax),%edx
xorps  %xmm6,%xmm6
cvtsi2sd %ecx,%xmm6
mulsd  (%rdi,%rdx,8),%xmm6
movapd %xmm5,%xmm4
movapd %xmm1,%xmm5
addsd  %xmm3,%xmm6
movapd %xmm0,%xmm1
mulsd  %xmm5,%xmm1
subsd  %xmm4,%xmm1
addsd  %xmm6,%xmm1
add    $0xffffffffffffffff,%rax
add    $0xfffffffe,%ecx
movapd %xmm2,%xmm3
movapd %xmm6,%xmm2
cmp    $0x2,%rax
ja     1130 <swi_edcheb+0x30>
subsd  %xmm4,%xmm1
mulsd  0xe84(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @swi_edcheb(double %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %4
store double* %1, double** %5
store i32 %2, i32* %6
%17 = load double, double* %4
%18 = fmul double %17, 2.000000e+00
store double %18, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %16
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %7
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %9
br label %21
21: ; preds = %49, %3
%22 = load i32, i32* %9
%23 = icmp sge i32 %22, 1
br i1 %23, label %24, label %52
24: ; preds = %21
%25 = load i32, i32* %9
%26 = load i32, i32* %9
%27 = add nsw i32 %25, %26
%28 = sitofp i32 %27 to double
store double %28, double* %13
%29 = load double*, double** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double, double* %13
%35 = load double, double* %16
%36 = call double @llvm.fmuladd.f64(double %33, double %34, double %35)
store double %36, double* %14
%37 = load double, double* %10
%38 = load double, double* %7
%39 = load double, double* %15
%40 = fneg double %39
%41 = call double @llvm.fmuladd.f64(double %37, double %38, double %40)
%42 = load double, double* %14
%43 = fadd double %41, %42
store double %43, double* %12
%44 = load double, double* %15
store double %44, double* %11
%45 = load double, double* %7
store double %45, double* %15
%46 = load double, double* %12
store double %46, double* %7
%47 = load double, double* %8
store double %47, double* %16
%48 = load double, double* %14
store double %48, double* %8
br label %49
49: ; preds = %24
%50 = load i32, i32* %9
%51 = add nsw i32 %50, -1
store i32 %51, i32* %9
br label %21
52: ; preds = %21
%53 = load double, double* %12
%54 = load double, double* %11
%55 = fsub double %53, %54
%56 = fmul double %55, 5.000000e-01
ret double %56
}

LLVM IR (-O2):
define double @swi_edcheb(double %0, double* nocapture %1, i32 %2) {
%4 = fmul double %0, 2.000000e+00
%5 = icmp sgt i32 %2, 1
br i1 %5, label %6, label %29
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ %7, %6 ], [ %14, %8 ]
%10 = phi double [ 0.000000e+00, %6 ], [ %13, %8 ]
%11 = phi double [ 0.000000e+00, %6 ], [ %12, %8 ]
%12 = phi double [ 0.000000e+00, %6 ], [ %24, %8 ]
%13 = phi double [ 0.000000e+00, %6 ], [ %21, %8 ]
%14 = add nsw i64 %9, -1
%15 = trunc i64 %14 to i32
%16 = shl nuw nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = and i64 %14, 4294967295
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %17, double %10)
%22 = fneg double %11
%23 = tail call double @llvm.fmuladd.f64(double %4, double %12, double %22)
%24 = fadd double %23, %21
%25 = icmp ugt i64 %9, 2
br i1 %25, label %8, label %26
26: ; preds = %8
%27 = fsub double %24, %11
%28 = fmul double %27, 5.000000e-01
br label %29
29: ; preds = %26, %3
%30 = phi double [ %28, %26 ], [ 0.000000e+00, %3 ]
ret double %30
}