double acceleratednewtonraphson(double initial, double accuracy,
                                double (*f)(double), double (*df)(double),
                                int degree) {
  int i = 1;
  double xi, ximinus1 = initial, fxi, dfxi, ei = exp(1);
  printf("ACCELERATED NETWON RAPHSON "
         "METHOD:\n\ni\txi\t\t|ei|\t\t|log(ei)/log(e(i-1))|\n");
  do {
    xi = ximinus1;
    fxi = f(xi);
    if (!(dfxi = df(xi)))
      break;
    ximinus1 = xi - degree * fxi / dfxi;
    printf("%02d\t%+09g\t%+09g\t%+09g\n", i++, xi, abslt(xi - ximinus1),
           abslt(log(abslt(xi - ximinus1)) / log(ei)));
    ei = abslt(xi - ximinus1);
  } while (abslt(xi - ximinus1) > accuracy);
  return xi;
}


x86 assembly (clang, -O0):
<acceleratednewtonraphson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8a(%rip),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x50(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x30(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  -0x30(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d0 <acceleratednewtonraphson+0x90>
jp     11d0 <acceleratednewtonraphson+0x90>
jmp    12a8 <acceleratednewtonraphson+0x168>
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
divsd  -0x48(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x64(%rbp)
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,-0x54(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    -0x64(%rbp),%esi
movsd  -0x60(%rbp),%xmm0
mov    -0x54(%rbp),%edx
mov    %eax,%ecx
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     118e <acceleratednewtonraphson+0x4e>
movsd  -0x30(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acceleratednewtonraphson>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r12
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x18(%rsp)
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%ebx
lea    0xe7b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   *%r12
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   *%r14
ucomisd 0xe43(%rip),%xmm0
jne    11cd <acceleratednewtonraphson+0x8d>
jnp    1295 <acceleratednewtonraphson+0x155>
movsd  (%rsp),%xmm2
mulsd  0x20(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
lea    0x1(%rbx),%r13d
movsd  %xmm1,0x18(%rsp)
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <log@plt>
movsd  0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %r15,%rdi
mov    %ebx,%esi
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edx
mov    %eax,%ecx
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd 0x28(%rsp),%xmm0
mov    %r13d,%ebx
ja     11a0 <acceleratednewtonraphson+0x60>
movsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [71 x i8] c"ACCELERATED NETWON RAPHSON METHOD:\0A\0Ai\09xi\09\09|ei|\09\09|log(ei)/log(e(i-1))|\0A\00"
@.str.1 = [24 x i8] c"%02d\09%+09g\09%+09g\09%+09g\0A\00"
define double @acceleratednewtonraphson(double %0, double %1, double (double)* %2, double (double)* %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double (double)*
%9 = alloca double (double)*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %6
store double %1, double* %7
store double (double)* %2, double (double)** %8
store double (double)* %3, double (double)** %9
store i32 %4, i32* %10
store i32 1, i32* %11
%17 = load double, double* %6
store double %17, double* %13
%18 = call double @exp(double 1.000000e+00)
store double %18, double* %16
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %62, %5
%21 = load double, double* %13
store double %21, double* %12
%22 = load double (double)*, double (double)** %8
%23 = load double, double* %12
%24 = call double %22(double %23)
store double %24, double* %14
%25 = load double (double)*, double (double)** %9
%26 = load double, double* %12
%27 = call double %25(double %26)
store double %27, double* %15
%28 = fcmp une double %27, 0.000000e+00
br i1 %28, label %30, label %29
29: ; preds = %20
br label %70
30: ; preds = %20
%31 = load double, double* %12
%32 = load i32, i32* %10
%33 = sitofp i32 %32 to double
%34 = load double, double* %14
%35 = fmul double %33, %34
%36 = load double, double* %15
%37 = fdiv double %35, %36
%38 = fsub double %31, %37
store double %38, double* %13
%39 = load i32, i32* %11
%40 = add nsw i32 %39, 1
store i32 %40, i32* %11
%41 = load double, double* %12
%42 = load double, double* %12
%43 = load double, double* %13
%44 = fsub double %42, %43
%45 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %44)
%46 = load double, double* %12
%47 = load double, double* %13
%48 = fsub double %46, %47
%49 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %48)
%50 = sitofp i32 %49 to double
%51 = call double @log(double %50)
%52 = load double, double* %16
%53 = call double @log(double %52)
%54 = fdiv double %51, %53
%55 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %39, double %41, i32 %45, i32 %55)
%57 = load double, double* %12
%58 = load double, double* %13
%59 = fsub double %57, %58
%60 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %59)
%61 = sitofp i32 %60 to double
store double %61, double* %16
br label %62
62: ; preds = %30
%63 = load double, double* %12
%64 = load double, double* %13
%65 = fsub double %63, %64
%66 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %65)
%67 = sitofp i32 %66 to double
%68 = load double, double* %7
%69 = fcmp ogt double %67, %68
br i1 %69, label %20, label %70
70: ; preds = %62, %29
%71 = load double, double* %12
ret double %71
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"%02d\09%+09g\09%+09g\09%+09g\0A\00"
@str = [70 x i8] c"ACCELERATED NETWON RAPHSON METHOD:\0A\0Ai\09xi\09\09|ei|\09\09|log(ei)/log(e(i-1))|\00"
define double @acceleratednewtonraphson(double %0, double %1, double (double)* nocapture %2, double (double)* nocapture %3, i32 %4) {
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%7 = sitofp i32 %4 to double
br label %8
8: ; preds = %15, %5
%9 = phi double [ %0, %5 ], [ %18, %15 ]
%10 = phi i32 [ 1, %5 ], [ %19, %15 ]
%11 = phi double [ 0x4005BF0A8B145769, %5 ], [ %30, %15 ]
%12 = tail call double %2(double %9)
%13 = tail call double %3(double %9)
%14 = fcmp une double %13, 0.000000e+00
br i1 %14, label %15, label %34
15: ; preds = %8
%16 = fmul double %12, %7
%17 = fdiv double %16, %13
%18 = fsub double %9, %17
%19 = add nuw nsw i32 %10, 1
%20 = fsub double %9, %18
%21 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %20)
%22 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %20)
%23 = sitofp i32 %22 to double
%24 = tail call double @log(double %23)
%25 = tail call double @log(double %11)
%26 = fdiv double %24, %25
%27 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %26)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %10, double %9, i32 %21, i32 %27)
%29 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %20)
%30 = sitofp i32 %29 to double
%31 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %20)
%32 = sitofp i32 %31 to double
%33 = fcmp ogt double %32, %1
br i1 %33, label %8, label %34
34: ; preds = %8, %15
ret double %9
}