// File: /workspace/github_cpp_makefile_star2_O1/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::initPSOswarm(bool)
void Swarm::initPSOswarm(bool resumeFit) {
	vector<unsigned int> finishedParticles;
	//unsigned int numFinishedParticles = 0;

	if (options.verbosity >= 3) {
		cout << "Launching swarm" << endl;
	}

	// Launch all particles
	//for (unsigned int p = 1; p <= options.swarmSize; ++p) {
	//	launchParticle(p);
	//}

	//if (options.verbosity >= 3) {
	//	cout << "Waiting for particles to finish" << endl;
	//}

	// Wait until they are all finished so we can initialize
	// stuff for subsequent iterations
	/*while(numFinishedParticles < options.swarmSize) {
		// Check for our finished particles

		cout << "RAQUEL swarm size is " << options.swarmSize << " finished: " << numFinishedParticles << endl;
		finishedParticles = checkMasterMessages();
		numFinishedParticles += finishedParticles.size();

		// Sleep for a second
		usleep(1000000);
	}

	*/
	//Raquel replaced the loop above by a synchronous generation
	runGeneration();



	// Fill a vector with all pID's to send for processing
	vector<unsigned int> allParticles;
	for (int p = 1; p <= options.swarmSize; ++p) {
		allParticles.push_back(p);
	}

	// Send all pID's in for processing (update velocities and positions)
	processParticlesPSO(allParticles, false);

	// Set our optimum
	optimum_ = particleBestFitsByFit_.begin()->first;

	// If we're using enhanced stop criteria, update the enhanced stop variables
	if (options.enhancedStop) {
		// Initialize our particle weights and weighted average position
		updateEnhancedStop();
	}


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpl $0x3, 0x1614(%rdi)
jb 0x9cb4c
movq 0xd947f(%rip), %r14     # 0x175f90
leaq 0x63b3e(%rip), %rsi     # 0x100656
movl $0xf, %edx
movq %r14, %rdi
callq 0x22ab0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r14, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq %rbx, %rdi
callq 0x8d672
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x1620(%rbx)
jle 0x9cbac
xorl %ebp, %ebp
leaq 0x10(%rsp), %r14
leaq 0xc(%rsp), %r15
incl %ebp
movl %ebp, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9cb99
movl %ebp, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x9cba4
movq %r14, %rdi
movq %r15, %rdx
callq 0xaf698
cmpl 0x1620(%rbx), %ebp
jl 0x9cb7a
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xa8934
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x8905e
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9cbe1
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x1ac8(%rbx), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x1d90(%rbx)
cmpb $0x1, 0x16f8(%rbx)
jne 0x9cc06
movq %rbx, %rdi
callq 0x87dd8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9cc1d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9cc49
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x9cc49
jmp 0x9cc46
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9cc60
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x23240