// File: /workspace/github_cpp_makefile_star2_O1/richardposner[P]BioNetFit2/src/code/Particle.cpp
// Function: Particle::runNelderMead(std::map<double, std::vector<double, std::allocator<double>>, std::less<double>, std::allocator<std::pair<double const, std::vector<double, std::allocator<double>>>>>, unsigned int)
void Particle::runNelderMead(map<double, vector<double> > simplex, unsigned int mid) {

	std::map<std::string, double> simParams = simParams_.at(mid);
	auto curPar = getSubParticle(mid);


	// The transformation coefficients
	float reflection = 1.0;
	float expansion = 2.0;
	float contraction = 0.5;
	float shrink = 0.5;
	unsigned int simulationCount = 0;

	while (simulationCount < 20) {
		// Get our important vertices
		auto sIt = simplex.end();
		advance(sIt, - 1); // Last element
		cout << "worst is: " << sIt->first << endl;
		auto worst = sIt;
		advance(sIt, - 1); // Second to last element
		cout << "second worst is: " << sIt->first << endl;
		auto good = sIt;
		auto best = simplex.begin();
		cout << "best is: " << best->first << endl;
		bool invalid = false;

		vector<vector<double> > centroidVectors;
		for (auto params = simplex.begin(); params != worst; ++params) {
			centroidVectors.push_back(swarm_->normalizeParams(params->second));
		}

		// Calculate the centroid
		vector<double> centroid = getCentroid(centroidVectors);

		// Reflect
		cout << "reflecting" << endl;
		vector<double> R; // The transformation vector
		for (unsigned int d = 0; d < centroid.size(); ++d) {
			double r = centroid[d] + reflection * (centroid[d] - worst->second[d]);
			if (r <= 0 || r > 1) {
				invalid = true;
			}
			cout << "creating new pt with eq " << centroid[d] << " + " << reflection << " * (" << centroid[d] << " - " << worst->second[d] << "): " << r << endl;
			R.push_back(r);
		}

		vector<double> deNormalizedReflection = swarm_->deNormalizeParams(R);

		auto tIt = deNormalizedReflection.begin();
		for (auto p = simParams.begin(); p != simParams.end(); ++p) {
			p->second = *tIt;
			++tIt;
		}

		double rCalc;
		if (!invalid) {
			for (unsigned int i = 1; i <= swarm_->options.smoothing; ++i) {
				curPar->runModel(i, true);
				++simulationCount;
			}
			if (swarm_->options.smoothing > 1) {
				curPar->smoothRuns();

			}
			curPar->calculateFit(true);
			rCalc = fitCalcs.at(mid)[-1];
		}
		else {
			invalid = false;
			rCalc = pow(10, 10);
		}
		cout << "reflection: " << rCalc << endl;

		// R Better than good, but worse than best
		if (rCalc > best->first && rCalc < good->first) {
			if (swarm_->options.verbosity >= 3) {
				cout << "reflection was worse than best and better than good. erasing worst of " << worst->first << endl;
			}
			simplex.erase(worst);
			if (swarm_->options.verbosity >= 3) {
				cout << "sim size: " << simplex.size() << endl;
			}
			simplex.insert(pair<double, vector<double> > (rCalc, R));
			if (swarm_->options.verbosity >= 3) {
				cout << "inserting rCalc of " << rCalc << endl;
			}
			continue;
		}
		// R Better than best
		else if (rCalc < best->first) {
			if (swarm_->options.verbosity >= 3) {
				cout << "reflection was better than best. expanding" << endl;
			}
			// Expand

			vector<double> E;
			for (unsigned int d = 0; d < centroid.size(); ++d) {
				double e = centroid[d] + expansion * (R[d] - centroid[d]);
				if (e <= 0 || e > 1) {
					invalid = true;
				}
				E.push_back(e);
				if (swarm_->options.verbosity >= 3) {
				cout << "creating new pt with eq " << centroid[d] << " + " << expansion << " * (" << R[d] << " - " << centroid[d] << "): " << e << endl;
				}
			}

			vector<double> deNormalizedExpansion = swarm_->deNormalizeParams(E);

			auto tIt = deNormalizedExpansion.begin();
			for (auto p = simParams.begin(); p != simParams.end(); ++p) {
				p->second = *tIt;
				++tIt;
			}

			double eCalc;
			if (!invalid) {
				for (unsigned int i = 1; i <= swarm_->options.smoothing; ++i) {
					curPar->runModel(i, true);
					++simulationCount;
				}
				if (swarm_->options.smoothing > 1) {
					curPar->smoothRuns();
				}
				curPar->calculateFit(true);

				eCalc = fitCalcs.at(mid)[-1];
				cout << "expansion: " << eCalc << endl;
			}
			else {
				eCalc = pow(10,10);
				invalid = false;
			}

			if (eCalc < rCalc) {
				cout << "expansion was better than reflection. looping." << endl;
				simplex.erase(worst);
				simplex.insert(pair<double, vector<double> > (eCalc, E));
				continue;
			}
			else {
				cout << "expansion was worse than reflection. looping." << endl;
				simplex.erase(worst);
				simplex.insert(pair<double, vector<double> > (rCalc, R));
				continue;
			}
		}
		// R worse than good
		else if (rCalc > good->first) {
			cout << "reflection was worse than good. contracting." << endl;
			// Contraction
			vector<double> C;
			for (unsigned int d = 0; d < centroid.size(); ++d) {
				double c = centroid[d] + contraction * (worst->second[d] - centroid[d]);
				if (c <= 0 || c > 1) {
					invalid = true;
				}
				C.push_back(c);
				cout << "creating new pt with eq " << centroid[d] << " + " << contraction << " * (" << worst->second[d] << " - " << centroid[d] << "): " << c << endl;
			}

			vector<double> deNormalizedContraction = swarm_->deNormalizeParams(C);

			auto tIt = deNormalizedContraction.begin();
			for (auto p = simParams.begin(); p != simParams.end(); ++p) {
				p->second = *tIt;
				++tIt;
			}

			double cCalc;
			if (!invalid) {
				for (unsigned int i = 1; i <= swarm_->options.smoothing; ++i) {
/*
					getSubParticle(mid)->runModel(i, true);
*/
					curPar->runModel(i, true);
					++simulationCount;
				}
				if (swarm_->options.smoothing > 1) {
					smoothRuns(mid); //razi: run for subparticle associated with model mid
					}
				calculateFit(true, mid); //razi: run for subparticle associated with model mid
				cCalc = fitCalcs.at(mid)[-1];
				cout << "contraction: " << cCalc << endl;
			}
			else {
				invalid = false;
				cCalc = pow(10, 10);
			}

			if (cCalc < worst->first) {
				cout << "contraction was better than worst. looping." << endl;
				simplex.erase(worst);
				simplex.insert(pair<double, vector<double> > (cCalc, C));
				continue;
			}
			else {
				//cout << "contraction was worse than worst. shrinking" << endl;
				// Shrink
				for (auto sIt = ++simplex.begin(); sIt != simplex.end(); ++sIt) {
					for (unsigned int d = 0; d < centroid.size(); ++d) {
						double s = simplex.begin()->second[d] + (shrink * (sIt->second[d] - best->second[d]));
						sIt->second[d] = s;
					}
				}
			}
		}
	}

	fitCalcs.at(mid)[-1] = simplex.begin()->first;
	unsigned int d = 0;
	for (auto p = simParams.begin(); p != simParams.end(); ++p) {
		p->second = simplex.begin()->second[d++];
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, 0x8(%rsp)
movl %edx, 0x8c(%rsp)
movl %edx, %ebx
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
subq %rsi, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %rbx, %rdx
jbe 0x56051
movq %rdi, %rbp
leaq (%rbx,%rbx,2), %rax
shlq $0x4, %rax
movq %rax, 0xb0(%rsp)
addq %rax, %rsi
leaq 0x110(%rsp), %rdi
callq 0x51a66
movq 0x48(%rbp), %rax
movq 0x50(%rbp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x56062
movq %rbx, 0x78(%rsp)
movq (%rax,%rbx,8), %rax
movq %rax, 0x80(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xc0(%rsp)
movq $0x0, 0x38(%rsp)
movq %rbp, (%rsp)
movq 0xc0(%rsp), %rdi
callq 0x22a10
movq %rax, %r13
movl $0xa, %edx
movq 0x1212a8(%rip), %rdi    # 0x175f90
leaq 0xa36d5(%rip), %rsi     # 0xf83c4
callq 0x22ab0
movsd 0x20(%r13), %xmm0
movq 0x12128f(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq %r13, %rdi
callq 0x22a10
movq %rax, 0xb8(%rsp)
movl $0x11, %edx
movq 0x121244(%rip), %rdi    # 0x175f90
leaq 0xa366a(%rip), %rsi     # 0xf83bd
callq 0x22ab0
movq 0xb8(%rsp), %rax
movsd 0x20(%rax), %xmm0
movq 0x121224(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x40(%rsp)
movl $0x9, %edx
movq 0x1211db(%rip), %rdi    # 0x175f90
leaq 0xa3613(%rip), %rsi     # 0xf83cf
callq 0x22ab0
movq 0x40(%rsp), %rax
movsd 0x20(%rax), %xmm0
movq 0x1211be(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
xorpd %xmm0, %xmm0
movapd %xmm0, 0xe0(%rsp)
movq $0x0, 0xf0(%rsp)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r12
cmpq %r13, %r12
je 0x54eb3
movq 0xa8(%rbp), %rbx
leaq 0x28(%r12), %rsi
leaq 0x188(%rsp), %r14
movq %r14, %rdi
callq 0x66228
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xa2910
leaq 0xe0(%rsp), %rdi
movq %r15, %rsi
callq 0x68704
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x54e82
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x54e9f
movq 0x198(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq %r12, %rdi
callq 0x22670
movq %rax, %r12
cmpq %r13, %rax
jne 0x54e2c
leaq 0x1a0(%rsp), %rbx
movq %rbx, %rdi
leaq 0xe0(%rsp), %rsi
callq 0x662a8
leaq 0x48(%rsp), %rdi
movq %rbx, %rdx
callq 0x54248
movq %rbx, %rdi
callq 0x66342
movl $0xa, %edx
movq 0x1210a4(%rip), %rdi    # 0x175f90
leaq 0xa34e6(%rip), %rsi     # 0xf83d9
callq 0x22ab0
movq 0x121091(%rip), %rcx    # 0x175f90
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x121073(%rip), %rdi    # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0x48(%rsp), %rax
cmpq %rax, 0x50(%rsp)
je 0x550ef
movl $0x1, %ebx
xorl %r15d, %r15d
xorl %ebp, %ebp
movsd (%rax,%r15,8), %xmm0
movq 0x28(%r13), %rax
movapd %xmm0, %xmm1
subsd (%rax,%r15,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
ucomisd 0xa338d(%rip), %xmm1    # 0xf8310
movzbl %bpl, %ebp
movl $0x1, %eax
cmoval %eax, %ebp
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
cmovael %eax, %ebp
movl $0x18, %edx
movq 0x120fea(%rip), %rdi    # 0x175f90
leaq 0xa3437(%rip), %rsi     # 0xf83e4
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x120fcc(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa3422(%rip), %rsi     # 0xf83fd
callq 0x22ab0
movq %r12, %rdi
movsd 0xa3325(%rip), %xmm0    # 0xf8310
callq 0x23060
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa33ff(%rip), %rsi     # 0xf8401
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa33da(%rip), %rsi     # 0xf8406
callq 0x22ab0
movq 0x28(%r13), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xab090(%rip), %rsi     # 0x1000e5
callq 0x22ab0
movsd 0x18(%rsp), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x98(%rsp), %rsi
cmpq 0xa0(%rsp), %rsi
je 0x550bc
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98(%rsp)
jmp 0x550ce
leaq 0x90(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x68992
movl %ebx, %r15d
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %ebx
cmpq %r15, %rcx
ja 0x54f5d
jmp 0x550f1
xorl %ebp, %ebp
movq (%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x170(%rsp), %r15
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x66228
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa2992
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x55144
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x128(%rsp), %rax
leaq 0x118(%rsp), %r12
cmpq %r12, %rax
je 0x5517b
movq 0xf8(%rsp), %rbx
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x22670
cmpq %r12, %rax
jne 0x55161
testb $0x1, %bpl
je 0x55190
xorl %ebp, %ebp
movsd 0xa318d(%rip), %xmm0    # 0xf8318
jmp 0x55267
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x0, 0x1658(%rax)
je 0x551ec
movl $0x1, %r12d
movq 0x80(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x562a0
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
incl %r12d
movq (%rsp), %rax
movq 0xa8(%rax), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
jbe 0x551aa
cmpl $0x2, %eax
setae %al
jmp 0x551ee
xorl %eax, %eax
testb %al, %al
je 0x55205
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
callq 0x5a290
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
movl $0x1, %esi
callq 0x5aea6
movq (%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rax), %rdx
subq %rdi, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq 0x78(%rsp), %rdx
jbe 0x56018
addq 0xb0(%rsp), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
callq 0x66390
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0xc, %edx
movq 0x120d17(%rip), %rdi    # 0x175f90
leaq 0xa318a(%rip), %rsi     # 0xf840a
callq 0x22ab0
movq 0x120d04(%rip), %rdi    # 0x175f90
movsd 0x10(%rsp), %xmm0
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x40(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd 0x10(%rsp), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x55487
movq 0xb8(%rsp), %rax
movsd 0x20(%rax), %xmm1
ucomisd %xmm2, %xmm1
jbe 0x55487
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x5535a
movl $0x46, %edx
movq 0x120c7e(%rip), %rdi    # 0x175f90
leaq 0xa30fe(%rip), %rsi     # 0xf8417
callq 0x22ab0
movsd 0x20(%r13), %xmm0
movq 0x120c65(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x68c78
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x553d2
movl $0xa, %edx
movq 0x120c09(%rip), %rdi    # 0x175f90
leaq 0xa30d0(%rip), %rsi     # 0xf845e
callq 0x22ab0
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0x120bed(%rip), %rdi    # 0x175f90
callq 0x22650
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x66228
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x68cb2
movq (%rsp), %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x5541a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xa8(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x55eec
movl $0x13, %edx
movq 0x120b56(%rip), %rdi    # 0x175f90
leaq 0xa3028(%rip), %rsi     # 0xf8469
callq 0x22ab0
movq 0x120b43(%rip), %rdi    # 0x175f90
movsd 0x10(%rsp), %xmm0
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
jmp 0x55eec
ucomisd %xmm2, %xmm0
jbe 0x55760
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x554ef
movl $0x2a, %edx
movq 0x120adf(%rip), %rdi    # 0x175f90
leaq 0xa2fc5(%rip), %rsi     # 0xf847d
callq 0x22ab0
movq 0x120acc(%rip), %rcx    # 0x175f90
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x120aae(%rip), %rdi    # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x48(%rsp), %rax
cmpq %rax, 0x50(%rsp)
je 0x556bc
movl $0x1, %ebx
xorl %r15d, %r15d
movsd (%rax,%r15,8), %xmm1
movq 0x90(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
subsd %xmm1, %xmm0
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0xa2dce(%rip), %xmm0    # 0xf8310
movzbl %bpl, %ebp
movl $0x1, %eax
cmoval %eax, %ebp
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovael %eax, %ebp
movsd %xmm0, 0x18(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x5557a
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x55589
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x68992
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x5569d
movl $0x18, %edx
movq 0x1209e3(%rip), %rdi    # 0x175f90
leaq 0xa2e30(%rip), %rsi     # 0xf83e4
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x1209c5(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa2e1b(%rip), %rsi     # 0xf83fd
callq 0x22ab0
movq %r12, %rdi
movsd 0xa2d2e(%rip), %xmm0    # 0xf8320
callq 0x23060
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa2df8(%rip), %rsi     # 0xf8401
callq 0x22ab0
movq 0x90(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa2dd0(%rip), %rsi     # 0xf8406
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xaaa85(%rip), %rsi     # 0x1000e5
callq 0x22ab0
movsd 0x18(%rsp), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movl %ebx, %r15d
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %ebx
cmpq %r15, %rcx
ja 0x5551a
movq (%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x158(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0x66228
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa2992
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x5570c
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x128(%rsp), %rax
leaq 0x118(%rsp), %r12
cmpq %r12, %rax
je 0x55743
movq 0xc8(%rsp), %rbx
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x22670
cmpq %r12, %rax
jne 0x55729
testb $0x1, %bpl
je 0x55a13
movsd 0xa2bc3(%rip), %xmm0    # 0xf8318
movsd %xmm0, 0x40(%rsp)
jmp 0x55b9f
movq 0xb8(%rsp), %rax
ucomisd 0x20(%rax), %xmm2
jbe 0x55eec
movl $0x2c, %edx
movq 0x120811(%rip), %rdi    # 0x175f90
leaq 0xa2d8b(%rip), %rsi     # 0xf8511
callq 0x22ab0
movq 0x1207fe(%rip), %rcx    # 0x175f90
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x1207e0(%rip), %rdi    # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x48(%rsp), %rax
cmpq %rax, 0x50(%rsp)
je 0x5596e
movl $0x1, %ebx
xorl %r15d, %r15d
movsd (%rax,%r15,8), %xmm1
movq 0x28(%r13), %rax
movsd (%rax,%r15,8), %xmm0
subsd %xmm1, %xmm0
mulsd 0xa1344(%rip), %xmm0    # 0xf6b48
addsd %xmm1, %xmm0
ucomisd 0xa2b00(%rip), %xmm0    # 0xf8310
movzbl %bpl, %ebp
movl $0x1, %eax
cmoval %eax, %ebp
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovael %eax, %ebp
movsd %xmm0, 0x18(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x55848
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x55857
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x68992
movl $0x18, %edx
movq 0x12072d(%rip), %rdi    # 0x175f90
leaq 0xa2b7a(%rip), %rsi     # 0xf83e4
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x12070f(%rip), %rdi    # 0x175f90
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa2b65(%rip), %rsi     # 0xf83fd
callq 0x22ab0
movq %r12, %rdi
movsd 0xa12a0(%rip), %xmm0    # 0xf6b48
callq 0x23060
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa2b42(%rip), %rsi     # 0xf8401
callq 0x22ab0
movq 0x28(%r13), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa2b1e(%rip), %rsi     # 0xf8406
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xaa7d3(%rip), %rsi     # 0x1000e5
callq 0x22ab0
movsd 0x18(%rsp), %xmm0
movq %r12, %rdi
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movl %ebx, %r15d
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %ebx
cmpq %r15, %rcx
ja 0x557e8
movq (%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x140(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0x66228
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa2992
movq 0x8(%rsp), %r15
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x559c3
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x128(%rsp), %rax
leaq 0x118(%rsp), %r12
cmpq %r12, %rax
je 0x559fa
movq 0xc8(%rsp), %rbx
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x22670
cmpq %r12, %rax
jne 0x559e0
testb $0x1, %bpl
je 0x55a6f
movsd 0xa2910(%rip), %xmm0    # 0xf8318
movsd %xmm0, 0x10(%rsp)
jmp 0x55d89
movq (%rsp), %rbx
movq 0xa8(%rbx), %rax
cmpl $0x0, 0x1658(%rax)
je 0x55ace
movl $0x1, %r12d
movq 0x80(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x562a0
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
incl %r12d
movq 0xa8(%rbx), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
jbe 0x55a31
cmpl $0x2, %eax
setae %al
jmp 0x55ad0
movq (%rsp), %rbx
movq 0xa8(%rbx), %rax
cmpl $0x0, 0x1658(%rax)
je 0x55cc0
movl $0x1, %r12d
movq 0x80(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x562a0
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
incl %r12d
movq 0xa8(%rbx), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
jbe 0x55a8d
cmpl $0x2, %eax
setae %al
jmp 0x55cc2
xorl %eax, %eax
testb %al, %al
je 0x55ae7
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
callq 0x5a290
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
movl $0x1, %esi
callq 0x5aea6
movq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rdx
subq %rdi, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq 0x78(%rsp), %rdx
jbe 0x5602b
addq 0xb0(%rsp), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
callq 0x66390
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movl $0xb, %edx
movq 0x120439(%rip), %rdi    # 0x175f90
leaq 0xa294a(%rip), %rsi     # 0xf84a8
callq 0x22ab0
movq 0x120426(%rip), %rdi    # 0x175f90
movsd 0x40(%rsp), %xmm0
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movsd 0x10(%rsp), %xmm0
ucomisd 0x40(%rsp), %xmm0
jbe 0x55c37
movl $0x2e, %edx
movq 0x1203d3(%rip), %rdi    # 0x175f90
leaq 0xa28f0(%rip), %rsi     # 0xf84b4
callq 0x22ab0
movq 0x1203c0(%rip), %rcx    # 0x175f90
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x1203a2(%rip), %rdi    # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x68c78
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x66228
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x68cb2
jmp 0x55ea1
movl $0x2d, %edx
movq 0x12034d(%rip), %rdi    # 0x175f90
leaq 0xa2899(%rip), %rsi     # 0xf84e3
callq 0x22ab0
movq 0x12033a(%rip), %rcx    # 0x175f90
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x12031c(%rip), %rdi    # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x68c78
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x66228
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x68cb2
jmp 0x55ea1
xorl %eax, %eax
testb %al, %al
je 0x55cd5
movq %rbx, %rdi
movl 0x8c(%rsp), %esi
callq 0x5a290
movq %rbx, %rdi
movl $0x1, %esi
movl 0x8c(%rsp), %edx
callq 0x5aea6
movq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rdx
subq %rdi, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq 0x78(%rsp), %rdx
jbe 0x5603e
addq 0xb0(%rsp), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
callq 0x66390
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0xd, %edx
movq 0x12024f(%rip), %rdi    # 0x175f90
leaq 0xa27f6(%rip), %rsi     # 0xf853e
callq 0x22ab0
movq 0x12023c(%rip), %rdi    # 0x175f90
movsd 0x10(%rsp), %xmm0
callq 0x23060
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r12, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movsd 0x20(%r13), %xmm0
ucomisd 0x10(%rsp), %xmm0
ja 0x55e24
movq 0x18(%r15), %r12
movq %r12, %rdi
callq 0x22670
cmpq 0xc0(%rsp), %rax
je 0x55eb8
movq 0x48(%rsp), %rbx
movq 0x50(%rsp), %r15
movq %r15, %r13
subq %rbx, %r13
sarq $0x3, %r13
cmpq %rbx, %r15
movsd 0xa0d74(%rip), %xmm1    # 0xf6b48
je 0x55e0d
movq 0x28(%r12), %rcx
movq 0x28(%rax), %rdx
movq 0x40(%rsp), %rsi
movq 0x28(%rsi), %rsi
xorl %edi, %edi
movsd (%rdx,%rdi,8), %xmm0
subsd (%rsi,%rdi,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%rcx,%rdi,8), %xmm0
movsd %xmm0, (%rdx,%rdi,8)
incq %rdi
movl %edi, %r8d
cmpq %r8, %r13
ja 0x55dea
movq %rax, %rdi
callq 0x22670
cmpq 0xc0(%rsp), %rax
jne 0x55dc9
jmp 0x55eb8
movl $0x2b, %edx
movq 0x120160(%rip), %rdi    # 0x175f90
leaq 0xa2715(%rip), %rsi     # 0xf854c
callq 0x22ab0
movq 0x12014d(%rip), %rcx    # 0x175f90
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x12012f(%rip), %rdi    # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq %r15, %rdi
movq %r13, %rsi
callq 0x68c78
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x66228
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x68cb2
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x55eb8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x55ed5
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x55eec
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x55f09
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
movq (%rsp), %rbp
je 0x55f2a
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x55f41
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
leaq 0xe0(%rsp), %rdi
callq 0x66342
cmpl $0x14, 0x38(%rsp)
jb 0x54ccc
movq 0x18(%rbp), %rdi
movq 0x20(%rbp), %rdx
subq %rdi, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
movq 0x78(%rsp), %rsi
cmpq %rsi, %rdx
jbe 0x56073
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
addq 0xb0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
callq 0x66390
leaq 0x118(%rsp), %r14
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x128(%rsp), %rax
cmpq %r14, %rax
je 0x55ff9
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rbx
xorl %ebp, %ebp
movl %ebp, %ecx
incl %ebp
movsd (%rbx,%rcx,8), %xmm0
movsd %xmm0, 0x40(%rax)
movq %rax, %rdi
callq 0x22670
cmpq %r14, %rax
jne 0x55fde
leaq 0x110(%rsp), %rdi
callq 0x4a694
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9d6a6(%rip), %rdi     # 0xf36c5
movq 0x78(%rsp), %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d693(%rip), %rdi     # 0xf36c5
movq 0x78(%rsp), %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d680(%rip), %rdi     # 0xf36c5
movq 0x78(%rsp), %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d66d(%rip), %rdi     # 0xf36c5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d65c(%rip), %rdi     # 0xf36c5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d64b(%rip), %rdi     # 0xf36c5
xorl %eax, %eax
callq 0x22f40
jmp 0x561be
jmp 0x561be
jmp 0x561be
jmp 0x56190
jmp 0x56190
jmp 0x560d8
jmp 0x56190
movq %rax, %rbx
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x56211
movq 0x150(%rsp), %rsi
jmp 0x561a8
jmp 0x5620e
jmp 0x56190
jmp 0x56190
jmp 0x560d8
jmp 0x56190
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x56193
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x56193
jmp 0x56190
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x56228
movq 0x30(%rsp), %rsi
jmp 0x56220
jmp 0x561c8
jmp 0x5620e
movq %rax, %rbx
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x56211
movq 0x168(%rsp), %rsi
jmp 0x561a8
jmp 0x561c8
jmp 0x561c8
jmp 0x56247
movq %rax, %rbx
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x5624a
movq 0x180(%rsp), %rsi
jmp 0x5623d
jmp 0x56207
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x66342
jmp 0x5627e
jmp 0x56190
jmp 0x56190
jmp 0x56190
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x56211
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x56211
movq %rax, %rbx
jmp 0x56267
jmp 0x561be
jmp 0x561be
movq %rax, %rbx
jmp 0x5628b
jmp 0x561c8
movq %rax, %rbx
jmp 0x56228
movq %rax, %rbx
jmp 0x561ec
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x561ec
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x5627e
movq 0x198(%rsp), %rsi
jmp 0x56276
movq %rax, %rbx
jmp 0x5627e
jmp 0x5620e
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x56228
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x5624a
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x5624a
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x56267
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5627e
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
leaq 0xe0(%rsp), %rdi
callq 0x66342
leaq 0x110(%rsp), %rdi
callq 0x4a694
movq %rbx, %rdi
callq 0x23240