double bisection(double initiala, double initialb, double accuracy,
                 double (*f)(double)) {
  int i = 1;
  double a = initiala, b = initialb, c, fa = f(a), fb = f(b), fc,
         ei = (b - a) / 2;
  printf("BISECTION "
         "METHOD:\n\ni\ta\t\tb\t\tc\t\tf(c)\t\t|f(c)|\t\t|ei|\t\t|log(ei)/"
         "log(e(i-1))|\n");
  do {
    c = (a + b) / 2;
    if (!(fc = f(c)))
      break;
    printf("%02d\t%+09g\t%+09g\t%+09g\t%+09g\t%+09g\t%+09g\t%+09g\n", i++, a, b,
           c, fc, abslt(fc), (b - a) / 2, abslt(log((b - a) / 2) / log(ei)));
    ei = (b - a) / 2;
    if (fa * fc > 0)
      fa = fc, a = c;
    else
      fb = fc, b = c;
  } while ((b - a) / 2 > accuracy);
  return c;
}


x86 assembly (clang, -O0):
<bisection>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  -0x30(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movsd  -0x38(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  -0x40(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f5 <bisection+0xc5>
jp     11f5 <bisection+0xc5>
jmp    135c <bisection+0x22c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x94(%rbp)
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,-0x6c(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xdad(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xd92(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    -0x94(%rbp),%esi
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm3
mov    -0x6c(%rbp),%edx
movsd  -0x68(%rbp),%xmm4
mov    %eax,%ecx
lea    0xd81(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xd17(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1322 <bisection+0x1f2>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1336 <bisection+0x206>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    133b <bisection+0x20b>
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xcb3(%rip),%xmm1
divsd  %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     11b2 <bisection+0x82>
movsd  -0x40(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bisection>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%r15
movsd  %xmm2,0x58(%rsp)
movaps %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   *%rdi
movsd  %xmm0,0x30(%rsp)
movaps 0x10(%rsp),%xmm0
call   *%r15
movapd 0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0xe7b(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
movsd  0xe5c(%rip),%xmm1
lea    0xe65(%rip),%r14
jmp    1210 <bisection+0xd0>
nopl   (%rax)
add    $0x1,%ebp
xorpd  %xmm1,%xmm1
cmpltsd %xmm2,%xmm1
movapd 0x10(%rsp),%xmm2
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
movsd  0xe1c(%rip),%xmm2
mulsd  %xmm2,%xmm1
ucomisd 0x58(%rsp),%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  %xmm4,0x30(%rsp)
movapd 0x70(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movapd %xmm2,%xmm1
jbe    12ff <bisection+0x1bf>
movapd 0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0x40(%rsp)
call   *%r15
ucomisd 0xdd7(%rip),%xmm0
jne    1239 <bisection+0xf9>
jnp    12ff <bisection+0x1bf>
movapd %xmm0,%xmm2
movsd  %xmm2,0x38(%rsp)
mov    $0x1,%al
movsd  %xmm0,0x68(%rsp)
call   1030 <abslt@plt>
mov    %eax,%ebx
movapd 0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0xd9a(%rip),%xmm0
movapd %xmm0,0x70(%rsp)
call   1060 <log@plt>
movsd  %xmm0,0x60(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <log@plt>
movsd  0x60(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %r14,%rdi
mov    %ebp,%esi
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movaps 0x40(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
mov    %ebx,%edx
movaps 0x70(%rsp),%xmm4
mov    %eax,%ecx
mov    $0x5,%al
call   1050 <printf@plt>
movsd  0x68(%rsp),%xmm2
movsd  0x38(%rsp),%xmm4
movsd  0x30(%rsp),%xmm1
mulsd  %xmm1,%xmm2
ucomisd 0xd28(%rip),%xmm2
movapd 0x40(%rsp),%xmm3
movapd %xmm3,%xmm0
ja     11b0 <bisection+0x70>
movsd  0x8(%rsp),%xmm0
movapd %xmm1,%xmm4
jmp    11b0 <bisection+0x70>
movaps 0x40(%rsp),%xmm0
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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