#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 */
double DistancePolar(double const, double const, double const);
double cos(double const);
double square(double const);
double InvDistanceD2dphi(const double r0, const double r1, const double dphi) {
  double d, cosdphi;
  if (r0 == 0 || r1 == 0) {
    return 0;
  }
  d = DistancePolar(r0, r1, dphi);
  cosdphi = cos(dphi);
  return -square(r0 * r1) *
         (cosdphi * (r0 / r1 + r1 / r0) + square(cosdphi) - 3) /
         (d * square(square(d)));
}


x86 assembly (clang, -O0):
<InvDistanceD2dphi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1164 <InvDistanceD2dphi+0x34>
jp     1164 <InvDistanceD2dphi+0x34>
jmp    117c <InvDistanceD2dphi+0x4c>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1189 <InvDistanceD2dphi+0x59>
jp     1189 <InvDistanceD2dphi+0x59>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126f <InvDistanceD2dphi+0x13f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1050 <DistancePolar@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <square@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <square@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm3
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xdd1(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <square@plt>
call   1030 <square@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InvDistanceD2dphi>:
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jne    1140 <InvDistanceD2dphi+0x10>
jnp    1222 <InvDistanceD2dphi+0xf2>
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm1
jne    1150 <InvDistanceD2dphi+0x20>
jnp    1222 <InvDistanceD2dphi+0xf2>
sub    $0x58,%rsp
movapd %xmm1,0x10(%rsp)
movapd %xmm0,0x30(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1050 <DistancePolar@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x30(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1030 <square@plt>
xorpd  0xe65(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
movapd 0x30(%rsp),%xmm2
movapd %xmm2,%xmm0
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm1,%xmm0
unpcklpd %xmm2,%xmm1
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <square@plt>
movapd 0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
addsd  0xe1e(%rip),%xmm1
mulsd  0x40(%rsp),%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <square@plt>
call   1030 <square@plt>
movapd 0x10(%rsp),%xmm4
mulsd  0x28(%rsp),%xmm0
divsd  %xmm0,%xmm4
add    $0x58,%rsp
movapd %xmm4,%xmm0
ret

LLVM IR (-O0):
define double @InvDistanceD2dphi(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%10 = load double, double* %5
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load double, double* %6
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %12, %3
store double 0.000000e+00, double* %4
br label %47
16: ; preds = %12
%17 = load double, double* %5
%18 = load double, double* %6
%19 = load double, double* %7
%20 = call double @DistancePolar(double %17, double %18, double %19)
store double %20, double* %8
%21 = load double, double* %7
%22 = call double @cos(double %21)
store double %22, double* %9
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = call double @square(double %25)
%27 = fneg double %26
%28 = load double, double* %9
%29 = load double, double* %5
%30 = load double, double* %6
%31 = fdiv double %29, %30
%32 = load double, double* %6
%33 = load double, double* %5
%34 = fdiv double %32, %33
%35 = fadd double %31, %34
%36 = load double, double* %9
%37 = call double @square(double %36)
%38 = call double @llvm.fmuladd.f64(double %28, double %35, double %37)
%39 = fsub double %38, 3.000000e+00
%40 = fmul double %27, %39
%41 = load double, double* %8
%42 = load double, double* %8
%43 = call double @square(double %42)
%44 = call double @square(double %43)
%45 = fmul double %41, %44
%46 = fdiv double %40, %45
store double %46, double* %4
br label %47
47: ; preds = %16, %15
%48 = load double, double* %4
ret double %48
}

LLVM IR (-O2):
define double @InvDistanceD2dphi(double %0, double %1, double %2) {
%4 = fcmp oeq double %0, 0.000000e+00
%5 = fcmp oeq double %1, 0.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %29, label %7
7: ; preds = %3
%8 = tail call double @DistancePolar(double %0, double %1, double %2)
%9 = tail call double @cos(double %2)
%10 = fmul double %0, %1
%11 = tail call double @square(double %10)
%12 = fneg double %11
%13 = insertelement <2 x double> poison, double %0, i64 0
%14 = insertelement <2 x double> %13, double %1, i64 1
%15 = insertelement <2 x double> poison, double %1, i64 0
%16 = insertelement <2 x double> %15, double %0, i64 1
%17 = fdiv <2 x double> %14, %16
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%19 = fadd <2 x double> %17, %18
%20 = extractelement <2 x double> %19, i64 0
%21 = tail call double @square(double %9)
%22 = tail call double @llvm.fmuladd.f64(double %9, double %20, double %21)
%23 = fadd double %22, -3.000000e+00
%24 = fmul double %23, %12
%25 = tail call double @square(double %8)
%26 = tail call double @square(double %25)
%27 = fmul double %8, %26
%28 = fdiv double %24, %27
br label %29
29: ; preds = %3, %7
%30 = phi double [ %28, %7 ], [ 0.000000e+00, %3 ]
ret double %30
}