// File: auton1[P]viterbi/variant_file.cpp
// Function: variant_file::read_file(parameters const&, std::vector<std::vector<bool, std::allocator<bool>>, std::allocator<std::vector<bool, std::allocator<bool>>>>&, std::vector<unsigned int, std::allocator<unsigned 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>>>>&, 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>>>>&)
void variant_file::read_file(const parameters &params, vector<vector<bool> > &haplotypes, vector<unsigned int> &positions, vector<string> &haplotype_names, vector<string> &alleles)
{
	unsigned int N_chr = 2*N_kept_individuals();
	haplotypes.resize(N_chr);

	haplotype_names.resize(0);
	for (unsigned int ui=0; ui<N_kept_individuals(); ui++)
	{
		if (include_indv[ui] == false)
			continue;
		haplotype_names.push_back(meta_data.indv[ui] + "_1");
		haplotype_names.push_back(meta_data.indv[ui] + "_2");
	}

	vector<char> variant_line;
	entry *e = get_entry_object();
	unsigned int N_alleles;

	while(!eof())
	{
		get_entry(variant_line);
		e->reset(variant_line);
		N_entries += e->apply_filters(params);

		if(!e->passed_filters)
			continue;
		N_kept_entries++;
		e->parse_basic_entry(true);

		e->parse_genotype_entries(true);
		N_alleles = e->get_N_alleles();

		if (N_alleles != 2)
		{
			LOG.one_off_warning("\tWarning: Only using biallelic sites.");
			continue;
		}
		if (e->is_diploid() == false)
		{
			LOG.one_off_warning("\tWarning: Only using fully diploid sites.");
			continue;
		}

		vector<bool> tmp;
		tmp.reserve(meta_data.N_indv*2);
		int allele_count = 0;

		pair<int, int> geno;
		bool skip = false;
		for (unsigned int ui=0; ui<meta_data.N_indv; ui++)
		{
			if (e->include_indv[ui] == false)
				continue;

			if (e->include_genotype[ui] == true)
			{
				e->get_indv_GENOTYPE_ids(ui, geno);
				if ((geno.first > 1) || (geno.second > 1))
					LOG.error("Only supporting biallelics... something bad happened", 1);
				if ((geno.first != -1) && (geno.second != -1))
				{
					tmp.push_back((bool)geno.first);
					tmp.push_back((bool)geno.second);
					allele_count += geno.first;
					allele_count += geno.second;
				}
				else
				{
					skip = true;
					LOG.one_off_warning("\tWarning: Only using sites without missing data.");
					break;
				}
			}
			else
			{
				skip = true;
				LOG.one_off_warning("\tWarning: Only using sites without missing data.");
				break;
			}
		}

		if (skip == true)
			continue;

		if (N_chr != tmp.size())
			LOG.error("Something unexpected happened.... oh dear.");

		string chr = e->get_CHROM();

		alleles.push_back(e->get_REF());
		alleles.push_back(e->get_ALT());
		positions.push_back(e->get_POS());
		
		for (unsigned int ui=0; ui<tmp.size(); ui++)
			haplotypes[ui].push_back(tmp[ui]);
	}
	delete e;
}

