// File: /workspace/github_cpp_makefile_star2_O3/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 0x3b346(%rip), %rsi     # 0x43c60
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xece6
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 0x28967(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movl %ecx, 0x4(%rdi)
subpd 0x2896c(%rip), %xmm0    # 0x312d0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x28998(%rip), %xmm1    # 0x31310
cvttsd2si %xmm1, %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %edx, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
leaq 0x39f42(%rip), %rsi     # 0x428d8
movq %rdi, %rdx
callq 0xc0b4
cltq
movq 0x10(%rsp), %rcx
movl (%rcx,%rax,4), %eax
leaq 0xc(%rsp), %rdx
movl %eax, (%rdx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc1a6
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xc2c5
movq 0x18(%rsp), %r13
cmpq %r13, %rax
je 0x89df
movq %rax, 0x18(%rsp)
movq %rax, %r13
movq 0x10(%rsp), %r14
leaq 0x28(%rsp), %r15
cmpq %r13, %r14
je 0x8a52
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 0xaa2d
cmpq $0x41, %r12
jl 0x8a45
leaq 0x40(%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0xae34
cmpq %r13, %r12
je 0x8a52
movq %r12, %rdi
movl %ebp, %esi
callq 0xaec1
addq $0x4, %r12
jmp 0x8a30
movq %r14, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0xae34
movq %r15, %rdi
leaq 0x39e7c(%rip), %rsi     # 0x428d8
movq %r15, %rdx
callq 0xc0b4
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 0x8a9d
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x8aaa
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
callq 0xc1a6
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xc2c5
movq 0x18(%rsp), %r13
cmpq %r13, %rax
je 0x8ad0
movq %rax, 0x18(%rsp)
movq %rax, %r13
movq 0x10(%rsp), %r14
cmpq %r13, %r14
jne 0x89e9
testq %r14, %r14
je 0x8af3
movq 0x20(%rsp), %rsi
subq %r14, %rsi
movq %r14, %rdi
callq 0x53b0
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8b0f
jmp 0x8b0f
jmp 0x8b0f
jmp 0x8b0f
jmp 0x8b0f
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x8b26
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8b3d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq %r14, %rdi
callq 0x5660