// File: 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
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xff80
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0xf7c0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xf790
testb $0x1, %al
jne 0xe723
jmp 0xec84
movl $0x0, -0x24(%rbp)
cmpl $0x5, -0x24(%rbp)
jge 0xec48
movslq -0x24(%rbp), %rcx
leaq 0x6aed6(%rip), %rax     # 0x79615
movsbl (%rax,%rcx), %eax
movl %eax, -0x18c(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x6910
movl -0x18c(%rbp), %edx
movq -0x188(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x9150
jmp 0xe776
leaq -0x49(%rbp), %rdi
callq 0x65a0
leaq -0x18(%rbp), %rdi
callq 0xf880
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x66a0
jmp 0xe796
leaq -0x18(%rbp), %rdi
callq 0xf880
movq %rax, %rdi
addq $0x20, %rdi
callq 0x67e0
movq %rax, -0x1a0(%rbp)
movb $0x0, -0x89(%rbp)
leaq -0x8a(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0xf380
movq -0x1a0(%rbp), %rsi
movq -0x198(%rbp), %rcx
leaq -0x88(%rbp), %rdi
leaq -0x89(%rbp), %rdx
callq 0xffb0
jmp 0xe7ef
leaq -0x8a(%rbp), %rdi
callq 0xf3e0
movl $0x0, -0x90(%rbp)
movb $0x0, -0x91(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xf880
movq %rax, %rdi
addq $0x20, %rdi
callq 0x64a0
movq %rax, -0xa0(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xf880
movq %rax, %rdi
addq $0x20, %rdi
callq 0x62e0
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x90d0
testb $0x1, %al
jne 0xe860
jmp 0xe95a
leaq -0xa0(%rbp), %rdi
callq 0x9110
movsbl (%rax), %eax
movslq -0x24(%rbp), %rdx
leaq 0x6ad9b(%rip), %rcx     # 0x79615
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xe938
movslq -0x90(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0xedc0
movq %rdx, -0x1b0(%rbp)
movq %rax, -0x1a8(%rbp)
jmp 0xe8a9
movq -0x1b0(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movq %rax, -0xb0(%rbp)
leaq -0xb8(%rbp), %rdi
movl $0x1, %esi
callq 0xee20
movb $0x1, -0x91(%rbp)
jmp 0xe938
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x65a0
jmp 0xec8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xec3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x8a(%rbp), %rdi
callq 0xf3e0
jmp 0xec3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xec31
jmp 0xe93a
leaq -0xa0(%rbp), %rdi
callq 0x9130
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0xe828
testb $0x1, -0x91(%rbp)
je 0xec0e
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xfc80
movq %rax, -0x1b8(%rbp)
jmp 0xe980
movq -0x1b8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xfce0
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xf0f0
testb $0x1, %al
jne 0xe9b7
jmp 0xe9da
leaq -0xc0(%rbp), %rdi
callq 0xfd10
movq %rax, %rdi
addq $0x28, %rdi
leaq -0x48(%rbp), %rsi
callq 0xabd0
jmp 0xe9d5
jmp 0xec0c
movq -0x10(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x150(%rbp), %rdi
movq %rdi, -0x158(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x6230
jmp 0xe9fe
leaq -0x150(%rbp), %rax
movq %rax, -0x130(%rbp)
movq $0x1, -0x128(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0xfdc0
movq -0x1c8(%rbp), %rcx
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0xfde0
jmp 0xea4d
leaq -0x108(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0xfd80
jmp 0xea69
movq -0x1c0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xfd40
movb %dl, -0x1d1(%rbp)
movq %rax, -0x1d0(%rbp)
jmp 0xea8b
movb -0x1d1(%rbp), %al
movq -0x1d0(%rbp), %rcx
movq %rcx, -0x170(%rbp)
movb %al, -0x168(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xfe60
leaq -0x120(%rbp), %rdi
callq 0xfe90
leaq -0x159(%rbp), %rdi
callq 0xfef0
leaq -0x150(%rbp), %rax
movq %rax, -0x1e8(%rbp)
addq $0x20, %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x6a08
movq -0x1e8(%rbp), %rcx
movq -0x1f0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1e0(%rbp)
jne 0xeae2
jmp 0xec0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movq -0x158(%rbp), %rax
leaq -0x150(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x1f8(%rbp)
je 0xeb6f
movq -0x1f8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x200(%rbp)
callq 0x6a08
movq -0x200(%rbp), %rax
leaq -0x150(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x1f8(%rbp)
jne 0xeb3e
jmp 0xec31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xebb4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xeba8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xfe60
leaq -0x120(%rbp), %rdi
callq 0xfe90
leaq -0x159(%rbp), %rdi
callq 0xfef0
leaq -0x150(%rbp), %rax
movq %rax, -0x210(%rbp)
addq $0x20, %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x218(%rbp)
callq 0x6a08
movq -0x210(%rbp), %rcx
movq -0x218(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x208(%rbp)
jne 0xebd9
jmp 0xec31
jmp 0xec0e
leaq -0x88(%rbp), %rdi
callq 0xf720
leaq -0x48(%rbp), %rdi
callq 0x6a08
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xe72a
leaq -0x88(%rbp), %rdi
callq 0xf720
leaq -0x48(%rbp), %rdi
callq 0x6a08
jmp 0xec8d
movq -0x8(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x10070
movq -0x220(%rbp), %rdi
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rsi
callq 0x10030
movq %rax, -0x180(%rbp)
jmp 0xe70d
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x6900
nopw %cs:(%rax,%rax)