#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__ newdonroot(double *, double (*)(double), double (*)(double), double,
                      int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  double x0;
  double f(double);
  double fd(double);
  double eps;
  int max;
  x0 = 0.0;
  eps = 0.00001;
  max = 60;
  printf("  x(k)         x(k+1)        dis\n\n");
  if (newdonroot(&x0, f, fd, eps, max))
    printf("\n%1.7f\n", x0);
  else
    printf("failed!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x3c,-0x14(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%ecx
lea    -0x8(%rbp),%rdi
mov    0x2e7b(%rip),%rsi
mov    0x2e6c(%rip),%rdx
call   1040 <newdonroot@plt>
cmp    $0x0,%rax
je     1193 <main+0x73>
movsd  -0x8(%rbp),%xmm0
lea    0xea4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11a1 <main+0x81>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e94(%rip),%rsi
mov    0x2e85(%rip),%rdx
mov    %rsp,%rdi
movsd  0xea2(%rip),%xmm0
mov    $0x3c,%ecx
call   1050 <newdonroot@plt>
test   %rax,%rax
je     1182 <main+0x52>
movsd  (%rsp),%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
pop    %rax
ret
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

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

LLVM IR (-O2):
@.str.1 = [8 x i8] c"\0A%1.7f\0A\00"
@str = [34 x i8] c" x(k) x(k+1) dis\0A\00"
@str.3 = [8 x i8] c"failed!\00"
define void @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = call i64 @newdonroot(double* %1, double (double)* @f, double (double)* @fd, 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 ([8 x i8], [8 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
}