#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 absoluteValue(float);
int /*<<< orphan*/ printf(char *, float);
float squareRoot(float x, float epsilon) {
  float guess = 1.0;
  while (absoluteValue(guess * guess - x) >= epsilon) {
    guess = (x / guess + guess) / 2.0;
    printf("%.3f\n", guess);
  }
  return guess;
}


x86 assembly (clang, -O0):
<squareRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  0xec6(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <absoluteValue@plt>
ucomiss -0x8(%rbp),%xmm0
jb     11b0 <squareRoot+0x90>
movss  -0x4(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7b(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <squareRoot+0x1f>
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squareRoot>:
push   %rbx
sub    $0x40,%rsp
movss  %xmm1,0xc(%rsp)
movaps %xmm0,%xmm1
movss  0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm1,0x20(%rsp)
subss  %xmm1,%xmm0
call   1040 <absoluteValue@plt>
movss  0xc(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jb     11c6 <squareRoot+0xa6>
movaps 0xea5(%rip),%xmm0
xorps  0x20(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
movss  0xea3(%rip),%xmm2
lea    0xea4(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movaps 0x20(%rsp),%xmm0
divss  %xmm2,%xmm0
addss  %xmm2,%xmm0
mulss  0xe7f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <printf@plt>
movaps 0x10(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  0x30(%rsp),%xmm0
call   1040 <absoluteValue@plt>
movss  0xc(%rsp),%xmm1
ucomiss %xmm1,%xmm0
movaps 0x10(%rsp),%xmm2
jae    1180 <squareRoot+0x60>
movaps 0x10(%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.3f\0A\00"
define float @squareRoot(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
store float 1.000000e+00, float* %5
br label %6
6: ; preds = %15, %2
%7 = load float, float* %5
%8 = load float, float* %5
%9 = load float, float* %3
%10 = fneg float %9
%11 = call float @llvm.fmuladd.f32(float %7, float %8, float %10)
%12 = call float @absoluteValue(float %11)
%13 = load float, float* %4
%14 = fcmp oge float %12, %13
br i1 %14, label %15, label %26
15: ; preds = %6
%16 = load float, float* %3
%17 = load float, float* %5
%18 = fdiv float %16, %17
%19 = load float, float* %5
%20 = fadd float %18, %19
%21 = fpext float %20 to double
%22 = fdiv double %21, 2.000000e+00
%23 = fptrunc double %22 to float
store float %23, float* %5
%24 = load float, float* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float %24)
br label %6
26: ; preds = %6
%27 = load float, float* %5
ret float %27
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.3f\0A\00"
define float @squareRoot(float %0, float %1) {
%3 = fneg float %0
%4 = fsub float 1.000000e+00, %0
%5 = tail call float @absoluteValue(float %4)
%6 = fcmp ult float %5, %1
br i1 %6, label %16, label %7
7: ; preds = %2, %7
%8 = phi float [ %11, %7 ], [ 1.000000e+00, %2 ]
%9 = fdiv float %0, %8
%10 = fadd float %8, %9
%11 = fmul float %10, 5.000000e-01
%12 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float %11)
%13 = tail call float @llvm.fmuladd.f32(float %11, float %11, float %3)
%14 = tail call float @absoluteValue(float %13)
%15 = fcmp ult float %14, %1
br i1 %15, label %16, label %7
16: ; preds = %7, %2
%17 = phi float [ 1.000000e+00, %2 ], [ %11, %7 ]
ret float %17
}