// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Particle.cpp
// Function: Particle::calculateFit(bool, unsigned int)
void Particle::calculateFit(bool local, unsigned int mid) {

	//razi TODO: check if the fit calculation is corrent.

	//swarm_->outputError("Particle::calculateFit needs modification");

	bool usingSD = false;
	bool usingMean = false;

	// Construct pointers to the relevant fitting function.
	// This lets us avoid a switch/case or excess conditionals
	// within the calculation loop
	if (swarm_->options.objFunc == 1) {
		objFuncPtr = &Particle::objFunc_sumOfSquares;
	}
	else if (swarm_->options.objFunc == 2) {
		objFuncPtr = &Particle::objFunc_chiSquare;
		usingSD = true;
	}
	else if (swarm_->options.objFunc == 3) {
		objFuncPtr = &Particle::objFunc_divByMeasured;
	}
	else if (swarm_->options.objFunc == 4) {
		objFuncPtr = &Particle::objFunc_divByMean;
		usingMean = true;
	}

	double colSum;
	double setSum;
	double totalSum;
	double divisor;


	//razi: loop over all subparticles associated with models

	unsigned int subParID = calcsubParID(mid);
	if ((mid<0)|| (mid >= swarm_->getNumModels()) || (!getSubParticle(mid)) || (!models.at(mid)) || (dataFiles_.at(mid).empty())){
		outputError("calculateFit Failed. Invalid SubParticle.  PID:"+ toString(id_) + "  model id:" + toString(mid)+ "  subParID:" + toString(subParID)+". Quitting !!!");
	}else{

		totalSum = 0;
		divisor = 0;
		int notfoundCount = 0;
		// Loop through .exp files. Iterator points to string/dataset pair
		for (auto e = swarm_->options.expFiles.begin(); e != swarm_->options.expFiles.end(); ++e){
			if(swarm_->options.verbosity >=4){
				cout << "DATA FILE FOR MID " << mid << " " << e->first << endl;
			}


			if ( dataFiles_.at(mid).find(e->first) == dataFiles_.at(mid).end() ) {
			  // not found
				if(swarm_->options.verbosity >=4){
					cout << "EXPERIMENTAL KEY NOT FOUND IN SIM GDAT FILE: " << e->first << " SKIPING..." << endl;
				}
				continue;
			}

			//razi: we first need to check if the exp file belongs to this subParticle
			if (dataFiles_.at(mid).count(e->first)!=1){
				cout<<"The exp file "<< e->first<< " does not belong to model is:"<<mid<<". try other models."<<endl;
				continue; //Raquel: was a break, making the fit for MID 1 always become zero
			}


			if(swarm_->options.verbosity >=4){
				cout << "RAQUEL PASSED MID " << mid << endl;
			}
			// Loop through .exp columns. Iterator points to column/map pair
			//cout << "exp loop " << e->first << endl;
			setSum = 0;
			if(swarm_->options.verbosity >=4){
				cout << "first: " << e->second->dataCurrent->begin()->first << endl;
				cout << "second " <<  e->second->dataCurrent->begin()->second.begin()->first << endl;
				cout << " third " << e->second->dataCurrent->begin()->second.begin()->second << endl;
			}
			for (std::map<std::string, std::map<double,double> >::iterator exp_col = e->second->dataCurrent->begin(); exp_col != e->second->dataCurrent->end(); ++exp_col) {
				// Loop through timepoints of column.  Iterator points to a timepoint/value pair

				if (usingMean) {
					//cout << "trying to set mean" << endl;
					divisor = e->second->colAverages.at(exp_col->first);
					//cout << "mean set" << endl;
					if(swarm_->options.verbosity >=4){
						cout << "RAQUEL divisor(colmean): " << divisor << endl;
					}
				}

				//cout << "col loop " << exp_col->first << endl;
				colSum = 0;
				for (std::map<double,double>::iterator timepoint = exp_col->second.begin(); timepoint != exp_col->second.end(); ++timepoint) {
					if (std::isnan(timepoint->second)) {
						continue;
					}

					//double exp = timepoint->second;
					//cout << "exp: " << exp << endl;
					if ( dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing)->dataCurrent->find(exp_col->first) == dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing)->dataCurrent->end() ) {
					  // not found
						if(swarm_->options.verbosity >=4){
							cout << "EXPERIMENTAL KEY NOT FOUND IN SIM GDAT FILE, exp_col: " << exp_col->first << " SKIPING..." << endl;

						}
						notfoundCount++;

						if((unsigned)notfoundCount>=e->second->dataCurrent->size()){
							if(swarm_->options.verbosity >=4){
								cout << "Went through all EXP columns and didn't find any result in the SIM GDAT, skipping this failed simulation." << endl;
							}

							totalSum=9999;

						}

						continue;
					}

					if ( dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing)->dataCurrent->at(exp_col->first).find(timepoint->first) == dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing)->dataCurrent->at(exp_col->first).end() ) {
					  // not found
						if(swarm_->options.verbosity >=4){
							cout << "EXPERIMENTAL KEY NOT FOUND IN SIM GDAT FILE, time_point: " << timepoint->first << " SKIPING..." << endl;
						}
						continue;
					}

					if (swarm_->options.smoothing == 1) {
						//cout << "sim: " << dataFiles_.at(e->first).at(swarm_->options.smoothing)->dataCurrent->at(exp_col->first).at(timepoint->first) << endl;


					}
					else {
						//cout << "sim: " << dataFiles_.at(e->first).at(swarm_->options.smoothing + 1)->dataCurrent->at(exp_col->first).at(timepoint->first) << endl;
					}



					if (usingSD) {
						divisor = e->second->standardDeviations.at(exp_col->first).at(timepoint->first);
						//cout << "divisor: " << divisor << endl;
					}

					double sim;
					// TODO: Introduce fudge tolerance to account for precision loss in simulation control column
					if (swarm_->options.smoothing == 1) {
						if(swarm_->options.verbosity >=4){
							cout << "trying smoothing" << endl;
							cout << "MID: " << mid << " data files size: " << dataFiles_.size() << " e->first: " << e->first << " dataFiles_.at(mid) size: " << dataFiles_.at(mid).size() << " exp_col->first: " << exp_col->first << endl;
							cout << "exp_col->first: " << exp_col->first << " timepoint->first: " << timepoint->first << endl;



						}

						if(swarm_->options.verbosity >=9){

							for(auto keys=dataFiles_.at(mid).at(e->first).begin(); keys!=dataFiles_.at(mid).at(e->first).end(); ++keys){

								cout << "keys: " << keys->first << endl;
								cout << "keys: " << keys->second << endl;

							}
						}

						if(swarm_->options.verbosity >=5){
							cout << "print: " << dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing+1)->dataCurrent->at(exp_col->first).at(timepoint->first) << endl;
						}
						sim = dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing)->dataCurrent->at(exp_col->first).at(timepoint->first);
						//cout << dataCurrent->at(exp_col->first).at(timepoint->first) << endl;
						if(swarm_->options.verbosity >=4){
							cout << " [mid] " << mid << " [e->first] " << e->first << " [swarm_->options.smoothing] " << swarm_->options.smoothing << " exp_col->first " << exp_col->first << " timepoint->first " << timepoint->first << endl;
							cout << "done " << endl;
						}
					}
					else {
						if(swarm_->options.verbosity >=4){
							cout << "trying smoothing2 " << endl;
						}
						sim = dataFiles_.at(mid).at(e->first).at(swarm_->options.smoothing+1)->dataCurrent->at(exp_col->first).at(timepoint->first);
						if(swarm_->options.verbosity >=4){
							cout << "done" << endl;
						}
					}
					double sum = 0;
					if(sim != timepoint->second){ //if simulation and experimental values are exactly equal, the difference between them will be zero, so we can skip the objective function
						sum = (this->*objFuncPtr)(sim, timepoint->second, divisor);
					}
					if(swarm_->options.verbosity >= 3){
						cout << "sum = " << sum << " sim =" << sim << " timepoint->second = " << timepoint->second << " divisor = "<< divisor << endl;
						cout << "SUM: " << sum << "MID: " << mid << endl;
					}
					if (swarm_->options.bootstrap) {
						//cout << "all sets: "<< swarm_->bootstrapMaps.size() << endl;
						//cout << "files: " << swarm_->bootstrapMaps[swarm_->bootstrapCounter].size() << endl;
						//cout << "cols: " << (swarm_->bootstrapMaps[swarm_->bootstrapCounter].begin())->first << endl;
						//cout << "tps: " << swarm_->bootstrapMaps[swarm_->bootstrapCounter][exp_col->first][timepoint->first] << endl;
						//cout << "multiplying " << colSum << " by " << swarm_->bootstrapMaps[swarm_->bootstrapCounter - 1][e->first][exp_col->first][timepoint->first] << endl;
						//cout << "m: " << colSum << " by " << swarm_->bootstrapMaps[swarm_->bootstrapCounter].at(e->first).at(exp_col->first).at(timepoint->first) << endl;
						sum *= swarm_->bootstrapMaps[swarm_->bootstrapCounter][e->first][exp_col->first][timepoint->first];
					} //if (swarm_->options.bootstrap)
					colSum += sum;
				} //for through values
				setSum += colSum;
			} //for col loop
			totalSum += setSum;
		}//for (auto e = swarm_->options.expFiles.begin(); e != swarm_->options.expFiles.end(); ++e)
		// Erase our data sets
		dataFiles_.at(mid).clear();
		// Store our fit calc
		if(swarm_->options.verbosity >=4){
			cout << " totalSum " << totalSum << endl;
		}
		if (!local) {
			fitCalcs[mid][currentGeneration_] = pow(totalSum, 0.5);
			if(swarm_->options.verbosity >=4){
				cout << "RAQUEL LOCAL FIT for mid " << mid << ": " << fitCalcs[mid][currentGeneration_] << endl;
			}
		}
		else {
			fitCalcs[mid][-1] = pow(totalSum, 0.5);
			if(swarm_->options.verbosity >=4){
				cout << "RAQUEL GLOBALFIT FIT for mid " << mid << ": " << fitCalcs[mid][-1]<< endl;
			}
		}

		if (swarm_->options.verbosity >= 3) {
			cout << "Fit calculation["<<mid<<"]: " << pow(totalSum, 0.5) << endl;
		}

	} //if(!getSubParticle(mid))
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %edx, %ebp
movq %rdi, 0x8(%rsp)
movq 0xa8(%rdi), %r14
movl 0x162c(%r14), %eax
movl $0x0, 0x2c(%rsp)
decl %eax
cmpl $0x3, %eax
movl %esi, 0xa4(%rsp)
ja 0x553e4
leaq 0x81d27(%rip), %rcx     # 0xd6230
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x3a19(%rip), %rax     # 0x50b00
jmp 0x54539
leaq -0x39fa(%rip), %rax     # 0x50b28
movl $0x0, 0x2c(%rsp)
jmp 0x54539
movb $0x1, %al
movl %eax, 0x2c(%rsp)
leaq -0x3951(%rip), %rax     # 0x50be8
movl $0x0, 0x1c(%rsp)
jmp 0x54558
movb $0x1, %al
movl %eax, 0x1c(%rsp)
leaq -0x3a3e(%rip), %rax     # 0x50b12
movl $0x0, 0x2c(%rsp)
movq 0x8(%rsp), %rbx
movq %rax, 0x30(%rbx)
andq $0x0, 0x38(%rbx)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5645e
movl %eax, %r12d
movq 0x15c8(%r14), %rax
subq 0x15c0(%r14), %rax
shrq $0x3, %rax
cmpl %ebp, %eax
jbe 0x55282
movq %rbx, %rdi
movl %ebp, %esi
callq 0x59f90
testq %rax, %rax
je 0x55282
leaq 0x78(%rbx), %rdi
movl %ebp, %r14d
movq %r14, %rsi
callq 0x3374c
cmpq $0x0, (%rax)
je 0x55282
leaq 0x90(%rbx), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5a176
cmpq $0x0, 0x28(%rax)
je 0x55282
movq 0xa8(%rbx), %rdx
movq 0x1578(%rdx), %rax
movq $0x0, 0xa8(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r15, 0x38(%rsp)
movq 0x111992(%rip), %r13    # 0x165f98
leaq 0x58(%rsp), %rbp
movq %r14, %r12
movq %r14, (%rsp)
movq %rbx, %r14
leaq 0x1568(%rdx), %rcx
cmpq %rcx, %rax
je 0x553f6
movsd %xmm0, 0x30(%rsp)
movq %rax, 0x20(%rsp)
cmpl $0x4, 0x1614(%rdx)
jb 0x5467b
movq %r13, %rdi
leaq 0x82d0b(%rip), %rsi     # 0xd734e
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x8afb0(%rip), %rsi     # 0xdf60d
callq 0x289f0
movq 0x20(%rsp), %rcx
leaq 0x20(%rcx), %rsi
movq %rax, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a176
movq 0x20(%rsp), %rcx
leaq 0x20(%rcx), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5ed82
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a176
addq $0x8, %rax
cmpq %rax, %r14
movq %rbx, 0x80(%rsp)
je 0x551af
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a176
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5a1fa
cmpq $0x1, %rax
movq 0x8(%rsp), %r14
jne 0x55200
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x547cb
movq %r13, %rdi
leaq 0x82cd6(%rip), %rsi     # 0xd73db
callq 0x289f0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x547cb
movq %r13, %rdi
leaq 0x82de5(%rip), %rsi     # 0xd7521
callq 0x289f0
movq 0x20(%rsp), %rbx
movq 0x40(%rbx), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rsi
addq $0x20, %rsi
movq %rax, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq %r13, %rdi
leaq 0x82c7f(%rip), %rsi     # 0xd73ee
callq 0x289f0
movq 0x40(%rbx), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq 0x58(%rcx), %rcx
movsd 0x20(%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq %r13, %rdi
leaq 0x82c54(%rip), %rsi     # 0xd73f6
callq 0x289f0
movq 0x40(%rbx), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq 0x58(%rcx), %rcx
movsd 0x28(%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x20(%rsp), %rcx
movq 0x40(%rcx), %rdi
movq (%rdi), %rdx
movq 0x18(%rdx), %rax
xorpd %xmm0, %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x80(%rsp), %r12
addq $0x8, %rdx
cmpq %rdx, %rax
je 0x55252
cmpb $0x0, 0x2c(%rsp)
movq %rax, 0x90(%rsp)
je 0x5485d
addq $0x38, %rdi
leaq 0x20(%rax), %rsi
callq 0x5a2b6
movsd (%rax), %xmm0
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
movsd %xmm0, 0x30(%rsp)
jb 0x54855
movq %r13, %rdi
leaq 0x82bc4(%rip), %rsi     # 0xd73fe
callq 0x289f0
movq %rax, %rdi
movsd 0x30(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x90(%rsp), %rax
leaq 0x20(%rax), %rbx
movq 0x58(%rax), %r15
leaq 0x48(%rax), %rcx
movq %rcx, 0xb0(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x88(%rsp)
movq %rbx, 0x98(%rsp)
cmpq 0xb0(%rsp), %r15
je 0x55181
movsd 0x28(%r15), %xmm0
ucomisd %xmm0, %xmm0
jp 0x55169
movq %r15, 0x10(%rsp)
movq 0x38(%rsp), %r15
movq %r15, %rdi
movq (%rsp), %r13
movq %r13, %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0xa8(%r14), %rcx
movl 0x1658(%rcx), %ecx
movl %ecx, 0x58(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x5edc0
movq %r14, %rbp
movq %rax, %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0xa8(%rbp), %rcx
movl 0x1658(%rcx), %ecx
movl %ecx, 0xb8(%rsp)
movq %rax, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rax
addq $0x8, %rax
cmpq %rax, %r14
je 0x54c36
movq 0x10(%rsp), %rax
leaq 0x20(%rax), %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0xa8(%rbp), %rcx
movl 0x1658(%rcx), %ecx
movl %ecx, 0x58(%rsp)
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rdi
movq 0x98(%rsp), %rbx
movq %rbx, %rsi
callq 0x5a37a
movq %rax, %rdi
movq %r14, 0x48(%rsp)
movq %r14, %rsi
callq 0x5edfe
movq %rax, %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0xa8(%rbp), %rcx
movl 0x1658(%rcx), %ecx
movl %ecx, 0xb8(%rsp)
movq %rax, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x5a37a
addq $0x8, %rax
cmpq %rax, %r14
je 0x54cfd
cmpb $0x0, 0x1c(%rsp)
movsd 0x30(%rsp), %xmm0
movq 0x48(%rsp), %r14
je 0x54a36
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rdi
addq $0x8, %rdi
movq %rbx, %rsi
callq 0x5a37a
movq %rax, %rdi
movq %r14, %rsi
callq 0x5a3c0
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x8(%rsp), %r14
movq 0xa8(%r14), %rcx
movl 0x1614(%rcx), %eax
cmpl $0x1, 0x1658(%rcx)
movq 0x11153c(%rip), %r13    # 0x165f98
leaq 0x58(%rsp), %rbp
jne 0x54d5d
cmpl $0x4, %eax
jb 0x54e90
movq %r13, %rdi
leaq 0x82a79(%rip), %rsi     # 0xd74f3
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq %r13, %rdi
leaq 0x82a73(%rip), %rsi     # 0xd7504
callq 0x289f0
movq %rax, %rdi
movq (%rsp), %r13
movq %r13, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x82a5b(%rip), %rsi     # 0xd750a
callq 0x289f0
movq %rax, %rdi
movq 0x8(%rsp), %r15
movq 0x98(%r15), %rax
subq 0x90(%r15), %rax
cqto
pushq $0x30
popq %rcx
idivq %rcx
movq %rax, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x82a39(%rip), %rsi     # 0xd751d
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x82a2b(%rip), %rsi     # 0xd7529
callq 0x289f0
movq %rax, %r14
movq 0x38(%rsp), %rdi
movq %r13, %rsi
movq 0x111483(%rip), %r13    # 0x165f98
callq 0x5a176
movq 0x28(%rax), %rsi
movq %r14, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x82a14(%rip), %rsi     # 0xd7544
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq %r13, %rdi
leaq 0x829f3(%rip), %rsi     # 0xd7545
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x829ea(%rip), %rsi     # 0xd7556
callq 0x289f0
movq 0x48(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0xa8(%r15), %rax
movl 0x1614(%rax), %eax
cmpl $0x9, %eax
jb 0x54e0e
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0x18(%rax), %r14
leaq 0x829a3(%rip), %r15     # 0xd756a
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
addq $0x8, %rax
cmpq %rax, %r14
je 0x54df4
movq %r13, %rdi
movq %r15, %rsi
callq 0x289f0
movl 0x20(%r14), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movq %r13, %rdi
movq %r15, %rsi
callq 0x289f0
movq 0x28(%r14), %rsi
movq %rax, %rdi
callq 0x287f0
movq %rax, %rdi
callq 0x284a0
movq %r14, %rdi
callq 0x28700
movq %rax, %r14
jmp 0x54bc7
movq 0xa8(%rbp), %rax
cmpl $0x4, 0x1614(%rax)
movq 0x11134d(%rip), %r13    # 0x165f98
movq %rbp, %r14
movq 0x98(%rsp), %rbx
jb 0x54c89
movq %r13, %rdi
leaq 0x827b6(%rip), %rsi     # 0xd7418
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x82713(%rip), %rsi     # 0xd738f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0xa8(%rsp), %rcx
incl %ecx
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq %rcx, 0xa8(%rsp)
cmpq %rcx, 0x28(%rax)
leaq 0x58(%rsp), %rbp
movq 0x80(%rsp), %r12
movq 0x10(%rsp), %r15
ja 0x55169
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x54cea
movq %r13, %rdi
leaq 0x82772(%rip), %rsi     # 0xd744f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movsd 0x81536(%rip), %xmm0    # 0xd6228
movsd %xmm0, 0x40(%rsp)
jmp 0x55169
movq 0xa8(%rbp), %rax
cmpl $0x4, 0x1614(%rax)
movq %rbp, %r14
movq 0x111283(%rip), %r13    # 0x165f98
jb 0x54d4e
movq %r13, %rdi
leaq 0x82798(%rip), %rsi     # 0xd74b9
callq 0x289f0
movq 0x48(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x8264e(%rip), %rsi     # 0xd738f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x58(%rsp), %rbp
movq 0x10(%rsp), %r15
jmp 0x55169
cmpl $0x4, %eax
movq 0x10(%rsp), %r15
jb 0x54d7e
movq %r13, %rdi
leaq 0x82865(%rip), %rsi     # 0xd75d6
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x38(%rsp), %rdi
movq (%rsp), %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0xa8(%r14), %rcx
movl 0x1658(%rcx), %ecx
incl %ecx
movl %ecx, 0x58(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x5a37a
movq %rax, %rdi
movq 0x48(%rsp), %rsi
callq 0x5a3c0
movsd (%rax), %xmm0
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
leaq 0x84983(%rip), %rsi     # 0xd976c
jae 0x54fbf
jmp 0x54fed
movq 0x8(%rsp), %rax
movq 0xa8(%rax), %rax
movl 0x1614(%rax), %eax
movq 0x98(%rsp), %rbx
cmpl $0x5, %eax
jb 0x54e90
movq %r13, %rdi
leaq 0x82754(%rip), %rsi     # 0xd7571
callq 0x289f0
movq %rax, %r14
movq 0x38(%rsp), %rdi
movq (%rsp), %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq 0x8(%rsp), %rcx
movq 0xa8(%rcx), %rcx
movl 0x1658(%rcx), %ecx
incl %ecx
movl %ecx, 0x58(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x5a37a
movq %rax, %rdi
movq 0x48(%rsp), %rsi
callq 0x5a3c0
movsd (%rax), %xmm0
movq %r14, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x38(%rsp), %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x5a176
movq %rax, %rdi
movq %r12, %rsi
callq 0x5a2fc
movq %rbx, %r15
movq 0x8(%rsp), %rbx
movq 0xa8(%rbx), %rcx
movl 0x1658(%rcx), %ecx
movl %ecx, 0x58(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5a342
movq (%rax), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq 0x5a37a
movq %rax, %rdi
movq 0x48(%rsp), %rbp
movq %rbp, %rsi
callq 0x5a3c0
movsd (%rax), %xmm0
movq 0xa8(%rbx), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x54fdd
movq %r13, %rdi
leaq 0x82669(%rip), %rsi     # 0xd7579
movsd %xmm0, 0x50(%rsp)
callq 0x289f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x82651(%rip), %rsi     # 0xd7581
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x82644(%rip), %rsi     # 0xd758e
callq 0x289f0
movq 0xa8(%rbx), %rcx
movl 0x1658(%rcx), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x8263e(%rip), %rsi     # 0xd75ac
callq 0x289f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x82635(%rip), %rsi     # 0xd75bd
callq 0x289f0
movsd (%rbp), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movsd 0x50(%rsp), %xmm0
leaq 0x82621(%rip), %rsi     # 0xd75d0
movq %rbx, %r14
movq %r15, %rbx
movq 0x10(%rsp), %r15
leaq 0x58(%rsp), %rbp
movsd %xmm0, 0x50(%rsp)
movq %r13, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movsd 0x50(%rsp), %xmm0
jmp 0x54fed
movq %rbx, %r14
movq %r15, %rbx
movq 0x10(%rsp), %r15
leaq 0x58(%rsp), %rbp
movsd 0x28(%r15), %xmm1
ucomisd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
jne 0x55001
jnp 0x55022
movq 0x30(%r14), %rax
movq 0x38(%r14), %rdi
addq %r14, %rdi
testb $0x1, %al
je 0x55018
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
movsd 0x30(%rsp), %xmm2
callq *%rax
jmp 0x55026
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xa8(%r14), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x55103
movq %r13, %rdi
leaq 0x8259f(%rip), %rsi     # 0xd75e9
callq 0x289f0
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
leaq 0x82589(%rip), %rsi     # 0xd75f0
callq 0x289f0
movq %rax, %rdi
movsd 0x50(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
leaq 0x82573(%rip), %rsi     # 0xd75f7
callq 0x289f0
movsd 0x28(%r15), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x8256c(%rip), %rsi     # 0xd760d
callq 0x289f0
movq %rax, %rdi
movsd 0x30(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq %r13, %rdi
leaq 0x82553(%rip), %rsi     # 0xd7619
callq 0x289f0
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
leaq 0x82421(%rip), %rsi     # 0xd7504
callq 0x289f0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xa8(%r14), %rax
cmpl $0x0, 0x1638(%rax)
je 0x5514d
movl 0x13ec(%rax), %ecx
imulq $0x30, %rcx, %rdi
addq 0x38(%rax), %rdi
movq %r12, %rsi
callq 0x5a3fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5a462
movq %rax, %rdi
movq 0x48(%rsp), %rsi
callq 0x5a4c8
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
jmp 0x55153
movsd 0x10(%rsp), %xmm1
movsd 0x88(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movq %r15, %rdi
callq 0x28700
movq %rax, %r15
movq 0x90(%rsp), %rax
jmp 0x54886
movsd 0x78(%rsp), %xmm0
addsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movq %rax, %rdi
callq 0x28700
movq 0x20(%rsp), %rcx
movq 0x40(%rcx), %rdi
movq (%rdi), %rdx
jmp 0x547ed
movq 0x8(%rsp), %r14
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x551fa
movq %r13, %rdi
leaq 0x82193(%rip), %rsi     # 0xd7361
callq 0x289f0
movq %rax, %rdi
movq 0x80(%rsp), %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x821a2(%rip), %rsi     # 0xd738f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%rsp), %r12
jmp 0x5524b
movq %r13, %rdi
leaq 0x82191(%rip), %rsi     # 0xd739b
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x82185(%rip), %rsi     # 0xd73a9
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x82189(%rip), %rsi     # 0xd73c7
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x20(%rsp), %rcx
jmp 0x55268
movsd 0x40(%rsp), %xmm0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq (%rsp), %r12
movq %rcx, %rdi
callq 0x28700
movq 0xa8(%r14), %rdx
movsd 0x30(%rsp), %xmm0
jmp 0x54615
movl 0x40(%rbx), %esi
leaq 0x198(%rsp), %rbx
movq %rbx, %rdi
callq 0x9f56b
leaq 0x82082(%rip), %rsi     # 0xd731e
leaq 0x118(%rsp), %rdi
movq %rbx, %rdx
callq 0x4933b
leaq 0x81924(%rip), %rdx     # 0xd6bd7
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x3336c
leaq 0xf8(%rsp), %rdi
movl %ebp, %esi
callq 0x9f56b
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x4e6ed
leaq 0x81389(%rip), %rdx     # 0xd6684
leaq 0xb8(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x3336c
leaq 0xd8(%rsp), %rdi
movl %r12d, %esi
callq 0x9f56b
leaq 0x58(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x4e6ed
leaq 0x819b1(%rip), %rdx     # 0xd6cf2
leaq 0x178(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x3336c
leaq 0x178(%rsp), %rdi
callq 0x9f54b
leaq 0x178(%rsp), %rdi
callq 0x295a0
leaq 0x58(%rsp), %rdi
callq 0x295a0
leaq 0xd8(%rsp), %rdi
callq 0x295a0
leaq 0xb8(%rsp), %rdi
callq 0x295a0
leaq 0x158(%rsp), %rdi
callq 0x295a0
leaq 0xf8(%rsp), %rdi
callq 0x295a0
leaq 0x138(%rsp), %rdi
callq 0x295a0
leaq 0x118(%rsp), %rdi
callq 0x295a0
leaq 0x198(%rsp), %rdi
callq 0x295a0
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x1c(%rsp)
movq 0x8(%rsp), %rbx
jmp 0x54566
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x5a176
movq %rax, %rdi
callq 0x5f7a2
movq 0xa8(%r14), %rax
cmpl $0x3, 0x1614(%rax)
jbe 0x55444
movq 0x110b76(%rip), %rdi    # 0x165f98
leaq 0x821f6(%rip), %rsi     # 0xd761f
callq 0x289f0
movq %rax, %rdi
movsd 0x40(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movsd 0x7f63c(%rip), %xmm1    # 0xd4a88
movsd 0x40(%rsp), %xmm0
callq 0x292b0
movsd %xmm0, (%rsp)
imulq $0x30, %r12, %r15
movq 0x18(%r14), %rdi
addq %r15, %rdi
cmpb $0x0, 0xa4(%rsp)
je 0x554de
leaq 0x58(%rsp), %rsi
orl $-0x1, (%rsi)
callq 0x5a0c0
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x55571
movq 0x110af6(%rip), %rdi    # 0x165f98
leaq 0x8219b(%rip), %rsi     # 0xd7644
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x286e0
leaq 0x7a6bc(%rip), %rsi     # 0xcfb7c
movq %rax, %rdi
callq 0x289f0
movq %rax, %r14
movq 0x8(%rsp), %rax
addq 0x18(%rax), %r15
leaq 0x58(%rsp), %rsi
orl $-0x1, (%rsi)
jmp 0x55550
movl 0xb0(%r14), %eax
leaq 0x58(%rsp), %rsi
movl %eax, (%rsi)
callq 0x5a0c0
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0xa8(%r14), %rax
cmpl $0x4, 0x1614(%rax)
jb 0x55571
movq 0x110a87(%rip), %rdi    # 0x165f98
leaq 0x82112(%rip), %rsi     # 0xd762a
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x286e0
leaq 0x7a64d(%rip), %rsi     # 0xcfb7c
movq %rax, %rdi
callq 0x289f0
addq 0x18(%r14), %r15
movq %rax, %r14
movq 0x8(%rsp), %rax
movl 0xb0(%rax), %eax
leaq 0x58(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x5a0c0
movsd (%rax), %xmm0
movq %r14, %rdi
movq 0x8(%rsp), %r14
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0xa8(%r14), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x553d2
movq 0x110a0c(%rip), %rdi    # 0x165f98
leaq 0x820cf(%rip), %rsi     # 0xd7662
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x286e0
leaq 0xab4c1(%rip), %rsi     # 0x100a6b
movq %rax, %rdi
callq 0x289f0
movq %rax, %rbx
movsd 0x7f4cb(%rip), %xmm1    # 0xd4a88
movsd 0x40(%rsp), %xmm0
callq 0x292b0
movq %rbx, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
jmp 0x553d2
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x295a0
jmp 0x555f2
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x295a0
jmp 0x55601
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x295a0
jmp 0x55613
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x295a0
jmp 0x55625
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x295a0
leaq 0xf8(%rsp), %rdi
callq 0x295a0
leaq 0x138(%rsp), %rdi
callq 0x295a0
leaq 0x118(%rsp), %rdi
callq 0x295a0
leaq 0x198(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x292f0
movq %rax, %rbx
jmp 0x55632
movq %rax, %rbx
jmp 0x5563f
movq %rax, %rbx
jmp 0x5564c
movq %rax, %rbx
jmp 0x55659