#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 */
typedef int uint64_t;

/* Variables and functions */
double isqrt_double_quake(const double x) {
  uint64_t i, *ip;
  double y, z, *yp;
  y = x;
  ip = (uint64_t *)&y;
  i = *ip;
  i = (uint64_t)0x5fe6eb50c7b537a9 - (i >> 1);
  yp = (double *)&i;
  y = *yp;
  z = x * y * y;
  y *= ((z * z + 6. * z + 1.) / (4. * z * (z + 1.)));
  z = x * y * y;
  y *= ((z * z + 6. * z + 1.) / (4. * z * (z + 1.)));
  return y;
}


x86 assembly (clang, -O0):
<isqrt_double_quake>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x1,%ecx
mov    $0xc7b537a9,%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  0xea1(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe7c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe78(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe63(%rip),%xmm2
addsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  0xe36(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe11(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe0d(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xdf8(%rip),%xmm2
addsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<isqrt_double_quake>:
movq   %xmm0,%rax
sar    %eax
mov    $0xc7b537a9,%ecx
sub    %eax,%ecx
mov    %ecx,-0x8(%rsp)
movsd  -0x8(%rsp),%xmm1
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm3
movsd  0xed4(%rip),%xmm4
movapd %xmm3,%xmm5
mulsd  %xmm4,%xmm5
movapd %xmm3,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm5,%xmm2
movsd  0xec0(%rip),%xmm5
addsd  %xmm5,%xmm2
movsd  0xebc(%rip),%xmm6
movapd %xmm3,%xmm7
mulsd  %xmm6,%xmm7
addsd  %xmm5,%xmm3
mulsd  %xmm7,%xmm3
divsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm4
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
addsd  %xmm5,%xmm1
mulsd  %xmm0,%xmm6
addsd  %xmm5,%xmm0
mulsd  %xmm6,%xmm0
divsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @isqrt_double_quake(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32*
%5 = alloca double
%6 = alloca double
%7 = alloca double*
store double %0, double* %2
%8 = load double, double* %2
store double %8, double* %5
%9 = bitcast double* %5 to i32*
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = ashr i32 %12, 1
%14 = sub nsw i32 -944425047, %13
store i32 %14, i32* %3
%15 = bitcast i32* %3 to double*
store double* %15, double** %7
%16 = load double*, double** %7
%17 = load double, double* %16
store double %17, double* %5
%18 = load double, double* %2
%19 = load double, double* %5
%20 = fmul double %18, %19
%21 = load double, double* %5
%22 = fmul double %20, %21
store double %22, double* %6
%23 = load double, double* %6
%24 = load double, double* %6
%25 = load double, double* %6
%26 = fmul double 6.000000e+00, %25
%27 = call double @llvm.fmuladd.f64(double %23, double %24, double %26)
%28 = fadd double %27, 1.000000e+00
%29 = load double, double* %6
%30 = fmul double 4.000000e+00, %29
%31 = load double, double* %6
%32 = fadd double %31, 1.000000e+00
%33 = fmul double %30, %32
%34 = fdiv double %28, %33
%35 = load double, double* %5
%36 = fmul double %35, %34
store double %36, double* %5
%37 = load double, double* %2
%38 = load double, double* %5
%39 = fmul double %37, %38
%40 = load double, double* %5
%41 = fmul double %39, %40
store double %41, double* %6
%42 = load double, double* %6
%43 = load double, double* %6
%44 = load double, double* %6
%45 = fmul double 6.000000e+00, %44
%46 = call double @llvm.fmuladd.f64(double %42, double %43, double %45)
%47 = fadd double %46, 1.000000e+00
%48 = load double, double* %6
%49 = fmul double 4.000000e+00, %48
%50 = load double, double* %6
%51 = fadd double %50, 1.000000e+00
%52 = fmul double %49, %51
%53 = fdiv double %47, %52
%54 = load double, double* %5
%55 = fmul double %54, %53
store double %55, double* %5
%56 = load double, double* %5
ret double %56
}

LLVM IR (-O2):
define double @isqrt_double_quake(double %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = bitcast double %0 to i64
%5 = trunc i64 %4 to i32
%6 = ashr i32 %5, 1
%7 = sub nsw i32 -944425047, %6
store i32 %7, i32* %2
%8 = bitcast i32* %2 to double*
%9 = load double, double* %8
%10 = fmul double %9, %0
%11 = fmul double %9, %10
%12 = fmul double %11, 6.000000e+00
%13 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %12)
%14 = fadd double %13, 1.000000e+00
%15 = fmul double %11, 4.000000e+00
%16 = fadd double %11, 1.000000e+00
%17 = fmul double %15, %16
%18 = fdiv double %14, %17
%19 = fmul double %9, %18
%20 = fmul double %19, %0
%21 = fmul double %19, %20
%22 = fmul double %21, 6.000000e+00
%23 = tail call double @llvm.fmuladd.f64(double %21, double %21, double %22)
%24 = fadd double %23, 1.000000e+00
%25 = fmul double %21, 4.000000e+00
%26 = fadd double %21, 1.000000e+00
%27 = fmul double %25, %26
%28 = fdiv double %24, %27
%29 = fmul double %19, %28
ret double %29
}