// File: 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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xff80
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf7c0
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xf790
testb $0x1, %al
jne 0x1c6ed
jmp 0x1cc48
leaq -0x28(%rbp), %rdi
callq 0xf880
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x6230
movq -0x1d0(%rbp), %rdi
callq 0x8100
movl %eax, -0x1c4(%rbp)
jmp 0x1c71d
movl -0x1c4(%rbp), %eax
cmpl $0x0, %eax
je 0x1c74c
movl $0x1, -0x4(%rbp)
movl $0x1, -0x68(%rbp)
jmp 0x1cc18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1cc3d
leaq -0x98(%rbp), %rdi
callq 0x1d550
leaq -0x28(%rbp), %rdi
callq 0xf880
movq %rax, %rdi
addq $0x20, %rdi
callq 0x64a0
movq %rax, -0xa0(%rbp)
leaq -0x28(%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 0x1c7a9
jmp 0x1c827
leaq -0xa0(%rbp), %rdi
callq 0x9110
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x1c814
leaq -0xa0(%rbp), %rdi
callq 0x9110
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x1d570
movb %dl, -0x1d9(%rbp)
movq %rax, -0x1d8(%rbp)
jmp 0x1c7e7
movb -0x1d9(%rbp), %al
movq -0x1d8(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movb %al, -0xb0(%rbp)
jmp 0x1c814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1cc31
jmp 0x1c816
leaq -0xa0(%rbp), %rdi
callq 0x9130
jmp 0x1c774
leaq -0x98(%rbp), %rdi
callq 0x1d5c0
movq %rax, -0xc0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x1d620
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x1d5f0
testb $0x1, %al
jne 0x1c869
jmp 0x1cbbe
movl -0x34(%rbp), %eax
incl %eax
movl %eax, -0x34(%rbp)
movslq -0x1c(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movb $0x0, -0xf1(%rbp)
leaq -0xf2(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0xf380
movq -0x1f0(%rbp), %rsi
movq -0x1e8(%rbp), %rcx
leaq -0xf0(%rbp), %rdi
leaq -0xf1(%rbp), %rdx
callq 0xffb0
jmp 0x1c8b9
leaq -0xf2(%rbp), %rdi
callq 0xf3e0
movl $0x0, -0xf8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xf880
movq %rax, %rdi
addq $0x20, %rdi
callq 0x64a0
movq %rax, -0x100(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xf880
movq %rax, %rdi
addq $0x20, %rdi
callq 0x62e0
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x90d0
testb $0x1, %al
jne 0x1c923
jmp 0x1c9fa
leaq -0xc0(%rbp), %rdi
callq 0x1d650
movsbl (%rax), %eax
movl %eax, -0x1f4(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x9110
movq %rax, %rcx
movl -0x1f4(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x1c9d8
movslq -0xf8(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0xedc0
movq %rdx, -0x208(%rbp)
movq %rax, -0x200(%rbp)
jmp 0x1c97b
movq -0x208(%rbp), %rax
movq -0x200(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movq %rax, -0x110(%rbp)
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
callq 0xee20
jmp 0x1c9d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf2(%rbp), %rdi
callq 0xf3e0
jmp 0x1cc31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1cbb0
jmp 0x1c9da
leaq -0x100(%rbp), %rdi
callq 0x9130
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x1c8eb
leaq -0xc0(%rbp), %rdi
callq 0x1d650
movsbl (%rax), %esi
leaq -0x138(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x1d670
jmp 0x1ca1b
movq -0x18(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xfc80
movq %rax, -0x210(%rbp)
jmp 0x1ca34
movq -0x210(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x18(%rbp), %rdi
callq 0xfce0
movq %rax, -0x148(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0xf0f0
testb $0x1, %al
jne 0x1ca6b
jmp 0x1caa2
leaq -0x140(%rbp), %rdi
callq 0xfd10
movq %rax, %rdi
addq $0x28, %rdi
leaq -0x138(%rbp), %rsi
callq 0xabd0
jmp 0x1ca8c
jmp 0x1cb7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1cba4
leaq -0x160(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x1ab40
movq -0x218(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xabd0
jmp 0x1caca
movq -0x18(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0x1d770
jmp 0x1caf1
movq -0x220(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0xfd40
movb %dl, -0x229(%rbp)
movq %rax, -0x228(%rbp)
jmp 0x1cb13
movb -0x229(%rbp), %al
movq -0x228(%rbp), %rcx
movq %rcx, -0x1b0(%rbp)
movb %al, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0xfe60
leaq -0x160(%rbp), %rdi
callq 0xfe90
jmp 0x1cb7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1cb6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0xfe60
leaq -0x160(%rbp), %rdi
callq 0xfe90
jmp 0x1cba4
leaq -0x138(%rbp), %rdi
callq 0x6a08
leaq -0xf0(%rbp), %rdi
callq 0xf720
leaq -0xc0(%rbp), %rdi
callq 0x1d7b0
jmp 0x1c83a
leaq -0x138(%rbp), %rdi
callq 0x6a08
leaq -0xf0(%rbp), %rdi
callq 0xf720
jmp 0x1cc31
movq -0x10(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x10070
movq -0x240(%rbp), %rdi
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rsi
callq 0x10030
movq %rax, -0x238(%rbp)
jmp 0x1cbf7
movq -0x238(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x1d7e0
movl $0x0, -0x68(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6a08
movl -0x68(%rbp), %eax
testl %eax, %eax
je 0x1cc2c
jmp 0x1cc2a
jmp 0x1cc4f
jmp 0x1c6d7
leaq -0x98(%rbp), %rdi
callq 0x1d7e0
leaq -0x58(%rbp), %rdi
callq 0x6a08
jmp 0x1cc5b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x6900
nopw %cs:(%rax,%rax)