double sqrt(x)
double x;
{
  typedef union {
    double d;
    unsigned u[4];
  } DBL;
  double y, re, p, q;
  unsigned ex;
  DBL *xp;
  xp = (DBL *)&x;
  ex = xp->u[3] & ~0100017;
  re = ex & 020 ? 1.4142135623730950488 : 1.0;
  ex = ex - 037740 >> 1;
  ex &= ~0100017;
  xp->u[3] &= ~0177760;
  xp->u[3] |= 037740;
  if (xp->d < .7071067812) {
    xp->d *= 1.4142135623730950488;
    if (re > 1.0)
      re = 1.189207115002721;
    else
      re = 1.0 / 1.18920711500271;
  }
  p = .54525387389085 +
      xp->d * (13.65944682358639 +
               xp->d * (27.090122712655 + xp->d * 6.43107724139784));
  q = 4.17003771413707 +
      xp->d * (24.84175210765124 + xp->d * (17.71411083016702 + xp->d));
  xp->d = p / q;
  xp->u[3] = xp->u[3] + ex & ~0100000;
  xp->d *= re;
  return (xp->d);
}


x86 assembly (clang, -O0):
<sqrt>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%eax
and    $0xffff7ff0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
and    $0x10,%eax
movsd  0xeda(%rip),%xmm0
movsd  0xeda(%rip),%xmm1
movsd  %xmm1,-0x48(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x40(%rbp)
jne    1153 <sqrt+0x53>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x3fe0,%eax
shr    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
and    $0xffff7ff0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%ecx
and    $0xffff000f,%ecx
mov    %ecx,0xc(%rax)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%ecx
or     $0x3fe0,%ecx
mov    %ecx,0xc(%rax)
mov    -0x38(%rbp),%rax
movsd  0xe5e(%rip),%xmm0
ucomisd (%rax),%xmm0
jbe    11fb <sqrt+0xfb>
mov    -0x38(%rbp),%rax
movsd  0xe50(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e9 <sqrt+0xe9>
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11f6 <sqrt+0xf6>
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11fb <sqrt+0xfb>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm2
movsd  0xe35(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe31(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe11(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x38(%rbp),%rax
movsd  0xdcc(%rip),%xmm2
addsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdb4(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd9c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%ecx
add    -0x2c(%rbp),%ecx
and    $0xffff7fff,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,0xc(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqrt>:
movsd  0xef8(%rip),%xmm1
movapd %xmm0,%xmm2
cmpltsd 0xef3(%rip),%xmm2
mulsd  %xmm0,%xmm1
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movsd  0xee3(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xedf(%rip),%xmm0
movapd %xmm2,%xmm1
addsd  0xedb(%rip),%xmm1
unpcklpd %xmm1,%xmm0
unpcklpd %xmm2,%xmm2
mulpd  %xmm2,%xmm0
addpd  0xed7(%rip),%xmm0
mulpd  %xmm2,%xmm0
addpd  0xedb(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
mulsd  0xeaf(%rip),%xmm0
ret

LLVM IR (-O0):
%union.DBL = type { double, [8 x i8] }
define double @sqrt(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca %union.DBL*
store double %0, double* %2
%9 = bitcast double* %2 to %union.DBL*
store %union.DBL* %9, %union.DBL** %8
%10 = load %union.DBL*, %union.DBL** %8
%11 = bitcast %union.DBL* %10 to [4 x i32]*
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %11, i64 0, i64 3
%13 = load i32, i32* %12
%14 = and i32 %13, -32784
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = and i32 %15, 16
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, double 0x3FF6A09E667F3BCD, double 1.000000e+00
store double %19, double* %4
%20 = load i32, i32* %7
%21 = sub i32 %20, 16352
%22 = lshr i32 %21, 1
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = and i32 %23, -32784
store i32 %24, i32* %7
%25 = load %union.DBL*, %union.DBL** %8
%26 = bitcast %union.DBL* %25 to [4 x i32]*
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %26, i64 0, i64 3
%28 = load i32, i32* %27
%29 = and i32 %28, -65521
store i32 %29, i32* %27
%30 = load %union.DBL*, %union.DBL** %8
%31 = bitcast %union.DBL* %30 to [4 x i32]*
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %31, i64 0, i64 3
%33 = load i32, i32* %32
%34 = or i32 %33, 16352
store i32 %34, i32* %32
%35 = load %union.DBL*, %union.DBL** %8
%36 = bitcast %union.DBL* %35 to double*
%37 = load double, double* %36
%38 = fcmp olt double %37, 0x3FE6A09E6681151E
br i1 %38, label %39, label %49
39: ; preds = %1
%40 = load %union.DBL*, %union.DBL** %8
%41 = bitcast %union.DBL* %40 to double*
%42 = load double, double* %41
%43 = fmul double %42, 0x3FF6A09E667F3BCD
store double %43, double* %41
%44 = load double, double* %4
%45 = fcmp ogt double %44, 1.000000e+00
br i1 %45, label %46, label %47
46: ; preds = %39
store double 0x3FF306FE0A31B715, double* %4
br label %48
47: ; preds = %39
store double 0x3FEAE89F995AD3F4, double* %4
br label %48
48: ; preds = %47, %46
br label %49
49: ; preds = %48, %1
%50 = load %union.DBL*, %union.DBL** %8
%51 = bitcast %union.DBL* %50 to double*
%52 = load double, double* %51
%53 = load %union.DBL*, %union.DBL** %8
%54 = bitcast %union.DBL* %53 to double*
%55 = load double, double* %54
%56 = load %union.DBL*, %union.DBL** %8
%57 = bitcast %union.DBL* %56 to double*
%58 = load double, double* %57
%59 = call double @llvm.fmuladd.f64(double %58, double 0x4019B96C4FF76A1B, double 0x403B171248377AE3)
%60 = call double @llvm.fmuladd.f64(double %55, double %59, double 0x402B51A30399825E)
%61 = call double @llvm.fmuladd.f64(double %52, double %60, double 0x3FE172B8408C1CBF)
store double %61, double* %5
%62 = load %union.DBL*, %union.DBL** %8
%63 = bitcast %union.DBL* %62 to double*
%64 = load double, double* %63
%65 = load %union.DBL*, %union.DBL** %8
%66 = bitcast %union.DBL* %65 to double*
%67 = load double, double* %66
%68 = load %union.DBL*, %union.DBL** %8
%69 = bitcast %union.DBL* %68 to double*
%70 = load double, double* %69
%71 = fadd double 0x4031B6CFF7A54969, %70
%72 = call double @llvm.fmuladd.f64(double %67, double %71, double 0x4038D77D10EDB37E)
%73 = call double @llvm.fmuladd.f64(double %64, double %72, double 0x4010AE1E5DD538A4)
store double %73, double* %6
%74 = load double, double* %5
%75 = load double, double* %6
%76 = fdiv double %74, %75
%77 = load %union.DBL*, %union.DBL** %8
%78 = bitcast %union.DBL* %77 to double*
store double %76, double* %78
%79 = load %union.DBL*, %union.DBL** %8
%80 = bitcast %union.DBL* %79 to [4 x i32]*
%81 = getelementptr inbounds [4 x i32], [4 x i32]* %80, i64 0, i64 3
%82 = load i32, i32* %81
%83 = load i32, i32* %7
%84 = add i32 %82, %83
%85 = and i32 %84, -32769
%86 = load %union.DBL*, %union.DBL** %8
%87 = bitcast %union.DBL* %86 to [4 x i32]*
%88 = getelementptr inbounds [4 x i32], [4 x i32]* %87, i64 0, i64 3
store i32 %85, i32* %88
%89 = load double, double* %4
%90 = load %union.DBL*, %union.DBL** %8
%91 = bitcast %union.DBL* %90 to double*
%92 = load double, double* %91
%93 = fmul double %92, %89
store double %93, double* %91
%94 = load %union.DBL*, %union.DBL** %8
%95 = bitcast %union.DBL* %94 to double*
%96 = load double, double* %95
ret double %96
}

LLVM IR (-O2):
%union.DBL = type { double, [8 x i8] }
define double @sqrt(double %0) {
%2 = fcmp olt double %0, 0x3FE6A09E6681151E
%3 = fmul double %0, 0x3FF6A09E667F3BCD
%4 = select i1 %2, double %3, double %0
%5 = tail call double @llvm.fmuladd.f64(double %4, double 0x4019B96C4FF76A1B, double 0x403B171248377AE3)
%6 = fadd double %4, 0x4031B6CFF7A54969
%7 = insertelement <2 x double> poison, double %4, i64 0
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
%9 = insertelement <2 x double> poison, double %5, i64 0
%10 = insertelement <2 x double> %9, double %6, i64 1
%11 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %8, <2 x double> %10, <2 x double> <double 0x402B51A30399825E, double 0x4038D77D10EDB37E>)
%12 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %8, <2 x double> %11, <2 x double> <double 0x3FE172B8408C1CBF, double 0x4010AE1E5DD538A4>)
%13 = extractelement <2 x double> %12, i64 0
%14 = extractelement <2 x double> %12, i64 1
%15 = fdiv double %13, %14
%16 = fmul double %15, 0x3FEAE89F995AD3F4
ret double %16
}