// File: /workspace/github_cpp_makefile_star2_O3/simonrharris[P]SKA/src/sk_refalign.cpp
// Function: printVariantSites(std::basic_ofstream<char, std::char_traits<char>>&, 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>>>> 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&)
void printVariantSites(std::ofstream & myOutfile, const int totalbases, const std::vector < std::string > & sampleNames, const std::vector < std::string > & mySequences){
	std::vector < int > sitestoprint;
	sitestoprint.reserve(10000);
	std::vector < int > constantBases (4, 0);
	for (int i=0; i<totalbases; ++i){

		std::vector < int > baseVector (6, 0);

		for (int j=0; j<sampleNames.size(); ++j){
			char base=toupper(mySequences[j][i]);
			baseVector[base_score[base]]++;
		}

		int acgtCount=0;
		int constbase=-1;

		for (int i=0; i<4; ++i){
			if (baseVector[i]>0){
				acgtCount++;
				constbase=i;
			}
		}

		if (acgtCount==1){
			constantBases[constbase]++;
		}
		else if (acgtCount>1) {
			sitestoprint.push_back(i);
		}
		
	}

	std::cout << "Printing alignment of " << sitestoprint.size() << " variant sites" << std::endl;

	for (int i=0; i<sampleNames.size(); ++i){
		std::string mySequence (sitestoprint.size(), '-');
		for (int j=0; j<sitestoprint.size(); ++j){
			mySequence[j]=mySequences[i][sitestoprint[j]];
		}
		myOutfile << ">" << sampleNames[i] << std::endl << mySequence << std::endl;
	}

	std::cout << "Constant sites (a c g t):" << std::endl;
	std::cout << constantBases[0] << " " << constantBases[1]  << " " << constantBases[2]  << " " << constantBases[3]  << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movq %rdx, %r12
movl %esi, 0xc(%rsp)
movq %rdi, 0x58(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x2710, %esi           # imm = 0x2710
callq 0x181e4
movl $0x10, %edi
callq 0x53b0
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x0, 0x30(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x1bb16
leaq 0x25a20(%rip), %rbx     # 0x41440
movq %r15, 0x50(%rsp)
movq %r12, 0x60(%rsp)
movl $0x18, %edi
callq 0x53b0
movq %rax, %r13
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, %rax
movq 0x8(%r12), %r12
subq (%rax), %r12
je 0x1ba8b
sarq $0x5, %r12
movq (%r14), %rbp
movslq 0x30(%rsp), %r15
cmpq $0x1, %r12
adcq $0x0, %r12
movq (%rbp), %rax
movsbl (%rax,%r15), %edi
callq 0x56d0
movsbq %al, %rax
movsbq (%rbx,%rax), %rax
incl (%r13,%rax,4)
addq $0x20, %rbp
decq %r12
jne 0x1ba66
xorl %edx, %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
xorl %esi, %esi
cmpl $0x0, (%r13,%rdx,4)
cmovgl %edx, %eax
setg %sil
addl %esi, %ecx
incq %rdx
cmpq $0x4, %rdx
jne 0x1ba94
testl %ecx, %ecx
movq 0x50(%rsp), %r15
movq 0x60(%rsp), %r12
je 0x1baf5
cmpl $0x1, %ecx
jne 0x1bac9
cltq
incl (%r15,%rax,4)
jmp 0x1baf5
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x1bae6
movl 0x30(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x1baf5
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0xdeae
movl $0x18, %esi
movq %r13, %rdi
callq 0x53c0
movl 0x30(%rsp), %eax
incl %eax
movl %eax, 0x30(%rsp)
cmpl 0xc(%rsp), %eax
jl 0x1ba2a
movq 0x254a3(%rip), %rdi     # 0x40fc0
leaq 0x17b60(%rip), %rsi     # 0x33684
movl $0x16, %edx
callq 0x5420
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x2, %rsi
movq 0x2547d(%rip), %rdi     # 0x40fc0
callq 0x5240
movq %rax, %r13
leaq 0x18871(%rip), %rsi     # 0x343c3
movl $0xe, %edx
movq %rax, %rdi
callq 0x5420
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x8(%r12), %rax
cmpq (%r12), %rax
je 0x1bccd
leaq 0x40(%rsp), %r13
xorl %ebp, %ebp
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x2, %rsi
movq %r13, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
movl $0x2d, %edx
callq 0x5440
movq 0x10(%rsp), %rcx
cmpq %rcx, 0x18(%rsp)
je 0x1bc03
movq %rbp, %rax
shlq $0x5, %rax
xorl %edx, %edx
movq (%r14), %rsi
movslq (%rcx,%rdx,4), %rcx
movq (%rsi,%rax), %rsi
movb (%rsi,%rcx), %cl
movq 0x30(%rsp), %rsi
movb %cl, (%rsi,%rdx)
incq %rdx
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
cmpq %rdx, %rsi
ja 0x1bbd4
movl $0x1, %edx
movq 0x58(%rsp), %rdi
leaq 0x18463(%rip), %rsi     # 0x34077
callq 0x5420
movq (%r12), %rax
movq %rbp, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq 0x58(%rsp), %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 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rax, %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 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1bcb4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
incq %rbp
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x5, %rax
cmpq %rbp, %rax
ja 0x1bb9d
movq 0x252ec(%rip), %rbx     # 0x40fc0
leaq 0x186f7(%rip), %rsi     # 0x343d2
movl $0x19, %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 0x252ba(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl (%r15), %esi
movq 0x252a3(%rip), %rdi     # 0x40fc0
callq 0x5690
movq %rax, %rbx
leaq 0x1865c(%rip), %rsi     # 0x34388
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x18639(%rip), %rsi     # 0x34388
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movl 0x8(%r15), %esi
movq %rbx, %rdi
callq 0x5690
movq %rax, %rbx
leaq 0x18616(%rip), %rsi     # 0x34388
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movl 0xc(%r15), %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
movl $0x10, %esi
movq %r15, %rdi
callq 0x53c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1bdd9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1bdea
movq %rax, %r14
jmp 0x1be34
movq %rax, %r14
movl $0x18, %esi
movq %r13, %rdi
jmp 0x1be22
jmp 0x1bdfe
movq %rax, %r14
jmp 0x1be27
movq %rax, %r14
movq 0x50(%rsp), %r15
jmp 0x1be27
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1be27
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
movl $0x10, %esi
movq %r15, %rdi
callq 0x53c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1be4b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq %r14, %rdi
callq 0x56a0