// Assembly:
subq $0x388, %rsp            # imm = 0x388
movq %rdi, 0x380(%rsp)
movq %rsi, 0x378(%rsp)
movq %rdx, 0x370(%rsp)
movq %rcx, 0x368(%rsp)
movq %r8, 0x360(%rsp)
movq %r9, 0x358(%rsp)
movq 0x380(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0x27690
shll %eax
movl %eax, 0x354(%rsp)
movq 0x370(%rsp), %rdi
movl 0x354(%rsp), %eax
movl %eax, %esi
callq 0x10340
movq 0x360(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2a0f0
movl $0x0, 0x350(%rsp)
movq 0xf8(%rsp), %rdi
movl 0x350(%rsp), %eax
movl %eax, 0xf4(%rsp)
callq 0x27690
movl %eax, %ecx
movl 0xf4(%rsp), %eax
cmpl %ecx, %eax
jae 0x282ce
movq 0xf8(%rsp), %rdi
addq $0x430, %rdi            # imm = 0x430
movl 0x350(%rsp), %eax
movl %eax, %esi
callq 0x102b0
movq %rax, 0x340(%rsp)
movq %rdx, 0x348(%rsp)
leaq 0x340(%rsp), %rdi
callq 0x10310
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2818c
jmp 0x2826c
movq 0xf8(%rsp), %rdi
movq 0x360(%rsp), %rax
movq %rax, 0xe0(%rsp)
addq $0x260, %rdi            # imm = 0x260
movl 0x350(%rsp), %eax
movl %eax, %esi
callq 0x10290
movq %rax, %rsi
leaq 0x4c5dc(%rip), %rdx     # 0x7479f
leaq 0x320(%rsp), %rdi
movq %rdi, 0xe8(%rsp)
callq 0x2a270
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x2a240
jmp 0x281ef
leaq 0x320(%rsp), %rdi
callq 0x6b50
movq 0xf8(%rsp), %rdi
movq 0x360(%rsp), %rax
movq %rax, 0xd0(%rsp)
addq $0x260, %rdi            # imm = 0x260
movl 0x350(%rsp), %eax
movl %eax, %esi
callq 0x10290
movq %rax, %rsi
leaq 0x4c56f(%rip), %rdx     # 0x747a2
leaq 0x2f0(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x2a270
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x2a240
jmp 0x2825f
leaq 0x2f0(%rsp), %rdi
callq 0x6b50
movl 0x350(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x350(%rsp)
jmp 0x28117
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x320(%rsp), %rdi
callq 0x6b50
jmp 0x28db6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x2f0(%rsp), %rdi
callq 0x6b50
jmp 0x28db6
leaq 0x2d8(%rsp), %rdi
callq 0x2a300
movq 0xf8(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movq %rax, 0xc8(%rsp)
jmp 0x282f6
movq 0xc8(%rsp), %rax
movq %rax, 0x2d0(%rsp)
movq 0xf8(%rsp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movb %al, 0xc7(%rsp)
jmp 0x28320
movb 0xc7(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x28332
jmp 0x28d76
movq 0xf8(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x2d8(%rsp), %rsi
callq *%rax
jmp 0x2834d
movq 0x2d0(%rsp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
leaq 0x2d8(%rsp), %rsi
callq *%rax
jmp 0x28368
movq 0x2d0(%rsp), %rdi
movq 0x378(%rsp), %rsi
callq 0x59590
movl %eax, 0xc0(%rsp)
jmp 0x28386
movq 0xf8(%rsp), %rax
movl 0xc0(%rsp), %ecx
addl 0x458(%rax), %ecx
movl %ecx, 0x458(%rax)
movq 0x2d0(%rsp), %rax
testb $0x1, 0xc(%rax)
jne 0x283cd
jmp 0x28306
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x28da9
movq 0xf8(%rsp), %rax
movl 0x45c(%rax), %ecx
incl %ecx
movl %ecx, 0x45c(%rax)
movq 0x2d0(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
jmp 0x283ff
movq 0x2d0(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
movl $0x1, %esi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq *%rax
jmp 0x28420
movq 0x2d0(%rsp), %rdi
callq 0x4c290
movl %eax, 0xbc(%rsp)
jmp 0x28436
movl 0xbc(%rsp), %eax
movl %eax, 0x2cc(%rsp)
cmpl $0x2, 0x2cc(%rsp)
je 0x28503
leaq 0x2a7(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x69f0
movq 0xb0(%rsp), %rdx
leaq 0x4c32f(%rip), %rsi     # 0x747a5
leaq 0x2a8(%rsp), %rdi
callq 0x67c0
jmp 0x28485
leaq 0x6b174(%rip), %rdi     # 0x93600
leaq 0x2a8(%rsp), %rsi
callq 0x71610
jmp 0x2849b
leaq 0x2a8(%rsp), %rdi
callq 0x6b50
leaq 0x2a7(%rsp), %rdi
callq 0x65f0
jmp 0x28306
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x284f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x6b50
leaq 0x2a7(%rsp), %rdi
callq 0x65f0
jmp 0x28da9
movq 0x2d0(%rsp), %rdi
callq 0x4a820
movb %al, 0xaf(%rsp)
jmp 0x28519
movb 0xaf(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x285df
leaq 0x27f(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x69f0
movq 0xa0(%rsp), %rdx
leaq 0x4c279(%rip), %rsi     # 0x747cb
leaq 0x280(%rsp), %rdi
callq 0x67c0
jmp 0x28561
leaq 0x6b098(%rip), %rdi     # 0x93600
leaq 0x280(%rsp), %rsi
callq 0x71610
jmp 0x28577
leaq 0x280(%rsp), %rdi
callq 0x6b50
leaq 0x27f(%rsp), %rdi
callq 0x65f0
jmp 0x28306
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x285cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x6b50
leaq 0x27f(%rsp), %rdi
callq 0x65f0
jmp 0x28da9
leaq 0x250(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x1b250
movq 0xf8(%rsp), %rax
movq 0x98(%rsp), %rdi
movl 0x2a8(%rax), %eax
addl %eax, %eax
movl %eax, %esi
callq 0x2a310
jmp 0x28615
movl $0x0, 0x24c(%rsp)
leaq 0x244(%rsp), %rdi
callq 0x2a380
jmp 0x2862f
movb $0x0, 0x243(%rsp)
movl $0x0, 0x23c(%rsp)
movq 0xf8(%rsp), %rcx
movl 0x23c(%rsp), %eax
cmpl 0x2a8(%rcx), %eax
jae 0x28a27
movq 0x2d0(%rsp), %rdi
addq $0x1f0, %rdi            # imm = 0x1F0
movl 0x23c(%rsp), %eax
movl %eax, %esi
callq 0x102b0
movq %rdx, 0x88(%rsp)
movq %rax, 0x90(%rsp)
jmp 0x2868c
movq 0x88(%rsp), %rax
movq 0x90(%rsp), %rcx
movq %rcx, 0x228(%rsp)
movq %rax, 0x230(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x10310
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x286e1
jmp 0x28a11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x28d67
movq 0x2d0(%rsp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl 0x23c(%rsp), %eax
movl %eax, %esi
callq 0x102b0
movq %rdx, 0x78(%rsp)
movq %rax, 0x80(%rsp)
jmp 0x2870d
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rcx, 0x218(%rsp)
movq %rax, 0x220(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x10310
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2895f
movq 0x2d0(%rsp), %rdi
movl 0x23c(%rsp), %esi
leaq 0x244(%rsp), %rdx
callq 0x4bd10
jmp 0x28763
cmpl $0x1, 0x244(%rsp)
jg 0x2877b
cmpl $0x1, 0x248(%rsp)
jle 0x28828
leaq 0x1f7(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x69f0
movq 0x70(%rsp), %rdx
leaq 0x4c05c(%rip), %rsi     # 0x747f5
leaq 0x1f8(%rsp), %rdi
callq 0x67c0
jmp 0x287a8
leaq 0x6ae51(%rip), %rdi     # 0x93600
leaq 0x1f8(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x287c3
leaq 0x1f8(%rsp), %rdi
callq 0x6b50
leaq 0x1f7(%rsp), %rdi
callq 0x65f0
jmp 0x28828
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x28816
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x6b50
leaq 0x1f7(%rsp), %rdi
callq 0x65f0
jmp 0x28d67
cmpl $-0x1, 0x244(%rsp)
je 0x288a7
cmpl $-0x1, 0x248(%rsp)
je 0x288a7
movl 0x244(%rsp), %eax
testl %eax, %eax
setne %al
movzbl %al, %esi
leaq 0x250(%rsp), %rdi
callq 0x10470
jmp 0x2885a
movl 0x248(%rsp), %eax
testl %eax, %eax
setne %al
movzbl %al, %esi
leaq 0x250(%rsp), %rdi
callq 0x10470
jmp 0x28878
movl 0x244(%rsp), %eax
addl 0x24c(%rsp), %eax
movl %eax, 0x24c(%rsp)
movl 0x248(%rsp), %eax
addl 0x24c(%rsp), %eax
movl %eax, 0x24c(%rsp)
jmp 0x2895a
movb $0x1, 0x243(%rsp)
leaq 0x1cf(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x69f0
movq 0x68(%rsp), %rdx
leaq 0x4bf5d(%rip), %rsi     # 0x7482a
leaq 0x1d0(%rsp), %rdi
callq 0x67c0
jmp 0x288dc
leaq 0x6ad1d(%rip), %rdi     # 0x93600
leaq 0x1d0(%rsp), %rsi
callq 0x71610
jmp 0x288f2
leaq 0x1d0(%rsp), %rdi
callq 0x6b50
leaq 0x1cf(%rsp), %rdi
callq 0x65f0
jmp 0x28a27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x28948
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x6b50
leaq 0x1cf(%rsp), %rdi
callq 0x65f0
jmp 0x28d67
jmp 0x28a0f
movb $0x1, 0x243(%rsp)
leaq 0x1a7(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x69f0
movq 0x60(%rsp), %rdx
leaq 0x4bea5(%rip), %rsi     # 0x7482a
leaq 0x1a8(%rsp), %rdi
callq 0x67c0
jmp 0x28994
leaq 0x6ac65(%rip), %rdi     # 0x93600
leaq 0x1a8(%rsp), %rsi
callq 0x71610
jmp 0x289aa
leaq 0x1a8(%rsp), %rdi
callq 0x6b50
leaq 0x1a7(%rsp), %rdi
callq 0x65f0
jmp 0x28a27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x289fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x6b50
leaq 0x1a7(%rsp), %rdi
callq 0x65f0
jmp 0x28d67
jmp 0x28a11
movl 0x23c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x23c(%rsp)
jmp 0x28642
movb 0x243(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x28a48
movl $0x5, 0x1a0(%rsp)
jmp 0x28d36
movl 0x354(%rsp), %eax
movq %rax, 0x58(%rsp)
leaq 0x250(%rsp), %rdi
callq 0xf1d0
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
je 0x28b1f
leaq 0x17f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x69f0
movq 0x50(%rsp), %rdx
leaq 0x4bdcb(%rip), %rsi     # 0x7485b
leaq 0x180(%rsp), %rdi
callq 0x67c0
jmp 0x28a9f
leaq 0x6ab5a(%rip), %rdi     # 0x93600
leaq 0x180(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x28aba
leaq 0x180(%rsp), %rdi
callq 0x6b50
leaq 0x17f(%rsp), %rdi
callq 0x65f0
jmp 0x28b1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x28b0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x6b50
leaq 0x17f(%rsp), %rdi
callq 0x65f0
jmp 0x28d67
movq 0x2d0(%rsp), %rsi
leaq 0x158(%rsp), %rdi
callq 0x4a260
jmp 0x28b36
movq 0x358(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x2d0(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x4a390
jmp 0x28b5a
movq 0x48(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x2a240
jmp 0x28b6e
leaq 0x138(%rsp), %rdi
callq 0x6b50
movq 0x358(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x2d0(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x4a450
jmp 0x28b9f
movq 0x40(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x2a240
jmp 0x28bb3
leaq 0x118(%rsp), %rdi
callq 0x6b50
movq 0x368(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x2d0(%rsp), %rdi
callq 0x4a2c0
movl %eax, 0x3c(%rsp)
jmp 0x28be0
movq 0x30(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, 0x114(%rsp)
leaq 0x114(%rsp), %rsi
callq 0x2a3a0
jmp 0x28bff
movl $0x0, 0x110(%rsp)
movl 0x110(%rsp), %eax
movq %rax, 0x28(%rsp)
leaq 0x250(%rsp), %rdi
callq 0xf1d0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x28d1e
movq 0x370(%rsp), %rdi
movl 0x110(%rsp), %eax
movl %eax, %esi
callq 0x103e0
movq %rax, 0x10(%rsp)
movl 0x110(%rsp), %eax
movl %eax, %esi
leaq 0x250(%rsp), %rdi
callq 0x102b0
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x28c71
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x100(%rsp)
movq %rax, 0x108(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x10310
movq 0x10(%rsp), %rdi
movzbl %al, %esi
callq 0x10470
jmp 0x28ca7
jmp 0x28ca9
movl 0x110(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x110(%rsp)
jmp 0x28c0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
jmp 0x28d5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x6b50
jmp 0x28d5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x6b50
jmp 0x28d5a
leaq 0x158(%rsp), %rdi
callq 0x6b50
movl $0x0, 0x1a0(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x11300
movl 0x1a0(%rsp), %eax
testl %eax, %eax
je 0x28d55
jmp 0x28d50
jmp 0x28306
jmp 0x28306
leaq 0x158(%rsp), %rdi
callq 0x6b50
leaq 0x250(%rsp), %rdi
callq 0x11300
jmp 0x28da9
movq 0x2d0(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x28d94
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x2d8(%rsp), %rdi
callq 0x267c0
addq $0x388, %rsp            # imm = 0x388
retq
leaq 0x2d8(%rsp), %rdi
callq 0x267c0
movq 0x318(%rsp), %rdi
callq 0x69e0
nopw %cs:(%rax,%rax)