#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 M_PI;
double acos(int);
int cos(double);
double fabs(double);
void arclength(double lon_1, double lon_0, double lat_1, double lat_0,
               double *arclen) {
  if ((lat_1 == -1000) || (lat_0 == -1000) || (lon_1 == -1000) ||
      (lon_0 == -1000)) {
    *arclen = 0.0;
  } else {
    *arclen = 696000000.0 * acos(cos(M_PI / 180.0 * fabs(lat_1 - lat_0)) *
                                 cos(M_PI / 180.0 * fabs(lon_1 - lon_0)));
  }
  return;
}


x86 assembly (clang, -O0):
<arclength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xeb3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1162 <arclength+0x42>
jp     1162 <arclength+0x42>
jmp    11c3 <arclength+0xa3>
movsd  -0x20(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1184 <arclength+0x64>
jp     1184 <arclength+0x64>
jmp    11c3 <arclength+0xa3>
movsd  -0x8(%rbp),%xmm0
movsd  0xe6f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11a6 <arclength+0x86>
jp     11a6 <arclength+0x86>
jmp    11c3 <arclength+0xa3>
movsd  -0x10(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11d3 <arclength+0xb3>
jp     11d3 <arclength+0xb3>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1262 <arclength+0x142>
mov    0x2e0e(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movaps 0xe25(%rip),%xmm2
pand   %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2dd6(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xdf2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xded(%rip),%xmm2
pand   %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
mov    -0x2c(%rbp),%edi
imul   %eax,%edi
call   1030 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xdb2(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arclength>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movapd %xmm0,%xmm4
ucomisd 0xec9(%rip),%xmm1
xorpd  %xmm0,%xmm0
jne    1143 <arclength+0x23>
jnp    11ea <arclength+0xca>
ucomisd 0xeb5(%rip),%xmm4
jne    1153 <arclength+0x33>
jnp    11ea <arclength+0xca>
ucomisd 0xea5(%rip),%xmm2
jne    1163 <arclength+0x43>
jnp    11ea <arclength+0xca>
ucomisd 0xe95(%rip),%xmm3
jne    116f <arclength+0x4f>
jnp    11ea <arclength+0xca>
mov    0x2e72(%rip),%r14
movsd  (%r14),%xmm0
divsd  0xe85(%rip),%xmm0
subsd  %xmm3,%xmm2
andpd  0xe91(%rip),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movapd %xmm4,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <cos@plt>
mov    %eax,%ebp
movsd  (%r14),%xmm0
divsd  0xe51(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  0x8(%rsp),%xmm1
andpd  0xe55(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1040 <cos@plt>
imul   %eax,%ebp
mov    %ebp,%edi
call   1030 <acos@plt>
mulsd  0xe26(%rip),%xmm0
movsd  %xmm0,(%rbx)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @arclength(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*
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
%11 = load double, double* %8
%12 = fcmp oeq double %11, -1.000000e+03
br i1 %12, label %22, label %13
13: ; preds = %5
%14 = load double, double* %9
%15 = fcmp oeq double %14, -1.000000e+03
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load double, double* %6
%18 = fcmp oeq double %17, -1.000000e+03
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load double, double* %7
%21 = fcmp oeq double %20, -1.000000e+03
br i1 %21, label %22, label %24
22: ; preds = %19, %16, %13, %5
%23 = load double*, double** %10
store double 0.000000e+00, double* %23
br label %45
24: ; preds = %19
%25 = load double, double* @M_PI
%26 = fdiv double %25, 1.800000e+02
%27 = load double, double* %8
%28 = load double, double* %9
%29 = fsub double %27, %28
%30 = call double @llvm.fabs.f64(double %29)
%31 = fmul double %26, %30
%32 = call i32 @cos(double %31)
%33 = load double, double* @M_PI
%34 = fdiv double %33, 1.800000e+02
%35 = load double, double* %6
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = call double @llvm.fabs.f64(double %37)
%39 = fmul double %34, %38
%40 = call i32 @cos(double %39)
%41 = mul nsw i32 %32, %40
%42 = call double @acos(i32 %41)
%43 = fmul double 6.960000e+08, %42
%44 = load double*, double** %10
store double %43, double* %44
br label %45
45: ; preds = %24, %22
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @arclength(double %0, double %1, double %2, double %3, double* nocapture writeonly %4) {
%6 = fcmp oeq double %2, -1.000000e+03
%7 = fcmp oeq double %3, -1.000000e+03
%8 = or i1 %6, %7
%9 = fcmp oeq double %0, -1.000000e+03
%10 = or i1 %9, %8
%11 = fcmp oeq double %1, -1.000000e+03
%12 = or i1 %11, %10
br i1 %12, label %29, label %13
13: ; preds = %5
%14 = load double, double* @M_PI
%15 = fdiv double %14, 1.800000e+02
%16 = fsub double %2, %3
%17 = tail call double @llvm.fabs.f64(double %16)
%18 = fmul double %17, %15
%19 = tail call i32 @cos(double %18)
%20 = load double, double* @M_PI
%21 = fdiv double %20, 1.800000e+02
%22 = fsub double %0, %1
%23 = tail call double @llvm.fabs.f64(double %22)
%24 = fmul double %23, %21
%25 = tail call i32 @cos(double %24)
%26 = mul nsw i32 %25, %19
%27 = tail call double @acos(i32 %26)
%28 = fmul double %27, 6.960000e+08
br label %29
29: ; preds = %5, %13
%30 = phi double [ %28, %13 ], [ 0.000000e+00, %5 ]
store double %30, double* %4
ret void
}