// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %r9, 0x38(%rsp)
movq %r8, %rbx
movq %rcx, 0x58(%rsp)
movq %rdx, %r14
movq %rsi, 0x8(%rsp)
movq %rdi, %r13
callq 0xe91e
addl %eax, %eax
movq %r14, 0x70(%rsp)
movq %r14, %rdi
movq %rax, 0x60(%rsp)
movq %rax, %rsi
callq 0x9cde
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
callq 0xfd72
leaq 0x430(%r13), %r14
leaq 0x10(%rsp), %rbp
xorl %r12d, %r12d
movq %r13, %rdi
callq 0xe91e
movl %eax, %eax
cmpq %rax, %r12
jae 0xef97
movq %r14, %rdi
movq %r12, %rsi
callq 0x9cc0
testq %rdx, (%rax)
je 0xef8e
movq 0x260(%r13), %rsi
addq %r15, %rsi
movq %rbp, %rdi
leaq 0x1e865(%rip), %rdx     # 0x2d7af
callq 0xfdce
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x10122
movq %rbp, %rdi
callq 0x5908
movq 0x260(%r13), %rsi
addq %r15, %rsi
movq %rbp, %rdi
leaq 0x1e83c(%rip), %rdx     # 0x2d7b2
callq 0xfdce
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x10122
movq %rbp, %rdi
callq 0x5908
incq %r12
addq $0x20, %r15
jmp 0xef17
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movq (%r13), %rax
movq %r13, %rdi
callq *0x28(%rax)
movq %rax, %r14
leaq 0x1f0(%rax), %rbx
addq $0x218, %rax            # imm = 0x218
movq %rax, 0x68(%rsp)
leaq 0x10(%rsp), %r12
movq 0x8(%rsp), %rbp
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
testb %al, %al
jne 0xf367
movq (%r13), %rax
movq %r13, %rdi
leaq 0x40(%rsp), %rsi
callq *0x20(%rax)
movq (%r14), %rax
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq *0x30(%rax)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x21614
addl %eax, 0x458(%r13)
cmpb $0x0, 0xc(%r14)
je 0xefce
incl 0x45c(%r13)
movq (%r14), %rax
movq %r14, %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq (%r14), %rax
movq %r14, %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x28(%rax)
movq %r14, %rdi
callq 0x1ce64
cmpl $0x2, %eax
jne 0xf173
movq %r14, %rdi
callq 0x1bf02
testb %al, %al
je 0xf19e
andq $0x0, 0x10(%rsp)
andl $0x0, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
andl $0x0, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movl 0x2a8(%r13), %esi
addl %esi, %esi
movq %r12, %rdi
callq 0xfe06
andq $0x0, (%rsp)
xorl %ebp, %ebp
movl 0x2a8(%r13), %eax
cmpq %rax, %rbp
jae 0xf1d4
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x9cc0
testq %rdx, (%rax)
je 0xf16b
movq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0x9cc0
testq %rdx, (%rax)
je 0xf2e8
movq %r14, %rdi
movl %ebp, %esi
movq %rsp, %rdx
callq 0x1cb02
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
cmpl $0x2, %eax
setge %dl
cmpl $0x2, %ecx
setge %sil
orb %dl, %sil
cmpb $0x1, %sil
jne 0xf136
leaq 0x118(%rsp), %r15
movq %r15, %rdi
leaq 0x1e6fa(%rip), %rsi     # 0x2d805
leaq 0x78(%rsp), %rdx
callq 0x5160
leaq 0x323b4(%rip), %rdi     # 0x414d0
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x2bf18
movq %r15, %rdi
callq 0x5908
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
cmpl $-0x1, %eax
je 0xf322
cmpl $-0x1, %ecx
je 0xf322
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %r12, %rdi
callq 0x9d32
xorl %esi, %esi
cmpl $0x0, 0x4(%rsp)
setne %sil
movq %r12, %rdi
callq 0x9d32
incq %rbp
jmp 0xf095
leaq 0x158(%rsp), %r15
movq %r15, %rdi
leaq 0x1e630(%rip), %rsi     # 0x2d7b5
movq %r12, %rdx
callq 0x5160
leaq 0x3233c(%rip), %rdi     # 0x414d0
movq %r15, %rsi
callq 0x2c10c
jmp 0xf1c7
leaq 0x138(%rsp), %r15
movq %r15, %rdi
leaq 0x1e62b(%rip), %rsi     # 0x2d7db
movq %r12, %rdx
callq 0x5160
leaq 0x32311(%rip), %rdi     # 0x414d0
movq %r15, %rsi
callq 0x2c10c
movq %r15, %rdi
callq 0x5908
jmp 0xefce
movq 0x20(%rsp), %rax
movl 0x28(%rsp), %ecx
subq 0x10(%rsp), %rax
leaq (%rcx,%rax,8), %rax
cmpq 0x60(%rsp), %rax
je 0xf223
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
leaq 0x1e66c(%rip), %rsi     # 0x2d86b
leaq 0x78(%rsp), %rdx
callq 0x5160
leaq 0x322c0(%rip), %rdi     # 0x414d0
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x2bf18
movq %r15, %rdi
callq 0x5908
leaq 0x78(%rsp), %rdi
movq %r14, %rsi
callq 0x1bc58
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1bcc8
movq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x10122
movq %r15, %rdi
callq 0x5908
movq %r15, %rdi
movq %r14, %rsi
callq 0x1bd18
movq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x10122
movq %r15, %rdi
callq 0x5908
movq %r14, %rdi
callq 0x1bc80
movl %eax, 0x98(%rsp)
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x1027a
xorl %r15d, %r15d
movl %r15d, %r15d
movq 0x20(%rsp), %rax
movl 0x28(%rsp), %ecx
subq 0x10(%rsp), %rax
leaq (%rcx,%rax,8), %rax
cmpq %r15, %rax
jbe 0xf2e1
movq 0x70(%rsp), %rax
movq (%rax), %rbp
movq %r12, %rdi
movq %r15, %rsi
callq 0x9cc0
imulq $0x28, %r15, %rcx
addq %rcx, %rbp
xorl %esi, %esi
testq %rdx, (%rax)
setne %sil
movq %rbp, %rdi
callq 0x9d32
incl %r15d
jmp 0xf297
leaq 0x78(%rsp), %rdi
jmp 0xf316
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x1e540(%rip), %rsi     # 0x2d83a
leaq 0x78(%rsp), %rdx
callq 0x5160
leaq 0x321c5(%rip), %rdi     # 0x414d0
movq %rbp, %rsi
callq 0x2c10c
movq %rbp, %rdi
callq 0x5908
movq 0x8(%rsp), %rbp
jmp 0xf35a
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
leaq 0x1e506(%rip), %rsi     # 0x2d83a
leaq 0x78(%rsp), %rdx
callq 0x5160
leaq 0x3218b(%rip), %rdi     # 0x414d0
movq %r15, %rsi
callq 0x2c10c
movq 0x8(%rsp), %rbp
movq %r15, %rdi
callq 0x5908
movq %r12, %rdi
callq 0xa0a6
jmp 0xefce
testq %r14, %r14
je 0xf375
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
leaq 0x40(%rsp), %rdi
callq 0xe88a
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0xf43e
jmp 0xf431
jmp 0xf44f
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0xf43e
jmp 0xf431
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0xf43e
jmp 0xf431
jmp 0xf3d0
jmp 0xf436
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5908
jmp 0xf439
jmp 0xf436
jmp 0xf431
jmp 0xf436
jmp 0xf431
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0xf404
jmp 0xf44f
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x5908
jmp 0xf452
jmp 0xf44f
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
jmp 0xf43e
jmp 0xf431
jmp 0xf41e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5908
jmp 0xf45c
jmp 0xf431
jmp 0xf431
movq %rax, %rbx
jmp 0xf443
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5908
leaq 0x10(%rsp), %rdi
callq 0xa0a6
jmp 0xf452
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xe88a
movq %rbx, %rdi
callq 0x5800