double distradec(double ra1, double dec1, double ra2, double dec2) {
  return (cos(((ra1 - ra2) * 0.01745329252)) * cos(((dec1)*0.01745329252)) *
              cos(((dec2)*0.01745329252)) +
          sin(((dec1)*0.01745329252)) * sin(((dec2)*0.01745329252)));
}


x86 assembly (clang, -O0):
<distradec>:
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  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xeb2(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xe9c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe79(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe62(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe4b(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distradec>:
sub    $0x28,%rsp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
subsd  %xmm2,%xmm0
mulsd  0xec4(%rip),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xeab(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe86(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @distradec(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %5
%10 = load double, double* %7
%11 = fsub double %9, %10
%12 = fmul double %11, 0x3F91DF46A252DD11
%13 = call double @cos(double %12)
%14 = load double, double* %6
%15 = fmul double %14, 0x3F91DF46A252DD11
%16 = call double @cos(double %15)
%17 = fmul double %13, %16
%18 = load double, double* %8
%19 = fmul double %18, 0x3F91DF46A252DD11
%20 = call double @cos(double %19)
%21 = load double, double* %6
%22 = fmul double %21, 0x3F91DF46A252DD11
%23 = call double @sin(double %22)
%24 = load double, double* %8
%25 = fmul double %24, 0x3F91DF46A252DD11
%26 = call double @sin(double %25)
%27 = fmul double %23, %26
%28 = call double @llvm.fmuladd.f64(double %17, double %20, double %27)
ret double %28
}

LLVM IR (-O2):
define double @distradec(double %0, double %1, double %2, double %3) {
%5 = fsub double %0, %2
%6 = fmul double %5, 0x3F91DF46A252DD11
%7 = tail call double @cos(double %6)
%8 = fmul double %1, 0x3F91DF46A252DD11
%9 = tail call double @cos(double %8)
%10 = fmul double %7, %9
%11 = fmul double %3, 0x3F91DF46A252DD11
%12 = tail call double @cos(double %11)
%13 = tail call double @sin(double %8)
%14 = tail call double @sin(double %11)
%15 = fmul double %13, %14
%16 = tail call double @llvm.fmuladd.f64(double %10, double %12, double %15)
ret double %16
}