// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::swapTR(std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>)
void Swarm::swapTR(vector<double> particleRadii, vector<double> particleTemps) {
	// Pick two random individuals
	unsigned int r1 = rand() % options.swarmSize + 1;
	unsigned int r2 = rand() % options.swarmSize + 1;

	// Make sure they're different
	while (r1 == r2) {
		r2 = rand() % options.swarmSize + 1;
	}

	// Choose probability and a random number [0,1]
	float p = min <float>(1, exp( (particleBestFits_.at(r1) - particleBestFits_.at(r2) ) * ((1/particleRadii[r1]) - (1/particleRadii[r2]))));
	float r = (float)rand() / (float)RAND_MAX;

	// Swap
	if (r < p) {
		float r1Temp = particleTemps[r1];
		float r1Radius = particleRadii[r1];

		particleTemps[r1] = particleTemps[r2];
		particleRadii[r1] = particleRadii[r2];

		particleTemps[r2] = r1Temp;
		particleRadii[r2] = r1Radius;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rsi, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
callq 0x30b00
movq -0x40(%rbp), %rcx
cltd
idivl 0x1620(%rcx)
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
callq 0x30b00
movq -0x40(%rbp), %rcx
cltd
idivl 0x1620(%rcx)
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x1168d3
callq 0x30b00
movq -0x40(%rbp), %rcx
cltd
idivl 0x1620(%rcx)
addl $0x1, %edx
movl %edx, -0x20(%rbp)
jmp 0x1168b3
movq -0x40(%rbp), %rdi
movss 0xbc725(%rip), %xmm0    # 0x1d3004
movss %xmm0, -0x28(%rbp)
addq $0x1a20, %rdi           # imm = 0x1A20
leaq -0x1c(%rbp), %rsi
callq 0x1226a0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
addq $0x1a20, %rdi           # imm = 0x1A20
leaq -0x20(%rbp), %rsi
callq 0x1226a0
movsd -0x68(%rbp), %xmm0
movq -0x50(%rbp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movq -0x50(%rbp), %rdi
movsd 0xc41ef(%rip), %xmm0    # 0x1dab28
divsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd -0x60(%rbp), %xmm1
movsd -0x58(%rbp), %xmm0
movsd 0xc41ca(%rip), %xmm2    # 0x1dab28
divsd (%rax), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
callq 0x2f350
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x124bc0
movss (%rax), %xmm0
movss %xmm0, -0x24(%rbp)
callq 0x30b00
cvtsi2ss %eax, %xmm0
movss 0xca1b9(%rip), %xmm1    # 0x1e0b58
divss %xmm1, %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm1
movss -0x24(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x116a9d
movq -0x48(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movq -0x50(%rbp), %rdi
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movq -0x48(%rbp), %rdi
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movq -0x48(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd -0x88(%rbp), %xmm0
movq -0x50(%rbp), %rdi
movsd %xmm0, (%rax)
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movq -0x50(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd -0x80(%rbp), %xmm0
movq -0x48(%rbp), %rdi
movsd %xmm0, (%rax)
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd -0x78(%rbp), %xmm0
movq -0x50(%rbp), %rdi
movsd %xmm0, (%rax)
movss -0x38(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)