// File: /workspace/github_cpp_makefile_star2_O3/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 0x346ef(%rip), %r14     # 0x43c60
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xed7a
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0xed7a
movq %r15, %rdi
callq 0xf870
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
callq 0xf876
movsd %xmm0, (%rsp)
movq %r15, %rdi
callq 0xf870
movaps %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0xf876
movaps %xmm0, 0x40(%rsp)
movq %rbx, %rdi
callq 0xf870
movsd %xmm0, 0x58(%rsp)
movq %rbx, %rdi
callq 0xf876
movsd %xmm0, 0x30(%rsp)
movq %rbx, %rdi
callq 0xf870
movaps %xmm0, 0x60(%rsp)
movq %rbx, %rdi
callq 0xf876
movaps %xmm0, 0x70(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x5190
movaps %xmm0, 0x20(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x5190
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 0x220c3(%rip), %xmm1    # 0x31710
mulpd 0x220cb(%rip), %xmm1    # 0x31720
addpd %xmm0, %xmm1
mulpd 0x220cf(%rip), %xmm1    # 0x31730
divpd 0x220d7(%rip), %xmm1    # 0x31740
movapd %xmm1, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x5190
movaps %xmm0, (%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x5190
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 0x2205b(%rip), %xmm0    # 0x31710
mulpd 0x22063(%rip), %xmm0    # 0x31720
addpd %xmm1, %xmm0
mulpd 0x22067(%rip), %xmm0    # 0x31730
divpd 0x2206f(%rip), %xmm0    # 0x31740
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
subsd %xmm1, %xmm0
callq 0x56b0
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 0x56b0
movsd %xmm0, (%rsp)
movapd 0x30(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
callq 0x56b0
movsd 0x21bf5(%rip), %xmm3    # 0x31318
movapd %xmm3, %xmm1
movsd 0x40(%rsp), %xmm2
subsd %xmm2, %xmm1
addsd %xmm3, %xmm2
mulsd %xmm0, %xmm1
mulsd (%rsp), %xmm2
subsd %xmm1, %xmm2
mulsd 0x22006(%rip), %xmm2    # 0x31750
movapd %xmm2, %xmm0
callq 0x5370
mulsd 0x21ffd(%rip), %xmm0    # 0x31758
addsd 0x21bb5(%rip), %xmm0    # 0x31318
callq 0x5190
cvttsd2si %xmm0, %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq