// File: /workspace/github_c_makefile_star2_O2/waynebhayes[P]SAHap/src/InputReader.cpp
// Function: SAHap::WIFInputReader::readGroundTruth(std::basic_ifstream<char, std::char_traits<char>>&, SAHap::InputFile&)
void WIFInputReader::readGroundTruth(ifstream& file, InputFile& parsed) {
	// Obtain sorted list of sites covered
	vector<dnapos_t> sites;
	sites.reserve(parsed.index.size());
	for (const auto& kv : parsed.index) {
		sites.push_back(kv.first);
	}
	sort(sites.begin(), sites.end());
	parsed.sites = sites;

	string buf;
	vector<vector<int>> truth;
	truth.reserve(parsed.ploidy);

	while (!file.eof()) {
		getline(file, buf);
		if (buf.size() == 0) continue;
		vector<int> ch(parsed.index.size(), -1);
		for (size_t i = 0; i < buf.size(); ++i) {
			char allele = buf[i];
			dnapos_t pos = sites[i];
			dnapos_t matrixPos = parsed.index[pos];
			if (allele == 'X') ch[matrixPos] = -1;
			else ch[matrixPos] = allele - '0';
			// else throw "Invalid ground truth allele value";
		}
		truth.push_back(ch);
	}

	if (truth.size() != parsed.ploidy) {
		cerr << "Warning: Number of haplotypes in ground truth does not match ploidy! Results will be meaningless." << endl;
	}

	parsed.groundTruth = truth;
	parsed.hasGroundTruth = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq 0x20(%rsi), %rsi
callq 0x84b4
leaq 0x8(%rbx), %r15
movq %rbx, 0x10(%rsp)
addq $0x18, %rbx
leaq 0x20(%rsp), %r12
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x81de
leaq 0x8(%rbx), %rsi
movq %r12, %rdi
callq 0x854a
jmp 0x81c8
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x8937
movq 0x10(%rsp), %r12
leaq 0x40(%r12), %rdi
leaq 0x20(%rsp), %rsi
callq 0x484e
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq (%r12), %rsi
callq 0x856a
leaq 0x18(%rsp), %rbp
pushq $-0x1
popq %rbx
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x20(%r14,%rax)
jne 0x82ee
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x2050
cmpq $0x0, 0x68(%rsp)
je 0x8233
movq 0x20(%r12), %rsi
orl $-0x1, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
movq %rbp, %rdx
leaq 0xf(%rsp), %rcx
callq 0x6fe8
xorl %r12d, %r12d
cmpq 0x68(%rsp), %r12
jae 0x82c7
movq 0x60(%rsp), %rax
movsbl (%rax,%r12), %r13d
movq 0x20(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x18(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8dbe
movq (%rax), %rax
movl %r13d, %ecx
addl $-0x30, %ecx
cmpb $0x58, %r13b
movq 0x80(%rsp), %rdx
cmovel %ebx, %ecx
movl %ecx, (%rdx,%rax,4)
incq %r12
jmp 0x827d
leaq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %r12
movq %r12, %rsi
callq 0x860c
movq %r12, %rdi
callq 0x5628
movq 0x10(%rsp), %r12
jmp 0x8233
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
cmpq (%r12), %rax
je 0x8321
movq 0x7ce3(%rip), %rdi      # 0xfff0
leaq 0x24e7(%rip), %rsi      # 0xa7fb
callq 0x2230
movq %rax, %rdi
callq 0x20f0
leaq 0x88(%r12), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4ac0
movb $0x1, 0xb1(%r12)
leaq 0x40(%rsp), %rdi
callq 0x5900
leaq 0x60(%rsp), %rdi
callq 0x20d0
leaq 0x20(%rsp), %rdi
callq 0x59ae
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8374
jmp 0x8379
jmp 0x837e
jmp 0x8374
movq %rax, %rbx
jmp 0x838e
movq %rax, %rbx
jmp 0x83a2
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x5628
leaq 0x40(%rsp), %rdi
callq 0x5900
leaq 0x60(%rsp), %rdi
callq 0x20d0
leaq 0x20(%rsp), %rdi
callq 0x59ae
movq %rbx, %rdi
callq 0x2400