#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) {
  const float epsilon = .00001;
  float guess = 1.0;
  while (absoluteValue(guess * guess / x - 1) >= epsilon)
    guess = (x / guess + guess) / 2.0;
  return guess;
}


x86 assembly (clang, -O0):
<squareRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xedf(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xece(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
divss  -0x4(%rbp),%xmm0
movss  0xeb2(%rip),%xmm1
subss  %xmm1,%xmm0
call   1030 <absoluteValue@plt>
movss  0xea5(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1195 <squareRoot+0x85>
movss  -0x4(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1137 <squareRoot+0x27>
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squareRoot>:
push   %rax
movaps %xmm0,%xmm1
movss  0xee4(%rip),%xmm0
movss  %xmm0,(%rsp)
movss  %xmm1,0x4(%rsp)
divss  %xmm1,%xmm0
addss  0xed1(%rip),%xmm0
call   1030 <absoluteValue@plt>
ucomiss 0xec9(%rip),%xmm0
jb     1194 <squareRoot+0x84>
movss  0xeb7(%rip),%xmm0
nopl   0x0(%rax)
movss  0x4(%rsp),%xmm1
movaps %xmm1,%xmm2
divss  %xmm0,%xmm2
addss  %xmm0,%xmm2
mulss  0xea3(%rip),%xmm2
movss  %xmm2,(%rsp)
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
divss  %xmm1,%xmm0
addss  0xe83(%rip),%xmm0
call   1030 <absoluteValue@plt>
ucomiss 0xe7b(%rip),%xmm0
movss  (%rsp),%xmm0
jae    1150 <squareRoot+0x40>
movss  (%rsp),%xmm0
pop    %rax
ret

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

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