// File: /workspace/github_cpp_makefile_star2_O1/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 $0x438, %rsp            # imm = 0x438
movq %r9, %r14
movq %r8, -0x1d8(%rbp)
movq %rcx, -0x138(%rbp)
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbx
callq 0x5060
movq %rax, %r12
movq 0x8(%r15), %rax
subq (%r15), %rax
movq %rax, -0x1e0(%rbp)
xorpd %xmm0, %xmm0
leaq -0x1c0(%rbp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, -0x34(%rbp)
movq %r15, -0x140(%rbp)
movq %r15, %rdi
movl $0x1, %edx
callq 0x98af
testl %eax, %eax
jne 0xdc25
movq -0x1b8(%rbp), %rsi
subq -0x1c0(%rbp), %rsi
sarq $0x5, %rsi
leaq -0x460(%rbp), %rdx
movb $0x0, (%rdx)
leaq -0xd8(%rbp), %rdi
leaq -0x258(%rbp), %rcx
callq 0xac4a
leaq -0x1c0(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
movq %r14, %rdi
callq 0x9ba8
xorpd %xmm0, %xmm0
movapd %xmm0, -0x1a0(%rbp)
movq $0x0, -0x190(%rbp)
movq -0xd8(%rbp), %r15
movq -0xc8(%rbp), %rax
movl -0xc0(%rbp), %ecx
cmpq %rax, %r15
setne %dl
testl %ecx, %ecx
setne %sil
orb %dl, %sil
cmpb $0x1, %sil
movq %r12, -0x1d0(%rbp)
movq %r13, -0x1c8(%rbp)
jne 0xd0d4
xorl %r12d, %r12d
leaq -0x1a0(%rbp), %r14
xorl %edx, %edx
movl %edx, %r13d
movq (%r15), %rax
btq %rdx, %rax
jae 0xd0a0
movq %r15, %rax
subq -0xd8(%rbp), %rax
shlq $0x8, %rax
addq -0x1c0(%rbp), %rax
movq %r13, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %r14, %rdi
callq 0x855c
leal 0x1(%r13), %edx
xorl %eax, %eax
cmpq $0x3f, %r13
sete %al
cmovel %r12d, %edx
leaq (%r15,%rax,8), %r15
movq -0xc8(%rbp), %rax
movl -0xc0(%rbp), %ecx
cmpq %rax, %r15
setne %sil
cmpl %ecx, %edx
setne %dil
orb %sil, %dil
jne 0xd06d
movq -0xd8(%rbp), %rdx
cmpq %rax, %rdx
setne %sil
testl %ecx, %ecx
setne %dil
orb %sil, %dil
xorl %esi, %esi
cmpb $0x1, %dil
jne 0xd12c
xorl %r10d, %r10d
xorl %esi, %esi
xorl %edi, %edi
movq (%rdx), %r8
btq %rdi, %r8
adcq $0x0, %rsi
xorl %r8d, %r8d
cmpl $0x3f, %edi
leal 0x1(%rdi), %edi
sete %r8b
leaq (%rdx,%r8,8), %rdx
cmovel %r10d, %edi
cmpq %rax, %rdx
setne %r8b
cmpl %ecx, %edi
setne %r9b
orb %r8b, %r9b
jne 0xd0fa
movq 0x33e8d(%rip), %rdi     # 0x40fc0
movq %rsi, -0x100(%rbp)
callq 0x5690
movq %rax, %r14
leaq 0x265b2(%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 0x260dc(%rip), %xmm1    # 0x33268
subsd %xmm0, %xmm1
movq -0x100(%rbp), %rbx
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
mulsd %xmm1, %xmm0
callq 0x5170
movsd %xmm0, -0x40(%rbp)
movq 0x33e0d(%rip), %rdi     # 0x40fc0
leaq 0x2656c(%rip), %rsi     # 0x33726
movl $0x24, %edx
callq 0x5420
xorps %xmm1, %xmm1
cvtsd2ss -0x40(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2ss %ebx, %xmm0
movss %xmm1, -0x40(%rbp)
subss %xmm1, %xmm0
cvttss2si %xmm0, %r14d
movq 0x33dd8(%rip), %rdi     # 0x40fc0
movl %r14d, %esi
callq 0x5690
movq %rax, %rbx
leaq 0x26551(%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
movl %r14d, -0x104(%rbp)
leaq -0x228(%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 -0x460(%rbp), %rdi
callq 0x5410
movq -0x140(%rbp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0xd85a
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
cvttss2si -0x40(%rbp), %ecx
movq %rcx, -0x208(%rbp)
leaq -0x460(%rbp), %r12
leaq -0xa0(%rbp), %r13
leaq -0x29(%rbp), %r14
xorl %edi, %edi
movl $0x0, -0x64(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0xf8(%rbp)
movq %rdi, -0x148(%rbp)
shlq $0x5, %rdi
addq %rax, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x7f73
movl $0x1, -0x34(%rbp)
testl %eax, %eax
jne 0xdbc3
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x96e2
movl -0x30(%rbp), %eax
cmpq $0x0, -0x148(%rbp)
je 0xd3c8
cmpl -0x64(%rbp), %eax
je 0xd3cb
movl $0x24, %edx
movq 0x33c9a(%rip), %rdi     # 0x40ff0
leaq 0x2612e(%rip), %rsi     # 0x3348b
callq 0x5420
movq 0x33c87(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x33c69(%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
movl $0x1, %ebx
movq %rax, %rdi
callq 0x5250
jmp 0xd81c
movl %eax, -0x64(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
movq $0x0, -0xe0(%rbp)
movl $0x0, -0xa0(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0xd48e
xorl %eax, %eax
movq -0xf8(%rbp), %rcx
addl %eax, %ecx
movslq %ecx, %rcx
leaq 0x3f(%rcx), %rdx
testq %rcx, %rcx
cmovnsq %rcx, %rdx
sarq $0x6, %rdx
shlq $0x3, %rdx
addq -0xd8(%rbp), %rdx
leaq 0x3f(%r15), %rsi
andq %rcx, %rsi
xorl %edi, %edi
cmpq %r15, %rsi
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
btq %rcx, %rdx
jae 0xd469
movq -0xe8(%rbp), %rsi
cmpq -0xe0(%rbp), %rsi
je 0xd45a
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0xe8(%rbp)
jmp 0xd469
leaq -0xf0(%rbp), %rdi
movq %r13, %rdx
callq 0xe01e
movslq -0xa0(%rbp), %rax
incq %rax
movl %eax, -0xa0(%rbp)
movq -0x58(%rbp), %rcx
subq -0x60(%rbp), %rcx
sarq $0x5, %rcx
cmpq %rax, %rcx
ja 0xd3fa
movq -0xe8(%rbp), %rax
subq -0xf0(%rbp), %rax
shrq $0x2, %rax
testl %eax, %eax
je 0xd504
movq %rax, -0x1f0(%rbp)
movq %rsp, -0x1e8(%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, -0xb0(%rbp)
leaq 0xf(%rcx), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
movq -0x58(%rbp), %rax
subq -0x60(%rbp), %rax
sarq $0x5, %rax
js 0xd57a
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xd592
movq %r12, %rdi
callq 0x50b0
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %r15
movq %r15, %rax
movl $0x7, %ebx
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
je 0xd7dc
movq %rcx, -0xa8(%rbp)
leaq 0x10(%rcx), %rbx
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0xd54b
movq (%rbx), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%rbx), %rax
addq $0x10, %rbx
cmpq %r15, %rbx
movq %rax, %rbx
jne 0xd537
movq -0xa8(%rbp), %rax
movq %rax, -0x58(%rbp)
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
movl $0x7, %ebx
jmp 0xd7e6
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x260e6(%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, -0x200(%rbp)
movq %rdx, -0xa8(%rbp)
leaq (%rdx,%rcx), %rax
movq %rax, -0x1f8(%rbp)
movq %r12, %rdi
movq -0xa8(%rbp), %rsi
movq -0x200(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xd7af
movq %r12, %rbx
movq %r14, %r12
movq %r13, %r14
leaq -0x120(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x130(%rbp), %r13
movq %r13, %rdi
movq -0xa8(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
callq 0x862a
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
movl %eax, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movl %eax, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq %r13, %rdi
movq %r14, %r13
movq %r14, %rsi
callq 0x89ef
movq %r12, %r14
movq %rbx, %r12
movq %r12, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0xd73a
movq %r12, %rdi
movq %r14, %rsi
callq 0x5500
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xd73a
movq %r12, %rdi
movq %r15, %rsi
movq -0xb0(%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 -0x158(%rbp), %rax
movq %rax, -0x168(%rbp)
addq %r15, %rdx
leaq -0x168(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x862a
movsbl -0x29(%rbp), %edx
leaq -0x258(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rcx
leaq -0xf0(%rbp), %r8
movl -0x40(%rbp), %r9d
pushq -0x208(%rbp)
pushq -0x100(%rbp)
callq 0xa08b
addq $0x10, %rsp
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0xd65d
movq -0x158(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xd65d
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdi
movl $0xa, %edx
callq 0x5220
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0xd784
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
movl %eax, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movl %eax, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0xd5cd
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xd5cd
movq -0x60(%rbp), %rbx
movq -0x58(%rbp), %r15
movq %r12, %rdi
callq 0x50b0
subq %rbx, %r15
movq %r15, -0xb0(%rbp)
movq -0x1f0(%rbp), %rax
addl %eax, -0x40(%rbp)
movq -0x1e8(%rbp), %rsp
xorl %ebx, %ebx
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0xd801
movq -0xe0(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0xb0(%rbp), %rcx
shrq $0x5, %rcx
movq -0xf8(%rbp), %rax
addl %ecx, %eax
movq %rax, -0xf8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xabee
cmpl $0x7, %ebx
je 0xd832
testl %ebx, %ebx
jne 0xdbc3
movq -0x148(%rbp), %rdi
incq %rdi
movq -0x140(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rdi, %rcx
ja 0xd2e7
movq -0x240(%rbp), %rsi
movq 0x33758(%rip), %rdi     # 0x40fc0
callq 0x5240
movq -0x100(%rbp), %r14
movq %rax, %rbx
leaq 0x25eeb(%rip), %rsi     # 0x33769
movl $0x17, %edx
movq %rax, %rdi
callq 0x5420
movq %rbx, %rdi
movl %r14d, %esi
callq 0x5690
movq %rax, %rbx
leaq 0x25c10(%rip), %rsi     # 0x334b0
movl $0xc, %edx
movq %rax, %rdi
callq 0x5420
movq -0x1e0(%rbp), %rsi
shrq $0x5, %rsi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x27237(%rip), %rsi     # 0x34b01
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
xorps %xmm0, %xmm0
movaps %xmm0, -0x130(%rbp)
movq $0x0, -0x120(%rbp)
movl $0x10, %edi
callq 0x53b0
movq -0x1d0(%rbp), %r12
movq -0x1c8(%rbp), %r13
movq %rax, %rbx
leaq -0x130(%rbp), %rsi
movq %rax, (%rsi)
movq %rax, 0x8(%rsi)
addq $0x10, %rax
movq %rax, 0x10(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq %rax, 0x8(%rsi)
xorl %eax, %eax
leaq -0x168(%rbp), %r9
movl %eax, (%r9)
leaq -0x60(%rbp), %r10
movl %eax, (%r10)
movq -0x138(%rbp), %rax
movzbl (%rax), %r8d
subq $0x8, %rsp
leaq -0x258(%rbp), %rdi
movl %r14d, %edx
movl -0x104(%rbp), %ecx
pushq %r10
callq 0xc940
addq $0x10, %rsp
movss -0x168(%rbp), %xmm0
movss -0x60(%rbp), %xmm1
movl -0x30(%rbp), %edi
callq 0x841e
movl $0x1, -0x34(%rbp)
testl %eax, %eax
jne 0xdbb6
leaq -0x90(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x859a
leaq 0x25da9(%rip), %rsi     # 0x33781
leaq -0xa0(%rbp), %rdi
callq 0x5710
leaq -0x220(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0xde3c
movq -0x138(%rbp), %rax
movzbl (%rax), %r8d
leaq -0xa0(%rbp), %rdi
leaq -0x258(%rbp), %rsi
leaq -0x130(%rbp), %rdx
leaq -0x220(%rbp), %rcx
callq 0xcac5
leaq -0x220(%rbp), %rdi
callq 0xabee
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0xda4a
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x1d8(%rbp), %rax
cmpb $0x1, (%rax)
jne 0xdba7
movq 0x3355f(%rip), %r14     # 0x40fc0
leaq 0x25d1e(%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 0x3352d(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq -0x70(%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 -0x258(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xa797
movq -0x88(%rbp), %rsi
movq 0x334dd(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %r14
leaq 0x25cb1(%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 -0x178(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq -0x188(%rbp), %rdi
callq 0x859a
leaq 0x2820f(%rip), %rsi     # 0x35d5e
leaq -0x188(%rbp), %rdi
callq 0x5710
movl -0x30(%rbp), %ecx
leaq -0xa0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x92ac
movl %eax, %r14d
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0xdb96
movq -0x178(%rbp), %rsi
incq %rsi
callq 0x53c0
leaq -0xa0(%rbp), %rdi
callq 0xdec6
testl %r14d, %r14d
jne 0xdbb6
movl $0x0, -0x34(%rbp)
movq %r12, %rdi
callq 0x8354
movl $0x10, %esi
movq %rbx, %rdi
callq 0x53c0
leaq -0x460(%rbp), %rdi
callq 0x50d0
leaq -0x258(%rbp), %rdi
callq 0xdf64
leaq -0x1a0(%rbp), %rdi
callq 0xabee
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xdc25
movq -0xb8(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, -0xd8(%rbp)
movl %eax, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
movl %eax, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xabee
movl -0x34(%rbp), %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdc45
movq %rax, %rbx
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0xdc9f
movq -0x178(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xdc9f
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0xabee
jmp 0xdc7b
jmp 0xdc78
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0xdcc2
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xdcc2
jmp 0xdcbf
jmp 0xdcf4
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0xdec6
jmp 0xdcc2
movq %rax, %rbx
jmp 0xddd2
movq %rax, %rbx
jmp 0xddea
jmp 0xdce6
movq %rax, %rbx
movq -0x130(%rbp), %rdi
testq %rdi, %rdi
je 0xddc6
movq -0x120(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0xddc6
movq %rax, %rbx
jmp 0xde28
jmp 0xdcfe
jmp 0xdd12
jmp 0xdcf4
movq %rax, %rbx
jmp 0xddc6
jmp 0xdcfe
movq %rax, %rbx
jmp 0xddde
movq %rax, %rbx
jmp 0xddbd
jmp 0xdd12
jmp 0xdd12
movq %rax, %rbx
jmp 0xdda2
jmp 0xdd45
jmp 0xdd45
movq %rax, %rbx
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0xdd48
movq -0x158(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xdd48
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0xdd80
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
movl %eax, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movl %eax, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0xdda2
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0xddbd
movq -0xe0(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x60(%rbp), %rdi
callq 0xabee
leaq -0x460(%rbp), %rdi
callq 0x50d0
leaq -0x258(%rbp), %rdi
callq 0xdf64
leaq -0x1a0(%rbp), %rdi
callq 0xabee
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xde28
movq -0xb8(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, -0xd8(%rbp)
movl %eax, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
movl %eax, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xabee
movq %rbx, %rdi
callq 0x56a0