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

	// Create an output directory for each island
	if (!checkIfFileExists(options.jobOutputDir + toString(1))) {
		string createDirCmd = "mkdir " + options.jobOutputDir + toString(1);
		runCommand(createDirCmd);
	}

	if (options.verbosity >= 3) {
		cout << "Generating island topology" << endl;
	}
	vector<vector<unsigned int> > islandTopology;
	if (!resumingSavedSwarm) {
		// Generate all particles that will be present in the swarm
		islandTopology = generateTopology(options.numIslands);
		// Map all particles and islands
		unsigned int particlesPerIsland = options.swarmSize / options.numIslands;
		unsigned int currParticle = 1;
		for (unsigned int i = 1; i <= options.numIslands; ++i) {
			for (unsigned int p = 0; p < particlesPerIsland; ++p) {
				particleToIsland_[currParticle] = i;
				islandToParticle_[i][p] = currParticle;
				if (options.verbosity >= 4) {
					cout << i << " " << p << " " << islandToParticle_[i][p] << endl;
				}
				if(options.verbosity >= 3){
					cout << "Particle to island " << particleToIsland_[currParticle] << endl;
					cout << "currPar " << currParticle << endl;
				}
				++currParticle;
			}
		}
	}

	saveSwarmState();

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

	unordered_map<unsigned int, vector<double> > finishedParticles;
	bool stopCriteria = false;
	vector<unsigned int> islandFinishedParticles(options.numIslands + 1, 0);

	map<unsigned int, vector<vector<double> > > migrationSets;

	bool trialLoop = false;




	//saveSwarmState();
	string path; //Raquel added
	//vector<unsigned int> finishedParticles;
	//vector<unsigned int> particlestoProcess;


	//int numFinishedParticles = 0;

	//unsigned int p = 1;
	//int mid; //Raquel added
	int sp = 0; //Raquel added
	//int nModels = options.models.size(); //Raquel added




	while(!stopCriteria) {


		//numFinishedParticles = options.swarmSize;
		string currentDirectory = options.jobOutputDir + toString(currentGeneration);
		if (options.deleteOldFiles) {
			//cout << "RAQUEL: starting cleanupFiles" << endl;

			cleanupFiles(currentDirectory.c_str());
			//cout << "RAQUEL: finished cleanupFiles" << endl;

		}


		//cout << "RAQUEL: starting runGeneration" << endl;
		runGeneration();
		//usleep(250000);

		// Create the output directory for the next generation
		if (!checkIfFileExists(options.jobOutputDir + toString(currentGeneration))) {
			string createDirCmd = "mkdir " + options.jobOutputDir + toString(currentGeneration);
			int retryCounter = 0;
			while (runCommand(createDirCmd) != 0 && !checkIfFileExists(options.jobOutputDir + toString(currentGeneration))) {
				if(++retryCounter >= 100) {
					outputError("Error: Couldn't create " + options.jobOutputDir + toString(currentGeneration) + " to hold next generation's output.");
				}
				//sleep(1);
				if(options.verbosity>=3){

					cout << "Trying again to create dir" << endl;
				}
			}
		}

		saveSwarmState();
		//cout << "RAQUEL: finished saveSwarmState" << endl;

		string outputPath = options.jobOutputDir + toString(currentGeneration - 1 ) + "_summary.txt";

		cout << "Generation: " << toString(currentGeneration - 1 ) << endl;

		outputRunSummary(outputPath);

		unordered_map<unsigned int, vector<double> > finished;


		for (int i = 1; i <= options.swarmSize; i++){
			//for (int mid=0; mid < options.models.size(); mid++){
				finished.insert(make_pair(i, subparticleCurrParamSets_[i][0]));


			//}

		}

		if(options.verbosity >= 4){
			cout << "RAQUEL FINISHED SIZE " << finished.size() << endl;
			cout << "vector size " << islandFinishedParticles.size() << endl;
		}
		if (finished.size()) {
			finishedParticles.insert(finished.begin(), finished.end());
			//numFinishedParticles = finished.size();
		}
		int counter = 0;


//		for(auto index = particleToIsland_.begin(); index != particleToIsland_.end(); )

		for (auto particle = finishedParticles.begin(); particle != finishedParticles.end(); ++particle) {
			// Increment the counter that tracks the number of particles finished
			// for a given island
			counter++;
			if(options.verbosity >= 4){
				cout << "counter" << counter << endl;
				cout << "Particle first " << particle->first  << endl;
				cout << "Particle to island " << particleToIsland_[particle->first] << endl;
				cout << "Particle to isalnd size " << particleToIsland_.size() << endl;
			}
			islandFinishedParticles[particleToIsland_[particle->first]] += 1;
		}

		finishedParticles.clear();
		//numFinishedParticles = 0;

		// Done processing params. Now we need to...
		// Check each island to see if it has completed its generation
		for (unsigned int island = 1; island <= options.numIslands; ++island) {
			// If the number finished in this island is equal to the total size of the island
			if (islandFinishedParticles.at(island) == (options.swarmSize / options.numIslands)) {
				if(options.verbosity >= 3){
					cout << "Island " << island << " finished" << endl;
				}
				// Loop through the particles in the island
				for (auto particle = islandToParticle_.at(island).begin(); particle != islandToParticle_.at(island).end(); ++particle) {

					// Will hold mutated and crossed over parameter sets
					vector<double> newParamSet;
					// If we're not in a trial loop, we should mutate and crossover
					if (trialLoop == false) {
						// Create a mutation set for the particle
						newParamSet = mutateParticleDE(*particle);

						// Run crossover for the particle
						newParamSet = crossoverParticleDE(*particle, newParamSet);
					}
					// If we're in a main loop, we just send the current parameter
					// set back to the particle
					else {
						newParamSet = particleCurrParamSets_.at(*particle);
					}

					// Convert our param set to string for sending
					vector<string> paramVecStr;
					for (auto param = newParamSet.begin(); param != newParamSet.end(); ++param) {
						paramVecStr.push_back(toString(*param));
					}

					// Send new param sets to particles for next generation
//					swarmComm->sendToSwarm(0, *particle, SEND_FINAL_PARAMS_TO_PARTICLE, false, paramVecStr);

					//Raquel updated the interprocess communication, added the loop bellow
					for(unsigned int mid = 0; mid < options.models.size(); mid++){
						sp = fcalcsubParID(*particle, mid, options.models.size());
						swarmComm->sendToSwarm(0, sp, SEND_FINAL_PARAMS_TO_PARTICLE, false, paramVecStr);
					}


					// Empty our finished particle counter for the next loop
					islandFinishedParticles[island] = 0;
				}
			}
		}


			// Check for stop criteria
			stopCriteria = checkStopCriteria();
			if(options.verbosity >= 3){
				cout << "Stop Criteria value: " << stopCriteria << endl;
			}
			if (!stopCriteria) {
				// Send/receive migration sets
				if ((options.migrationFrequency != 0) && (currentGeneration % options.migrationFrequency == 0)) {

					for (unsigned int island = 1; island <= options.numIslands; ++island) {
						sendMigrationSetDE(island, islandTopology, migrationSets);
					}

					for (unsigned int island = 1; island <= options.numIslands; ++island) {
						recvMigrationSetDE(island, migrationSets);
					}
				}

//				string outputPath = options.jobOutputDir + toString(currentGeneration) + "_summary.txt";
	//			outputRunSummary(outputPath);
				//++currentGeneration;
				//cout << "Switching to main loop" << endl;
				//trialLoop = false;

			}
		//}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, %rbx
cmpl $0x3, 0x1614(%rdi)
jb 0x6e696
movq 0xf7916(%rip), %rdi     # 0x165f98
leaq 0x70368(%rip), %rsi     # 0xde9f1
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x1520(%rbx), %r15
leaq 0xf8(%rsp), %r14
pushq $0x1
popq %rbp
movq %r14, %rdi
movl %ebp, %esi
callq 0x9e9c3
leaq 0x1e8(%rsp), %rdi
movq %r15, 0x8(%rsp)
movq %r15, %rsi
movq %r14, %rdx
callq 0x5a115
leaq 0x1e8(%rsp), %rdi
callq 0x9ec28
movl %eax, %r14d
leaq 0x1e8(%rsp), %rdi
callq 0x295a0
leaq 0xf8(%rsp), %rdi
callq 0x295a0
testl %r14d, %r14d
jne 0x6e790
leaq 0x67793(%rip), %rsi     # 0xd5e97
leaq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
callq 0x3338b
leaq 0x158(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x9e9c3
leaq 0xf8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x158(%rsp), %rdx
callq 0x4e6ed
leaq 0x158(%rsp), %rdi
callq 0x295a0
leaq 0x20(%rsp), %rdi
callq 0x295a0
leaq 0x1c8(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x28dd0
leaq 0x1c8(%rsp), %rdi
callq 0x9f543
leaq 0x1c8(%rsp), %rdi
callq 0x295a0
leaq 0xf8(%rsp), %rdi
callq 0x295a0
cmpl $0x3, 0x1614(%rbx)
jb 0x6e7b4
movq 0xf77f8(%rip), %rdi     # 0x165f98
leaq 0x70267(%rip), %rsi     # 0xdea0e
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
andq $0x0, 0x140(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x130(%rsp)
cmpb $0x0, 0x13f0(%rbx)
je 0x6f03f
movq %rbx, %rdi
callq 0x7ec70
leaq 0x128(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movl 0x16fc(%rbx), %esi
incl %esi
leaq 0x20(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0xe0(%rsp), %rdi
leaq 0x158(%rsp), %rcx
callq 0x86150
leaq 0x160(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x258(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1460(%rbx), %rax
movq %rax, 0x150(%rsp)
leaq 0xa8(%rsp), %r13
leaq 0x1d38(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x20(%rsp), %r15
leaq 0xa0(%rsp), %r14
leaq 0x280(%rsp), %rbp
movl 0x13e8(%rbx), %esi
movq %r15, %rdi
callq 0x9f56b
leaq 0x1a8(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x5a115
movq %r15, %rdi
callq 0x295a0
cmpb $0x1, 0x1646(%rbx)
jne 0x6e8d2
movq 0x1a8(%rsp), %rsi
callq 0x791e0
movq %rbx, %rdi
callq 0x76bce
movl 0x13e8(%rbx), %esi
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x9f56b
leaq 0x2b8(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x5a115
movq %r12, %rdi
callq 0x9ec28
movl %eax, %r15d
movq %r12, %rdi
callq 0x295a0
leaq 0x20(%rsp), %rdi
callq 0x295a0
testl %r15d, %r15d
jne 0x6ea4f
leaq 0x60(%rsp), %rdi
leaq 0x67560(%rip), %rsi     # 0xd5e97
movq 0x8(%rsp), %rdx
callq 0x3338b
movl 0x13e8(%rbx), %esi
movq %r14, %rdi
callq 0x9f56b
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %r15
movq %r15, %rsi
movq %r14, %rdx
callq 0x4e6ed
movq %r14, %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x295a0
pushq $0x63
popq %r13
leaq 0x188(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x28dd0
leaq 0x188(%rsp), %rdi
callq 0x9f543
testl %eax, %eax
je 0x6ea30
movl 0x13e8(%rbx), %esi
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0x9f56b
leaq 0x298(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x5a115
movq %r12, %rdi
callq 0x9ec28
movl %eax, %r15d
movq %r12, %rdi
callq 0x295a0
leaq 0x60(%rsp), %rdi
callq 0x295a0
leaq 0x188(%rsp), %rdi
callq 0x295a0
testl %r15d, %r15d
jne 0x6ea3d
subl $0x1, %r13d
jb 0x6f22c
cmpl $0x3, 0x1614(%rbx)
jb 0x6e978
movq 0xf7581(%rip), %rdi     # 0x165f98
leaq 0x6e643(%rip), %rsi     # 0xdd061
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
jmp 0x6e978
leaq 0x188(%rsp), %rdi
callq 0x295a0
leaq 0x20(%rsp), %rdi
callq 0x295a0
leaq 0xa8(%rsp), %r13
movq %rbx, %rdi
callq 0x7ec70
movl 0x13e8(%rbx), %esi
decl %esi
movq %r14, %rdi
callq 0x9f56b
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x5a115
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
leaq 0x6febb(%rip), %rdx     # 0xde946
callq 0x3336c
movq %r15, %rdi
callq 0x295a0
movq %r14, %rdi
callq 0x295a0
movq 0xf74f1(%rip), %rdi     # 0x165f98
leaq 0x6ea14(%rip), %rsi     # 0xdd4c2
callq 0x289f0
movq %rax, %r12
movl 0x13e8(%rbx), %esi
decl %esi
movq %r15, %rdi
callq 0x9f56b
movq %r12, %rdi
movq %r15, %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
leaq 0x20(%rsp), %rdi
callq 0x295a0
leaq 0x208(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x28dd0
movq %rbx, %rdi
leaq 0x208(%rsp), %r15
movq %r15, %rsi
callq 0x7942a
movq %r15, %rdi
callq 0x295a0
leaq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x1, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, 0x40(%rsp) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
pushq $0x1
popq %r15
cmpl 0x1620(%rbx), %r15d
jg 0x6eba5
movl %r15d, 0x80(%rsp)
movq 0x150(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x61db6
andl $0x0, 0xc0(%rsp)
movq %rax, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x61e04
movl %r15d, 0xa0(%rsp)
movq %r13, %rdi
movq %rax, %rsi
callq 0x59fa2
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x9cab2
movq %r13, %rdi
callq 0x5c44e
incl %r15d
jmp 0x6eb3a
cmpl $0x3, 0x1614(%rbx)
jbe 0x6ec0d
movq 0xf73e3(%rip), %rdi     # 0x165f98
leaq 0x6fe8a(%rip), %rsi     # 0xdea46
callq 0x289f0
movq 0x38(%rsp), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xf73bb(%rip), %rdi     # 0x165f98
leaq 0x6fe78(%rip), %rsi     # 0xdea5c
callq 0x289f0
movq 0xe8(%rsp), %rsi
subq 0xe0(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
cmpq $0x0, 0x38(%rsp)
je 0x6ec29
movq 0x30(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
xorl %edx, %edx
callq 0x9cb82
pushq $0x1
popq %r12
leaq 0x108(%rsp), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x6ed22
cmpl $0x4, 0x1614(%rbx)
jb 0x6ed01
movq 0xf7343(%rip), %rdi     # 0x165f98
leaq 0x6e1a9(%rip), %rsi     # 0xdce05
callq 0x289f0
movq %rax, %rdi
movl %r12d, %esi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movq 0xf731d(%rip), %rdi     # 0x165f98
leaq 0x6fde7(%rip), %rsi     # 0xdea69
callq 0x289f0
movl 0x8(%r15), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xf72f6(%rip), %rdi     # 0x165f98
leaq 0x6fd80(%rip), %rsi     # 0xdea29
callq 0x289f0
movl 0x8(%r15), %ecx
movq 0x1d20(%rbx), %rdx
movl (%rdx,%rcx,4), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xf72c5(%rip), %rdi     # 0x165f98
leaq 0x6fd9f(%rip), %rsi     # 0xdea79
callq 0x289f0
movq 0x1d28(%rbx), %rsi
subq 0x1d20(%rbx), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movl 0x8(%r15), %eax
movq 0x1d20(%rbx), %rcx
movl (%rcx,%rax,4), %eax
movq 0xe0(%rsp), %rcx
incl (%rcx,%rax,4)
incl %r12d
jmp 0x6ec35
leaq 0xf8(%rsp), %rdi
callq 0x8b376
pushq $0x1
popq %rax
cmpl 0x16fc(%rbx), %eax
ja 0x6ef41
movl %eax, 0x14(%rsp)
movl %eax, %r15d
leaq 0xe0(%rsp), %rdi
movq %r15, %rsi
callq 0x5a5de
movl (%rax), %ecx
movl 0x1620(%rbx), %eax
xorl %edx, %edx
divl 0x16fc(%rbx)
cmpl %eax, %ecx
jne 0x6ef36
cmpl $0x3, 0x1614(%rbx)
jb 0x6edab
movq 0xf721b(%rip), %rdi     # 0x165f98
leaq 0x6fd0e(%rip), %rsi     # 0xdea92
callq 0x289f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x68983(%rip), %rsi     # 0xd7721
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x8687e
movq (%rax), %r12
movq %r15, 0x58(%rsp)
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x8687e
cmpq 0x8(%rax), %r12
je 0x6ef36
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
movl (%r12), %edx
xorps %xmm0, %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x815e8
movq %rbp, %r13
leaq 0x80(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8f17e
movq %r14, %rdi
callq 0x5c44e
movl (%r12), %r15d
movq %r13, %rdi
movq %rbp, %rsi
callq 0x59fa2
xorps %xmm0, %xmm0
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x8234e
movq %r13, %rbp
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x8f17e
movq %r14, %rdi
callq 0x5c44e
movq %r13, %rdi
callq 0x5c44e
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movq 0x80(%rsp), %r15
cmpq 0x88(%rsp), %r15
je 0x6eeb5
movsd (%r15), %xmm0
movq %r14, %rdi
callq 0x9f57b
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x5ec8c
movq %r14, %rdi
callq 0x295a0
addq $0x8, %r15
jmp 0x6ee80
xorl %r15d, %r15d
movl %r15d, %eax
movq 0x15c8(%rbx), %rdx
subq 0x15c0(%rbx), %rdx
sarq $0x3, %rdx
cmpq %rax, %rdx
jbe 0x6ef01
movl (%r12), %edi
movl %r15d, %esi
callq 0x9ec09
movq (%rbx), %rdi
orl $-0x1, (%rsp)
xorl %esi, %esi
movl %eax, %edx
pushq $0x15
popq %rcx
xorl %r8d, %r8d
leaq 0xc0(%rsp), %r9
callq 0x600c8
incl %r15d
jmp 0x6eeb8
movq 0xe0(%rsp), %rax
movq 0x58(%rsp), %r15
andl $0x0, (%rax,%r15,4)
leaq 0xc0(%rsp), %rdi
callq 0x3355a
leaq 0x80(%rsp), %rdi
callq 0x5c44e
addq $0x4, %r12
jmp 0x6edc0
movl 0x14(%rsp), %eax
incl %eax
jmp 0x6ed32
movq %rbx, %rdi
callq 0x72f2a
movl %eax, %r15d
cmpl $0x3, 0x1614(%rbx)
jb 0x6ef7c
movq 0xf703c(%rip), %rdi     # 0x165f98
leaq 0x6fa78(%rip), %rsi     # 0xde9db
callq 0x289f0
movzbl %r15b, %esi
movq %rax, %rdi
callq 0x29180
movq %rax, %rdi
callq 0x284a0
testb %r15b, %r15b
leaq 0xa8(%rsp), %r13
jne 0x6f1b8
movl 0x1708(%rbx), %ecx
testl %ecx, %ecx
je 0x6efa5
movl 0x13e8(%rbx), %eax
xorl %edx, %edx
divl %ecx
testl %edx, %edx
je 0x6efce
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x8b35a
leaq 0x60(%rsp), %rdi
callq 0x295a0
leaq 0x1a8(%rsp), %rdi
callq 0x295a0
jmp 0x6e891
pushq $0x1
popq %r15
movl 0x16fc(%rbx), %eax
cmpl %eax, %r15d
ja 0x6f018
leaq 0x268(%rsp), %r12
movq %r12, %rdi
leaq 0x130(%rsp), %rsi
callq 0x8689c
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
leaq 0x158(%rsp), %rcx
callq 0x7ee94
movq %r12, %rdi
callq 0x85c60
incl %r15d
jmp 0x6efd2
pushq $0x1
popq %r15
cmpl %eax, %r15d
ja 0x6efa5
movq %rbx, %rdi
movl %r15d, %esi
leaq 0x158(%rsp), %rdx
callq 0x7f1ba
incl %r15d
movl 0x16fc(%rbx), %eax
jmp 0x6f01c
movl 0x16fc(%rbx), %edx
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
callq 0x734e6
leaq 0x130(%rsp), %rdi
leaq 0xf8(%rsp), %r14
movq %r14, %rsi
callq 0x9ca60
movq %r14, %rdi
callq 0x85c60
movl 0x1620(%rbx), %eax
movl 0x16fc(%rbx), %ecx
xorl %edx, %edx
divl %ecx
movq %rax, 0x18(%rsp)
movl %ebp, %eax
cmpl %ecx, %ebp
ja 0x6e7d5
movl %ebp, %r12d
movl %ebp, %ecx
movl %eax, 0x14(%rsp)
movl %eax, %r14d
movq %rcx, 0x58(%rsp)
imulq $0x18, %rcx, %r15
xorl %r13d, %r13d
cmpq 0x18(%rsp), %r13
jae 0x6f1a1
leaq (%r14,%r13), %rax
movl %eax, %ebp
movq 0x1d20(%rbx), %rcx
movl %r12d, (%rcx,%rbp,4)
movq 0x1d38(%rbx), %rcx
movq (%rcx,%r15), %rcx
movl %eax, (%rcx,%r13,4)
movl 0x1614(%rbx), %eax
cmpl $0x4, %eax
jb 0x6f141
movq 0xf6eaf(%rip), %rdi     # 0x165f98
movq 0x58(%rsp), %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x70510(%rip), %rsi     # 0xdf60d
callq 0x289f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x704f6(%rip), %rsi     # 0xdf60d
callq 0x289f0
movq 0x1d38(%rbx), %rcx
movq (%rcx,%r15), %rcx
movl (%rcx,%r13,4), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movl 0x1614(%rbx), %eax
cmpl $0x3, %eax
jb 0x6f199
movq 0xf6e4b(%rip), %rdi     # 0x165f98
leaq 0x6f8d5(%rip), %rsi     # 0xdea29
callq 0x289f0
movq 0x1d20(%rbx), %rcx
movl (%rcx,%rbp,4), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xf6e1e(%rip), %rdi     # 0x165f98
leaq 0x6f8bc(%rip), %rsi     # 0xdea3d
callq 0x289f0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
incq %r13
jmp 0x6f0ac
movl %r12d, %ebp
incl %ebp
movl 0x16fc(%rbx), %ecx
movl 0x14(%rsp), %eax
addl %r13d, %eax
jmp 0x6f08c
leaq 0x20(%rsp), %rdi
callq 0x8b35a
leaq 0x60(%rsp), %rdi
callq 0x295a0
leaq 0x1a8(%rsp), %rdi
callq 0x295a0
leaq 0x248(%rsp), %rdi
callq 0x295a0
leaq 0x158(%rsp), %rdi
callq 0x8b72c
leaq 0xe0(%rsp), %rdi
callq 0x5b268
leaq 0xf8(%rsp), %rdi
callq 0x8b35a
leaq 0x130(%rsp), %rdi
callq 0x85c60
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6ddf3(%rip), %rsi     # 0xdd026
leaq 0xa0(%rsp), %rdi
movq 0x8(%rsp), %rdx
callq 0x3338b
movl 0x13e8(%rbx), %esi
leaq 0x80(%rsp), %rdi
callq 0x9f56b
leaq 0x60(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x4e6ed
leaq 0x6ddc5(%rip), %rdx     # 0xdd03e
leaq 0x228(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3336c
leaq 0x228(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aed2
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
jmp 0x6f2e3
jmp 0x6f2ea
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x295a0
jmp 0x6f2bf
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x6f2f5
jmp 0x6f444
movq %rax, %rbx
jmp 0x6f4e3
jmp 0x6f444
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x295a0
jmp 0x6f2ed
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x295a0
jmp 0x6f4fd
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x295a0
jmp 0x6f314
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x295a0
jmp 0x6f33a
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x6f3bf
jmp 0x6f3af
jmp 0x6f3ce
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x295a0
jmp 0x6f3a5
jmp 0x6f3af
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x295a0
jmp 0x6f35d
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x6f4aa
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
jmp 0x6f3bf
jmp 0x6f3ce
jmp 0x6f428
jmp 0x6f3ce
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x6f4b7
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
jmp 0x6f40b
movq %rax, %rbx
jmp 0x6f4bc
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x6f40b
movq %rax, %rbx
jmp 0x6f4a5
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x295a0
jmp 0x6f4a5
jmp 0x6f465
movq %rax, %rbx
jmp 0x6f4af
jmp 0x6f428
jmp 0x6f465
jmp 0x6f400
movq %rax, %rbx
leaq 0x298(%rsp), %rdi
callq 0x295a0
jmp 0x6f3f4
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x295a0
jmp 0x6f403
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x295a0
jmp 0x6f42b
jmp 0x6f465
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0x85c60
jmp 0x6f49b
jmp 0x6f465
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x6f4aa
jmp 0x6f465
jmp 0x6f465
movq %rax, %rbx
movq %r13, %rdi
jmp 0x6f496
jmp 0x6f465
jmp 0x6f465
jmp 0x6f465
movq %rax, %rbx
jmp 0x6f4f0
jmp 0x6f460
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
callq 0x5c44e
jmp 0x6f48e
movq %rax, %rbx
jmp 0x6f48e
movq %rax, %rbx
jmp 0x6f49b
jmp 0x6f47e
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x295a0
jmp 0x6f481
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3355a
leaq 0x80(%rsp), %rdi
callq 0x5c44e
leaq 0x20(%rsp), %rdi
callq 0x8b35a
leaq 0x60(%rsp), %rdi
callq 0x295a0
leaq 0x1a8(%rsp), %rdi
callq 0x295a0
leaq 0x248(%rsp), %rdi
callq 0x295a0
leaq 0x158(%rsp), %rdi
callq 0x8b72c
leaq 0xe0(%rsp), %rdi
callq 0x5b268
leaq 0xf8(%rsp), %rdi
callq 0x8b35a
leaq 0x130(%rsp), %rdi
callq 0x85c60
movq %rbx, %rdi
callq 0x292f0
nop