// File: simonrharris[P]SKA/src/kmers.cpp
// Function: printKmerAlleleFrequencies(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::array<int, 8ul>, 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::array<int, 8ul>>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int printKmerAlleleFrequencies(const std::unordered_map < std::string, std::array < int, 8 > > & mymap, const std::string outputfile){
	
	std::cout << "Writing kmer allele frequencies to " << outputfile << std::endl;

	std::ofstream allelefile(outputfile);
	if (allelefile.fail()){
		std::cerr << std::endl << "Error: Failed to open " << outputfile << std::endl << std::endl;
		return 1;
	}
	for (std::unordered_map < std::string, std::array < int, 8 > >::const_iterator it=mymap.begin(); it!=mymap.end(); ++it){
		std::string kmer=it->first;
		allelefile << kmer;
		for (std::array < int, 8 >::const_iterator it2=it->second.begin(); it2!=it->second.end()-4; ++it2){
		
			allelefile << "\t" << *it2;
		
		}
		allelefile << std::endl;
	}
	allelefile.close();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rsi, -0x270(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq 0x6ca77(%rip), %rdi     # 0x78fa8
leaq 0x4cf11(%rip), %rsi     # 0x59449
callq 0x6520
movq -0x270(%rbp), %rsi
movq %rax, %rdi
callq 0x64d0
movq %rax, %rdi
movq 0x6ca3a(%rip), %rsi     # 0x78f90
callq 0x6570
movq -0x270(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x10, %edx
callq 0x69b0
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x6030
movb %al, -0x261(%rbp)
jmp 0xc593
movb -0x261(%rbp), %al
testb $0x1, %al
jne 0xc5a2
jmp 0xc654
movq 0x6ca47(%rip), %rdi     # 0x78ff0
movq 0x6c9e0(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x278(%rbp)
jmp 0xc5be
movq -0x278(%rbp), %rdi
leaq 0x4ce64(%rip), %rsi     # 0x59430
callq 0x6520
movq %rax, -0x280(%rbp)
jmp 0xc5da
movq -0x270(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x64d0
movq %rax, -0x288(%rbp)
jmp 0xc5f6
movq -0x288(%rbp), %rdi
movq 0x6c98c(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x290(%rbp)
jmp 0xc612
movq -0x290(%rbp), %rdi
movq 0x6c970(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0xc627
movl $0x1, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
jmp 0xc7d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0xc7ef
movq -0x10(%rbp), %rdi
callq 0xeeb0
movq %rax, -0x230(%rbp)
movq -0x10(%rbp), %rdi
callq 0xef10
movq %rax, -0x238(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0xeee0
testb $0x1, %al
jne 0xc690
jmp 0xc7b8
leaq -0x230(%rbp), %rdi
callq 0xef40
movq %rax, %rsi
leaq -0x258(%rbp), %rdi
callq 0x6230
jmp 0xc6ad
leaq -0x218(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x64d0
jmp 0xc6c2
leaq -0x230(%rbp), %rdi
callq 0xef40
movq %rax, %rdi
addq $0x20, %rdi
callq 0xef70
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xef40
movq %rax, %rdi
addq $0x20, %rdi
callq 0xefc0
movq %rax, %rcx
movq -0x298(%rbp), %rax
addq $-0x10, %rcx
cmpq %rcx, %rax
je 0xc786
leaq 0x4db90(%rip), %rsi     # 0x5a2b1
leaq -0x218(%rbp), %rdi
callq 0x6520
movq %rax, -0x2a0(%rbp)
jmp 0xc736
movq -0x2a0(%rbp), %rdi
movq -0x260(%rbp), %rax
movl (%rax), %esi
callq 0x68d0
jmp 0xc74d
jmp 0xc74f
movq -0x260(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x260(%rbp)
jmp 0xc6e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x6a08
jmp 0xc7ef
movq 0x6c803(%rip), %rsi     # 0x78f90
leaq -0x218(%rbp), %rdi
callq 0x6570
jmp 0xc79b
leaq -0x258(%rbp), %rdi
callq 0x6a08
leaq -0x230(%rbp), %rdi
callq 0xef90
jmp 0xc664
leaq -0x218(%rbp), %rdi
callq 0x6740
jmp 0xc7c6
movl $0x0, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x67d0
movl -0x4(%rbp), %eax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x67d0
movq -0x220(%rbp), %rdi
callq 0x6900
nopw (%rax,%rax)