double evalpoly(ord, coef, x)
int ord;
double *coef, x;
{
  double *fp, f;
  fp = &coef[ord];
  f = *fp;
  for (fp--; fp >= coef; fp--)
    f = x * f + *fp;
  return (f);
}


x86 assembly (clang, -O0):
<evalpoly>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     117a <evalpoly+0x7a>
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <evalpoly+0x3c>
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<evalpoly>:
movapd %xmm0,%xmm1
movslq %edi,%rax
movsd  (%rsi,%rax,8),%xmm0
lea    (%rsi,%rax,8),%rax
add    $0xfffffffffffffff8,%rax
cmp    %rsi,%rax
jb     1131 <evalpoly+0x31>
nopl   0x0(%rax)
mulsd  %xmm1,%xmm0
addsd  (%rax),%xmm0
add    $0xfffffffffffffff8,%rax
cmp    %rsi,%rax
jae    1120 <evalpoly+0x20>
ret

LLVM IR (-O0):
define double @evalpoly(i32 %0, double* %1, double %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double
%7 = alloca double*
%8 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double %2, double* %6
%9 = load double*, double** %5
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %9, i64 %11
store double* %12, double** %7
%13 = load double*, double** %7
%14 = load double, double* %13
store double %14, double* %8
%15 = load double*, double** %7
%16 = getelementptr inbounds double, double* %15, i32 -1
store double* %16, double** %7
br label %17
17: ; preds = %27, %3
%18 = load double*, double** %7
%19 = load double*, double** %5
%20 = icmp uge double* %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load double, double* %6
%23 = load double, double* %8
%24 = load double*, double** %7
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %22, double %23, double %25)
store double %26, double* %8
br label %27
27: ; preds = %21
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i32 -1
store double* %29, double** %7
br label %17
30: ; preds = %17
%31 = load double, double* %8
ret double %31
}

LLVM IR (-O2):
define double @evalpoly(i32 %0, double* %1, double %2) {
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds double, double* %1, i64 %4
%6 = load double, double* %5
%7 = getelementptr inbounds double, double* %5, i64 -1
%8 = icmp ult double* %7, %1
br i1 %8, label %16, label %9
9: ; preds = %3, %9
%10 = phi double* [ %14, %9 ], [ %7, %3 ]
%11 = phi double [ %13, %9 ], [ %6, %3 ]
%12 = load double, double* %10
%13 = tail call double @llvm.fmuladd.f64(double %2, double %11, double %12)
%14 = getelementptr inbounds double, double* %10, i64 -1
%15 = icmp ult double* %14, %1
br i1 %15, label %16, label %9
16: ; preds = %9, %3
%17 = phi double [ %6, %3 ], [ %13, %9 ]
ret double %17
}