// File: /workspace/github_cpp_makefile_star2_O2/simonrharris[P]SKA/src/kmers.cpp
// Function: reverseStringKmerMap(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>>>>>>>&)
void reverseStringKmerMap(std::unordered_map < std::string, std::string > & kmerMap, std::unordered_map < std::vector < bool >, std::vector < std::string > > & revKmerMap){

	std::unordered_map < std::string, std::string >::iterator it = kmerMap.begin();
	std::unordered_map < std::string, std::string >::iterator endIter = kmerMap.end();

	for (; it!=endIter; ){

		for (int i=0; i<5; ++i){
			std::string kmer (1, bases[i]);
			kmer+=it->first;
			std::vector < bool > myvb (it->second.length(), false);

			int j=0;
			bool matched=false;
			for (std::string::iterator sit=it->second.begin(); sit!=it->second.end(); ++sit, ++j){
				if (*sit==bases[i]){
					myvb[j]=true;
					matched=true;
				}
			}

			if (matched){
				std::unordered_map < std::vector < bool >, std::vector < std::string > >::iterator it2 = revKmerMap.find(myvb);//check if the bitset is in the map
				if ( it2 != revKmerMap.end() ){//if the bitset is in the map
					it2->second.push_back(kmer); //add the kmer
				}
				else {//if the bitset isn't in the map
					revKmerMap.insert(std::make_pair(myvb, std::vector < std::string > {kmer})); //insert the vector into the map
				}
			}
		}
		kmerMap.erase(it++); //remove kmer from kmerMap to save space
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movq 0x10(%rdi), %r15
leaq 0x2d6f6(%rip), %r13     # 0x364d5
leaq 0x28(%rsp), %r14
leaq 0xc0(%rsp), %rbp
testq %r15, %r15
je 0x8f5e
leaq 0x8(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
cmpq $0x5, %rbx
je 0x8f46
movsbl (%r13,%rbx), %edx
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x5470
movq %r14, %rdi
movq 0x20(%rsp), %rsi
callq 0x5750
movq 0x30(%r15), %rsi
movb $0x0, 0x80(%rsp)
movq %rbp, %rdi
leaq 0x80(%rsp), %rdx
leaq 0x48(%rsp), %rcx
callq 0x9140
movq 0x28(%r15), %r12
xorl %r14d, %r14d
movq %r12, %rax
xorl %ecx, %ecx
leaq (%r12,%r14), %rdx
movq 0x30(%r15), %rsi
addq %rax, %rsi
cmpq %rsi, %rdx
je 0x8e91
movb (%rdx), %dl
cmpb (%r13,%rbx), %dl
jne 0x8e8c
movq %rbp, %rdi
movq %r14, %rsi
callq 0x903c
orq %rdx, (%rax)
movq 0x28(%r15), %rax
movb $0x1, %cl
incq %r14
jmp 0x8e5f
testb $0x1, %cl
leaq 0x28(%rsp), %r14
je 0x8f2e
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0xa6e2
testq %rax, %rax
je 0x8ec2
addq $0x30, %rax
movq %rax, %rdi
movq %r14, %rsi
callq 0x77fc
jmp 0x8f2e
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x5540
movq %r12, %rsi
leaq 0x68(%rsp), %r12
movq %r12, %rdi
pushq $0x1
popq %rdx
leaq 0xf(%rsp), %rcx
callq 0x90ce
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x92b4
movq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %r12
movq %r12, %rsi
callq 0xa9b8
movq %r12, %rdi
callq 0x9108
leaq 0x68(%rsp), %rdi
callq 0x911e
leaq 0x48(%rsp), %rdi
callq 0x5778
movq %rbp, %rdi
callq 0x908a
movq %r14, %rdi
callq 0x5778
incq %rbx
jmp 0x8e00
movq (%r15), %rbx
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xaec4
movq %rbx, %r15
jmp 0x8dec
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9108
jmp 0x8f85
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x911e
jmp 0x8f94
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5778
jmp 0x8fae
jmp 0x8fab
jmp 0x8fab
jmp 0x8fa6
movq %rax, %rbx
jmp 0x8fbb
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x908a
leaq 0x28(%rsp), %rdi
callq 0x5778
movq %rbx, %rdi
callq 0x56c0
nop