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


x86 assembly (clang, -O0):
<Secant>:
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)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe77(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1203 <Secant+0xf3>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe22(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe2e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1203 <Secant+0xf3>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1352 <Secant+0x242>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  0xdbd(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm3
mulsd  -0x10(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm5
movsd  -0x10(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
movsd  0xd79(%rip),%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xd17(%rip),%xmm2
subsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm4
movsd  -0x10(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  0xcd8(%rip),%xmm3
subsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1149 <Secant+0x39>
mov    -0x24(%rbp),%esi
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Secant>:
sub    $0x18,%rsp
movsd  0xee4(%rip),%xmm4
movsd  0xee4(%rip),%xmm7
mov    $0x1,%esi
movsd  0xedf(%rip),%xmm1
movsd  0xedf(%rip),%xmm5
movapd 0xeef(%rip),%xmm2
movsd  0xed7(%rip),%xmm3
movsd  0xed6(%rip),%xmm8
movapd %xmm1,%xmm6
cs nopw 0x0(%rax,%rax,1)
movapd %xmm4,%xmm0
movapd %xmm7,%xmm4
movapd %xmm0,%xmm7
mulsd  %xmm0,%xmm7
mulsd  %xmm0,%xmm7
subsd  %xmm0,%xmm7
addsd  %xmm1,%xmm7
mulsd  %xmm7,%xmm6
mulsd  %xmm5,%xmm0
addsd  %xmm6,%xmm0
subsd  %xmm7,%xmm5
movapd %xmm0,%xmm7
divsd  %xmm5,%xmm7
add    $0x1,%esi
movapd %xmm7,%xmm5
mulsd  %xmm7,%xmm5
movapd %xmm7,%xmm6
xorpd  %xmm2,%xmm6
mulsd  %xmm7,%xmm5
subsd  %xmm7,%xmm5
addsd  %xmm1,%xmm5
ucomisd %xmm5,%xmm3
jbe    1160 <Secant+0x50>
ucomisd %xmm8,%xmm5
jbe    1160 <Secant+0x50>
lea    0xe79(%rip),%rdi
xor    %eax,%eax
movapd %xmm7,(%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 @Secant() {
%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
br label %6
6: ; preds = %0, %30
%7 = load i32, i32* %5
%8 = add nsw i32 %7, 1
store i32 %8, i32* %5
%9 = load double, double* %3
%10 = load double, double* %3
%11 = fmul double %9, %10
%12 = load double, double* %3
%13 = load double, double* %3
%14 = fneg double %13
%15 = call double @llvm.fmuladd.f64(double %11, double %12, double %14)
%16 = fsub double %15, 2.000000e+00
%17 = fcmp olt double %16, 1.000000e-05
br i1 %17, label %18, label %30
18: ; preds = %6
%19 = load double, double* %3
%20 = load double, double* %3
%21 = fmul double %19, %20
%22 = load double, double* %3
%23 = load double, double* %3
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %21, double %22, double %24)
%26 = fsub double %25, 2.000000e+00
%27 = fcmp ogt double %26, -1.000000e-05
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = load double, double* %3
store double %29, double* %1
br label %72
30: ; preds = %18, %6
%31 = load double, double* %2
%32 = load double, double* %3
%33 = load double, double* %3
%34 = fmul double %32, %33
%35 = load double, double* %3
%36 = load double, double* %3
%37 = fneg double %36
%38 = call double @llvm.fmuladd.f64(double %34, double %35, double %37)
%39 = fsub double %38, 2.000000e+00
%40 = load double, double* %3
%41 = load double, double* %2
%42 = load double, double* %2
%43 = fmul double %41, %42
%44 = load double, double* %2
%45 = load double, double* %2
%46 = fneg double %45
%47 = call double @llvm.fmuladd.f64(double %43, double %44, double %46)
%48 = fsub double %47, 2.000000e+00
%49 = fmul double %40, %48
%50 = fneg double %49
%51 = call double @llvm.fmuladd.f64(double %31, double %39, double %50)
%52 = load double, double* %3
%53 = load double, double* %3
%54 = fmul double %52, %53
%55 = load double, double* %3
%56 = load double, double* %3
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double %54, double %55, double %57)
%59 = fsub double %58, 2.000000e+00
%60 = load double, double* %2
%61 = load double, double* %2
%62 = fmul double %60, %61
%63 = load double, double* %2
%64 = load double, double* %2
%65 = fneg double %64
%66 = call double @llvm.fmuladd.f64(double %62, double %63, double %65)
%67 = fsub double %66, 2.000000e+00
%68 = fsub double %59, %67
%69 = fdiv double %51, %68
store double %69, double* %4
%70 = load double, double* %3
store double %70, double* %2
%71 = load double, double* %4
store double %71, double* %3
br label %6
72: ; preds = %28
%73 = load i32, i32* %5
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %73)
%75 = load double, double* %1
ret double %75
}

LLVM IR (-O2):
@.str = [19 x i8] c"It took %d loops.\0A\00"
define double @Secant() {
br label %3
1: ; preds = %3
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %17)
ret double %16
3: ; preds = %0, %3
%4 = phi double [ 4.000000e+00, %0 ], [ %21, %3 ]
%5 = phi double [ -2.000000e+00, %0 ], [ %19, %3 ]
%6 = phi i32 [ 1, %0 ], [ %17, %3 ]
%7 = phi double [ 2.000000e+00, %0 ], [ %16, %3 ]
%8 = phi double [ 1.000000e+00, %0 ], [ %7, %3 ]
%9 = fmul double %8, %8
%10 = fneg double %8
%11 = tail call double @llvm.fmuladd.f64(double %9, double %8, double %10)
%12 = fadd double %11, -2.000000e+00
%13 = fmul double %5, %12
%14 = tail call double @llvm.fmuladd.f64(double %8, double %4, double %13)
%15 = fsub double %4, %12
%16 = fdiv double %14, %15
%17 = add nuw nsw i32 %6, 1
%18 = fmul double %16, %16
%19 = fneg double %16
%20 = tail call double @llvm.fmuladd.f64(double %18, double %16, 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 %1, label %3
}