// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xd8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x56c0
leaq -0x38(%rbp), %rdi
callq 0x2300
movq -0xd8(%rbp), %rdi
movq $0x0, -0x40(%rbp)
movq $0x0, (%rdi)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2440
movb %al, -0xe1(%rbp)
jmp 0x156f7
movb -0xe1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x15708
jmp 0x158d1
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2050
jmp 0x15717
leaq -0x78(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x20e0
jmp 0x15726
leaq -0x78(%rbp), %rdi
callq 0x15970
movq %rax, -0xf0(%rbp)
jmp 0x15738
movq -0xd8(%rbp), %rsi
movq -0xf0(%rbp), %rax
incq %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6050
movq %rax, -0xf8(%rbp)
jmp 0x1575f
movq -0xd8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, (%rax)
leaq -0x78(%rbp), %rdi
callq 0x2150
leaq -0x38(%rbp), %rdi
callq 0x2190
cmpq $0x0, %rax
je 0x157a5
leaq -0x38(%rbp), %rdi
leaq 0x7043(%rip), %rsi      # 0x1c7d9
xorl %eax, %eax
movl %eax, %edx
callq 0x2470
cmpq $0x0, %rax
jne 0x157d5
jmp 0x156dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1592b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2150
jmp 0x1592b
movq -0xd8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x100(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x20e0
jmp 0x157f9
movq -0x100(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0x15bf0
jmp 0x15815
leaq -0xc8(%rbp), %rdi
callq 0x2150
movq -0x80(%rbp), %rax
subq -0x88(%rbp), %rax
cmpq $0x1, %rax
jae 0x1585b
movl $0x2, -0xcc(%rbp)
jmp 0x15895
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x2150
jmp 0x1592b
movq -0xd8(%rbp), %rdi
addq $0x58, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x16560
jmp 0x15874
movq -0x80(%rbp), %rax
subq -0x88(%rbp), %rax
addq $0x1, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0xcc(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5ff0
movl -0xcc(%rbp), %eax
testl %eax, %eax
je 0x158b2
jmp 0x158ad
jmp 0x156dc
jmp 0x156dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5ff0
jmp 0x1592b
movq -0xd8(%rbp), %rdi
movq -0x40(%rbp), %rax
movq %rax, -0x108(%rbp)
addq $0x58, %rdi
callq 0x8f70
movq %rax, %rcx
movq -0x108(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0xa8(%rax)
movb $0x1, -0x11(%rbp)
movl $0x1, -0xcc(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2150
testb $0x1, -0x11(%rbp)
jne 0x1594e
jmp 0x15942
leaq -0x38(%rbp), %rdi
callq 0x2150
movq -0xd8(%rbp), %rdi
callq 0x5a80
jmp 0x1595e
movq -0xd8(%rbp), %rdi
callq 0x5a80
movq -0xe0(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2410
nopw (%rax,%rax)