double BisectionMethod() {
  double root = 0;
  double a = 1, b = 2;
  double c = 0;
  int loopCounter = 0;
  if ((((a) * (a) * (a)) - (a)-2) * (((b) * (b) * (b)) - (b)-2) < 0) {
    while (1) {
      loopCounter++;
      c = (a + b) / 2;
      if ((((c) * (c) * (c)) - (c)-2) < 0.00001 &&
          (((c) * (c) * (c)) - (c)-2) > -0.00001) {
        root = c;
        break;
      }
      if (((((a) * (a) * (a)) - (a)-2)) * ((((c) * (c) * (c)) - (c)-2)) < 0) {
        b = c;
      } else {
        a = c;
      }
    }
  }
  printf("It took %d loops.\n", loopCounter);
  return root;
}


x86 assembly (clang, -O0):
<BisectionMethod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xee0(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe7c(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  0xe3d(%rip),%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1364 <BisectionMethod+0x254>
jmp    11dd <BisectionMethod+0xcd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe08(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdc4(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xdc8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12b2 <BisectionMethod+0x1a2>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd73(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xd7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12b2 <BisectionMethod+0x1a2>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    135f <BisectionMethod+0x24f>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd13(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  0xcd4(%rip),%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1350 <BisectionMethod+0x240>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    135a <BisectionMethod+0x24a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11dd <BisectionMethod+0xcd>
jmp    1364 <BisectionMethod+0x254>
mov    -0x24(%rbp),%esi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BisectionMethod>:
sub    $0x18,%rsp
movsd  0xee4(%rip),%xmm4
movsd  0xee4(%rip),%xmm5
mov    $0x1,%esi
movsd  0xedf(%rip),%xmm3
movsd  0xedf(%rip),%xmm6
movsd  0xedf(%rip),%xmm1
xorpd  %xmm2,%xmm2
movsd  0xeda(%rip),%xmm9
movsd  0xed9(%rip),%xmm10
movsd  0xed8(%rip),%xmm8
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
mulsd  %xmm4,%xmm0
subsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm6,%xmm0
ucomisd %xmm0,%xmm2
movapd %xmm3,%xmm7
ja     1186 <BisectionMethod+0x76>
movapd %xmm5,%xmm7
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm4
andnpd %xmm3,%xmm0
orpd   %xmm0,%xmm4
add    $0x1,%esi
movapd %xmm4,%xmm3
addsd  %xmm7,%xmm3
mulsd  %xmm9,%xmm3
movapd %xmm3,%xmm6
mulsd  %xmm3,%xmm6
mulsd  %xmm3,%xmm6
subsd  %xmm3,%xmm6
addsd  %xmm1,%xmm6
ucomisd %xmm6,%xmm10
movapd %xmm7,%xmm5
jbe    1160 <BisectionMethod+0x50>
ucomisd %xmm8,%xmm6
movapd %xmm7,%xmm5
jbe    1160 <BisectionMethod+0x50>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
movapd %xmm3,(%rsp)
call   1030 <printf@plt>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"It took %d loops.\0A\00"
define double @BisectionMethod() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double 0.000000e+00, double* %1
store double 1.000000e+00, double* %2
store double 2.000000e+00, double* %3
store double 0.000000e+00, double* %4
store i32 0, i32* %5
%6 = load double, double* %2
%7 = load double, double* %2
%8 = fmul double %6, %7
%9 = load double, double* %2
%10 = load double, double* %2
%11 = fneg double %10
%12 = call double @llvm.fmuladd.f64(double %8, double %9, double %11)
%13 = fsub double %12, 2.000000e+00
%14 = load double, double* %3
%15 = load double, double* %3
%16 = fmul double %14, %15
%17 = load double, double* %3
%18 = load double, double* %3
%19 = fneg double %18
%20 = call double @llvm.fmuladd.f64(double %16, double %17, double %19)
%21 = fsub double %20, 2.000000e+00
%22 = fmul double %13, %21
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %78
24: ; preds = %0
br label %25
25: ; preds = %24, %76
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
%28 = load double, double* %2
%29 = load double, double* %3
%30 = fadd double %28, %29
%31 = fdiv double %30, 2.000000e+00
store double %31, double* %4
%32 = load double, double* %4
%33 = load double, double* %4
%34 = fmul double %32, %33
%35 = load double, double* %4
%36 = load double, double* %4
%37 = fneg double %36
%38 = call double @llvm.fmuladd.f64(double %34, double %35, double %37)
%39 = fsub double %38, 2.000000e+00
%40 = fcmp olt double %39, 1.000000e-05
br i1 %40, label %41, label %53
41: ; preds = %25
%42 = load double, double* %4
%43 = load double, double* %4
%44 = fmul double %42, %43
%45 = load double, double* %4
%46 = load double, double* %4
%47 = fneg double %46
%48 = call double @llvm.fmuladd.f64(double %44, double %45, double %47)
%49 = fsub double %48, 2.000000e+00
%50 = fcmp ogt double %49, -1.000000e-05
br i1 %50, label %51, label %53
51: ; preds = %41
%52 = load double, double* %4
store double %52, double* %1
br label %77
53: ; preds = %41, %25
%54 = load double, double* %2
%55 = load double, double* %2
%56 = fmul double %54, %55
%57 = load double, double* %2
%58 = load double, double* %2
%59 = fneg double %58
%60 = call double @llvm.fmuladd.f64(double %56, double %57, double %59)
%61 = fsub double %60, 2.000000e+00
%62 = load double, double* %4
%63 = load double, double* %4
%64 = fmul double %62, %63
%65 = load double, double* %4
%66 = load double, double* %4
%67 = fneg double %66
%68 = call double @llvm.fmuladd.f64(double %64, double %65, double %67)
%69 = fsub double %68, 2.000000e+00
%70 = fmul double %61, %69
%71 = fcmp olt double %70, 0.000000e+00
br i1 %71, label %72, label %74
72: ; preds = %53
%73 = load double, double* %4
store double %73, double* %3
br label %76
74: ; preds = %53
%75 = load double, double* %4
store double %75, double* %2
br label %76
76: ; preds = %74, %72
br label %25
77: ; preds = %51
br label %78
78: ; preds = %77, %0
%79 = load i32, i32* %5
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %79)
%81 = load double, double* %1
ret double %81
}

LLVM IR (-O2):
@.str = [19 x i8] c"It took %d loops.\0A\00"
define double @BisectionMethod() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ -1.250000e-01, %0 ], [ %21, %1 ]
%3 = phi double [ 1.500000e+00, %0 ], [ %17, %1 ]
%4 = phi i32 [ 1, %0 ], [ %15, %1 ]
%5 = phi double [ 2.000000e+00, %0 ], [ %14, %1 ]
%6 = phi double [ 1.000000e+00, %0 ], [ %13, %1 ]
%7 = fmul double %6, %6
%8 = fneg double %6
%9 = tail call double @llvm.fmuladd.f64(double %7, double %6, double %8)
%10 = fadd double %9, -2.000000e+00
%11 = fmul double %10, %2
%12 = fcmp olt double %11, 0.000000e+00
%13 = select i1 %12, double %6, double %3
%14 = select i1 %12, double %3, double %5
%15 = add nuw nsw i32 %4, 1
%16 = fadd double %13, %14
%17 = fmul double %16, 5.000000e-01
%18 = fmul double %17, %17
%19 = fneg double %17
%20 = tail call double @llvm.fmuladd.f64(double %18, double %17, double %19)
%21 = fadd double %20, -2.000000e+00
%22 = fcmp olt double %21, 1.000000e-05
%23 = fcmp ogt double %21, -1.000000e-05
%24 = and i1 %22, %23
br i1 %24, label %25, label %1
25: ; preds = %1
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %15)
ret double %17
}