#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 sqrt(double);
double inv_distance(double x1, double x2, double y1, double y2, double z1,
                    double z2) {
  double distance2;
  distance2 =
      (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
  return 1 / sqrt(distance2);
}


x86 assembly (clang, -O0):
<inv_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm3
subsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_distance>:
push   %rax
subsd  %xmm1,%xmm0
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
subsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm4
addsd  %xmm4,%xmm0
call   1030 <sqrt@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @inv_distance(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%14 = load double, double* %7
%15 = load double, double* %8
%16 = fsub double %14, %15
%17 = load double, double* %7
%18 = load double, double* %8
%19 = fsub double %17, %18
%20 = load double, double* %9
%21 = load double, double* %10
%22 = fsub double %20, %21
%23 = load double, double* %9
%24 = load double, double* %10
%25 = fsub double %23, %24
%26 = fmul double %22, %25
%27 = call double @llvm.fmuladd.f64(double %16, double %19, double %26)
%28 = load double, double* %11
%29 = load double, double* %12
%30 = fsub double %28, %29
%31 = load double, double* %11
%32 = load double, double* %12
%33 = fsub double %31, %32
%34 = call double @llvm.fmuladd.f64(double %30, double %33, double %27)
store double %34, double* %13
%35 = load double, double* %13
%36 = call i32 @sqrt(double %35)
%37 = sdiv i32 1, %36
%38 = sitofp i32 %37 to double
ret double %38
}

LLVM IR (-O2):
define double @inv_distance(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = fsub double %0, %1
%8 = fsub double %2, %3
%9 = fmul double %8, %8
%10 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %9)
%11 = fsub double %4, %5
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %10)
%13 = tail call i32 @sqrt(double %12)
%14 = add i32 %13, 1
%15 = icmp ult i32 %14, 3
%16 = select i1 %15, i32 %13, i32 0
%17 = sitofp i32 %16 to double
ret double %17
}