void geom_CM2_sph_rtp(double xm[], double xp[], double xc[], int dir) {
  double r1 = xm[0];
  double r2 = xp[0];
  double th1 = xm[1];
  double th2 = xp[1];
  xc[0] = 2.0 * (r1 * r1 + r1 * r2 + r2 * r2) / (3.0 * (r1 + r2));
  xc[1] = 0.5 * (th1 + th2);
}


x86 assembly (clang, -O0):
<geom_CM2_sph_rtp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe91(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm2
addsd  -0x30(%rbp),%xmm2
movsd  0xe73(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe49(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_CM2_sph_rtp>:
movsd  (%rsi),%xmm0
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
addsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm4,%xmm0
mulsd  0xecb(%rip),%xmm1
addsd  %xmm0,%xmm0
divsd  %xmm1,%xmm0
addsd  0x8(%rsi),%xmm2
movsd  %xmm0,(%rdx)
mulsd  0xeba(%rip),%xmm2
movsd  %xmm2,0x8(%rdx)
ret

LLVM IR (-O0):
define void @geom_CM2_sph_rtp(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
store double %15, double* %9
%16 = load double*, double** %6
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
store double %18, double* %10
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
store double %21, double* %11
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
store double %24, double* %12
%25 = load double, double* %9
%26 = load double, double* %9
%27 = load double, double* %9
%28 = load double, double* %10
%29 = fmul double %27, %28
%30 = call double @llvm.fmuladd.f64(double %25, double %26, double %29)
%31 = load double, double* %10
%32 = load double, double* %10
%33 = call double @llvm.fmuladd.f64(double %31, double %32, double %30)
%34 = fmul double 2.000000e+00, %33
%35 = load double, double* %9
%36 = load double, double* %10
%37 = fadd double %35, %36
%38 = fmul double 3.000000e+00, %37
%39 = fdiv double %34, %38
%40 = load double*, double** %7
%41 = getelementptr inbounds double, double* %40, i64 0
store double %39, double* %41
%42 = load double, double* %11
%43 = load double, double* %12
%44 = fadd double %42, %43
%45 = fmul double 5.000000e-01, %44
%46 = load double*, double** %7
%47 = getelementptr inbounds double, double* %46, i64 1
store double %45, double* %47
ret void
}

LLVM IR (-O2):
define void @geom_CM2_sph_rtp(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2, i32 %3) {
%5 = load double, double* %0
%6 = load double, double* %1
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = fmul double %5, %6
%12 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %12)
%14 = fmul double %13, 2.000000e+00
%15 = fadd double %5, %6
%16 = fmul double %15, 3.000000e+00
%17 = fdiv double %14, %16
store double %17, double* %2
%18 = fadd double %8, %10
%19 = fmul double %18, 5.000000e-01
%20 = getelementptr inbounds double, double* %2, i64 1
store double %19, double* %20
ret void
}