double linedist(double lat1, double lon1, double lat2, double lon2, double lat3,
                double lon3) {
  static double _lat1 = -9999;
  static double _lat2 = -9999;
  static double _lon1 = -9999;
  static double _lon2 = -9999;
  static double x1, y1, z1;
  static double x2, y2, z2;
  static double xa, ya, za, la;
  double x3, y3, z3;
  double xp, yp, zp, lp;
  double xa1, ya1, za1;
  double xa2, ya2, za2;
  double d1, d2;
  double c1, c2;
  double dot;
  int newpoints;
  lat1 = ((lat1)*3.14159265358979323846 / 180.0);
  lon1 = ((lon1)*3.14159265358979323846 / 180.0);
  lat2 = ((lat2)*3.14159265358979323846 / 180.0);
  lon2 = ((lon2)*3.14159265358979323846 / 180.0);
  lat3 = ((lat3)*3.14159265358979323846 / 180.0);
  lon3 = ((lon3)*3.14159265358979323846 / 180.0);
  newpoints = 1;
  if (lat1 == _lat1 && lat2 == _lat2 && lon1 == _lon1 && lon2 == _lon2) {
    newpoints = 0;
  } else {
    _lat1 = lat1;
    _lat2 = lat2;
    _lon1 = lon1;
    _lon2 = lon2;
  }
  if (newpoints) {
    x1 = cos(lon1) * cos(lat1);
    y1 = sin(lat1);
    z1 = sin(lon1) * cos(lat1);
    x2 = cos(lon2) * cos(lat2);
    y2 = sin(lat2);
    z2 = sin(lon2) * cos(lat2);
  }
  x3 = cos(lon3) * cos(lat3);
  y3 = sin(lat3);
  z3 = sin(lon3) * cos(lat3);
  if (newpoints) {
    crossproduct(x1, y1, z1, x2, y2, z2, &xa, &ya, &za);
    la = sqrt(xa * xa + ya * ya + za * za);
    if (la) {
      xa /= la;
      ya /= la;
      za /= la;
    }
  }
  if (la) {
    dot = dotproduct(x3, y3, z3, xa, ya, za);
    xp = x3 - dot * xa;
    yp = y3 - dot * ya;
    zp = z3 - dot * za;
    lp = sqrt(xp * xp + yp * yp + zp * zp);
    if (lp) {
      xp /= lp;
      yp /= lp;
      zp /= lp;
      crossproduct(x1, y1, z1, xp, yp, zp, &xa1, &ya1, &za1);
      d1 = dotproduct(xa1, ya1, za1, xa, ya, za);
      crossproduct(xp, yp, zp, x2, y2, z2, &xa2, &ya2, &za2);
      d2 = dotproduct(xa2, ya2, za2, xa, ya, za);
      if (d1 >= 0 && d2 >= 0) {
        return atan(fabs(dot) / lp);
      }
      c1 = dotproduct(x1, y1, z1, xp, yp, zp);
      c2 = dotproduct(x2, y2, z2, xp, yp, zp);
      d1 = fabs(d1);
      d2 = fabs(d2);
      if (c1 < 0) {
        d1 = 2 - d1;
      }
      if (c2 < 0) {
        d2 = 2 - d2;
      }
      if (fabs(d1) < fabs(d2)) {
        return gcdist(lat1, lon1, lat3, lon3);
      } else {
        return gcdist(lat2, lon2, lat3, lon3);
      }
    } else {
      return 3.14159265358979323846 / 2;
    }
  } else {
    dot = dotproduct(x1, y1, z1, x2, y2, z2);
    if (dot >= 0) {
      return gcdist(lat1, lon1, lat3, lon3);
    } else {
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<linedist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  0xe67(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe52(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe49(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe2b(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe16(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe0d(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xdf8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdef(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xdda(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdd1(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xdbc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0xcc(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd 0x2df4(%rip),%xmm0
jne    12ca <linedist+0x15a>
jp     12ca <linedist+0x15a>
movsd  -0x20(%rbp),%xmm0
ucomisd 0x2de3(%rip),%xmm0
jne    12ca <linedist+0x15a>
jp     12ca <linedist+0x15a>
movsd  -0x18(%rbp),%xmm0
ucomisd 0x2dd2(%rip),%xmm0
jne    12ca <linedist+0x15a>
jp     12ca <linedist+0x15a>
movsd  -0x28(%rbp),%xmm0
ucomisd 0x2dc1(%rip),%xmm0
jne    12ca <linedist+0x15a>
jp     12ca <linedist+0x15a>
movl   $0x0,-0xcc(%rbp)
jmp    12fe <linedist+0x18e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2d81(%rip)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,0x2d7c(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,0x2d77(%rip)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,0x2d72(%rip)
cmpl   $0x0,-0xcc(%rbp)
je     13fb <linedist+0x28b>
movsd  -0x18(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xf0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2d42(%rip)
movsd  -0x10(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x2d38(%rip)
movsd  -0x18(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xe8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2d0d(%rip)
movsd  -0x28(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xe0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2ce2(%rip)
movsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x2cd8(%rip)
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2cad(%rip)
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x100(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xf8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cmpl   $0x0,-0xcc(%rbp)
je     1589 <linedist+0x419>
movsd  0x2c01(%rip),%xmm0
movsd  0x2c01(%rip),%xmm1
movsd  0x2c01(%rip),%xmm2
movsd  0x2c01(%rip),%xmm3
movsd  0x2c01(%rip),%xmm4
movsd  0x2c01(%rip),%xmm5
lea    0x2c02(%rip),%rdi
lea    0x2c03(%rip),%rsi
lea    0x2c04(%rip),%rdx
mov    $0x6,%al
call   1090 <crossproduct@plt>
movsd  0x2be5(%rip),%xmm1
movsd  0x2bdd(%rip),%xmm2
movsd  0x2bdd(%rip),%xmm0
mulsd  0x2bd5(%rip),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x2bcd(%rip),%xmm0
movsd  0x2bc5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,0x2bb8(%rip)
movsd  0x2bb0(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1530 <linedist+0x3c0>
jp     1530 <linedist+0x3c0>
jmp    1584 <linedist+0x414>
movsd  0x2b90(%rip),%xmm1
movsd  0x2b70(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2b64(%rip)
movsd  0x2b74(%rip),%xmm1
movsd  0x2b5c(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2b50(%rip)
movsd  0x2b58(%rip),%xmm1
movsd  0x2b48(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2b3c(%rip)
jmp    1589 <linedist+0x419>
movsd  0x2b37(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    15a9 <linedist+0x439>
jp     15a9 <linedist+0x439>
jmp    19fd <linedist+0x88d>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  0x2af0(%rip),%xmm3
movsd  0x2af0(%rip),%xmm4
movsd  0x2af0(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x40(%rbp),%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
movsd  0x2ab8(%rip),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
movsd  0x2a87(%rip),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
movsd  0x2a56(%rip),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    16e3 <linedist+0x573>
jp     16e3 <linedist+0x573>
jmp    19eb <linedist+0x87b>
movsd  -0x70(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x70(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0x295c(%rip),%xmm0
movsd  0x295c(%rip),%xmm1
movsd  0x295c(%rip),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm5
lea    -0x78(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x88(%rbp),%rdx
mov    $0x6,%al
call   1090 <crossproduct@plt>
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm2
ff
movsd  0x293d(%rip),%xmm3
movsd  0x293d(%rip),%xmm4
movsd  0x293d(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movsd  0x28eb(%rip),%xmm3
movsd  0x28eb(%rip),%xmm4
movsd  0x28eb(%rip),%xmm5
lea    -0x90(%rbp),%rdi
lea    -0x98(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
mov    $0x6,%al
call   1090 <crossproduct@plt>
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
movsd  0x28b7(%rip),%xmm3
movsd  0x28b7(%rip),%xmm4
movsd  0x28b7(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     186d <linedist+0x6fd>
movsd  -0xb0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     186d <linedist+0x6fd>
movsd  -0xc8(%rbp),%xmm0
ff
movaps 0x7cb(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x70(%rbp),%xmm0
call   1060 <atan@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1a86 <linedist+0x916>
movsd  0x280b(%rip),%xmm0
movsd  0x280b(%rip),%xmm1
movsd  0x280b(%rip),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  0x27e9(%rip),%xmm0
movsd  0x27e9(%rip),%xmm1
movsd  0x27e9(%rip),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movaps 0x730(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movaps 0x715(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
xorps  %xmm0,%xmm0
ucomisd -0xb8(%rbp),%xmm0
ff
jbe    1940 <linedist+0x7d0>
movsd  0x6e8(%rip),%xmm0
subsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
xorps  %xmm0,%xmm0
ucomisd -0xc0(%rbp),%xmm0
ff
jbe    1969 <linedist+0x7f9>
movsd  0x6bf(%rip),%xmm0
subsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm1
ff
movaps 0x6a8(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
movaps 0x695(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    19c2 <linedist+0x852>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    $0x4,%al
call   1040 <gcdist@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1a86 <linedist+0x916>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    $0x4,%al
call   1040 <gcdist@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1a86 <linedist+0x916>
movsd  0x61d(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1a86 <linedist+0x916>
movsd  0x267b(%rip),%xmm0
movsd  0x267b(%rip),%xmm1
movsd  0x267b(%rip),%xmm2
movsd  0x267b(%rip),%xmm3
movsd  0x267b(%rip),%xmm4
movsd  0x267b(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1a7e <linedist+0x90e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    $0x4,%al
call   1040 <gcdist@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1a86 <linedist+0x916>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linedist>:
push   %rbx
sub    $0xb0,%rsp
movapd %xmm0,%xmm6
unpcklpd %xmm2,%xmm6
unpcklpd %xmm3,%xmm1
movapd 0xe74(%rip),%xmm0
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm6
movapd 0xe74(%rip),%xmm0
divpd  %xmm0,%xmm6
divpd  %xmm0,%xmm1
movsd  0xe94(%rip),%xmm0
mulsd  %xmm0,%xmm4
movsd  0xe90(%rip),%xmm2
divsd  %xmm2,%xmm4
movsd  %xmm4,0x38(%rsp)
mulsd  %xmm0,%xmm5
divsd  %xmm2,%xmm5
movsd  %xmm5,0x40(%rsp)
movsd  0x2e80(%rip),%xmm0
movhpd 0x2e80(%rip),%xmm0
movsd  0x2e80(%rip),%xmm2
movhpd 0x2e80(%rip),%xmm2
cmpeqpd %xmm1,%xmm2
cmpeqpd %xmm6,%xmm0
shufps $0x88,%xmm2,%xmm0
pslld  $0x1f,%xmm0
movmskps %xmm0,%ebx
cmp    $0xf,%bl
movapd %xmm1,0x70(%rsp)
movapd %xmm6,0x60(%rsp)
je     131e <linedist+0x1ae>
movlpd %xmm6,0x2e35(%rip)
movapd %xmm6,%xmm0
unpckhpd %xmm6,%xmm0
movapd %xmm0,0x20(%rsp)
movhpd %xmm6,0x2e27(%rip)
movlpd %xmm1,0x2e27(%rip)
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movhpd %xmm1,0x2e19(%rip)
movapd %xmm1,%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x60(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x2e01(%rip)
movaps 0x60(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x2df7(%rip)
movaps 0x70(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x60(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x2dd6(%rip)
movaps 0x10(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x2db5(%rip)
movaps 0x20(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x2dab(%rip)
movaps 0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x2d8a(%rip)
movsd  0x40(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x38(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x50(%rsp)
movsd  0x38(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x40(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x38(%rsp),%xmm0
call   1070 <cos@plt>
movapd %xmm0,%xmm1
cmp    $0xf,%bl
je     1408 <linedist+0x298>
movsd  %xmm1,0x48(%rsp)
movsd  0x2cf8(%rip),%xmm0
movsd  0x2cf8(%rip),%xmm1
movsd  0x2cf8(%rip),%xmm2
movsd  0x2cf8(%rip),%xmm3
movsd  0x2cf8(%rip),%xmm4
movsd  0x2cf8(%rip),%xmm5
lea    0x2cf9(%rip),%rdi
lea    0x2cfa(%rip),%rsi
lea    0x2cfb(%rip),%rdx
mov    $0x6,%al
call   1090 <crossproduct@plt>
movsd  0x2cdc(%rip),%xmm1
movsd  0x2cdc(%rip),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x2cd0(%rip),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1412 <linedist+0x2a2>
sqrtsd %xmm0,%xmm0
jmp    141b <linedist+0x2ab>
movsd  0x2cb8(%rip),%xmm0
jmp    146d <linedist+0x2fd>
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x2ca5(%rip)
ucomisd %xmm1,%xmm0
jne    142b <linedist+0x2bb>
jnp    1467 <linedist+0x2f7>
movsd  0x2c7d(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x2c71(%rip)
movsd  0x2c71(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x2c65(%rip)
movsd  0x2c65(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x2c59(%rip)
movsd  0x48(%rsp),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    147d <linedist+0x30d>
jnp    1551 <linedist+0x3e1>
movsd  0x20(%rsp),%xmm0
mulsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x2c09(%rip),%xmm3
movsd  0x2c09(%rip),%xmm4
movsd  0x2c09(%rip),%xmm5
movsd  0x8(%rsp),%xmm1
mov    $0x6,%al
call   1030 <dotproduct@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  0x2bdd(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x2bcf(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm4
subsd  %xmm0,%xmm4
movsd  0x2bc1(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm3
subsd  %xmm0,%xmm3
movsd  %xmm4,0x8(%rsp)
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm1,0x20(%rsp)
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm2,0x50(%rsp)
jb     15a4 <linedist+0x434>
sqrtsd %xmm0,%xmm0
jmp    15ad <linedist+0x43d>
movsd  0x2b27(%rip),%xmm0
movsd  0x2b27(%rip),%xmm1
movsd  0x2b27(%rip),%xmm2
movsd  0x2b27(%rip),%xmm3
movsd  0x2b27(%rip),%xmm4
movsd  0x2b27(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
js     1826 <linedist+0x6b6>
movaps 0x60(%rsp),%xmm0
movapd 0x70(%rsp),%xmm1
jmp    180c <linedist+0x69c>
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    15b9 <linedist+0x449>
jnp    1717 <linedist+0x5a7>
movsd  0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm3
movsd  %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm4
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,0x48(%rsp)
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm5
movsd  %xmm1,0x10(%rsp)
movsd  0x2a7d(%rip),%xmm0
movsd  0x2a7d(%rip),%xmm1
movsd  0x2a7d(%rip),%xmm2
lea    0xa8(%rsp),%rdi
lea    0xa0(%rsp),%rsi
lea    0x98(%rsp),%rdx
mov    $0x6,%al
call   1090 <crossproduct@plt>
movsd  0xa8(%rsp),%xmm0
movsd  0xa0(%rsp),%xmm1
movsd  0x98(%rsp),%xmm2
movsd  0x2a5b(%rip),%xmm3
movsd  0x2a5b(%rip),%xmm4
movsd  0x2a5b(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
mov    %eax,%ebx
movsd  0x2a22(%rip),%xmm3
movsd  0x2a22(%rip),%xmm4
movsd  0x2a22(%rip),%xmm5
lea    0x90(%rsp),%rdi
lea    0x88(%rsp),%rsi
lea    0x80(%rsp),%rdx
movsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    $0x6,%al
call   1090 <crossproduct@plt>
movsd  0x90(%rsp),%xmm0
movsd  0x88(%rsp),%xmm1
movsd  0x80(%rsp),%xmm2
movsd  0x29d6(%rip),%xmm3
movsd  0x29d6(%rip),%xmm4
movsd  0x29d6(%rip),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
test   %ebx,%ebx
js     1724 <linedist+0x5b4>
test   %eax,%eax
js     1724 <linedist+0x5b4>
movapd 0x50(%rsp),%xmm0
andpd  0x919(%rip),%xmm0
divsd  0x48(%rsp),%xmm0
call   1060 <atan@plt>
jmp    1826 <linedist+0x6b6>
movsd  0x931(%rip),%xmm0
jmp    1826 <linedist+0x6b6>
movd   %eax,%xmm0
movd   %ebx,%xmm1
punpckldq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm0
movaps %xmm0,0x50(%rsp)
movsd  0x293f(%rip),%xmm0
movsd  0x293f(%rip),%xmm1
movsd  0x293f(%rip),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
mov    %eax,%ebx
movsd  0x2924(%rip),%xmm0
movsd  0x2924(%rip),%xmm1
movsd  0x2924(%rip),%xmm2
movq   0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm5
mov    $0x6,%al
call   1030 <dotproduct@plt>
movapd 0x87b(%rip),%xmm0
movapd 0x50(%rsp),%xmm4
andpd  %xmm0,%xmm4
movd   %ebx,%xmm1
movd   %eax,%xmm2
punpckldq %xmm2,%xmm1
pxor   %xmm2,%xmm2
pxor   %xmm3,%xmm3
pcmpgtd %xmm1,%xmm3
pcmpgtd %xmm3,%xmm2
punpckldq %xmm2,%xmm3
movapd 0x859(%rip),%xmm1
movapd %xmm4,%xmm2
subpd  %xmm4,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm4,%xmm3
orpd   %xmm1,%xmm3
andpd  %xmm0,%xmm3
pshufd $0xee,%xmm3,%xmm0
ucomisd %xmm3,%xmm0
movapd 0x70(%rsp),%xmm1
movaps 0x60(%rsp),%xmm0
ja     180c <linedist+0x69c>
movhlps %xmm0,%xmm0
unpckhpd %xmm1,%xmm1
movsd  0x38(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
mov    $0x4,%al
call   1040 <gcdist@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0xb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@linedist._lat1 = internal global double -9.999000e+03
@linedist._lat2 = internal global double -9.999000e+03
@linedist._lon1 = internal global double -9.999000e+03
@linedist._lon2 = internal global double -9.999000e+03
@linedist.x1 = internal global double 0.000000e+00
@linedist.y1 = internal global double 0.000000e+00
@linedist.z1 = internal global double 0.000000e+00
@linedist.x2 = internal global double 0.000000e+00
@linedist.y2 = internal global double 0.000000e+00
@linedist.z2 = internal global double 0.000000e+00
@linedist.xa = internal global double 0.000000e+00
@linedist.ya = internal global double 0.000000e+00
@linedist.za = internal global double 0.000000e+00
@linedist.la = internal global double 0.000000e+00
define double @linedist(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca i32
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%33 = load double, double* %8
%34 = fmul double %33, 0x400921FB54442D18
%35 = fdiv double %34, 1.800000e+02
store double %35, double* %8
%36 = load double, double* %9
%37 = fmul double %36, 0x400921FB54442D18
%38 = fdiv double %37, 1.800000e+02
store double %38, double* %9
%39 = load double, double* %10
%40 = fmul double %39, 0x400921FB54442D18
%41 = fdiv double %40, 1.800000e+02
store double %41, double* %10
%42 = load double, double* %11
%43 = fmul double %42, 0x400921FB54442D18
%44 = fdiv double %43, 1.800000e+02
store double %44, double* %11
%45 = load double, double* %12
%46 = fmul double %45, 0x400921FB54442D18
%47 = fdiv double %46, 1.800000e+02
store double %47, double* %12
%48 = load double, double* %13
%49 = fmul double %48, 0x400921FB54442D18
%50 = fdiv double %49, 1.800000e+02
store double %50, double* %13
store i32 1, i32* %32
%51 = load double, double* %8
%52 = load double, double* @linedist._lat1
%53 = fcmp oeq double %51, %52
br i1 %53, label %54, label %67
54: ; preds = %6
%55 = load double, double* %10
%56 = load double, double* @linedist._lat2
%57 = fcmp oeq double %55, %56
br i1 %57, label %58, label %67
58: ; preds = %54
%59 = load double, double* %9
%60 = load double, double* @linedist._lon1
%61 = fcmp oeq double %59, %60
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load double, double* %11
%64 = load double, double* @linedist._lon2
%65 = fcmp oeq double %63, %64
br i1 %65, label %66, label %67
66: ; preds = %62
store i32 0, i32* %32
br label %72
67: ; preds = %62, %58, %54, %6
%68 = load double, double* %8
store double %68, double* @linedist._lat1
%69 = load double, double* %10
store double %69, double* @linedist._lat2
%70 = load double, double* %9
store double %70, double* @linedist._lon1
%71 = load double, double* %11
store double %71, double* @linedist._lon2
br label %72
72: ; preds = %67, %66
%73 = load i32, i32* %32
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %100
75: ; preds = %72
%76 = load double, double* %9
%77 = call double @cos(double %76)
%78 = load double, double* %8
%79 = call double @cos(double %78)
%80 = fmul double %77, %79
store double %80, double* @linedist.x1
%81 = load double, double* %8
%82 = call double @sin(double %81)
store double %82, double* @linedist.y1
%83 = load double, double* %9
%84 = call double @sin(double %83)
%85 = load double, double* %8
%86 = call double @cos(double %85)
%87 = fmul double %84, %86
store double %87, double* @linedist.z1
%88 = load double, double* %11
%89 = call double @cos(double %88)
%90 = load double, double* %10
%91 = call double @cos(double %90)
%92 = fmul double %89, %91
store double %92, double* @linedist.x2
%93 = load double, double* %10
%94 = call double @sin(double %93)
store double %94, double* @linedist.y2
%95 = load double, double* %11
%96 = call double @sin(double %95)
%97 = load double, double* %10
%98 = call double @cos(double %97)
%99 = fmul double %96, %98
store double %99, double* @linedist.z2
br label %100
100: ; preds = %75, %72
%101 = load double, double* %13
%102 = call double @cos(double %101)
%103 = load double, double* %12
%104 = call double @cos(double %103)
%105 = fmul double %102, %104
store double %105, double* %14
%106 = load double, double* %12
%107 = call double @sin(double %106)
store double %107, double* %15
%108 = load double, double* %13
%109 = call double @sin(double %108)
%110 = load double, double* %12
%111 = call double @cos(double %110)
%112 = fmul double %109, %111
store double %112, double* %16
%113 = load i32, i32* %32
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %146
115: ; preds = %100
%116 = load double, double* @linedist.x1
%117 = load double, double* @linedist.y1
%118 = load double, double* @linedist.z1
%119 = load double, double* @linedist.x2
%120 = load double, double* @linedist.y2
%121 = load double, double* @linedist.z2
%122 = call i32 (double, double, double, double, double, double, double*, double*, double*, ...) bitcast (i32 (...)* @crossproduct to i32 (double, double, double, double, double, double, double*, double*, double*, ...)*)(double %116, double %117, double %118, double %119, double %120, double %121, double* @linedist.xa, double* @linedist.ya, double* @linedist.za)
%123 = load double, double* @linedist.xa
%124 = load double, double* @linedist.xa
%125 = load double, double* @linedist.ya
%126 = load double, double* @linedist.ya
%127 = fmul double %125, %126
%128 = call double @llvm.fmuladd.f64(double %123, double %124, double %127)
%129 = load double, double* @linedist.za
%130 = load double, double* @linedist.za
%131 = call double @llvm.fmuladd.f64(double %129, double %130, double %128)
%132 = call double @sqrt(double %131)
store double %132, double* @linedist.la
%133 = load double, double* @linedist.la
%134 = fcmp une double %133, 0.000000e+00
br i1 %134, label %135, label %145
135: ; preds = %115
%136 = load double, double* @linedist.la
%137 = load double, double* @linedist.xa
%138 = fdiv double %137, %136
store double %138, double* @linedist.xa
%139 = load double, double* @linedist.la
%140 = load double, double* @linedist.ya
%141 = fdiv double %140, %139
store double %141, double* @linedist.ya
%142 = load double, double* @linedist.la
%143 = load double, double* @linedist.za
%144 = fdiv double %143, %142
store double %144, double* @linedist.za
br label %145
145: ; preds = %135, %115
br label %146
146: ; preds = %145, %100
%147 = load double, double* @linedist.la
%148 = fcmp une double %147, 0.000000e+00
br i1 %148, label %149, label %289
149: ; preds = %146
%150 = load double, double* %14
%151 = load double, double* %15
%152 = load double, double* %16
%153 = load double, double* @linedist.xa
%154 = load double, double* @linedist.ya
%155 = load double, double* @linedist.za
%156 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %150, double %151, double %152, double %153, double %154, double %155)
%157 = sitofp i32 %156 to double
store double %157, double* %31
%158 = load double, double* %14
%159 = load double, double* %31
%160 = load double, double* @linedist.xa
%161 = fneg double %159
%162 = call double @llvm.fmuladd.f64(double %161, double %160, double %158)
store double %162, double* %17
%163 = load double, double* %15
%164 = load double, double* %31
%165 = load double, double* @linedist.ya
%166 = fneg double %164
%167 = call double @llvm.fmuladd.f64(double %166, double %165, double %163)
store double %167, double* %18
%168 = load double, double* %16
%169 = load double, double* %31
%170 = load double, double* @linedist.za
%171 = fneg double %169
%172 = call double @llvm.fmuladd.f64(double %171, double %170, double %168)
store double %172, double* %19
%173 = load double, double* %17
%174 = load double, double* %17
%175 = load double, double* %18
%176 = load double, double* %18
%177 = fmul double %175, %176
%178 = call double @llvm.fmuladd.f64(double %173, double %174, double %177)
%179 = load double, double* %19
%180 = load double, double* %19
%181 = call double @llvm.fmuladd.f64(double %179, double %180, double %178)
%182 = call double @sqrt(double %181)
store double %182, double* %20
%183 = load double, double* %20
%184 = fcmp une double %183, 0.000000e+00
br i1 %184, label %185, label %288
185: ; preds = %149
%186 = load double, double* %20
%187 = load double, double* %17
%188 = fdiv double %187, %186
store double %188, double* %17
%189 = load double, double* %20
%190 = load double, double* %18
%191 = fdiv double %190, %189
store double %191, double* %18
%192 = load double, double* %20
%193 = load double, double* %19
%194 = fdiv double %193, %192
store double %194, double* %19
%195 = load double, double* @linedist.x1
%196 = load double, double* @linedist.y1
%197 = load double, double* @linedist.z1
%198 = load double, double* %17
%199 = load double, double* %18
%200 = load double, double* %19
%201 = call i32 (double, double, double, double, double, double, double*, double*, double*, ...) bitcast (i32 (...)* @crossproduct to i32 (double, double, double, double, double, double, double*, double*, double*, ...)*)(double %195, double %196, double %197, double %198, double %199, double %200, double* %21, double* %22, double* %23)
%202 = load double, double* %21
%203 = load double, double* %22
%204 = load double, double* %23
%205 = load double, double* @linedist.xa
%206 = load double, double* @linedist.ya
%207 = load double, double* @linedist.za
%208 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %202, double %203, double %204, double %205, double %206, double %207)
%209 = sitofp i32 %208 to double
store double %209, double* %27
%210 = load double, double* %17
%211 = load double, double* %18
%212 = load double, double* %19
%213 = load double, double* @linedist.x2
%214 = load double, double* @linedist.y2
%215 = load double, double* @linedist.z2
%216 = call i32 (double, double, double, double, double, double, double*, double*, double*, ...) bitcast (i32 (...)* @crossproduct to i32 (double, double, double, double, double, double, double*, double*, double*, ...)*)(double %210, double %211, double %212, double %213, double %214, double %215, double* %24, double* %25, double* %26)
%217 = load double, double* %24
%218 = load double, double* %25
%219 = load double, double* %26
%220 = load double, double* @linedist.xa
%221 = load double, double* @linedist.ya
%222 = load double, double* @linedist.za
%223 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %217, double %218, double %219, double %220, double %221, double %222)
%224 = sitofp i32 %223 to double
store double %224, double* %28
%225 = load double, double* %27
%226 = fcmp oge double %225, 0.000000e+00
br i1 %226, label %227, label %236
227: ; preds = %185
%228 = load double, double* %28
%229 = fcmp oge double %228, 0.000000e+00
br i1 %229, label %230, label %236
230: ; preds = %227
%231 = load double, double* %31
%232 = call double @llvm.fabs.f64(double %231)
%233 = load double, double* %20
%234 = fdiv double %232, %233
%235 = call double @atan(double %234)
store double %235, double* %7
br label %308
236: ; preds = %227, %185
%237 = load double, double* @linedist.x1
%238 = load double, double* @linedist.y1
%239 = load double, double* @linedist.z1
%240 = load double, double* %17
%241 = load double, double* %18
%242 = load double, double* %19
%243 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %237, double %238, double %239, double %240, double %241, double %242)
%244 = sitofp i32 %243 to double
store double %244, double* %29
%245 = load double, double* @linedist.x2
%246 = load double, double* @linedist.y2
%247 = load double, double* @linedist.z2
%248 = load double, double* %17
%249 = load double, double* %18
%250 = load double, double* %19
%251 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %245, double %246, double %247, double %248, double %249, double %250)
%252 = sitofp i32 %251 to double
store double %252, double* %30
%253 = load double, double* %27
%254 = call double @llvm.fabs.f64(double %253)
store double %254, double* %27
%255 = load double, double* %28
%256 = call double @llvm.fabs.f64(double %255)
store double %256, double* %28
%257 = load double, double* %29
%258 = fcmp olt double %257, 0.000000e+00
br i1 %258, label %259, label %262
259: ; preds = %236
%260 = load double, double* %27
%261 = fsub double 2.000000e+00, %260
store double %261, double* %27
br label %262
262: ; preds = %259, %236
%263 = load double, double* %30
%264 = fcmp olt double %263, 0.000000e+00
br i1 %264, label %265, label %268
265: ; preds = %262
%266 = load double, double* %28
%267 = fsub double 2.000000e+00, %266
store double %267, double* %28
br label %268
268: ; preds = %265, %262
%269 = load double, double* %27
%270 = call double @llvm.fabs.f64(double %269)
%271 = load double, double* %28
%272 = call double @llvm.fabs.f64(double %271)
%273 = fcmp olt double %270, %272
br i1 %273, label %274, label %281
274: ; preds = %268
%275 = load double, double* %8
%276 = load double, double* %9
%277 = load double, double* %12
%278 = load double, double* %13
%279 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @gcdist to i32 (double, double, double, double, ...)*)(double %275, double %276, double %277, double %278)
%280 = sitofp i32 %279 to double
store double %280, double* %7
br label %308
281: ; preds = %268
%282 = load double, double* %10
%283 = load double, double* %11
%284 = load double, double* %12
%285 = load double, double* %13
%286 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @gcdist to i32 (double, double, double, double, ...)*)(double %282, double %283, double %284, double %285)
%287 = sitofp i32 %286 to double
store double %287, double* %7
br label %308
288: ; preds = %149
store double 0x3FF921FB54442D18, double* %7
br label %308
289: ; preds = %146
%290 = load double, double* @linedist.x1
%291 = load double, double* @linedist.y1
%292 = load double, double* @linedist.z1
%293 = load double, double* @linedist.x2
%294 = load double, double* @linedist.y2
%295 = load double, double* @linedist.z2
%296 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %290, double %291, double %292, double %293, double %294, double %295)
%297 = sitofp i32 %296 to double
store double %297, double* %31
%298 = load double, double* %31
%299 = fcmp oge double %298, 0.000000e+00
br i1 %299, label %300, label %307
300: ; preds = %289
%301 = load double, double* %8
%302 = load double, double* %9
%303 = load double, double* %12
%304 = load double, double* %13
%305 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @gcdist to i32 (double, double, double, double, ...)*)(double %301, double %302, double %303, double %304)
%306 = sitofp i32 %305 to double
store double %306, double* %7
br label %308
307: ; preds = %289
store double 0.000000e+00, double* %7
br label %308
308: ; preds = %307, %300, %288, %281, %274, %230
%309 = load double, double* %7
ret double %309
}

LLVM IR (-O2):
@linedist._lat1 = internal unnamed_addr global double -9.999000e+03
@linedist._lat2 = internal unnamed_addr global double -9.999000e+03
@linedist._lon1 = internal unnamed_addr global double -9.999000e+03
@linedist._lon2 = internal unnamed_addr global double -9.999000e+03
@linedist.x1 = internal unnamed_addr global double 0.000000e+00
@linedist.y1 = internal unnamed_addr global double 0.000000e+00
@linedist.z1 = internal unnamed_addr global double 0.000000e+00
@linedist.x2 = internal unnamed_addr global double 0.000000e+00
@linedist.y2 = internal unnamed_addr global double 0.000000e+00
@linedist.z2 = internal unnamed_addr global double 0.000000e+00
@linedist.xa = internal global double 0.000000e+00
@linedist.ya = internal global double 0.000000e+00
@linedist.za = internal global double 0.000000e+00
@linedist.la = internal unnamed_addr global double 0.000000e+00
define double @linedist(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = bitcast double* %7 to i8*
%14 = bitcast double* %8 to i8*
%15 = bitcast double* %9 to i8*
%16 = bitcast double* %10 to i8*
%17 = bitcast double* %11 to i8*
%18 = bitcast double* %12 to i8*
%19 = insertelement <4 x double> poison, double %0, i64 0
%20 = insertelement <4 x double> %19, double %2, i64 1
%21 = insertelement <4 x double> %20, double %1, i64 2
%22 = insertelement <4 x double> %21, double %3, i64 3
%23 = fmul <4 x double> %22, <double 0x400921FB54442D18, double 0x400921FB54442D18, double 0x400921FB54442D18, double 0x400921FB54442D18>
%24 = fdiv <4 x double> %23, <double 1.800000e+02, double 1.800000e+02, double 1.800000e+02, double 1.800000e+02>
%25 = fmul double %4, 0x400921FB54442D18
%26 = fdiv double %25, 1.800000e+02
%27 = fmul double %5, 0x400921FB54442D18
%28 = fdiv double %27, 1.800000e+02
%29 = load double, double* @linedist._lat1
%30 = load double, double* @linedist._lat2
%31 = load double, double* @linedist._lon1
%32 = load double, double* @linedist._lon2
%33 = insertelement <4 x double> poison, double %29, i64 0
%34 = insertelement <4 x double> %33, double %30, i64 1
%35 = insertelement <4 x double> %34, double %31, i64 2
%36 = insertelement <4 x double> %35, double %32, i64 3
%37 = fcmp oeq <4 x double> %24, %36
%38 = freeze <4 x i1> %37
%39 = bitcast <4 x i1> %38 to i4
%40 = icmp eq i4 %39, -1
br i1 %40, label %60, label %41
41: ; preds = %6
%42 = extractelement <4 x double> %24, i64 0
store double %42, double* @linedist._lat1
%43 = extractelement <4 x double> %24, i64 1
store double %43, double* @linedist._lat2
%44 = extractelement <4 x double> %24, i64 2
store double %44, double* @linedist._lon1
%45 = extractelement <4 x double> %24, i64 3
store double %45, double* @linedist._lon2
%46 = tail call double @cos(double %44)
%47 = tail call double @cos(double %42)
%48 = fmul double %46, %47
store double %48, double* @linedist.x1
%49 = tail call double @sin(double %42)
store double %49, double* @linedist.y1
%50 = tail call double @sin(double %44)
%51 = tail call double @cos(double %42)
%52 = fmul double %50, %51
store double %52, double* @linedist.z1
%53 = tail call double @cos(double %45)
%54 = tail call double @cos(double %43)
%55 = fmul double %53, %54
store double %55, double* @linedist.x2
%56 = tail call double @sin(double %43)
store double %56, double* @linedist.y2
%57 = tail call double @sin(double %45)
%58 = tail call double @cos(double %43)
%59 = fmul double %57, %58
store double %59, double* @linedist.z2
br label %60
60: ; preds = %6, %41
%61 = tail call double @cos(double %28)
%62 = tail call double @cos(double %26)
%63 = fmul double %61, %62
%64 = tail call double @sin(double %26)
%65 = tail call double @sin(double %28)
%66 = tail call double @cos(double %26)
%67 = fmul double %65, %66
br i1 %40, label %68, label %70
68: ; preds = %60
%69 = load double, double* @linedist.la
br label %93
70: ; preds = %60
%71 = load double, double* @linedist.x1
%72 = load double, double* @linedist.y1
%73 = load double, double* @linedist.z1
%74 = load double, double* @linedist.x2
%75 = load double, double* @linedist.y2
%76 = load double, double* @linedist.z2
%77 = tail call i32 (double, double, double, double, double, double, double*, double*, double*, ...) bitcast (i32 (...)* @crossproduct to i32 (double, double, double, double, double, double, double*, double*, double*, ...)*)(double %71, double %72, double %73, double %74, double %75, double %76, double* @linedist.xa, double* @linedist.ya, double* @linedist.za)
%78 = load double, double* @linedist.xa
%79 = load double, double* @linedist.ya
%80 = fmul double %79, %79
%81 = tail call double @llvm.fmuladd.f64(double %78, double %78, double %80)
%82 = load double, double* @linedist.za
%83 = tail call double @llvm.fmuladd.f64(double %82, double %82, double %81)
%84 = tail call double @sqrt(double %83)
store double %84, double* @linedist.la
%85 = fcmp une double %84, 0.000000e+00
br i1 %85, label %86, label %93
86: ; preds = %70
%87 = load double, double* @linedist.xa
%88 = fdiv double %87, %84
store double %88, double* @linedist.xa
%89 = load double, double* @linedist.ya
%90 = fdiv double %89, %84
store double %90, double* @linedist.ya
%91 = load double, double* @linedist.za
%92 = fdiv double %91, %84
store double %92, double* @linedist.za
br label %93
93: ; preds = %86, %68, %70
%94 = phi double [ %84, %70 ], [ %69, %68 ], [ %84, %86 ]
%95 = fcmp une double %94, 0.000000e+00
br i1 %95, label %96, label %179
96: ; preds = %93
%97 = load double, double* @linedist.xa
%98 = load double, double* @linedist.ya
%99 = load double, double* @linedist.za
%100 = tail call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %63, double %64, double %67, double %97, double %98, double %99)
%101 = sitofp i32 %100 to double
%102 = load double, double* @linedist.xa
%103 = fneg double %101
%104 = tail call double @llvm.fmuladd.f64(double %103, double %102, double %63)
%105 = load double, double* @linedist.ya
%106 = tail call double @llvm.fmuladd.f64(double %103, double %105, double %64)
%107 = load double, double* @linedist.za
%108 = tail call double @llvm.fmuladd.f64(double %103, double %107, double %67)
%109 = fmul double %106, %106
%110 = tail call double @llvm.fmuladd.f64(double %104, double %104, double %109)
%111 = tail call double @llvm.fmuladd.f64(double %108, double %108, double %110)
%112 = tail call double @sqrt(double %111)
%113 = fcmp une double %112, 0.000000e+00
br i1 %113, label %114, label %193
114: ; preds = %96
%115 = fdiv double %104, %112
%116 = fdiv double %106, %112
%117 = fdiv double %108, %112
%118 = load double, double* @linedist.x1
%119 = load double, double* @linedist.y1
%120 = load double, double* @linedist.z1
%121 = call i32 (double, double, double, double, double, double, double*, double*, double*, ...) bitcast (i32 (...)* @crossproduct to i32 (double, double, double, double, double, double, double*, double*, double*, ...)*)(double %118, double %119, double %120, double %115, double %116, double %117, double* %7, double* %8, double* %9)
%122 = load double, double* %7
%123 = load double, double* %8
%124 = load double, double* %9
%125 = load double, double* @linedist.xa
%126 = load double, double* @linedist.ya
%127 = load double, double* @linedist.za
%128 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %122, double %123, double %124, double %125, double %126, double %127)
%129 = load double, double* @linedist.x2
%130 = load double, double* @linedist.y2
%131 = load double, double* @linedist.z2
%132 = call i32 (double, double, double, double, double, double, double*, double*, double*, ...) bitcast (i32 (...)* @crossproduct to i32 (double, double, double, double, double, double, double*, double*, double*, ...)*)(double %115, double %116, double %117, double %129, double %130, double %131, double* %10, double* %11, double* %12)
%133 = load double, double* %10
%134 = load double, double* %11
%135 = load double, double* %12
%136 = load double, double* @linedist.xa
%137 = load double, double* @linedist.ya
%138 = load double, double* @linedist.za
%139 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %133, double %134, double %135, double %136, double %137, double %138)
%140 = icmp sgt i32 %128, -1
%141 = icmp sgt i32 %139, -1
%142 = select i1 %140, i1 %141, i1 false
br i1 %142, label %143, label %147
143: ; preds = %114
%144 = call double @llvm.fabs.f64(double %101)
%145 = fdiv double %144, %112
%146 = call double @atan(double %145)
br label %193
147: ; preds = %114
%148 = insertelement <2 x i32> poison, i32 %128, i64 0
%149 = insertelement <2 x i32> %148, i32 %139, i64 1
%150 = sitofp <2 x i32> %149 to <2 x double>
%151 = load double, double* @linedist.x1
%152 = load double, double* @linedist.y1
%153 = load double, double* @linedist.z1
%154 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %151, double %152, double %153, double %115, double %116, double %117)
%155 = load double, double* @linedist.x2
%156 = load double, double* @linedist.y2
%157 = load double, double* @linedist.z2
%158 = call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %155, double %156, double %157, double %115, double %116, double %117)
%159 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %150)
%160 = insertelement <2 x i32> poison, i32 %154, i64 0
%161 = insertelement <2 x i32> %160, i32 %158, i64 1
%162 = icmp slt <2 x i32> %161, zeroinitializer
%163 = fsub <2 x double> <double 2.000000e+00, double 2.000000e+00>, %159
%164 = select <2 x i1> %162, <2 x double> %163, <2 x double> %159
%165 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %164)
%166 = extractelement <2 x double> %165, i64 0
%167 = extractelement <2 x double> %165, i64 1
%168 = fcmp olt double %166, %167
br i1 %168, label %169, label %174
169: ; preds = %147
%170 = extractelement <4 x double> %24, i64 0
%171 = extractelement <4 x double> %24, i64 2
%172 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @gcdist to i32 (double, double, double, double, ...)*)(double %170, double %171, double %26, double %28)
%173 = sitofp i32 %172 to double
br label %193
174: ; preds = %147
%175 = extractelement <4 x double> %24, i64 1
%176 = extractelement <4 x double> %24, i64 3
%177 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @gcdist to i32 (double, double, double, double, ...)*)(double %175, double %176, double %26, double %28)
%178 = sitofp i32 %177 to double
br label %193
179: ; preds = %93
%180 = load double, double* @linedist.x1
%181 = load double, double* @linedist.y1
%182 = load double, double* @linedist.z1
%183 = load double, double* @linedist.x2
%184 = load double, double* @linedist.y2
%185 = load double, double* @linedist.z2
%186 = tail call i32 (double, double, double, double, double, double, ...) bitcast (i32 (...)* @dotproduct to i32 (double, double, double, double, double, double, ...)*)(double %180, double %181, double %182, double %183, double %184, double %185)
%187 = icmp sgt i32 %186, -1
br i1 %187, label %188, label %193
188: ; preds = %179
%189 = extractelement <4 x double> %24, i64 0
%190 = extractelement <4 x double> %24, i64 2
%191 = tail call i32 (double, double, double, double, ...) bitcast (i32 (...)* @gcdist to i32 (double, double, double, double, ...)*)(double %189, double %190, double %26, double %28)
%192 = sitofp i32 %191 to double
br label %193
193: ; preds = %179, %96, %188, %174, %169, %143
%194 = phi double [ %146, %143 ], [ %173, %169 ], [ %178, %174 ], [ %192, %188 ], [ 0x3FF921FB54442D18, %96 ], [ 0.000000e+00, %179 ]
ret double %194
}