// File: GAStudyGroup[P]GPX2/src/base/sources/Utils.cpp
// Function: GEO(int, int)
int GEO(int p1,int p2){
    // double PI{3.141592};
    City c1{Globals::map.getCityById(p1)},c2{Globals::map.getCityById(p2)};
    double PI{M_PI};
    double RRR{6378.388};
    double lat_1,lng_1,lat_2,lng_2;

    {
        auto conv = [PI](int deg, double min){
            return(PI * (deg + (5.0*(min/3.0)))/180.0);
        };

        int deg_x1{(int)round(c1.getX())},deg_y1{(int)round(c1.getY())};
        double min_x1{deg_x1-c1.getX()},min_y1{deg_y1-c1.getY()}; 
        int deg_x2{(int)round(c2.getX())},deg_y2{(int)round(c2.getY())};
        double min_x2{deg_x2-c2.getX()},min_y2{deg_y2-c2.getY()};

        lat_1 = conv(deg_x1,min_x1);
        lng_1 = conv(deg_y1,min_y1);

        lat_2 = conv(deg_x2,min_x2);
        lng_2 = conv(deg_y2,min_y2);
    }

    double q1 = cos(lng_1 - lng_2), q2 = cos(lat_1 - lat_2), q3 = cos(lat_1 + lat_2);

    return(round((RRR*acos(0.5*((1.0+q1)*q2 - (1.0-q1)*q3)))+1.0));
}

// Assembly:
subq $0xe8, %rsp
movl %edi, 0xe4(%rsp)
movl %esi, 0xe0(%rsp)
movl 0xe4(%rsp), %edx
leaq 0xc8(%rsp), %rdi
leaq 0x82785(%rip), %rsi     # 0x9dd90
callq 0x19740
movl 0xe0(%rsp), %edx
leaq 0xb0(%rsp), %rdi
leaq 0x8276a(%rip), %rsi     # 0x9dd90
callq 0x19740
movsd 0x590b5(%rip), %xmm0    # 0x746e8
movsd %xmm0, 0xa8(%rsp)
movsd 0x5909c(%rip), %xmm0    # 0x746e0
movsd %xmm0, 0xa0(%rsp)
movsd 0xa8(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1bb50
callq 0x61f0
cvttsd2si %xmm0, %eax
movl %eax, 0x74(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1bb60
callq 0x61f0
cvttsd2si %xmm0, %eax
movl %eax, 0x70(%rsp)
cvtsi2sdl 0x74(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1bb50
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
cvtsi2sdl 0x70(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1bb60
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x1bb50
callq 0x61f0
cvttsd2si %xmm0, %eax
movl %eax, 0x5c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x1bb60
callq 0x61f0
cvttsd2si %xmm0, %eax
movl %eax, 0x58(%rsp)
cvtsi2sdl 0x5c(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x1bb50
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
cvtsi2sdl 0x58(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x1bb60
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movl 0x74(%rsp), %esi
movsd 0x68(%rsp), %xmm0
leaq 0x78(%rsp), %rdi
callq 0x1b9f0
movsd %xmm0, 0x98(%rsp)
movl 0x70(%rsp), %esi
movsd 0x60(%rsp), %xmm0
leaq 0x78(%rsp), %rdi
callq 0x1b9f0
movsd %xmm0, 0x90(%rsp)
movl 0x5c(%rsp), %esi
movsd 0x50(%rsp), %xmm0
leaq 0x78(%rsp), %rdi
callq 0x1b9f0
movsd %xmm0, 0x88(%rsp)
movl 0x58(%rsp), %esi
movsd 0x48(%rsp), %xmm0
leaq 0x78(%rsp), %rdi
callq 0x1b9f0
movsd %xmm0, 0x80(%rsp)
movsd 0x90(%rsp), %xmm0
subsd 0x80(%rsp), %xmm0
callq 0x68b0
movsd %xmm0, 0x40(%rsp)
movsd 0x98(%rsp), %xmm0
subsd 0x88(%rsp), %xmm0
callq 0x68b0
movsd %xmm0, 0x38(%rsp)
movsd 0x98(%rsp), %xmm0
addsd 0x88(%rsp), %xmm0
callq 0x68b0
movsd %xmm0, 0x30(%rsp)
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x58a5a(%rip), %xmm1    # 0x742b0
addsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x58a46(%rip), %xmm0    # 0x742b0
subsd 0x40(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x58e3b(%rip), %xmm0    # 0x746d8
mulsd %xmm1, %xmm0
callq 0x6470
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x589f5(%rip), %xmm1    # 0x742b0
addsd %xmm1, %xmm0
callq 0x61f0
cvttsd2si %xmm0, %eax
addq $0xe8, %rsp
retq