// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
movq %rdi, 0xa0(%rsp)
movq 0x10(%rdi), %r15
testq %r15, %r15
je 0xaa24
xorl %r14d, %r14d
leaq 0x36cf9(%rip), %r12     # 0x414c5
leaq 0x10(%rsp), %rbp
xorl %ebx, %ebx
movsbl (%r12,%rbx), %edx
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x1, %esi
leaq 0x40(%rsp), %r13
movq %r13, %rdi
callq 0x5440
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
movq %r13, %rdi
callq 0x5110
movq 0x30(%r15), %rsi
movb $0x0, 0xa8(%rsp)
movq %rbp, %rdi
leaq 0xa8(%rsp), %rdx
leaq 0x80(%rsp), %r13
movq %r13, %rcx
callq 0xac4a
cmpq $0x0, 0x30(%r15)
je 0xa9ac
movq 0x28(%r15), %rax
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
xorl %esi, %esi
movb (%rax,%rcx), %dil
cmpb (%r12,%rbx), %dil
jne 0xa863
movq %rcx, %rsi
shrq $0x6, %rsi
movl $0x1, %edi
shlq %cl, %rdi
orq %rdi, (%rdx,%rsi,8)
movb $0x1, %sil
incq %rcx
cmpq 0x30(%r15), %rcx
jne 0xa843
testb $0x1, %sil
je 0xa9ac
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0xc0e4
testq %rax, %rax
je 0xa89e
addq $0x30, %rax
movq %rax, %rdi
leaq 0x40(%rsp), %rsi
callq 0x855c
jmp 0xa9ac
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x859a
movq %r13, %rsi
movq %rbp, %r13
movl $0x1, %edx
leaq 0x60(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0xab86
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0xad94
movq 0x60(%rsp), %rax
movq %rax, 0xd0(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, 0xd8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0xc3e2
leaq 0xd0(%rsp), %rdi
callq 0xabee
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
movq %r13, %rbp
je 0xa97d
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r14, 0xa8(%rsp)
movl %r14d, 0xb0(%rsp)
movq %r14, 0xb8(%rsp)
movl %r14d, 0xc0(%rsp)
movq %r14, 0xc8(%rsp)
leaq 0x60(%rsp), %rdi
callq 0xabee
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xa9ac
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa9dc
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r14, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movl %r14d, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xa9f8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x53c0
incq %rbx
cmpq $0x5, %rbx
jne 0xa7d3
movq (%r15), %rbx
movq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0xc86a
movq %rbx, %r15
testq %rbx, %rbx
jne 0xa7d1
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0xabce
jmp 0xaa4b
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0xabee
jmp 0xaa5a
movq %rax, %r14
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xaa86
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0xaa86
jmp 0xaa83
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xaabd
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movq %rax, 0x30(%rsp)
jmp 0xaabd
jmp 0xaaba
movq %rax, %r14
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xaad9
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r14, %rdi
callq 0x56a0
nop