// File: /workspace/github_cpp_makefile_star2_O2/simonrharris[P]SKA/src/sk_alleles.cpp
// Function: reverseKmerMap(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<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>>>>>&, std::unordered_map<std::vector<bool, std::allocator<bool>>, 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>>>>, std::hash<std::vector<bool, std::allocator<bool>>>, std::equal_to<std::vector<bool, std::allocator<bool>>>, std::allocator<std::pair<std::vector<bool, std::allocator<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>>>>>>>&, int)
int reverseKmerMap(std::unordered_map < std::string, std::string > & myKmerMap, std::unordered_map < std::vector < bool >, std::vector < std::string > > & myRevKmerMap, const int alleleCount){
	std::unordered_map < std::string, std::string >::iterator kmit = myKmerMap.begin();
	std::unordered_map < std::string, std::string >::iterator endKmit = myKmerMap.end();
	int kmercount = 0;
	for (; kmit!=endKmit; ){
		std::string kmer=kmit->first;
		if(ascii_codons(kmer)){return 1;}
		std::set < char > mybases;
		for (std::string::iterator it2=kmit->second.begin(); it2!=kmit->second.end(); ++it2){
			if (*it2!='-'){
				mybases.insert(*it2);
			}
		}
		for (std::set < char >::iterator it2=mybases.begin(); it2!=mybases.end(); ++it2){
			kmercount++;
			std::vector < bool > baseBitString(alleleCount, false);
			int i=0;
			for (std::string::iterator it3=kmit->second.begin(); it3!=kmit->second.end(); ++it3, ++i){
				if (*it2==*it3){
					baseBitString[i]=true;
				}
			}
			std::string kmerString = *it2 + kmer;
			std::unordered_map < std::vector < bool >,  std::vector < std::string > >::iterator it3 = myRevKmerMap.find(baseBitString);//check if the bitset is in the map
			if ( it3 != myRevKmerMap.end() ){//if the bitset is in the map
				it3->second.push_back(kmerString); //add the kmer
			}
			else {//if the bitset isn't in the map
				std::vector < std::string > myvector; //create a new vector of strings
				myvector.push_back(kmerString); //add the bitset to the vector
				myRevKmerMap.insert(std::make_pair(baseBitString, myvector)); //insert the vector into the map
			}
		}
		myKmerMap.erase(kmit++); //remove kmer from kmerMap to free up memory
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x10(%rdi), %r13
movslq %edx, %rax
movq %rax, 0x18(%rsp)
leaq 0x20(%rsp), %r12
leaq 0xf0(%rsp), %r15
leaq 0xd0(%rsp), %rbp
testq %r13, %r13
je 0xc534
leaq 0x8(%r13), %rsi
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0x5540
movq %rbx, %rdi
callq 0x6674
movl %eax, %ebx
testl %eax, %eax
jne 0xc51d
andl $0x0, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
leaq 0x28(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rax, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movq 0x28(%r13), %rax
movq %rax, %r14
movq 0x30(%r13), %rcx
addq %rax, %rcx
cmpq %rcx, %r14
je 0xc3dd
cmpb $0x2d, (%r14)
je 0xc3d8
movq %r12, %rdi
movq %r14, %rsi
callq 0xcc70
movq 0x28(%r13), %rax
incq %r14
jmp 0xc3b7
movl %ebx, 0x4(%rsp)
movq 0x38(%rsp), %r12
leaq 0x90(%rsp), %rbx
leaq 0x28(%rsp), %rax
cmpq %rax, %r12
je 0xc4f8
movb $0x0, 0x90(%rsp)
movq %r15, %rdi
movq 0x18(%rsp), %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x9140
movq 0x28(%r13), %rbx
movq %rbx, %rax
xorl %r14d, %r14d
leaq (%rbx,%r14), %rcx
movq 0x30(%r13), %rdx
addq %rax, %rdx
cmpq %rdx, %rcx
je 0xc451
movb 0x20(%r12), %dl
cmpb (%rcx), %dl
jne 0xc44c
movq %r15, %rdi
movq %r14, %rsi
callq 0x903c
orq %rdx, (%rax)
movq 0x28(%r13), %rax
incq %r14
jmp 0xc421
movsbl 0x20(%r12), %esi
movq %rbp, %rdi
leaq 0x70(%rsp), %rdx
callq 0xcb85
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0xa6e2
leaq 0x90(%rsp), %rbx
leaq 0x50(%rsp), %r14
testq %rax, %rax
je 0xc494
addq $0x30, %rax
movq %rax, %rdi
movq %rbp, %rsi
callq 0x77fc
jmp 0xc4d8
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x77fc
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xcbe2
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xa9b8
movq %rbx, %rdi
callq 0x9108
movq %r14, %rdi
callq 0x911e
movq %rbp, %rdi
callq 0x5778
movq %r15, %rdi
callq 0x908a
movq %r12, %rdi
callq 0x5460
movq %rax, %r12
jmp 0xc3ee
movq (%r13), %rbx
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0xaec4
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0xcc18
movq %rbx, %r13
movl 0x4(%rsp), %ebx
leaq 0x70(%rsp), %rdi
callq 0x5778
testl %ebx, %ebx
je 0xc364
pushq $0x1
popq %rax
jmp 0xc536
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc574
movq %rax, %rbx
jmp 0xc5a7
jmp 0xc551
movq %rax, %rbx
jmp 0xc566
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x9108
leaq 0x50(%rsp), %rdi
callq 0x911e
jmp 0xc57e
jmp 0xc574
movq %rax, %rbx
jmp 0xc59d
jmp 0xc58d
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x5778
jmp 0xc590
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x908a
leaq 0x20(%rsp), %rdi
callq 0xcc18
leaq 0x70(%rsp), %rdi
callq 0x5778
movq %rbx, %rdi
callq 0x56c0