double wcsdiff(x1, y1, x2, y2)
double x1, y1;
double x2, y2;
{
  double xdiff, ydiff, ycos, diff;
  ycos = cos(degrad((y2 + y1) / 2.0));
  xdiff = x2 - x1;
  if (xdiff > 180.0)
    xdiff = xdiff - 360.0;
  if (xdiff < -180.0)
    xdiff = xdiff + 360.0;
  xdiff = xdiff / ycos;
  ydiff = (y2 - y1);
  diff = sqrt((xdiff * xdiff) + (ydiff * ydiff));
  return (diff);
}


x86 assembly (clang, -O0):
<wcsdiff>:
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  -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0x1,%al
call   1030 <degrad@plt>
cvtsi2sd %eax,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b3 <wcsdiff+0x83>
movsd  -0x28(%rbp),%xmm0
movsd  0xe66(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe5d(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11d8 <wcsdiff+0xa8>
movsd  0xe42(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsdiff>:
sub    $0x38,%rsp
movsd  %xmm3,0x10(%rsp)
movaps %xmm2,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
addsd  %xmm3,%xmm0
mulsd  0xea5(%rip),%xmm0
mov    $0x1,%al
call   1030 <degrad@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1040 <cos@plt>
movapd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm3
subsd  0x8(%rsp),%xmm3
movsd  0xe82(%rip),%xmm0
addsd  %xmm3,%xmm0
movsd  0xe7e(%rip),%xmm2
cmpltsd %xmm3,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm3,%xmm2
orpd   %xmm0,%xmm2
movsd  0xe6d(%rip),%xmm3
movapd %xmm2,%xmm0
cmpltsd 0xe68(%rip),%xmm0
addsd  %xmm2,%xmm3
andpd  %xmm0,%xmm3
andnpd %xmm2,%xmm0
orpd   %xmm3,%xmm0
divsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f7 <wcsdiff+0xc7>
sqrtsd %xmm0,%xmm0
add    $0x38,%rsp
ret
add    $0x38,%rsp
jmp    1050 <sqrt@plt>

LLVM IR (-O0):
define double @wcsdiff(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%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 double %3, double* %8
%13 = load double, double* %8
%14 = load double, double* %6
%15 = fadd double %13, %14
%16 = fdiv double %15, 2.000000e+00
%17 = call i32 (double, ...) bitcast (i32 (...)* @degrad to i32 (double, ...)*)(double %16)
%18 = sitofp i32 %17 to double
%19 = call double @cos(double %18)
store double %19, double* %11
%20 = load double, double* %7
%21 = load double, double* %5
%22 = fsub double %20, %21
store double %22, double* %9
%23 = load double, double* %9
%24 = fcmp ogt double %23, 1.800000e+02
br i1 %24, label %25, label %28
25: ; preds = %4
%26 = load double, double* %9
%27 = fsub double %26, 3.600000e+02
store double %27, double* %9
br label %28
28: ; preds = %25, %4
%29 = load double, double* %9
%30 = fcmp olt double %29, -1.800000e+02
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load double, double* %9
%33 = fadd double %32, 3.600000e+02
store double %33, double* %9
br label %34
34: ; preds = %31, %28
%35 = load double, double* %9
%36 = load double, double* %11
%37 = fdiv double %35, %36
store double %37, double* %9
%38 = load double, double* %8
%39 = load double, double* %6
%40 = fsub double %38, %39
store double %40, double* %10
%41 = load double, double* %9
%42 = load double, double* %9
%43 = load double, double* %10
%44 = load double, double* %10
%45 = fmul double %43, %44
%46 = call double @llvm.fmuladd.f64(double %41, double %42, double %45)
%47 = call double @sqrt(double %46)
store double %47, double* %12
%48 = load double, double* %12
ret double %48
}

LLVM IR (-O2):
define double @wcsdiff(double %0, double %1, double %2, double %3) {
%5 = fadd double %1, %3
%6 = fmul double %5, 5.000000e-01
%7 = tail call i32 (double, ...) bitcast (i32 (...)* @degrad to i32 (double, ...)*)(double %6)
%8 = sitofp i32 %7 to double
%9 = tail call double @cos(double %8)
%10 = fsub double %2, %0
%11 = fcmp ogt double %10, 1.800000e+02
%12 = fadd double %10, -3.600000e+02
%13 = select i1 %11, double %12, double %10
%14 = fcmp olt double %13, -1.800000e+02
%15 = fadd double %13, 3.600000e+02
%16 = select i1 %14, double %15, double %13
%17 = fdiv double %16, %9
%18 = fsub double %3, %1
%19 = fmul double %18, %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %19)
%21 = tail call double @sqrt(double %20)
ret double %21
}