#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ aitkenroot(double *, double (*)(double), double, int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  double x, eps;
  double *x0 = &x;
  double f(double);
  int max;
  *x0 = 1.0;
  eps = 0.00001;
  max = 60;
  printf("  x(k)         x(k+1)        dis\n");
  if (aitkenroot(x0, f, eps, max))
    printf("\n%1.5f\n\n", *x0);
  else
    printf("failed!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x3c,-0x1c(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%edx
mov    0x2e6b(%rip),%rsi
call   1040 <aitkenroot@plt>
cmp    $0x0,%rax
je     119f <main+0x7f>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe9f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11ad <main+0x8d>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rsp)
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e8e(%rip),%rsi
mov    %rsp,%rdi
movsd  0xea3(%rip),%xmm0
mov    $0x3c,%edx
call   1050 <aitkenroot@plt>
test   %rax,%rax
je     1181 <main+0x51>
movsd  (%rsp),%xmm0
lea    0xe90(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
pop    %rax
ret
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [34 x i8] c" x(k) x(k+1) dis\0A\00"
@.str.1 = [9 x i8] c"\0A%1.5f\0A\0A\00"
@.str.2 = [9 x i8] c"failed!\0A\00"
define void @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double*
%4 = alloca i32
store double* %1, double** %3
%5 = load double*, double** %3
store double 1.000000e+00, double* %5
store double 1.000000e-05, double* %2
store i32 60, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = load double*, double** %3
%8 = load double, double* %2
%9 = load i32, i32* %4
%10 = call i64 @aitkenroot(double* %7, double (double)* @f, double %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load double*, double** %3
%14 = load double, double* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %14)
br label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
ret void
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"\0A%1.5f\0A\0A\00"
@str = [33 x i8] c" x(k) x(k+1) dis\00"
@str.3 = [8 x i8] c"failed!\00"
define void @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 1.000000e+00, double* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = call i64 @aitkenroot(double* %1, double (double)* @f, double 1.000000e-05, i32 60)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = load double, double* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %7)
br label %11
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.3, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
ret void
}