#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 const absoluteValue(float);
float squareRoot(float x) {
  if (0 > x)
    return -1.0;
  const float epsilon = 0.00001;
  float 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    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    113c <squareRoot+0x2c>
movss  0xed6(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c7 <squareRoot+0xb7>
movss  0xec0(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xeaf(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <absoluteValue@plt>
movss  0xe7d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11bd <squareRoot+0xad>
movss  -0x8(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1156 <squareRoot+0x46>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squareRoot>:
sub    $0x38,%rsp
xorps  %xmm1,%xmm1
movaps %xmm0,(%rsp)
ucomiss %xmm0,%xmm1
jbe    112d <squareRoot+0x1d>
movss  0xed8(%rip),%xmm1
jmp    11ac <squareRoot+0x9c>
movss  0xecf(%rip),%xmm0
subss  (%rsp),%xmm0
call   1030 <absoluteValue@plt>
movss  0xebd(%rip),%xmm1
ucomiss 0xeba(%rip),%xmm0
jb     11ac <squareRoot+0x9c>
movaps 0xeb9(%rip),%xmm0
xorps  (%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movss  0xe9c(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movaps (%rsp),%xmm1
divss  %xmm0,%xmm1
addss  %xmm0,%xmm1
mulss  0xe88(%rip),%xmm1
movaps %xmm1,0x20(%rsp)
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
addss  0x10(%rsp),%xmm0
call   1030 <absoluteValue@plt>
movaps 0x20(%rsp),%xmm1
ucomiss 0xe61(%rip),%xmm0
movaps %xmm1,%xmm0
jae    1170 <squareRoot+0x60>
movaps %xmm1,%xmm0
add    $0x38,%rsp
ret

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

LLVM IR (-O2):
define float @squareRoot(float %0) {
%2 = fcmp olt float %0, 0.000000e+00
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = fneg float %0
%5 = fsub float 1.000000e+00, %0
%6 = tail call float @absoluteValue(float %5)
%7 = fcmp ult float %6, 0x3EE4F8B580000000
br i1 %7, label %16, label %8
8: ; preds = %3, %8
%9 = phi float [ %12, %8 ], [ 1.000000e+00, %3 ]
%10 = fdiv float %0, %9
%11 = fadd float %9, %10
%12 = fmul float %11, 5.000000e-01
%13 = tail call float @llvm.fmuladd.f32(float %12, float %12, float %4)
%14 = tail call float @absoluteValue(float %13)
%15 = fcmp ult float %14, 0x3EE4F8B580000000
br i1 %15, label %16, label %8
16: ; preds = %8, %3, %1
%17 = phi float [ -1.000000e+00, %1 ], [ 1.000000e+00, %3 ], [ %12, %8 ]
ret float %17
}