// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
movq %rdi, 0x80(%rsp)
movq 0x10(%rdi), %r13
movslq %edx, %rax
movq %rax, 0x88(%rsp)
xorl %r15d, %r15d
leaq 0xd8(%rsp), %rbx
testq %r13, %r13
je 0xe4ad
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x859a
movq %r12, %rdi
callq 0x6ab2
movl %eax, %ebp
testl %eax, %eax
jne 0xe483
movl %ebp, 0xc(%rsp)
movl $0x0, 0x98(%rsp)
movq %r15, 0xa0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
movq %r15, 0xb8(%rsp)
cmpq %r15, 0x30(%r13)
je 0xe2a1
movq 0x28(%r13), %r12
cmpb $0x2d, (%r12)
je 0xe291
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0xeec0
incq %r12
movq 0x28(%r13), %rax
addq 0x30(%r13), %rax
cmpq %rax, %r12
jne 0xe27a
movq 0xa8(%rsp), %r12
leaq 0x98(%rsp), %rax
cmpq %rax, %r12
je 0xe45b
movb $0x0, 0xd8(%rsp)
leaq 0x10(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq %rbx, %rdx
leaq 0x40(%rsp), %rcx
callq 0xac4a
cmpq $0x0, 0x30(%r13)
je 0xe315
movq 0x28(%r13), %rax
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
movb 0x20(%r12), %sil
cmpb (%rax,%rcx), %sil
jne 0xe30c
movq %rcx, %rsi
movl $0x1, %edi
shlq %cl, %rdi
shrq $0x6, %rsi
orq %rdi, (%rdx,%rsi,8)
incq %rcx
cmpq 0x30(%r13), %rcx
jne 0xe2ee
movsbl 0x20(%r12), %esi
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xedb1
movq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xc0e4
testq %rax, %rax
je 0xe354
addq $0x30, %rax
movq %rax, %rdi
leaq 0x40(%rsp), %rsi
callq 0x855c
jmp 0xe3ff
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movq $0x0, 0xd0(%rsp)
leaq 0xc0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x855c
movq %rbx, %r14
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
movq %rbp, %rdx
callq 0xee32
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0xc3e2
leaq 0x100(%rsp), %rdi
callq 0xabee
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0xe3f2
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r15, 0xd8(%rsp)
movl %r15d, 0xe0(%rsp)
movq %r15, 0xe8(%rsp)
movl %r15d, 0xf0(%rsp)
movq %r15, 0xf8(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xabee
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xe41b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xe44b
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r15, 0x10(%rsp)
movl %r15d, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl %r15d, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq %r12, %rdi
callq 0x5430
movq %rax, %r12
jmp 0xe2a9
movq (%r13), %r12
movq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0xc86a
leaq 0x90(%rsp), %rdi
callq 0xee70
movq %r12, %r13
movl 0xc(%rsp), %ebp
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xe49f
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x53c0
testl %ebp, %ebp
je 0xe1fc
movl $0x1, %r15d
movl %r15d, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe4f4
movq %rax, %rbx
jmp 0xe55a
jmp 0xe4e0
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0xabce
jmp 0xe4e3
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xabee
jmp 0xe501
jmp 0xe4f4
movq %rax, %rbx
jmp 0xe54d
movq %rax, %rbx
jmp 0xe51d
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xe51d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xe54d
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)
leaq 0x90(%rsp), %rdi
callq 0xee70
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xe576
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %rbx, %rdi
callq 0x56a0