// File: /workspace/github_cpp_makefile_star2_O1/simonrharris[P]SKA/src/sk_align.cpp
// Function: printAlignment(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, 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>>>>> const&, std::vector<int, std::allocator<int>>&, 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>>>>, bool)
void printAlignment(const std::string & outputfilename, const std::unordered_map < std::string, std::string > & myKmerMap,std::vector < int > & constantBaseVector, const std::vector < std::string > sampleNames, const bool variantOnly){
	
	std::cout << "Printing alignment of "<< myKmerMap.size() << " sites" << std::endl;
	
	std::ofstream alignfile(outputfilename);

	for (int i=0; i<sampleNames.size(); ++i){
		float nonns=0.0;
		std::string mysequence (myKmerMap.size(), '-');
		int j=0;
		for (std::unordered_map < std::string, std::string >::const_iterator kmit=myKmerMap.begin(); kmit!=myKmerMap.end(); ++kmit, ++j){
			mysequence[j] = kmit->second[i];
			if(base_score[kmit->second[i]]<4){
				nonns++;
			}
		}
		alignfile << ">" << sampleNames[i] << std::endl << mysequence << std::endl;
		if ((nonns/myKmerMap.size())<0.5){
			std::cerr << "Warning: " << sampleNames[i] << " only matches " << nonns/myKmerMap.size()*100 << "% of kmers in the alignment" << std::endl;
		}
	}
	alignfile.close();

	if (variantOnly){//if the variant only option was selected, print the constant site counts
		std::cout << "Constant sites matching filters (a c g t):" << std::endl;
		std::cout << constantBaseVector[0] << " " << constantBaseVector[1]  << " " << constantBaseVector[2]  << " " << constantBaseVector[3]  << std::endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl %r8d, 0xc(%rsp)
movq %rcx, %r14
movq %rdx, 0x30(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x344d0(%rip), %r12     # 0x40fc0
leaq 0x26b8d(%rip), %rsi     # 0x33684
movl $0x16, %edx
movq %r12, %rdi
callq 0x5420
movq 0x18(%r15), %rsi
movq %r12, %rdi
callq 0x5240
movq %rax, %r12
leaq 0x278c1(%rip), %rsi     # 0x343db
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
movq (%r12), %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 0x38(%rsp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x5720
movq 0x8(%r14), %rax
cmpq (%r14), %rax
je 0xcdca
xorl %ebx, %ebx
leaq 0x348c9(%rip), %r13     # 0x41440
movq 0x18(%r15), %rsi
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
movl $0x2d, %edx
callq 0x5440
movq 0x10(%r15), %rax
testq %rax, %rax
je 0xcbe0
xorps %xmm0, %xmm0
xorl %ecx, %ecx
movaps %xmm0, %xmm1
movq 0x28(%rax), %rdx
movb (%rdx,%rbx), %dl
movq 0x10(%rsp), %rsi
movb %dl, (%rsi,%rcx)
movq 0x28(%rax), %rdx
movsbq (%rdx,%rbx), %rdx
cmpb $0x4, (%r13,%rdx)
addss 0x26439(%rip), %xmm1    # 0x33004
jl 0xcbd0
movaps %xmm0, %xmm1
movq (%rax), %rax
incq %rcx
movaps %xmm1, %xmm0
testq %rax, %rax
jne 0xcba5
jmp 0xcbe3
xorps %xmm1, %xmm1
movss %xmm1, 0x8(%rsp)
movl $0x1, %edx
leaq 0x38(%rsp), %rdi
leaq 0x2748d(%rip), %rsi     # 0x34087
callq 0x5420
movq (%r14), %rax
movq %rbx, %rbp
shlq $0x5, %rbp
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
leaq 0x38(%rsp), %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
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rax, %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
movq 0x18(%r15), %rax
testq %rax, %rax
js 0xcc95
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xccaa
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss 0x8(%rsp), %xmm1
divss %xmm0, %xmm1
movss 0x269bc(%rip), %xmm0    # 0x33678
ucomiss %xmm1, %xmm0
jbe 0xcd97
movl $0x9, %edx
movq 0x3431f(%rip), %rdi     # 0x40ff0
leaq 0x269c3(%rip), %rsi     # 0x3369b
callq 0x5420
movq (%r14), %rax
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
movq 0x34300(%rip), %rdi     # 0x40ff0
callq 0x5420
movq %rax, %r12
movl $0xe, %edx
movq %rax, %rdi
leaq 0x2699e(%rip), %rsi     # 0x336a5
callq 0x5420
movq 0x18(%r15), %rax
testq %rax, %rax
js 0xcd1f
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xcd37
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss 0x8(%rsp), %xmm1
divss %xmm0, %xmm1
mulss 0x26933(%rip), %xmm1    # 0x3367c
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %r12, %rdi
callq 0x5610
movq %rax, %r12
movl $0x1b, %edx
movq %rax, %rdi
leaq 0x2694a(%rip), %rsi     # 0x336b4
callq 0x5420
movq (%r12), %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 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xcdb3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
incq %rbx
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq %rbx, %rax
ja 0xcb77
leaq 0x38(%rsp), %rdi
callq 0x5530
movq 0x30(%rsp), %r14
cmpb $0x0, 0xc(%rsp)
je 0xced4
movq 0x341d5(%rip), %rbx     # 0x40fc0
leaq 0x268de(%rip), %rsi     # 0x336d0
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x341a3(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq (%r14), %rax
movl (%rax), %esi
movq 0x3418a(%rip), %rdi     # 0x40fc0
callq 0x5690
movq %rax, %rbx
leaq 0x27553(%rip), %rsi     # 0x34398
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movq (%r14), %rax
movl 0x4(%rax), %esi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x2752e(%rip), %rsi     # 0x34398
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movq (%r14), %rax
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x27509(%rip), %rsi     # 0x34398
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movq (%r14), %rax
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x5690
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 0x340d5(%rip), %rax     # 0x40fb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x40(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x38(%rsp,%rcx)
callq 0x5330
leaq 0x130(%rsp), %rdi
callq 0x5120
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcf1a
movq %rax, %rbx
jmp 0xcf3e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xcf3e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x38(%rsp), %rdi
callq 0x55a0
movq %rbx, %rdi
callq 0x56a0