// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1c8, %rsp            # imm = 0x1C8
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movl %edx, %esi
movq %rsi, 0x88(%rsp)
callq 0x59f72
leaq 0x108(%rsp), %rdi
movq %rax, %rsi
callq 0x4e96a
movq %r15, %rdi
movl %ebp, 0x64(%rsp)
movl %ebp, %esi
callq 0x59f90
movq %rax, 0x30(%rsp)
movq %rbx, (%rsp)
leaq 0x8(%rbx), %rax
movq %rax, 0xd0(%rsp)
leaq 0x18(%r15), %rax
movq %rax, 0x80(%rsp)
movq $0x0, 0x28(%rsp)
leaq 0x38(%rsp), %r13
movq %r15, 0x18(%rsp)
cmpl $0x13, 0x28(%rsp)
ja 0x51ec9
movq 0xd0(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
pushq $-0x1
popq %rsi
callq 0x5aab9
movq 0x114d5e(%rip), %rdi    # 0x165f98
leaq 0x85083(%rip), %rsi     # 0xd62c4
callq 0x289f0
movq 0x58(%rsp), %rcx
movsd 0x20(%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x58(%rsp), %rdi
pushq $-0x1
popq %rsi
callq 0x5aab9
movq 0x114d1a(%rip), %rdi    # 0x165f98
leaq 0x85038(%rip), %rsi     # 0xd62bd
callq 0x289f0
movq 0x58(%rsp), %rcx
movsd 0x20(%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
movq 0x18(%rax), %rbp
movq 0x114cdb(%rip), %rdi    # 0x165f98
leaq 0x8500b(%rip), %rsi     # 0xd62cf
callq 0x289f0
movsd 0x20(%rbp), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
xorpd %xmm0, %xmm0
movapd %xmm0, 0xf0(%rsp)
andq $0x0, 0x100(%rsp)
movq (%rsp), %rax
movq 0x18(%rax), %r12
cmpq 0x8(%rsp), %r12
je 0x5135f
movq 0xa8(%r15), %rbx
leaq 0x28(%r12), %rsi
leaq 0x150(%rsp), %r14
movq %r14, %rdi
callq 0x59fa2
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x82bec
leaq 0xf0(%rsp), %rdi
movq %r13, %rsi
callq 0x5c984
movq %r13, %rdi
callq 0x5c44e
leaq 0x150(%rsp), %rdi
callq 0x5c44e
movq %r12, %rdi
callq 0x28700
movq %rax, %r12
jmp 0x512fc
leaq 0x1b0(%rsp), %rbx
movq %rbx, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x5a004
leaq 0x68(%rsp), %rdi
movq %rbx, %rdx
callq 0x50bfe
pushq $0x1
popq %r12
movq %rbx, %rdi
callq 0x5a05e
movq 0x114c01(%rip), %rdi    # 0x165f98
leaq 0x84f3b(%rip), %rsi     # 0xd62d9
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
andq $0x0, 0xc0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movl %ebx, %ebx
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x514e5
movsd (%rax,%rbx,8), %xmm0
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
movapd %xmm0, %xmm1
subsd (%rax,%rbx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
ucomisd 0x84e0d(%rip), %xmm1    # 0xd6218
movzbl %r15b, %r15d
cmoval %r12d, %r15d
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
cmovael %r12d, %r15d
movq 0x114b72(%rip), %rdi    # 0x165f98
leaq 0x84eb7(%rip), %rsi     # 0xd62e4
callq 0x289f0
movq 0x68(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x84eaf(%rip), %rsi     # 0xd62fd
callq 0x289f0
movq %rax, %rdi
movsd 0x84dba(%rip), %xmm0    # 0xd6218
callq 0x290f0
movq %rax, %rdi
leaq 0x84e94(%rip), %rsi     # 0xd6301
callq 0x289f0
movq 0x68(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x84e78(%rip), %rsi     # 0xd6306
callq 0x289f0
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x8ce02(%rip), %rsi     # 0xde2b5
callq 0x289f0
movsd 0x38(%rsp), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
leaq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x5a080
incl %ebx
jmp 0x513c6
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x198(%rsp), %r13
movq %r13, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x59fa2
leaq 0x138(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x82c4a
movq %r13, %rdi
callq 0x5c44e
movq 0x138(%rsp), %rbx
movq 0x120(%rsp), %rax
leaq 0x38(%rsp), %r13
leaq 0x110(%rsp), %rcx
cmpq %rcx, %rax
je 0x5155d
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x28700
jmp 0x51539
testb $0x1, %r15b
je 0x51573
xorl %r15d, %r15d
movsd 0x84ca2(%rip), %xmm0    # 0xd6210
jmp 0x515f3
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
ja 0x5159f
movq 0x30(%rsp), %rdi
movl %r12d, %esi
pushq $0x1
popq %rdx
callq 0x520a6
incl %r12d
jmp 0x51573
cmpl $0x1, %eax
jbe 0x515ae
movq 0x30(%rsp), %rdi
callq 0x53e88
movq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x53e96
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x5a0a2
orl $-0x1, 0x38(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5a0c0
movq 0x28(%rsp), %rcx
addl %r12d, %ecx
decl %ecx
movq %rcx, 0x28(%rsp)
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x114998(%rip), %rdi    # 0x165f98
leaq 0x84d03(%rip), %rsi     # 0xd630a
callq 0x289f0
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movsd 0x20(%rbp), %xmm0
movsd 0x10(%rsp), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x51756
movq 0x20(%rsp), %rax
movsd 0x20(%rax), %xmm1
ucomisd %xmm2, %xmm1
jbe 0x51756
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x5168d
movq 0x114931(%rip), %rdi    # 0x165f98
leaq 0x84ca9(%rip), %rsi     # 0xd6317
callq 0x289f0
movq 0x8(%rsp), %rcx
movsd 0x20(%rcx), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x5cf46
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x516db
movq 0x1148e1(%rip), %rdi    # 0x165f98
leaq 0x84ca0(%rip), %rsi     # 0xd635e
callq 0x289f0
movq (%rsp), %rcx
movq 0x28(%rcx), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x59fa2
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x5cf94
movq 0x18(%rsp), %rbx
leaq 0x40(%rsp), %rdi
callq 0x5c44e
movq 0xa8(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x51e8e
movq 0x114869(%rip), %rdi    # 0x165f98
leaq 0x84c33(%rip), %rsi     # 0xd6369
callq 0x289f0
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
jmp 0x51e8e
ucomisd %xmm2, %xmm0
jbe 0x518e5
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x51790
movq 0x11481c(%rip), %rdi    # 0x165f98
leaq 0x84bfa(%rip), %rsi     # 0xd637d
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
xorl %ebx, %ebx
pushq $0x1
popq %rbp
movl %ebx, %ebx
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x51a53
movsd (%rax,%rbx,8), %xmm0
movq 0xb0(%rsp), %rax
movsd (%rax,%rbx,8), %xmm1
subsd %xmm0, %xmm1
addsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
ucomisd 0x84a25(%rip), %xmm1    # 0xd6218
movzbl %r15b, %r15d
cmoval %ebp, %r15d
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
cmovael %ebp, %r15d
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x5a080
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x518de
movq 0x114761(%rip), %rdi    # 0x165f98
leaq 0x84aa6(%rip), %rsi     # 0xd62e4
callq 0x289f0
movq 0x68(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x84a9e(%rip), %rsi     # 0xd62fd
callq 0x289f0
movq %rax, %rdi
movsd 0x849b1(%rip), %xmm0    # 0xd6220
callq 0x290f0
movq %rax, %rdi
leaq 0x84a83(%rip), %rsi     # 0xd6301
callq 0x289f0
movq 0xb0(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x84a64(%rip), %rsi     # 0xd6306
callq 0x289f0
movq 0x68(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x8c9f2(%rip), %rsi     # 0xde2b5
callq 0x289f0
movsd 0x38(%rsp), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
incl %ebx
jmp 0x517ab
movq 0x20(%rsp), %rax
ucomisd 0x20(%rax), %xmm2
jbe 0x51e8e
movq 0x11469c(%rip), %rdi    # 0x165f98
leaq 0x84b0e(%rip), %rsi     # 0xd6411
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
xorl %ebx, %ebx
pushq $0x1
popq %r12
movl %ebx, %ebx
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x51c53
movsd (%rax,%rbx,8), %xmm0
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
movsd (%rax,%rbx,8), %xmm1
subsd %xmm0, %xmm1
mulsd 0x83121(%rip), %xmm1    # 0xd4a88
addsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
ucomisd 0x8489f(%rip), %xmm1    # 0xd6218
movzbl %r15b, %r15d
cmoval %r12d, %r15d
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
cmovael %r12d, %r15d
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x5a080
movq 0x1145f4(%rip), %rdi    # 0x165f98
leaq 0x84939(%rip), %rsi     # 0xd62e4
callq 0x289f0
movq 0x68(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x84931(%rip), %rsi     # 0xd62fd
callq 0x289f0
movq %rax, %rdi
movsd 0x830ac(%rip), %xmm0    # 0xd4a88
callq 0x290f0
movq %rax, %rdi
leaq 0x84916(%rip), %rsi     # 0xd6301
callq 0x289f0
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x848f6(%rip), %rsi     # 0xd6306
callq 0x289f0
movq 0x68(%rsp), %rcx
movsd (%rcx,%rbx,8), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
leaq 0x8c884(%rip), %rsi     # 0xde2b5
callq 0x289f0
movsd 0x38(%rsp), %xmm0
movq %rax, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
incl %ebx
jmp 0x5192c
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %rbx
leaq 0x180(%rsp), %r12
movq %r12, %rdi
leaq 0x90(%rsp), %rsi
callq 0x59fa2
leaq 0xd8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x82c4a
movq %r12, %rdi
callq 0x5c44e
movq 0xd8(%rsp), %rbx
movq 0x120(%rsp), %rax
leaq 0x110(%rsp), %rcx
cmpq %rcx, %rax
je 0x51ac6
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x28700
jmp 0x51aa2
testb $0x1, %r15b
je 0x51ad9
movsd 0x8473c(%rip), %xmm1    # 0xd6210
jmp 0x51b91
movl %ebp, %r12d
movq 0x18(%rsp), %rbx
movq 0xa8(%rbx), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
ja 0x51b08
movq 0x30(%rsp), %rdi
movl %r12d, %esi
pushq $0x1
popq %rdx
callq 0x520a6
incl %r12d
jmp 0x51ae1
cmpl $0x1, %eax
jbe 0x51b17
movq 0x30(%rsp), %rdi
callq 0x53e88
movq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x53e96
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x5a0a2
orl $-0x1, 0x38(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5a0c0
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x11443e(%rip), %rdi    # 0x165f98
leaq 0x84847(%rip), %rsi     # 0xd63a8
callq 0x289f0
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x28(%rsp), %rax
addl %r12d, %eax
decl %eax
movq %rax, 0x28(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
movsd %xmm1, 0x20(%rsp)
ucomisd %xmm1, %xmm0
jbe 0x51bfb
movq 0x1143ee(%rip), %rdi    # 0x165f98
leaq 0x84803(%rip), %rsi     # 0xd63b4
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x5cf46
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x59fa2
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x5cf94
jmp 0x51e6a
movq 0x114396(%rip), %rdi    # 0x165f98
leaq 0x847da(%rip), %rsi     # 0xd63e3
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x5cf46
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x59fa2
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x5cf94
jmp 0x51e6a
movq 0x18(%rsp), %rax
movq 0xa8(%rax), %r14
leaq 0x168(%rsp), %rbx
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
callq 0x59fa2
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x82c4a
movq %rbx, %rdi
callq 0x5c44e
movq 0xd8(%rsp), %rbx
movq 0x120(%rsp), %rax
leaq 0x110(%rsp), %rcx
cmpq %rcx, %rax
je 0x51cc6
movsd (%rbx), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x8, %rbx
movq %rax, %rdi
callq 0x28700
jmp 0x51ca2
testb $0x1, %r15b
je 0x51cd9
movsd 0x8453c(%rip), %xmm1    # 0xd6210
jmp 0x51d92
movq 0x18(%rsp), %rbx
movq 0xa8(%rbx), %rax
movl 0x1658(%rax), %eax
cmpl %eax, %r12d
ja 0x51d05
movq 0x30(%rsp), %rdi
movl %r12d, %esi
pushq $0x1
popq %rdx
callq 0x520a6
incl %r12d
jmp 0x51cde
cmpl $0x1, %eax
jbe 0x51d16
movq %rbx, %rdi
movl 0x64(%rsp), %esi
callq 0x53ea4
movq %rbx, %rdi
pushq $0x1
popq %rsi
movl 0x64(%rsp), %edx
callq 0x544c2
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x5a0a2
orl $-0x1, 0x38(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5a0c0
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x11423d(%rip), %rdi    # 0x165f98
leaq 0x846dc(%rip), %rsi     # 0xd643e
callq 0x289f0
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq 0x28(%rsp), %rax
addl %r12d, %eax
decl %eax
movq %rax, 0x28(%rsp)
movsd 0x10(%rsp), %xmm1
movq 0x8(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm1, 0x10(%rsp)
ucomisd %xmm1, %xmm0
ja 0x51e17
movq (%rsp), %rax
movq 0x18(%rax), %r14
movq %r14, %rdi
callq 0x28700
movq 0x70(%rsp), %rbx
subq 0x68(%rsp), %rbx
sarq $0x3, %rbx
cmpq 0xd0(%rsp), %rax
movsd 0x82cb2(%rip), %xmm1    # 0xd4a88
je 0x51e74
xorl %ecx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rbx
jbe 0x51e0d
movq 0x28(%r14), %rdx
movq 0x28(%rax), %rsi
movsd (%rsi,%rcx,8), %xmm0
movq 0x28(%rbp), %rdi
subsd (%rdi,%rcx,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%rdx,%rcx,8), %xmm0
movsd %xmm0, (%rsi,%rcx,8)
incl %ecx
jmp 0x51dde
movq %rax, %rdi
callq 0x28700
jmp 0x51dc6
movq 0x11417a(%rip), %rdi    # 0x165f98
leaq 0x84627(%rip), %rsi     # 0xd644c
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x5cf46
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x59fa2
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x5cf94
leaq 0x40(%rsp), %rdi
callq 0x5c44e
leaq 0xd8(%rsp), %rdi
callq 0x5c44e
leaq 0x90(%rsp), %rdi
callq 0x5c44e
leaq 0x138(%rsp), %rdi
callq 0x5c44e
leaq 0xb0(%rsp), %rdi
callq 0x5c44e
leaq 0x68(%rsp), %rdi
callq 0x5c44e
leaq 0xf0(%rsp), %rdi
callq 0x5a05e
movq 0x18(%rsp), %r15
jmp 0x5120e
movq (%rsp), %r14
movq 0x18(%r14), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x5a0a2
leaq 0x38(%rsp), %rsi
orl $-0x1, (%rsi)
movq %rax, %rdi
callq 0x5a0c0
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %ebx, %ebx
movq 0x120(%rsp), %rax
leaq 0x110(%rsp), %rcx
cmpq %rcx, %rax
je 0x51f42
movq 0x18(%r14), %rcx
movl %ebx, %edx
incl %ebx
movq 0x28(%rcx), %rcx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x40(%rax)
movq %rax, %rdi
callq 0x28700
jmp 0x51f15
leaq 0x108(%rsp), %rdi
callq 0x495ac
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x52006
jmp 0x52006
jmp 0x52006
jmp 0x51f99
jmp 0x5200e
jmp 0x5200e
jmp 0x5204a
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
jmp 0x52019
jmp 0x5200e
jmp 0x5200e
jmp 0x51f99
jmp 0x5200e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5c44e
jmp 0x52011
jmp 0x52022
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x52055
jmp 0x5204a
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
jmp 0x52019
jmp 0x52022
jmp 0x5200e
jmp 0x52069
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
jmp 0x52062
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
callq 0x5a05e
jmp 0x52083
jmp 0x52027
movq %rax, %rbx
jmp 0x52079
jmp 0x5200e
jmp 0x5200e
jmp 0x52006
jmp 0x52006
movq %rax, %rbx
jmp 0x52090
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x5c44e
jmp 0x5204d
jmp 0x52022
movq %rax, %rbx
jmp 0x5205a
movq %rax, %rbx
jmp 0x52083
movq %rax, %rbx
jmp 0x5203e
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5c44e
leaq 0x150(%rsp), %rdi
jmp 0x5207e
jmp 0x5204a
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x5c44e
leaq 0x138(%rsp), %rdi
callq 0x5c44e
jmp 0x5206c
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x5c44e
leaq 0x68(%rsp), %rdi
callq 0x5c44e
leaq 0xf0(%rsp), %rdi
callq 0x5a05e
leaq 0x108(%rsp), %rdi
callq 0x495ac
movq %rbx, %rdi
callq 0x292f0
nop