double iterative(double initial, double accuracy, double (*f)(double)) {
  int i = 1;
  double xi, ximinus1 = initial, fxi, ei = exp(1);
  printf("ITERATIVE "
         "METHOD:\n\ni\txi\t\t|g(xi)|\t\t|f(xi)|\t\t|ei|\t\t|log(ei)/"
         "log(e(i-1))|\n");
  do {
    xi = ximinus1;
    fxi = f(xi);
    ximinus1 = fxi;
    printf("%02d\t%+09g\t%+09g\t%+09g\t%+09g\t%+09g\n", i++, xi,
           abslt(ximinus1), abslt(xi - ximinus1), 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):
<iterative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe91(%rip),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x40(%rbp)
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,-0x4c(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,-0x44(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    -0x5c(%rbp),%esi
movsd  -0x58(%rbp),%xmm0
mov    -0x4c(%rbp),%edx
mov    -0x48(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    %eax,%r9d
lea    0xe00(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1187 <iterative+0x47>
movsd  -0x28(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterative>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r15
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x18(%rsp)
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
movsd  0xe8f(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    $0x1,%ebx
nopl   0x0(%rax)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
call   *%r15
movsd  %xmm0,0x18(%rsp)
lea    0x1(%rbx),%r14d
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,%r12d
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,%r13d
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <log@plt>
movsd  0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
lea    0xdf4(%rip),%rdi
mov    %ebx,%esi
movsd  0x10(%rsp),%xmm0
mov    %r12d,%edx
mov    %r13d,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd 0x28(%rsp),%xmm0
mov    %r14d,%ebx
ja     1180 <iterative+0x40>
movsd  0x10(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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