double dpoly(x, p)
double x;
double *p;
{
  static int i;
  static double r, s;
  s = 1.0;
  r = 0.0;
  for (i = 1; i < p[0]; i++) {
    r += i * p[i + 1] * s;
    s *= x;
  }
  return (r);
}


x86 assembly (clang, -O0):
<dpoly>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  0xeeb(%rip),%xmm0
movsd  %xmm0,0x2f1b(%rip)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2f08(%rip)
movl   $0x1,0x2ef6(%rip)
cvtsi2sdl 0x2eee(%rip),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b2 <dpoly+0xb2>
cvtsi2sdl 0x2ed4(%rip),%xmm0
mov    -0x10(%rbp),%rax
mov    0x2eca(%rip),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  0x2ec7(%rip),%xmm2
movsd  0x2eb7(%rip),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x2ea7(%rip)
movsd  -0x8(%rbp),%xmm0
mulsd  0x2ea2(%rip),%xmm0
movsd  %xmm0,0x2e9a(%rip)
mov    0x2e84(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e7b(%rip)
jmp    1132 <dpoly+0x32>
movsd  0x2e76(%rip),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<dpoly>:
movsd  (%rdi),%xmm2
xorpd  %xmm1,%xmm1
ucomisd 0xef0(%rip),%xmm2
jbe    1152 <dpoly+0x52>
xorpd  %xmm1,%xmm1
movsd  0xee2(%rip),%xmm3
mov    $0x2,%eax
movapd %xmm3,%xmm4
nopw   0x0(%rax,%rax,1)
mulsd  (%rdi,%rax,8),%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm3,%xmm1
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
mulsd  %xmm0,%xmm4
add    $0x1,%rax
ucomisd %xmm3,%xmm2
ja     1130 <dpoly+0x30>
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
@dpoly.i = internal global i32 0
@dpoly.r = internal global double 0.000000e+00
@dpoly.s = internal global double 0.000000e+00
define double @dpoly(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
store double %0, double* %3
store double* %1, double** %4
store double 1.000000e+00, double* @dpoly.s
store double 0.000000e+00, double* @dpoly.r
store i32 1, i32* @dpoly.i
br label %5
5: ; preds = %28, %2
%6 = load i32, i32* @dpoly.i
%7 = sitofp i32 %6 to double
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = fcmp olt double %7, %10
br i1 %11, label %12, label %31
12: ; preds = %5
%13 = load i32, i32* @dpoly.i
%14 = sitofp i32 %13 to double
%15 = load double*, double** %4
%16 = load i32, i32* @dpoly.i
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %15, i64 %18
%20 = load double, double* %19
%21 = fmul double %14, %20
%22 = load double, double* @dpoly.s
%23 = load double, double* @dpoly.r
%24 = call double @llvm.fmuladd.f64(double %21, double %22, double %23)
store double %24, double* @dpoly.r
%25 = load double, double* %3
%26 = load double, double* @dpoly.s
%27 = fmul double %26, %25
store double %27, double* @dpoly.s
br label %28
28: ; preds = %12
%29 = load i32, i32* @dpoly.i
%30 = add nsw i32 %29, 1
store i32 %30, i32* @dpoly.i
br label %5
31: ; preds = %5
%32 = load double, double* @dpoly.r
ret double %32
}

LLVM IR (-O2):
define double @dpoly(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = fcmp ogt double %3, 1.000000e+00
br i1 %4, label %5, label %19
5: ; preds = %2, %5
%6 = phi i64 [ %10, %5 ], [ 1, %2 ]
%7 = phi double [ %17, %5 ], [ 1.000000e+00, %2 ]
%8 = phi double [ %15, %5 ], [ 1.000000e+00, %2 ]
%9 = phi double [ %14, %5 ], [ 0.000000e+00, %2 ]
%10 = add nuw nsw i64 %6, 1
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = load double, double* %11
%13 = fmul double %7, %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double %8, double %9)
%15 = fmul double %8, %0
%16 = trunc i64 %10 to i32
%17 = sitofp i32 %16 to double
%18 = fcmp ogt double %3, %17
br i1 %18, label %5, label %19
19: ; preds = %5, %2
%20 = phi double [ 0.000000e+00, %2 ], [ %14, %5 ]
ret double %20
}