// File: /workspace/github_cpp_makefile_star2_O2/GAStudyGroup[P]GPX2/src/base/sources/GAUtils.cpp
// Function: GAUtils::nearestNeighbor()
vector<int> GAUtils::nearestNeighbor() {
    vector<int> cityList{Globals::map.getCityList()},tmp;
    int delta = cityList.size()*0.05;
    delta = delta<1?1:delta;

    uniform_int_distribution<int> dist(0,cityList.size()-1);
    uniform_int_distribution<int> distDelta(0,delta);

    int choosenCity = cityList[dist(Globals::urng)];
    tmp.push_back(choosenCity);
    cityList.erase(remove(cityList.begin(),cityList.end(),choosenCity),cityList.end());

    do{

        sort(cityList.begin(),cityList.end(),[choosenCity](int a,int b){
            return distance(a,choosenCity) < distance(b,choosenCity);
        });

        unsigned next = distDelta(Globals::urng);

        if(next >= cityList.size()){
            next = cityList.size()-1;
        }

        choosenCity = cityList[next];

        tmp.push_back(choosenCity);
        cityList.erase(remove(cityList.begin(),cityList.end(),choosenCity),cityList.end());

    }while(!cityList.empty());

    return tmp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x366d8(%rip), %rsi     # 0x3dc50
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xbb16
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movq 0x8(%r14), %rax
subq (%r14), %rax
movups %xmm0, (%rbx)
sarq $0x2, %rax
leal -0x1(%rax), %ecx
leaq 0x30(%rsp), %rdi
andl $0x0, (%rdi)
movq %rax, %xmm0
punpckldq 0x1fd0d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1fd15(%rip), %xmm0    # 0x272d0
movl %ecx, 0x4(%rdi)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1fd0e(%rip), %xmm1    # 0x272e0
cvttsd2si %xmm1, %eax
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
andl $0x0, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
leaq 0x352d9(%rip), %rsi     # 0x3c8c8
callq 0x94da
cltq
movq 0x10(%rsp), %rcx
movl (%rcx,%rax,4), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x94e2
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xa385
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rdx
movq %rax, %rsi
callq 0x9500
leaq 0x10(%rsp), %rax
movq (%rax), %r12
movq 0x8(%rax), %rbp
leaq 0xc(%rsp), %r13
cmpq %rbp, %r12
je 0x76b2
movl 0xc(%rsp), %r15d
movq %rbp, %r14
subq %r12, %r14
movq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %rbp, %rsi
movl %r15d, %ecx
callq 0x8d6d
cmpq $0x41, %r14
jl 0x76a4
leaq 0x40(%r12), %r14
movq %r12, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x90b4
cmpq %rbp, %r14
je 0x76b2
movq %r14, %rdi
movl %r15d, %esi
callq 0x9137
addq $0x4, %r14
jmp 0x768e
movq %r12, %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0x90b4
leaq 0x28(%rsp), %rdi
leaq 0x3520a(%rip), %rsi     # 0x3c8c8
callq 0x94da
movl %eax, %ecx
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
leal -0x1(%rsi), %edi
cmpq %rcx, %rsi
cmoval %eax, %edi
movl (%rdx,%rdi,4), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x94e2
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r13, %rdx
callq 0xa385
movq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x9500
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rbp
cmpq %rbp, %r12
jne 0x7643
leaq 0x10(%rsp), %rdi
callq 0x6e4c
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7752
jmp 0x7752
jmp 0x7752
jmp 0x7752
jmp 0x7752
jmp 0x7752
jmp 0x7752
movq %rax, %r14
movq %rbx, %rdi
callq 0x6e4c
leaq 0x10(%rsp), %rdi
callq 0x6e4c
movq %r14, %rdi
callq 0x5610