// File: /workspace/github_cpp_makefile_star2_O3/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 0x37d4d(%rip), %r12     # 0x40fc0
leaq 0x2a19e(%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 0x939b
movq 0x37d01(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x37ce6(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x2a10f(%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 0x95db
leaq 0x2a9c8(%rip), %rsi     # 0x33d6a
leaq 0x20(%rsp), %rdi
movl $0x5, %edx
callq 0x5420
leaq 0x38158(%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 0x946b
leaq 0x20(%rsp), %r12
leaq 0x2af47(%rip), %r13     # 0x34388
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 0x9441
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 0x95cf
leaq 0x220(%rsp), %r13
xorl %ebx, %ebx
movq %rsp, %r15
movq %r13, %rdi
callq 0x5280
movq 0x8(%r12), %r13
cmpq 0x18(%r12), %r13
jne 0x94cf
cmpl $0x0, 0x20(%r12)
je 0x950f
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 %ebx, %ebp
cmpq 0x18(%r12), %r13
jne 0x94d1
cmpl 0x20(%r12), %ebp
jne 0x94d1
movq %r15, %rdi
leaq 0x238(%rsp), %rsi
callq 0x5600
movq %r15, %rdi
callq 0x88a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x5420
movq 0x30(%r12), %r13
cmpq 0x38(%r12), %r13
je 0x955a
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r14, %rdi
callq 0x5420
addq $0x20, %r13
jmp 0x953d
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 0x95a6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r13, %rdi
movq 0x379d8(%rip), %rsi     # 0x40f88
callq 0x52c0
leaq 0x2a0(%rsp), %rdi
callq 0x5120
movq (%r12), %r12
testq %r12, %r12
jne 0x94b3
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
callq 0x5530
movq 0x379ce(%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 0x962e
jmp 0x9627
jmp 0x9627
movq %rax, %rbx
jmp 0x9672
jmp 0x9633
movq %rax, %rbx
jmp 0x9651
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9651
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x37930(%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