#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 */
double error(double, double);
double siguientePaso(double, double);
double newtonRaphson(double x, double r) {
  double xi = 1, xs, tmp;
  xs = siguientePaso(xi, x);
  while (error(xs, xi) > r) {
    xi = xs;
    xs = siguientePaso(xi, x);
  }
  return xs;
}


x86 assembly (clang, -O0):
<newtonRaphson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <siguientePaso@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <error@plt>
ucomisd -0x10(%rbp),%xmm0
jbe    1190 <newtonRaphson+0x70>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <siguientePaso@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1153 <newtonRaphson+0x33>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newtonRaphson>:
sub    $0x28,%rsp
movsd  %xmm1,0x10(%rsp)
movaps %xmm0,%xmm1
movsd  0xecb(%rip),%xmm0
movsd  %xmm1,0x18(%rsp)
call   1030 <siguientePaso@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xeb2(%rip),%xmm1
call   1040 <error@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11aa <newtonRaphson+0x8a>
movsd  0x8(%rsp),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
call   1030 <siguientePaso@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm1
call   1040 <error@plt>
movsd  0x20(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm2,%xmm0
ja     1170 <newtonRaphson+0x50>
jmp    11b0 <newtonRaphson+0x90>
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @newtonRaphson(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 1.000000e+00, double* %5
%8 = load double, double* %5
%9 = load double, double* %3
%10 = call double @siguientePaso(double %8, double %9)
store double %10, double* %6
br label %11
11: ; preds = %17, %2
%12 = load double, double* %6
%13 = load double, double* %5
%14 = call double @error(double %12, double %13)
%15 = load double, double* %4
%16 = fcmp ogt double %14, %15
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load double, double* %6
store double %18, double* %5
%19 = load double, double* %5
%20 = load double, double* %3
%21 = call double @siguientePaso(double %19, double %20)
store double %21, double* %6
br label %11
22: ; preds = %11
%23 = load double, double* %6
ret double %23
}

LLVM IR (-O2):
define double @newtonRaphson(double %0, double %1) {
%3 = tail call double @siguientePaso(double 1.000000e+00, double %0)
%4 = tail call double @error(double %3, double 1.000000e+00)
%5 = fcmp ogt double %4, %1
br i1 %5, label %6, label %11
6: ; preds = %2, %6
%7 = phi double [ %8, %6 ], [ %3, %2 ]
%8 = tail call double @siguientePaso(double %7, double %0)
%9 = tail call double @error(double %8, double %7)
%10 = fcmp ogt double %9, %1
br i1 %10, label %6, label %11
11: ; preds = %6, %2
%12 = phi double [ %3, %2 ], [ %8, %6 ]
ret double %12
}