#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 */
float FLT_EPSILON;
float NAN;
float fabsf(float);
float sqrtf(float x) {
  float y0, y1, e;
  if (x < 0.0) {
    return NAN;
  }
  y0 = x;
  y1 = 0.0;
  e = 1.0;
  while (fabsf(y0 - y1) > e) {
    y0 = y1;
    y1 = y1 - (y1 * y1 - x) / (2.0 * y1);
    e = FLT_EPSILON * y1;
  }
  return y1;
}


x86 assembly (clang, -O0):
<sqrtf>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1134 <sqrtf+0x34>
mov    0x2ed2(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11f7 <sqrtf+0xf7>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb2(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movaps 0xeac(%rip),%xmm1
pand   %xmm1,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    11ed <sqrtf+0xed>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm3
movss  -0x8(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm3
movsd  0xe62(%rip),%xmm2
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    0x2dfe(%rip),%rax
movss  (%rax),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1153 <sqrtf+0x53>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqrtf>:
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    1114 <sqrtf+0x14>
mov    0x2ee9(%rip),%rax
movss  (%rax),%xmm0
ret
movaps 0xee5(%rip),%xmm2
andps  %xmm0,%xmm2
ucomiss 0xefb(%rip),%xmm2
jbe    118f <sqrtf+0x8f>
xorps  0xee2(%rip),%xmm0
mov    0x2ea3(%rip),%rax
movss  (%rax),%xmm2
xorps  %xmm4,%xmm4
movaps 0xebd(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
movaps %xmm4,%xmm5
mulss  %xmm4,%xmm5
addss  %xmm0,%xmm5
cvtss2sd %xmm5,%xmm5
movaps %xmm1,%xmm6
addsd  %xmm1,%xmm6
divsd  %xmm6,%xmm5
subsd  %xmm5,%xmm1
cvtsd2ss %xmm1,%xmm1
movaps %xmm2,%xmm5
mulss  %xmm1,%xmm5
subss  %xmm1,%xmm4
andps  %xmm3,%xmm4
ucomiss %xmm5,%xmm4
movaps %xmm1,%xmm4
ja     1150 <sqrtf+0x50>
movaps %xmm1,%xmm0
ret

LLVM IR (-O0):
@NAN = global float 0.000000e+00
@FLT_EPSILON = global float 0.000000e+00
define float @sqrtf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %3
%7 = load float, float* %3
%8 = fpext float %7 to double
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load float, float* @NAN
store float %11, float* %2
br label %42
12: ; preds = %1
%13 = load float, float* %3
store float %13, float* %4
store float 0.000000e+00, float* %5
store float 1.000000e+00, float* %6
br label %14
14: ; preds = %21, %12
%15 = load float, float* %4
%16 = load float, float* %5
%17 = fsub float %15, %16
%18 = call float @llvm.fabs.f32(float %17)
%19 = load float, float* %6
%20 = fcmp ogt float %18, %19
br i1 %20, label %21, label %40
21: ; preds = %14
%22 = load float, float* %5
store float %22, float* %4
%23 = load float, float* %5
%24 = fpext float %23 to double
%25 = load float, float* %5
%26 = load float, float* %5
%27 = load float, float* %3
%28 = fneg float %27
%29 = call float @llvm.fmuladd.f32(float %25, float %26, float %28)
%30 = fpext float %29 to double
%31 = load float, float* %5
%32 = fpext float %31 to double
%33 = fmul double 2.000000e+00, %32
%34 = fdiv double %30, %33
%35 = fsub double %24, %34
%36 = fptrunc double %35 to float
store float %36, float* %5
%37 = load float, float* @FLT_EPSILON
%38 = load float, float* %5
%39 = fmul float %37, %38
store float %39, float* %6
br label %14
40: ; preds = %14
%41 = load float, float* %5
store float %41, float* %2
br label %42
42: ; preds = %40, %10
%43 = load float, float* %2
ret float %43
}

LLVM IR (-O2):
@NAN = global float 0.000000e+00
@FLT_EPSILON = global float 0.000000e+00
define float @sqrtf(float %0) {
%2 = fcmp olt float %0, 0.000000e+00
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call float @llvm.fabs.f32(float %0)
%5 = fcmp ogt float %4, 1.000000e+00
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = fneg float %0
%8 = load float, float* @FLT_EPSILON
br label %11
9: ; preds = %1
%10 = load float, float* @NAN
br label %24
11: ; preds = %6, %11
%12 = phi float [ 0.000000e+00, %6 ], [ %19, %11 ]
%13 = fpext float %12 to double
%14 = tail call float @llvm.fmuladd.f32(float %12, float %12, float %7)
%15 = fpext float %14 to double
%16 = fmul double %13, 2.000000e+00
%17 = fdiv double %15, %16
%18 = fsub double %13, %17
%19 = fptrunc double %18 to float
%20 = fmul float %8, %19
%21 = fsub float %12, %19
%22 = tail call float @llvm.fabs.f32(float %21)
%23 = fcmp ogt float %22, %20
br i1 %23, label %11, label %24
24: ; preds = %11, %3, %9
%25 = phi float [ %10, %9 ], [ 0.000000e+00, %3 ], [ %19, %11 ]
ret float %25
}