// File: /workspace/github_cpp_makefile_star2_O3/simonrharris[P]SKA/src/sk_merge.cpp
// Function: mergeKmerFiles(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&, 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 mergeKmerFiles(const std::string & outfile, const std::vector < std::string > & kmerfiles, 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();
	
	// Create the kmer map
	std::unordered_map < std::string, std::vector < bool > > kmerMap;
	
	std::vector< int > kmerCounts;
	int kmersize=0;
	std::vector < std::string > sampleNames;

	if (collectSampleNames(kmerfiles, sampleNames)!=0){return 1;}

	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 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)]);
		}
	}

	//int numSamples=sampleNames.size();
	int numSamples = std::count(include.begin(), include.end(), true);

	std::vector < std::string > fileSampleNames;

	int sampleNum=0;
	int includedSampleNum=0;
	std::ifstream fileStream;

	for (int s = 0; s < kmerfiles.size(); ++s){

		if (openFileStream(kmerfiles[s], fileStream)){return 1;};

		int newkmersize;
		
		readKmerHeader(fileStream, newkmersize, fileSampleNames);
		
		if (s==0){
			kmersize=newkmersize;
		}

		if (newkmersize!=kmersize){
			std::cout << "kmer files have different kmer sizes" << std::endl << std::endl;
			return 0;
		}

		std::vector < int > fileInclude;

		for (int i=0; i<fileSampleNames.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();
			sampleNum+=int(fileSampleNames.size());
			fileSampleNames.clear();
			continue;
		}

		//int numFileSamples=fileSampleNames.size();
		int numFileSamples = fileInclude.size();

		char basebuffer[1];
		char kmerbuffer[(kmersize*2/3)+1];
		char asciibuffer[int(std::ceil(float(fileSampleNames.size())/6))];

		while (fileStream.read(asciibuffer, sizeof(asciibuffer))){//read the ascii representation of the taxa
			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

			int mybitcount=0;
			for (int i=0; i< fileInclude.size(); ++i){
				if (mybits[fileInclude[i]]){
					mybitcount++;
				}
			}

			if (mybitcount==0){
				std::string line;
				std::getline(fileStream, line);
				continue;
			}

			while (fileStream.peek()!='\n' && fileStream.read(kmerbuffer, sizeof(kmerbuffer))){
				std::string kmer (kmerbuffer, (kmersize*2/3)+1);
				
				std::unordered_map < std::string, std::vector < bool > >::iterator it = kmerMap.find(kmer);//check if the kmer is in the map
				if ( it != kmerMap.end() ){//if the kmer is in the map
					for (int i=0; i<fileInclude.size(); ++i){
						it->second[i+includedSampleNum]=mybits[fileInclude[i]];
					}
				}
				else {//if the kmer is not in the hash
					std::vector < bool > taxonBitset(numSamples, false);//create a new vector of bools for all samples
					for (int i=0; i<fileInclude.size(); ++i){ //change the bools to true based for taxa in the file containing the kmer
						taxonBitset[i+includedSampleNum]=mybits[fileInclude[i]];
					}
					kmerMap.insert(std::make_pair(kmer, taxonBitset));//add the new vector to the map
				}
	    	}
	    	fileStream.ignore(256,'\n');//skip the end of line character
    	}
    	sampleNum+=numFileSamples; //add the number of samples in the file to the count of total samples
    	includedSampleNum+=fileInclude.size();
    	fileSampleNames.clear();
		fileStream.close();
	}

	std::cout << kmerMap.size() << " kmers identified from " << includedSampleNum << " samples in " << numfiles << " files" << std::endl;
	
	std::cout << "Merging..." << std::endl;

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

	reverseVectorBoolKmerMap(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, outfile, includedSampleNames, kmersize)){return 1;}
	
	printDuration(start);//stop the clock
	
	return 0;
		
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, -0x1e0(%rbp)
callq 0x5060
movq %rax, -0x1d8(%rbp)
movq 0x8(%r15), %rax
subq (%r15), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x268(%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 -0x190(%rbp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, %ebx
movq %r15, -0x110(%rbp)
movq %r15, %rdi
movl $0x1, %edx
callq 0x9851
testl %eax, %eax
jne 0x1b13b
movq -0x188(%rbp), %rsi
subq -0x190(%rbp), %rsi
sarq $0x5, %rsi
leaq -0x4a0(%rbp), %rdx
movb $0x0, (%rdx)
leaq -0x158(%rbp), %rdi
leaq -0xd8(%rbp), %rcx
callq 0xabec
leaq -0x190(%rbp), %rsi
leaq -0x158(%rbp), %rdx
movq %r14, %rdi
callq 0x9b39
xorps %xmm0, %xmm0
movaps %xmm0, -0x1d0(%rbp)
movq $0x0, -0x1c0(%rbp)
movq -0x158(%rbp), %r14
movq -0x148(%rbp), %rax
movl -0x140(%rbp), %edx
cmpq %rax, %r14
setne %cl
testl %edx, %edx
setne %sil
orb %cl, %sil
xorl %ecx, %ecx
cmpb $0x1, %sil
jne 0x1a5ab
xorl %r15d, %r15d
leaq -0x1d0(%rbp), %rbx
movl %edx, %ecx
xorl %edx, %edx
movl %edx, %r12d
movq (%r14), %rsi
btq %rdx, %rsi
jae 0x1a582
movq %r14, %rax
subq -0x158(%rbp), %rax
shlq $0x8, %rax
addq -0x190(%rbp), %rax
movq %r12, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x8528
movq -0x148(%rbp), %rax
movl -0x140(%rbp), %ecx
leal 0x1(%r12), %edx
xorl %esi, %esi
cmpq $0x3f, %r12
sete %sil
leaq (%r14,%rsi,8), %r14
cmovel %r15d, %edx
cmpq %rax, %r14
jne 0x1a542
cmpl %ecx, %edx
jne 0x1a542
movq -0x158(%rbp), %r14
jmp 0x1a5ae
movq %r14, %rax
movq $0x0, -0x120(%rbp)
cmpq %rax, %r14
jne 0x1a5c2
testl %ecx, %ecx
je 0x1a5fc
xorl %edx, %edx
xorl %esi, %esi
movq (%r14), %rdi
btq %rsi, %rdi
adcq $0x0, %rdx
xorl %edi, %edi
cmpl $0x3f, %esi
leal 0x1(%rsi), %esi
sete %dil
leaq (%r14,%rdi,8), %r14
movl $0x0, %edi
cmovel %edi, %esi
cmpq %rax, %r14
jne 0x1a5c6
cmpl %ecx, %esi
jne 0x1a5c6
movslq %edx, %rax
movq %rax, -0x120(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
leaq -0x4a0(%rbp), %r13
movq %r13, %rdi
callq 0x5410
movq -0x110(%rbp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x1ae87
xorl %r15d, %r15d
xorl %ebx, %ebx
movq $0x0, -0x88(%rbp)
movl $0x0, -0x2c(%rbp)
movq %r15, %rdi
shlq $0x5, %rdi
addq %rax, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x7f3f
testl %eax, %eax
jne 0x1b086
movq %r13, %rdi
leaq -0xdc(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x9684
movq %r15, -0x78(%rbp)
testq %r15, %r15
sete %al
movl -0xdc(%rbp), %r15d
cmpl %r15d, %ebx
sete %cl
orb %al, %cl
leaq -0x178(%rbp), %r14
je 0x1b08d
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0xd8(%rbp)
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq %rax, %rcx
je 0x1a7e4
xorl %edx, %edx
leaq -0x50(%rbp), %rbx
movq -0x88(%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 -0x158(%rbp), %rdi
movabsq $-0x8000000000000000, %r10 # imm = 0x8000000000000000
leaq 0x3f(%r10), %r12
movq %rsi, %r8
andq %r12, %r8
xorl %r9d, %r9d
cmpq %r10, %r8
setbe %r9b
movq -0x8(%rdi,%r9,8), %rdi
btq %rsi, %rdi
jae 0x1a74b
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x1a734
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x1a74b
movq %rbx, %rdi
leaq -0xd8(%rbp), %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 0x1a6cd
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rax
subq %rax, %rcx
je 0x1a7e4
movq %rcx, -0x80(%rbp)
movq %rsp, -0x1f0(%rbp)
leal (%r15,%r15), %eax
cltq
imulq $0x55555556, %rax, %rbx # imm = 0x55555556
movq %rbx, %rax
shrq $0x3f, %rax
shrq $0x20, %rbx
leal (%rbx,%rax), %ecx
incl %ecx
movq %rcx, -0x218(%rbp)
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x90(%rbp)
movq %rdx, %rsp
movq -0x68(%rbp), %rcx
subq -0x70(%rbp), %rcx
sarq $0x5, %rcx
movq %r15, -0x1f8(%rbp)
js 0x1a853
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
jmp 0x1a868
movq %r15, %r12
movq %r13, %rdi
callq 0x50b0
movq -0x70(%rbp), %r14
movq -0x68(%rbp), %r15
movq %r15, %rax
subq %r14, %rax
sarq $0x5, %rax
movq %rax, -0x80(%rbp)
movl $0x7, %ebx
cmpq %r14, %r15
je 0x1a84b
leaq 0x10(%r14), %r13
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x1a828
movq (%r13), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%r13), %rax
addq $0x10, %r13
cmpq %r15, %r13
movq %rax, %r13
jne 0x1a813
movq %r14, -0x68(%rbp)
movq %r12, %r14
leaq -0x4a0(%rbp), %r13
jmp 0x1ae2a
movq %r12, %r14
jmp 0x1ae2a
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
sarq $0x2, -0x80(%rbp)
addl %eax, %ebx
divss 0x18e09(%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, -0x208(%rbp)
movq %rdx, -0x118(%rbp)
leaq (%rdx,%rcx), %rax
movq %rax, -0x200(%rbp)
movslq %ebx, %rax
movq -0x90(%rbp), %rcx
leaq 0x1(%rax,%rcx), %rax
movq %rax, -0x210(%rbp)
movslq -0x2c(%rbp), %rax
movq %rax, -0x128(%rbp)
movl %eax, %r15d
movq %r12, -0x130(%rbp)
movq %r13, %rdi
movq -0x118(%rbp), %rsi
movq -0x208(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1adc2
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0x1b0(%rbp), %rbx
movq %rbx, %rdi
movq -0x118(%rbp), %rsi
movq -0x200(%rbp), %rdx
callq 0x85fc
xorl %eax, %eax
movq %rax, -0x108(%rbp)
movl %eax, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
movl %eax, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
movq %rbx, %rdi
leaq -0x108(%rbp), %rsi
callq 0x8993
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
je 0x1acfc
sarq $0x2, %rcx
movq -0x108(%rbp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
xorl %edi, %edi
movabsq $-0x8000000000000000, %rbx # imm = 0x8000000000000000
movslq (%rax,%rsi,4), %r8
leal 0x3f(%r8), %r9d
testq %r8, %r8
cmovnsl %r8d, %r9d
sarl $0x6, %r9d
movslq %r9d, %r9
leaq (%rdx,%r9,8), %r9
movq %r8, %r10
andq %r12, %r10
xorl %r11d, %r11d
cmpq %rbx, %r10
setbe %r11b
movq -0x8(%r9,%r11,8), %r9
btq %r8, %r9
adcl $0x0, %edi
incq %rsi
cmpq %rsi, %rcx
jne 0x1a98c
testl %edi, %edi
je 0x1acfc
movq %r13, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0x1ad6a
movq %r13, %rdi
movq -0x90(%rbp), %rsi
movq -0x218(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1ad6a
leaq -0x168(%rbp), %rax
movq %rax, -0x178(%rbp)
movq %r14, %rdi
movq -0x90(%rbp), %rsi
movq -0x210(%rbp), %rdx
callq 0x85fc
leaq -0x298(%rbp), %rdi
movq %r14, %rsi
callq 0x1b44a
testq %rax, %rax
je 0x1ab24
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rsi
subq %rdx, %rsi
je 0x1acc7
sarq $0x2, %rsi
movq -0x108(%rbp), %rdi
movq 0x28(%rax), %rax
cmpq $0x1, %rsi
adcq $0x0, %rsi
xorl %r8d, %r8d
movslq (%rdx,%r8,4), %r9
leal 0x3f(%r9), %r11d
testq %r9, %r9
cmovnsl %r9d, %r11d
sarl $0x6, %r11d
movq %r9, %rcx
andq %r12, %rcx
xorl %r10d, %r10d
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
cmpq %r14, %rcx
setbe %r10b
movl %r15d, %ecx
addl %r8d, %ecx
leal 0x3f(%r15,%r8), %r13d
cmovnsl %ecx, %r13d
movq %r12, %rbx
movq -0x128(%rbp), %rcx
leaq (%rcx,%r8), %r12
sarl $0x6, %r13d
movq %r12, %rcx
andq %rbx, %rcx
xorl %ebx, %ebx
cmpq %r14, %rcx
movslq %r11d, %rcx
leaq (%rdi,%rcx,8), %rcx
setbe %bl
movq -0x8(%rcx,%r10,8), %r11
movl $0x1, %r10d
movl %r12d, %ecx
shlq %cl, %r10
btq %r9, %r11
movslq %r13d, %rcx
leaq (%rax,%rcx,8), %rcx
leaq -0x8(,%rbx,8), %r9
jae 0x1ab01
orq (%rcx,%r9), %r10
jmp 0x1ab08
notq %r10
andq (%rcx,%r9), %r10
movq %r10, (%rcx,%r9)
incq %r8
cmpq %r8, %rsi
movq -0x130(%rbp), %r12
jne 0x1aa72
jmp 0x1acc7
movb $0x0, -0xd8(%rbp)
leaq -0x260(%rbp), %rdi
movq -0x120(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
leaq -0x2d(%rbp), %rcx
callq 0xabec
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rdx
subq %rax, %rdx
je 0x1ac20
sarq $0x2, %rdx
movq -0x108(%rbp), %rsi
movq -0x260(%rbp), %rdi
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %r8d, %r8d
movslq (%rax,%r8,4), %r9
leal 0x3f(%r9), %r11d
testq %r9, %r9
cmovnsl %r9d, %r11d
sarl $0x6, %r11d
movq %r9, %rcx
andq %r12, %rcx
xorl %r10d, %r10d
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
cmpq %r14, %rcx
setbe %r10b
movl %r15d, %ecx
addl %r8d, %ecx
leal 0x3f(%r15,%r8), %ebx
cmovnsl %ecx, %ebx
movq -0x128(%rbp), %rcx
addq %r8, %rcx
sarl $0x6, %ebx
movq %r12, %r13
movq %rcx, %r12
andq %r13, %r12
xorl %r13d, %r13d
cmpq %r14, %r12
movslq %r11d, %r11
leaq (%rsi,%r11,8), %r11
setbe %r13b
movq -0x8(%r11,%r10,8), %r11
movl $0x1, %r10d
shlq %cl, %r10
btq %r9, %r11
movslq %ebx, %rcx
leaq (%rdi,%rcx,8), %rcx
leaq -0x8(,%r13,8), %r9
jae 0x1ac02
orq (%rcx,%r9), %r10
jmp 0x1ac09
notq %r10
andq (%rcx,%r9), %r10
movq %r10, (%rcx,%r9)
incq %r8
cmpq %r8, %rdx
movq -0x130(%rbp), %r12
jne 0x1ab77
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
leaq -0x178(%rbp), %rsi
leaq -0x260(%rbp), %rdx
callq 0x1b358
leaq -0x298(%rbp), %rdi
movq %rbx, %rsi
callq 0x1b546
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x1ac8a
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
movl %eax, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
movl %eax, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x1acac
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x260(%rbp), %rdi
testq %rdi, %rdi
je 0x1acc7
movq -0x240(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x178(%rbp), %rdi
leaq -0x168(%rbp), %rax
cmpq %rax, %rdi
je 0x1ace9
movq -0x168(%rbp), %rsi
incq %rsi
callq 0x53c0
leaq -0x4a0(%rbp), %r13
leaq -0x178(%rbp), %r14
jmp 0x1a9d2
leaq -0xc8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq $0x0, -0xd0(%rbp)
movb $0x0, -0xc8(%rbp)
movq -0x4a0(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %edx
movq %r13, %rdi
leaq -0xd8(%rbp), %rsi
callq 0x56c0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x1ad7c
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x1ad7c
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
movl $0xa, %edx
callq 0x5220
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x1ad97
movq -0xe8(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
cmpq %rax, %rdi
je 0x1a8d5
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x1a8d5
movq -0x48(%rbp), %rbx
subq -0x50(%rbp), %rbx
movq -0x70(%rbp), %r14
movq -0x68(%rbp), %r15
cmpq %r14, %r15
je 0x1ae0b
leaq 0x10(%r14), %r13
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x1adf0
movq (%r13), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%r13), %rax
addq $0x10, %r13
cmpq %r15, %r13
movq %rax, %r13
jne 0x1addb
movq %r14, -0x68(%rbp)
leaq -0x4a0(%rbp), %r13
movq %r13, %rdi
callq 0x50b0
shrq $0x2, %rbx
addl %ebx, -0x2c(%rbp)
movq -0x1f0(%rbp), %rsp
xorl %ebx, %ebx
movq -0x1f8(%rbp), %r14
movq -0x78(%rbp), %r15
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1ae43
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
cmpl $0x7, %ebx
je 0x1ae50
testl %ebx, %ebx
jne 0x1b0fd
movq -0x88(%rbp), %rax
addl -0x80(%rbp), %eax
movq %rax, -0x88(%rbp)
incq %r15
movq -0x110(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
movl %r14d, %ebx
cmpq %r15, %rcx
ja 0x1a645
jmp 0x1ae91
movl $0x0, -0x2c(%rbp)
xorl %r14d, %r14d
movq -0x280(%rbp), %rsi
movq 0x26121(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %rbx
leaq 0x188bb(%rip), %rsi     # 0x33769
movl $0x17, %edx
movq %rax, %rdi
callq 0x5420
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x5690
movq %rax, %rbx
leaq 0x185e0(%rip), %rsi     # 0x334b0
movl $0xc, %edx
movq %rax, %rdi
callq 0x5420
movq -0x1e8(%rbp), %rsi
shrq $0x5, %rsi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x19bf7(%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
movq 0x2608b(%rip), %rbx     # 0x40fc0
leaq 0x1947c(%rip), %rsi     # 0x343b8
movl $0xa, %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 0x26059(%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 -0x298(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa595
movq -0xc0(%rbp), %rsi
movq 0x26006(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %rbx
leaq 0x187da(%rip), %rsi     # 0x337a3
movl $0x21, %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
leaq -0x228(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x1e0(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x238(%rbp), %rdi
callq 0x8566
leaq -0xd8(%rbp), %rdi
leaq -0x238(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
movl %r14d, %ecx
callq 0x9250
movl %eax, %r14d
movq -0x238(%rbp), %rdi
cmpq %r15, %rdi
je 0x1b060
movq -0x228(%rbp), %rsi
incq %rsi
callq 0x53c0
movl $0x1, %ebx
testl %r14d, %r14d
jne 0x1b078
xorl %ebx, %ebx
movq -0x1d8(%rbp), %rdi
callq 0x8320
leaq -0xd8(%rbp), %rdi
callq 0xdd56
jmp 0x1b0ff
movl $0x1, %ebx
jmp 0x1b0ff
movq 0x25f2c(%rip), %rbx     # 0x40fc0
leaq 0x183f0(%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 0x25efa(%rip), %rdi     # 0x40fc0
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
xorl %ebx, %ebx
leaq -0x4a0(%rbp), %rdi
callq 0x50d0
leaq -0x70(%rbp), %rdi
callq 0xab8e
leaq -0x1d0(%rbp), %rdi
callq 0xab8e
movq -0x158(%rbp), %rdi
testq %rdi, %rdi
je 0x1b13b
movq -0x138(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x190(%rbp), %rdi
callq 0xab8e
leaq -0x298(%rbp), %rdi
callq 0x1b3ac
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x238(%rbp), %rdi
cmpq %r15, %rdi
je 0x1b1a7
movq -0x228(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x1b1a7
movq %rax, %rbx
jmp 0x1b2d8
movq %rax, %rbx
jmp 0x1b2ed
jmp 0x1b19a
jmp 0x1b1bc
jmp 0x1b1da
movq %rax, %rbx
jmp 0x1b308
jmp 0x1b1da
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0xdd56
jmp 0x1b2cc
jmp 0x1b1bc
jmp 0x1b1bc
movq %rax, %rbx
jmp 0x1b2cc
movq %rax, %rbx
jmp 0x1b2e1
jmp 0x1b1da
jmp 0x1b25d
jmp 0x1b25d
jmp 0x1b1da
movq %rax, %rbx
jmp 0x1b2b7
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x1b260
movq -0xc8(%rbp), %rsi
jmp 0x1b251
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x1b328
jmp 0x1b215
movq %rax, %rbx
movq -0x260(%rbp), %rdi
testq %rdi, %rdi
je 0x1b237
movq -0x240(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0x1b237
jmp 0x1b234
movq %rax, %rbx
movq -0x178(%rbp), %rdi
leaq -0x168(%rbp), %rax
cmpq %rax, %rdi
je 0x1b260
movq -0x168(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x1b260
jmp 0x1b25d
movq %rax, %rbx
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x1b295
movq -0xe8(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, -0x108(%rbp)
movl $0x0, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
movq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
cmpq %rax, %rdi
je 0x1b2b7
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1b2cc
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x4a0(%rbp), %rdi
callq 0x50d0
leaq -0x70(%rbp), %rdi
callq 0xab8e
leaq -0x1d0(%rbp), %rdi
callq 0xab8e
movq -0x158(%rbp), %rdi
testq %rdi, %rdi
je 0x1b308
movq -0x138(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x190(%rbp), %rdi
callq 0xab8e
leaq -0x298(%rbp), %rdi
callq 0x1b3ac
movq %rbx, %rdi
callq 0x56a0