// File: GAStudyGroup[P]GPX2/src/cross/AntColony/Ant.cpp
// Function: Ant::calcChance(int)
double Ant::calcChance(int nextCity){
    double pheromoneNext = AntMap::getPheromoneLevel(path.back(),nextCity);
    double niNext = 1.0/distance(path.back(),nextCity);
    double top = ((pow(pheromoneNext,AntConstants::alfa))*(pow(niNext,AntConstants::beta)));

    double bottom = 0.0;
    {
        double pheromoneTmp = 0.0;
        double niTmp = 0.0;
        for(unsigned city : Globals::map.getCityList()){
            if(find(path.begin(),path.end(),city) == path.end()){
                pheromoneTmp = AntMap::getPheromoneLevel(path.back(),city);
                niTmp = 1.0/distance(path.back(),city);
                bottom += ((pow(pheromoneTmp,AntConstants::alfa))*(pow(niTmp,AntConstants::beta)));
            }
        }   
    }
    return top/bottom;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movl %esi, 0xcc(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x1a9c0
movl (%rax), %edi
movl 0xcc(%rsp), %esi
callq 0x4f580
movq 0x20(%rsp), %rdi
movsd %xmm0, 0xc0(%rsp)
callq 0x1a9c0
movl (%rax), %edi
movl 0xcc(%rsp), %esi
callq 0x1b2d0
cvtsi2sd %eax, %xmm1
movsd 0x27aad(%rip), %xmm0    # 0x742b0
divsd %xmm1, %xmm0
movsd %xmm0, 0xb8(%rsp)
movsd 0xc0(%rsp), %xmm0
leaq 0x500e0(%rip), %rax     # 0x9c900
movsd (%rax), %xmm1
callq 0x6830
movsd %xmm0, 0x28(%rsp)
movsd 0xb8(%rsp), %xmm0
leaq 0x500c9(%rip), %rax     # 0x9c908
movsd (%rax), %xmm1
callq 0x6830
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xa8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x98(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x51502(%rip), %rsi     # 0x9dd90
callq 0x195b0
leaq 0x78(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdi
callq 0x10130
movq %rax, 0x70(%rsp)
movq 0x90(%rsp), %rdi
callq 0x10160
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x11c60
testb $0x1, %al
jne 0x4c8e6
leaq 0x78(%rsp), %rdi
callq 0x9af0
jmp 0x4ca4a
leaq 0x70(%rsp), %rdi
callq 0x11fc0
movq 0x20(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x64(%rsp)
callq 0x10130
movq 0x20(%rsp), %rdi
movq %rax, 0x50(%rsp)
callq 0x10160
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
leaq 0x64(%rsp), %rdx
callq 0x4e150
movq %rax, 0x18(%rsp)
jmp 0x4c92f
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0x58(%rsp)
callq 0x10160
movq %rax, 0x30(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x11aa0
testb $0x1, %al
jne 0x4c960
jmp 0x4ca39
movq 0x20(%rsp), %rdi
callq 0x1a9c0
movl (%rax), %edi
movl 0x64(%rsp), %esi
callq 0x4f580
movsd %xmm0, 0x10(%rsp)
jmp 0x4c97d
movq 0x20(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
callq 0x1a9c0
movl (%rax), %edi
movl 0x64(%rsp), %esi
callq 0x1b2d0
movl %eax, 0xc(%rsp)
jmp 0x4c9a7
movl 0xc(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x278f9(%rip), %xmm0    # 0x742b0
divsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0xa0(%rsp), %xmm0
leaq 0x4ff2c(%rip), %rax     # 0x9c900
movsd (%rax), %xmm1
callq 0x6830
movsd %xmm0, (%rsp)
movsd 0x98(%rsp), %xmm0
leaq 0x4ff16(%rip), %rax     # 0x9c908
movsd (%rax), %xmm1
callq 0x6830
movaps %xmm0, %xmm2
movsd (%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xa8(%rsp)
jmp 0x4ca39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x9af0
jmp 0x4ca64
jmp 0x4ca3b
leaq 0x70(%rsp), %rdi
callq 0x11f60
jmp 0x4c8c4
movsd 0xb0(%rsp), %xmm0
divsd 0xa8(%rsp), %xmm0
addq $0xd8, %rsp
retq
movq 0x40(%rsp), %rdi
callq 0x6850
nop