// File: /workspace/github_cpp_makefile_star2_O1/simonrharris[P]SKA/src/sk_weed.cpp
// Function: weedKmers(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::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, float, float, int, int)
int weedKmers(const std::vector < std::string > & weedfiles, const std::string & kmerfile, const float minproportion, const float maxproportion, int minsamples, int maxsamples)
{

	const std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
	// Create the kmer map
	std::set < std::string > kmerSet;
	
	std::ifstream fileStream;

	

	int kmersize=0;
	char base;
	
	

	if (kmerfile!=""){
		if (openFileStream(kmerfile, fileStream)){return 1;};
		std::vector < std::string > weednames;
		
		readKmerHeader(fileStream, kmersize, weednames);
		char kmerbuffer[kmersize*2/3];
		char asciibuffer[int(ceil(float(weednames.size())/6))];
		
		while (fileStream.read(asciibuffer, sizeof(asciibuffer))){
			std::string asciibits (asciibuffer, sizeof(asciibuffer));
			
			while (fileStream.peek()!='\n' && fileStream.get(base)){
				fileStream.read(kmerbuffer, sizeof(kmerbuffer));
				std::string kmer (kmerbuffer, sizeof(kmerbuffer));
				kmerSet.insert(kmer);
			}
			fileStream.ignore(256,'\n');//skip the end ofline character
	    }
		fileStream.close();
		
		std::cout << kmerSet.size() << " unique kmers in weed set" << std::endl;

		
	}


	std:: vector < std::string > sampleNames;
	if (collectSampleNames(weedfiles, sampleNames)!=0){return 1;}

	if (maxsamples==0){
		maxsamples=sampleNames.size();
	}
	else if (maxsamples>sampleNames.size()){
		std::cerr << "Warning: Maxsamples is greater than the number of samples in your files." << std::endl;
	}
	if (minsamples>sampleNames.size()){
		std::cerr << "Error: Minsamples is greater than the number of samples in your files." << std::endl;
		return 1;
	}

	int myminsamples=std::ceil(minproportion*sampleNames.size());
	int mymaxsamples;
	if (maxproportion==1.0){
		mymaxsamples=sampleNames.size();
	}
	else{
		mymaxsamples=std::floor(maxproportion*sampleNames.size());
	}

	if (myminsamples>minsamples){
		minsamples=myminsamples;
	}
	if (mymaxsamples<maxsamples){
		maxsamples=mymaxsamples;
	}

	if (minsamples>0 || maxsamples<sampleNames.size()){
		if (addKmersByFilters (kmerSet, weedfiles, minsamples, maxsamples, kmersize, sampleNames.size())){return 1;};
		std::cout << kmerSet.size() << " unique kmers in weed set" << std::endl;
	}
	
	int weeded=0;
	int totalweedkmers=0;
	
	for (std::vector < std::string >::const_iterator it = weedfiles.begin(); it != weedfiles.end(); ++it){

		if (openFileStream(*it, fileStream)){return 1;};

		int weedkmersize;
		std::vector < std::string > names;
		
		readKmerHeader(fileStream, weedkmersize, names);
		char kmerbuffer[weedkmersize*2/3];
		
		if (weedkmersize!=kmersize){
			std::cerr << "Files have different kmer sizes" << std::endl << std::endl;
			return 1;
		}
		std::string filename=std::string(*it);
		std::string outputfile=filename.substr(0, filename.find_last_of("."))+".weeded"+filename.substr(filename.find_last_of("."), filename.length());

		std::cout << "Writing weeded kmers to " << outputfile << std::endl;
	
		std::ofstream weededfile(outputfile);
		weededfile << "SKA v" << versionNumber << std::endl;
		weededfile << kmersize << std::endl;
		for ( std::vector < std::string >::iterator it=names.begin(); it!=names.end(); ++it){ //print each sample name to output file stream
			weededfile << *it << " "; 
		}
		weededfile << std::endl;

		bool firstkmer=true;

		char asciibuffer[int(ceil(float(names.size())/6))];
		while (fileStream.read(asciibuffer, sizeof(asciibuffer))){
			std::string asciibits (asciibuffer, sizeof(asciibuffer));
			
			while (fileStream.peek()!='\n' && fileStream.get(base)){
				fileStream.read(kmerbuffer, sizeof(kmerbuffer));
				std::string kmer (kmerbuffer, kmersize*2/3);
				
				std::set < std::string >::iterator it2 = kmerSet.find(kmer);//check if the kmer is in the hash
				if ( it2 == kmerSet.end() ){//if the kmer is not in the hash
					if (firstkmer){//if it's the first kmer, print the ascii bitstring
						weededfile << asciibits;
						firstkmer=false;
					}
					weededfile << base << kmer;//print the kmer
					weeded++;
				}
				totalweedkmers++;
			}
			if (firstkmer==false){
				weededfile << std::endl;
			}
			firstkmer=true;
			fileStream.ignore(256,'\n');//skip the end ofline character
    	}
		fileStream.close();
		weededfile.close();
	}
	std::cout << totalweedkmers << " kmers prior to weeding" << std::endl;
	std::cout << weeded << " kmers remaining after weeding" << std::endl;
	std::cout << totalweedkmers-weeded << " kmers weeded (Note this may be more than the number of kmers in the weed set due to mulitple variants of a kmer being in the file)" << std::endl;

	printDuration(start);
	
	return 0;
	
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x588, %rsp            # imm = 0x588
movl %ecx, %r12d
movl %edx, %r14d
movss %xmm1, -0x108(%rbp)
movss %xmm0, -0xa8(%rbp)
movq %rsi, %rbx
movq %rdi, %r15
callq 0x5060
movq %rax, -0x170(%rbp)
leaq -0x198(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq -0x5a8(%rbp), %rdi
callq 0x5410
movl $0x0, -0x30(%rbp)
leaq 0xf704(%rip), %rsi      # 0x342b2
movq %rbx, %rdi
callq 0x50f0
testl %eax, %eax
je 0x24e4d
leaq -0x5a8(%rbp), %rsi
movl $0x1, %r13d
movq %rbx, %rdi
movl $0x1, %edx
callq 0x7f73
testl %eax, %eax
jne 0x25978
movq %r12, -0x100(%rbp)
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq -0x5a8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x96e2
movq %rsp, -0xa0(%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, %r12
subq %rax, %r12
movq %r12, %rsp
movq -0x68(%rbp), %rax
subq -0x70(%rbp), %rax
sarq $0x5, %rax
movq %r15, -0xf8(%rbp)
movl %r14d, -0x34(%rbp)
js 0x24c63
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x24c7b
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0xe9fd(%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, -0xb0(%rbp)
movq %rdx, -0x40(%rbp)
leaq (%rdx,%rcx), %rax
movq %rax, -0x110(%rbp)
leaq -0xe0(%rbp), %r15
movq -0x48(%rbp), %rax
leaq (%r12,%rax), %rbx
leaq -0x5a8(%rbp), %r13
leaq -0xf0(%rbp), %r14
movq %r13, %rdi
movq -0x40(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x24dce
leaq -0x390(%rbp), %rax
movq %rax, -0x3a0(%rbp)
leaq -0x3a0(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x110(%rbp), %rdx
callq 0x862a
movq %r13, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0x24d91
movq %r13, %rdi
leaq -0x29(%rbp), %rsi
callq 0x5500
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x24d91
movq %r13, %rdi
movq %r12, %rsi
movq -0x48(%rbp), %rdx
callq 0x5480
movq %r15, -0xf0(%rbp)
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x862a
leaq -0x1a0(%rbp), %rdi
movq %r14, %rsi
callq 0xb4ec
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0x24d1a
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24d1a
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
movl $0xa, %edx
callq 0x5220
movq -0x3a0(%rbp), %rdi
leaq -0x390(%rbp), %rax
cmpq %rax, %rdi
je 0x24cd0
movq -0x390(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24cd0
leaq -0x5a8(%rbp), %rdi
callq 0x50b0
movq -0xf8(%rbp), %r15
movl -0x34(%rbp), %r14d
movq -0x178(%rbp), %rsi
movq 0x1c1cd(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %rbx
leaq 0xf9ad(%rip), %rsi      # 0x347af
movl $0x19, %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 -0xa0(%rbp), %rsp
leaq -0x70(%rbp), %rdi
callq 0xabee
movq -0x100(%rbp), %r12
xorps %xmm0, %xmm0
leaq -0x150(%rbp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, %r13d
movq %r15, %rdi
movl $0x1, %edx
callq 0x98af
testl %eax, %eax
jne 0x2596c
testl %r12d, %r12d
je 0x24ee4
movslq %r12d, %rax
movq -0x148(%rbp), %rcx
subq -0x150(%rbp), %rcx
sarq $0x5, %rcx
cmpq %rax, %rcx
jae 0x24ef6
movq 0x1c14d(%rip), %rbx     # 0x40ff0
leaq 0xf91f(%rip), %rsi      # 0x347c9
movl $0x48, %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 0x1c11b(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x24ef6
movq -0x148(%rbp), %r12
subq -0x150(%rbp), %r12
shrq $0x5, %r12
movslq %r14d, %rax
movq -0x148(%rbp), %rbx
subq -0x150(%rbp), %rbx
sarq $0x5, %rbx
cmpq %rax, %rbx
jae 0x24f5b
movq 0x1c0d9(%rip), %rbx     # 0x40ff0
leaq 0xf8f4(%rip), %rsi      # 0x34812
movl $0x46, %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 0x1c0a7(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x2596c
testq %rbx, %rbx
movl %r14d, -0x34(%rbp)
js 0x24f6b
cvtsi2ss %rbx, %xmm1
jmp 0x24f82
movq %rbx, %rax
shrq %rax
movl %ebx, %ecx
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm1
addss %xmm1, %xmm1
movss -0xa8(%rbp), %xmm0
movss %xmm1, -0x48(%rbp)
mulss %xmm1, %xmm0
callq 0x51e0
cvttss2si %xmm0, %r14d
movss -0x108(%rbp), %xmm1
ucomiss 0xe058(%rip), %xmm1     # 0x33004
jne 0x24fb4
jp 0x24fb4
movl %ebx, %eax
jmp 0x24fc6
movss -0x48(%rbp), %xmm0
mulss %xmm1, %xmm0
callq 0x5150
cvttss2si %xmm0, %eax
movl -0x34(%rbp), %edx
cmpl %edx, %r14d
cmovgl %r14d, %edx
cmpl %r12d, %eax
cmovll %eax, %r12d
testl %edx, %edx
jg 0x24fe3
movslq %r12d, %rax
cmpq %rax, %rbx
jbe 0x25055
leaq -0x1a0(%rbp), %rdi
leaq -0x30(%rbp), %r8
movq %r15, %rsi
movl %r12d, %ecx
movl %ebx, %r9d
callq 0x24430
testl %eax, %eax
jne 0x2596c
movq -0x178(%rbp), %rsi
movq 0x1bfae(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %rbx
leaq 0xf78e(%rip), %rsi      # 0x347af
movl $0x19, %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 (%r15), %rax
cmpq 0x8(%r15), %rax
sete -0xa0(%rbp)
je 0x2585b
movq %rax, %rdi
movq 0x1bf3d(%rip), %rax     # 0x40fb0
movq (%rax), %rcx
movq %rcx, -0x160(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x158(%rbp)
xorl %r12d, %r12d
leaq -0x5a8(%rbp), %r14
movl $0x0, -0x40(%rbp)
movq %r15, -0xf8(%rbp)
movq %rdi, -0xa8(%rbp)
movq %r14, %rsi
movl $0x1, %edx
callq 0x7f73
testl %eax, %eax
jne 0x25865
xorps %xmm0, %xmm0
movaps %xmm0, -0x130(%rbp)
movq $0x0, -0x120(%rbp)
movq %r14, %rdi
leaq -0x94(%rbp), %rsi
leaq -0x130(%rbp), %rdx
callq 0x96e2
leaq -0x390(%rbp), %rbx
movq %rsp, %r15
movl -0x94(%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
movl -0x94(%rbp), %eax
movl -0x30(%rbp), %ecx
movl %eax, -0x34(%rbp)
movl %ecx, -0x100(%rbp)
cmpl %ecx, %eax
jne 0x251e4
movq %r15, -0x168(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xa8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
callq 0x859a
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x11284(%rip), %rsi     # 0x36406
movq $-0x1, %rdx
callq 0x5740
movq %r15, %rsi
leaq -0xd0(%rbp), %r15
movq %r15, %rdi
xorl %edx, %edx
movq %rax, %rcx
callq 0x53e0
movq %r15, %rdi
leaq 0xf6aa(%rip), %rsi      # 0x34859
callq 0x5710
movq %rbx, -0x3a0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x25263
movq %rdx, -0x3a0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x390(%rbp)
jmp 0x25269
movl $0x1f, %edx
movq 0x1be00(%rip), %rdi     # 0x40ff0
leaq 0xf598(%rip), %rsi      # 0x3478f
callq 0x5420
movl $0x1, %r13d
movq 0x1bde7(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1bdc9(%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
jmp 0x2581c
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, -0x398(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x1, %ecx
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
leaq 0x1116d(%rip), %rsi     # 0x36406
movq $-0x1, %rdx
callq 0x5740
movq -0xe8(%rbp), %rcx
leaq -0x90(%rbp), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x53e0
movq -0x3a0(%rbp), %rcx
movl $0xf, %esi
cmpq %rbx, %rcx
leaq -0x3a0(%rbp), %rbx
movq 0x1bce5(%rip), %r15     # 0x40fc0
je 0x252e4
movq -0x390(%rbp), %rsi
movq -0x398(%rbp), %r8
movq -0x88(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq -0x90(%rbp), %r9
jbe 0x2531d
movl $0xf, %esi
leaq -0x80(%rbp), %rdi
cmpq %rdi, -0x90(%rbp)
je 0x25318
movq -0x80(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x2532e
movq -0x90(%rbp), %rsi
movq %rbx, %rdi
callq 0x5110
jmp 0x2533a
movq %r9, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5400
leaq -0x60(%rbp), %rsi
movq %rsi, -0x70(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2535b
movq %rdx, -0x70(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x60(%rbp)
jmp 0x25361
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x68(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x25399
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x3a0(%rbp), %rdi
leaq -0x390(%rbp), %rax
cmpq %rax, %rdi
je 0x253bb
movq -0x390(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x253dd
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x53c0
movl $0x18, %edx
movq %r15, %rdi
leaq 0xf475(%rip), %rsi      # 0x34861
callq 0x5420
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r15, %rdi
callq 0x5420
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 %rbx, %rdi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0x5720
movl $0x5, %edx
movq %rbx, %rdi
leaq 0xe92f(%rip), %rsi      # 0x33d7a
callq 0x5420
leaq 0x1c0b9(%rip), %rax     # 0x41510
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x5420
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
movl -0x30(%rbp), %esi
movq %rbx, %rdi
callq 0x5690
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 -0x130(%rbp), %r15
cmpq -0x128(%rbp), %r15
je 0x25502
movq (%r15), %rsi
movq 0x8(%r15), %rdx
leaq -0x3a0(%rbp), %rdi
callq 0x5420
movl $0x1, %edx
movq %rax, %rdi
leaq 0xeea1(%rip), %rsi      # 0x34398
callq 0x5420
addq $0x20, %r15
jmp 0x254cc
movq -0x3a0(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x3a0(%rbp), %rbx
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x128(%rbp), %rax
subq -0x130(%rbp), %rax
sarq $0x5, %rax
js 0x2554f
cvtsi2ss %rax, %xmm0
jmp 0x25564
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
leaq -0xd0(%rbp), %r15
divss 0xe10d(%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, -0x110(%rbp)
movq %rdx, -0xb0(%rbp)
leaq (%rdx,%rcx), %rax
movq %rax, -0x108(%rbp)
movq %r14, %rdi
movq -0xb0(%rbp), %rsi
movq -0x110(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x25787
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq %r15, %rdi
movq -0xb0(%rbp), %rsi
movq -0x108(%rbp), %rdx
callq 0x862a
movb $0x1, %r15b
movq %r14, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0x25707
movq %r14, %rdi
leaq -0x29(%rbp), %rsi
callq 0x5500
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x25707
movq %r14, %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 -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
addq %r13, %rdx
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x862a
leaq -0x1a0(%rbp), %rdi
movq %rbx, %rsi
callq 0xb694
leaq -0x198(%rbp), %rcx
cmpq %rcx, %rax
jne 0x256e3
testb $0x1, %r15b
je 0x256af
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0x3a0(%rbp), %rdi
callq 0x5420
xorl %r15d, %r15d
movb -0x29(%rbp), %al
movb %al, -0x2a(%rbp)
movl $0x1, %edx
leaq -0x3a0(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
callq 0x5420
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %rax, %rdi
callq 0x5420
incl -0x40(%rbp)
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x256ff
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x53c0
incl %r12d
jmp 0x255f5
testb $0x1, %r15b
jne 0x25743
movq -0x3a0(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x3a0(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
leaq -0x3a0(%rbp), %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movl $0xa, %edx
callq 0x5220
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
leaq -0xd0(%rbp), %r15
je 0x255a6
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x255a6
movq %r14, %rdi
callq 0x50b0
leaq -0x3a0(%rbp), %rdi
callq 0x5530
movq -0x160(%rbp), %rax
movq %rax, -0x3a0(%rbp)
movq -0x18(%rax), %rax
movq -0x158(%rbp), %rcx
movq %rcx, -0x3a0(%rbp,%rax)
leaq -0x398(%rbp), %rdi
callq 0x5330
leaq -0x2a8(%rbp), %rdi
callq 0x5120
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
movl $0x1, %r13d
movq -0x168(%rbp), %r15
je 0x257fa
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x2581c
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x53c0
movq %r15, %rsp
leaq -0x130(%rbp), %rdi
callq 0xabee
movl -0x100(%rbp), %eax
cmpl %eax, -0x34(%rbp)
jne 0x25865
movq -0xa8(%rbp), %rdi
addq $0x20, %rdi
movq -0xf8(%rbp), %r15
cmpq 0x8(%r15), %rdi
sete -0xa0(%rbp)
jne 0x250a0
jmp 0x25865
movl $0x0, -0x40(%rbp)
xorl %r12d, %r12d
testb $0x1, -0xa0(%rbp)
je 0x2596c
movq 0x1b747(%rip), %rdi     # 0x40fc0
movl %r12d, %esi
callq 0x5690
movq %rax, %rbx
leaq 0xefef(%rip), %rsi      # 0x3487a
movl $0x17, %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 0x1b6fa(%rip), %rdi     # 0x40fc0
movl -0x40(%rbp), %esi
callq 0x5690
movq %rax, %rbx
leaq 0xefba(%rip), %rsi      # 0x34892
movl $0x1e, %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
subl -0x40(%rbp), %r12d
movq 0x1b6a9(%rip), %rdi     # 0x40fc0
movl %r12d, %esi
callq 0x5690
movq %rax, %rbx
leaq 0xef88(%rip), %rsi      # 0x348b1
movl $0x83, %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
xorl %r13d, %r13d
movq -0x170(%rbp), %rdi
callq 0x8354
leaq -0x150(%rbp), %rdi
callq 0xabee
leaq -0x5a8(%rbp), %rdi
callq 0x50d0
leaq -0x1a0(%rbp), %rdi
callq 0xacb2
movl %r13d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25a42
movq %rax, %rbx
jmp 0x25a01
movq %rax, %rbx
jmp 0x25b27
jmp 0x25a4c
jmp 0x25a3a
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x259df
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x259df
movq %rax, %rbx
movq -0x3a0(%rbp), %rdi
leaq -0x390(%rbp), %rax
cmpq %rax, %rdi
je 0x25a01
movq -0x390(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x25b27
movq -0xc0(%rbp), %rsi
jmp 0x25b1f
jmp 0x25a63
jmp 0x25a42
jmp 0x25a42
movq %rax, %rbx
jmp 0x25b61
movq %rax, %rbx
jmp 0x25b6d
movq %rax, %rbx
jmp 0x25b0e
movq %rax, %rbx
jmp 0x25b55
jmp 0x25a5a
movq %rax, %rbx
jmp 0x25b49
jmp 0x25a63
jmp 0x25ab2
jmp 0x25a5a
movq %rax, %rbx
jmp 0x25ad7
jmp 0x25a63
jmp 0x25a63
movq %rax, %rbx
jmp 0x25b02
jmp 0x25add
jmp 0x25ab2
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0x25ab5
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x25ab5
jmp 0x25add
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x25ae0
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x25ae0
movq %rax, %rbx
movq -0x3a0(%rbp), %rdi
leaq -0x390(%rbp), %rax
cmpq %rax, %rdi
je 0x25ad7
movq -0x390(%rbp), %rsi
incq %rsi
callq 0x53c0
leaq -0x70(%rbp), %rdi
jmp 0x25b5c
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x25b02
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x53c0
leaq -0x3a0(%rbp), %rdi
callq 0x55a0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x25b27
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x25b49
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x53c0
leaq -0x130(%rbp), %rdi
callq 0xabee
leaq -0x150(%rbp), %rdi
callq 0xabee
leaq -0x5a8(%rbp), %rdi
callq 0x50d0
leaq -0x1a0(%rbp), %rdi
callq 0xacb2
movq %rbx, %rdi
callq 0x56a0
nop