double ft_invsqrt(double x) {
  int i;
  double xhalf;
  xhalf = 0.5f * x;
  i = *(int *)&x;
  i = 0x5f3759df - (i >> 1);
  x = *(double *)&i;
  x = x * (1.5f - xhalf * x * x);
  x = x * (1.5f - (xhalf * x * x));
  return (x);
}


x86 assembly (clang, -O0):
<ft_invsqrt>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xef7(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x1,%ecx
mov    $0x5f3759df,%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
movsd  -0xc(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe8e(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe4a(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_invsqrt>:
movq   %xmm0,%rax
sar    %eax
mov    $0x5f3759df,%ecx
sub    %eax,%ecx
mov    %ecx,-0x8(%rsp)
movsd  -0x8(%rsp),%xmm1
mulsd  0xee0(%rip),%xmm0
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xed4(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @ft_invsqrt(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store double %0, double* %2
%5 = load double, double* %2
%6 = fmul double 5.000000e-01, %5
store double %6, double* %4
%7 = bitcast double* %2 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = ashr i32 %9, 1
%11 = sub nsw i32 1597463007, %10
store i32 %11, i32* %3
%12 = bitcast i32* %3 to double*
%13 = load double, double* %12
store double %13, double* %2
%14 = load double, double* %2
%15 = load double, double* %4
%16 = load double, double* %2
%17 = fmul double %15, %16
%18 = load double, double* %2
%19 = fneg double %17
%20 = call double @llvm.fmuladd.f64(double %19, double %18, double 1.500000e+00)
%21 = fmul double %14, %20
store double %21, double* %2
%22 = load double, double* %2
%23 = load double, double* %4
%24 = load double, double* %2
%25 = fmul double %23, %24
%26 = load double, double* %2
%27 = fneg double %25
%28 = call double @llvm.fmuladd.f64(double %27, double %26, double 1.500000e+00)
%29 = fmul double %22, %28
store double %29, double* %2
%30 = load double, double* %2
ret double %30
}

LLVM IR (-O2):
define double @ft_invsqrt(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 1597463007, %6
store i32 %7, i32* %2
%8 = bitcast i32* %2 to double*
%9 = load double, double* %8
%10 = fmul double %0, -5.000000e-01
%11 = fmul double %10, %9
%12 = tail call double @llvm.fmuladd.f64(double %11, double %9, double 1.500000e+00)
%13 = fmul double %9, %12
%14 = fmul double %10, %13
%15 = tail call double @llvm.fmuladd.f64(double %14, double %13, double 1.500000e+00)
%16 = fmul double %13, %15
ret double %16
}