// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xb8, %rsp
movl %esi, %ebp
movl %edi, %edx
leaq 0x31952(%rip), %r14     # 0x3dc50
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xbb82
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0xbb82
movq %r15, %rdi
callq 0xc5fe
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
callq 0xc604
movsd %xmm0, (%rsp)
movq %r15, %rdi
callq 0xc5fe
movaps %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0xc604
movaps %xmm0, 0x40(%rsp)
movq %rbx, %rdi
callq 0xc5fe
movsd %xmm0, 0x58(%rsp)
movq %rbx, %rdi
callq 0xc604
movsd %xmm0, 0x30(%rsp)
movq %rbx, %rdi
callq 0xc5fe
movaps %xmm0, 0x60(%rsp)
movq %rbx, %rdi
callq 0xc604
movaps %xmm0, 0x70(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x5180
movaps %xmm0, 0x20(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x5180
movapd 0x20(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
movapd 0x10(%rsp), %xmm2
unpcklpd 0x60(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
movapd %xmm0, %xmm1
subpd %xmm2, %xmm1
divpd 0x1b306(%rip), %xmm1    # 0x276e0
mulpd 0x1b30e(%rip), %xmm1    # 0x276f0
addpd %xmm0, %xmm1
mulpd 0x1b312(%rip), %xmm1    # 0x27700
divpd 0x1b31a(%rip), %xmm1    # 0x27710
movapd %xmm1, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x5180
movaps %xmm0, (%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x5180
movapd (%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm1
movapd 0x40(%rsp), %xmm2
unpcklpd 0x70(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
movapd %xmm1, %xmm0
subpd %xmm2, %xmm0
divpd 0x1b29e(%rip), %xmm0    # 0x276e0
mulpd 0x1b2a6(%rip), %xmm0    # 0x276f0
addpd %xmm1, %xmm0
mulpd 0x1b2aa(%rip), %xmm0    # 0x27700
divpd 0x1b2b2(%rip), %xmm0    # 0x27710
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
subsd %xmm1, %xmm0
callq 0x5650
movsd %xmm0, 0x40(%rsp)
movapd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movapd %xmm1, 0x30(%rsp)
subsd %xmm1, %xmm0
callq 0x5650
movsd %xmm0, (%rsp)
movapd 0x30(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
callq 0x5650
movsd 0x1ae38(%rip), %xmm3    # 0x272e8
movapd %xmm3, %xmm1
movsd 0x40(%rsp), %xmm2
subsd %xmm2, %xmm1
addsd %xmm3, %xmm2
mulsd %xmm0, %xmm1
mulsd (%rsp), %xmm2
subsd %xmm1, %xmm2
mulsd 0x1b249(%rip), %xmm2    # 0x27720
movapd %xmm2, %xmm0
callq 0x5360
mulsd 0x1b240(%rip), %xmm0    # 0x27728
addsd 0x1adf8(%rip), %xmm0    # 0x272e8
callq 0x5180
cvttsd2si %xmm0, %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq