// File: /workspace/github_c_makefile_star2_O3/waynebhayes[P]SAHap/src/InputReader.cpp
// Function: SAHap::WIFInputReader::read(std::basic_ifstream<char, std::char_traits<char>>&)
InputFile WIFInputReader::read(ifstream& file) {
	InputFile result;
	string buf;

	dnacnt_t totalReadLength = 0;
	
	result.ploidy = 0;
	while (!file.eof()) {
		
		getline(file, buf);
		result.ploidy = max(WIFInputReader::getPloidy(buf)+1,result.ploidy);

		
		if (buf.size() == 0 || buf.find("#") == 0) continue;

		Read read = WIFInputReader::parseRead(result.index, buf);
		if (read.range.end - read.range.start < 1)
			continue;
		result.reads.push_back(read);
		totalReadLength += read.range.end - read.range.start + 1;
	}
	result.averageReadLength = totalReadLength / result.reads.size();

	// std::cout << "Total: " << totalReadLength << std::endl;
	// std::cout << "Average Read Length: " << result.averageReadLength << std::endl;
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x38(%rdi), %rax
movq %rax, 0x8(%rdi)
movq $0x1, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rdi)
movl $0x3f800000, 0x28(%rdi) # imm = 0x3F800000
addq $0x30, %rdi
xorl %r15d, %r15d
movl $0x82, %edx
xorl %esi, %esi
callq 0x2140
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb $0x0, (%rax)
movq $0x0, (%rsp)
movq %r15, (%rbx)
movq (%r14), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%r14,%rdi)
jne 0x8801
leaq 0x8(%rbx), %rax
movq %rax, 0x50(%rsp)
addq %r14, %rdi
leaq 0x68(%rsp), %r15
leaq 0x58(%rbx), %rax
movq %rax, 0x48(%rsp)
movq $0x0, (%rsp)
leaq 0x8(%rsp), %rbp
leaq 0x58(%rsp), %r13
leaq 0x31b4(%rip), %r12      # 0xb869
movl $0xa, %esi
callq 0x2250
movsbl %al, %edx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2480
movq %r15, 0x58(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x9426
movq %r13, %rdi
callq 0x88de
incq %rax
movq (%rbx), %rcx
cmpq %rcx, %rax
cmovbeq %rcx, %rax
movq %rax, (%rbx)
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x8716
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2290
cmpq $0x0, 0x10(%rsp)
je 0x8735
movl $0x1, %ecx
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2440
testq %rax, %rax
jne 0x8751
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
testb $0x2, 0x20(%r14,%rax)
je 0x86b5
jmp 0x8801
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x9426
leaq 0x78(%rsp), %rdi
movq 0x50(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x8b0a
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x87a2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2290
movq 0xa0(%rsp), %rax
cmpq 0x98(%rsp), %rax
je 0x87de
movq 0x48(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x9230
movq (%rsp), %rax
addq 0xa0(%rsp), %rax
subq 0x98(%rsp), %rax
incq %rax
movq %rax, (%rsp)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x8735
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x2290
jmp 0x8735
movq 0x60(%rbx), %rax
subq 0x58(%rbx), %rax
sarq $0x4, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movq (%rsp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, 0xa8(%rbx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x8847
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2290
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x88b2
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
jmp 0x88a8
movq %rax, %r14
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x88b2
movq 0x38(%rsp), %rsi
jmp 0x88a5
jmp 0x88af
jmp 0x88af
movq %rax, %r14
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x88b2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2290
jmp 0x88b2
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x88ce
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2290
movq %rbx, %rdi
callq 0x51c0
movq %r14, %rdi
callq 0x2450