// File: /workspace/github_cpp_makefile_star2_O1/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 0x34712(%rip), %r14     # 0x43c70
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xed92
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0xed92
movq %r15, %rdi
callq 0xf878
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
callq 0xf87e
movsd %xmm0, (%rsp)
movq %r15, %rdi
callq 0xf878
movaps %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0xf87e
movaps %xmm0, 0x40(%rsp)
movq %rbx, %rdi
callq 0xf878
movsd %xmm0, 0x58(%rsp)
movq %rbx, %rdi
callq 0xf87e
movsd %xmm0, 0x30(%rsp)
movq %rbx, %rdi
callq 0xf878
movaps %xmm0, 0x60(%rsp)
movq %rbx, %rdi
callq 0xf87e
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 0x220d6(%rip), %xmm1    # 0x31710
mulpd 0x220de(%rip), %xmm1    # 0x31720
addpd %xmm0, %xmm1
mulpd 0x220e2(%rip), %xmm1    # 0x31730
divpd 0x220ea(%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 0x2206e(%rip), %xmm0    # 0x31710
mulpd 0x22076(%rip), %xmm0    # 0x31720
addpd %xmm1, %xmm0
mulpd 0x2207a(%rip), %xmm0    # 0x31730
divpd 0x22082(%rip), %xmm0    # 0x31740
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
subsd %xmm1, %xmm0
callq 0x56c0
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 0x56c0
movsd %xmm0, (%rsp)
movapd 0x30(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
callq 0x56c0
movsd 0x21c08(%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 0x22019(%rip), %xmm2    # 0x31750
movapd %xmm2, %xmm0
callq 0x5380
mulsd 0x22010(%rip), %xmm0    # 0x31758
addsd 0x21bc8(%rip), %xmm0    # 0x31318
callq 0x5190
cvttsd2si %xmm0, %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq