// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Model.cpp
// Function: Model::outputModelWithParams(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, double>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, bool, bool, bool, bool)
void Model::outputModelWithParams(map<string, double> params, string path, string filename, string suffix, bool stopAtNetGen=false, bool onlyActions=false, bool netAndBngl=false, bool usePipe=false, bool isNetFile=false) {
	if (swarm_->options.verbosity >= 3) {
//		cout << "RAQUEL outputmodel path " << path << " filename: " << filename << endl;
	}
	//Raquel added this check step to make sure that the simulation path really exists
	if (!checkIfFileExists(path)) {
		runCommand("mkdir " + path);
	}


	if (netAndBngl) {
		// First output the .bngl file (containing only action commands)
		outputModelWithParams(params, path, filename, suffix, false, true, false, false, false);
		filename = boost::regex_replace(filename, boost::regex("bngl$"), string("net"));
		// Then output the .net file
		outputModelWithParams(params, path, filename, "", false, false, false, false, true);

		return;
	}

	// Erase file if it already exists
	string fullPath = path + filename;
	if (checkIfFileExists(fullPath)) {
		unlink(fullPath.c_str());
	}

	if (!usePipe) {
		unlink(fullPath.c_str());
		if (swarm_->options.verbosity >= 3) {
			cout << "RAQUEL outputmodel inside !usepipe " << filename  << endl;
		}
		ofstream outFile;
		outFile.open(fullPath);
		if (swarm_->options.verbosity >= 3) {
			cout << "RAQUEL outputmodel fullPath is: " << fullPath << endl;
		}
		boost::smatch matches;

		if (outFile.is_open()) {
			if (isNetFile) {
				bool inParameterBlock = true;
				int numParamsToReplace = params.size();
				int numReplacedParams = 0;
				if (swarm_->options.verbosity >= 3) {
					cout << "Raquel param size is: " << params.size() << endl;
				}
				for (auto line = netContents_.begin(); line != netContents_.end(); ++line) {
					if (*line == "end parameters" || numReplacedParams == numParamsToReplace) {
						inParameterBlock = false;
					}
					else if (inParameterBlock) {
						// Replace free param with generated param
						//double tt = 0;
						//for (auto p : params) { // TODO: Is there a faster way to do this than loop through params over and over? It's still too slow.
						for (map<string, double>::iterator p = params.begin(); p != params.end(); ++p) {
							//cout << "p is " << p.first << endl;
							//Timer tmr;
							if(boost::regex_match(*line, matches, boost::regex("\\s+\\d+\\s+(\\w+)\\s+(.+)\\s+"))) {
								//double t = tmr.elapsed();
								//cout << "Match took " << t << " seconds" << endl;
								//tt += t;
								if (matches[1] == p->first) {
									string match = p->first + "\\s+.+";
									string replacement = p->first + " " + toString(abs(p->second)) + "\n";
									*line = boost::regex_replace(*line, boost::regex(match), replacement);
									numReplacedParams++;
								}
							}
						}
						//cout << "matches took " << tt << " seconds" << endl;
					}
					outFile << *line;
				}
			}
			else {
				if (onlyActions) {
					filename = boost::regex_replace(filename, boost::regex("bngl$"), string("net"));
					string line = "readFile({file=>\"" + path + filename + "\"})\n";
					outFile << line;
				}

				for (auto line = fullContents_.begin(); line != fullContents_.end(); ++line) {
					if (onlyActions) {
						string actionLine = *line;
						if (boost::regex_search(*line, boost::regex("^\\s*simulate|^\\s*simulate_nf|^\\s*simulate_ode|^\\s*simulate_ssa|^\\s*simulate_pla|^\\s*parameter_scan|^\\s*setConcentration|^\\s*addConcentration|^\\s*saveConcentration|^\\s*resetConcentrations|^\\s*setParameter|^\\s*saveParameters|^\\s*resetParameters|^\\s*quit|^\\s*substanceUnits|^\\s*version|^\\s*setOption"))) {
							if (!suffix.empty()) {
								string suffixLine = ",suffix=>\"" + suffix + "\"})";
								actionLine = boost::regex_replace(actionLine, boost::regex("\\}\\)"), suffixLine);
							}
						}
						else {
							continue;
						}
						actionLine = actionLine + "\n";
						outFile << actionLine;
					}
					else {
						string newLine = *line;
						//Raquel fixing problem that would remove space after closing parenthesis, making the rules from example 4 not work
						string fixedLine = boost::regex_replace(newLine, boost::regex("\\)\\w"), string(") \\w"));
						newLine = fixedLine;

						bool inParameterBlock = true;
						int numReplacedParams = 0;
						int numParamsToReplace = params.size();
						// Skip line if it's empty or if it is a comment
						if (boost::regex_match(*line, boost::regex("^\\s*$")) || boost::regex_match(*line, boost::regex("^#"))) {
							continue;
						}
						// TODO: Next line is never working. Same as above for .net file?
						if (*line == "end parameters" || numReplacedParams == numParamsToReplace) {
							inParameterBlock = false;
							//cout << "out of parameter block" << endl;
						}
						if (swarm_->options.verbosity >= 9) {

							cout << *line << endl;
							cout << numReplacedParams << " " << numParamsToReplace << endl;
						}
						if (inParameterBlock) {
							// Replace free param with generated param
							if (swarm_->options.verbosity >= 9) {

								cout << "in parameter block" << endl;

							}
							if (boost::regex_search(*line, matches, boost::regex("(\\s+|=\\s*)(\\w+)__FREE__"))) {
								// Older version of C++ don't support double overload to toString, so we have to cast to long double
								if (swarm_->options.verbosity >= 9) {

									cout << "found a FP: " << matches[2] << endl;
									cout << "OPTIONS USED:" << stopAtNetGen << "," << onlyActions << "," << netAndBngl << "," << usePipe << "," << isNetFile << endl;
								}
								newLine = boost::regex_replace(*line, boost::regex("(\\w+)__FREE__"), toString(params[matches[2]]));

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

									cout << "replacing with: " << params[matches[2]] << endl;
								}
								++numReplacedParams;
							}else if(boost::regex_search(*line, matches, boost::regex("\\w+__FREE__"))){
								if (swarm_->options.verbosity >= 3) {

									cout << "found a FP2: " << matches[2] << endl;
								}
								newLine = boost::regex_replace(*line, boost::regex("\\w+__FREE__"), toString(params[matches[2]]));
								if (swarm_->options.verbosity >= 3) {

									cout << "replacing with: " << params[matches[2]] << endl;
								}
							}
						}else{
							if (swarm_->options.verbosity >= 3) {

								cout << "out of parmeter block" << endl;
							}
						}
						// Add in the unique suffix
						if (!suffix.empty()) {
							if (boost::regex_search(*line, boost::regex("^\\s*simulate|^\\s*simulate_nf|^\\s*simulate_ode|^\\s*simulate_ssa|^\\s*simulate_pla|^\\s*parameter_scan"))) {
								string suffixLine = ",suffix=>\"" + suffix + "\"})";
								newLine = boost::regex_replace(*line, boost::regex("\\}\\)"), suffixLine);
								newLine = newLine + "\n";
							}
						}
						//Raquel fixed problem that made resetConcentrations and simulate commands not be separated into different lines
						char ch = newLine.back();
						if(ch!='\n'){
							newLine = newLine + "\n";
						}

						outFile << newLine;
						if (stopAtNetGen) {
							if (boost::regex_search(*line,matches,boost::regex("^generate_network"))) {
								break;
							}
						}
					}
				}
			}
			outFile.close();
		}
		else {
			swarm_->outputError("Couldn't open file '" + fullPath + "' for output");
		}
	}
	else {
		const char * fifo = path.c_str();

		int fifo_status = mkfifo(fifo, 0666);
		if (fifo_status) {
			swarm_->outputError("Couldn't create pipe '" + path + "' for output");
		}

		int fd = open(fifo, O_RDONLY);
		if (fd < 0) {
			cout << "Couldn't open " << fifo << endl;
		}

		//for (auto line : fullContents_) {
		for (vector<string>::iterator line = fullContents_.begin(); line != fullContents_.end(); ++line) {
			write(fd,line->c_str(),line->size());
		}
		close(fd);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x628, %rsp            # imm = 0x628
movl %r9d, 0x2c(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x30(%rsp)
movq %rdi, %r13
leaq 0x2e8(%rsp), %rbx
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x28dd0
movq %rbx, %rdi
callq 0x9ec28
movl %eax, %ebx
leaq 0x2e8(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
jne 0x4cfa8
leaq 0x88f17(%rip), %rsi     # 0xd5e97
leaq 0x2c8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3338b
movq %rbx, %rdi
callq 0x9f543
leaq 0x2c8(%rsp), %rdi
callq 0x295a0
cmpb $0x0, 0x668(%rsp)
je 0x4d1c1
leaq 0x338(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x4e96a
leaq 0x2a8(%rsp), %rdi
movq %r12, %rsi
callq 0x28dd0
leaq 0x288(%rsp), %rdi
movq %r15, %rsi
callq 0x28dd0
leaq 0x268(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x28dd0
andl $0x0, 0x18(%rsp)
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
movl $0x1, (%rsp)
leaq 0x338(%rsp), %rsi
leaq 0x2a8(%rsp), %rdx
leaq 0x288(%rsp), %rcx
leaq 0x268(%rsp), %r8
movq %r13, %rdi
xorl %r9d, %r9d
callq 0x4cf22
leaq 0x268(%rsp), %rdi
callq 0x295a0
leaq 0x288(%rsp), %rdi
callq 0x295a0
leaq 0x2a8(%rsp), %rdi
callq 0x295a0
leaq 0x338(%rsp), %rdi
callq 0x495ac
leaq 0x88e28(%rip), %rsi     # 0xd5e9e
leaq 0xf0(%rsp), %rdi
xorl %edx, %edx
callq 0x33278
leaq 0x898ba(%rip), %rsi     # 0xd6946
leaq 0x248(%rsp), %rdi
leaq 0x148(%rsp), %rdx
callq 0x33402
leaq 0x428(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
leaq 0x248(%rsp), %rcx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x4926c
leaq 0x428(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x28c40
movq %rbx, %rdi
callq 0x295a0
leaq 0x248(%rsp), %rdi
callq 0x295a0
leaq 0xf8(%rsp), %rdi
callq 0x33e80
leaq 0x308(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x4e96a
leaq 0x228(%rsp), %rdi
movq %r12, %rsi
callq 0x28dd0
leaq 0x208(%rsp), %rdi
movq %r15, %rsi
callq 0x28dd0
leaq 0x87acf(%rip), %rsi     # 0xd4c01
leaq 0x1e8(%rsp), %rdi
leaq 0x428(%rsp), %rdx
callq 0x33402
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movl $0x1, 0x18(%rsp)
leaq 0x308(%rsp), %rsi
leaq 0x228(%rsp), %rdx
leaq 0x208(%rsp), %rcx
leaq 0x1e8(%rsp), %r8
movq %r13, %rdi
xorl %r9d, %r9d
callq 0x4cf22
leaq 0x1e8(%rsp), %rdi
callq 0x295a0
leaq 0x208(%rsp), %rdi
callq 0x295a0
leaq 0x228(%rsp), %rdi
callq 0x295a0
leaq 0x308(%rsp), %rdi
callq 0x495ac
jmp 0x4e0e2
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x34fc8
leaq 0x1c8(%rsp), %rdi
movq %rbx, %rsi
callq 0x28dd0
leaq 0x1c8(%rsp), %rdi
callq 0x9ec28
movl %eax, %ebx
movb 0x670(%rsp), %bpl
leaq 0x1c8(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
je 0x4d21c
movq 0x148(%rsp), %rdi
callq 0x28480
testb %bpl, %bpl
je 0x4d2fb
movq (%r12), %rbx
movq %rbx, %rdi
movl $0x1b6, %esi            # imm = 0x1B6
callq 0x28150
testl %eax, %eax
je 0x4d29b
movq 0x60(%r13), %r14
leaq 0x88ef3(%rip), %rsi     # 0xd6138
leaq 0x428(%rsp), %rdi
movq %r12, %rdx
callq 0x3338b
leaq 0x88ecf(%rip), %rdx     # 0xd612b
leaq 0x168(%rsp), %rdi
leaq 0x428(%rsp), %rsi
callq 0x3336c
leaq 0x168(%rsp), %rsi
movq %r14, %rdi
callq 0x6aed2
leaq 0x168(%rsp), %rdi
callq 0x295a0
leaq 0x428(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x28770
movl %eax, %ebp
testl %eax, %eax
jns 0x4d2d3
movq 0x118ce4(%rip), %rdi    # 0x165f98
leaq 0x90690(%rip), %rsi     # 0xdd94b
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x88(%r13), %rbx
cmpq 0x90(%r13), %rbx
je 0x4d667
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl %ebp, %edi
callq 0x28340
addq $0x20, %rbx
jmp 0x4d2da
movq 0x148(%rsp), %rdi
callq 0x28480
movq 0x60(%r13), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x4d33b
movq 0x118c7c(%rip), %rdi    # 0x165f98
leaq 0x88b81(%rip), %rsi     # 0xd5ea4
callq 0x289f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
leaq 0x428(%rsp), %rdi
callq 0x29240
leaq 0x428(%rsp), %rdi
leaq 0x148(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x28490
movq 0x60(%r13), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x4d398
movq 0x118c24(%rip), %rdi    # 0x165f98
leaq 0x88b4d(%rip), %rsi     # 0xd5ec8
callq 0x289f0
leaq 0x148(%rsp), %rsi
movq %rax, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0xf0(%rsp)
movb $0x0, 0x120(%rsp)
andl $0x0, 0x138(%rsp)
movups %xmm0, 0x128(%rsp)
movb $0x1, 0x13c(%rsp)
leaq 0x498(%rsp), %rdi
callq 0x28200
testb %al, %al
je 0x4d673
cmpb $0x0, 0x678(%rsp)
movq %r13, 0x38(%rsp)
je 0x4d6de
movq 0x30(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0xcc(%rsp)
movq 0x60(%r13), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x4d443
movq 0x118b7a(%rip), %rdi    # 0x165f98
leaq 0x88ac4(%rip), %rsi     # 0xd5ee9
callq 0x289f0
movq 0x30(%rsp), %rcx
movq 0x28(%rcx), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0xa0(%r13), %r13
movq 0x30(%rsp), %rax
leaq 0x8(%rax), %rbx
movb $0x1, 0x2c(%rsp)
movl $0x0, 0x40(%rsp)
leaq 0xa8(%rsp), %r14
leaq 0x48(%rsp), %r12
movq 0x38(%rsp), %rax
cmpq 0xa8(%rax), %r13
je 0x4e0ae
movq %r13, %rdi
leaq 0x88a77(%rip), %rsi     # 0xd5f00
callq 0x3357b
movl 0x40(%rsp), %ecx
cmpl 0xcc(%rsp), %ecx
sete %cl
orb %al, %cl
movl %ecx, %eax
xorb $0x1, %al
movb 0x2c(%rsp), %dl
andb %dl, %al
testb %cl, %cl
jne 0x4d64a
movl %edx, %ecx
xorb $0x1, %cl
testb $0x1, %cl
jne 0x4d64a
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rbp
cmpq %rbx, %rbp
je 0x4d64e
movq %r14, %rdi
leaq 0x88a35(%rip), %rsi     # 0xd5f0f
xorl %edx, %edx
callq 0x33278
movq %r13, %rdi
leaq 0xf0(%rsp), %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x4e67f
movl %eax, %r15d
leaq 0xb0(%rsp), %rdi
callq 0x33e80
testb %r15b, %r15b
je 0x4d63a
leaq 0xf0(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x332c4
leaq 0x20(%rbp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x4e69a
testb %al, %al
je 0x4d63a
movq %r14, %rdi
movq %r15, %rsi
leaq 0x889e5(%rip), %rdx     # 0xd5f28
callq 0x334ed
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
leaq 0x920b6(%rip), %rdx     # 0xdf60d
callq 0x334ed
movsd 0x40(%rbp), %xmm0
andps 0x88638(%rip), %xmm0    # 0xd5ba0
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
callq 0x9f57b
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
movq %r15, %rdx
callq 0x4e6ed
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
leaq 0x894ba(%rip), %rdx     # 0xd6a54
callq 0x3336c
movq %r12, %rdi
callq 0x295a0
leaq 0xd0(%rsp), %rdi
callq 0x295a0
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x295a0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4e754
leaq 0x408(%rsp), %r15
movq %r15, %rdi
leaq 0x88(%rsp), %rsi
callq 0x28dd0
movq %r12, %rdi
movq %r13, %rsi
leaq 0x68(%rsp), %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x4926c
movq %r13, %rdi
movq %r12, %rsi
callq 0x28c40
movq %r12, %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x33e80
incl 0x40(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x295a0
movq %r14, %rdi
callq 0x295a0
movq %rbp, %rdi
callq 0x28700
movq %rax, %rbp
jmp 0x4d4c7
movb %al, 0x2c(%rsp)
leaq 0x428(%rsp), %rdi
movq %r13, %rsi
callq 0x28910
addq $0x20, %r13
jmp 0x4d46d
movl %ebp, %edi
callq 0x294e0
jmp 0x4e0d5
movq 0x60(%r13), %rbx
leaq 0x88a98(%rip), %rsi     # 0xd6116
leaq 0xa8(%rsp), %rdi
leaq 0x148(%rsp), %rdx
callq 0x3338b
leaq 0x88a91(%rip), %rdx     # 0xd612b
leaq 0x188(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x3336c
leaq 0x188(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aed2
leaq 0x188(%rsp), %rdi
callq 0x295a0
leaq 0xa8(%rsp), %rdi
callq 0x295a0
jmp 0x4e0bb
movb 0x660(%rsp), %bpl
testb %bpl, %bpl
je 0x4d7f4
leaq 0x887a8(%rip), %rsi     # 0xd5e9e
leaq 0x88(%rsp), %rdi
xorl %edx, %edx
callq 0x33278
leaq 0x8923a(%rip), %rsi     # 0xd6946
leaq 0x1a8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x33402
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rdx
leaq 0x1a8(%rsp), %rcx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x4926c
leaq 0xa8(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x28c40
movq %rbx, %rdi
callq 0x295a0
leaq 0x1a8(%rsp), %rdi
callq 0x295a0
leaq 0x90(%rsp), %rdi
callq 0x33e80
leaq 0x887b1(%rip), %rsi     # 0xd5f2e
leaq 0x48(%rsp), %rdi
movq %r12, %rdx
callq 0x3338b
leaq 0x88(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movq %r15, %rdx
callq 0x334ce
leaq 0x8879a(%rip), %rdx     # 0xd5f40
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x3336c
leaq 0x88(%rsp), %rdi
callq 0x295a0
leaq 0x48(%rsp), %rdi
callq 0x295a0
leaq 0x428(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x28910
leaq 0xa8(%rsp), %rdi
callq 0x295a0
movq 0x88(%r13), %r12
leaq 0xa8(%rsp), %r13
leaq 0x48(%rsp), %r15
movq 0x38(%rsp), %rax
cmpq 0x90(%rax), %r12
je 0x4e0ae
testb %bpl, %bpl
je 0x4d963
movq %r13, %rdi
movq %r12, %rsi
callq 0x28dd0
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
leaq 0x88705(%rip), %rsi     # 0xd5f45
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x33735
movl %eax, %ebx
leaq 0x90(%rsp), %rdi
callq 0x33e80
testb %bl, %bl
je 0x4e083
movq 0x40(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4d921
movq %r15, %rdi
leaq 0x887e9(%rip), %rsi     # 0xd606e
movq 0x40(%rsp), %rdx
callq 0x3338b
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
leaq 0x887d8(%rip), %rdx     # 0xd6079
callq 0x3336c
movq %r15, %rdi
callq 0x295a0
leaq 0x68(%rsp), %rdi
leaq 0x887c3(%rip), %rsi     # 0xd607d
xorl %edx, %edx
callq 0x33278
leaq 0x3e8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x88(%rsp), %rsi
callq 0x28dd0
movq %r15, %rdi
movq %r13, %rsi
leaq 0x68(%rsp), %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x4926c
movq %r13, %rdi
movq %r15, %rsi
callq 0x28c40
movq %r15, %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x33e80
leaq 0x88(%rsp), %rdi
callq 0x295a0
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x8911e(%rip), %rdx     # 0xd6a54
callq 0x334ed
movq %r13, %rdi
movq %rbx, %rsi
callq 0x28c40
movq %rbx, %rdi
callq 0x295a0
leaq 0x428(%rsp), %rdi
movq %r13, %rsi
callq 0x28910
jmp 0x4e083
movq %r13, %rdi
movq %r12, %rsi
callq 0x28dd0
movq %r15, %rdi
leaq 0x8870a(%rip), %rsi     # 0xd6082
xorl %edx, %edx
callq 0x33278
leaq 0x3c8(%rsp), %r14
movq %r14, %rdi
leaq 0x886f6(%rip), %rsi     # 0xd6087
leaq 0x68(%rsp), %rdx
callq 0x33402
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x4926c
movq %r14, %rdi
callq 0x295a0
leaq 0x50(%rsp), %rdi
callq 0x33e80
movq %r13, %rdi
movq %rbx, %rsi
callq 0x28570
movq 0x30(%rsp), %rax
movl 0x28(%rax), %ebx
movq %r15, %rdi
leaq 0x886a6(%rip), %rsi     # 0xd608c
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4e785
testb %al, %al
je 0x4da0d
leaq 0x50(%rsp), %rdi
callq 0x33e80
jmp 0x4e076
leaq 0x68(%rsp), %r14
movq %r14, %rdi
leaq 0x88676(%rip), %rsi     # 0xd6092
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4e785
movl %eax, %r14d
leaq 0x70(%rsp), %rdi
callq 0x33e80
leaq 0x50(%rsp), %rdi
callq 0x33e80
testb %r14b, %r14b
jne 0x4e076
movq %r12, %rdi
leaq 0x884a6(%rip), %rsi     # 0xd5f00
callq 0x3357b
movl %eax, %r14d
testl %ebx, %ebx
sete %bpl
movq 0x38(%rsp), %rax
movq 0x60(%rax), %rax
cmpl $0x8, 0x1614(%rax)
jbe 0x4dac0
movq 0x118517(%rip), %rdi    # 0x165f98
movq %r12, %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq 0x118500(%rip), %rdi    # 0x165f98
xorl %esi, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x91b64(%rip), %rsi     # 0xdf60d
callq 0x289f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
orb %r14b, %bpl
movq 0x38(%rsp), %rax
movq 0x60(%rax), %rax
movl 0x1614(%rax), %eax
je 0x4dafd
cmpl $0x3, %eax
jb 0x4ded4
movq 0x1184b4(%rip), %rdi    # 0x165f98
leaq 0x88603(%rip), %rsi     # 0xd60ee
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
jmp 0x4ded4
cmpl $0x9, %eax
jb 0x4db1d
movq 0x11848f(%rip), %rdi    # 0x165f98
leaq 0x88585(%rip), %rsi     # 0xd6095
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq %r15, %rdi
leaq 0x8822a(%rip), %rsi     # 0xd5d51
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
leaq 0xf0(%rsp), %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x332a9
movl %eax, %ebx
leaq 0x50(%rsp), %rdi
callq 0x33e80
testb %bl, %bl
je 0x4dd41
movq 0x38(%rsp), %rax
movq 0x60(%rax), %rax
cmpl $0x9, 0x1614(%rax)
jb 0x4dc32
movq 0x118424(%rip), %rdi    # 0x165f98
leaq 0x8852d(%rip), %rsi     # 0xd60a8
callq 0x289f0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x332c4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4e630
movq %rax, %rdi
callq 0x284a0
movq 0x1183eb(%rip), %rdi    # 0x165f98
leaq 0x88501(%rip), %rsi     # 0xd60b5
callq 0x289f0
movzbl 0x2c(%rsp), %esi
movq %rax, %rdi
callq 0x29180
movq %rax, %rdi
leaq 0x88140(%rip), %rsi     # 0xd5d10
callq 0x289f0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29180
movq %rax, %rdi
leaq 0x88127(%rip), %rsi     # 0xd5d10
callq 0x289f0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29180
movq %rax, %rdi
leaq 0x8810e(%rip), %rsi     # 0xd5d10
callq 0x289f0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29180
movq %rax, %rdi
leaq 0x880f5(%rip), %rsi     # 0xd5d10
callq 0x289f0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29180
movq %rax, %rdi
callq 0x284a0
leaq 0xd0(%rsp), %rdi
leaq 0x8811a(%rip), %rsi     # 0xd5d5b
xorl %edx, %edx
callq 0x33278
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x332c4
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3331c
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x4e7f0
leaq 0x3a8(%rsp), %rbx
movsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x9f57b
movq %r15, %rdi
movq %r12, %rsi
leaq 0xd0(%rsp), %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x4926c
movq %r13, %rdi
movq %r15, %rsi
callq 0x28c40
movq %r15, %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x295a0
leaq 0x68(%rsp), %rdi
callq 0x295a0
leaq 0xd8(%rsp), %rdi
callq 0x33e80
movq 0x38(%rsp), %rax
movq 0x60(%rax), %rax
cmpl $0x9, 0x1614(%rax)
jb 0x4ded4
movq 0x1182a7(%rip), %rdi    # 0x165f98
leaq 0x883cb(%rip), %rsi     # 0xd60c3
callq 0x289f0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x332c4
movq %r15, %rdi
movq %rax, %rsi
callq 0x3331c
movq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4e7f0
movsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
jmp 0x4decc
movq %r15, %rdi
leaq 0x88389(%rip), %rsi     # 0xd60d4
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
leaq 0xf0(%rsp), %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x332a9
movl %eax, %ebx
leaq 0x50(%rsp), %rdi
callq 0x33e80
testb %bl, %bl
je 0x4ded4
movq 0x38(%rsp), %rax
movq 0x60(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x4ddc6
movq 0x118204(%rip), %rdi    # 0x165f98
leaq 0x88345(%rip), %rsi     # 0xd60e0
callq 0x289f0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x332c4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4e630
movq %rax, %rdi
callq 0x284a0
leaq 0xd0(%rsp), %rdi
leaq 0x882ff(%rip), %rsi     # 0xd60d4
xorl %edx, %edx
callq 0x33278
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x332c4
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3331c
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x4e7f0
leaq 0x388(%rsp), %rbx
movsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x9f57b
movq %r15, %rdi
movq %r12, %rsi
leaq 0xd0(%rsp), %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x4926c
movq %r13, %rdi
movq %r15, %rsi
callq 0x28c40
movq %r15, %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x295a0
leaq 0x68(%rsp), %rdi
callq 0x295a0
leaq 0xd8(%rsp), %rdi
callq 0x33e80
movq 0x38(%rsp), %rax
movq 0x60(%rax), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x4ded4
movq 0x118117(%rip), %rdi    # 0x165f98
leaq 0x8823b(%rip), %rsi     # 0xd60c3
callq 0x289f0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x332c4
movq %r15, %rdi
movq %rax, %rsi
callq 0x3331c
movq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4e7f0
movsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x290f0
movq %rax, %rdi
callq 0x284a0
movq %r15, %rdi
callq 0x295a0
movq 0x40(%rsp), %rax
cmpq $0x0, 0x8(%rax)
movb 0x660(%rsp), %bpl
je 0x4dfed
movq %r15, %rdi
leaq 0x87cfa(%rip), %rsi     # 0xd5bf0
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x33735
movl %eax, %ebx
leaq 0x50(%rsp), %rdi
callq 0x33e80
testb %bl, %bl
je 0x4dfed
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
leaq 0x88141(%rip), %rsi     # 0xd606e
movq 0x40(%rsp), %rdx
callq 0x3338b
movq %r15, %rdi
movq %rbx, %rsi
leaq 0x88135(%rip), %rdx     # 0xd6079
callq 0x3336c
movq %rbx, %rdi
callq 0x295a0
leaq 0xd0(%rsp), %rdi
leaq 0x8811d(%rip), %rsi     # 0xd607d
xorl %edx, %edx
callq 0x33278
leaq 0x368(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x28dd0
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
leaq 0xd0(%rsp), %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x4926c
movq %r13, %rdi
movq %rbx, %rsi
callq 0x28c40
movq %rbx, %rdi
callq 0x295a0
movq %r14, %rdi
callq 0x295a0
leaq 0xd8(%rsp), %rdi
callq 0x33e80
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x88a87(%rip), %rdx     # 0xd6a54
callq 0x334ed
movq %r13, %rdi
movq %rbx, %rsi
callq 0x28c40
movq %rbx, %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x295a0
movq 0xa8(%rsp), %rax
movq 0xb0(%rsp), %rcx
cmpb $0xa, -0x1(%rax,%rcx)
je 0x4e029
movq %r15, %rdi
movq %r13, %rsi
leaq 0x88a43(%rip), %rdx     # 0xd6a54
callq 0x334ed
movq %r13, %rdi
movq %r15, %rsi
callq 0x28c40
movq %r15, %rdi
callq 0x295a0
leaq 0x428(%rsp), %rdi
movq %r13, %rsi
callq 0x28910
cmpb $0x0, 0x2c(%rsp)
je 0x4e076
movq %r15, %rdi
leaq 0x880ba(%rip), %rsi     # 0xd6104
xorl %edx, %edx
callq 0x33278
movq %r12, %rdi
leaq 0xf0(%rsp), %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x332a9
movl %eax, %ebx
leaq 0x50(%rsp), %rdi
callq 0x33e80
testb %bl, %bl
jne 0x4e094
leaq 0x88(%rsp), %rdi
callq 0x295a0
movq %r13, %rdi
callq 0x295a0
addq $0x20, %r12
jmp 0x4d808
leaq 0x88(%rsp), %rdi
callq 0x295a0
leaq 0xa8(%rsp), %rdi
callq 0x295a0
leaq 0x428(%rsp), %rdi
callq 0x28e60
leaq 0xf0(%rsp), %rdi
callq 0x3397a
leaq 0x428(%rsp), %rdi
callq 0x28f10
leaq 0x148(%rsp), %rdi
callq 0x295a0
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4e43f
movq %rax, %rbx
leaq 0x388(%rsp), %rdi
jmp 0x4e189
jmp 0x4e43f
jmp 0x4e417
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x295a0
jmp 0x4e128
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x4e478
jmp 0x4e498
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x295a0
jmp 0x4e14c
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x4e48f
jmp 0x4e498
jmp 0x4e1c7
jmp 0x4e43f
jmp 0x4e1ed
jmp 0x4e1fc
jmp 0x4e3cc
jmp 0x4e43f
jmp 0x4e43f
movq %rax, %rbx
leaq 0x3a8(%rsp), %rdi
callq 0x295a0
jmp 0x4e1f0
jmp 0x4e1c7
movq %rax, %rbx
leaq 0x368(%rsp), %rdi
callq 0x295a0
jmp 0x4e1a7
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x33e80
jmp 0x4e1ca
jmp 0x4e1c7
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x4e1cf
jmp 0x4e43f
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x295a0
jmp 0x4e442
jmp 0x4e498
jmp 0x4e3cc
jmp 0x4e43f
jmp 0x4e43f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x295a0
jmp 0x4e1ff
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x4e438
jmp 0x4e3cc
jmp 0x4e43f
jmp 0x4e498
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
jmp 0x4e46b
jmp 0x4e417
jmp 0x4e498
jmp 0x4e3cc
jmp 0x4e43f
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x295a0
jmp 0x4e254
movq %rax, %rbx
leaq 0x428(%rsp), %rdi
jmp 0x4e366
jmp 0x4e47f
jmp 0x4e43f
jmp 0x4e47f
movq %rax, %rbx
leaq 0x3e8(%rsp), %rdi
jmp 0x4e429
jmp 0x4e430
jmp 0x4e43f
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x4e46b
jmp 0x4e417
movq %rax, %rbx
leaq 0x2c8(%rsp), %rdi
jmp 0x4e4bd
jmp 0x4e417
jmp 0x4e417
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x33e80
jmp 0x4e3cf
jmp 0x4e3cc
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x295a0
jmp 0x4e2e2
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x295a0
jmp 0x4e2f4
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x295a0
jmp 0x4e306
movq %rax, %rbx
leaq 0x308(%rsp), %rdi
jmp 0x4e38d
movq %rax, %rbx
leaq 0x248(%rsp), %rdi
callq 0x295a0
jmp 0x4e325
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x33e80
jmp 0x4e4c2
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0x295a0
jmp 0x4e34c
movq %rax, %rbx
leaq 0x288(%rsp), %rdi
callq 0x295a0
jmp 0x4e373
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x295a0
jmp 0x4e4b5
movq %rax, %rbx
leaq 0x2a8(%rsp), %rdi
callq 0x295a0
jmp 0x4e385
movq %rax, %rbx
leaq 0x338(%rsp), %rdi
callq 0x495ac
jmp 0x4e4c2
movq %rax, %rbx
jmp 0x4e4a8
jmp 0x4e47f
jmp 0x4e47f
jmp 0x4e43f
jmp 0x4e498
jmp 0x4e498
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x4e3ef
movq %rax, %rbx
jmp 0x4e3ea
jmp 0x4e43f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x4e438
jmp 0x4e417
jmp 0x4e417
movq %rax, %rbx
leaq 0x3c8(%rsp), %rdi
callq 0x295a0
leaq 0x50(%rsp), %rdi
callq 0x33e80
jmp 0x4e470
movq %rax, %rbx
leaq 0x2e8(%rsp), %rdi
jmp 0x4e4bd
jmp 0x4e43f
jmp 0x4e498
movq %rax, %rbx
jmp 0x4e459
movq %rax, %rbx
jmp 0x4e466
movq %rax, %rbx
jmp 0x4e470
jmp 0x4e498
movq %rax, %rbx
leaq 0x408(%rsp), %rdi
callq 0x295a0
jmp 0x4e433
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x33e80
jmp 0x4e442
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x4e46b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x295a0
leaq 0xd0(%rsp), %rdi
callq 0x295a0
leaq 0x68(%rsp), %rdi
callq 0x295a0
leaq 0xa8(%rsp), %rdi
callq 0x295a0
jmp 0x4e49b
movq %rax, %rbx
jmp 0x4e4b5
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x33e80
jmp 0x4e49b
jmp 0x4e498
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x3397a
leaq 0x428(%rsp), %rdi
callq 0x28f10
leaq 0x148(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x292f0