// File: /workspace/github_cpp_makefile_star2_O2/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 0x2dec1(%rip), %rdi     # 0x35fb8
leaq 0x1d30a(%rip), %rsi     # 0x25408
callq 0x53f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
leaq 0x20(%rsp), %r12
pushq $0x10
popq %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x5740
movq (%r12), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x40(%rsp,%rax)
je 0x8176
movq 0x2deb1(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x1d2d5(%rip), %rsi     # 0x25420
movq %rax, %rdi
callq 0x53f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
pushq $0x1
popq %rbx
jmp 0x82d1
leaq 0x1dc0d(%rip), %rsi     # 0x25d8a
leaq 0x20(%rsp), %rdi
callq 0x53f0
leaq 0x2e392(%rip), %rsi     # 0x36520
movq %rax, %rdi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
leaq 0x20(%rsp), %rdi
movl %ebp, %esi
callq 0x56a0
movq %rax, %rdi
callq 0x51c0
movq (%r14), %r15
leaq 0x20(%rsp), %r12
leaq 0x1e19c(%rip), %r13     # 0x2635d
cmpq 0x8(%r14), %r15
je 0x81e3
movq %r12, %rdi
movq %r15, %rsi
callq 0x53a0
movq %rax, %rdi
movq %r13, %rsi
callq 0x53f0
addq $0x20, %r15
jmp 0x81c1
leaq 0x20(%rsp), %rdi
callq 0x51c0
addq $0x10, %rbx
leaq 0x230(%rsp), %r14
leaq 0x220(%rsp), %r13
xorl %r12d, %r12d
leaq 0x20(%rsp), %rbp
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x82c5
movq %r13, %rdi
callq 0x52b0
movq 0x8(%rbx), %r15
xorl %r13d, %r13d
cmpq 0x18(%rbx), %r15
jne 0x8230
cmpl 0x20(%rbx), %r13d
je 0x825f
movq (%r15), %rax
xorl %esi, %esi
btq %r13, %rax
setb %sil
movq %r14, %rdi
callq 0x5650
xorl %eax, %eax
cmpl $0x3f, %r13d
leal 0x1(%r13), %ecx
sete %al
leaq (%r15,%rax,8), %r15
cmovel %r12d, %ecx
movl %ecx, %r13d
jmp 0x8224
movq %rsp, %r15
movq %r15, %rdi
leaq 0x238(%rsp), %rsi
callq 0x5600
movq %r15, %rdi
callq 0x7ad4
leaq 0x220(%rsp), %r13
movq %rbp, %rdi
movq %r15, %rsi
callq 0x53a0
movq 0x30(%rbx), %r15
cmpq 0x38(%rbx), %r15
je 0x82a8
movq %rbp, %rdi
movq %r15, %rsi
callq 0x53a0
addq $0x20, %r15
jmp 0x8291
movq %rbp, %rdi
callq 0x51c0
movq %rsp, %rdi
callq 0x5778
movq %r13, %rdi
callq 0x5320
jmp 0x8209
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
callq 0x5560
leaq 0x20(%rsp), %rdi
callq 0x55c0
movl %ebx, %eax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x82f5
jmp 0x8309
jmp 0x82f5
movq %rax, %rbx
jmp 0x8319
jmp 0x82fc
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5778
jmp 0x830c
movq %rax, %rbx
leaq 0x220(%rsp), %rdi
callq 0x5320
leaq 0x20(%rsp), %rdi
callq 0x55c0
movq %rbx, %rdi
callq 0x56c0