double sqrt10(const double number) {
  const double ACCURACY = 0.001;
  double lower, upper, guess;
  if (number < 1) {
    lower = number;
    upper = 1;
  } else {
    lower = 1;
    upper = number;
  }
  while ((upper - lower) > ACCURACY) {
    guess = (lower + upper) / 2;
    if (guess * guess > number)
      upper = guess;
    else
      lower = guess;
  }
  return (lower + upper) / 2;
}


x86 assembly (clang, -O0):
<sqrt10>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xef7(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xee2(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1145 <sqrt10+0x45>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    115c <sqrt10+0x5c>
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1161 <sqrt10+0x61>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11cb <sqrt10+0xcb>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11bc <sqrt10+0xbc>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c6 <sqrt10+0xc6>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1161 <sqrt10+0x61>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqrt10>:
movsd  0xef8(%rip),%xmm3
movapd %xmm0,%xmm2
minsd  %xmm3,%xmm2
maxsd  %xmm0,%xmm3
movapd %xmm3,%xmm1
subsd  %xmm2,%xmm1
ucomisd 0xee4(%rip),%xmm1
jbe    1187 <sqrt10+0x87>
movsd  0xee2(%rip),%xmm4
movsd  0xed2(%rip),%xmm5
jmp    1167 <sqrt10+0x67>
nopl   0x0(%rax,%rax,1)
movapd %xmm0,%xmm1
cmpltsd %xmm7,%xmm1
andpd  %xmm1,%xmm6
andnpd %xmm3,%xmm1
orpd   %xmm6,%xmm1
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
ucomisd %xmm5,%xmm3
movapd %xmm1,%xmm3
jbe    118b <sqrt10+0x8b>
movapd %xmm3,%xmm6
addsd  %xmm2,%xmm6
mulsd  %xmm4,%xmm6
movapd %xmm6,%xmm7
mulsd  %xmm6,%xmm7
ucomisd %xmm0,%xmm7
ja     1140 <sqrt10+0x40>
movapd %xmm6,%xmm2
jmp    1140 <sqrt10+0x40>
movapd %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  0xe79(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @sqrt10(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
store double 1.000000e-03, double* %3
%7 = load double, double* %2
%8 = fcmp olt double %7, 1.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load double, double* %2
store double %10, double* %4
store double 1.000000e+00, double* %5
br label %13
11: ; preds = %1
store double 1.000000e+00, double* %4
%12 = load double, double* %2
store double %12, double* %5
br label %13
13: ; preds = %11, %9
br label %14
14: ; preds = %33, %13
%15 = load double, double* %5
%16 = load double, double* %4
%17 = fsub double %15, %16
%18 = fcmp ogt double %17, 1.000000e-03
br i1 %18, label %19, label %34
19: ; preds = %14
%20 = load double, double* %4
%21 = load double, double* %5
%22 = fadd double %20, %21
%23 = fdiv double %22, 2.000000e+00
store double %23, double* %6
%24 = load double, double* %6
%25 = load double, double* %6
%26 = fmul double %24, %25
%27 = load double, double* %2
%28 = fcmp ogt double %26, %27
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = load double, double* %6
store double %30, double* %5
br label %33
31: ; preds = %19
%32 = load double, double* %6
store double %32, double* %4
br label %33
33: ; preds = %31, %29
br label %14
34: ; preds = %14
%35 = load double, double* %4
%36 = load double, double* %5
%37 = fadd double %35, %36
%38 = fdiv double %37, 2.000000e+00
ret double %38
}

LLVM IR (-O2):
define double @sqrt10(double %0) {
%2 = fcmp olt double %0, 1.000000e+00
%3 = select i1 %2, double 1.000000e+00, double %0
%4 = select i1 %2, double %0, double 1.000000e+00
%5 = fsub double %3, %4
%6 = fcmp ogt double %5, 1.000000e-03
br i1 %6, label %7, label %18
7: ; preds = %1, %7
%8 = phi double [ %15, %7 ], [ %4, %1 ]
%9 = phi double [ %14, %7 ], [ %3, %1 ]
%10 = fadd double %9, %8
%11 = fmul double %10, 5.000000e-01
%12 = fmul double %11, %11
%13 = fcmp ogt double %12, %0
%14 = select i1 %13, double %11, double %9
%15 = select i1 %13, double %8, double %11
%16 = fsub double %14, %15
%17 = fcmp ogt double %16, 1.000000e-03
br i1 %17, label %7, label %18
18: ; preds = %7, %1
%19 = phi double [ %3, %1 ], [ %14, %7 ]
%20 = phi double [ %4, %1 ], [ %15, %7 ]
%21 = fadd double %19, %20
%22 = fmul double %21, 5.000000e-01
ret double %22
}