#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 */
int /*<<< orphan*/ printf(char *, float);
float InvSqrt(float x) {
  union {
    float f;
    int i;
  } tmp;
  printf("%4.6f\n", tmp.f);
  printf("%i\n", tmp.i);
  tmp.f = x;
  printf("%4.6f\n", tmp.f);
  printf("%i\n", tmp.i);
  tmp.i = 0x5f3759df - (tmp.i >> 1);
  printf("%4.6f\n", tmp.f);
  printf("%i\n", tmp.i);
  float y = tmp.f;
  return y * (1.5f - 0.5f * x * y * y);
}


x86 assembly (clang, -O0):
<InvSqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
sar    $0x1,%ecx
mov    $0x5f3759df,%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe50(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm1
movss  0xe24(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InvSqrt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movss  %xmm0,(%rsp)
lea    0xee5(%rip),%r15
mov    %r15,%rdi
call   1030 <printf@plt>
lea    0xedd(%rip),%r14
xorps  %xmm0,%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
movss  (%rsp),%xmm0
call   1030 <printf@plt>
movd   (%rsp),%xmm0
movd   %xmm0,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
sar    %ebp
mov    $0x5f3759df,%ebx
sub    %ebp,%ebx
movd   %ebx,%xmm0
movd   %xmm0,0x4(%rsp)
mov    %r15,%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
movss  (%rsp),%xmm0
mulss  0xe67(%rip),%xmm0
movss  0x4(%rsp),%xmm1
mulss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
addss  0xe55(%rip),%xmm0
mulss  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%union.anon = type { float }
@.str = [7 x i8] c"%4.6f\0A\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define float @InvSqrt(float %0) {
%2 = alloca float
%3 = alloca %union.anon
%4 = alloca float
store float %0, float* %2
%5 = bitcast %union.anon* %3 to float*
%6 = load float, float* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %6)
%8 = bitcast %union.anon* %3 to i32*
%9 = load i32, i32* %8
%10 = sitofp i32 %9 to float
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %10)
%12 = load float, float* %2
%13 = bitcast %union.anon* %3 to float*
store float %12, float* %13
%14 = bitcast %union.anon* %3 to float*
%15 = load float, float* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %15)
%17 = bitcast %union.anon* %3 to i32*
%18 = load i32, i32* %17
%19 = sitofp i32 %18 to float
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %19)
%21 = bitcast %union.anon* %3 to i32*
%22 = load i32, i32* %21
%23 = ashr i32 %22, 1
%24 = sub nsw i32 1597463007, %23
%25 = bitcast %union.anon* %3 to i32*
store i32 %24, i32* %25
%26 = bitcast %union.anon* %3 to float*
%27 = load float, float* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %27)
%29 = bitcast %union.anon* %3 to i32*
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to float
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %31)
%33 = bitcast %union.anon* %3 to float*
%34 = load float, float* %33
store float %34, float* %4
%35 = load float, float* %4
%36 = load float, float* %2
%37 = fmul float 5.000000e-01, %36
%38 = load float, float* %4
%39 = fmul float %37, %38
%40 = load float, float* %4
%41 = fneg float %39
%42 = call float @llvm.fmuladd.f32(float %41, float %40, float 1.500000e+00)
%43 = fmul float %35, %42
ret float %43
}

LLVM IR (-O2):
@.str = [7 x i8] c"%4.6f\0A\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define float @InvSqrt(float %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float undef)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float 0.000000e+00)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %0)
%5 = bitcast float %0 to i32
%6 = sitofp i32 %5 to float
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %6)
%8 = ashr i32 %5, 1
%9 = sub nsw i32 1597463007, %8
%10 = bitcast i32 %9 to float
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %10)
%12 = sitofp i32 %9 to float
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %12)
%14 = fmul float %0, -5.000000e-01
%15 = fmul float %14, %10
%16 = tail call float @llvm.fmuladd.f32(float %15, float %10, float 1.500000e+00)
%17 = fmul float %16, %10
ret float %17
}