#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 const abs(double);
double newton(double n, double guess) {
  const double epsilon = 0.00001;
  if (abs(guess * guess - n) < epsilon)
    return guess;
  else
    return newton(n, (n / guess + guess) / 2);
}


x86 assembly (clang, -O0):
<newton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <abs@plt>
movaps %xmm0,%xmm1
movsd  0xe83(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1196 <newton+0x76>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c0 <newton+0xa0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x18(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  0xe56(%rip),%xmm2
divsd  %xmm2,%xmm1
call   1040 <newton@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newton>:
sub    $0x38,%rsp
movapd %xmm0,%xmm2
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm2,0x10(%rsp)
subsd  %xmm2,%xmm0
call   1030 <abs@plt>
movsd  0xed4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    114c <newton+0x3c>
movsd  (%rsp),%xmm0
add    $0x38,%rsp
ret
movapd 0xeac(%rip),%xmm0
xorpd  0x10(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movapd 0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe92(%rip),%xmm0
movapd %xmm0,(%rsp)
mulsd  %xmm0,%xmm0
addsd  0x20(%rsp),%xmm0
call   1030 <abs@plt>
movsd  0xe6e(%rip),%xmm1
ucomisd %xmm0,%xmm1
movapd (%rsp),%xmm0
movapd %xmm0,%xmm1
jbe    1170 <newton+0x60>
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @newton(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
store double 1.000000e-05, double* %6
%7 = load double, double* %5
%8 = load double, double* %5
%9 = load double, double* %4
%10 = fneg double %9
%11 = call double @llvm.fmuladd.f64(double %7, double %8, double %10)
%12 = call double @abs(double %11)
%13 = fcmp olt double %12, 1.000000e-05
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load double, double* %5
store double %15, double* %3
br label %25
16: ; preds = %2
%17 = load double, double* %4
%18 = load double, double* %4
%19 = load double, double* %5
%20 = fdiv double %18, %19
%21 = load double, double* %5
%22 = fadd double %20, %21
%23 = fdiv double %22, 2.000000e+00
%24 = call double @newton(double %17, double %23)
store double %24, double* %3
br label %25
25: ; preds = %16, %14
%26 = load double, double* %3
ret double %26
}

LLVM IR (-O2):
define double @newton(double %0, double %1) {
%3 = fneg double %0
%4 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %3)
%5 = tail call double @abs(double %4)
%6 = fcmp olt double %5, 1.000000e-05
br i1 %6, label %15, label %7
7: ; preds = %2, %7
%8 = phi double [ %11, %7 ], [ %1, %2 ]
%9 = fdiv double %0, %8
%10 = fadd double %8, %9
%11 = fmul double %10, 5.000000e-01
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %3)
%13 = tail call double @abs(double %12)
%14 = fcmp olt double %13, 1.000000e-05
br i1 %14, label %15, label %7
15: ; preds = %7, %2
%16 = phi double [ %1, %2 ], [ %11, %7 ]
ret double %16
}