// File: Luthaf[P]zeopp/geometry.cc
// Function: calcSphereDistance(Point, Point, double)
double calcSphereDistance(Point p1, Point p2, double circRad){
  pair<double,double> coords1 = findLongAndLat(p1);
  pair<double,double> coords2 = findLongAndLat(p2);
  double phi1 = coords1.first; double phi2 = coords2.first;
  double lambda1 = coords1.second; double lambda2 = coords2.second;
  double deltaLambda = lambda1-lambda2;

  double deltaSigma = atan( (sqrt (pow(cos(phi1)*sin(deltaLambda),2.0) +  pow(cos(phi2)*sin(phi1)-sin(phi2)*cos(phi1)*cos(deltaLambda),2))) 
			    / (sin(phi1)*sin(phi2) + cos(phi1)*cos(phi2)*cos(deltaLambda)));
  return circRad*deltaSigma;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
leaq 0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq 0x10(%rbp), %rax
movsd %xmm0, -0x8(%rbp)
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
leaq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xecda0
movq -0xe8(%rbp), %rax
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x10(%rbp)
movq (%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x58(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xecda0
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x70(%rbp), %xmm0
subsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x60(%rbp), %xmm0
callq 0x5970
movsd %xmm0, -0xe0(%rbp)
movsd -0x80(%rbp), %xmm0
callq 0x5140
movaps %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x105432(%rip), %xmm1   # 0x1f2048
callq 0x58e0
movsd %xmm0, -0xb8(%rbp)
movsd -0x68(%rbp), %xmm0
callq 0x5970
movsd %xmm0, -0xc0(%rbp)
movsd -0x60(%rbp), %xmm0
callq 0x5140
movsd %xmm0, -0xc8(%rbp)
movsd -0x68(%rbp), %xmm0
callq 0x5140
movsd %xmm0, -0xd8(%rbp)
movsd -0x60(%rbp), %xmm0
callq 0x5970
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x80(%rbp), %xmm0
callq 0x5970
movsd -0xd0(%rbp), %xmm1
movsd -0xc8(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0xc0(%rbp), %xmm0
mulsd %xmm3, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl $0x2, %edi
callq 0x850c0
movaps %xmm0, %xmm1
movsd -0xb8(%rbp), %xmm0
addsd %xmm1, %xmm0
callq 0x53f0
movsd %xmm0, -0x90(%rbp)
movsd -0x60(%rbp), %xmm0
callq 0x5140
movsd %xmm0, -0xa0(%rbp)
movsd -0x68(%rbp), %xmm0
callq 0x5140
movsd %xmm0, -0x98(%rbp)
movsd -0x60(%rbp), %xmm0
callq 0x5970
movsd %xmm0, -0xb0(%rbp)
movsd -0x68(%rbp), %xmm0
callq 0x5970
movaps %xmm0, %xmm1
movsd -0xb0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x80(%rbp), %xmm0
callq 0x5970
movsd -0xa8(%rbp), %xmm2
movsd -0xa0(%rbp), %xmm1
movsd -0x98(%rbp), %xmm3
movaps %xmm0, %xmm4
movsd -0x90(%rbp), %xmm0
mulsd %xmm4, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x5440
movsd %xmm0, -0x88(%rbp)
movsd -0x8(%rbp), %xmm0
mulsd -0x88(%rbp), %xmm0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nop