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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x3c,-0x24(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x24(%rbp),%edx
mov    0x2e5e(%rip),%rsi
call   1040 <interroot@plt>
cmp    $0x0,%rax
je     11ac <main+0x8c>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe92(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11ba <main+0x9a>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rsp)
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e8e(%rip),%rsi
mov    %rsp,%rdi
movsd  0xea3(%rip),%xmm1
xorps  %xmm0,%xmm0
mov    $0x3c,%edx
call   1050 <interroot@plt>
test   %rax,%rax
je     1184 <main+0x54>
movsd  (%rsp),%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
pop    %rax
ret
lea    0xea6(%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 = [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 double
%4 = alloca double*
%5 = alloca i32
store double* %1, double** %4
%6 = load double*, double** %4
store double 1.000000e+00, double* %6
store double 0.000000e+00, double* %3
store double 1.000000e-05, double* %2
store i32 60, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = load double*, double** %4
%9 = load double, double* %3
%10 = load double, double* %2
%11 = load i32, i32* %5
%12 = call i64 @interroot(double* %8, double %9, double (double)* @f, double %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load double*, double** %4
%16 = load double, double* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %20
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
ret void
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"\0A%1.7f\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 @interroot(double* %1, double 0.000000e+00, 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 ([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
}