// File: /workspace/github_cpp_makefile_star2_O3/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 $0x108, %rsp            # imm = 0x108
movq %rsi, 0x20(%rsp)
movq %rdi, 0x48(%rsp)
movq 0x10(%rdi), %r15
leaq 0x10(%rsp), %r12
movslq %edx, %rax
movq %rax, 0x50(%rsp)
leaq 0xc8(%rsp), %rbx
testq %r15, %r15
je 0xe2eb
movq %r12, (%rsp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
movq %rsp, %r14
movq %r14, %rdi
callq 0x8566
movq %r14, %rdi
callq 0x6a7b
movl %eax, %r14d
testl %eax, %eax
jne 0xe2c5
movl $0x0, 0x60(%rsp)
xorl %eax, %eax
movq %rax, 0x68(%rsp)
leaq 0x60(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movq %rcx, 0x78(%rsp)
movq %rax, 0x80(%rsp)
movq 0x30(%r15), %rax
testq %rax, %rax
je 0xe2a3
movq 0x28(%r15), %rcx
movq %rcx, %r12
cmpb $0x2d, (%r12)
je 0xe114
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0xed04
movq 0x28(%r15), %rcx
movq 0x30(%r15), %rax
incq %r12
leaq (%rcx,%rax), %rdx
cmpq %rdx, %r12
jne 0xe0f8
movq 0x70(%rsp), %r12
leaq 0x60(%rsp), %rax
cmpq %rax, %r12
je 0xe2a3
movb $0x0, 0xc8(%rsp)
leaq 0x88(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %rbx, %rdx
leaq 0x28(%rsp), %rcx
callq 0xabec
movq 0x30(%r15), %rsi
testq %rsi, %rsi
je 0xe194
movq 0x28(%r15), %rax
movq 0x88(%rsp), %rdx
xorl %ecx, %ecx
movb 0x20(%r12), %dil
cmpb (%rax,%rcx), %dil
jne 0xe18c
movl %ecx, %esi
shrl $0x6, %esi
movl $0x1, %edi
shlq %cl, %rdi
orq %rdi, (%rdx,%rsi,8)
movq 0x30(%r15), %rsi
incq %rcx
cmpq %rsi, %rcx
jne 0xe16c
movsbl 0x20(%r12), %esi
leaq 0x28(%rsp), %rdi
movq %rsp, %rdx
callq 0xebf6
movq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xc07c
testq %rax, %rax
je 0xe1d4
addq $0x30, %rax
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x8528
jmp 0xe25a
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movq $0x0, 0xc0(%rsp)
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x8528
movq %rbx, %r13
movq %rbx, %rdi
leaq 0x88(%rsp), %rsi
movq %rbp, %rdx
callq 0xec76
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0xc360
leaq 0xf0(%rsp), %rdi
callq 0xab8e
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0xe24d
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0xb0(%rsp), %rdi
callq 0xab8e
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xe276
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xe293
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r12, %rdi
callq 0x5430
movq %rax, %r12
jmp 0xe125
movq (%r15), %r12
movq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0xc7ce
leaq 0x58(%rsp), %rdi
callq 0xecb4
movq %r12, %r15
leaq 0x10(%rsp), %r12
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0xe2db
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53c0
testl %r14d, %r14d
je 0xe088
movl $0x1, %eax
jmp 0xe2ed
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe331
movq %rax, %rbx
jmp 0xe39c
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xab6e
jmp 0xe320
jmp 0xe31d
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xab8e
jmp 0xe348
jmp 0xe331
movq %rax, %rbx
leaq 0x10(%rsp), %r12
jmp 0xe392
movq %rax, %rbx
leaq 0x10(%rsp), %r12
jmp 0xe369
movq %rax, %rbx
leaq 0x10(%rsp), %r12
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xe369
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xe392
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq $0x0, 0x88(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xecb4
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0xe3b2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %rbx, %rdi
callq 0x56a0