// File: simonrharris[P]SKA/src/sk_align.cpp
// Function: alignKmers(float 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&, 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&)
int alignKmers(const float & minproportion, const std::string & outputprefix, const std::vector < std::string > & kmerfiles, const bool & variantonly, const bool & printkmers, const std::vector < std::string > & sample)
{

	const std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();//start the clock

	int numfiles=kmerfiles.size();//record the number of files

	std::vector < std::string > sampleNames;
	if (collectSampleNames(kmerfiles, sampleNames)!=0){return 1;}//get the total number of samples in all input files

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

	int numSamples = std::count(include.begin(), include.end(), true);//count the number of included samples

	std::cout << numSamples << " samples will be included in the alignment" << std::endl;
	
	float maxmissing=round((1.0-minproportion)*numSamples);//calculate the maximum number of samples that can be missing for the site to be included in the alignment

	float minrequired=numSamples-maxmissing;//calculate the minimum number of samples that must contain a kmer for the site to be included in the alignment
	
	std::cout << "Keeping variants for which at least " << int(minrequired) << " samples include kmer matches" << std::endl << std::endl;
	
	// Create the kmer map
	std::unordered_map < std::string, std::string > kmerMap;
	int oldkmersize=0;
	int sampleNum=0;
	int includedSampleNum=0;
	char base;
	int kmersize;

	std::ifstream fileStream;
	for (int s = 0; s < kmerfiles.size(); ++s){//read each file and make a map of the kmers which stores the bases for each included sample
		
		if (openFileStream(kmerfiles[s], fileStream)){return 1;};

		
		std::vector < std::string > names;
		
		readKmerHeader(fileStream, kmersize, names);//read the header from the kmer file to get the kmer size and sample names
		
		if (s==0){ //If it's the first file, set the oldkmersize
			oldkmersize=kmersize;
		}
		else if (kmersize!=oldkmersize){ //if the file kmer size isn't the same as the other files then ditch out
			std::cerr << "kmer files have different kmer sizes" << 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);
			}
		}

		int fileIncludeSize=fileInclude.size();

		if (fileIncludeSize==0){ // if no sample names in the file are going to be included then don't read the file
			fileStream.close();
			sampleNum+=int(names.size());
			names.clear();
			continue;
		}

		char kmerbuffer[kmersize*2/3];
		char asciibuffer[int(ceil(float(names.size())/6))];

		while (fileStream.read(asciibuffer, sizeof(asciibuffer))){//read the next ascii bitstring
			std::string asciibits (asciibuffer, sizeof(asciibuffer));
			std::vector < bool > mybits;
			vectorbool_from_ascii(asciibits, mybits);//convert the ascii representation of the taxa to a vector of bools

			while (fileStream.peek()!='\n' && fileStream.get(base)){
				fileStream.read(kmerbuffer, sizeof(kmerbuffer));
				std::string kmer (kmerbuffer, kmersize*2/3);
				
				addKmerToStringMap(kmerMap, kmer, base, mybits, fileInclude, includedSampleNum, numSamples, maxmissing);
				
	    	}
	    	fileStream.ignore(256,'\n');//skip the end ofline character
	    }
	    sampleNum+=int(names.size()); //add the number of samples in the file to the count of total samples
	    includedSampleNum+=fileIncludeSize;
		fileStream.close();
	}
	
	std::cout << kmerMap.size() << " kmers identified from " << numSamples << " samples in " << numfiles << " files" << std::endl;
	
	std::vector < int > constantBases (4,0);
	
	float filteredsites=0;
	float variantsites=0;

	filterAlignment(kmerMap, constantBases, numSamples, minrequired, variantonly, filteredsites, variantsites);

	if(calculateMissedSNPs(filteredsites, variantsites, kmersize)){return 1;};
	
	printAlignment(outputprefix+".aln", kmerMap, constantBases, includedSampleNames, variantonly);

	if (printkmers){

		std::cout << "Printing aligned split kmers" << std::endl;

		std::unordered_map < std::vector < bool >,  std::vector < std::string > > revKmerMap;

		reverseStringKmerMap(kmerMap, revKmerMap);//reverse the map so that we have a new map of kmers for each combination of samples

		std::cout << revKmerMap.size() << " unique taxon combinations in map" << std::endl;
		
		if(printMergedKmerFile(revKmerMap, outputprefix+".skf", includedSampleNames, kmersize)){return 1;}
	}

	printDuration(start);
	
	return 0;
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x740, %rsp            # imm = 0x740
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
callq 0x6080
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0xb670
movl %eax, -0x44(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
callq 0x1ab40
movq -0x5a8(%rbp), %rsi
movq -0x20(%rbp), %rdi
movl $0x1, %edx
callq 0xced0
movl %eax, -0x59c(%rbp)
jmp 0x198b5
movl -0x59c(%rbp), %eax
cmpl $0x0, %eax
je 0x198e4
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x1a8cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a8dc
leaq -0x60(%rbp), %rdi
callq 0xb670
movq %rax, -0x5b8(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x5b0(%rbp)
callq 0xf380
movq -0x5b8(%rbp), %rsi
movq -0x5b0(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0xf3a0
jmp 0x19923
leaq -0x99(%rbp), %rdi
callq 0xf3e0
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0xd240
jmp 0x19945
leaq -0xb8(%rbp), %rdi
callq 0x1ab40
leaq -0x98(%rbp), %rdi
callq 0xf580
movl %edx, -0xd0(%rbp)
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0xd0(%rbp), %eax
movl %eax, -0xc0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xf5c0
movl %edx, -0xf0(%rbp)
movq %rax, -0xf8(%rbp)
movl -0xf0(%rbp), %eax
movl %eax, -0xe0(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xf1c0
movb %al, -0x5b9(%rbp)
jmp 0x199d2
movb -0x5b9(%rbp), %al
testb $0x1, %al
jne 0x199e1
jmp 0x19b0e
leaq -0xc8(%rbp), %rdi
callq 0xf5e0
movq %rdx, -0x5d0(%rbp)
movq %rax, -0x5c8(%rbp)
jmp 0x199fd
movq -0x5d0(%rbp), %rax
movq -0x5c8(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xf510
testb $0x1, %al
jne 0x19a2e
jmp 0x19af9
leaq -0x98(%rbp), %rdi
callq 0xf580
movl %edx, -0x120(%rbp)
movq %rax, -0x128(%rbp)
movl -0x120(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x118(%rbp)
movups -0xc8(%rbp), %xmm0
movaps %xmm0, -0x140(%rbp)
movq -0x118(%rbp), %rdi
movl -0x110(%rbp), %esi
movq -0x140(%rbp), %rdx
movl -0x138(%rbp), %ecx
callq 0xf670
movq %rax, -0x5d8(%rbp)
jmp 0x19a97
movq -0x5d8(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x1ab60
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0xabd0
jmp 0x19ab8
jmp 0x19af9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x99(%rbp), %rdi
callq 0xf3e0
jmp 0x1a8dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a8bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a8b1
jmp 0x19afb
leaq -0xc8(%rbp), %rdi
callq 0xf6f0
jmp 0x19b09
jmp 0x19984
leaq -0x98(%rbp), %rdi
movq %rdi, -0x5e8(%rbp)
callq 0xf580
movq -0x5e8(%rbp), %rdi
movl %edx, -0x160(%rbp)
movq %rax, -0x168(%rbp)
movl -0x160(%rbp), %eax
movl %eax, -0x150(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x158(%rbp)
callq 0xf5c0
movl %edx, -0x180(%rbp)
movq %rax, -0x188(%rbp)
movl -0x180(%rbp), %eax
movl %eax, -0x170(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x178(%rbp)
movb $0x1, -0x189(%rbp)
movq -0x158(%rbp), %rdi
movl -0x150(%rbp), %esi
movq -0x178(%rbp), %rdx
movl -0x170(%rbp), %ecx
leaq -0x189(%rbp), %r8
callq 0x1ab80
movq %rax, -0x5e0(%rbp)
jmp 0x19bb1
movq -0x5e0(%rbp), %rax
movl %eax, -0x144(%rbp)
movl -0x144(%rbp), %esi
movq 0x5f3dd(%rip), %rdi     # 0x78fa8
callq 0x68d0
movq %rax, -0x5f0(%rbp)
jmp 0x19bd9
movq -0x5f0(%rbp), %rdi
leaq 0x3fb18(%rip), %rsi     # 0x596ff
callq 0x6520
movq %rax, -0x5f8(%rbp)
jmp 0x19bf5
movq -0x5f8(%rbp), %rdi
movq 0x5f38d(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x19c0a
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3f64a(%rip), %xmm0    # 0x59268
subsd %xmm1, %xmm0
cvtsi2sdl -0x144(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x6220
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x190(%rbp)
cvtsi2ssl -0x144(%rbp), %xmm0
movss -0x190(%rbp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0x194(%rbp)
movq 0x5f346(%rip), %rdi     # 0x78fa8
leaq 0x3fac1(%rip), %rsi     # 0x5972a
callq 0x6520
movq %rax, -0x600(%rbp)
jmp 0x19c77
movq -0x600(%rbp), %rdi
cvttss2si -0x194(%rbp), %esi
callq 0x68d0
movq %rax, -0x608(%rbp)
jmp 0x19c94
movq -0x608(%rbp), %rdi
leaq 0x3faad(%rip), %rsi     # 0x5974f
callq 0x6520
movq %rax, -0x610(%rbp)
jmp 0x19cb0
movq -0x610(%rbp), %rdi
movq 0x5f2d2(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x618(%rbp)
jmp 0x19ccc
movq -0x618(%rbp), %rdi
movq 0x5f2b6(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x19ce1
leaq -0x1d0(%rbp), %rdi
callq 0x1abf0
movl $0x0, -0x1d4(%rbp)
movl $0x0, -0x1d8(%rbp)
movl $0x0, -0x1dc(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x65f0
jmp 0x19d19
movl $0x0, -0x3f4(%rbp)
movslq -0x3f4(%rbp), %rax
movq %rax, -0x620(%rbp)
movq -0x20(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0x620(%rbp), %rax
cmpq %rcx, %rax
jae 0x1a429
movq -0x20(%rbp), %rdi
movslq -0x3f4(%rbp), %rsi
callq 0xf2d0
movq %rax, %rdi
leaq -0x3f0(%rbp), %rsi
movl $0x1, %edx
callq 0xa4f0
movl %eax, -0x624(%rbp)
jmp 0x19d79
movl -0x624(%rbp), %eax
cmpl $0x0, %eax
je 0x19db9
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x1a867
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a8a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a899
leaq -0x410(%rbp), %rdi
movq %rdi, -0x630(%rbp)
callq 0x1ab40
movq -0x630(%rbp), %rdx
leaq -0x3f0(%rbp), %rdi
leaq -0x1e4(%rbp), %rsi
callq 0xcd40
jmp 0x19de8
cmpl $0x0, -0x3f4(%rbp)
jne 0x19e13
movl -0x1e4(%rbp), %eax
movl %eax, -0x1d4(%rbp)
jmp 0x19e83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a418
movl -0x1e4(%rbp), %eax
cmpl -0x1d4(%rbp), %eax
je 0x19e81
movq 0x5f1c8(%rip), %rdi     # 0x78ff0
leaq 0x3f65c(%rip), %rsi     # 0x5948b
callq 0x6520
movq %rax, -0x638(%rbp)
jmp 0x19e3d
movq -0x638(%rbp), %rdi
movq 0x5f145(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x640(%rbp)
jmp 0x19e59
movq -0x640(%rbp), %rdi
movq 0x5f129(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x19e6e
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x1a3cb
jmp 0x19e83
leaq -0x428(%rbp), %rdi
callq 0x1ac10
movl $0x0, -0x42c(%rbp)
movslq -0x42c(%rbp), %rax
movq %rax, -0x648(%rbp)
leaq -0x410(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0x648(%rbp), %rax
cmpq %rcx, %rax
jae 0x19f5f
movl -0x1d8(%rbp), %eax
movl -0x42c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x98(%rbp), %rdi
callq 0xedc0
movq %rdx, -0x658(%rbp)
movq %rax, -0x650(%rbp)
jmp 0x19ef3
movq -0x658(%rbp), %rax
movq -0x650(%rbp), %rcx
movq %rcx, -0x440(%rbp)
movq %rax, -0x438(%rbp)
leaq -0x440(%rbp), %rdi
callq 0xf510
testb $0x1, %al
jne 0x19f21
jmp 0x19f49
leaq -0x428(%rbp), %rdi
leaq -0x42c(%rbp), %rsi
callq 0x1ac30
jmp 0x19f36
jmp 0x19f49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a40c
jmp 0x19f4b
movl -0x42c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42c(%rbp)
jmp 0x19e99
leaq -0x428(%rbp), %rdi
callq 0xf7f0
movl %eax, -0x444(%rbp)
cmpl $0x0, -0x444(%rbp)
jne 0x19fb8
leaq -0x3f0(%rbp), %rdi
callq 0x60f0
jmp 0x19f88
leaq -0x410(%rbp), %rdi
callq 0xb670
addl -0x1d8(%rbp), %eax
movl %eax, -0x1d8(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x1aca0
movl $0x7, -0x70(%rbp)
jmp 0x1a3bf
movl -0x1e4(%rbp), %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, -0x670(%rbp)
movq %rsp, %rcx
movq %rcx, -0x450(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x668(%rbp)
movq %rcx, %rsp
movq %rax, -0x458(%rbp)
leaq -0x410(%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, -0x660(%rbp)
testq %rax, %rax
movss %xmm0, -0x65c(%rbp)
js 0x1a056
movss -0x660(%rbp), %xmm0
movss %xmm0, -0x65c(%rbp)
movss -0x65c(%rbp), %xmm0
movss 0x3f616(%rip), %xmm1    # 0x5967c
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x60b0
cvttsd2si %xmm0, %eax
movq %rax, -0x680(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x678(%rbp)
movq %rcx, %rsp
movq %rax, -0x460(%rbp)
movq -0x680(%rbp), %rdx
movq -0x678(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x6680
movq %rax, -0x688(%rbp)
jmp 0x1a0c3
movq -0x688(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, -0x689(%rbp)
jmp 0x1a0e1
movb -0x689(%rbp), %al
testb $0x1, %al
jne 0x1a0f0
jmp 0x1a370
leaq -0x481(%rbp), %rdi
movq %rdi, -0x698(%rbp)
callq 0x6910
movq -0x678(%rbp), %rsi
movq -0x680(%rbp), %rdx
movq -0x698(%rbp), %rcx
leaq -0x480(%rbp), %rdi
callq 0x65e0
jmp 0x1a126
leaq -0x481(%rbp), %rdi
callq 0x65a0
leaq -0x4b0(%rbp), %rdi
movq %rdi, -0x6a0(%rbp)
callq 0x1acc0
movq -0x6a0(%rbp), %rsi
leaq -0x480(%rbp), %rdi
callq 0xbd50
jmp 0x1a15a
jmp 0x1a15c
leaq -0x3f0(%rbp), %rdi
callq 0x61c0
movl %eax, -0x6a4(%rbp)
jmp 0x1a170
movl -0x6a4(%rbp), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x6a5(%rbp)
je 0x1a1cb
leaq -0x3f0(%rbp), %rdi
leaq -0x1dd(%rbp), %rsi
callq 0x6720
movq %rax, -0x6b0(%rbp)
jmp 0x1a19f
movq -0x6b0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, -0x6b1(%rbp)
jmp 0x1a1bd
movb -0x6b1(%rbp), %al
movb %al, -0x6a5(%rbp)
jmp 0x1a1cb
movb -0x6a5(%rbp), %al
testb $0x1, %al
jne 0x1a1da
jmp 0x1a31e
movq -0x670(%rbp), %rdx
movq -0x668(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x6680
jmp 0x1a1f6
movl -0x1e4(%rbp), %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, -0x6c8(%rbp)
leaq -0x4d1(%rbp), %rdi
movq %rdi, -0x6c0(%rbp)
callq 0x6910
movq -0x668(%rbp), %rsi
movq -0x6c8(%rbp), %rdx
movq -0x6c0(%rbp), %rcx
leaq -0x4d0(%rbp), %rdi
callq 0x65e0
jmp 0x1a253
leaq -0x4d1(%rbp), %rdi
callq 0x65a0
movsbl -0x1dd(%rbp), %edx
movl -0x1dc(%rbp), %r9d
movl -0x144(%rbp), %ecx
cvttss2si -0x190(%rbp), %esi
subq $0x10, %rsp
movq %rsp, %rax
movl %esi, 0x8(%rax)
movl %ecx, (%rax)
leaq -0x1d0(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
leaq -0x4b0(%rbp), %rcx
leaq -0x428(%rbp), %r8
callq 0xda00
addq $0x10, %rsp
jmp 0x1a2ae
leaq -0x4d0(%rbp), %rdi
callq 0x6a08
jmp 0x1a15c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x481(%rbp), %rdi
callq 0x65a0
jmp 0x1a40c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x4d1(%rbp), %rdi
callq 0x65a0
jmp 0x1a353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x6a08
jmp 0x1a353
leaq -0x3f0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xa, %edx
callq 0x6340
jmp 0x1a336
leaq -0x4b0(%rbp), %rdi
callq 0xf720
leaq -0x480(%rbp), %rdi
callq 0x6a08
jmp 0x1a0a0
leaq -0x4b0(%rbp), %rdi
callq 0xf720
leaq -0x480(%rbp), %rdi
callq 0x6a08
jmp 0x1a40c
leaq -0x410(%rbp), %rdi
callq 0xb670
movl %eax, %ecx
movl -0x1d8(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x1d8(%rbp)
movl -0x444(%rbp), %ecx
movl -0x1dc(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x1dc(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x60f0
jmp 0x1a3ae
movq -0x450(%rbp), %rax
movq %rax, %rsp
movl $0x0, -0x70(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x1aa00
leaq -0x410(%rbp), %rdi
callq 0xfe90
movl -0x70(%rbp), %eax
movl %eax, -0x6cc(%rbp)
testl %eax, %eax
je 0x1a3f6
jmp 0x1a3e6
movl -0x6cc(%rbp), %eax
subl $0x7, %eax
je 0x1a3f8
jmp 0x1a867
jmp 0x1a3f8
movl -0x3f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3f4(%rbp)
jmp 0x19d23
leaq -0x428(%rbp), %rdi
callq 0x1aa00
leaq -0x410(%rbp), %rdi
callq 0xfe90
jmp 0x1a899
leaq -0x1d0(%rbp), %rdi
callq 0x1aa60
movq %rax, %rsi
movq 0x5eb69(%rip), %rdi     # 0x78fa8
callq 0x6120
movq %rax, -0x6d8(%rbp)
jmp 0x1a44d
movq -0x6d8(%rbp), %rdi
leaq 0x3f312(%rip), %rsi     # 0x5976d
callq 0x6520
movq %rax, -0x6e0(%rbp)
jmp 0x1a469
movq -0x6e0(%rbp), %rdi
movl -0x144(%rbp), %esi
callq 0x68d0
movq %rax, -0x6e8(%rbp)
jmp 0x1a484
movq -0x6e8(%rbp), %rdi
leaq 0x3f01e(%rip), %rsi     # 0x594b0
callq 0x6520
movq %rax, -0x6f0(%rbp)
jmp 0x1a4a0
movq -0x6f0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x68d0
movq %rax, -0x6f8(%rbp)
jmp 0x1a4b8
movq -0x6f8(%rbp), %rdi
leaq 0x405f3(%rip), %rsi     # 0x5aab9
callq 0x6520
movq %rax, -0x700(%rbp)
jmp 0x1a4d4
movq -0x700(%rbp), %rdi
movq 0x5eaae(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x1a4e9
movl $0x0, -0x4f4(%rbp)
leaq -0x4f5(%rbp), %rdi
movq %rdi, -0x708(%rbp)
callq 0x1a8f0
movq -0x708(%rbp), %rcx
leaq -0x4f0(%rbp), %rdi
movl $0x4, %esi
leaq -0x4f4(%rbp), %rdx
callq 0x1a910
jmp 0x1a527
leaq -0x4f5(%rbp), %rdi
callq 0x1a990
movl $0x0, -0x4fc(%rbp)
movl $0x0, -0x500(%rbp)
movl -0x144(%rbp), %edx
cvttss2si -0x194(%rbp), %ecx
movq -0x28(%rbp), %rax
movzbl (%rax), %r8d
subq $0x10, %rsp
movq %rsp, %rax
leaq -0x500(%rbp), %rsi
movq %rsi, (%rax)
andl $0x1, %r8d
leaq -0x1d0(%rbp), %rdi
leaq -0x4f0(%rbp), %rsi
leaq -0x4fc(%rbp), %r9
callq 0x18f30
addq $0x10, %rsp
jmp 0x1a592
movss -0x4fc(%rbp), %xmm0
movss -0x500(%rbp), %xmm1
movl -0x1e4(%rbp), %edi
callq 0xa9a0
movl %eax, -0x70c(%rbp)
jmp 0x1a5b5
movl -0x70c(%rbp), %eax
cmpl $0x0, %eax
je 0x1a601
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x1a84b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x4f5(%rbp), %rdi
callq 0x1a990
jmp 0x1a899
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a859
movq -0x18(%rbp), %rsi
leaq 0x3f179(%rip), %rdx     # 0x59785
leaq -0x520(%rbp), %rdi
callq 0x1ace0
jmp 0x1a61a
leaq -0x538(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x1ad60
jmp 0x1a62f
movq -0x28(%rbp), %rax
movzbl (%rax), %r8d
andl $0x1, %r8d
leaq -0x520(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
leaq -0x4f0(%rbp), %rdx
leaq -0x538(%rbp), %rcx
callq 0x191f0
jmp 0x1a65e
leaq -0x538(%rbp), %rdi
callq 0xfe90
leaq -0x520(%rbp), %rdi
callq 0x6a08
movq -0x30(%rbp), %rax
testb $0x1, (%rax)
je 0x1a824
movq 0x5e91e(%rip), %rdi     # 0x78fa8
leaq 0x3f0f9(%rip), %rsi     # 0x5978a
callq 0x6520
movq %rax, -0x718(%rbp)
jmp 0x1a69f
movq -0x718(%rbp), %rdi
movq 0x5e8e3(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x1a6b4
leaq -0x570(%rbp), %rdi
movq %rdi, -0x720(%rbp)
callq 0x1ae50
movq -0x720(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0xe6e0
jmp 0x1a6dc
leaq -0x570(%rbp), %rdi
callq 0x1ae70
movq %rax, %rsi
movq 0x5e8b6(%rip), %rdi     # 0x78fa8
callq 0x6120
movq %rax, -0x728(%rbp)
jmp 0x1a700
movq -0x728(%rbp), %rdi
leaq 0x3f099(%rip), %rsi     # 0x597a7
callq 0x6520
movq %rax, -0x730(%rbp)
jmp 0x1a71c
movq -0x730(%rbp), %rdi
movq 0x5e866(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x1a731
movq -0x18(%rbp), %rsi
leaq 0x415da(%rip), %rdx     # 0x5bd16
leaq -0x590(%rbp), %rdi
callq 0x1ace0
jmp 0x1a74a
movl -0x1e4(%rbp), %ecx
leaq -0x570(%rbp), %rdi
leaq -0x590(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0xc810
movl %eax, -0x734(%rbp)
jmp 0x1a772
leaq -0x590(%rbp), %rdi
callq 0x6a08
movl -0x734(%rbp), %eax
cmpl $0x0, %eax
je 0x1a7f8
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x1a7ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a7bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x538(%rbp), %rdi
callq 0xfe90
leaq -0x520(%rbp), %rdi
callq 0x6a08
jmp 0x1a859
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1a816
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x590(%rbp), %rdi
callq 0x6a08
jmp 0x1a816
movl $0x0, -0x70(%rbp)
leaq -0x570(%rbp), %rdi
callq 0x1ae90
movl -0x70(%rbp), %eax
testl %eax, %eax
jne 0x1a84b
jmp 0x1a814
jmp 0x1a824
leaq -0x570(%rbp), %rdi
callq 0x1ae90
jmp 0x1a859
movq -0x40(%rbp), %rax
movq %rax, -0x598(%rbp)
movq -0x598(%rbp), %rdi
callq 0xa8f0
jmp 0x1a83d
movl $0x0, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x1aa00
jmp 0x1a867
leaq -0x4f0(%rbp), %rdi
callq 0x1aa00
jmp 0x1a899
leaq -0x3f0(%rbp), %rdi
callq 0x6140
leaq -0x1d0(%rbp), %rdi
callq 0x1aeb0
leaq -0xb8(%rbp), %rdi
callq 0xfe90
leaq -0x98(%rbp), %rdi
callq 0xf720
jmp 0x1a8cb
leaq -0x3f0(%rbp), %rdi
callq 0x6140
leaq -0x1d0(%rbp), %rdi
callq 0x1aeb0
leaq -0xb8(%rbp), %rdi
callq 0xfe90
leaq -0x98(%rbp), %rdi
callq 0xf720
jmp 0x1a8dc
leaq -0x60(%rbp), %rdi
callq 0xfe90
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0xfe90
movq -0x68(%rbp), %rdi
callq 0x6900
nop