// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::checkMasterMessages()
vector<unsigned int> Swarm::checkMasterMessages() {  //razi:  modified version, particles replaced with subparticles
	unsigned int pID, mid, NumNewlyFinishedParticles=0;
	std::vector<unsigned int> NewlyFinishedParticles;

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

	// First let's check interswarm communication
	int numMessages = swarmComm->recvMessage(-1, 0, -1, true, swarmComm->univMessageReceiver);
	//if we set false in the boolean above, the program still works for multiple models, but doesn't work for single models, who knows why...
	if (numMessages >= 1) {
		if (options.verbosity >= 3) {
			cout << "Found " << numMessages << " messages" << endl;
		}

		pair <Pheromones::swarmMsgHolderIt, Pheromones::swarmMsgHolderIt> smhRange;

		smhRange = swarmComm->univMessageReceiver.equal_range(SIMULATION_END);

		for (Pheromones::swarmMsgHolderIt sm = smhRange.first; sm != smhRange.second; ++sm) {

			unsigned int subParID;
			subParID = sm->second.sender;

			pID = fcalcParID(subParID, options.models.size());
			mid= fcalcMID(subParID, options.models.size());

			fixRunningParticle(subParID);


			if (options.verbosity >= 3) {
				cout << "subParticle [" << subParID << ":"<< pID <<"-"<< mid <<"] finished simulation" << endl;
			}
			// Get an iterator to the particle in our list of running particles
			runningSubParticlesIterator_ = runningSubParticles_.find(subParID);
			// Then remove it
			if (runningSubParticlesIterator_ == runningSubParticles_.end()) {
				string errMsg = "Error: Couldn't remove subParticle " + toString(subParID) + " from runningParticle list.";

				if(options.verbosity >= 3) {

					cout << "Size of runningSubParticles_: " << runningSubParticles_.size() << endl;
					cout << "Subparticles in running list are: " << endl;

					for(auto myIt = runningSubParticles_.begin(); myIt != runningSubParticles_.end(); myIt++){
						cout << "first: " << *myIt << endl;

					}
					cout << "Done listing running particles. " << endl;
				}
				outputError(errMsg);
			}

			if(options.verbosity >= 3) {

				cout << "Master messages Added supar " << subParID << " to finnished list and removed it from running list" << endl;
			}
			runningSubParticles_.erase(runningSubParticlesIterator_);
			finishedSubParticles_.insert(subParID); //razi: add to the list
			++particleIterationCounter_[pID][mid];
			if(options.verbosity >= 5) {

				cout << "Master messages running sub" << runningSubParticles_.size() << " finished size " << finishedSubParticles_.size() << endl;
			}
			update_cur_particle_params(pID, mid, true); //razi: TODO  the same procedure should be done in other places, the slave sends theliust of free parameters for subparticle that should be reordered for particles

			//finishedsubParticles.push_back(subParID);


			//razi: was ++flightCounter_;    //razi increment the flight counter if this subparticle completes a particle
			NewlyFinishedParticles = update_finished_running_particles(); //update particle lists
			NumNewlyFinishedParticles = NewlyFinishedParticles.size(); //update particle lists
			flightCounter_=flightCounter_+ NumNewlyFinishedParticles;
			if (options.verbosity == 3) {
				cout << "Master NumNewlyFinishedParticles " <<  NumNewlyFinishedParticles << " Flightcounter " << flightCounter_ << endl;
			}
			unsigned int gen = currentGeneration;
			string paramsString;
			if (options.synchronicity == 1 || options.synchronicity == 0) { //Raquel testing
				if (options.fitType == "ga") {
					paramsString = "gen" + toString(gen) + "perm" + toString(subParID) + " ";
				}
				else if (options.fitType == "pso") {
					paramsString = "flock" + toString(gen) + "SubParticle" + toString(subParID) + " ";
				}

			}
			/*else if (options.synchronicity == 0) {
				// Increment our flight counter

				// TODO: This run summary contains 1 less particle than it should.
				// Output a run summary every outputEvery flights
				if (flightCounter_ % options.outputEvery == 0) {
					string outputPath = options.jobOutputDir + toString(flightCounter_) + "_summary.txt";
					outputRunSummary(outputPath);
				}

				paramsString = toString(flightCounter_) + " ";
			}
	*/
			// Store the parameters given to us by the particle


//cout<< "check messages: this part may need modifications ...."<<endl;

//razi: just for debugging, later del
/*int i1, i2;
cout<<"size 1:"<< subparticleCurrParamSets_.size()<<endl;
i1=0;
for (auto ii=subparticleCurrParamSets_.begin(); ii!=subparticleCurrParamSets_.end(); ii++){
	i2=0;
	for (auto jj=ii->second.begin(); jj!=ii->second.end(); jj++){
		cout<<"size [p-sp]: ["<< i1<<","<<i2 <<"]: "<< jj->second.size()<<endl;
		i2++;
	}i1++;
}
*/

			vector<double> paramsVec;
			int i = 0;
			for (vector<string>::iterator m = sm->second.message.begin() + 1; m != sm->second.message.end(); ++m) {
				paramsString += *m + " ";
//cout<<"paramsString["<<i<<"]= "<<paramsString<<endl; //mypause();
				paramsVec.push_back(stod(*m));
				if (options.fitType == "ga") {
					subparticleCurrParamSets_[pID][mid][i] = stod(*m);   //razi: the list and order of free params can be different for  different models
					if (options.verbosity>= 3) {
						cout << "pID " << pID << " mid " << mid << " i " << i << " *m " << *m << endl;
					}
					particleCurrParamSets_[pID][i] = stod(*m);
				}
				++i;
			}
			if(options.verbosity >= 5) {

cout<<i <<" Params collected for one subparticle: "<<paramsString<<endl; //mypause();
subparticleCurrParamSets_copy = subparticleCurrParamSets_;
particleCurrParamSets_copy = particleCurrParamSets_;

			}
			update_cur_particle_params(pID, mid, true); //razi: TODO  the same procedure should be done in other places, the slave sends theliust of free parameters for subparticle that should be reordered for particles

			if (options.verbosity>= 3) {cout << "params are stored" << endl;} //mypause();}

			double fitCalc = stod(sm->second.message[0]);
			if (options.verbosity>= 3) {cout << "fitCalc: " << fitCalc <<endl;} //mypause();}


			update_fitCalcs(); //razi: TODO: later develop and test this function
			if(options.verbosity >= 3) {

cout << "add to allGenFits fitCalc: " << fitCalc <<" params:" << paramsString<<endl; //mypause();
			}
			allGenFits.insert(pair<double, string>(fitCalc, order_params(paramsString, mid)));
			swarmBestFits_.insert(pair<double, unsigned int>(fitCalc, pID));
			subswarmBestFits_.insert(pair<double, unsigned int>(fitCalc, subParID));
			currentsubswarmBestFits_.insert(pair<double, unsigned int>(fitCalc, subParID));
			currentsubswarmBestFits_copy.insert(pair<double, unsigned int>(fitCalc, subParID));

			if(options.verbosity>=3){

				cout << "@@@@@@@@@@@@@@@@@ currentsubswarmBestFits_ size A " << currentsubswarmBestFits_.size() << " @@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;

			}
//cout << "add to swarmBestFits_ fitCalc: " << fitCalc <<endl;mypause();

			if (options.fitType == "pso") {
				processParamsPSO(paramsVec, subParID, fitCalc);
			}

			if (options.fitType == "de") {
				processParamsDE(paramsVec, subParID, fitCalc);
			}
		}

		// TODO: When sending NEXT_GENERATION, make sure failed particles have actually run again. If not, they need re-launched.
		if(options.verbosity >= 5) {

			cout << "RAQUEL: before univMessageReceiver.equal_range(SIMULATION_FAIL)" << endl;
			cout << "Number of runnning subparticles before" << runningSubParticles_.size() << endl;
		}
		smhRange = swarmComm->univMessageReceiver.equal_range(SIMULATION_FAIL);
		if(options.verbosity >= 5) {

			cout << "RAQUEL: after univMessageReceiver.equal_range(SIMULATION_FAIL);" << endl;
		}
		for (Pheromones::swarmMsgHolderIt sm = smhRange.first; sm != smhRange.second; ++sm) {

			unsigned int subParID = sm->second.sender;
			pID = fcalcParID(subParID, options.models.size());
			mid= fcalcMID(subParID, options.models.size());

			fixRunningParticle(subParID);

			// Get an iterator to the particle in our list of running particles
			runningSubParticlesIterator_ = runningSubParticles_.find(subParID);
			if(options.verbosity >= 5) {

				cout << "Number of runnning subparticles before erasing" << runningSubParticles_.size() << endl;
			}


			if (runningSubParticlesIterator_ == runningSubParticles_.end()) {
				string errMsg = "Error: Couldn't remove particle " + toString(pID) +  "  SubParticle " + toString(subParID) + " from runningParticle list.";
				outputError(errMsg);
			}else{
				runningSubParticles_.erase(runningSubParticlesIterator_);
				if(options.verbosity >= 5) {

					cout << "RAQUEL Erased one subparticle fro running list " << endl;
					cout << "New size: " << runningSubParticles_.size() << endl;
				}
			}
			runningSubParticlesIterator_ = failedSubParticles_.find(subParID);
			if (runningSubParticlesIterator_== failedSubParticles_.end())  //add to the list of failed subparticles
				failedParticles_.insert(subParID);
			else{
				string errMsg = "Error: subparticle failed, but failure was already reported for particle " + toString(pID) +  "  SubParticle " + toString(subParID);
				outputError(errMsg);
			}
			update_finished_running_particles();


			cout << "Particle " << pID << " SubParticle:" << subParID << "  failed in gen " << currentGeneration << endl;

			// Store particle ID in our list of failed particles

		}
		if(options.verbosity >= 5) {

			cout << "RAQUEL: After for (Pheromones::swarmMsgHolderIt sm = smhRange.first; sm != smhRange.second; ++sm) {" << endl;
		}
		int messageCount = 0;
		if(options.verbosity >= 5) {

			cout << "RAQUEL: Before for (Pheromones::swarmMsgHolderIt sm = smhRange.first; sm != smhRange.second; ++sm) { {" << endl;
		}
		smhRange = swarmComm->univMessageReceiver.equal_range(GET_RUNNING_PARTICLES);
		for (Pheromones::swarmMsgHolderIt sm = smhRange.first; sm != smhRange.second; ++sm) {

			vector<string> intParts;
			//for (auto i: runningParticles_) {
			for (auto i = runningSubParticles_.begin(); i != runningSubParticles_.end(); ++i) { //razi: get list of subparticles
				intParts.push_back(toString(*i));
			}
			messageCount++;
			//cout << "RAQUEL: Sending " << messageCount << " messages." << endl;
			//cout << "RAQUEL: sending message to subpar " << sm->second.sender << " message=Running_particles" << endl;
			swarmComm->sendToSwarm(0, sm->second.sender, SEND_RUNNING_PARTICLES, true, intParts);
			//cout << "RAQUEL: Sent " << messageCount << " messages." << endl;
		}

		if(options.verbosity >= 5) {

			cout << "RAQUEL: After for (Pheromones::swarmMsgHolderIt sm = smhRange.first; sm != smhRange.second; ++sm) { {" << endl;
		}

		swarmComm->univMessageReceiver.clear();

	}

	// Now let's check for any external messages
	//checkExternalMessages();
	if (options.verbosity>= 4) {

		cout<<"checking message is finished.\n";
		cout << "RAQUEL: NewlyFinishedParticles = " << toString(NewlyFinishedParticles.size()) << endl;
	}

	return NewlyFinishedParticles;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rsi, %r14
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movq %rdi, 0xb8(%rsp)
movups %xmm0, (%rdi)
cmpl $0x3, 0x1614(%rsi)
jb 0x7710f
movq 0xeee9d(%rip), %rdi     # 0x165f98
leaq 0x66c48(%rip), %rsi     # 0xddd4a
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%r14), %rdi
leaq 0x18(%rdi), %r9
orl $-0x1, 0x8(%rsp)
movl $0x1, (%rsp)
pushq $-0x1
popq %rcx
pushq $0x1
popq %r8
movl %ecx, %esi
xorl %edx, %edx
callq 0x60fd6
movl %eax, %ebx
testl %eax, %eax
jle 0x77ee0
cmpl $0x3, 0x1614(%r14)
jb 0x7717a
movq 0xeee4b(%rip), %rdi     # 0x165f98
leaq 0x628be(%rip), %rsi     # 0xd9a12
callq 0x289f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x29290
leaq 0x89195(%rip), %rsi     # 0x1002ff
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%r14), %rdi
addq $0x18, %rdi
leaq 0x28(%rsp), %rsi
movl $0xd, (%rsi)
callq 0x5da18
movq %rdx, 0x188(%rsp)
movq %rax, %r12
leaq 0x1820(%r14), %rax
movq %rax, 0xc0(%rsp)
leaq 0x1828(%r14), %rax
movq %rax, 0xd8(%rsp)
leaq 0x1890(%r14), %rax
movq %rax, 0x180(%rsp)
leaq 0x1950(%r14), %rax
movq %rax, 0x178(%rsp)
leaq 0x14e0(%r14), %rbp
leaq 0x1460(%r14), %rax
movq %rax, 0xd0(%rsp)
leaq 0x1400(%r14), %rax
movq %rax, 0xc8(%rsp)
leaq 0x1490(%r14), %rax
movq %rax, 0x148(%rsp)
leaq 0x1430(%r14), %rax
movq %rax, 0x140(%rsp)
leaq 0x8(%r14), %rax
movq %rax, 0x170(%rsp)
leaq 0x1bd0(%r14), %rax
movq %rax, 0x168(%rsp)
leaq 0x1c00(%r14), %rax
movq %rax, 0x160(%rsp)
leaq 0x1c30(%r14), %rax
movq %rax, 0x158(%rsp)
leaq 0x1c60(%r14), %rax
movq %rax, 0x150(%rsp)
leaq 0x28(%rsp), %r13
cmpq 0x188(%rsp), %r12
je 0x77b38
movl 0x34(%r12), %edi
movl %edi, 0x14(%rsp)
movq 0x15c8(%r14), %rsi
subq 0x15c0(%r14), %rsi
shrq $0x3, %rsi
callq 0x9ec1e
movl %eax, 0x18(%rsp)
movl 0x14(%rsp), %edi
movq 0x15c8(%r14), %rsi
subq 0x15c0(%r14), %rsi
shrq $0x3, %rsi
callq 0x9ec14
movl %eax, 0x1c(%rsp)
movl 0x14(%rsp), %esi
movq %r14, %rdi
callq 0x7bbe4
cmpl $0x3, 0x1614(%r14)
jb 0x7733b
movq 0xeecc2(%rip), %rdi     # 0x165f98
leaq 0x66a7f(%rip), %rsi     # 0xddd5c
callq 0x289f0
movl 0x14(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x65438(%rip), %rsi     # 0xdc730
callq 0x289f0
movl 0x18(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x68557(%rip), %rsi     # 0xdf86a
callq 0x289f0
movl 0x1c(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x66a3c(%rip), %rsi     # 0xddd6a
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0xc0(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x8fa0c
movq %rax, 0x1850(%r14)
cmpq 0xd8(%rsp), %rax
je 0x77f69
cmpl $0x3, 0x1614(%r14)
jb 0x773a9
movq 0xeec25(%rip), %rdi     # 0x165f98
leaq 0x66aa9(%rip), %rsi     # 0xdde23
callq 0x289f0
movl 0x14(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x66aab(%rip), %rsi     # 0xdde40
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x1850(%r14), %rax
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
callq 0x8fa5e
movq 0x180(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x8f830
movq 0x178(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x865fc
movq %rax, %rdi
leaq 0x1c(%rsp), %rsi
callq 0x8665e
incl (%rax)
cmpl $0x5, 0x1614(%r14)
jb 0x7743e
movq 0xeeb9b(%rip), %rdi     # 0x165f98
leaq 0x66a70(%rip), %rsi     # 0xdde74
callq 0x289f0
movq 0x1848(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x66a6e(%rip), %rsi     # 0xdde90
callq 0x289f0
movq 0x18b8(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movl 0x18(%rsp), %esi
movl 0x1c(%rsp), %edx
movq %r14, %rdi
pushq $0x1
popq %rcx
callq 0x75af6
movq %r13, %rdi
movq %r14, %rsi
callq 0x7bc26
movq 0xb8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x8f082
movq %r13, %rdi
callq 0x5b268
movq 0x8(%r15), %rbx
subq (%r15), %rbx
shrq $0x2, %rbx
addl %ebx, 0x1d84(%r14)
cmpl $0x3, 0x1614(%r14)
jne 0x774d6
movq 0xeeafe(%rip), %rdi     # 0x165f98
leaq 0x669ff(%rip), %rsi     # 0xddea0
callq 0x289f0
movl %ebx, %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x66a08(%rip), %rsi     # 0xddec2
callq 0x289f0
movl 0x1d84(%r14), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movl 0x13e8(%r14), %ebx
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movq %rbp, %rdi
leaq 0x58aad(%rip), %rsi     # 0xcffa9
callq 0x3357b
testb %al, %al
je 0x7758f
leaq 0x120(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
callq 0x9f56b
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x669a5(%rip), %rsi     # 0xdded2
movq %r15, %rdx
callq 0x4933b
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
leaq 0x6698f(%rip), %rdx     # 0xdded6
callq 0x3336c
movl 0x14(%rsp), %esi
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0x9f56b
leaq 0x70(%rsp), %r15
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
movq %rbx, %rdx
callq 0x4e6ed
movq %r13, %rdi
movq %r15, %rsi
leaq 0x68088(%rip), %rdx     # 0xdf60d
callq 0x3336c
jmp 0x77627
movq %rbp, %rdi
leaq 0x65b39(%rip), %rsi     # 0xdd0d2
callq 0x3357b
testb %al, %al
je 0x77678
leaq 0x120(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
callq 0x9f56b
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x66911(%rip), %rsi     # 0xddedb
movq %r15, %rdx
callq 0x4933b
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
leaq 0x668fd(%rip), %rdx     # 0xddee1
callq 0x3336c
movl 0x14(%rsp), %esi
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0x9f56b
leaq 0x70(%rsp), %r15
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
movq %rbx, %rdx
callq 0x4e6ed
movq %r13, %rdi
movq %r15, %rsi
leaq 0x67feb(%rip), %rdx     # 0xdf60d
callq 0x3336c
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x28c40
movq %r13, %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x295a0
leaq 0x100(%rsp), %rdi
callq 0x295a0
leaq 0x90(%rsp), %rdi
callq 0x295a0
leaq 0xe0(%rsp), %rdi
callq 0x295a0
leaq 0x120(%rsp), %rdi
callq 0x295a0
andq $0x0, 0xa0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq 0x38(%r12), %r15
addq $0x20, %r15
xorl %ebx, %ebx
cmpq 0x40(%r12), %r15
je 0x777f8
movq %r13, %rdi
movq %r15, %rsi
leaq 0x67f5e(%rip), %rdx     # 0xdf60d
callq 0x334ed
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x294d0
movq %r13, %rdi
callq 0x295a0
movq %r15, %rdi
xorl %esi, %esi
callq 0x33525
movsd %xmm0, 0x28(%rsp)
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x5c482
movq %rbp, %rdi
leaq 0x588b6(%rip), %rsi     # 0xcffa9
callq 0x3357b
testb %al, %al
je 0x777ec
movq %r15, %rdi
xorl %esi, %esi
callq 0x33525
movsd %xmm0, 0x20(%rsp)
movq 0xd0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x86550
movq %rax, %rdi
leaq 0x1c(%rsp), %rsi
callq 0x86502
movq (%rax), %rax
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax,%rbx,8)
cmpl $0x3, 0x1614(%r14)
jb 0x777bc
movq 0xee84a(%rip), %rdi     # 0x165f98
leaq 0x66798(%rip), %rsi     # 0xddeed
callq 0x289f0
movl 0x18(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x5fece(%rip), %rsi     # 0xd763e
callq 0x289f0
movl 0x1c(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x5f71e(%rip), %rsi     # 0xd6ea9
callq 0x289f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x6674e(%rip), %rsi     # 0xddef2
callq 0x289f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq %r15, %rdi
xorl %esi, %esi
callq 0x33525
movsd %xmm0, 0x20(%rsp)
movq 0xc8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x86502
movq (%rax), %rax
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
addq $0x20, %r15
jmp 0x77697
cmpl $0x4, 0x1614(%r14)
jbe 0x7785e
movq 0xee78f(%rip), %rdi     # 0x165f98
movl %ebx, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x666dd(%rip), %rsi     # 0xddef7
callq 0x289f0
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq 0x148(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x8adc4
movq 0x140(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0x8b0ce
movl 0x18(%rsp), %esi
movl 0x1c(%rsp), %edx
movq %r14, %rdi
pushq $0x1
popq %rcx
callq 0x75af6
cmpl $0x3, 0x1614(%r14)
jb 0x77896
movq 0xee716(%rip), %rdi     # 0x165f98
leaq 0x66696(%rip), %rsi     # 0xddf1f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x38(%r12), %rdi
xorl %esi, %esi
callq 0x33525
movsd %xmm0, 0x20(%rsp)
cmpl $0x3, 0x1614(%r14)
jb 0x778db
movq 0xee6df(%rip), %rdi     # 0x165f98
leaq 0x66683(%rip), %rsi     # 0xddf43
callq 0x289f0
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq %r14, %rdi
callq 0x7c00a
cmpl $0x3, 0x1614(%r14)
jb 0x77932
movq 0xee6a4(%rip), %rdi     # 0x165f98
leaq 0x66636(%rip), %rsi     # 0xddf31
callq 0x289f0
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
leaq 0x66635(%rip), %rsi     # 0xddf4d
callq 0x289f0
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
callq 0x28dd0
movl 0x1c(%rsp), %ecx
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7c032
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x40(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq 0x70(%rsp), %rax
leaq 0x80(%rsp), %rdx
cmpq %rdx, %rax
je 0x77997
movq %rax, 0x30(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x7799d
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
movq 0x78(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rdx, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
movb $0x0, 0x80(%rsp)
movq 0x170(%rsp), %rdi
movq %r13, %rsi
callq 0x8fb4e
leaq 0x30(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x1d0(%rsp), %rdi
callq 0x295a0
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x168(%rsp), %rdi
movq %r13, %rsi
callq 0x8edfc
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x160(%rsp), %rdi
movq %r13, %rsi
callq 0x8edfc
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x158(%rsp), %rdi
movq %r13, %rsi
callq 0x8edfc
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x150(%rsp), %rdi
movq %r13, %rsi
callq 0x8edfc
cmpl $0x3, 0x1614(%r14)
jb 0x77abe
movq 0xee50c(%rip), %rdi     # 0x165f98
leaq 0x664c3(%rip), %rsi     # 0xddf56
callq 0x289f0
movq 0x1c58(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x65bac(%rip), %rsi     # 0xdd65d
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq %rbp, %rdi
leaq 0x6560a(%rip), %rsi     # 0xdd0d2
callq 0x3357b
testb %al, %al
je 0x77aeb
movl 0x14(%rsp), %edx
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
movsd 0x20(%rsp), %xmm0
callq 0x755d4
movq %rbp, %rdi
leaq 0x94966(%rip), %rsi     # 0x10c45b
callq 0x3357b
testb %al, %al
je 0x77b18
movl 0x14(%rsp), %edx
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
movsd 0x20(%rsp), %xmm0
callq 0x75eb4
leaq 0x90(%rsp), %rdi
callq 0x5c44e
leaq 0x50(%rsp), %rdi
callq 0x295a0
movq (%r12), %r12
jmp 0x77268
cmpl $0x4, 0x1614(%r14)
jbe 0x77b87
movq 0xee44f(%rip), %rdi     # 0x165f98
leaq 0x66439(%rip), %rsi     # 0xddf89
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0xee434(%rip), %rdi     # 0x165f98
leaq 0x6645e(%rip), %rsi     # 0xddfc9
callq 0x289f0
movq 0x1848(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq (%r14), %rdi
addq $0x18, %rdi
leaq 0x28(%rsp), %rsi
movl $0xe, (%rsi)
callq 0x5da18
movq %rdx, 0x20(%rsp)
movq %rax, %rbx
cmpl $0x5, 0x1614(%r14)
jb 0x77bcb
movq 0xee3e1(%rip), %rdi     # 0x165f98
leaq 0x66432(%rip), %rsi     # 0xddff0
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x1858(%r14), %rax
movq %rax, 0xd0(%rsp)
leaq 0x1860(%r14), %rax
movq %rax, 0xc8(%rsp)
leaq 0x19d0(%r14), %r13
leaq 0x100(%rsp), %rbp
movq 0xee399(%rip), %r15     # 0x165f98
leaq 0x210(%rsp), %r12
cmpq 0x20(%rsp), %rbx
je 0x77dc5
movl 0x34(%rbx), %edi
movl %edi, 0x100(%rsp)
movq 0x15c8(%r14), %rsi
subq 0x15c0(%r14), %rsi
shrq $0x3, %rsi
callq 0x9ec1e
movl %eax, 0x18(%rsp)
movl 0x100(%rsp), %edi
movq 0x15c8(%r14), %rsi
subq 0x15c0(%r14), %rsi
shrq $0x3, %rsi
callq 0x9ec14
movl %eax, 0x1c(%rsp)
movl 0x100(%rsp), %esi
movq %r14, %rdi
callq 0x7bbe4
movq 0xc0(%rsp), %rdi
movq %rbp, %rsi
callq 0x8fa0c
movq %rax, 0x1850(%r14)
cmpl $0x5, 0x1614(%r14)
jb 0x77cb6
movq %r15, %rdi
leaq 0x6639d(%rip), %rsi     # 0xde030
callq 0x289f0
movq 0x1848(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0x1850(%r14), %rax
cmpq 0xd8(%rsp), %rax
je 0x7805a
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
callq 0x8fa5e
cmpl $0x5, 0x1614(%r14)
jb 0x77d1b
movq %r15, %rdi
leaq 0x663a7(%rip), %rsi     # 0xde08f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq %r15, %rdi
leaq 0x663c0(%rip), %rsi     # 0xde0bf
callq 0x289f0
movq 0x1848(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xd0(%rsp), %rdi
movq %rbp, %rsi
callq 0x8fa0c
movq %rax, 0x1850(%r14)
cmpq 0xc8(%rsp), %rax
jne 0x7813e
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8f830
movq %r12, %rdi
movq %r14, %rsi
callq 0x7bc26
movq %r12, %rdi
callq 0x5b268
movq %r15, %rdi
leaq 0x6631d(%rip), %rsi     # 0xde085
callq 0x289f0
movl 0x18(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x65853(%rip), %rsi     # 0xdd5d6
callq 0x289f0
movl 0x100(%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x66373(%rip), %rsi     # 0xde114
callq 0x289f0
movl 0x13e8(%r14), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq (%rbx), %rbx
jmp 0x77c07
cmpl $0x4, 0x1614(%r14)
jbe 0x77e0f
movq 0xee1c2(%rip), %rdi     # 0x165f98
leaq 0x66348(%rip), %rsi     # 0xde125
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
cmpl $0x5, 0x1614(%r14)
jb 0x77e0f
movq 0xee19d(%rip), %rdi     # 0x165f98
leaq 0x66387(%rip), %rsi     # 0xde189
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%r14), %rdi
addq $0x18, %rdi
leaq 0x28(%rsp), %rsi
movl $0xb, (%rsi)
callq 0x5da18
movq %rax, %rbx
movq %rdx, %r15
leaq 0x50(%rsp), %r13
leaq 0x28(%rsp), %rbp
cmpq %r15, %rbx
je 0x77eaf
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq 0x1838(%r14), %r12
cmpq 0xd8(%rsp), %r12
je 0x77e87
movl 0x20(%r12), %esi
movq %rbp, %rdi
callq 0x9f56b
movq %r13, %rdi
movq %rbp, %rsi
callq 0x5ec8c
movq %rbp, %rdi
callq 0x295a0
movq %r12, %rdi
callq 0x28b60
movq %rax, %r12
jmp 0x77e50
movq (%r14), %rdi
movl 0x34(%rbx), %edx
orl $-0x1, (%rsp)
xorl %esi, %esi
pushq $0xc
popq %rcx
pushq $0x1
popq %r8
movq %r13, %r9
callq 0x600c8
movq %r13, %rdi
callq 0x3355a
movq (%rbx), %rbx
jmp 0x77e36
cmpl $0x4, 0x1614(%r14)
jbe 0x77ed4
movq 0xee0d8(%rip), %rdi     # 0x165f98
leaq 0x66329(%rip), %rsi     # 0xde1f0
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%r14), %rdi
addq $0x18, %rdi
callq 0x5d19a
cmpl $0x4, 0x1614(%r14)
jb 0x77f4f
movq 0xee0a7(%rip), %rdi     # 0x165f98
leaq 0x6635e(%rip), %rsi     # 0xde256
callq 0x289f0
movq 0xee094(%rip), %rdi     # 0x165f98
leaq 0x6636a(%rip), %rsi     # 0xde275
callq 0x289f0
movq %rax, %rbx
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x2, %rsi
leaq 0x28(%rsp), %rdi
callq 0x9f5c1
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
leaq 0x28(%rsp), %rdi
callq 0x295a0
movq 0xb8(%rsp), %rax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x14(%rsp), %esi
leaq 0x70(%rsp), %rdi
callq 0x9f56b
leaq 0x65e02(%rip), %rsi     # 0xddd80
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x4933b
leaq 0x65e10(%rip), %rdx     # 0xddda4
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3336c
leaq 0x50(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x295a0
cmpl $0x3, 0x1614(%r14)
jb 0x78214
movq 0xedfcc(%rip), %rdi     # 0x165f98
leaq 0x65ded(%rip), %rsi     # 0xdddc0
callq 0x289f0
movq 0x1848(%r14), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xedfa2(%rip), %rdi     # 0x165f98
leaq 0x65de2(%rip), %rsi     # 0xddddf
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x1838(%r14), %r12
movq 0xedf80(%rip), %rbx     # 0x165f98
leaq 0x5f502(%rip), %r15     # 0xd7521
cmpq 0xd8(%rsp), %r12
je 0x781f9
movq %rbx, %rdi
movq %r15, %rsi
callq 0x289f0
movl 0x20(%r12), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq %r12, %rdi
callq 0x28b60
movq %rax, %r12
jmp 0x7801f
movl 0x18(%rsp), %esi
leaq 0xe0(%rsp), %rdi
callq 0x9f56b
leaq 0x65fed(%rip), %rsi     # 0xde05f
leaq 0x90(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x4933b
leaq 0x65ff2(%rip), %rdx     # 0xde080
leaq 0x70(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x3336c
movl 0x100(%rsp), %esi
leaq 0x120(%rsp), %rdi
callq 0x9f56b
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x4e6ed
leaq 0x65cd2(%rip), %rdx     # 0xddda4
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3336c
leaq 0x50(%rsp), %rdi
callq 0x295a0
leaq 0x120(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x90(%rsp), %rdi
callq 0x295a0
leaq 0xe0(%rsp), %rdi
callq 0x295a0
leaq 0x1b0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x28dd0
leaq 0x1b0(%rsp), %rsi
movq %r14, %rdi
callq 0x6aed2
movl 0x18(%rsp), %esi
leaq 0x90(%rsp), %rdi
callq 0x9f56b
leaq 0x65f74(%rip), %rsi     # 0xde0ca
leaq 0x70(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x4933b
leaq 0x65f11(%rip), %rdx     # 0xde080
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3336c
movl 0x100(%rsp), %esi
leaq 0xe0(%rsp), %rdi
callq 0x9f56b
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x4e6ed
leaq 0xe0(%rsp), %rdi
callq 0x295a0
leaq 0x50(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x90(%rsp), %rdi
callq 0x295a0
leaq 0x190(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x28dd0
leaq 0x190(%rsp), %rsi
movq %r14, %rdi
callq 0x6aed2
movq 0xedd98(%rip), %rdi     # 0x165f98
leaq 0x65bfb(%rip), %rsi     # 0xdde02
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x1f0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x28dd0
leaq 0x1f0(%rsp), %rsi
movq %r14, %rdi
callq 0x6aed2
jmp 0x782e2
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
jmp 0x782a2
jmp 0x782e2
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
jmp 0x782a2
jmp 0x782e2
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x295a0
jmp 0x78288
jmp 0x78413
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x295a0
jmp 0x782c7
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x295a0
jmp 0x782d6
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x295a0
jmp 0x782e5
jmp 0x78413
jmp 0x78413
jmp 0x78413
jmp 0x78413
jmp 0x782e2
jmp 0x78413
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x295a0
jmp 0x782f2
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x295a0
jmp 0x78301
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x7845e
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x295a0
jmp 0x7832c
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x295a0
jmp 0x7833c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x295a0
jmp 0x7834e
jmp 0x78413
jmp 0x78413
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x7845e
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x7845e
jmp 0x7838d
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x7845e
jmp 0x78379
jmp 0x78388
jmp 0x78374
jmp 0x78383
jmp 0x7836c
jmp 0x78413
jmp 0x78413
movq %rax, %rbx
jmp 0x78459
movq %rax, %rbx
jmp 0x783b4
movq %rax, %rbx
jmp 0x7839a
jmp 0x78413
movq %rax, %rbx
jmp 0x783c1
movq %rax, %rbx
jmp 0x783a7
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x100(%rsp), %rdi
callq 0x295a0
leaq 0x90(%rsp), %rdi
callq 0x295a0
leaq 0xe0(%rsp), %rdi
callq 0x295a0
leaq 0x120(%rsp), %rdi
callq 0x295a0
jmp 0x78459
jmp 0x78418
jmp 0x78413
jmp 0x78413
jmp 0x78449
jmp 0x78449
jmp 0x78449
movq %rax, %rbx
jmp 0x783fb
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x1d0(%rsp), %rdi
jmp 0x7843e
jmp 0x78449
jmp 0x78449
jmp 0x78413
jmp 0x78413
jmp 0x78449
jmp 0x78449
jmp 0x78413
movq %rax, %rbx
jmp 0x78463
movq %rax, %rbx
jmp 0x7842a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x295a0
leaq 0x50(%rsp), %rdi
callq 0x3355a
jmp 0x78463
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x295a0
jmp 0x7844c
jmp 0x78449
jmp 0x78449
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x5c44e
leaq 0x50(%rsp), %rdi
callq 0x295a0
movq 0xb8(%rsp), %rdi
callq 0x5b268
movq %rbx, %rdi
callq 0x292f0