int aitkenroot(x0, f, eps, max)
double *x0, (*f)(), eps;
int max;
{
  double x, x1, x2, dis;
  int num = 0;
  do {
    x1 = f(*x0);
    x2 = f(x1);
    dis = fabs(x2 - x1);
    x = x2 - dis * dis / (x2 - 2 * x1 + *x0);
    num++;
    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):
<aitkenroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rcx
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xe99(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm2
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
lea    0xe48(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x20(%rbp),%xmm0
mov    %al,-0x4d(%rbp)
jbe    11fd <aitkenroot+0xed>
mov    -0x4c(%rbp),%eax
cmp    -0x24(%rbp),%eax
setl   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    112f <aitkenroot+0x1f>
mov    -0x4c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1220 <aitkenroot+0x110>
movl   $0x0,-0x4(%rbp)
jmp    1227 <aitkenroot+0x117>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aitkenroot>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edx,%r14d
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r12
mov    %rdi,%rbp
movsd  (%rdi),%xmm0
mov    $0x1,%ebx
lea    0xed5(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    $0x1,%al
call   *%r12
movsd  %xmm0,(%rsp)
mov    $0x1,%al
call   *%r12
movapd %xmm0,%xmm3
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm4
subsd  %xmm4,%xmm1
movapd %xmm1,%xmm0
andpd  0xe94(%rip),%xmm0
movapd %xmm0,%xmm2
movapd %xmm0,0x10(%rsp)
mulsd  %xmm1,%xmm1
addsd  %xmm4,%xmm4
movapd %xmm4,%xmm0
movapd %xmm3,%xmm4
subsd  %xmm0,%xmm4
movsd  0x0(%rbp),%xmm0
addsd  %xmm0,%xmm4
divsd  %xmm4,%xmm1
subsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
mov    %r15,%rdi
movapd %xmm3,%xmm1
mov    $0x3,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%rbp)
lea    0x1(%rbx),%ecx
movapd 0x10(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
jbe    11d4 <aitkenroot+0xc4>
cmp    %r14d,%ebx
mov    %ecx,%ebx
jl     1140 <aitkenroot+0x30>
sub    %r14d,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
setne  %al
add    $0x20,%rsp
pop    %rbx
pop    %r12
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 @aitkenroot(double* %0, double (...)* %1, double %2, i32 %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double (...)*
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double* %0, double** %6
store double (...)* %1, double (...)** %7
store double %2, double* %8
store i32 %3, i32* %9
store i32 0, i32* %14
br label %15
15: ; preds = %58, %4
%16 = load double (...)*, double (...)** %7
%17 = load double*, double** %6
%18 = load double, double* %17
%19 = bitcast double (...)* %16 to double (double, ...)*
%20 = call double (double, ...) %19(double %18)
store double %20, double* %11
%21 = load double (...)*, double (...)** %7
%22 = load double, double* %11
%23 = bitcast double (...)* %21 to double (double, ...)*
%24 = call double (double, ...) %23(double %22)
store double %24, double* %12
%25 = load double, double* %12
%26 = load double, double* %11
%27 = fsub double %25, %26
%28 = call double @llvm.fabs.f64(double %27)
store double %28, double* %13
%29 = load double, double* %12
%30 = load double, double* %13
%31 = load double, double* %13
%32 = fmul double %30, %31
%33 = load double, double* %12
%34 = load double, double* %11
%35 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %34, double %33)
%36 = load double*, double** %6
%37 = load double, double* %36
%38 = fadd double %35, %37
%39 = fdiv double %32, %38
%40 = fsub double %29, %39
store double %40, double* %10
%41 = load i32, i32* %14
%42 = add nsw i32 %41, 1
store i32 %42, i32* %14
%43 = load double*, double** %6
%44 = load double, double* %43
%45 = load double, double* %10
%46 = load double, double* %13
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %44, double %45, double %46)
%48 = load double, double* %10
%49 = load double*, double** %6
store double %48, double* %49
br label %50
50: ; preds = %15
%51 = load double, double* %13
%52 = load double, double* %8
%53 = fcmp ogt double %51, %52
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i32, i32* %14
%56 = load i32, i32* %9
%57 = icmp slt i32 %55, %56
br label %58
58: ; preds = %54, %50
%59 = phi i1 [ false, %50 ], [ %57, %54 ]
br i1 %59, label %15, label %60
60: ; preds = %58
%61 = load i32, i32* %14
%62 = load i32, i32* %9
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 0, i32* %5
br label %66
65: ; preds = %60
store i32 1, i32* %5
br label %66
66: ; preds = %65, %64
%67 = load i32, i32* %5
ret i32 %67
}

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