// File: 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
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rcx, -0x288(%rbp)
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq 0x5fd87(%rip), %rdi     # 0x78fa8
leaq 0x40460(%rip), %rsi     # 0x59688
callq 0x6520
movq %rax, -0x280(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1aa60
movq -0x280(%rbp), %rdi
movq %rax, %rsi
callq 0x6120
movq %rax, %rdi
leaq 0x4113a(%rip), %rsi     # 0x5a390
callq 0x6520
movq %rax, %rdi
movq 0x5fd2b(%rip), %rsi     # 0x78f90
callq 0x6570
movq -0x8(%rbp), %rsi
leaq -0x228(%rbp), %rdi
movl $0x10, %edx
callq 0x69b0
movl $0x0, -0x22c(%rbp)
movq -0x288(%rbp), %rdi
movslq -0x22c(%rbp), %rax
movq %rax, -0x290(%rbp)
callq 0xb670
movq %rax, %rcx
movq -0x290(%rbp), %rax
cmpq %rcx, %rax
jae 0x196ba
movl $0x0, -0x230(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1aa60
movq %rax, -0x2a0(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x6910
movq -0x2a0(%rbp), %rsi
movq -0x298(%rbp), %rcx
leaq -0x250(%rbp), %rdi
movl $0x2d, %edx
callq 0x9150
jmp 0x19304
leaq -0x251(%rbp), %rdi
callq 0x65a0
movl $0x0, -0x268(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1aa80
movq %rax, -0x270(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1aab0
movq %rax, -0x278(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0xf790
testb $0x1, %al
jne 0x19356
jmp 0x1945d
leaq -0x270(%rbp), %rdi
callq 0x1aae0
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x22c(%rbp), %rsi
callq 0x65c0
movb (%rax), %al
movb %al, -0x2a9(%rbp)
movslq -0x268(%rbp), %rsi
leaq -0x250(%rbp), %rdi
callq 0x69e0
movq %rax, -0x2a8(%rbp)
jmp 0x19399
movq -0x2a8(%rbp), %rax
movb -0x2a9(%rbp), %cl
movb %cl, (%rax)
leaq -0x270(%rbp), %rdi
callq 0x1aae0
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x22c(%rbp), %rsi
callq 0x65c0
movsbq (%rax), %rcx
leaq 0x601be(%rip), %rax     # 0x79590
movsbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x1943b
movss 0x3fc21(%rip), %xmm0    # 0x59004
addss -0x230(%rbp), %xmm0
movss %xmm0, -0x230(%rbp)
jmp 0x1943b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x251(%rbp), %rdi
callq 0x65a0
jmp 0x1982a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x6a08
jmp 0x1982a
jmp 0x1943d
leaq -0x270(%rbp), %rdi
callq 0x1ab10
movl -0x268(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x268(%rbp)
jmp 0x1932a
leaq 0x40c23(%rip), %rsi     # 0x5a087
leaq -0x228(%rbp), %rdi
callq 0x6520
movq %rax, -0x2b8(%rbp)
jmp 0x19479
movq -0x288(%rbp), %rdi
movslq -0x22c(%rbp), %rsi
callq 0xf2d0
movq -0x2b8(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0x2c0(%rbp)
jmp 0x194a4
movq -0x2c0(%rbp), %rdi
movq 0x5fade(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x2c8(%rbp)
jmp 0x194c0
movq -0x2c8(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x64d0
movq %rax, -0x2d0(%rbp)
jmp 0x194dc
movq -0x2d0(%rbp), %rdi
movq 0x5faa6(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x194f1
movss -0x230(%rbp), %xmm0
movss %xmm0, -0x2dc(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1aa60
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x2d8(%rbp)
testq %rax, %rax
movss %xmm0, -0x2d4(%rbp)
js 0x1954b
movss -0x2d8(%rbp), %xmm0
movss %xmm0, -0x2d4(%rbp)
movss -0x2dc(%rbp), %xmm0
movss -0x2d4(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x40115(%rip), %xmm0    # 0x59680
ucomisd %xmm1, %xmm0
jbe 0x1969a
movq 0x5fa74(%rip), %rdi     # 0x78ff0
leaq 0x4011c(%rip), %rsi     # 0x5969f
callq 0x6520
movq %rax, -0x2e8(%rbp)
jmp 0x19591
movq -0x288(%rbp), %rdi
movslq -0x22c(%rbp), %rsi
callq 0xf2d0
movq -0x2e8(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0x2f0(%rbp)
jmp 0x195bc
movq -0x2f0(%rbp), %rdi
leaq 0x400df(%rip), %rsi     # 0x596a9
callq 0x6520
movq %rax, -0x2f8(%rbp)
jmp 0x195d8
movss -0x230(%rbp), %xmm0
movss %xmm0, -0x304(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1aa60
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x300(%rbp)
testq %rax, %rax
movss %xmm0, -0x2fc(%rbp)
js 0x19632
movss -0x300(%rbp), %xmm0
movss %xmm0, -0x2fc(%rbp)
movq -0x2f8(%rbp), %rdi
movss -0x304(%rbp), %xmm0
movss -0x2fc(%rbp), %xmm1
divss %xmm1, %xmm0
movss 0x40023(%rip), %xmm1    # 0x59678
mulss %xmm1, %xmm0
callq 0x63f0
movq %rax, -0x310(%rbp)
jmp 0x19667
movq -0x310(%rbp), %rdi
leaq 0x40043(%rip), %rsi     # 0x596b8
callq 0x6520
movq %rax, -0x318(%rbp)
jmp 0x19683
movq -0x318(%rbp), %rdi
movq 0x5f8ff(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x19698
jmp 0x1969a
leaq -0x250(%rbp), %rdi
callq 0x6a08
movl -0x22c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x22c(%rbp)
jmp 0x19289
leaq -0x228(%rbp), %rdi
callq 0x6740
jmp 0x196c8
testb $0x1, -0x21(%rbp)
je 0x19815
movq 0x5f8cf(%rip), %rdi     # 0x78fa8
leaq 0x3fff4(%rip), %rsi     # 0x596d4
callq 0x6520
movq %rax, -0x320(%rbp)
jmp 0x196ee
movq -0x320(%rbp), %rdi
movq 0x5f894(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x19703
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1a9b0
movl (%rax), %esi
movq 0x5f88f(%rip), %rdi     # 0x78fa8
callq 0x68d0
movq %rax, -0x328(%rbp)
jmp 0x19727
movq -0x328(%rbp), %rdi
leaq 0x40c18(%rip), %rsi     # 0x5a34d
callq 0x6520
movq %rax, -0x330(%rbp)
jmp 0x19743
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x1a9b0
movq -0x330(%rbp), %rdi
movl (%rax), %esi
callq 0x68d0
movq %rax, -0x338(%rbp)
jmp 0x19768
movq -0x338(%rbp), %rdi
leaq 0x40bd7(%rip), %rsi     # 0x5a34d
callq 0x6520
movq %rax, -0x340(%rbp)
jmp 0x19784
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0x1a9b0
movq -0x340(%rbp), %rdi
movl (%rax), %esi
callq 0x68d0
movq %rax, -0x348(%rbp)
jmp 0x197a9
movq -0x348(%rbp), %rdi
leaq 0x40b96(%rip), %rsi     # 0x5a34d
callq 0x6520
movq %rax, -0x350(%rbp)
jmp 0x197c5
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0x1a9b0
movq -0x350(%rbp), %rdi
movl (%rax), %esi
callq 0x68d0
movq %rax, -0x358(%rbp)
jmp 0x197ea
movq -0x358(%rbp), %rdi
movq 0x5f798(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x197ff
jmp 0x19815
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x1982a
leaq -0x228(%rbp), %rdi
callq 0x67d0
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0x67d0
movq -0x260(%rbp), %rdi
callq 0x6900
nopw %cs:(%rax,%rax)