double Hn(double x, int n) {
  double h[2] = {1, 2 * x};
  for (int k = 1; k < 100; k++) {
    double newvalue = 2 * (x * h[1] - k * h[0]);
    h[0] = h[1];
    h[1] = newvalue;
  }
  return h[1];
}


x86 assembly (clang, -O0):
<Hn>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  0xef4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xedf(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    11a2 <Hn+0xa2>
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <Hn+0x32>
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hn>:
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xef0(%rip),%xmm2
mov    $0x3,%eax
movsd  0xeeb(%rip),%xmm3
movapd %xmm2,%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mulsd  %xmm2,%xmm4
movapd %xmm0,%xmm5
mulsd  %xmm1,%xmm5
subsd  %xmm4,%xmm5
lea    -0x1(%rax),%ecx
addsd  %xmm5,%xmm5
xorps  %xmm6,%xmm6
cvtsi2sd %ecx,%xmm6
mulsd  %xmm1,%xmm6
movapd %xmm0,%xmm4
mulsd  %xmm5,%xmm4
subsd  %xmm6,%xmm4
xorps  %xmm6,%xmm6
cvtsi2sd %eax,%xmm6
addsd  %xmm4,%xmm4
mulsd  %xmm5,%xmm6
movapd %xmm0,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm6,%xmm1
addsd  %xmm3,%xmm2
addsd  %xmm1,%xmm1
add    $0x3,%eax
cmp    $0x66,%eax
jne    1130 <Hn+0x30>
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @Hn(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca [2 x double]
%6 = alloca i32
%7 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
store double 1.000000e+00, double* %8
%9 = getelementptr inbounds double, double* %8, i64 1
%10 = load double, double* %3
%11 = fmul double 2.000000e+00, %10
store double %11, double* %9
store i32 1, i32* %6
br label %12
12: ; preds = %32, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 100
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = load double, double* %3
%17 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%18 = load double, double* %17
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to double
%21 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%22 = load double, double* %21
%23 = fmul double %20, %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %16, double %18, double %24)
%26 = fmul double 2.000000e+00, %25
store double %26, double* %7
%27 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%28 = load double, double* %27
%29 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
store double %28, double* %29
%30 = load double, double* %7
%31 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
store double %30, double* %31
br label %32
32: ; preds = %15
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %12
35: ; preds = %12
%36 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%37 = load double, double* %36
ret double %37
}

LLVM IR (-O2):
define double @Hn(double %0, i32 %1) {
%3 = fmul double %0, 2.000000e+00
br label %5
4: ; preds = %5
ret double %26
5: ; preds = %5, %2
%6 = phi double [ %3, %2 ], [ %26, %5 ]
%7 = phi i32 [ 1, %2 ], [ %25, %5 ]
%8 = phi double [ 1.000000e+00, %2 ], [ %20, %5 ]
%9 = sitofp i32 %7 to double
%10 = fneg double %8
%11 = fmul double %10, %9
%12 = tail call double @llvm.fmuladd.f64(double %0, double %6, double %11)
%13 = add nuw nsw i32 %7, 1
%14 = fmul double %12, 2.000000e+00
%15 = sitofp i32 %13 to double
%16 = fneg double %6
%17 = fmul double %16, %15
%18 = tail call double @llvm.fmuladd.f64(double %0, double %14, double %17)
%19 = add nuw nsw i32 %7, 2
%20 = fmul double %18, 2.000000e+00
%21 = sitofp i32 %19 to double
%22 = fneg double %14
%23 = fmul double %22, %21
%24 = tail call double @llvm.fmuladd.f64(double %0, double %20, double %23)
%25 = add nuw nsw i32 %7, 3
%26 = fmul double %24, 2.000000e+00
%27 = icmp eq i32 %25, 100
br i1 %27, label %4, label %5
}