int newdonroot(x0, f, fd, eps, max)
double *x0, (*f)(), (*fd)(), eps;
int max;
{
  double x, dis;
  double y0;
  double yd0;
  int num = 0;
  do {
    y0 = f(*x0);
    yd0 = fd(*x0);
    x = *x0 - y0 / yd0;
    num++;
    dis = fabs(x - *x0);
    if (dis < fabs(y0))
      dis = fabs(y0);
    printf("%1.7f    %1.7f    %1.7f\n", *x0, x, dis);
    *x0 = x;
  } while (dis > eps && num < max);
  if (num == max)
    return (0);
  else
    return (1);
}


x86 assembly (clang, -O0):
<newdonroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x48(%rbp),%xmm1
divsd  -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movaps 0xe6b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movaps 0xe51(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11d2 <newdonroot+0xc2>
movsd  -0x48(%rbp),%xmm0
movaps 0xe37(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
lea    0xe25(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x28(%rbp),%xmm0
mov    %al,-0x55(%rbp)
jbe    1220 <newdonroot+0x110>
mov    -0x54(%rbp),%eax
cmp    -0x2c(%rbp),%eax
setl   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    1133 <newdonroot+0x23>
mov    -0x54(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1243 <newdonroot+0x133>
movl   $0x0,-0x4(%rbp)
jmp    124a <newdonroot+0x13a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newdonroot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r14d
movsd  %xmm0,0x18(%rsp)
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
mov    $0x1,%ebp
lea    0xed0(%rip),%r12
mov    $0x1,%al
call   *%r13
movaps %xmm0,(%rsp)
movsd  (%rbx),%xmm0
mov    $0x1,%al
call   *%r15
movsd  (%rbx),%xmm1
movapd (%rsp),%xmm3
movapd %xmm3,%xmm2
divsd  %xmm0,%xmm2
movapd %xmm1,%xmm4
subsd  %xmm2,%xmm4
movapd %xmm4,%xmm0
movsd  %xmm4,0x20(%rsp)
subsd  %xmm1,%xmm0
movapd 0xe7f(%rip),%xmm2
andpd  %xmm2,%xmm0
andpd  %xmm2,%xmm3
maxsd  %xmm0,%xmm3
movapd %xmm3,(%rsp)
mov    %r12,%rdi
movapd %xmm1,%xmm0
movapd %xmm4,%xmm1
movapd %xmm3,%xmm2
mov    $0x3,%al
call   1030 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rbx)
lea    0x1(%rbp),%ecx
movapd (%rsp),%xmm1
ucomisd 0x18(%rsp),%xmm1
jbe    11cd <newdonroot+0xbd>
cmp    %r14d,%ebp
mov    %ecx,%ebp
jl     1140 <newdonroot+0x30>
sub    %r14d,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
setne  %al
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%1.7f %1.7f %1.7f\0A\00"
define i32 @newdonroot(double* %0, double (...)* %1, double (...)* %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double (...)*
%9 = alloca double (...)*
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
store double* %0, double** %7
store double (...)* %1, double (...)** %8
store double (...)* %2, double (...)** %9
store double %3, double* %10
store i32 %4, i32* %11
store i32 0, i32* %16
br label %17
17: ; preds = %64, %5
%18 = load double (...)*, double (...)** %8
%19 = load double*, double** %7
%20 = load double, double* %19
%21 = bitcast double (...)* %18 to double (double, ...)*
%22 = call double (double, ...) %21(double %20)
store double %22, double* %14
%23 = load double (...)*, double (...)** %9
%24 = load double*, double** %7
%25 = load double, double* %24
%26 = bitcast double (...)* %23 to double (double, ...)*
%27 = call double (double, ...) %26(double %25)
store double %27, double* %15
%28 = load double*, double** %7
%29 = load double, double* %28
%30 = load double, double* %14
%31 = load double, double* %15
%32 = fdiv double %30, %31
%33 = fsub double %29, %32
store double %33, double* %12
%34 = load i32, i32* %16
%35 = add nsw i32 %34, 1
store i32 %35, i32* %16
%36 = load double, double* %12
%37 = load double*, double** %7
%38 = load double, double* %37
%39 = fsub double %36, %38
%40 = call double @llvm.fabs.f64(double %39)
store double %40, double* %13
%41 = load double, double* %13
%42 = load double, double* %14
%43 = call double @llvm.fabs.f64(double %42)
%44 = fcmp olt double %41, %43
br i1 %44, label %45, label %48
45: ; preds = %17
%46 = load double, double* %14
%47 = call double @llvm.fabs.f64(double %46)
store double %47, double* %13
br label %48
48: ; preds = %45, %17
%49 = load double*, double** %7
%50 = load double, double* %49
%51 = load double, double* %12
%52 = load double, double* %13
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %50, double %51, double %52)
%54 = load double, double* %12
%55 = load double*, double** %7
store double %54, double* %55
br label %56
56: ; preds = %48
%57 = load double, double* %13
%58 = load double, double* %10
%59 = fcmp ogt double %57, %58
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i32, i32* %16
%62 = load i32, i32* %11
%63 = icmp slt i32 %61, %62
br label %64
64: ; preds = %60, %56
%65 = phi i1 [ false, %56 ], [ %63, %60 ]
br i1 %65, label %17, label %66
66: ; preds = %64
%67 = load i32, i32* %16
%68 = load i32, i32* %11
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %71
70: ; preds = %66
store i32 0, i32* %6
br label %72
71: ; preds = %66
store i32 1, i32* %6
br label %72
72: ; preds = %71, %70
%73 = load i32, i32* %6
ret i32 %73
}

LLVM IR (-O2):
@.str = [25 x i8] c"%1.7f %1.7f %1.7f\0A\00"
define i32 @newdonroot(double* nocapture %0, double (...)* nocapture %1, double (...)* nocapture %2, double %3, i32 %4) {
%6 = bitcast double (...)* %1 to double (double, ...)*
%7 = bitcast double (...)* %2 to double (double, ...)*
%8 = load double, double* %0
br label %9
9: ; preds = %9, %5
%10 = phi double [ %8, %5 ], [ %17, %9 ]
%11 = phi i32 [ 0, %5 ], [ %18, %9 ]
%12 = tail call double (double, ...) %6(double %10)
%13 = load double, double* %0
%14 = tail call double (double, ...) %7(double %13)
%15 = load double, double* %0
%16 = fdiv double %12, %14
%17 = fsub double %15, %16
%18 = add nuw nsw i32 %11, 1
%19 = fsub double %17, %15
%20 = tail call double @llvm.fabs.f64(double %19)
%21 = tail call double @llvm.fabs.f64(double %12)
%22 = fcmp olt double %20, %21
%23 = select i1 %22, double %21, double %20
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %15, double %17, double %23)
store double %17, double* %0
%25 = fcmp ogt double %23, %3
%26 = icmp slt i32 %18, %4
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %9, label %28
28: ; preds = %9
%29 = icmp ne i32 %18, %4
%30 = zext i1 %29 to i32
ret i32 %30
}