#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 */
double fabs(double);
double newtonIterative(double x) {
  double answer = 1;
  while (fabs((answer * answer) / x - 1.0) >= 0.0000001) {
    answer = ((x / answer) + answer) / 2;
  }
  return answer;
}


x86 assembly (clang, -O0):
<newtonIterative>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeef(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  0xed3(%rip),%xmm1
subsd  %xmm1,%xmm0
movaps 0xee8(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xec4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1173 <newtonIterative+0x73>
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1116 <newtonIterative+0x16>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<newtonIterative>:
movsd  0xef8(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
addsd  0xef0(%rip),%xmm2
andpd  0xf00(%rip),%xmm2
ucomisd 0xee8(%rip),%xmm2
jb     118e <newtonIterative+0x8e>
movsd  0xece(%rip),%xmm6
movsd  0xede(%rip),%xmm2
movsd  0xec6(%rip),%xmm3
movapd 0xed6(%rip),%xmm4
movsd  0xebe(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm0,%xmm1
divsd  %xmm6,%xmm1
addsd  %xmm6,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm6
mulsd  %xmm1,%xmm6
divsd  %xmm0,%xmm6
addsd  %xmm3,%xmm6
andpd  %xmm4,%xmm6
ucomisd %xmm5,%xmm6
movapd %xmm1,%xmm6
jae    1160 <newtonIterative+0x60>
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @newtonIterative(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
store double 1.000000e+00, double* %3
br label %4
4: ; preds = %13, %1
%5 = load double, double* %3
%6 = load double, double* %3
%7 = fmul double %5, %6
%8 = load double, double* %2
%9 = fdiv double %7, %8
%10 = fsub double %9, 1.000000e+00
%11 = call double @llvm.fabs.f64(double %10)
%12 = fcmp oge double %11, 0x3E7AD7F29ABCAF48
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load double, double* %2
%15 = load double, double* %3
%16 = fdiv double %14, %15
%17 = load double, double* %3
%18 = fadd double %16, %17
%19 = fdiv double %18, 2.000000e+00
store double %19, double* %3
br label %4
20: ; preds = %4
%21 = load double, double* %3
ret double %21
}

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