#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 INT_MAX;
double acos(int);
int cos(double);
int sin(double);
double compute_distance(double longitude1, double latitude1, double longitude2,
                        double latitude2) {
  if ((longitude1 == 0) || (latitude1 == 0) || (longitude2 == 0) ||
      (latitude2 == 0))
    return INT_MAX;
  longitude1 /= 57.3;
  latitude1 /= 57.3;
  longitude2 /= 57.3;
  latitude2 /= 57.3;
  return 3959.0 *
         acos((sin(latitude1) * sin(latitude2)) +
              (cos(latitude1) * cos(latitude2) * cos(longitude2 - longitude1)));
}


x86 assembly (clang, -O0):
<compute_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1169 <compute_distance+0x39>
jp     1169 <compute_distance+0x39>
jmp    11bb <compute_distance+0x8b>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1186 <compute_distance+0x56>
jp     1186 <compute_distance+0x56>
jmp    11bb <compute_distance+0x8b>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a3 <compute_distance+0x73>
jp     11a3 <compute_distance+0x73>
jmp    11bb <compute_distance+0x8b>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d0 <compute_distance+0xa0>
jp     11d0 <compute_distance+0xa0>
mov    0x2e26(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a1 <compute_distance+0x171>
movsd  -0x10(%rbp),%xmm0
movsd  0xe2b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe15(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
add    %eax,%edi
call   1030 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xd68(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_distance>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jne    1146 <compute_distance+0x16>
jnp    11fe <compute_distance+0xce>
ucomisd %xmm4,%xmm1
jne    1152 <compute_distance+0x22>
jnp    11fe <compute_distance+0xce>
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm2
jne    1162 <compute_distance+0x32>
jnp    11fe <compute_distance+0xce>
ucomisd %xmm4,%xmm3
jne    116e <compute_distance+0x3e>
jnp    11fe <compute_distance+0xce>
movsd  0xe8a(%rip),%xmm4
divsd  %xmm4,%xmm1
movsd  %xmm1,0x8(%rsp)
unpcklpd %xmm0,%xmm2
divpd  0xe84(%rip),%xmm2
movapd %xmm2,0x10(%rsp)
divsd  %xmm4,%xmm3
movsd  %xmm3,(%rsp)
movapd %xmm1,%xmm0
call   1040 <sin@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
imul   %eax,%ebx
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
imul   %eax,%ebp
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <cos@plt>
imul   %eax,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
call   1030 <acos@plt>
mulsd  0xe0c(%rip),%xmm0
jmp    1209 <compute_distance+0xd9>
mov    0x2de3(%rip),%rax
movsd  (%rax),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global double 0.000000e+00
define double @compute_distance(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%10 = load double, double* %6
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %21, label %12
12: ; preds = %4
%13 = load double, double* %7
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load double, double* %8
%17 = fcmp oeq double %16, 0.000000e+00
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load double, double* %9
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %23
21: ; preds = %18, %15, %12, %4
%22 = load double, double* @INT_MAX
store double %22, double* %5
br label %50
23: ; preds = %18
%24 = load double, double* %6
%25 = fdiv double %24, 5.730000e+01
store double %25, double* %6
%26 = load double, double* %7
%27 = fdiv double %26, 5.730000e+01
store double %27, double* %7
%28 = load double, double* %8
%29 = fdiv double %28, 5.730000e+01
store double %29, double* %8
%30 = load double, double* %9
%31 = fdiv double %30, 5.730000e+01
store double %31, double* %9
%32 = load double, double* %7
%33 = call i32 @sin(double %32)
%34 = load double, double* %9
%35 = call i32 @sin(double %34)
%36 = mul nsw i32 %33, %35
%37 = load double, double* %7
%38 = call i32 @cos(double %37)
%39 = load double, double* %9
%40 = call i32 @cos(double %39)
%41 = mul nsw i32 %38, %40
%42 = load double, double* %8
%43 = load double, double* %6
%44 = fsub double %42, %43
%45 = call i32 @cos(double %44)
%46 = mul nsw i32 %41, %45
%47 = add nsw i32 %36, %46
%48 = call double @acos(i32 %47)
%49 = fmul double 3.959000e+03, %48
store double %49, double* %5
br label %50
50: ; preds = %23, %21
%51 = load double, double* %5
ret double %51
}

LLVM IR (-O2):
@INT_MAX = global double 0.000000e+00
define double @compute_distance(double %0, double %1, double %2, double %3) {
%5 = fcmp oeq double %0, 0.000000e+00
%6 = fcmp oeq double %1, 0.000000e+00
%7 = or i1 %5, %6
%8 = fcmp oeq double %2, 0.000000e+00
%9 = or i1 %7, %8
%10 = fcmp oeq double %3, 0.000000e+00
%11 = or i1 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = load double, double* @INT_MAX
br label %34
14: ; preds = %4
%15 = fdiv double %1, 5.730000e+01
%16 = insertelement <2 x double> poison, double %2, i64 0
%17 = insertelement <2 x double> %16, double %0, i64 1
%18 = fdiv <2 x double> %17, <double 5.730000e+01, double 5.730000e+01>
%19 = fdiv double %3, 5.730000e+01
%20 = tail call i32 @sin(double %15)
%21 = tail call i32 @sin(double %19)
%22 = mul nsw i32 %21, %20
%23 = tail call i32 @cos(double %15)
%24 = tail call i32 @cos(double %19)
%25 = mul nsw i32 %24, %23
%26 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%27 = fsub <2 x double> %18, %26
%28 = extractelement <2 x double> %27, i64 0
%29 = tail call i32 @cos(double %28)
%30 = mul nsw i32 %25, %29
%31 = add nsw i32 %30, %22
%32 = tail call double @acos(i32 %31)
%33 = fmul double %32, 3.959000e+03
br label %34
34: ; preds = %14, %12
%35 = phi double [ %13, %12 ], [ %33, %14 ]
ret double %35
}