// File: /workspace/github_cpp_makefile_star2_O1/simonrharris[P]SKA/src/kmers.cpp
// Function: printMergedKmerFile(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>>>>>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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>>>> const&, int)
int printMergedKmerFile(const std::unordered_map < std::vector < bool >, std::vector < std::string > > & mymap, const std::string outputfile, const std::vector < std::string > & mysamples, const int kmersize){

	std::cout << "Writing split kmers to " << outputfile << std::endl;

	std::ofstream kmerout(outputfile); //open output file stream
	if (kmerout.fail()){
		std::cerr << std::endl << "Error: Failed to open " << outputfile << std::endl << std::endl;
		return 1;
	}
	kmerout << "SKA v" << versionNumber << std::endl;
	kmerout << kmersize << std::endl; // print kmer size to output file stream
	for ( std::vector < std::string >::const_iterator it=mysamples.begin(); it!=mysamples.end(); ++it){ //print each sample name to output file stream
		kmerout << *it << " "; 
	}
	kmerout << std::endl;

	for ( std::unordered_map < std::vector < bool >, std::vector < std::string > >::const_iterator it=mymap.begin(); it!=mymap.end(); ++it){
		std::stringstream bitstringstream;
		for (std::vector < bool >::const_iterator it2=it->first.begin(); it2!=it->first.end(); ++it2){
			bitstringstream << *it2;
		}
		std::string bitstring = bitstringstream.str();

		ascii_bitstring(bitstring);
		kmerout << bitstring;
		for (std::vector < std::string >::const_iterator it2=it->second.begin(); it2!=it->second.end(); ++it2){
			kmerout << *it2;
		}
		kmerout << std::endl;
	}
	
	kmerout.close();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x37cf1(%rip), %r12     # 0x40fc0
leaq 0x2a142(%rip), %rsi     # 0x33418
movl $0x17, %edx
movq %r12, %rdi
callq 0x5420
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %r12, %rdi
callq 0x5420
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x5720
movq (%r12), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x40(%rsp,%rax)
je 0x93f7
movq 0x37ca5(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x37c8a(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x2a0b3(%rip), %rsi     # 0x33430
movl $0x16, %edx
movq %rax, %rdi
callq 0x5420
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x5250
jmp 0x9639
leaq 0x2a97c(%rip), %rsi     # 0x33d7a
leaq 0x20(%rsp), %rdi
movl $0x5, %edx
callq 0x5420
leaq 0x380fc(%rip), %rax     # 0x41510
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x20(%rsp), %rdi
callq 0x5420
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x5690
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq (%r14), %rbp
cmpq 0x8(%r14), %rbp
je 0x94c7
leaq 0x20(%rsp), %r12
leaq 0x2aefb(%rip), %r13     # 0x34398
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
movq %r12, %rdi
callq 0x5420
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x5420
addq $0x20, %rbp
cmpq 0x8(%r14), %rbp
jne 0x949d
movq 0x20(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x10(%rbx), %r12
testq %r12, %r12
je 0x962d
leaq 0x220(%rsp), %r13
xorl %r15d, %r15d
movq %rsp, %rbx
movq %r13, %rdi
callq 0x5280
movq 0x8(%r12), %r13
cmpq 0x18(%r12), %r13
jne 0x952c
cmpl $0x0, 0x20(%r12)
je 0x956d
xorl %ebp, %ebp
movq (%r13), %rax
xorl %esi, %esi
btq %rbp, %rax
setb %sil
leaq 0x230(%rsp), %rdi
callq 0x5640
xorl %eax, %eax
cmpl $0x3f, %ebp
leal 0x1(%rbp), %ecx
sete %al
leaq (%r13,%rax,8), %r13
movl %ecx, %ebp
cmovel %r15d, %ebp
cmpq 0x18(%r12), %r13
jne 0x952e
cmpl 0x20(%r12), %ebp
jne 0x952e
movq %rbx, %rdi
leaq 0x238(%rsp), %rsi
callq 0x5600
movq %rbx, %rdi
callq 0x8900
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x5420
movq 0x30(%r12), %r13
cmpq 0x38(%r12), %r13
je 0x95b8
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r14, %rdi
callq 0x5420
addq $0x20, %r13
jmp 0x959b
movq 0x20(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
leaq 0x220(%rsp), %r13
je 0x9604
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r13, %rdi
movq 0x3797a(%rip), %rsi     # 0x40f88
callq 0x52c0
leaq 0x2a0(%rsp), %rdi
callq 0x5120
movq (%r12), %r12
testq %r12, %r12
jne 0x9510
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
callq 0x5530
movq 0x37970(%rip), %rax     # 0x40fb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x28(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x20(%rsp,%rcx)
callq 0x5330
leaq 0x118(%rsp), %rdi
callq 0x5120
movl %ebx, %eax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x968c
jmp 0x9685
jmp 0x9685
movq %rax, %rbx
jmp 0x96d0
jmp 0x9691
movq %rax, %rbx
jmp 0x96af
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x96af
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x378d2(%rip), %rsi     # 0x40f88
leaq 0x220(%rsp), %rdi
callq 0x52c0
leaq 0x2a0(%rsp), %rdi
callq 0x5120
leaq 0x20(%rsp), %rdi
callq 0x55a0
movq %rbx, %rdi
callq 0x56a0