// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::runASA()
void Swarm::runASA() {
	if (options.verbosity >= 3) {
		cout << "Running an asynchronous PSADE fit" << endl;
	}

	if (!checkIfFileExists(options.jobOutputDir + "1")) {
		string createDirCmd = "mkdir " + options.jobOutputDir + "1";
		if (runCommand(createDirCmd) != 0) {
			outputError("Error: Couldn't create first generation output directory with command: " + createDirCmd + ". Quitting.");
		}
	}

	// Initialize and/or fill our parameter vectors
	vector<unsigned int> isLocal = vector<unsigned int>(options.swarmSize + 1);
	vector<double> particleTemps = vector<double>(options.swarmSize + 1, 0);
	vector<double> particleRadii = vector<double>(options.swarmSize + 1, 0);
	vector<float> particleFs = generateParticleFs();
	vector<float> particleCRs = generateParticleCRs();
	vector<float> cpuToParticle = vector<float>(options.swarmSize + 1, 0);
	vector<vector<float> > trialParams = vector<vector<float> >(options.swarmSize + 1, vector<float>(2, 0));
	map<unsigned int, unsigned int> particleToController;

	// Launch the initialization population and map
	// CPUs to particles
	for (int p = 1; p <= options.swarmSize; ++p) {
		launchParticle(p);
		cpuToParticle[p] = p;
		particleToController[p] = p;
	}

	unordered_map<unsigned int, vector<double> > finishedParticles;
	unordered_map<unsigned int, vector<double> > initFinishedParticles;
	int numFinishedParticles = 0;

	// Wait for initialization population to finish simulations
	while (numFinishedParticles < options.swarmSize) {
		initFinishedParticles = checkMasterMessagesDE();
		// Save finished particles in another map, we still need to process them in the main loop later on
		if (initFinishedParticles.size()) {
			finishedParticles.insert(initFinishedParticles.begin(), initFinishedParticles.end());
			numFinishedParticles += initFinishedParticles.size();
		}

		// Process each finished particle
		for (auto particle = initFinishedParticles.begin(); particle != initFinishedParticles.end(); ++particle) {
			//++flightCounter_;
			cout << "particle " << cpuToParticle[particle->first] << " on cpu " << particle->first << " finished" << endl;
			string paramString = toString(flightCounter_) + " ";

			// Update parameter values
			unsigned int i = 0;
			for (auto param = particle->second.begin() + 1; param != particle->second.end(); ++param) {
				particleCurrParamSets_[cpuToParticle[particle->first]][i++] = *param;
				cout << "updating particle " << cpuToParticle[particle->first] << " to " << *param << " at " << i << endl;
				paramString += toString(*param) + " ";
			}

			// Update fit calcs
			particleBestFits_[cpuToParticle[particle->first]] = particle->second[0];
			insertKeyByValue(particleBestFitsByFit_, particle->second[0], cpuToParticle[particle->first]);
			//allGenFits.insert(pair<double, string>(particle->second[0], paramString));
			cout << "updating particle " << cpuToParticle[particle->first] << " calc to " << particle->second[0] << endl;
			//cout << "count: " << particleBestFitsByFit_.count(particle->second[0]) << endl;

			// Update F and CR
			trialParams[cpuToParticle[particle->first]][0] = particleFs[cpuToParticle[particle->first]];
			trialParams[cpuToParticle[particle->first]][1] = particleCRs[cpuToParticle[particle->first]];
		}
	}

	// Generate our initial temps and radii
	particleTemps = generateParticleTemps();
	particleRadii = generateParticleRadii();

	// Main loop
	cout << "entering main loop" << endl;
	while (!checkStopCriteria()) {

		// Check to make sure we aren't processing init swarm before checking for new
		if (!finishedParticles.size()) {
			finishedParticles = checkMasterMessagesDE();
		}

		// Process any finished particles
		for (auto particle = finishedParticles.begin(); particle != finishedParticles.end(); ++particle) {
			cout << "particle " << cpuToParticle[particle->first] << " on cpu " << particle->first << " finished" << endl;

			string paramString = toString(flightCounter_ + 1) + " ";

			// If the particle finished their local search
			if (isLocal[particle->first]) {
				cout << "particle just finished local search" << endl;

				cout << "greedy acceptance of fit of " << particle->second[0] << endl;
				// Greedy acceptance
				particleBestFits_[cpuToParticle[particle->first]] = particle->second[0];
				insertKeyByValue(particleBestFitsByFit_, particle->second[0], cpuToParticle[particle->first]);

				unsigned int i = 0;
				for (auto param = particle->second.begin() + 1; param != particle->second.end(); ++param) {
					particleCurrParamSets_[cpuToParticle[particle->first]][i++] = *param;
					cout << "updating particle " << cpuToParticle[particle->first] << " to " << *param << " at " << i << endl;
					paramString += toString(*param) + " ";
				}

				particleFs[cpuToParticle[particle->first]] = trialParams[cpuToParticle[particle->first]][0];
				particleCRs[cpuToParticle[particle->first]] = trialParams[cpuToParticle[particle->first]][1];

				allGenFits.insert(pair<double, string>(particle->second[0], paramString));

				isLocal[particle->first] = 0;
			}
			else {
				// If we pass metropolis selection, store the params for assignment to receiver
				if (particle->second[0] < particleBestFits_.at(particleToController[cpuToParticle[particle->first]]) || metropolisSelection(particleToController[cpuToParticle[particle->first]], particle->second[0], particleTemps[particleToController[cpuToParticle[particle->first]]])) {

					cout << "particle was accepted through metropolis selection" << endl;

					unsigned int i = 0;
					for (auto param = particle->second.begin() + 1; param != particle->second.end(); ++param) {
						particleCurrParamSets_[cpuToParticle[particle->first]][i++] = *param;
						cout << "updating particle " << cpuToParticle[particle->first] << " to " << *param << " at " << i << endl;
						paramString += toString(*param) + " ";
					}

					// Update fitness
					particleBestFits_[cpuToParticle[particle->first]] = particle->second[0];
					insertKeyByValue(particleBestFitsByFit_, particle->second[0], cpuToParticle[particle->first]);
					cout << "accepting params and fit of " << particle->second[0] << endl;

					// Update CR and F
					cout << "updating F to " << trialParams[cpuToParticle[particle->first]][0] << " and CR to " << trialParams[cpuToParticle[particle->first]][1] << endl;
					particleFs[cpuToParticle[particle->first]] = trialParams[cpuToParticle[particle->first]][0];
					particleCRs[cpuToParticle[particle->first]] = trialParams[cpuToParticle[particle->first]][1];
				}
				else {
					for (auto param = particle->second.begin() + 1; param != particle->second.end(); ++param) {
						paramString += toString(*param) + " ";
					}
				}

				// Save params for output no matter what
				allGenFits.insert(pair<double, string>(particle->second[0], paramString));
				cout << "inserting " << paramString << endl;
				// Do a local search at some probability
				// Or if particle is best in swarm
				if (particle->second[0] < particleBestFits_.at(particleToController[cpuToParticle[particle->first]]) || options.localSearchProbability >= ((float)rand() / (float)RAND_MAX)) {
					cout << "going to do a local search" << endl;
					// This receiver will go on to do a local search
					isLocal[particle->first] = cpuToParticle[particle->first];
				}
			}

			if ((options.outputEvery != 0) && (++flightCounter_ && flightCounter_ % options.outputEvery == 0)) {
				string outputPath = options.jobOutputDir + toString(flightCounter_) + "_summary.txt";
				outputRunSummary(outputPath);
				//cout << "fc is " << flightCounter_ << ", outputting" << endl;
			}

			unsigned int it = rand() % options.swarmSize + 1;
			cout << "chose receiver of " << it << endl;
			vector<double> newParams;

			// Swap temps and radii
			swapTR(particleRadii, particleTemps);

			// If we aren't going to do a local search, generate a new trial point
			if (!isLocal[particle->first]) {
				// Pick the controller
				unsigned int controller = pickWeightedSA();
				cout << "not doing local search. chose controller of " << controller << endl;
				// Generate a new trial vector
				particleToController[cpuToParticle[particle->first]] = controller;
				newParams = generateTrialPointSA(controller, it, particleRadii, particleCRs, particleFs, trialParams);
				cout << "generated new trial points" << endl;

				// Make sure we know this CPU will be running this Receiver
				cpuToParticle[particle->first] = it;
				cout << "setting cpu " << particle->first << " as receiver " << it << endl;

				// Save new params for sending to particle
				vector<string> newParamsStr;
				for (auto param = newParams.begin(); param != newParams.end(); ++param) {
					newParamsStr.push_back(toString(*param));
				}

				cout << "running " << cpuToParticle[particle->first] << " with new params on cpu " << particle->first << endl;

				// Send the params to the CPU
				swarmComm->sendToSwarm(0, particle->first, SEND_FINAL_PARAMS_TO_PARTICLE, false, newParamsStr);
				launchParticle(particle->first);
			}
			else {
				cout << "running local search on cpu " << particle->first << endl;
				// Do local search using PREVIOUS receiver
				runNelderMead(isLocal[particle->first], particle->first);
			}
		}
		finishedParticles.clear();
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movq %rdi, %rbp
cmpl $0x3, 0x1614(%rdi)
jb 0x7131e
movq 0xf4c8e(%rip), %rdi     # 0x165f98
leaq 0x6da72(%rip), %rsi     # 0xded83
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x1520(%rbp), %r12
leaq 0x6f07f(%rip), %rdx     # 0xe03ab
leaq 0x2c0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x334ed
movq %rbx, %rdi
callq 0x9ec28
movl %eax, %ebx
leaq 0x2c0(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
movq %rbp, 0x18(%rsp)
jne 0x713e7
leaq 0x64b2d(%rip), %rsi     # 0xd5e97
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3338b
leaq 0x6f027(%rip), %rdx     # 0xe03ab
leaq 0xd8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3336c
leaq 0x110(%rsp), %rdi
callq 0x295a0
leaq 0x280(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x28dd0
leaq 0x280(%rsp), %rdi
callq 0x9f543
movl %eax, %ebx
leaq 0x280(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
jne 0x71ce6
leaq 0xd8(%rsp), %rdi
callq 0x295a0
movslq 0x1620(%rbp), %rsi
incq %rsi
leaq 0x160(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x8643e
movslq 0x1620(%rbp), %rsi
incq %rsi
leaq 0xd8(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x1c8(%rsp), %rdi
leaq 0x110(%rsp), %rcx
callq 0x868f6
movslq 0x1620(%rbp), %rsi
incq %rsi
leaq 0xd8(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x1b0(%rsp), %rdi
leaq 0x110(%rsp), %rcx
callq 0x868f6
leaq 0x190(%rsp), %rdi
movq %rbp, %rsi
callq 0x8250a
leaq 0x178(%rsp), %rdi
movq %rbp, %rsi
callq 0x8257a
movslq 0x1620(%rbp), %rsi
incq %rsi
leaq 0xd8(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0x110(%rsp), %rcx
callq 0x8694c
movslq 0x1620(%rbp), %rbx
leaq 0x110(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0xd8(%rsp), %rdi
pushq $0x2
popq %rsi
leaq 0x40(%rsp), %rcx
callq 0x8694c
incq %rbx
leaq 0x148(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
leaq 0x1e0(%rsp), %rcx
movq %rbx, %rsi
callq 0x869a2
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0x9cd84
leaq 0x1e8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
pushq $0x1
popq %r14
leaq 0x1e0(%rsp), %r15
movslq 0x1620(%rbp), %rax
cmpq %rax, %r14
jg 0x7156a
movq %rbp, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x764b8
cvtsi2ss %r14d, %xmm0
movq 0x20(%rsp), %rax
movss %xmm0, (%rax,%r14,4)
movl %r14d, 0xd8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x86102
movl %r14d, (%rax)
incq %r14
jmp 0x71526
movq %r12, 0x1a8(%rsp)
leaq 0x108(%rsp), %rcx
movq %rcx, -0x30(%rcx)
pushq $0x1
popq %rdx
movq %rdx, -0x28(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rcx)
movl $0x3f800000, %esi       # imm = 0x3F800000
movl %esi, -0x10(%rcx)
movups %xmm0, -0x8(%rcx)
leaq 0x140(%rsp), %rcx
movq %rcx, -0x30(%rcx)
movq %rdx, -0x28(%rcx)
leaq 0x120(%rsp), %rcx
movups %xmm0, (%rcx)
movl %esi, 0x10(%rcx)
movups %xmm0, 0x18(%rcx)
leaq 0x1400(%rbp), %rcx
movq %rcx, 0x90(%rsp)
leaq 0x1a20(%rbp), %rcx
movq %rcx, 0x38(%rsp)
leaq 0x1ab0(%rbp), %rcx
movq %rcx, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
leaq 0x40(%rsp), %r14
leaq 0xb8(%rsp), %rbx
leaq 0x98(%rsp), %r12
cmpl %eax, 0x80(%rsp)
jge 0x71960
movq %r14, %rdi
movq %rbp, %rsi
callq 0x7c0c4
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x8b790
movq %r14, %rdi
callq 0x8b35a
cmpq $0x0, 0x128(%rsp)
je 0x7166e
movq 0x120(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
xorl %edx, %edx
callq 0x9cb82
movq 0x80(%rsp), %rax
addl 0x128(%rsp), %eax
movq %rax, 0x80(%rsp)
leaq 0x120(%rsp), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x71955
movq 0xf490f(%rip), %rdi     # 0x165f98
leaq 0x6c9e6(%rip), %rsi     # 0xde076
callq 0x289f0
movl 0x8(%r15), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x28780
movq %rax, %rdi
leaq 0x6d84b(%rip), %rsi     # 0xdef00
callq 0x289f0
movl 0x8(%r15), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x66051(%rip), %rsi     # 0xd7721
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movl 0x1d84(%rbp), %esi
movq %rbx, %rdi
callq 0x9f56b
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x6df15(%rip), %rdx     # 0xdf60d
callq 0x3336c
movq %rbx, %rdi
callq 0x295a0
movq 0x10(%r15), %r13
addq $0x8, %r13
xorl %ebp, %ebp
cmpq 0x18(%r15), %r13
je 0x71808
movsd (%r13), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%r15), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movl %eax, 0xb8(%rsp)
movq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq 0x61e04
movl %ebp, %ecx
movq (%rax), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0xf4836(%rip), %rdi     # 0x165f98
leaq 0x6d63c(%rip), %rsi     # 0xdeda5
callq 0x289f0
movl 0x8(%r15), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x28780
movq %rax, %rdi
leaq 0x6d6e7(%rip), %rsi     # 0xdee75
callq 0x289f0
movsd (%r13), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x6d60d(%rip), %rsi     # 0xdedb8
callq 0x289f0
incl %ebp
movl %ebp, %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movsd (%r13), %xmm0
movq %r12, %rdi
callq 0x9f57b
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x6de2e(%rip), %rdx     # 0xdf60d
callq 0x3336c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x294d0
movq %rbx, %rdi
callq 0x295a0
movq %r12, %rdi
callq 0x295a0
addq $0x8, %r13
jmp 0x7170f
movq 0x10(%r15), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%r15), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movl %eax, 0xb8(%rsp)
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x86066
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x10(%r15), %rax
movsd (%rax), %xmm0
movl 0x8(%r15), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rdx
movq 0x88(%rsp), %rsi
callq 0x7ea8e
movq 0xf472a(%rip), %rdi     # 0x165f98
leaq 0x6d530(%rip), %rsi     # 0xdeda5
callq 0x289f0
movl 0x8(%r15), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x28780
movq %rax, %rdi
leaq 0x6d523(%rip), %rsi     # 0xdedbd
callq 0x289f0
movq 0x10(%r15), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r15), %eax
movq 0x20(%rsp), %rcx
movss (%rcx,%rax,4), %xmm0
cvttss2si %xmm0, %rdx
movq %rdx, %rsi
movss 0x64973(%rip), %xmm1    # 0xd6248
subss %xmm1, %xmm0
cvttss2si %xmm0, %rdi
sarq $0x3f, %rsi
andq %rsi, %rdi
orq %rdx, %rdi
movq 0x190(%rsp), %rdx
movss (%rdx,%rdi,4), %xmm0
movq 0x148(%rsp), %rdx
imulq $0x18, %rdi, %rsi
movq (%rdx,%rsi), %rsi
movss %xmm0, (%rsi)
movss (%rcx,%rax,4), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss %xmm1, %xmm0
cvttss2si %xmm0, %rsi
sarq $0x3f, %rcx
andq %rcx, %rsi
orq %rax, %rsi
movq 0x178(%rsp), %rax
movss (%rax,%rsi,4), %xmm0
imulq $0x18, %rsi, %rax
movq (%rdx,%rax), %rax
movss %xmm0, 0x4(%rax)
movq %r14, %rdi
callq 0x295a0
movq 0x18(%rsp), %rbp
jmp 0x71676
movl 0x1620(%rbp), %eax
jmp 0x71605
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x825f2
leaq 0x1c8(%rsp), %rdi
leaq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0x8f17e
movq %rbx, %rdi
callq 0x5c44e
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x826ca
leaq 0x1b0(%rsp), %rdi
leaq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0x8f17e
movq %rbx, %rdi
callq 0x5c44e
movq 0xf45dd(%rip), %rdi     # 0x165f98
leaq 0x6d405(%rip), %rsi     # 0xdedc7
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x40(%rsp), %rbx
leaq 0xd8(%rsp), %r14
movq %rbp, %rdi
callq 0x72f2a
testb %al, %al
jne 0x71a2c
cmpq $0x0, 0xf0(%rsp)
jne 0x71a11
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x7c0c4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8b790
movq %rbx, %rdi
callq 0x8b35a
movq 0xe8(%rsp), %r13
testq %r13, %r13
jne 0x71abd
movq %r14, %rdi
callq 0x8b376
jmp 0x719dc
leaq 0x110(%rsp), %rdi
callq 0x8b35a
leaq 0xd8(%rsp), %rdi
callq 0x8b35a
leaq 0x1e0(%rsp), %rdi
callq 0x8ab6a
leaq 0x148(%rsp), %rdi
callq 0x86a5a
leaq 0x20(%rsp), %rdi
callq 0x9cd84
leaq 0x178(%rsp), %rdi
callq 0x9cd84
leaq 0x190(%rsp), %rdi
callq 0x9cd84
leaq 0x1b0(%rsp), %rdi
callq 0x5c44e
leaq 0x1c8(%rsp), %rdi
callq 0x5c44e
leaq 0x160(%rsp), %rdi
callq 0x5b268
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf44d4(%rip), %rdi     # 0x165f98
leaq 0x6c5ab(%rip), %rsi     # 0xde076
callq 0x289f0
movl 0x8(%r13), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x28780
leaq 0x6d413(%rip), %rsi     # 0xdef00
movq %rax, %rdi
callq 0x289f0
movl 0x8(%r13), %esi
movq %rax, %rdi
callq 0x286e0
leaq 0x65c19(%rip), %rsi     # 0xd7721
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x18(%rsp), %rax
movl 0x1d84(%rax), %esi
incl %esi
leaq 0x40(%rsp), %rdi
callq 0x9f56b
leaq 0x6dad7(%rip), %rdx     # 0xdf60d
leaq 0xb8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x3336c
leaq 0x40(%rsp), %rdi
callq 0x295a0
movl 0x8(%r13), %eax
movq 0x160(%rsp), %rcx
cmpl $0x0, (%rcx,%rax,4)
jne 0x71d30
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x40(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x1e0(%rsp), %rdi
callq 0x86102
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x8626a
movsd (%rax), %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x71eeb
movq 0xf43df(%rip), %rdi     # 0x165f98
leaq 0x6d25b(%rip), %rsi     # 0xdee1b
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x10(%r13), %r12
addq $0x8, %r12
xorl %r14d, %r14d
leaq 0x40(%rsp), %rbx
leaq 0x98(%rsp), %rbp
leaq 0xb8(%rsp), %r15
cmpq 0x18(%r13), %r12
je 0x71fda
movsd (%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movl %eax, 0x40(%rsp)
movq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq 0x61e04
movl %r14d, %ecx
movq (%rax), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0xf435a(%rip), %rdi     # 0x165f98
leaq 0x6d160(%rip), %rsi     # 0xdeda5
callq 0x289f0
movl 0x8(%r13), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x28780
movq %rax, %rdi
leaq 0x6d20b(%rip), %rsi     # 0xdee75
callq 0x289f0
movsd (%r12), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x6d131(%rip), %rsi     # 0xdedb8
callq 0x289f0
incl %r14d
movl %r14d, %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movsd (%r12), %xmm0
movq %rbp, %rdi
callq 0x9f57b
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x6d950(%rip), %rdx     # 0xdf60d
callq 0x3336c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x294d0
movq %rbx, %rdi
callq 0x295a0
movq %rbp, %rdi
callq 0x295a0
addq $0x8, %r12
jmp 0x71bed
leaq 0x6cc11(%rip), %rsi     # 0xde8fe
leaq 0x110(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x3338b
leaq 0x6de99(%rip), %rdx     # 0xdfba2
leaq 0x2a0(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x3336c
leaq 0x2a0(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x6aed2
movq 0xf4261(%rip), %rdi     # 0x165f98
leaq 0x6d09c(%rip), %rsi     # 0xdedda
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0xf4246(%rip), %rdi     # 0x165f98
leaq 0x6d0a5(%rip), %rsi     # 0xdedfe
callq 0x289f0
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x40(%rsp), %rsi
movl %eax, (%rsi)
movq 0x38(%rsp), %rdi
callq 0x86066
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x10(%r13), %rax
movsd (%rax), %xmm0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rdx
movq 0x88(%rsp), %rsi
callq 0x7ea8e
movq 0x10(%r13), %r12
addq $0x8, %r12
xorl %r14d, %r14d
leaq 0x40(%rsp), %rbx
leaq 0x98(%rsp), %rbp
leaq 0xb8(%rsp), %r15
cmpq 0x18(%r13), %r12
je 0x722bf
movsd (%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movl %eax, 0x40(%rsp)
movq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq 0x61e04
movl %r14d, %ecx
movq (%rax), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0xf4155(%rip), %rdi     # 0x165f98
leaq 0x6cf5b(%rip), %rsi     # 0xdeda5
callq 0x289f0
movl 0x8(%r13), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x28780
movq %rax, %rdi
leaq 0x6d006(%rip), %rsi     # 0xdee75
callq 0x289f0
movsd (%r12), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x6cf2c(%rip), %rsi     # 0xdedb8
callq 0x289f0
incl %r14d
movl %r14d, %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movsd (%r12), %xmm0
movq %rbp, %rdi
callq 0x9f57b
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x6d74b(%rip), %rdx     # 0xdf60d
callq 0x3336c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x294d0
movq %rbx, %rdi
callq 0x295a0
movq %rbp, %rdi
callq 0x295a0
addq $0x8, %r12
jmp 0x71df2
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
leaq 0x98(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x1e0(%rsp), %rdi
callq 0x86102
movl (%rax), %ebx
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x240(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x1e0(%rsp), %rdi
callq 0x86102
movl (%rax), %eax
movq 0x1c8(%rsp), %rcx
cvtsd2ss (%rcx,%rax,8), %xmm1
movq 0x18(%rsp), %rdi
movl %ebx, %esi
movsd 0x10(%rsp), %xmm0
callq 0x8278c
testb %al, %al
jne 0x71bb2
movq 0x10(%r13), %rbp
addq $0x8, %rbp
leaq 0x98(%rsp), %rbx
leaq 0x6d686(%rip), %r14     # 0xdf60d
leaq 0x40(%rsp), %r15
leaq 0xb8(%rsp), %r12
cmpq 0x18(%r13), %rbp
je 0x721aa
movsd (%rbp), %xmm0
movq %rbx, %rdi
callq 0x9f57b
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3336c
movq %r12, %rdi
movq %r15, %rsi
callq 0x294d0
movq %r15, %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x295a0
addq $0x8, %rbp
jmp 0x71f94
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x40(%rsp), %rsi
movl %eax, (%rsi)
movq 0x38(%rsp), %rdi
callq 0x86066
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x10(%r13), %rax
movsd (%rax), %xmm0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rdx
movq 0x88(%rsp), %rsi
callq 0x7ea8e
movq 0xf3f5b(%rip), %rdi     # 0x165f98
leaq 0x6ce0a(%rip), %rsi     # 0xdee4e
callq 0x289f0
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0xf3f30(%rip), %rdi     # 0x165f98
leaq 0x6cdfc(%rip), %rsi     # 0xdee6b
callq 0x289f0
movl 0x8(%r13), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
cvttss2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subss 0x641b2(%rip), %xmm0    # 0xd6248
cvttss2si %xmm0, %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq 0x148(%rsp), %rcx
imulq $0x18, %rsi, %rdx
movq (%rcx,%rdx), %rcx
movss (%rcx), %xmm0
movq %rax, %rdi
callq 0x28780
leaq 0x6cdb6(%rip), %rsi     # 0xdee7a
movq %rax, %rdi
callq 0x289f0
movl 0x8(%r13), %ecx
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm0
cvttss2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subss 0x6415a(%rip), %xmm0    # 0xd6248
cvttss2si %xmm0, %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq 0x148(%rsp), %rcx
imulq $0x18, %rsi, %rdx
movq (%rcx,%rdx), %rcx
movss 0x4(%rcx), %xmm0
movq %rax, %rdi
callq 0x28780
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
movss (%rcx,%rax,4), %xmm0
cvttss2si %xmm0, %rdx
movq %rdx, %rsi
movss 0x6410c(%rip), %xmm1    # 0xd6248
subss %xmm1, %xmm0
cvttss2si %xmm0, %rdi
sarq $0x3f, %rsi
andq %rsi, %rdi
orq %rdx, %rdi
movq 0x148(%rsp), %rdx
imulq $0x18, %rdi, %rsi
movq (%rdx,%rsi), %rsi
movss (%rsi), %xmm0
movq 0x190(%rsp), %rsi
movss %xmm0, (%rsi,%rdi,4)
movss (%rcx,%rax,4), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss %xmm1, %xmm0
cvttss2si %xmm0, %rsi
sarq $0x3f, %rcx
andq %rcx, %rsi
orq %rax, %rsi
imulq $0x18, %rsi, %rax
movq (%rdx,%rax), %rax
movss 0x4(%rax), %xmm0
movq 0x178(%rsp), %rax
movss %xmm0, (%rax,%rsi,4)
movq 0x10(%r13), %rsi
leaq 0x40(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x869f8
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rdi
leaq 0x40(%rsp), %rsi
callq 0x8fb4e
leaq 0x48(%rsp), %rdi
callq 0x295a0
movq 0xf3db4(%rip), %rdi     # 0x165f98
leaq 0x6cc9b(%rip), %rsi     # 0xdee86
callq 0x289f0
leaq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
movq 0x10(%r13), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x40(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x1e0(%rsp), %rdi
callq 0x86102
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x8626a
movsd (%rax), %xmm0
ucomisd 0x10(%rsp), %xmm0
ja 0x72285
movq 0x18(%rsp), %rax
movss 0x1720(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
callq 0x28280
cvtsi2ss %eax, %xmm0
mulss 0x69f52(%rip), %xmm0    # 0xdc1c8
movss 0x10(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jb 0x7238e
movq 0xf3d0c(%rip), %rdi     # 0x165f98
leaq 0x6cbfe(%rip), %rsi     # 0xdee91
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rcx
movq 0x160(%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
jmp 0x7238e
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
movss (%rcx,%rax,4), %xmm0
cvttss2si %xmm0, %rdx
movq %rdx, %rsi
sarq $0x3f, %rsi
movss 0x63f67(%rip), %xmm1    # 0xd6248
subss %xmm1, %xmm0
cvttss2si %xmm0, %rdi
andq %rsi, %rdi
orq %rdx, %rdi
movq 0x148(%rsp), %rdx
imulq $0x18, %rdi, %rsi
movq (%rdx,%rsi), %rsi
movss (%rsi), %xmm0
movq 0x190(%rsp), %rsi
movss %xmm0, (%rsi,%rdi,4)
movss (%rcx,%rax,4), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subss %xmm1, %xmm0
cvttss2si %xmm0, %rsi
andq %rcx, %rsi
orq %rax, %rsi
imulq $0x18, %rsi, %rax
movq (%rdx,%rax), %rax
movss 0x4(%rax), %xmm0
movq 0x178(%rsp), %rax
movss %xmm0, (%rax,%rsi,4)
movq 0x10(%r13), %rsi
leaq 0x40(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x869f8
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rdi
leaq 0x40(%rsp), %rsi
callq 0x8fb4e
leaq 0x48(%rsp), %rdi
callq 0x295a0
movl 0x8(%r13), %eax
movq 0x160(%rsp), %rcx
andl $0x0, (%rcx,%rax,4)
movq 0x18(%rsp), %rax
movl 0x1728(%rax), %ecx
testl %ecx, %ecx
je 0x72460
movq 0x18(%rsp), %rax
movl 0x1d84(%rax), %esi
incl %esi
movl %esi, 0x1d84(%rax)
je 0x72460
movl %esi, %eax
xorl %edx, %edx
divl %ecx
testl %edx, %edx
jne 0x72460
leaq 0x240(%rsp), %rdi
callq 0x9f56b
leaq 0x98(%rsp), %rdi
leaq 0x240(%rsp), %rdx
movq 0x1a8(%rsp), %rsi
callq 0x5a115
leaq 0x6c54d(%rip), %rdx     # 0xde946
leaq 0x40(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x3336c
leaq 0x98(%rsp), %rdi
callq 0x295a0
leaq 0x240(%rsp), %rdi
callq 0x295a0
leaq 0x260(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x28dd0
leaq 0x260(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x7942a
leaq 0x260(%rsp), %rdi
callq 0x295a0
leaq 0x40(%rsp), %rdi
callq 0x295a0
callq 0x28280
movl %eax, %ebx
movq 0x18(%rsp), %rax
movl 0x1620(%rax), %ebp
movq 0xf3b1f(%rip), %rdi     # 0x165f98
leaq 0x6ca2c(%rip), %rsi     # 0xdeeac
callq 0x289f0
movq %rax, %rdi
movl %ebx, %eax
cltd
idivl %ebp
leal 0x1(%rdx), %esi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
leaq 0x228(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x59fa2
leaq 0x210(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x59fa2
leaq 0x228(%rsp), %rsi
leaq 0x210(%rsp), %rdx
movq 0x18(%rsp), %rdi
callq 0x82808
leaq 0x210(%rsp), %rdi
callq 0x5c44e
leaq 0x228(%rsp), %rdi
callq 0x5c44e
movl 0x8(%r13), %eax
movq 0x160(%rsp), %rcx
cmpl $0x0, (%rcx,%rax,4)
jne 0x725c5
movq 0x18(%rsp), %rdi
callq 0x8293a
movl %eax, %ebx
movq 0xf3a64(%rip), %rdi     # 0x165f98
leaq 0x6c984(%rip), %rsi     # 0xdeebf
callq 0x289f0
movl %ebx, %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r13), %eax
movq 0x20(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %rax
leaq 0x98(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x1e0(%rsp), %rdi
callq 0x86102
movl %ebx, (%rax)
leaq 0x310(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x59fa2
leaq 0x2f8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x86a0c
leaq 0x2e0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x86a0c
movq 0x18(%rsp), %rsi
movl %ebx, %edx
callq 0x82af4
movq 0xf39cc(%rip), %rdi     # 0x165f98
leaq 0x6c919(%rip), %rsi     # 0xdeeec
callq 0x289f0
movl 0x8(%r13), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r13), %edx
movq 0x160(%rsp), %rax
movl (%rax,%rdx,4), %esi
movq 0x18(%rsp), %rdi
callq 0x82b3e
jmp 0x7263c
movq %rax, %rbx
leaq 0x2e0(%rsp), %rdi
callq 0x9cd84
jmp 0x7261c
movq %rax, %rbx
leaq 0x2f8(%rsp), %rdi
callq 0x9cd84
jmp 0x7262e
movq %rax, %rbx
leaq 0x310(%rsp), %rdi
jmp 0x7265e
jmp 0x7263c
jmp 0x7263c
movq %rax, %rbx
jmp 0x72663
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x5c44e
jmp 0x72656
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x5c44e
leaq 0x40(%rsp), %rdi
callq 0x5c44e
jmp 0x72821
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x295a0
jmp 0x72687
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x7270d
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x295a0
jmp 0x726a3
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
jmp 0x7270d
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x726c3
jmp 0x7281e
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x7270d
jmp 0x726f3
jmp 0x72702
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x726f3
jmp 0x72702
jmp 0x7281e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x295a0
jmp 0x72705
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x295a0
jmp 0x72821
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7281e
jmp 0x7285a
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x295a0
jmp 0x7275e
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x7277a
jmp 0x7282d
jmp 0x72781
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
callq 0x295a0
jmp 0x72784
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x727fd
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x727fd
jmp 0x7282d
jmp 0x7282d
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x9cd84
jmp 0x7289b
movq %rax, %rbx
jmp 0x7289b
movq %rax, %rbx
jmp 0x728a5
movq %rax, %rbx
jmp 0x728b2
movq %rax, %rbx
jmp 0x728bf
movq %rax, %rbx
jmp 0x728cc
movq %rax, %rbx
jmp 0x728d9
movq %rax, %rbx
jmp 0x728e6
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x295a0
jmp 0x728e6
jmp 0x7282d
jmp 0x7282d
jmp 0x7282d
jmp 0x7282d
jmp 0x7282d
jmp 0x7282d
jmp 0x72815
movq %rax, %rbx
jmp 0x72881
jmp 0x7285a
jmp 0x7282d
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x72862
jmp 0x7285a
movq %rax, %rbx
jmp 0x72867
jmp 0x7285a
jmp 0x7285a
movq %rax, %rbx
jmp 0x7284b
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x295a0
leaq 0x98(%rsp), %rdi
callq 0x295a0
jmp 0x7285d
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x295a0
leaq 0x110(%rsp), %rdi
callq 0x8b35a
leaq 0xd8(%rsp), %rdi
callq 0x8b35a
leaq 0x1e0(%rsp), %rdi
callq 0x8ab6a
leaq 0x148(%rsp), %rdi
callq 0x86a5a
leaq 0x20(%rsp), %rdi
callq 0x9cd84
leaq 0x178(%rsp), %rdi
callq 0x9cd84
leaq 0x190(%rsp), %rdi
callq 0x9cd84
leaq 0x1b0(%rsp), %rdi
callq 0x5c44e
leaq 0x1c8(%rsp), %rdi
callq 0x5c44e
leaq 0x160(%rsp), %rdi
callq 0x5b268
movq %rbx, %rdi
callq 0x292f0