// File: simonrharris[P]SKA/src/sk_refalign.cpp
// Function: alignKmersToReference(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, int const&, bool const&, bool const&, bool const&, bool const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, bool)
int alignKmersToReference(const std::string & reference, const std::string & outputfile, const std::vector < std::string > & kmerfiles, const int & kmerlen, const bool & includeref, const bool & maprepeats, const bool & fillall, const bool & variantonly, const std::vector <std::string> & sample, const bool circularContigs)
{

	const std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
	
	// Create the kmer map
	std::unordered_map < std::string, std::vector <int> > kmerMap;
	std::set < int > revSet;
	int substringlength=(kmerlen*2)+1;
	std::string filename=splitFileName(reference);
	std::cout << "Reading " << filename << std::endl;

	int basenum=0;
	std::string refseq;
	char base;
	std::vector < int > referenceContigLengths;
	
	igzstream gzfileStream;

	if(openGzFileStream(reference, gzfileStream)){return 1;}//open the fasta file. May be gzipped.

	while (gzfileStream.peek() != EOF){
		std::string sequence;
		std::string name;

		if(readNextFastaSequence(gzfileStream, reference, name, sequence)){return 1;}//read the next sequence from the file
		int seqlen=sequence.length();
		referenceContigLengths.push_back(seqlen);
		refseq.append(sequence);
		if (seqlen<substringlength){
			basenum+=seqlen;
			continue;
		}

		int baseposition=basenum;

		if (circularContigs){
			if(circulariseSequence(sequence, kmerlen)){return 1;}//if the contigs are circular, add an extra kmer length of sequence from the opposite end to each end
		}
		else {
			baseposition+=kmerlen;
		}
		
		int i=0;
		
		
		for (std::string::iterator iti = sequence.begin(), end = sequence.end()-(substringlength-1); iti != end; ++iti, ++i, ++baseposition){
			std::string kmer=sequence.substr(i,substringlength);
			
			if (reverseComplementIfMin(kmer)){
				revSet.insert(baseposition);
			}
			extractMiddleBase(kmer, base);
			if(ascii_codons(kmer)){return 1;}
			
			addKmerToBasePositionMap(kmerMap, kmer, baseposition);

		}
		basenum+=seqlen;
			
    }
    gzfileStream.close();


	
	std::cout << kmerMap.size() << " kmers read" << std::endl;
	
	std::vector < std::string > sampleNames;
	if (collectSampleNames(kmerfiles, sampleNames)!=0){return 1;}//get sample names from all kmerfiles

	std::vector < bool > include (sampleNames.size());
	getSubsample(sample, sampleNames, include);//get a vector of bools representing which samples to include based on a provided sample file. This also removed duplicate samples in the input files

	std::vector < std::string > includedSampleNames;

	if (includeref){
		includedSampleNames.push_back(filename);
	}

	for (std::vector < bool >::iterator it=include.begin(); it!=include.end(); ++it){//make a vector of all included sample names to help printing output files later
		if (*it){
			includedSampleNames.push_back(sampleNames[distance(include.begin(), it)]);
		}
	}

	std::cout << includedSampleNames.size()-int(includeref) << " samples will be aligned to " << reference << std::endl;

	std::vector < std::string > sequences(includedSampleNames.size(), std::string (basenum , '-'));//create a vector to store the new sequences;

	std::ifstream fileStream;

	char kmerbuffer[kmerlen*2/3];
	int sampleNum=0;
	int includedSampleNum=0;
	if (includeref){
		sequences[0]=refseq;
		includedSampleNum=1;
	}
	
	std::vector < std::string > names;
	
	for (int s = 0; s < kmerfiles.size(); ++s){

		std::string filename=splitFileName(kmerfiles[s]);
		if (openFileStream(kmerfiles[s], fileStream)){return 1;};

		int kmersize;
		
		readKmerHeader(fileStream, kmersize, names);//read the header from the kmer file to get the kmer size and sample names
		
		if (kmersize!=kmerlen){
			std::cerr << std::endl << "kmer size in " << filename << " is not " << kmerlen << std::endl << std::endl;
			return 1;
		}

		std::vector < int > fileInclude;

		for (int i=0; i<names.size(); ++i){ //put the index of all sample names that are to be included into a vector
			if (include[sampleNum+i]){
				fileInclude.push_back(i);
			}
		}

		if (fileInclude.size()==0){ // if no sample names in the file are going to be included then don't read the file
			fileStream.close();
			std::cerr << "Nothing to align" << std::endl;
			sampleNum+=int(names.size());
			names.clear();
			continue;
		}

		char asciibuffer[int(ceil(float(names.size())/6))];

		while (fileStream.read(asciibuffer, sizeof(asciibuffer))){
			std::string asciibits (asciibuffer, sizeof(asciibuffer));
			std::vector < bool > mybits;
			vectorbool_from_ascii(asciibits, mybits);//read the ascii representation of the taxa to a vector of bools
			
			while (fileStream.peek()!='\n' && fileStream.get(base)){
				//base=toupper(base);
				fileStream.read(kmerbuffer, sizeof(kmerbuffer));
				std::string kmer (kmerbuffer, kmerlen*2/3);
				std::unordered_map < std::string, std::vector <int> >::iterator it = kmerMap.find(kmer);//check if the kmer is in the hash
				if ( it != kmerMap.end() ){//if the kmer is in the hash
					if (it->second.size()==1 || maprepeats){//if the match is unique or the user has chosen to map repeats
						
						for (std::vector < int >::iterator itb = it->second.begin(); itb != it->second.end(); ++itb) {//iterate each match of the kmer in the reference
							char mybase=base;
							std::set < int >::iterator itc = revSet.find(*itb);//for each match see if the kmer in the reference is on the reverse strand
							if ( itc != revSet.end() ){//if so, complement the base
								mybase=complement(base);
							}

							for (int j=0; j<fileInclude.size(); ++j){ //add the base to all samples that are true in the bitset
								if (mybits[fileInclude[j]]){
									sequences[includedSampleNum+j][*itb]=mybase;//set the base of the sequence at the site matching the reference
								}
							}
						}
					}
				}
			}
			fileStream.ignore(256,'\n');//skip the end ofline character
    	}

    	for (int i=0; i<fileInclude.size(); ++i){//print the percentage of mapped bases for each sample in a file

    		int contigStart=0;
    		int filledto=0;

    		for (std::vector <int >::iterator rclit=referenceContigLengths.begin(); rclit!=referenceContigLengths.end(); ++rclit){//Fill bases around mapped bases or SNPs
    			filledto=contigStart;
    			for (int j=kmerlen; j<(*rclit-kmerlen); ++j){
    				if ((base_score[sequences[includedSampleNum+i][contigStart+j]]<4 && std::isupper(sequences[includedSampleNum+i][contigStart+j])) && ( fillall || sequences[includedSampleNum+i][contigStart+j] != refseq[contigStart+j])){
    					int fillfrom=std::max(std::max(contigStart+j-kmerlen, contigStart), filledto);
		    			filledto=std::min(contigStart+j+kmerlen+1, contigStart+*rclit);
		    			for (int k=fillfrom; k<filledto; ++k){
		    				if (sequences[includedSampleNum+i][k]=='-'){//if the base is a gap in the sample set it to the reference base in lower case
								sequences[includedSampleNum+i][k]=std::tolower(refseq[k]);//this needs fixing when the contigs are circular to stop it running into the next contig
							}
		    			}
    				}
    			}
    			contigStart+=*rclit;
    		}

	    	int mappedbases=basenum;
	    	int mappedNs=0;
	    	int snps=0;
	    	for (int j=0; j<basenum; ++j){
	    		if (sequences[includedSampleNum+i][j]=='-'){
	    			mappedbases--;
	    		}
	    		if (base_score[sequences[includedSampleNum+i][j]]<4 && base_score[refseq[j]]<4 && sequences[includedSampleNum+i][j]!=refseq[j] && ::isupper(sequences[includedSampleNum+i][j]) ) { 
	    			snps++;
	    		}
	    	}
			std::cout << includedSampleNames[i] << ": " << float(mappedbases)/(basenum)*100 << "% of reference bases mapped. " << snps << " SNPs found vs reference sequence. ";
			if(calculateMissedSNPs(basenum, snps, kmersize)){return 1;};
    	}
    	sampleNum+=int(names.size()); //add the number of samples in the file to the count of total samples
    	includedSampleNum+=int(fileInclude.size());
    	names.clear();
		fileStream.close();
	}


	std::ofstream alignfile(outputfile);
	if (alignfile.fail()){
		std::cerr << std::endl << "Error: Failed to open " << outputfile << std::endl << std::endl;
		return 1;
	}
	
	if (variantonly){
		printVariantSites(alignfile, basenum, includedSampleNames, sequences);
	}
	else{
		std::cout << "Printing alignment" << std::endl;
		for (int i=0; i<includedSampleNames.size(); ++i){
			alignfile << ">" << includedSampleNames[i] << std::endl << sequences[i] << std::endl;
		}
	}

	alignfile.close();
	
	printDuration(start);

	return 0;
	
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe90, %rsp            # imm = 0xE90
movb 0x28(%rbp), %al
movq 0x20(%rbp), %r10
movq 0x18(%rbp), %r10
movq 0x10(%rbp), %r10
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
andb $0x1, %al
movb %al, -0x39(%rbp)
callq 0x6080
movq %rax, -0x48(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2dd50
leaq -0xb0(%rbp), %rdi
callq 0x38e90
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %eax
movl %eax, -0xb4(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0xa370
jmp 0x36e69
movq 0x42138(%rip), %rdi     # 0x78fa8
leaq 0x22410(%rip), %rsi     # 0x59287
callq 0x6520
movq %rax, -0xb60(%rbp)
jmp 0x36e85
movq -0xb60(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x64d0
movq %rax, -0xb68(%rbp)
jmp 0x36ea1
movq -0xb68(%rbp), %rdi
movq 0x420e1(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x36eb6
movl $0x0, -0xe8(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x6730
leaq -0x128(%rbp), %rdi
callq 0x1ac10
leaq -0x3c8(%rbp), %rdi
callq 0x92d0
jmp 0x36ee6
movq -0x10(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
movl $0x1, %edx
callq 0xa5e0
movl %eax, -0xb6c(%rbp)
jmp 0x36f03
movl -0xb6c(%rbp), %eax
cmpl $0x0, %eax
je 0x36f80
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x38d2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38d9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38d86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38d7a
jmp 0x36f82
leaq -0x240(%rbp), %rdi
callq 0x61c0
movl %eax, -0xb70(%rbp)
jmp 0x36f96
movl -0xb70(%rbp), %eax
cmpl $-0x1, %eax
je 0x37332
leaq -0x3f0(%rbp), %rdi
movq %rdi, -0xb80(%rbp)
callq 0x6730
leaq -0x410(%rbp), %rdi
movq %rdi, -0xb88(%rbp)
callq 0x6730
movq -0xb88(%rbp), %rdx
movq -0xb80(%rbp), %rcx
movq -0x10(%rbp), %rsi
leaq -0x3c8(%rbp), %rdi
callq 0x84b0
movl %eax, -0xb74(%rbp)
jmp 0x36ff1
movl -0xb74(%rbp), %eax
cmpl $0x0, %eax
je 0x37029
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x372d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x37315
leaq -0x3f0(%rbp), %rdi
callq 0x67e0
movl %eax, -0x414(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x414(%rbp), %rsi
callq 0x1ac30
jmp 0x37050
leaq -0x108(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x69c0
jmp 0x37065
movl -0x414(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0x37094
movl -0x414(%rbp), %eax
addl -0xe8(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl $0x2, -0x3cc(%rbp)
jmp 0x372d2
movl -0xe8(%rbp), %eax
movl %eax, -0x418(%rbp)
testb $0x1, -0x39(%rbp)
je 0x370e3
movq -0x28(%rbp), %rax
movl (%rax), %esi
leaq -0x3f0(%rbp), %rdi
callq 0x8ee0
movl %eax, -0xb8c(%rbp)
jmp 0x370c0
movl -0xb8c(%rbp), %eax
cmpl $0x0, %eax
je 0x370e1
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x372d2
jmp 0x370f5
movq -0x28(%rbp), %rax
movl (%rax), %eax
addl -0x418(%rbp), %eax
movl %eax, -0x418(%rbp)
movl $0x0, -0x41c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x64a0
movq %rax, -0x428(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x62e0
movq %rax, -0x438(%rbp)
movl -0xb4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x438(%rbp), %rdi
callq 0x38eb0
movq %rax, -0x430(%rbp)
leaq -0x428(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x90d0
testb $0x1, %al
jne 0x37160
jmp 0x372b6
movslq -0x41c(%rbp), %rdx
movslq -0xb4(%rbp), %rcx
leaq -0x458(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x6550
jmp 0x37183
leaq -0x458(%rbp), %rdi
callq 0x7ec0
movb %al, -0xb8d(%rbp)
jmp 0x37197
movb -0xb8d(%rbp), %al
testb $0x1, %al
jne 0x371a3
jmp 0x37204
leaq -0xb0(%rbp), %rdi
leaq -0x418(%rbp), %rsi
callq 0x38ef0
movb %dl, -0xb99(%rbp)
movq %rax, -0xb98(%rbp)
jmp 0x371c5
movb -0xb99(%rbp), %al
movq -0xb98(%rbp), %rcx
movq %rcx, -0x468(%rbp)
movb %al, -0x460(%rbp)
jmp 0x37204
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x458(%rbp), %rdi
callq 0x6a08
jmp 0x37315
leaq -0x458(%rbp), %rdi
leaq -0x109(%rbp), %rsi
callq 0xbe60
jmp 0x37219
leaq -0x458(%rbp), %rdi
callq 0x8100
movl %eax, -0xba0(%rbp)
jmp 0x3722d
movl -0xba0(%rbp), %eax
cmpl $0x0, %eax
je 0x3724b
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x3726d
movl -0x418(%rbp), %edx
leaq -0x80(%rbp), %rdi
leaq -0x458(%rbp), %rsi
callq 0x365a0
jmp 0x37263
movl $0x0, -0x3cc(%rbp)
leaq -0x458(%rbp), %rdi
callq 0x6a08
movl -0x3cc(%rbp), %eax
testl %eax, %eax
jne 0x372d2
jmp 0x37285
jmp 0x37287
leaq -0x428(%rbp), %rdi
callq 0x9130
movl -0x41c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x41c(%rbp)
movl -0x418(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x418(%rbp)
jmp 0x37144
movl -0x414(%rbp), %eax
addl -0xe8(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl $0x0, -0x3cc(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x6a08
leaq -0x3f0(%rbp), %rdi
callq 0x6a08
movl -0x3cc(%rbp), %eax
movl %eax, -0xba4(%rbp)
testl %eax, %eax
je 0x37310
jmp 0x372fc
movl -0xba4(%rbp), %eax
subl $0x2, %eax
je 0x36f82
jmp 0x38d2d
jmp 0x36f82
leaq -0x410(%rbp), %rdi
callq 0x6a08
leaq -0x3f0(%rbp), %rdi
callq 0x6a08
jmp 0x38d7a
leaq -0x3c8(%rbp), %rdi
callq 0x9400
jmp 0x37340
leaq -0x80(%rbp), %rdi
callq 0x2e2a0
movq %rax, %rsi
movq 0x41c55(%rip), %rdi     # 0x78fa8
callq 0x6120
movq %rax, -0xbb0(%rbp)
jmp 0x37361
movq -0xbb0(%rbp), %rdi
leaq 0x23042(%rip), %rsi     # 0x5a3b1
callq 0x6520
movq %rax, -0xbb8(%rbp)
jmp 0x3737d
movq -0xbb8(%rbp), %rdi
movq 0x41c05(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x37392
leaq -0x480(%rbp), %rdi
movq %rdi, -0xbc8(%rbp)
callq 0x1ab40
movq -0xbc8(%rbp), %rsi
movq -0x20(%rbp), %rdi
movl $0x1, %edx
callq 0xced0
movl %eax, -0xbbc(%rbp)
jmp 0x373c2
movl -0xbbc(%rbp), %eax
cmpl $0x0, %eax
je 0x373fa
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x38d11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38d1f
leaq -0x480(%rbp), %rdi
callq 0xb670
movq %rax, -0xbd8(%rbp)
leaq -0x4a9(%rbp), %rdi
movq %rdi, -0xbd0(%rbp)
callq 0xf380
movq -0xbd8(%rbp), %rsi
movq -0xbd0(%rbp), %rdx
leaq -0x4a8(%rbp), %rdi
callq 0xf3a0
jmp 0x3743c
leaq -0x4a9(%rbp), %rdi
callq 0xf3e0
movq 0x20(%rbp), %rdi
leaq -0x480(%rbp), %rsi
leaq -0x4a8(%rbp), %rdx
callq 0xd240
jmp 0x37461
leaq -0x4c8(%rbp), %rdi
callq 0x1ab40
movq -0x30(%rbp), %rax
testb $0x1, (%rax)
je 0x374de
leaq -0x4c8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xabd0
jmp 0x3748b
jmp 0x374de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x4a9(%rbp), %rdi
callq 0xf3e0
jmp 0x38d1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38d03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38cf7
leaq -0x4a8(%rbp), %rdi
callq 0xf580
movl %edx, -0x4e0(%rbp)
movq %rax, -0x4e8(%rbp)
movq -0x4e8(%rbp), %rax
movq %rax, -0x4d8(%rbp)
movl -0x4e0(%rbp), %eax
movl %eax, -0x4d0(%rbp)
leaq -0x4a8(%rbp), %rdi
callq 0xf5c0
movl %edx, -0x500(%rbp)
movq %rax, -0x508(%rbp)
movl -0x500(%rbp), %eax
movl %eax, -0x4f0(%rbp)
movq -0x508(%rbp), %rax
movq %rax, -0x4f8(%rbp)
leaq -0x4d8(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
callq 0xf1c0
movb %al, -0xbd9(%rbp)
jmp 0x3755f
movb -0xbd9(%rbp), %al
testb $0x1, %al
jne 0x3756e
jmp 0x3765f
leaq -0x4d8(%rbp), %rdi
callq 0xf5e0
movq %rdx, -0xbf0(%rbp)
movq %rax, -0xbe8(%rbp)
jmp 0x3758a
movq -0xbf0(%rbp), %rax
movq -0xbe8(%rbp), %rcx
movq %rcx, -0x518(%rbp)
movq %rax, -0x510(%rbp)
leaq -0x518(%rbp), %rdi
callq 0xf510
testb $0x1, %al
jne 0x375bb
jmp 0x3764a
leaq -0x4a8(%rbp), %rdi
callq 0xf580
movl %edx, -0x530(%rbp)
movq %rax, -0x538(%rbp)
movl -0x530(%rbp), %eax
movl %eax, -0x520(%rbp)
movq -0x538(%rbp), %rax
movq %rax, -0x528(%rbp)
movups -0x4d8(%rbp), %xmm0
movaps %xmm0, -0x550(%rbp)
movq -0x528(%rbp), %rdi
movl -0x520(%rbp), %esi
movq -0x550(%rbp), %rdx
movl -0x548(%rbp), %ecx
callq 0xf670
movq %rax, -0xbf8(%rbp)
jmp 0x37624
movq -0xbf8(%rbp), %rsi
leaq -0x480(%rbp), %rdi
callq 0x1ab60
movq %rax, %rsi
leaq -0x4c8(%rbp), %rdi
callq 0xabd0
jmp 0x37648
jmp 0x3764a
jmp 0x3764c
leaq -0x4d8(%rbp), %rdi
callq 0xf6f0
jmp 0x3765a
jmp 0x37511
leaq -0x4c8(%rbp), %rdi
callq 0xb670
movq %rax, %rsi
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0x1, %eax
subq %rax, %rsi
movq 0x41926(%rip), %rdi     # 0x78fa8
callq 0x6120
movq %rax, -0xc00(%rbp)
jmp 0x37690
movq -0xc00(%rbp), %rdi
leaq 0x22d1f(%rip), %rsi     # 0x5a3bd
callq 0x6520
movq %rax, -0xc08(%rbp)
jmp 0x376ac
movq -0xc08(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x64d0
movq %rax, -0xc10(%rbp)
jmp 0x376c5
movq -0xc10(%rbp), %rdi
movq 0x418bd(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x376da
leaq -0x4c8(%rbp), %rdi
callq 0xb670
movq %rax, -0xc28(%rbp)
movslq -0xe8(%rbp), %rax
movq %rax, -0xc20(%rbp)
leaq -0x589(%rbp), %rdi
movq %rdi, -0xc18(%rbp)
callq 0x6910
movq -0xc20(%rbp), %rsi
movq -0xc18(%rbp), %rcx
leaq -0x588(%rbp), %rdi
movl $0x2d, %edx
callq 0x9150
jmp 0x3772f
leaq -0x58a(%rbp), %rdi
movq %rdi, -0xc30(%rbp)
callq 0xfdc0
movq -0xc28(%rbp), %rsi
movq -0xc30(%rbp), %rcx
leaq -0x568(%rbp), %rdi
leaq -0x588(%rbp), %rdx
callq 0x38f40
jmp 0x37765
leaq -0x58a(%rbp), %rdi
callq 0xfef0
leaq -0x588(%rbp), %rdi
callq 0x6a08
leaq -0x589(%rbp), %rdi
callq 0x65a0
leaq -0x798(%rbp), %rdi
callq 0x65f0
jmp 0x37797
movq -0x28(%rbp), %rax
movl (%rax), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
movq %rax, -0xc40(%rbp)
movq %rsp, %rcx
movq %rcx, -0x7a0(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xc38(%rbp)
movq %rcx, %rsp
movq %rax, -0x7a8(%rbp)
movl $0x0, -0x7ac(%rbp)
movl $0x0, -0x7b0(%rbp)
movq -0x30(%rbp), %rax
testb $0x1, (%rax)
je 0x378b3
xorl %eax, %eax
movl %eax, %esi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
leaq -0x108(%rbp), %rsi
callq 0x6060
jmp 0x3782a
movl $0x1, -0x7b0(%rbp)
jmp 0x378b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x37874
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x58a(%rbp), %rdi
callq 0xfef0
leaq -0x588(%rbp), %rdi
callq 0x6a08
leaq -0x589(%rbp), %rdi
callq 0x65a0
jmp 0x38cf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38ceb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38cdf
leaq -0x7c8(%rbp), %rdi
callq 0x1ab40
movl $0x0, -0x7cc(%rbp)
movslq -0x7cc(%rbp), %rax
movq %rax, -0xc48(%rbp)
movq -0x20(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0xc48(%rbp), %rax
cmpq %rcx, %rax
jae 0x389f3
movq -0x20(%rbp), %rdi
movslq -0x7cc(%rbp), %rsi
callq 0xf2d0
movq %rax, %rsi
leaq -0x7f0(%rbp), %rdi
callq 0xa370
jmp 0x37914
movq -0x20(%rbp), %rdi
movslq -0x7cc(%rbp), %rsi
callq 0xf2d0
movq %rax, %rdi
leaq -0x798(%rbp), %rsi
movl $0x1, %edx
callq 0xa4f0
movl %eax, -0xc4c(%rbp)
jmp 0x37940
movl -0xc4c(%rbp), %eax
cmpl $0x0, %eax
je 0x3798f
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x38992
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x38cd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x389e2
leaq -0x798(%rbp), %rdi
leaq -0x7f4(%rbp), %rsi
leaq -0x7c8(%rbp), %rdx
callq 0xcd40
jmp 0x379ab
movl -0x7f4(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
je 0x37a8f
movq 0x4162c(%rip), %rdi     # 0x78ff0
movq 0x415c5(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0xc58(%rbp)
jmp 0x379d9
movq -0xc58(%rbp), %rdi
leaq 0x229f3(%rip), %rsi     # 0x5a3da
callq 0x6520
movq %rax, -0xc60(%rbp)
jmp 0x379f5
movq -0xc60(%rbp), %rdi
leaq -0x7f0(%rbp), %rsi
callq 0x64d0
movq %rax, -0xc68(%rbp)
jmp 0x37a11
movq -0xc68(%rbp), %rdi
leaq 0x229c9(%rip), %rsi     # 0x5a3e8
callq 0x6520
movq %rax, -0xc70(%rbp)
jmp 0x37a2d
movq -0xc70(%rbp), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %esi
callq 0x68d0
movq %rax, -0xc78(%rbp)
jmp 0x37a48
movq -0xc78(%rbp), %rdi
movq 0x4153a(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0xc80(%rbp)
jmp 0x37a64
movq -0xc80(%rbp), %rdi
movq 0x4151e(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x37a79
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x38992
leaq -0x810(%rbp), %rdi
callq 0x1ac10
movl $0x0, -0x814(%rbp)
movslq -0x814(%rbp), %rax
movq %rax, -0xc88(%rbp)
leaq -0x7c8(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0xc88(%rbp), %rax
cmpq %rcx, %rax
jae 0x37b71
movl -0x7ac(%rbp), %eax
movl -0x814(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x4a8(%rbp), %rdi
callq 0xedc0
movq %rdx, -0xc98(%rbp)
movq %rax, -0xc90(%rbp)
jmp 0x37aff
movq -0xc98(%rbp), %rax
movq -0xc90(%rbp), %rcx
movq %rcx, -0x828(%rbp)
movq %rax, -0x820(%rbp)
leaq -0x828(%rbp), %rdi
callq 0xf510
testb $0x1, %al
jne 0x37b2d
jmp 0x37b5b
leaq -0x810(%rbp), %rdi
leaq -0x814(%rbp), %rsi
callq 0x1ac30
jmp 0x37b42
jmp 0x37b5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x389d6
jmp 0x37b5d
movl -0x814(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x814(%rbp)
jmp 0x37aa5
leaq -0x810(%rbp), %rdi
callq 0xf7f0
cmpq $0x0, %rax
jne 0x37bf5
leaq -0x798(%rbp), %rdi
callq 0x60f0
jmp 0x37b91
movq 0x41458(%rip), %rdi     # 0x78ff0
leaq 0x22852(%rip), %rsi     # 0x5a3f1
callq 0x6520
movq %rax, -0xca0(%rbp)
jmp 0x37bad
movq -0xca0(%rbp), %rdi
movq 0x413d5(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x37bc2
leaq -0x7c8(%rbp), %rdi
callq 0xb670
addl -0x7ac(%rbp), %eax
movl %eax, -0x7ac(%rbp)
leaq -0x7c8(%rbp), %rdi
callq 0x1aca0
movl $0xc, -0x3cc(%rbp)
jmp 0x38986
leaq -0x7c8(%rbp), %rdi
callq 0xb670
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xca8(%rbp)
testq %rax, %rax
movss %xmm0, -0xca4(%rbp)
js 0x37c42
movss -0xca8(%rbp), %xmm0
movss %xmm0, -0xca4(%rbp)
movss -0xca4(%rbp), %xmm0
movss 0x21a2a(%rip), %xmm1    # 0x5967c
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x60b0
cvttsd2si %xmm0, %eax
movq %rax, -0xcb8(%rbp)
movq %rsp, %rcx
movq %rcx, -0x830(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xcb0(%rbp)
movq %rcx, %rsp
movq %rax, -0x838(%rbp)
movq -0xcb8(%rbp), %rdx
movq -0xcb0(%rbp), %rsi
leaq -0x798(%rbp), %rdi
callq 0x6680
movq %rax, -0xcc0(%rbp)
jmp 0x37cb9
movq -0xcc0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, -0xcc1(%rbp)
jmp 0x37cd7
movb -0xcc1(%rbp), %al
testb $0x1, %al
jne 0x37ce6
jmp 0x381c9
leaq -0x859(%rbp), %rdi
movq %rdi, -0xcd0(%rbp)
callq 0x6910
movq -0xcb0(%rbp), %rsi
movq -0xcb8(%rbp), %rdx
movq -0xcd0(%rbp), %rcx
leaq -0x858(%rbp), %rdi
callq 0x65e0
jmp 0x37d1c
leaq -0x859(%rbp), %rdi
callq 0x65a0
leaq -0x888(%rbp), %rdi
movq %rdi, -0xcd8(%rbp)
callq 0x1acc0
movq -0xcd8(%rbp), %rsi
leaq -0x858(%rbp), %rdi
callq 0xbd50
jmp 0x37d50
jmp 0x37d52
leaq -0x798(%rbp), %rdi
callq 0x61c0
movl %eax, -0xcdc(%rbp)
jmp 0x37d66
movl -0xcdc(%rbp), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0xcdd(%rbp)
je 0x37dc1
leaq -0x798(%rbp), %rdi
leaq -0x109(%rbp), %rsi
callq 0x6720
movq %rax, -0xce8(%rbp)
jmp 0x37d95
movq -0xce8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, -0xce9(%rbp)
jmp 0x37db3
movb -0xce9(%rbp), %al
movb %al, -0xcdd(%rbp)
jmp 0x37dc1
movb -0xcdd(%rbp), %al
testb $0x1, %al
jne 0x37dd0
jmp 0x38177
movq -0xc40(%rbp), %rdx
movq -0xc38(%rbp), %rsi
leaq -0x798(%rbp), %rdi
callq 0x6680
jmp 0x37dec
movq -0x28(%rbp), %rax
movl (%rax), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
cltq
movq %rax, -0xd00(%rbp)
leaq -0x8a9(%rbp), %rdi
movq %rdi, -0xcf8(%rbp)
callq 0x6910
movq -0xc38(%rbp), %rsi
movq -0xd00(%rbp), %rdx
movq -0xcf8(%rbp), %rcx
leaq -0x8a8(%rbp), %rdi
callq 0x65e0
jmp 0x37e49
leaq -0x8a9(%rbp), %rdi
callq 0x65a0
leaq -0x80(%rbp), %rdi
leaq -0x8a8(%rbp), %rsi
callq 0x2df50
movq %rax, -0xd08(%rbp)
jmp 0x37e6e
movq -0xd08(%rbp), %rax
movq %rax, -0x8b8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2dfb0
movq %rax, -0x8c0(%rbp)
leaq -0x8b8(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
callq 0x2df80
testb $0x1, %al
jne 0x37ea8
jmp 0x38166
leaq -0x8b8(%rbp), %rdi
callq 0x2e020
movq %rax, %rdi
addq $0x20, %rdi
callq 0xf7f0
cmpq $0x1, %rax
je 0x37ed3
movq -0x38(%rbp), %rax
testb $0x1, (%rax)
je 0x38164
leaq -0x8b8(%rbp), %rdi
callq 0x2e020
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1c1b0
movq %rax, -0x8c8(%rbp)
leaq -0x8b8(%rbp), %rdi
callq 0x2e020
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1c040
movq %rax, -0x8d0(%rbp)
leaq -0x8c8(%rbp), %rdi
leaq -0x8d0(%rbp), %rsi
callq 0x245c0
testb $0x1, %al
jne 0x37f2d
jmp 0x38162
movb -0x109(%rbp), %al
movb %al, -0x8d1(%rbp)
leaq -0x8c8(%rbp), %rdi
callq 0x24600
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x38fc0
movq %rax, -0xd10(%rbp)
jmp 0x37f5d
movq -0xd10(%rbp), %rax
movq %rax, -0x8e0(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x39030
movq %rax, -0x8e8(%rbp)
leaq -0x8e0(%rbp), %rdi
leaq -0x8e8(%rbp), %rsi
callq 0x39000
testb $0x1, %al
jne 0x37f9a
jmp 0x3803f
leaq -0x109(%rbp), %rdi
callq 0x7d20
movb %al, -0xd11(%rbp)
jmp 0x37fae
movb -0xd11(%rbp), %al
movb %al, -0x8d1(%rbp)
jmp 0x3803f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x859(%rbp), %rdi
callq 0x65a0
jmp 0x389d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x381ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x8a9(%rbp), %rdi
callq 0x65a0
jmp 0x381ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x8a8(%rbp), %rdi
callq 0x6a08
jmp 0x381ac
movl $0x0, -0x8ec(%rbp)
movslq -0x8ec(%rbp), %rax
movq %rax, -0xd20(%rbp)
leaq -0x810(%rbp), %rdi
callq 0xf7f0
movq %rax, %rcx
movq -0xd20(%rbp), %rax
cmpq %rcx, %rax
jae 0x3814f
movslq -0x8ec(%rbp), %rsi
leaq -0x810(%rbp), %rdi
callq 0x1a9b0
movslq (%rax), %rsi
leaq -0x888(%rbp), %rdi
callq 0xedc0
movq %rdx, -0xd30(%rbp)
movq %rax, -0xd28(%rbp)
jmp 0x380a8
movq -0xd30(%rbp), %rax
movq -0xd28(%rbp), %rcx
movq %rcx, -0x900(%rbp)
movq %rax, -0x8f8(%rbp)
leaq -0x900(%rbp), %rdi
callq 0xf510
testb $0x1, %al
jne 0x380d6
jmp 0x38139
movb -0x8d1(%rbp), %al
movb %al, -0xd41(%rbp)
movl -0x7b0(%rbp), %eax
movl -0x8ec(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, -0xd40(%rbp)
leaq -0x8c8(%rbp), %rdi
callq 0x24600
movq -0xd40(%rbp), %rdi
movslq (%rax), %rsi
callq 0x69e0
movq %rax, -0xd38(%rbp)
jmp 0x3812a
movq -0xd38(%rbp), %rax
movb -0xd41(%rbp), %cl
movb %cl, (%rax)
jmp 0x3813b
movl -0x8ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8ec(%rbp)
jmp 0x38049
jmp 0x38151
leaq -0x8c8(%rbp), %rdi
callq 0x24620
jmp 0x37ef2
jmp 0x38164
jmp 0x38166
leaq -0x8a8(%rbp), %rdi
callq 0x6a08
jmp 0x37d52
leaq -0x798(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xa, %edx
callq 0x6340
jmp 0x3818f
leaq -0x888(%rbp), %rdi
callq 0xf720
leaq -0x858(%rbp), %rdi
callq 0x6a08
jmp 0x37c96
leaq -0x888(%rbp), %rdi
callq 0xf720
leaq -0x858(%rbp), %rdi
callq 0x6a08
jmp 0x389d6
movl $0x0, -0x904(%rbp)
movslq -0x904(%rbp), %rax
movq %rax, -0xd50(%rbp)
leaq -0x810(%rbp), %rdi
callq 0xf7f0
movq %rax, %rcx
movq -0xd50(%rbp), %rax
cmpq %rcx, %rax
jae 0x38919
movl $0x0, -0x908(%rbp)
movl $0x0, -0x90c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x1c1b0
movq %rax, -0x918(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x1c040
movq %rax, -0x920(%rbp)
leaq -0x918(%rbp), %rdi
leaq -0x920(%rbp), %rsi
callq 0x245c0
testb $0x1, %al
jne 0x38256
jmp 0x385f9
movl -0x908(%rbp), %eax
movl %eax, -0x90c(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x924(%rbp)
movl -0x924(%rbp), %eax
movl %eax, -0xd54(%rbp)
leaq -0x918(%rbp), %rdi
callq 0x24600
movq %rax, %rcx
movl -0xd54(%rbp), %eax
movl (%rcx), %ecx
movq -0x28(%rbp), %rdx
subl (%rdx), %ecx
cmpl %ecx, %eax
jge 0x385ce
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movl -0x908(%rbp), %eax
movl -0x924(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x69e0
movq %rax, -0xd60(%rbp)
jmp 0x382de
movq -0xd60(%rbp), %rax
movsbq (%rax), %rcx
leaq 0x412a0(%rip), %rax     # 0x79590
movsbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x385b8
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movl -0x908(%rbp), %eax
movl -0x924(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x69e0
movq %rax, -0xd68(%rbp)
jmp 0x3833c
movq -0xd68(%rbp), %rax
movsbl (%rax), %edi
callq 0x6400
cmpl $0x0, %eax
je 0x385b8
movq 0x10(%rbp), %rax
testb $0x1, (%rax)
jne 0x383ee
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movl -0x908(%rbp), %eax
movl -0x924(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x69e0
movq %rax, -0xd70(%rbp)
jmp 0x383a0
movq -0xd70(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0xd7c(%rbp)
movl -0x908(%rbp), %eax
movl -0x924(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x108(%rbp), %rdi
callq 0x69e0
movq %rax, -0xd78(%rbp)
jmp 0x383d6
movl -0xd7c(%rbp), %eax
movq -0xd78(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x385b8
movl -0x908(%rbp), %eax
movl -0x924(%rbp), %ecx
addl %ecx, %eax
movq -0x28(%rbp), %rcx
movl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x92c(%rbp)
leaq -0x92c(%rbp), %rdi
leaq -0x908(%rbp), %rsi
callq 0x39060
movq %rax, -0xd88(%rbp)
jmp 0x38426
movq -0xd88(%rbp), %rdi
leaq -0x90c(%rbp), %rsi
callq 0x39060
movq %rax, -0xd90(%rbp)
jmp 0x38442
movq -0xd90(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x928(%rbp)
movl -0x908(%rbp), %eax
movl -0x924(%rbp), %ecx
addl %ecx, %eax
movq -0x28(%rbp), %rcx
movl (%rcx), %edx
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %eax
movl %eax, -0x930(%rbp)
movl -0x908(%rbp), %eax
movl %eax, -0xd9c(%rbp)
leaq -0x918(%rbp), %rdi
callq 0x24600
movq %rax, %rcx
movl -0xd9c(%rbp), %eax
movl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x934(%rbp)
leaq -0x930(%rbp), %rdi
leaq -0x934(%rbp), %rsi
callq 0x24770
movq %rax, -0xd98(%rbp)
jmp 0x384ba
movq -0xd98(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x90c(%rbp)
movl -0x928(%rbp), %eax
movl %eax, -0x938(%rbp)
movl -0x938(%rbp), %eax
cmpl -0x90c(%rbp), %eax
jge 0x385b6
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movslq -0x938(%rbp), %rsi
callq 0x69e0
movq %rax, -0xda8(%rbp)
jmp 0x3851c
movq -0xda8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x385a0
movslq -0x938(%rbp), %rsi
leaq -0x108(%rbp), %rdi
callq 0x69e0
movq %rax, -0xdb0(%rbp)
jmp 0x38547
movq -0xdb0(%rbp), %rax
movsbl (%rax), %edi
callq 0x6a18
movb %al, -0xdb9(%rbp)
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movslq -0x938(%rbp), %rsi
callq 0x69e0
movq %rax, -0xdb8(%rbp)
jmp 0x38591
movq -0xdb8(%rbp), %rax
movb -0xdb9(%rbp), %cl
movb %cl, (%rax)
jmp 0x385a2
movl -0x938(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x938(%rbp)
jmp 0x384d5
jmp 0x385b8
jmp 0x385ba
movl -0x924(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x924(%rbp)
jmp 0x3826e
leaq -0x918(%rbp), %rdi
callq 0x24600
movl (%rax), %eax
addl -0x908(%rbp), %eax
movl %eax, -0x908(%rbp)
leaq -0x918(%rbp), %rdi
callq 0x24620
jmp 0x38227
movl -0xe8(%rbp), %eax
movl %eax, -0x93c(%rbp)
movl $0x0, -0x940(%rbp)
movl $0x0, -0x944(%rbp)
movl $0x0, -0x948(%rbp)
movl -0x948(%rbp), %eax
cmpl -0xe8(%rbp), %eax
jge 0x387fa
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movslq -0x948(%rbp), %rsi
callq 0x69e0
movq %rax, -0xdc8(%rbp)
jmp 0x3866a
movq -0xdc8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x38688
movl -0x93c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x93c(%rbp)
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movslq -0x948(%rbp), %rsi
callq 0x69e0
movq %rax, -0xdd0(%rbp)
jmp 0x386bd
movq -0xdd0(%rbp), %rax
movsbq (%rax), %rcx
leaq 0x40ec1(%rip), %rax     # 0x79590
movsbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x387e4
movslq -0x948(%rbp), %rsi
leaq -0x108(%rbp), %rdi
callq 0x69e0
movq %rax, -0xdd8(%rbp)
jmp 0x386f8
movq -0xdd8(%rbp), %rax
movsbq (%rax), %rcx
leaq 0x40e86(%rip), %rax     # 0x79590
movsbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x387e4
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movslq -0x948(%rbp), %rsi
callq 0x69e0
movq %rax, -0xde0(%rbp)
jmp 0x3874c
movq -0xde0(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0xdec(%rbp)
movslq -0x948(%rbp), %rsi
leaq -0x108(%rbp), %rdi
callq 0x69e0
movq %rax, -0xde8(%rbp)
jmp 0x38778
movl -0xdec(%rbp), %eax
movq -0xde8(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x387e4
movl -0x7b0(%rbp), %eax
movl -0x904(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq %rax, %rdi
movslq -0x948(%rbp), %rsi
callq 0x69e0
movq %rax, -0xdf8(%rbp)
jmp 0x387c1
movq -0xdf8(%rbp), %rax
movsbl (%rax), %edi
callq 0x6400
cmpl $0x0, %eax
je 0x387e4
movl -0x944(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x944(%rbp)
jmp 0x387e6
movl -0x948(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x948(%rbp)
jmp 0x38623
movslq -0x904(%rbp), %rsi
leaq -0x4c8(%rbp), %rdi
callq 0x1ab60
movq %rax, %rsi
movq 0x40791(%rip), %rdi     # 0x78fa8
callq 0x64d0
movq %rax, -0xe00(%rbp)
jmp 0x38825
movq -0xe00(%rbp), %rdi
leaq 0x20a9c(%rip), %rsi     # 0x592cf
callq 0x6520
movq %rax, -0xe08(%rbp)
jmp 0x38841
movq -0xe08(%rbp), %rdi
cvtsi2ssl -0x93c(%rbp), %xmm0
cvtsi2ssl -0xe8(%rbp), %xmm1
divss %xmm1, %xmm0
movss 0x20e14(%rip), %xmm1    # 0x59678
mulss %xmm1, %xmm0
callq 0x63f0
movq %rax, -0xe10(%rbp)
jmp 0x38876
movq -0xe10(%rbp), %rdi
leaq 0x21b7e(%rip), %rsi     # 0x5a402
callq 0x6520
movq %rax, -0xe18(%rbp)
jmp 0x38892
movq -0xe18(%rbp), %rdi
movl -0x944(%rbp), %esi
callq 0x68d0
movq %rax, -0xe20(%rbp)
jmp 0x388ad
movq -0xe20(%rbp), %rdi
leaq 0x21b65(%rip), %rsi     # 0x5a420
callq 0x6520
jmp 0x388c2
cvtsi2ssl -0xe8(%rbp), %xmm0
cvtsi2ssl -0x944(%rbp), %xmm1
movl -0x7f4(%rbp), %edi
callq 0xa9a0
movl %eax, -0xe24(%rbp)
jmp 0x388e5
movl -0xe24(%rbp), %eax
cmpl $0x0, %eax
je 0x38903
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x3897c
jmp 0x38905
movl -0x904(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x904(%rbp)
jmp 0x381d3
leaq -0x7c8(%rbp), %rdi
movq %rdi, -0xe30(%rbp)
callq 0xb670
movl %eax, %ecx
movl -0x7ac(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x7ac(%rbp)
leaq -0x810(%rbp), %rdi
callq 0xf7f0
movq -0xe30(%rbp), %rdi
movl %eax, %ecx
movl -0x7b0(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x7b0(%rbp)
callq 0x1aca0
leaq -0x798(%rbp), %rdi
callq 0x60f0
jmp 0x38972
movl $0x0, -0x3cc(%rbp)
movq -0x830(%rbp), %rax
movq %rax, %rsp
leaq -0x810(%rbp), %rdi
callq 0x1aa00
leaq -0x7f0(%rbp), %rdi
callq 0x6a08
movl -0x3cc(%rbp), %eax
movl %eax, -0xe34(%rbp)
testl %eax, %eax
je 0x389c0
jmp 0x389b0
movl -0xe34(%rbp), %eax
subl $0xc, %eax
je 0x389c2
jmp 0x38c8b
jmp 0x389c2
movl -0x7cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7cc(%rbp)
jmp 0x378c9
leaq -0x810(%rbp), %rdi
callq 0x1aa00
leaq -0x7f0(%rbp), %rdi
callq 0x6a08
jmp 0x38cd3
movq -0x18(%rbp), %rsi
leaq -0xb48(%rbp), %rdi
movl $0x10, %edx
callq 0x69b0
jmp 0x38a0a
movq -0xb48(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0xb48(%rbp,%rax), %rdi
callq 0x6030
movb %al, -0xe35(%rbp)
jmp 0x38a2a
movb -0xe35(%rbp), %al
testb $0x1, %al
jne 0x38a39
jmp 0x38af4
movq 0x405b0(%rip), %rdi     # 0x78ff0
movq 0x40549(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0xe40(%rbp)
jmp 0x38a55
movq -0xe40(%rbp), %rdi
leaq 0x209cd(%rip), %rsi     # 0x59430
callq 0x6520
movq %rax, -0xe48(%rbp)
jmp 0x38a71
movq -0xe48(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x64d0
movq %rax, -0xe50(%rbp)
jmp 0x38a8a
movq -0xe50(%rbp), %rdi
movq 0x404f8(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0xe58(%rbp)
jmp 0x38aa6
movq -0xe58(%rbp), %rdi
movq 0x404dc(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x38abb
movl $0x1, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
jmp 0x38c7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0xb48(%rbp), %rdi
callq 0x67d0
jmp 0x38cd3
movq 0x18(%rbp), %rax
testb $0x1, (%rax)
je 0x38b24
movl -0xe8(%rbp), %esi
leaq -0xb48(%rbp), %rdi
leaq -0x4c8(%rbp), %rdx
leaq -0x568(%rbp), %rcx
callq 0x36750
jmp 0x38b1f
jmp 0x38c47
movq 0x4047d(%rip), %rdi     # 0x78fa8
leaq 0x21912(%rip), %rsi     # 0x5a444
callq 0x6520
movq %rax, -0xe60(%rbp)
jmp 0x38b40
movq -0xe60(%rbp), %rdi
movq 0x40442(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x38b55
movl $0x0, -0xb4c(%rbp)
movslq -0xb4c(%rbp), %rax
movq %rax, -0xe68(%rbp)
leaq -0x4c8(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0xe68(%rbp), %rax
cmpq %rcx, %rax
jae 0x38c45
leaq 0x214f4(%rip), %rsi     # 0x5a087
leaq -0xb48(%rbp), %rdi
callq 0x6520
movq %rax, -0xe70(%rbp)
jmp 0x38ba8
movslq -0xb4c(%rbp), %rsi
leaq -0x4c8(%rbp), %rdi
callq 0x1ab60
movq -0xe70(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0xe78(%rbp)
jmp 0x38bd3
movq -0xe78(%rbp), %rdi
movq 0x403af(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0xe80(%rbp)
jmp 0x38bef
movslq -0xb4c(%rbp), %rsi
leaq -0x568(%rbp), %rdi
callq 0x1ab60
movq -0xe80(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0xe88(%rbp)
jmp 0x38c1a
movq -0xe88(%rbp), %rdi
movq 0x40368(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x38c2f
jmp 0x38c31
movl -0xb4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4c(%rbp)
jmp 0x38b5f
jmp 0x38c47
leaq -0xb48(%rbp), %rdi
callq 0x6740
jmp 0x38c55
movq -0x48(%rbp), %rax
movq %rax, -0xb58(%rbp)
movq -0xb58(%rbp), %rdi
callq 0xa8f0
jmp 0x38c6e
movl $0x0, -0x4(%rbp)
movl $0x1, -0x3cc(%rbp)
leaq -0xb48(%rbp), %rdi
callq 0x67d0
leaq -0x7c8(%rbp), %rdi
callq 0xfe90
movq -0x7a0(%rbp), %rax
movq %rax, %rsp
leaq -0x798(%rbp), %rdi
callq 0x6140
leaq -0x568(%rbp), %rdi
callq 0xfe90
leaq -0x4c8(%rbp), %rdi
callq 0xfe90
leaq -0x4a8(%rbp), %rdi
callq 0xf720
jmp 0x38d11
leaq -0x7c8(%rbp), %rdi
callq 0xfe90
leaq -0x798(%rbp), %rdi
callq 0x6140
leaq -0x568(%rbp), %rdi
callq 0xfe90
leaq -0x4c8(%rbp), %rdi
callq 0xfe90
leaq -0x4a8(%rbp), %rdi
callq 0xf720
jmp 0x38d1f
leaq -0x480(%rbp), %rdi
callq 0xfe90
jmp 0x38d2d
leaq -0x480(%rbp), %rdi
callq 0xfe90
jmp 0x38d7a
leaq -0x3c8(%rbp), %rdi
callq 0x9480
leaq -0x128(%rbp), %rdi
callq 0x1aa00
leaq -0x108(%rbp), %rdi
callq 0x6a08
leaq -0xd8(%rbp), %rdi
callq 0x6a08
leaq -0xb0(%rbp), %rdi
callq 0x390a0
leaq -0x80(%rbp), %rdi
callq 0x2e790
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
leaq -0x3c8(%rbp), %rdi
callq 0x9480
leaq -0x128(%rbp), %rdi
callq 0x1aa00
leaq -0x108(%rbp), %rdi
callq 0x6a08
leaq -0xd8(%rbp), %rdi
callq 0x6a08
leaq -0xb0(%rbp), %rdi
callq 0x390a0
leaq -0x80(%rbp), %rdi
callq 0x2e790
movq -0xe0(%rbp), %rdi
callq 0x6900
nopl (%rax,%rax)