double NewtonRaphson(f, df, x) double (*f)(), (*df)(), x;
{
  double d = (*df)(x);
  if (d != 0.0)
    return (x - ((*f)(x) / d));
  return (x - 1.0);
}


x86 assembly (clang, -O0):
<NewtonRaphson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1144 <NewtonRaphson+0x44>
jp     1144 <NewtonRaphson+0x44>
jmp    1176 <NewtonRaphson+0x76>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118c <NewtonRaphson+0x8c>
movsd  -0x20(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NewtonRaphson>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  %xmm0,(%rsp)
mov    $0x1,%al
call   *%rsi
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1121 <NewtonRaphson+0x21>
jnp    1145 <NewtonRaphson+0x45>
movsd  (%rsp),%xmm0
mov    $0x1,%al
movsd  %xmm1,0x8(%rsp)
call   *%rbx
divsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    1152 <NewtonRaphson+0x52>
movsd  (%rsp),%xmm0
addsd  0xeae(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @NewtonRaphson(double (...)* %0, double (...)* %1, double %2) {
%4 = alloca double
%5 = alloca double (...)*
%6 = alloca double (...)*
%7 = alloca double
%8 = alloca double
store double (...)* %0, double (...)** %5
store double (...)* %1, double (...)** %6
store double %2, double* %7
%9 = load double (...)*, double (...)** %6
%10 = load double, double* %7
%11 = bitcast double (...)* %9 to double (double, ...)*
%12 = call double (double, ...) %11(double %10)
store double %12, double* %8
%13 = load double, double* %8
%14 = fcmp une double %13, 0.000000e+00
br i1 %14, label %15, label %24
15: ; preds = %3
%16 = load double, double* %7
%17 = load double (...)*, double (...)** %5
%18 = load double, double* %7
%19 = bitcast double (...)* %17 to double (double, ...)*
%20 = call double (double, ...) %19(double %18)
%21 = load double, double* %8
%22 = fdiv double %20, %21
%23 = fsub double %16, %22
store double %23, double* %4
br label %27
24: ; preds = %3
%25 = load double, double* %7
%26 = fsub double %25, 1.000000e+00
store double %26, double* %4
br label %27
27: ; preds = %24, %15
%28 = load double, double* %4
ret double %28
}

LLVM IR (-O2):
define double @NewtonRaphson(double (...)* nocapture %0, double (...)* nocapture %1, double %2) {
%4 = bitcast double (...)* %1 to double (double, ...)*
%5 = tail call double (double, ...) %4(double %2)
%6 = fcmp une double %5, 0.000000e+00
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = bitcast double (...)* %0 to double (double, ...)*
%9 = tail call double (double, ...) %8(double %2)
%10 = fdiv double %9, %5
%11 = fsub double %2, %10
br label %14
12: ; preds = %3
%13 = fadd double %2, -1.000000e+00
br label %14
14: ; preds = %12, %7
%15 = phi double [ %11, %7 ], [ %13, %12 ]
ret double %15
}