// File: 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:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x68(%rsp)
movq %rdi, %rax
movq %rax, 0x60(%rsp)
movq %rdi, 0x140(%rsp)
leaq 0x92e8d(%rip), %rsi     # 0x9dd90
leaq 0x128(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x195b0
movq 0x68(%rsp), %rdi
movb $0x0, 0x127(%rsp)
callq 0xfdf0
movq 0x70(%rsp), %rdi
callq 0x107e0
movq %rax, %xmm0
movaps 0x69383(%rip), %xmm1    # 0x742c0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x69387(%rip), %xmm1    # 0x742d0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x69348(%rip), %xmm1    # 0x742a8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x120(%rsp)
cmpl $0x1, 0x120(%rsp)
jge 0xaf84
movl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0xaf8f
movl 0x120(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x107e0
movl %eax, %edx
decl %edx
leaq 0x118(%rsp), %rdi
xorl %esi, %esi
callq 0x10800
jmp 0xafbc
movl 0x120(%rsp), %edx
leaq 0x104(%rsp), %rdi
xorl %esi, %esi
callq 0x10800
jmp 0xafd4
leaq 0x91a2d(%rip), %rsi     # 0x9ca08
leaq 0x118(%rsp), %rdi
callq 0x10850
movl %eax, 0x58(%rsp)
jmp 0xafee
movl 0x58(%rsp), %eax
movslq %eax, %rsi
leaq 0x128(%rsp), %rdi
callq 0x10830
movq 0x68(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x100(%rsp)
leaq 0x100(%rsp), %rsi
callq 0x10880
jmp 0xb01f
leaq 0x128(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x10130
movq 0x48(%rsp), %rdi
movq %rax, 0xe8(%rsp)
callq 0x10160
movq %rax, 0xe0(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0x10990
movq %rax, 0x50(%rsp)
jmp 0xb06f
movq 0x50(%rsp), %rax
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x109f0
leaq 0x128(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x10160
movq %rax, 0xd0(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x109f0
movq 0x38(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movq 0xd8(%rsp), %rdx
callq 0x108f0
movq %rax, 0x40(%rsp)
jmp 0xb0e1
movq 0x40(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x128(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x10130
movq 0x30(%rsp), %rdi
movq %rax, 0xc0(%rsp)
callq 0x10160
movq %rax, 0xb8(%rsp)
movl 0x100(%rsp), %eax
movl %eax, 0xb4(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movl 0xb4(%rsp), %edx
callq 0xd3b0
jmp 0xb146
leaq 0x918bb(%rip), %rsi     # 0x9ca08
leaq 0x104(%rsp), %rdi
callq 0x10850
movl %eax, 0x2c(%rsp)
jmp 0xb160
movl 0x2c(%rsp), %eax
movl %eax, 0xb0(%rsp)
movl 0xb0(%rsp), %eax
movq %rax, 0x20(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x107e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jb 0xb1db
leaq 0x128(%rsp), %rdi
callq 0x107e0
subq $0x1, %rax
movl %eax, 0xb0(%rsp)
jmp 0xb1db
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
callq 0x9af0
leaq 0x128(%rsp), %rdi
callq 0x9af0
jmp 0xb325
movl 0xb0(%rsp), %eax
movl %eax, %esi
leaq 0x128(%rsp), %rdi
callq 0x10830
movq 0x68(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x100(%rsp)
leaq 0x100(%rsp), %rsi
callq 0x10880
jmp 0xb20e
leaq 0x128(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x10130
movq 0x10(%rsp), %rdi
movq %rax, 0x98(%rsp)
callq 0x10160
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0x10990
movq %rax, 0x18(%rsp)
jmp 0xb25e
movq 0x18(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x109f0
leaq 0x128(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x10160
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x109f0
movq (%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x108f0
movq %rax, 0x8(%rsp)
jmp 0xb2ce
movq 0x8(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x10a30
xorb $-0x1, %al
testb $0x1, %al
jne 0xb0ee
movb $0x1, 0x127(%rsp)
testb $0x1, 0x127(%rsp)
jne 0xb30b
movq 0x68(%rsp), %rdi
callq 0x9af0
leaq 0x128(%rsp), %rdi
callq 0x9af0
movq 0x60(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
movq 0x110(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)