#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 asin(double);
double cos(double);
double sin(double);
double sqrt(double);
double sphericalDistance(double f1, double t1, double f2, double t2,
                         double radius) {
  double dx = sin(t2) * cos(f2) - sin(t1) * cos(f1);
  double dy = sin(t2) * sin(f2) - sin(t1) * sin(f1);
  double dz = cos(t2) - cos(t1);
  double d = sqrt(dx * dx + dy * dy + dz * dz);
  return radius * 2 * asin(d / 2);
}


x86 assembly (clang, -O0):
<sphericalDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xd4a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xd33(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <asin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sphericalDistance>:
sub    $0x48,%rsp
movsd  %xmm4,0x38(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x40(%rsp)
movaps %xmm3,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x30(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x40(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x40(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x30(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm2
movsd  0x28(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     126d <sphericalDistance+0x12d>
sqrtsd %xmm0,%xmm0
jmp    1272 <sphericalDistance+0x132>
call   1060 <sqrt@plt>
movsd  0x38(%rsp),%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x38(%rsp)
mulsd  0xd76(%rip),%xmm0
call   1040 <asin@plt>
mulsd  0x38(%rsp),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @sphericalDistance(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%15 = load double, double* %9
%16 = call double @sin(double %15)
%17 = load double, double* %8
%18 = call double @cos(double %17)
%19 = load double, double* %7
%20 = call double @sin(double %19)
%21 = load double, double* %6
%22 = call double @cos(double %21)
%23 = fmul double %20, %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %16, double %18, double %24)
store double %25, double* %11
%26 = load double, double* %9
%27 = call double @sin(double %26)
%28 = load double, double* %8
%29 = call double @sin(double %28)
%30 = load double, double* %7
%31 = call double @sin(double %30)
%32 = load double, double* %6
%33 = call double @sin(double %32)
%34 = fmul double %31, %33
%35 = fneg double %34
%36 = call double @llvm.fmuladd.f64(double %27, double %29, double %35)
store double %36, double* %12
%37 = load double, double* %9
%38 = call double @cos(double %37)
%39 = load double, double* %7
%40 = call double @cos(double %39)
%41 = fsub double %38, %40
store double %41, double* %13
%42 = load double, double* %11
%43 = load double, double* %11
%44 = load double, double* %12
%45 = load double, double* %12
%46 = fmul double %44, %45
%47 = call double @llvm.fmuladd.f64(double %42, double %43, double %46)
%48 = load double, double* %13
%49 = load double, double* %13
%50 = call double @llvm.fmuladd.f64(double %48, double %49, double %47)
%51 = call double @sqrt(double %50)
store double %51, double* %14
%52 = load double, double* %10
%53 = fmul double %52, 2.000000e+00
%54 = load double, double* %14
%55 = fdiv double %54, 2.000000e+00
%56 = call double @asin(double %55)
%57 = fmul double %53, %56
ret double %57
}

LLVM IR (-O2):
define double @sphericalDistance(double %0, double %1, double %2, double %3, double %4) {
%6 = tail call double @sin(double %3)
%7 = tail call double @cos(double %2)
%8 = tail call double @sin(double %1)
%9 = tail call double @cos(double %0)
%10 = fneg double %8
%11 = fmul double %9, %10
%12 = tail call double @llvm.fmuladd.f64(double %6, double %7, double %11)
%13 = tail call double @sin(double %3)
%14 = tail call double @sin(double %2)
%15 = tail call double @sin(double %1)
%16 = tail call double @sin(double %0)
%17 = fneg double %15
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %18)
%20 = tail call double @cos(double %3)
%21 = tail call double @cos(double %1)
%22 = fsub double %20, %21
%23 = fmul double %19, %19
%24 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %23)
%25 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %24)
%26 = tail call double @sqrt(double %25)
%27 = fmul double %4, 2.000000e+00
%28 = fmul double %26, 5.000000e-01
%29 = tail call double @asin(double %28)
%30 = fmul double %27, %29
ret double %30
}