#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 absoluteValue(double);
double squareRoot(double x, double epsilon) {
  double guess = 1.0;
  while (absoluteValue(guess * guess - x) >= epsilon)
    guess = (x / guess + guess) / 2.0;
  return guess;
}


x86 assembly (clang, -O0):
<squareRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xed6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <absoluteValue@plt>
ucomisd -0x10(%rbp),%xmm0
jb     1192 <squareRoot+0x82>
movsd  -0x8(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    112f <squareRoot+0x1f>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squareRoot>:
sub    $0x48,%rsp
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm1
movsd  0xeea(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movapd %xmm1,0x20(%rsp)
subsd  %xmm1,%xmm0
call   1030 <absoluteValue@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jb     11a1 <squareRoot+0x91>
movaps 0xeb2(%rip),%xmm0
xorps  0x20(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  0xeb0(%rip),%xmm0
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xea2(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  0x30(%rsp),%xmm0
call   1030 <absoluteValue@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
movapd 0x10(%rsp),%xmm0
jae    1160 <squareRoot+0x50>
movaps 0x10(%rsp),%xmm0
add    $0x48,%rsp
ret

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

LLVM IR (-O2):
define double @squareRoot(double %0, double %1) {
%3 = fneg double %0
%4 = fsub double 1.000000e+00, %0
%5 = tail call double @absoluteValue(double %4)
%6 = fcmp ult double %5, %1
br i1 %6, label %15, label %7
7: ; preds = %2, %7
%8 = phi double [ %11, %7 ], [ 1.000000e+00, %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 @absoluteValue(double %12)
%14 = fcmp ult double %13, %1
br i1 %14, label %15, label %7
15: ; preds = %7, %2
%16 = phi double [ 1.000000e+00, %2 ], [ %11, %7 ]
ret double %16
}