#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 */
long double LDBL_EPSILON;
long double NAN;
long double fabsl(long double);
long double sqrtl(long double x) {
  long double y0, y1, e;
  if (x < 0.0) {
    return NAN;
  }
  y0 = x;
  y1 = 0.0;
  e = 1.0;
  while (fabsl(y0 - y1) > e) {
    y0 = y1;
    y1 = y1 - (y1 * y1 - x) / (2.0 * y1);
    e = LDBL_EPSILON * y1;
  }
  return y1;
}


x86 assembly (clang, -O0):
<sqrtl>:
push   %rbp
mov    %rsp,%rbp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    112f <sqrtl+0x2f>
jmp    111e <sqrtl+0x1e>
mov    0x2ed3(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
jmp    1196 <sqrtl+0x96>
fldt   -0x20(%rbp)
fstpt  -0x30(%rbp)
fldz
fstpt  -0x40(%rbp)
fld1
fstpt  -0x50(%rbp)
fldt   -0x30(%rbp)
fldt   -0x40(%rbp)
fsubrp %st,%st(1)
fabs
fldt   -0x50(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1190 <sqrtl+0x90>
jmp    115d <sqrtl+0x5d>
fldt   -0x40(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x40(%rbp)
fldt   -0x20(%rbp)
fld    %st(1)
fmul   %st(2),%st
fsubp  %st,%st(1)
fld    %st(1)
fadd   %st(2),%st
fdivrp %st,%st(1)
fsubrp %st,%st(1)
fstpt  -0x40(%rbp)
mov    0x2e4f(%rip),%rax
fldt   (%rax)
fldt   -0x40(%rbp)
fmulp  %st,%st(1)
fstpt  -0x50(%rbp)
jmp    113f <sqrtl+0x3f>
fldt   -0x40(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqrtl>:
fldt   0x8(%rsp)
fldz
fucomi %st(1),%st
jbe    111f <sqrtl+0x1f>
fstp   %st(0)
fstp   %st(0)
mov    0x2ee3(%rip),%rax
fldt   (%rax)
fldz
fldz
fldz
jmp    1182 <sqrtl+0x82>
fld    %st(1)
fabs
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
fldz
fldz
fxch   %st(2)
fxch   %st(3)
fxch   %st(2)
jbe    1182 <sqrtl+0x82>
fstp   %st(3)
fstp   %st(0)
fstp   %st(1)
fchs
mov    0x2e8a(%rip),%rax
fldt   (%rax)
fldz
fldz
fxch   %st(3)
fxch   %st(2)
fxch   %st(1)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
fstp   %st(3)
fld    %st(2)
fmul   %st(3),%st
fadd   %st(2),%st
fld    %st(3)
fadd   %st(4),%st
fdivrp %st,%st(1)
fsubr  %st(3),%st
fld    %st(0)
fmul   %st(2),%st
fxch   %st(4)
fsub   %st(1),%st
fabs
fucomip %st(4),%st
fstp   %st(3)
fld    %st(2)
ja     1160 <sqrtl+0x60>
fstp   %st(2)
fstp   %st(0)
fstp   %st(0)
ret

LLVM IR (-O0):
@NAN = global x86_fp80 0xK00000000000000000000
@LDBL_EPSILON = global x86_fp80 0xK00000000000000000000
define x86_fp80 @sqrtl(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %3
%7 = load x86_fp80, x86_fp80* %3
%8 = fcmp olt x86_fp80 %7, 0xK00000000000000000000
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load x86_fp80, x86_fp80* @NAN
store x86_fp80 %10, x86_fp80* %2
br label %37
11: ; preds = %1
%12 = load x86_fp80, x86_fp80* %3
store x86_fp80 %12, x86_fp80* %4
store x86_fp80 0xK00000000000000000000, x86_fp80* %5
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %6
br label %13
13: ; preds = %20, %11
%14 = load x86_fp80, x86_fp80* %4
%15 = load x86_fp80, x86_fp80* %5
%16 = fsub x86_fp80 %14, %15
%17 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %16)
%18 = load x86_fp80, x86_fp80* %6
%19 = fcmp ogt x86_fp80 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %13
%21 = load x86_fp80, x86_fp80* %5
store x86_fp80 %21, x86_fp80* %4
%22 = load x86_fp80, x86_fp80* %5
%23 = load x86_fp80, x86_fp80* %5
%24 = load x86_fp80, x86_fp80* %5
%25 = load x86_fp80, x86_fp80* %3
%26 = fneg x86_fp80 %25
%27 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %23, x86_fp80 %24, x86_fp80 %26)
%28 = load x86_fp80, x86_fp80* %5
%29 = fmul x86_fp80 0xK40008000000000000000, %28
%30 = fdiv x86_fp80 %27, %29
%31 = fsub x86_fp80 %22, %30
store x86_fp80 %31, x86_fp80* %5
%32 = load x86_fp80, x86_fp80* @LDBL_EPSILON
%33 = load x86_fp80, x86_fp80* %5
%34 = fmul x86_fp80 %32, %33
store x86_fp80 %34, x86_fp80* %6
br label %13
35: ; preds = %13
%36 = load x86_fp80, x86_fp80* %5
store x86_fp80 %36, x86_fp80* %2
br label %37
37: ; preds = %35, %9
%38 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %38
}

LLVM IR (-O2):
@NAN = global x86_fp80 0xK00000000000000000000
@LDBL_EPSILON = global x86_fp80 0xK00000000000000000000
define x86_fp80 @sqrtl(x86_fp80 %0) {
%2 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %0)
%5 = fcmp ogt x86_fp80 %4, 0xK3FFF8000000000000000
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = fneg x86_fp80 %0
%8 = load x86_fp80, x86_fp80* @LDBL_EPSILON
br label %11
9: ; preds = %1
%10 = load x86_fp80, x86_fp80* @NAN
br label %21
11: ; preds = %6, %11
%12 = phi x86_fp80 [ 0xK00000000000000000000, %6 ], [ %16, %11 ]
%13 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %12, x86_fp80 %7)
%14 = fmul x86_fp80 %12, 0xK40008000000000000000
%15 = fdiv x86_fp80 %13, %14
%16 = fsub x86_fp80 %12, %15
%17 = fmul x86_fp80 %16, %8
%18 = fsub x86_fp80 %12, %16
%19 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %18)
%20 = fcmp ogt x86_fp80 %19, %17
br i1 %20, label %11, label %21
21: ; preds = %11, %3, %9
%22 = phi x86_fp80 [ %10, %9 ], [ 0xK00000000000000000000, %3 ], [ %16, %11 ]
ret x86_fp80 %22
}