// File: /workspace/github_cpp_makefile_star2_O1/simonrharris[P]SKA/src/sk_compare.cpp
// Function: compareKmerFiles(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 compareKmerFiles(const std::string & queryfile, const std::vector < std::string > & subjectfiles)
{

	// Create the kmer map
	std::unordered_map < std::string, char > kmerMap;

	//std::vector < std::string > sampleNames;
	//if (collectSampleNames(subjectfiles, sampleNames, false)!=0){return 1;}
	//int numSamples=sampleNames.size();
	//std::string emptySequence (numSamples , '-');
	

	int querykmersize;
	std::vector < std::string > querySampleNames;

	std::ifstream fileStream;

	if (openFileStream(queryfile, fileStream, false)){return 1;};		
		
	readKmerHeader(fileStream, querykmersize, querySampleNames);

	char base;
	char kmerbuffer[querykmersize*2/3];
	char asciibuffer[int(ceil(float(querySampleNames.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 verctor of bools
		while (fileStream.peek()!='\n' && fileStream.get(base)){
			fileStream.read(kmerbuffer, sizeof(kmerbuffer));
			std::string kmer (kmerbuffer, querykmersize*2/3);
			
			std::unordered_map < std::string, char >::iterator it = kmerMap.find(kmer);//check if the kmer is in the hash
			if ( it != kmerMap.end() ){//if the kmer is in the hash
				it->second='N';
			}
			else {
				kmerMap.insert(std::make_pair(kmer, base));
			}
		}
		fileStream.ignore(256,'\n');//skip the end ofline character
	}
	querySampleNames.clear();
	fileStream.close();

	std::cout << "Subject\tKmers unique to Query\tKmers unique to Subject\tMatches\t% kmers in Query matching\t% kmers in Subject matching\tSNPs\t%ID of matching kmers\t%ID of Query kmers\t%ID of Subject kmers\tNs in Query\tNs in Subject\tNs in both" << std::endl;
	
	for (int s = 0; s < subjectfiles.size(); ++s){
		fileStream.open(subjectfiles[s], std::ios::in);
		if (fileStream.fail()) {
			std::cerr << "Failed to open " << subjectfiles[s] << std::endl << std::endl;
			return 1;
		}
		int subjectkmersize;
		std::vector < std::string > subjectSampleNames;
		
		try {
				int returnval = readKmerHeader(fileStream, subjectkmersize, subjectSampleNames);
			}
			catch (int e){
				std::cerr << "An exception occurred when reading file " << subjectfiles[s] << ". Please check the format. Exception Nr. " << e << std::endl;
				return 1;
			}
		if (subjectkmersize!=querykmersize){
			std::cout << subjectfiles[s] << " has different kmer size to query" << std::endl;
			return 1;
		}

		
		std::vector < int > kmerjustinsubject (subjectSampleNames.size(), 0);
		std::vector < int > snps (subjectSampleNames.size(), 0);
		std::vector < int > ninsubject (subjectSampleNames.size(), 0);
		std::vector < int > ninquery (subjectSampleNames.size(), 0);
		std::vector < int > ninboth (subjectSampleNames.size(), 0);
		std::vector < int > matches (subjectSampleNames.size(), 0);

		char base;
		char kmerbuffer[querykmersize*2/3];
		char asciibuffer[int(ceil(float(subjectSampleNames.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 verctor of bools

			int nb=0;
			int nq=0;
			int ns=0;
			int m=0;
			int sn=0;
			int js=0;

			while (fileStream.peek()!='\n' && fileStream.get(base)){
				base=toupper(base);
				fileStream.read(kmerbuffer, sizeof(kmerbuffer));
				std::string kmer (kmerbuffer, querykmersize*2/3);

				std::unordered_map < std::string, char >::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=='N' && base=='N'){
						nb++;
					}
					else if (it->second=='N'){
						nq++;
					}
					else if (base=='N'){
						ns++;
					}
					else if (it->second==base){
						m++;
					}
					else {
						sn++;
					}
				}
				else {
					js++;
				}
	    	}
	    	for (int i=0; i<subjectSampleNames.size(); ++i){ //add the base to all samples that are true in the bitset
				if (mybits[i]){
					ninboth[i]+=nb;
					ninquery[i]+=nq;
					ninsubject[i]+=ns;
					matches[i]+=m;
					snps[i]+=sn;
					kmerjustinsubject[i]+=js;
				}
			}
	    	fileStream.ignore(256,'\n');//skip the end ofline character
	    }
		fileStream.close();
		
		for (int i=0; i<subjectSampleNames.size(); ++i){

			int kmerjustinquery=kmerMap.size()-(matches[i]+snps[i]+ninquery[i]+ninboth[i]+ninsubject[i]);
			float percentmatchquery=float(matches[i]+snps[i]+ninquery[i]+ninboth[i])/(kmerjustinquery+matches[i]+snps[i]+ninquery[i]+ninboth[i])*100;
			float percentmatchsubject=float(matches[i]+snps[i]+ninsubject[i]+ninboth[i])/(kmerjustinsubject[i]+matches[i]+snps[i]+ninsubject[i]+ninboth[i])*100;
			float percentidofmatches=float(matches[i])/(matches[i]+snps[i])*100;
			float percentidofquery=(percentidofmatches*percentmatchquery)/100;
			float percentidofsubject=(percentidofmatches*percentmatchsubject)/100;
			
			std::cout << subjectSampleNames[i] << "\t" << kmerjustinquery << "\t" << kmerjustinsubject[i] << "\t" << (matches[i]+snps[i]+ninquery[i]+ninboth[i]+ninsubject[i]) << "\t" << percentmatchquery << "\t" << percentmatchsubject << "\t" << snps[i] << "\t" << percentidofmatches << "\t" << percentidofquery << "\t" << percentidofsubject << "\t" << ninquery[i] << "\t" << ninsubject[i] << "\t" << ninboth[i] << std::endl;

		}
	}
	return 0;
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rsi, -0xa8(%rbp)
movq %rdi, %rbx
leaq -0x1d8(%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)
movaps %xmm0, -0x120(%rbp)
movq $0x0, -0x110(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x5410
leaq -0x410(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x7f73
movl $0x1, %ebx
testl %eax, %eax
jne 0xfdcd
leaq -0x410(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0x96e2
movq %rsp, -0x1b8(%rbp)
movl -0x3c(%rbp), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rbx # imm = 0x55555556
movq %rbx, %rax
shrq $0x3f, %rax
shrq $0x20, %rbx
addl %eax, %ebx
leaq 0xf(%rbx), %rax
andq $-0x10, %rax
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq -0x118(%rbp), %rax
subq -0x120(%rbp), %rax
sarq $0x5, %rax
js 0xf0b7
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xf0cf
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x245a9(%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, -0x78(%rbp)
movq %rdx, -0x48(%rbp)
leaq (%rdx,%rcx), %rax
movq %rax, -0x50(%rbp)
leaq -0x90(%rbp), %r12
leaq -0x410(%rbp), %r13
leaq -0xc8(%rbp), %r15
movq %r14, -0x38(%rbp)
movq %r13, %rdi
movq -0x48(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xf2ca
leaq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x862a
movq %r13, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0xf28d
movq %r13, %rdi
leaq -0x2a(%rbp), %rsi
callq 0x5500
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xf28d
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x5480
movl -0x3c(%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 -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
addq %r14, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x862a
leaq -0x208(%rbp), %rdi
movq %r15, %rsi
callq 0x101f6
testq %rax, %rax
je 0xf1ef
movb $0x4e, 0x28(%rax)
jmp 0xf262
movq %r13, %r14
movq %r15, %r13
movq %rbx, %r15
movq %r12, %rbx
movq %r12, -0xa0(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x859a
movb -0x2a(%rbp), %al
movb %al, -0x80(%rbp)
leaq -0x208(%rbp), %rdi
movq %r12, %rsi
callq 0x102f2
movq -0xa0(%rbp), %rdi
movq %rbx, %r12
cmpq %rbx, %rdi
je 0xf255
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x53c0
movq %r15, %rbx
movq %r13, %r15
movq %r14, %r13
movq -0x38(%rbp), %r14
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xf15e
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xf15e
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
movl $0xa, %edx
callq 0x5220
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0xf11a
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xf11a
movq -0x120(%rbp), %rbx
movq -0x118(%rbp), %r14
cmpq %rbx, %r14
je 0xf30c
leaq 0x10(%rbx), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xf2f5
movq (%r15), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%r15), %rax
addq $0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0xf2e1
movq %rbx, -0x118(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x50b0
movq 0x31ca1(%rip), %rbx     # 0x40fc0
leaq 0x244b9(%rip), %rsi     # 0x337df
movl $0xdb, %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 0x31c6f(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0xa8(%rbp), %rax
movq (%rax), %rsi
cmpq %rsi, 0x8(%rax)
setne %r15b
je 0xfdbf
leaq -0x410(%rbp), %rbx
leaq -0x70(%rbp), %r12
leaq -0xa0(%rbp), %r13
xorl %r14d, %r14d
movq %r14, -0x1c8(%rbp)
shlq $0x5, %r14
addq %r14, %rsi
movq %rbx, %rdi
movl $0x8, %edx
callq 0x5350
movq -0x410(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x3f0(%rbp,%rax)
jne 0xfccc
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movq %rbx, %rdi
leaq -0xfc(%rbp), %rsi
movq %r12, %rdx
callq 0x96e2
movl -0xfc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0xfd59
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x5, %rsi
movl $0x0, -0xa0(%rbp)
leaq -0x1b0(%rbp), %rdi
movq %r13, %rdx
leaq -0xe8(%rbp), %r14
movq %r14, %rcx
callq 0x100da
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x5, %rsi
movl $0x0, -0xa0(%rbp)
leaq -0x180(%rbp), %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x100da
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x5, %rsi
movl $0x0, -0xa0(%rbp)
leaq -0x168(%rbp), %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x100da
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x5, %rsi
movl $0x0, -0xa0(%rbp)
leaq -0x150(%rbp), %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x100da
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x5, %rsi
movl $0x0, -0xa0(%rbp)
leaq -0x138(%rbp), %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x100da
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x5, %rsi
movl $0x0, -0xa0(%rbp)
leaq -0x198(%rbp), %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x100da
movq %rsp, -0x1c0(%rbp)
movl -0x3c(%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 0xf532
cvtsi2ss %rax, %xmm0
jmp 0xf547
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x24131(%rip), %xmm0    # 0x33680
callq 0x51e0
cvttss2si %xmm0, %ecx
leaq 0xf(%rcx), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
movq %rcx, -0xf8(%rbp)
leaq (%r15,%rcx), %rax
movq %rax, -0xf0(%rbp)
movq %r15, -0x1d0(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
movq -0xf8(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xf838
leaq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq %r14, %rdi
movq %r15, %rsi
movq -0xf0(%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 %r14, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x89ef
movl $0x0, -0x38(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x30(%rbp)
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0xf720
movq %rbx, %rdi
leaq -0x29(%rbp), %rsi
callq 0x5500
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xf720
movsbl -0x29(%rbp), %edi
callq 0x56d0
movb %al, -0x29(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
movq -0x48(%rbp), %rdx
callq 0x5480
movl -0x3c(%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 -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
addq %r13, %rdx
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x862a
leaq -0x208(%rbp), %rdi
movq %r12, %rsi
callq 0x101f6
testq %rax, %rax
je 0xf6d1
movb 0x28(%rax), %al
movl %eax, %edx
xorb $0x4e, %dl
movb -0x29(%rbp), %cl
movl %ecx, %esi
xorb $0x4e, %sil
orb %dl, %sil
jne 0xf6d6
incl %r15d
jmp 0xf6f5
incl %r14d
jmp 0xf6f5
cmpb $0x4e, %al
jne 0xf6df
incl -0x38(%rbp)
jmp 0xf6f5
cmpb $0x4e, %cl
jne 0xf6e9
incl -0x78(%rbp)
jmp 0xf6f5
cmpb %cl, %al
jne 0xf6f2
incl -0x50(%rbp)
jmp 0xf6f5
incl -0x30(%rbp)
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xf617
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xf617
movq -0x68(%rbp), %rax
subq -0x70(%rbp), %rax
je 0xf7ae
sarq $0x5, %rax
movq -0xa0(%rbp), %rcx
movq -0x138(%rbp), %rdx
movq -0x150(%rbp), %rsi
movq -0x168(%rbp), %rdi
movq -0x198(%rbp), %r8
movq -0x180(%rbp), %r9
movq -0x1b0(%rbp), %r10
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %ebx, %ebx
movq %rbx, %r11
shrq $0x6, %r11
movq (%rcx,%r11,8), %r11
btq %rbx, %r11
jae 0xf7a6
addl %r15d, (%rdx,%rbx,4)
movl -0x38(%rbp), %r11d
addl %r11d, (%rsi,%rbx,4)
movl -0x78(%rbp), %r11d
addl %r11d, (%rdi,%rbx,4)
movl -0x50(%rbp), %r11d
addl %r11d, (%r8,%rbx,4)
movl -0x30(%rbp), %r11d
addl %r11d, (%r9,%rbx,4)
addl %r14d, (%r10,%rbx,4)
incq %rbx
cmpq %rbx, %rax
jne 0xf76d
movl $0x100, %esi            # imm = 0x100
leaq -0x410(%rbp), %rbx
movq %rbx, %rdi
movl $0xa, %edx
callq 0x5220
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
leaq -0xe8(%rbp), %r14
movq -0x1d0(%rbp), %r15
je 0xf80d
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 -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0xf582
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xf582
movq %rbx, %rdi
callq 0x50b0
movq -0x70(%rbp), %rax
cmpq %rax, -0x68(%rbp)
je 0xfbd8
xorl %edx, %edx
movq $0x0, -0x78(%rbp)
movl -0x1f0(%rbp), %r15d
movq -0x198(%rbp), %rcx
movl (%rcx,%rdx), %esi
movq -0x180(%rbp), %rcx
movl (%rcx,%rdx), %edi
movl %esi, -0xf0(%rbp)
addl %esi, %edi
movq -0x150(%rbp), %rcx
movl (%rcx,%rdx), %r14d
movq -0x138(%rbp), %rcx
movl (%rcx,%rdx), %ecx
movq %rdi, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
leal (%rcx,%rdi), %r12d
movq -0x168(%rbp), %rcx
movl (%rcx,%rdx), %ebx
leal (%r12,%rbx), %esi
movq -0x1b0(%rbp), %rcx
movl (%rcx,%rdx), %ecx
movl %esi, -0x30(%rbp)
addl %esi, %ecx
movl %ecx, -0xf8(%rbp)
movq (%rax,%rdx,8), %rsi
movq %rdx, -0x38(%rbp)
movq 0x8(%rax,%rdx,8), %rdx
movq 0x316ed(%rip), %rdi     # 0x40fc0
callq 0x5420
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x249c7(%rip), %rsi     # 0x342b1
callq 0x5420
addl %r14d, %r12d
addl %r12d, %ebx
subl %ebx, %r15d
movq %r13, %rdi
movl %r15d, %esi
callq 0x5690
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2499c(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x1b0(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx), %esi
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2496f(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x198(%rbp), %rax
movq -0x180(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl (%rcx,%rdx), %esi
addl (%rax,%rdx), %esi
movq -0x150(%rbp), %rax
addl (%rax,%rdx), %esi
movq -0x138(%rbp), %rax
addl (%rax,%rdx), %esi
movq -0x168(%rbp), %rax
addl (%rax,%rdx), %esi
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2491a(%rip), %rsi     # 0x342b1
callq 0x5420
cvtsi2ss %r12d, %xmm1
addl -0x50(%rbp), %r14d
addl -0x48(%rbp), %r14d
addl %r15d, %r14d
cvtsi2ss %r14d, %xmm0
divss %xmm0, %xmm1
mulss 0x23cbf(%rip), %xmm1    # 0x3367c
movss %xmm1, -0x50(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %r13, %rdi
callq 0x5610
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x248ce(%rip), %rsi     # 0x342b1
callq 0x5420
xorps %xmm1, %xmm1
cvtsi2ssl -0x30(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2ssl -0xf8(%rbp), %xmm0
divss %xmm0, %xmm1
mulss 0x23c75(%rip), %xmm1    # 0x3367c
movss %xmm1, -0x30(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %r15, %rdi
callq 0x5610
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x24884(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x180(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx), %esi
movq %r15, %rdi
callq 0x5690
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x24857(%rip), %rsi     # 0x342b1
callq 0x5420
xorps %xmm1, %xmm1
cvtsi2ssl -0xf0(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2ssl -0x48(%rbp), %xmm0
divss %xmm0, %xmm1
mulss 0x23bfe(%rip), %xmm1    # 0x3367c
movss %xmm1, -0x48(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %r15, %rdi
callq 0x5610
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2480d(%rip), %rsi     # 0x342b1
callq 0x5420
movss -0x50(%rbp), %xmm0
mulss -0x48(%rbp), %xmm0
divss 0x23bc1(%rip), %xmm0    # 0x3367c
cvtss2sd %xmm0, %xmm0
movq %r15, %rdi
callq 0x5610
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x247d8(%rip), %rsi     # 0x342b1
callq 0x5420
movss -0x48(%rbp), %xmm0
mulss -0x30(%rbp), %xmm0
divss 0x23b8c(%rip), %xmm0    # 0x3367c
cvtss2sd %xmm0, %xmm0
movq %r15, %rdi
callq 0x5610
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x247a3(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x150(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx), %esi
movq %r15, %rdi
callq 0x5690
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x24776(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x168(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx), %esi
movq %r15, %rdi
callq 0x5690
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x24749(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x138(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx), %esi
movq %r15, %rdi
callq 0x5690
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x78(%rbp), %rdi
incq %rdi
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
movq -0x38(%rbp), %rdx
addq $0x4, %rdx
movq %rdi, -0x78(%rbp)
cmpq %rdi, %rcx
ja 0xf858
movq -0x1c0(%rbp), %rsp
movq -0x198(%rbp), %rdi
testq %rdi, %rdi
je 0xfbfa
movq -0x188(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x138(%rbp), %rdi
testq %rdi, %rdi
leaq -0x70(%rbp), %r12
leaq -0xa0(%rbp), %r13
movq -0x1c8(%rbp), %r14
je 0xfc27
movq -0x128(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x150(%rbp), %rdi
testq %rdi, %rdi
je 0xfc42
movq -0x140(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x168(%rbp), %rdi
testq %rdi, %rdi
leaq -0x410(%rbp), %rbx
je 0xfc64
movq -0x158(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x180(%rbp), %rdi
testq %rdi, %rdi
je 0xfc7f
movq -0x170(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x1b0(%rbp), %rdi
testq %rdi, %rdi
je 0xfc9a
movq -0x1a0(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r12, %rdi
callq 0xabee
incq %r14
movq -0xa8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r14, %rax
seta %r15b
ja 0xf38b
jmp 0xfdbf
movq 0x3131d(%rip), %rdi     # 0x40ff0
leaq 0x2375d(%rip), %rsi     # 0x33437
movl $0xf, %edx
callq 0x5420
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
movq 0x312f2(%rip), %rdi     # 0x40ff0
callq 0x5420
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
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
jmp 0xfdbf
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
movq 0x3124d(%rip), %rdi     # 0x40fc0
callq 0x5420
movq %rax, %rbx
leaq 0x23b8c(%rip), %rsi     # 0x3390e
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 -0x70(%rbp), %rdi
callq 0xabee
movzbl %r15b, %ebx
andl $0x1, %ebx
movq -0x1b8(%rbp), %rsp
leaq -0x410(%rbp), %rdi
callq 0x50d0
leaq -0x120(%rbp), %rdi
callq 0xabee
leaq -0x208(%rbp), %rdi
callq 0x10158
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfe38
jmp 0xfee3
movq %rax, %r12
jmp 0x100ba
jmp 0xfee3
jmp 0xfee3
jmp 0xffa1
movq %rax, %r12
jmp 0x1001e
movq %rax, %r12
jmp 0x1006f
movq %rax, %r12
jmp 0x10054
movq %rax, %r12
jmp 0x100a5
movq %rax, %r12
jmp 0x10039
movq %rax, %r12
jmp 0x1008a
movq %rax, %r12
cmpl $0x1, %edx
jne 0x100a5
movq %r12, %rdi
callq 0x5160
movl (%rax), %ebx
movq 0x31183(%rip), %rdi     # 0x40ff0
leaq 0x23a47(%rip), %rsi     # 0x338bb
movl $0x28, %edx
callq 0x5420
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
movq 0x31158(%rip), %rdi     # 0x40ff0
callq 0x5420
movq %rax, %r14
leaq 0x23a3d(%rip), %rsi     # 0x338e4
movl $0x29, %edx
movq %rax, %rdi
callq 0x5420
movq %r14, %rdi
movl %ebx, %esi
callq 0x5690
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0xfdb6
movq %rax, %r12
callq 0x5630
jmp 0x100a5
jmp 0xfee3
jmp 0xff4a
jmp 0xfee3
movq %rax, %r12
jmp 0x100ae
movq %rax, %r12
movq -0xa0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xff24
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xff24
jmp 0xff21
jmp 0xffa6
jmp 0xffa1
jmp 0xffa6
jmp 0xffa1
movq %rax, %r12
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xff4d
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xff4d
jmp 0xff4a
movq %rax, %r12
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x100ae
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x100ae
jmp 0xffa6
movq %rax, %r12
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xffa9
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0xffa9
movq %rax, %r12
jmp 0x10003
movq %rax, %r12
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0xffe1
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 -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x10003
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x198(%rbp), %rdi
testq %rdi, %rdi
je 0x1001e
movq -0x188(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x138(%rbp), %rdi
testq %rdi, %rdi
je 0x10039
movq -0x128(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x150(%rbp), %rdi
testq %rdi, %rdi
je 0x10054
movq -0x140(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x168(%rbp), %rdi
testq %rdi, %rdi
je 0x1006f
movq -0x158(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x180(%rbp), %rdi
testq %rdi, %rdi
je 0x1008a
movq -0x170(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq -0x1b0(%rbp), %rdi
testq %rdi, %rdi
je 0x100a5
movq -0x1a0(%rbp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq -0x70(%rbp), %rdi
callq 0xabee
leaq -0x410(%rbp), %rdi
callq 0x50d0
leaq -0x120(%rbp), %rdi
callq 0xabee
leaq -0x208(%rbp), %rdi
callq 0x10158
movq %r12, %rdi
callq 0x56a0