// File: /workspace/github_cpp_makefile_star2_O1/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 0x3b37a(%rip), %rsi     # 0x43c70
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xecfe
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
leal -0x1(%rax), %ecx
xorl %edx, %edx
leaq 0x30(%rsp), %rdi
movl %edx, (%rdi)
movq %rax, %xmm0
punpckldq 0x2898b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movl %ecx, 0x4(%rdi)
subpd 0x28990(%rip), %xmm0    # 0x312d0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x289bc(%rip), %xmm1    # 0x31310
cvttsd2si %xmm1, %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %edx, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
leaq 0x39f76(%rip), %rsi     # 0x428e8
movq %rdi, %rdx
callq 0xc08c
cltq
movq 0x10(%rsp), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x899e
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x89ab
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xc17e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xc29d
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x89e1
movq 0x18(%rsp), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
addq %rsi, %rax
cmpq %rax, %rdx
je 0x89e1
movq %rax, 0x18(%rsp)
leaq 0x28(%rsp), %r15
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r13
cmpq %r13, %r14
je 0x8a59
movl 0xc(%rsp), %ebp
movq %r13, %r12
subq %r14, %r12
movq %r12, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r13, %rsi
movl %ebp, %ecx
callq 0xa9fb
cmpq $0x41, %r12
jl 0x8a4c
leaq 0x40(%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0xae18
cmpq %r13, %r12
je 0x8a59
movq %r12, %rdi
movl %ebp, %esi
callq 0xaea5
addq $0x4, %r12
jmp 0x8a37
movq %r14, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0xae18
movq %r15, %rdi
leaq 0x39e85(%rip), %rsi     # 0x428e8
movq %r15, %rdx
callq 0xc08c
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 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x8aa4
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x8ab1
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
callq 0xc17e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xc29d
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x8ae7
movq 0x18(%rsp), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
addq %rsi, %rax
cmpq %rax, %rdx
je 0x8ae7
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rdi
cmpq 0x18(%rsp), %rdi
jne 0x89e6
testq %rdi, %rdi
je 0x8b09
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8b25
jmp 0x8b25
jmp 0x8b25
jmp 0x8b25
jmp 0x8b25
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x8b3c
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x53c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8b53
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r14, %rdi
callq 0x5670