// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %r9, %r14
movq %r8, -0x1e0(%rbp)
movq %rcx, -0x1e8(%rbp)
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
callq 0x5060
movq %rax, %r12
movq 0x8(%r13), %rax
subq (%r13), %rax
movq %rax, -0x1f0(%rbp)
xorpd %xmm0, %xmm0
leaq -0x1d0(%rbp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, -0x34(%rbp)
movq %r13, -0x100(%rbp)
movq %r13, %rdi
movl $0x1, %edx
callq 0x9851
testl %eax, %eax
jne 0xda7e
movq -0x1c8(%rbp), %rsi
subq -0x1d0(%rbp), %rsi
sarq $0x5, %rsi
leaq -0x468(%rbp), %rdx
movb $0x0, (%rdx)
leaq -0x130(%rbp), %rdi
leaq -0x260(%rbp), %rcx
callq 0xabec
movq %r15, -0xf8(%rbp)
leaq -0x1d0(%rbp), %rsi
leaq -0x130(%rbp), %rdx
movq %r14, %rdi
callq 0x9b39
xorpd %xmm0, %xmm0
movapd %xmm0, -0x1b0(%rbp)
movq $0x0, -0x1a0(%rbp)
movq -0x130(%rbp), %r15
movq -0x120(%rbp), %rax
movl -0x118(%rbp), %ecx
cmpq %rax, %r15
setne %dl
testl %ecx, %ecx
setne %sil
orb %dl, %sil
movq $0x0, -0x40(%rbp)
cmpb $0x1, %sil
movq %r12, -0x1d8(%rbp)
jne 0xd032
xorl %r12d, %r12d
leaq -0x1b0(%rbp), %r14
xorl %edx, %edx
movl %edx, %r13d
movq (%r15), %rsi
btq %rdx, %rsi
jae 0xd00a
movq %r15, %rax
subq -0x130(%rbp), %rax
shlq $0x8, %rax
addq -0x1d0(%rbp), %rax
movq %r13, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %r14, %rdi
callq 0x8528
movq -0x120(%rbp), %rax
movl -0x118(%rbp), %ecx
leal 0x1(%r13), %edx
xorl %esi, %esi
cmpq $0x3f, %r13
sete %sil
leaq (%r15,%rsi,8), %r15
cmovel %r12d, %edx
cmpq %rax, %r15
jne 0xcfca
cmpl %ecx, %edx
jne 0xcfca
movq -0x130(%rbp), %r15
jmp 0xd037
movq %r15, %rax
xorl %ecx, %ecx
cmpq %rax, %r15
jne 0xd040
testl %ecx, %ecx
je 0xd074
xorl %edx, %edx
movq $0x0, -0x40(%rbp)
xorl %esi, %esi
movq (%r15), %rdi
btq %rsi, %rdi
adcq $0x0, -0x40(%rbp)
xorl %edi, %edi
cmpl $0x3f, %esi
leal 0x1(%rsi), %esi
sete %dil
leaq (%r15,%rdi,8), %r15
cmovel %edx, %esi
cmpq %rax, %r15
jne 0xd04c
cmpl %ecx, %esi
jne 0xd04c
movq 0x33f45(%rip), %rdi     # 0x40fc0
movq -0x40(%rbp), %rsi
callq 0x5690
movq %rax, %r14
leaq 0x2666d(%rip), %rsi     # 0x336fb
movl $0x2a, %edx
movq %rax, %rdi
callq 0x5420
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
xorps %xmm0, %xmm0
cvtss2sd (%rbx), %xmm0
movsd 0x26197(%rip), %xmm1    # 0x33268
subsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl -0x40(%rbp), %xmm0
mulsd %xmm1, %xmm0
callq 0x5170
movsd %xmm0, -0x50(%rbp)
movq 0x33ece(%rip), %rdi     # 0x40fc0
leaq 0x2662d(%rip), %rsi     # 0x33726
movl $0x24, %edx
callq 0x5420
xorps %xmm1, %xmm1
cvtsd2ss -0x50(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2ssl -0x40(%rbp), %xmm0
movss %xmm1, -0x50(%rbp)
subss %xmm1, %xmm0
cvttss2si %xmm0, %esi
movq 0x33e99(%rip), %rdi     # 0x40fc0
movl %esi, -0xec(%rbp)
callq 0x5690
movq %rax, %rbx
leaq 0x2660f(%rip), %rsi     # 0x3374b
movl $0x1d, %edx
movq %rax, %rdi
callq 0x5420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq -0x230(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq -0x468(%rbp), %rdi
callq 0x5410
movq -0x100(%rbp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0xd6f3
movabsq $-0x8000000000000000, %r13 # imm = 0x8000000000000000
cvttss2si -0x50(%rbp), %ecx
movq %rcx, -0x210(%rbp)
leaq -0x468(%rbp), %r12
leaq -0x70(%rbp), %r15
leaq -0xd8(%rbp), %rbx
leaq -0x29(%rbp), %r14
xorl %edi, %edi
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x50(%rbp)
movq $0x0, -0xe8(%rbp)
movq %rdi, -0x108(%rbp)
shlq $0x5, %rdi
addq %rax, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x7f3f
movl $0x1, -0x34(%rbp)
testl %eax, %eax
jne 0xda3f
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
movq %r15, %rdx
callq 0x9684
movl -0x30(%rbp), %eax
cmpq $0x0, -0x108(%rbp)
je 0xd285
cmpl -0x7c(%rbp), %eax
je 0xd288
jmp 0xda9c
movl %eax, -0x7c(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movq $0x0, -0x90(%rbp)
movl $0x0, -0xd8(%rbp)
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq %rax, %rcx
je 0xd3c6
xorl %edx, %edx
movq -0xe8(%rbp), %rdi
leal (%rdx,%rdi), %esi
movslq %esi, %rsi
addl %edx, %edi
addl $0x3f, %edi
testl %esi, %esi
cmovnsl %esi, %edi
sarl $0x6, %edi
movslq %edi, %rdi
shlq $0x3, %rdi
addq -0x130(%rbp), %rdi
leaq 0x3f(%r13), %r8
andq %rsi, %r8
xorl %r9d, %r9d
cmpq %r13, %r8
setbe %r9b
movq -0x8(%rdi,%r9,8), %rdi
btq %rsi, %rdi
jae 0xd334
movq -0x98(%rbp), %rsi
cmpq -0x90(%rbp), %rsi
je 0xd31d
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x98(%rbp)
jmp 0xd334
leaq -0xa0(%rbp), %rdi
movq %rbx, %rdx
callq 0xdeae
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0xd8(%rbp), %rdx
incq %rdx
movl %edx, -0xd8(%rbp)
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x5, %rsi
cmpq %rdx, %rsi
ja 0xd2ba
movq -0x98(%rbp), %rax
subq -0xa0(%rbp), %rax
shrq $0x2, %rax
testl %eax, %eax
je 0xd3c6
movq %rax, -0x200(%rbp)
movq %rsp, -0x1f8(%rbp)
movl -0x30(%rbp), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rax
shrq $0x3f, %rax
shrq $0x20, %rcx
addl %eax, %ecx
movq %rcx, -0x48(%rbp)
leaq 0xf(%rcx), %rax
andq $-0x10, %rax
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
movq -0x68(%rbp), %rax
subq -0x70(%rbp), %rax
sarq $0x5, %rax
js 0xd435
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xd44a
movq %r12, %rdi
callq 0x50b0
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %r15
movq %r15, -0x48(%rbp)
movl $0x7, -0x78(%rbp)
subq %rax, %r15
je 0xd678
movq %rax, -0xe0(%rbp)
leaq 0x10(%rax), %r13
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0xd40a
movq (%r13), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%r13), %rax
addq $0x10, %r13
cmpq -0x48(%rbp), %r13
movq %rax, %r13
jne 0xd3f5
movq -0xe0(%rbp), %rax
movq %rax, -0x68(%rbp)
movabsq $-0x8000000000000000, %r13 # imm = 0x8000000000000000
jmp 0xd678
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x2622e(%rip), %xmm0    # 0x33680
callq 0x51e0
cvttss2si %xmm0, %ecx
leaq 0xf(%rcx), %rax
andq $-0x10, %rax
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, %rsp
movq %rcx, -0xe0(%rbp)
movq %rdx, -0x78(%rbp)
leaq (%rdx,%rcx), %rax
movq %rax, -0x208(%rbp)
movq %r12, %rdi
movq -0x78(%rbp), %rsi
movq -0xe0(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xd63e
movq %r12, %r15
movq %r14, %r12
movq %rbx, %r14
leaq -0x160(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x170(%rbp), %rbx
movq %rbx, %rdi
movq -0x78(%rbp), %rsi
movq -0x208(%rbp), %rdx
callq 0x85fc
xorl %eax, %eax
movq %rax, -0xd8(%rbp)
movl %eax, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
movl %eax, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
movq %rbx, %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x8993
movq %r12, %r14
movq %r15, %r12
leaq -0x150(%rbp), %r15
movq %r12, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0xd5e6
movq %r12, %rdi
movq %r14, %rsi
callq 0x5500
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xd5e6
movq %r12, %rdi
movq %r13, %rsi
movq -0x48(%rbp), %rdx
callq 0x5480
movl -0x30(%rbp), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
movslq %eax, %rdx
leaq -0x140(%rbp), %rax
movq %rax, -0x150(%rbp)
addq %r13, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x85fc
movsbl -0x29(%rbp), %edx
leaq -0x260(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rcx
leaq -0xa0(%rbp), %r8
movl -0x50(%rbp), %r9d
pushq -0x210(%rbp)
pushq -0x40(%rbp)
callq 0xa00a
addq $0x10, %rsp
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0xd516
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xd516
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdi
movl $0xa, %edx
callq 0x5220
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xd613
movq -0xb8(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x170(%rbp), %rdi
leaq -0x160(%rbp), %rax
cmpq %rax, %rdi
je 0xd482
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xd482
movq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x68(%rbp), %r15
movq %r12, %rdi
callq 0x50b0
movabsq $-0x8000000000000000, %r13 # imm = 0x8000000000000000
subq -0x48(%rbp), %r15
movq -0x200(%rbp), %rax
addl %eax, -0x50(%rbp)
movq -0x1f8(%rbp), %rsp
movl $0x0, -0x78(%rbp)
movq %r15, -0x48(%rbp)
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
leaq -0x70(%rbp), %r15
je 0xd69b
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r15, %rdi
callq 0xab8e
movl -0x78(%rbp), %eax
cmpl $0x7, %eax
je 0xd6b3
testl %eax, %eax
jne 0xda3f
movq -0x48(%rbp), %rcx
shrq $0x5, %rcx
movq -0xe8(%rbp), %rax
addl %ecx, %eax
movq %rax, -0xe8(%rbp)
movq -0x108(%rbp), %rdi
incq %rdi
movq -0x100(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rdi, %rcx
ja 0xd226
movq -0x248(%rbp), %rsi
movq 0x338bf(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %rbx
leaq 0x26059(%rip), %rsi     # 0x33769
movl $0x17, %edx
movq %rax, %rdi
callq 0x5420
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x5690
movq %rax, %rbx
leaq 0x25d7d(%rip), %rsi     # 0x334b0
movl $0xc, %edx
movq %rax, %rdi
callq 0x5420
movq -0x1f0(%rbp), %rsi
shrq $0x5, %rsi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x27394(%rip), %rsi     # 0x34af1
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x10, %edi
callq 0x53b0
movq -0x1d8(%rbp), %r12
movq -0x1e8(%rbp), %r14
movq %rax, %rbx
leaq -0x170(%rbp), %rsi
movq %rax, (%rsi)
addq $0x10, %rax
movq %rax, 0x10(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq %rax, 0x8(%rsi)
xorl %eax, %eax
leaq -0x150(%rbp), %r9
movl %eax, (%r9)
leaq -0x70(%rbp), %r10
movl %eax, (%r10)
movzbl (%r14), %r8d
subq $0x8, %rsp
leaq -0x260(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl -0xec(%rbp), %ecx
pushq %r10
callq 0xc894
addq $0x10, %rsp
movss -0x150(%rbp), %xmm0
movss -0x70(%rbp), %xmm1
movl -0x30(%rbp), %edi
callq 0x83ea
movl $0x1, -0x34(%rbp)
testl %eax, %eax
jne 0xda32
leaq -0xc8(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0xf8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x8566
leaq 0x25f2f(%rip), %rsi     # 0x33781
leaq -0xd8(%rbp), %rdi
callq 0x5710
leaq -0x228(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0xdccc
movzbl (%r14), %r8d
leaq -0xd8(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x170(%rbp), %rdx
leaq -0x228(%rbp), %rcx
callq 0xca19
leaq -0x228(%rbp), %rdi
callq 0xab8e
movq -0xd8(%rbp), %rdi
cmpq %r15, %rdi
je 0xd8bd
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x1e0(%rbp), %rax
cmpb $0x1, (%rax)
jne 0xda23
movq 0x336ec(%rip), %r14     # 0x40fc0
leaq 0x25eab(%rip), %rsi     # 0x33786
movl $0x1c, %edx
movq %r14, %rdi
callq 0x5420
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x336ba(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq -0xa8(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq -0x260(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa72f
movq -0xc0(%rbp), %rsi
movq 0x33667(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %r14
leaq 0x25e3b(%rip), %rsi     # 0x337a3
movl $0x21, %edx
movq %rax, %rdi
callq 0x5420
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq -0x180(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0xf8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x190(%rbp), %rdi
callq 0x8566
leaq 0x28383(%rip), %rsi     # 0x35d4e
leaq -0x190(%rbp), %rdi
callq 0x5710
movl -0x30(%rbp), %ecx
leaq -0xd8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x1b0(%rbp), %rdx
callq 0x9250
movl %eax, %r14d
movq -0x190(%rbp), %rdi
cmpq %r15, %rdi
je 0xda12
movq -0x180(%rbp), %rsi
incq %rsi
callq 0x53c0
leaq -0xd8(%rbp), %rdi
callq 0xdd56
testl %r14d, %r14d
jne 0xda32
movl $0x0, -0x34(%rbp)
movq %r12, %rdi
callq 0x8320
movl $0x10, %esi
movq %rbx, %rdi
callq 0x53c0
leaq -0x468(%rbp), %rdi
callq 0x50d0
leaq -0x260(%rbp), %rdi
callq 0xddf4
leaq -0x1b0(%rbp), %rdi
callq 0xab8e
movq -0x130(%rbp), %rdi
testq %rdi, %rdi
je 0xda7e
movq -0x110(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x1d0(%rbp), %rdi
callq 0xab8e
movl -0x34(%rbp), %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3354d(%rip), %rbx     # 0x40ff0
leaq 0x259e1(%rip), %rsi     # 0x3348b
movl $0x24, %edx
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x3351b(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq -0x70(%rbp), %rdi
callq 0xab8e
jmp 0xda3f
jmp 0xdb1c
movq %rax, %r14
movq -0x190(%rbp), %rdi
cmpq %r15, %rdi
je 0xdb76
movq -0x180(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xdb76
movq %rax, %r14
leaq -0x228(%rbp), %rdi
callq 0xab8e
jmp 0xdb52
jmp 0xdb4f
movq %rax, %r14
movq -0xd8(%rbp), %rdi
cmpq %r15, %rdi
je 0xdb9b
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xdb9b
jmp 0xdb98
jmp 0xdbc3
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
callq 0xdd56
jmp 0xdb9b
jmp 0xdbbb
movq %rax, %r14
jmp 0xdc84
movq %rax, %r14
jmp 0xdc9c
jmp 0xdbad
movq %rax, %r14
movl $0x10, %esi
movq %rbx, %rdi
callq 0x53c0
jmp 0xdc78
movq %rax, %r14
jmp 0xdcb7
jmp 0xdbcd
jmp 0xdbc3
jmp 0xdbd9
movq %rax, %r14
jmp 0xdc6f
movq %rax, %r14
jmp 0xdc78
jmp 0xdbcd
movq %rax, %r14
jmp 0xdc90
jmp 0xdbd9
jmp 0xdbd9
movq %rax, %r14
jmp 0xdc54
jmp 0xdc09
jmp 0xdc09
movq %rax, %r14
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0xdc0c
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xdc0c
movq %rax, %r14
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xdc32
movq -0xb8(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq $0x0, -0xd8(%rbp)
movq -0x170(%rbp), %rdi
leaq -0x160(%rbp), %rax
cmpq %rax, %rdi
je 0xdc54
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0xdc6f
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x70(%rbp), %rdi
callq 0xab8e
leaq -0x468(%rbp), %rdi
callq 0x50d0
leaq -0x260(%rbp), %rdi
callq 0xddf4
leaq -0x1b0(%rbp), %rdi
callq 0xab8e
movq -0x130(%rbp), %rdi
testq %rdi, %rdi
je 0xdcb7
movq -0x110(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x1d0(%rbp), %rdi
callq 0xab8e
movq %r14, %rdi
callq 0x56a0
nop