// File: /workspace/github_cpp_makefile_star2_O3/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 0x55d19
movq %rdi, %rbp
leaq (%rbx,%rbx,2), %rax
shlq $0x4, %rax
movq %rax, 0xb0(%rsp)
addq %rax, %rsi
leaq 0x110(%rsp), %rdi
callq 0x51772
movq 0x48(%rbp), %rax
movq 0x50(%rbp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x55d2a
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 0x1215d6(%rip), %rdi    # 0x175fa8
leaq 0xa39cb(%rip), %rsi     # 0xf83a4
callq 0x22ab0
movsd 0x20(%r13), %xmm0
movq 0x1215bd(%rip), %rdi    # 0x175fa8
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 0x121572(%rip), %rdi    # 0x175fa8
leaq 0xa3960(%rip), %rsi     # 0xf839d
callq 0x22ab0
movq 0xb8(%rsp), %rax
movsd 0x20(%rax), %xmm0
movq 0x121552(%rip), %rdi    # 0x175fa8
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 0x121509(%rip), %rdi    # 0x175fa8
leaq 0xa3909(%rip), %rsi     # 0xf83af
callq 0x22ab0
movq 0x40(%rsp), %rax
movsd 0x20(%rax), %xmm0
movq 0x1214ec(%rip), %rdi    # 0x175fa8
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 0x54b9d
movq 0xa8(%rbp), %rbx
leaq 0x28(%r12), %rsi
leaq 0x188(%rsp), %r14
movq %r14, %rdi
callq 0x65d5c
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xa1e5c
leaq 0xe0(%rsp), %rdi
movq %r15, %rsi
callq 0x6825e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x54b6c
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x54b89
movq 0x198(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq %r12, %rdi
callq 0x22670
movq %rax, %r12
cmpq %r13, %rax
jne 0x54b16
leaq 0x1a0(%rsp), %rbx
movq %rbx, %rdi
leaq 0xe0(%rsp), %rsi
callq 0x65ddc
leaq 0x48(%rsp), %rdi
movq %rbx, %rdx
callq 0x53f58
movq %rbx, %rdi
callq 0x65e76
movl $0xa, %edx
movq 0x1213d2(%rip), %rdi    # 0x175fa8
leaq 0xa37dc(%rip), %rsi     # 0xf83b9
callq 0x22ab0
movq 0x1213bf(%rip), %rcx    # 0x175fa8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x1213a1(%rip), %rdi    # 0x175fa8
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 0x54dd9
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 0xa3683(%rip), %xmm1    # 0xf82f0
movzbl %bpl, %ebp
movl $0x1, %eax
cmoval %eax, %ebp
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
cmovael %eax, %ebp
movl $0x18, %edx
movq 0x121318(%rip), %rdi    # 0x175fa8
leaq 0xa372d(%rip), %rsi     # 0xf83c4
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x1212fa(%rip), %rdi    # 0x175fa8
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa3718(%rip), %rsi     # 0xf83dd
callq 0x22ab0
movq %r12, %rdi
movsd 0xa361b(%rip), %xmm0    # 0xf82f0
callq 0x23060
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa36f5(%rip), %rsi     # 0xf83e1
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 0xa36d0(%rip), %rsi     # 0xf83e6
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 0xab38d(%rip), %rsi     # 0x1000cc
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 0x54da6
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98(%rsp)
jmp 0x54db8
leaq 0x90(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x684d4
movl %ebx, %r15d
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %ebx
cmpq %r15, %rcx
ja 0x54c47
jmp 0x54ddb
xorl %ebp, %ebp
movq (%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x170(%rsp), %r15
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x65d5c
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa1ec4
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x54e2e
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x128(%rsp), %rax
leaq 0x118(%rsp), %r12
cmpq %r12, %rax
je 0x54e65
movq 0xf8(%rsp), %rbx
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x22670
cmpq %r12, %rax
jne 0x54e4b
testb $0x1, %bpl
je 0x54e7a
xorl %ebp, %ebp
movsd 0xa3483(%rip), %xmm0    # 0xf82f8
jmp 0x54f48
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x0, 0x1658(%rax)
je 0x54ee6
movl $0x1, %r12d
movq 0x80(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x55f62
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 0x54e94
cmpl $0x1, %eax
jbe 0x54ee6
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
callq 0x59ef4
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
movl $0x1, %esi
callq 0x5aae4
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 0x55ce0
addq 0xb0(%rsp), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
callq 0x65eca
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0xc, %edx
movq 0x12104e(%rip), %rdi    # 0x175fa8
leaq 0xa3489(%rip), %rsi     # 0xf83ea
callq 0x22ab0
movq 0x12103b(%rip), %rdi    # 0x175fa8
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 0x55168
movq 0xb8(%rsp), %rax
movsd 0x20(%rax), %xmm1
ucomisd %xmm2, %xmm1
jbe 0x55168
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x5503b
movl $0x46, %edx
movq 0x120fb5(%rip), %rdi    # 0x175fa8
leaq 0xa33fd(%rip), %rsi     # 0xf83f7
callq 0x22ab0
movsd 0x20(%r13), %xmm0
movq 0x120f9c(%rip), %rdi    # 0x175fa8
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 0x687b8
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x550b3
movl $0xa, %edx
movq 0x120f40(%rip), %rdi    # 0x175fa8
leaq 0xa33cf(%rip), %rsi     # 0xf843e
callq 0x22ab0
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0x120f24(%rip), %rdi    # 0x175fa8
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 0x65d5c
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x687f2
movq (%rsp), %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x550fb
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xa8(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x55bb4
movl $0x13, %edx
movq 0x120e8d(%rip), %rdi    # 0x175fa8
leaq 0xa3327(%rip), %rsi     # 0xf8449
callq 0x22ab0
movq 0x120e7a(%rip), %rdi    # 0x175fa8
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 0x55bb4
ucomisd %xmm2, %xmm0
jbe 0x55441
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x551d0
movl $0x2a, %edx
movq 0x120e16(%rip), %rdi    # 0x175fa8
leaq 0xa32c4(%rip), %rsi     # 0xf845d
callq 0x22ab0
movq 0x120e03(%rip), %rcx    # 0x175fa8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x120de5(%rip), %rdi    # 0x175fa8
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 0x5539d
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 0xa30cd(%rip), %xmm0    # 0xf82f0
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 0x5525b
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x5526a
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x684d4
movq (%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x5537e
movl $0x18, %edx
movq 0x120d1a(%rip), %rdi    # 0x175fa8
leaq 0xa312f(%rip), %rsi     # 0xf83c4
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x120cfc(%rip), %rdi    # 0x175fa8
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa311a(%rip), %rsi     # 0xf83dd
callq 0x22ab0
movq %r12, %rdi
movsd 0xa302d(%rip), %xmm0    # 0xf8300
callq 0x23060
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa30f7(%rip), %rsi     # 0xf83e1
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 0xa30cf(%rip), %rsi     # 0xf83e6
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 0xaad8b(%rip), %rsi     # 0x1000cc
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 0x551fb
movq (%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x158(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0x65d5c
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa1ec4
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x553ed
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x128(%rsp), %rax
leaq 0x118(%rsp), %r12
cmpq %r12, %rax
je 0x55424
movq 0xc8(%rsp), %rbx
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x22670
cmpq %r12, %rax
jne 0x5540a
testb $0x1, %bpl
je 0x556f8
movsd 0xa2ec2(%rip), %xmm0    # 0xf82f8
movsd %xmm0, 0x40(%rsp)
jmp 0x55818
movq 0xb8(%rsp), %rax
ucomisd 0x20(%rax), %xmm2
jbe 0x55bb4
movl $0x2c, %edx
movq 0x120b48(%rip), %rdi    # 0x175fa8
leaq 0xa308a(%rip), %rsi     # 0xf84f1
callq 0x22ab0
movq 0x120b35(%rip), %rcx    # 0x175fa8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x120b17(%rip), %rdi    # 0x175fa8
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 0x5564f
movl $0x1, %ebx
xorl %r15d, %r15d
movsd (%rax,%r15,8), %xmm1
movq 0x28(%r13), %rax
movsd (%rax,%r15,8), %xmm0
subsd %xmm1, %xmm0
mulsd 0xa1613(%rip), %xmm0    # 0xf6af8
addsd %xmm1, %xmm0
ucomisd 0xa2dff(%rip), %xmm0    # 0xf82f0
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 0x55529
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x55538
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x684d4
movl $0x18, %edx
movq 0x120a64(%rip), %rdi    # 0x175fa8
leaq 0xa2e79(%rip), %rsi     # 0xf83c4
callq 0x22ab0
movq 0x48(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x120a46(%rip), %rdi    # 0x175fa8
callq 0x23060
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xa2e64(%rip), %rsi     # 0xf83dd
callq 0x22ab0
movq %r12, %rdi
movsd 0xa156f(%rip), %xmm0    # 0xf6af8
callq 0x23060
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa2e41(%rip), %rsi     # 0xf83e1
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 0xa2e1d(%rip), %rsi     # 0xf83e6
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 0xaaad9(%rip), %rsi     # 0x1000cc
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 0x554c9
movq (%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x140(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0x65d5c
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa1ec4
movq 0x8(%rsp), %r15
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x556a4
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x128(%rsp), %rax
leaq 0x118(%rsp), %r12
cmpq %r12, %rax
je 0x556db
movq 0xc8(%rsp), %rbx
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x22670
cmpq %r12, %rax
jne 0x556c1
testb $0x1, %bpl
je 0x55939
movsd 0xa2c0b(%rip), %xmm0    # 0xf82f8
movsd %xmm0, 0x10(%rsp)
jmp 0x55a51
movq (%rsp), %rbx
movq 0xa8(%rbx), %rax
cmpl $0x0, 0x1658(%rax)
je 0x55760
movl $0x1, %r12d
movq 0x80(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x55f62
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
incl %r12d
movq 0xa8(%rbx), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
jbe 0x55712
cmpl $0x1, %eax
jbe 0x55760
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
callq 0x59ef4
movq 0x80(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
movl $0x1, %esi
callq 0x5aae4
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 0x55cf3
addq 0xb0(%rsp), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
callq 0x65eca
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movl $0xb, %edx
movq 0x1207d8(%rip), %rdi    # 0x175fa8
leaq 0xa2cb1(%rip), %rsi     # 0xf8488
callq 0x22ab0
movq 0x1207c5(%rip), %rdi    # 0x175fa8
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 0x558b0
movl $0x2e, %edx
movq 0x120772(%rip), %rdi    # 0x175fa8
leaq 0xa2c57(%rip), %rsi     # 0xf8494
callq 0x22ab0
movq 0x12075f(%rip), %rcx    # 0x175fa8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x120741(%rip), %rdi    # 0x175fa8
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x687b8
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x65d5c
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x687f2
jmp 0x55b69
movl $0x2d, %edx
movq 0x1206ec(%rip), %rdi    # 0x175fa8
leaq 0xa2c00(%rip), %rsi     # 0xf84c3
callq 0x22ab0
movq 0x1206d9(%rip), %rcx    # 0x175fa8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x1206bb(%rip), %rdi    # 0x175fa8
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x687b8
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x65d5c
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x687f2
jmp 0x55b69
movq (%rsp), %rbx
movq 0xa8(%rbx), %rax
cmpl $0x0, 0x1658(%rax)
je 0x5599d
movl $0x1, %r12d
movq 0x80(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x55f62
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
incl %r12d
movq 0xa8(%rbx), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
jbe 0x55953
cmpl $0x1, %eax
jbe 0x5599d
movq %rbx, %rdi
movl 0x8c(%rsp), %esi
callq 0x59ef4
movq %rbx, %rdi
movl $0x1, %esi
movl 0x8c(%rsp), %edx
callq 0x5aae4
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 0x55d06
addq 0xb0(%rsp), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
callq 0x65eca
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0xd, %edx
movq 0x12059f(%rip), %rdi    # 0x175fa8
leaq 0xa2b0e(%rip), %rsi     # 0xf851e
callq 0x22ab0
movq 0x12058c(%rip), %rdi    # 0x175fa8
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 0x55aec
movq 0x18(%r15), %r12
movq %r12, %rdi
callq 0x22670
cmpq 0xc0(%rsp), %rax
je 0x55b80
movq 0x48(%rsp), %rbx
movq 0x50(%rsp), %r15
movq %r15, %r13
subq %rbx, %r13
sarq $0x3, %r13
cmpq %rbx, %r15
movsd 0xa105c(%rip), %xmm1    # 0xf6af8
je 0x55ad5
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 0x55ab2
movq %rax, %rdi
callq 0x22670
cmpq 0xc0(%rsp), %rax
jne 0x55a91
jmp 0x55b80
movl $0x2b, %edx
movq 0x1204b0(%rip), %rdi    # 0x175fa8
leaq 0xa2a2d(%rip), %rsi     # 0xf852c
callq 0x22ab0
movq 0x12049d(%rip), %rcx    # 0x175fa8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0x12047f(%rip), %rdi    # 0x175fa8
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq %r15, %rdi
movq %r13, %rsi
callq 0x687b8
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x65d5c
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x687f2
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x55b80
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x55b9d
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x55bb4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x55bd1
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
movq (%rsp), %rbp
je 0x55bf2
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x55c09
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
leaq 0xe0(%rsp), %rdi
callq 0x65e76
cmpl $0x14, 0x38(%rsp)
jb 0x549b6
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 0x55d3b
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 0x65eca
leaq 0x118(%rsp), %r14
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x128(%rsp), %rax
cmpq %r14, %rax
je 0x55cc1
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 0x55ca6
leaq 0x110(%rsp), %rdi
callq 0x4a472
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9d992(%rip), %rdi     # 0xf3679
movq 0x78(%rsp), %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d97f(%rip), %rdi     # 0xf3679
movq 0x78(%rsp), %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d96c(%rip), %rdi     # 0xf3679
movq 0x78(%rsp), %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d959(%rip), %rdi     # 0xf3679
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d948(%rip), %rdi     # 0xf3679
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22f40
leaq 0x9d937(%rip), %rdi     # 0xf3679
xorl %eax, %eax
callq 0x22f40
jmp 0x55e80
jmp 0x55e80
jmp 0x55e80
jmp 0x55e52
jmp 0x55e52
jmp 0x55d9b
jmp 0x55e52
movq %rax, %rbx
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x55ed2
movq 0x150(%rsp), %rsi
jmp 0x55e6a
jmp 0x55ecf
jmp 0x55e52
jmp 0x55d9b
jmp 0x55e52
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x55e55
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x55e55
jmp 0x55e52
jmp 0x55e52
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x55ee9
movq 0x30(%rsp), %rsi
jmp 0x55ee1
jmp 0x55e8a
movq %rax, %rbx
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x55ed2
movq 0x168(%rsp), %rsi
jmp 0x55e6a
jmp 0x55ecf
jmp 0x55e8a
jmp 0x55e8a
jmp 0x55f08
movq %rax, %rbx
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x55f0b
movq 0x180(%rsp), %rsi
jmp 0x55efe
jmp 0x55eab
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x65e76
jmp 0x55f3f
jmp 0x55e52
jmp 0x55e52
jmp 0x55e52
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x55ed2
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x55ed2
movq %rax, %rbx
jmp 0x55f28
jmp 0x55e80
jmp 0x55e80
movq %rax, %rbx
jmp 0x55f4c
jmp 0x55e8a
movq %rax, %rbx
jmp 0x55ee9
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x55eb6
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x55eb6
movq %rax, %rbx
jmp 0x55f3f
movq %rax, %rbx
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x55f3f
movq 0x198(%rsp), %rsi
jmp 0x55f37
jmp 0x55ecf
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x55ee9
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x55f0b
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
jmp 0x55f0b
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x55f28
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x55f3f
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
leaq 0xe0(%rsp), %rdi
callq 0x65e76
leaq 0x110(%rsp), %rdi
callq 0x4a472
movq %rbx, %rdi
callq 0x23240
nop