double findroot(left, right, tolerance, f, df)
double left, right, tolerance;
double (*f)(), (*df)();
{
  double newx = left;
  while (((((*f)(newx)) < 0) ? -((*f)(newx)) : ((*f)(newx))) > tolerance) {
    newx = NewtonRaphson(f, df, newx);
    if (newx < left || newx > right)
      newx = RegulaFalsi(f, left, right);
    if ((*f)(newx) * (*f)(left) <= 0.0)
      right = newx;
    else
      left = newx;
  }
  return (newx);
}


x86 assembly (clang, -O0):
<findroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1194 <findroot+0x74>
mov    -0x20(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11a6 <findroot+0x86>
mov    -0x20(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1268 <findroot+0x148>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1030 <NewtonRaphson@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11f7 <findroot+0xd7>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1215 <findroot+0xf5>
mov    -0x20(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    $0x2,%al
call   1040 <RegulaFalsi@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rcx
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1259 <findroot+0x139>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1263 <findroot+0x143>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1149 <findroot+0x29>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findroot>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    $0x1,%al
call   *%rdi
movaps %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
mov    $0x1,%al
call   *%rbx
movapd 0xea8(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm3
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
ucomisd 0x28(%rsp),%xmm3
jbe    129c <findroot+0x17c>
movapd 0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
jmp    1213 <findroot+0xf3>
cs nopw 0x0(%rax,%rax,1)
nop
cmpnlesd %xmm0,%xmm2
movapd %xmm2,%xmm1
movapd 0x10(%rsp),%xmm0
andpd  %xmm0,%xmm1
andnpd (%rsp),%xmm2
orpd   %xmm1,%xmm2
movapd %xmm2,(%rsp)
mov    $0x1,%al
call   *%rbx
movapd %xmm0,0x30(%rsp)
movapd 0x10(%rsp),%xmm0
mov    $0x1,%al
call   *%rbx
movapd 0x30(%rsp),%xmm2
cmpltsd 0xe2c(%rip),%xmm2
movapd %xmm2,%xmm1
andnpd %xmm0,%xmm1
xorpd  0xe0c(%rip),%xmm0
andpd  %xmm2,%xmm0
orpd   %xmm1,%xmm0
ucomisd 0x28(%rsp),%xmm0
movapd (%rsp),%xmm1
movapd 0x10(%rsp),%xmm0
jbe    12a2 <findroot+0x182>
movapd %xmm1,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1030 <NewtonRaphson@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd (%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     123f <findroot+0x11f>
ucomisd 0x20(%rsp),%xmm0
jbe    125a <findroot+0x13a>
mov    %rbx,%rdi
movaps (%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mov    $0x2,%al
call   1040 <RegulaFalsi@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,0x10(%rsp)
mov    $0x1,%al
call   *%rbx
movsd  %xmm0,0x30(%rsp)
movapd (%rsp),%xmm0
mov    $0x1,%al
call   *%rbx
movapd %xmm0,%xmm2
mulsd  0x30(%rsp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jb     11a0 <findroot+0x80>
movapd 0x10(%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
jmp    11a0 <findroot+0x80>
movapd 0x10(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @findroot(double %0, double %1, double %2, double (...)* %3, double (...)* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double (...)*
%10 = alloca double (...)*
%11 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double (...)* %3, double (...)** %9
store double (...)* %4, double (...)** %10
%12 = load double, double* %6
store double %12, double* %11
br label %13
13: ; preds = %68, %5
%14 = load double (...)*, double (...)** %9
%15 = load double, double* %11
%16 = bitcast double (...)* %14 to double (double, ...)*
%17 = call double (double, ...) %16(double %15)
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load double (...)*, double (...)** %9
%21 = load double, double* %11
%22 = bitcast double (...)* %20 to double (double, ...)*
%23 = call double (double, ...) %22(double %21)
%24 = fneg double %23
br label %30
25: ; preds = %13
%26 = load double (...)*, double (...)** %9
%27 = load double, double* %11
%28 = bitcast double (...)* %26 to double (double, ...)*
%29 = call double (double, ...) %28(double %27)
br label %30
30: ; preds = %25, %19
%31 = phi double [ %24, %19 ], [ %29, %25 ]
%32 = load double, double* %8
%33 = fcmp ogt double %31, %32
br i1 %33, label %34, label %69
34: ; preds = %30
%35 = load double (...)*, double (...)** %9
%36 = load double (...)*, double (...)** %10
%37 = load double, double* %11
%38 = call i32 (double (...)*, double (...)*, double, ...) bitcast (i32 (...)* @NewtonRaphson to i32 (double (...)*, double (...)*, double, ...)*)(double (...)* %35, double (...)* %36, double %37)
%39 = sitofp i32 %38 to double
store double %39, double* %11
%40 = load double, double* %11
%41 = load double, double* %6
%42 = fcmp olt double %40, %41
br i1 %42, label %47, label %43
43: ; preds = %34
%44 = load double, double* %11
%45 = load double, double* %7
%46 = fcmp ogt double %44, %45
br i1 %46, label %47, label %53
47: ; preds = %43, %34
%48 = load double (...)*, double (...)** %9
%49 = load double, double* %6
%50 = load double, double* %7
%51 = call i32 (double (...)*, double, double, ...) bitcast (i32 (...)* @RegulaFalsi to i32 (double (...)*, double, double, ...)*)(double (...)* %48, double %49, double %50)
%52 = sitofp i32 %51 to double
store double %52, double* %11
br label %53
53: ; preds = %47, %43
%54 = load double (...)*, double (...)** %9
%55 = load double, double* %11
%56 = bitcast double (...)* %54 to double (double, ...)*
%57 = call double (double, ...) %56(double %55)
%58 = load double (...)*, double (...)** %9
%59 = load double, double* %6
%60 = bitcast double (...)* %58 to double (double, ...)*
%61 = call double (double, ...) %60(double %59)
%62 = fmul double %57, %61
%63 = fcmp ole double %62, 0.000000e+00
br i1 %63, label %64, label %66
64: ; preds = %53
%65 = load double, double* %11
store double %65, double* %7
br label %68
66: ; preds = %53
%67 = load double, double* %11
store double %67, double* %6
br label %68
68: ; preds = %66, %64
br label %13
69: ; preds = %30
%70 = load double, double* %11
ret double %70
}

LLVM IR (-O2):
define double @findroot(double %0, double %1, double %2, double (...)* %3, double (...)* %4) {
%6 = bitcast double (...)* %3 to double (double, ...)*
%7 = tail call double (double, ...) %6(double %0)
%8 = fcmp olt double %7, 0.000000e+00
%9 = tail call double (double, ...) %6(double %0)
%10 = fneg double %9
%11 = select i1 %8, double %10, double %9
%12 = fcmp ogt double %11, %2
br i1 %12, label %13, label %39
13: ; preds = %5, %25
%14 = phi double [ %26, %25 ], [ %0, %5 ]
%15 = phi double [ %32, %25 ], [ %0, %5 ]
%16 = phi double [ %31, %25 ], [ %1, %5 ]
%17 = tail call i32 (double (...)*, double (...)*, double, ...) bitcast (i32 (...)* @NewtonRaphson to i32 (double (...)*, double (...)*, double, ...)*)(double (...)* %3, double (...)* %4, double %14)
%18 = sitofp i32 %17 to double
%19 = fcmp ogt double %15, %18
%20 = fcmp olt double %16, %18
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = tail call i32 (double (...)*, double, double, ...) bitcast (i32 (...)* @RegulaFalsi to i32 (double (...)*, double, double, ...)*)(double (...)* %3, double %15, double %16)
%24 = sitofp i32 %23 to double
br label %25
25: ; preds = %13, %22
%26 = phi double [ %24, %22 ], [ %18, %13 ]
%27 = tail call double (double, ...) %6(double %26)
%28 = tail call double (double, ...) %6(double %15)
%29 = fmul double %27, %28
%30 = fcmp ugt double %29, 0.000000e+00
%31 = select i1 %30, double %16, double %26
%32 = select i1 %30, double %26, double %15
%33 = tail call double (double, ...) %6(double %26)
%34 = fcmp olt double %33, 0.000000e+00
%35 = tail call double (double, ...) %6(double %26)
%36 = fneg double %35
%37 = select i1 %34, double %36, double %35
%38 = fcmp ogt double %37, %2
br i1 %38, label %13, label %39
39: ; preds = %25, %5
%40 = phi double [ %0, %5 ], [ %26, %25 ]
ret double %40
}