// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rsi, (%rsp)
movq 0x20(%rsi), %rsi
callq 0x9280
movq (%rsp), %rax
movq 0x18(%rax), %rbx
testq %rbx, %rbx
je 0x8e4b
leaq 0x10(%rsp), %r15
leaq 0x8(%rbx), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x8e3b
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x8e43
movq %r15, %rdi
callq 0x96bc
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x8e1a
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x8e87
movq %r12, %rax
subq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x97db
movq %r15, %rdi
movq %r12, %rsi
callq 0x98c4
movq (%rsp), %rax
leaq 0x40(%rax), %rdi
leaq 0x10(%rsp), %rsi
callq 0x52a0
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0x50(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq (%rsp), %rax
movq (%rax), %rsi
callq 0x931c
movq (%r14), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%r14,%rdi)
jne 0x8fd7
movq (%rsp), %rax
leaq 0x8(%rax), %r15
addq %r14, %rdi
leaq 0x70(%rsp), %r12
leaq 0x48(%rsp), %rbp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %r14, 0x68(%rsp)
movl $0xa, %esi
callq 0x2250
movsbl %al, %edx
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2480
cmpq $0x0, 0x30(%rsp)
je 0x8fc0
movq (%rsp), %rax
movq 0x20(%rax), %rsi
movl $0xffffffff, 0x48(%rsp) # imm = 0xFFFFFFFF
movq %r12, %r14
movq %r12, %rdi
movq %rbp, %rdx
leaq 0xf(%rsp), %rcx
callq 0x79be
cmpq $0x0, 0x30(%rsp)
je 0x8f91
xorl %r12d, %r12d
movq 0x28(%rsp), %rax
movsbl (%rax,%r12), %r13d
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x48(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x9b36
movq (%rax), %rax
movl %r13d, %ecx
addl $-0x30, %ecx
cmpb $0x58, %r13b
movq 0x70(%rsp), %rdx
cmovel %ebx, %ecx
movl %ecx, (%rdx,%rax,4)
incq %r12
cmpq 0x30(%rsp), %r12
jb 0x8f4c
leaq 0x50(%rsp), %rdi
movq %r14, %r12
movq %r14, %rsi
callq 0x93fa
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
movq 0x68(%rsp), %r14
je 0x8fc0
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2290
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
testb $0x2, 0x20(%r14,%rax)
je 0x8ef8
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movq (%rsp), %rax
cmpq (%rax), %rcx
je 0x9042
movq 0x6fed(%rip), %r14      # 0xfff0
leaq 0x2861(%rip), %rsi      # 0xb86b
movl $0x61, %edx
movq %r14, %rdi
callq 0x22b0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2250
movsbl %al, %esi
movq 0x6fbb(%rip), %rdi      # 0xfff0
callq 0x2030
movq %rax, %rdi
callq 0x21a0
movq (%rsp), %rax
leaq 0x88(%rax), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5630
movq (%rsp), %rax
movb $0x1, 0xb1(%rax)
leaq 0x50(%rsp), %rdi
callq 0x6200
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x9088
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2290
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x909f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2290
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x90b5
jmp 0x90be
movq %rax, %rbx
jmp 0x910b
jmp 0x90be
jmp 0x90c8
movq %rax, %rbx
leaq 0x38(%rsp), %r14
jmp 0x90ea
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
leaq 0x38(%rsp), %r14
je 0x90ea
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2290
leaq 0x50(%rsp), %rdi
callq 0x6200
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x910b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2290
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9122
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2290
movq %rbx, %rdi
callq 0x2450