// File: /workspace/github_cpp_makefile_star2_O2/tonymugen[P]sampleSNPs/varfiles.cpp
// Function: sampFiles::BedFileI::_famLines()
uint64_t BedFileI::_famLines(){
	uint64_t N = 0;

	/*
	 * I am using the line-end counting method. It is > 2-fold faster than reading lines with getline().
	 */
	if (_famFile.is_open()) {
        _famFile.close();
    }
    string famName = _fileStub + ".fam";
    try {
        _famFile.open(famName.c_str(), ios::in);
		if (!_famFile.is_open()) {
			cerr << "ERROR: failed to open .fam file " << famName << " for input" << endl;
			exit(2);
		}
    } catch (system_error &error) {
        cerr << "ERROR: cannot open .fam file " << famName << " for input: " << error.code().message() << flush;
        perror(" ");
        exit(1);
    }

	const size_t bufSize = BUF_SIZE;
	char *buf;
	try {
		buf = new char[bufSize];
	} catch (bad_alloc& error) {
		cerr << "ERROR: failed to allocate buffer in BedFile::_famLines(): " << error.what() << endl;
		exit(4);
	}

	while (_famFile) {
		_famFile.read(buf, bufSize);
		for (size_t i = 0; i < _famFile.gcount(); i++) {
			if (buf[i] == '\n') {
				N++;
			}
		}
	}
	delete [] buf;
	_famFile.close();
	return N;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
leaq 0x248(%rdi), %rbx
leaq 0x2c8(%rdi), %r15
movq %r15, %rdi
callq 0x40b0
testb %al, %al
je 0x782e
movq %rbx, %rdi
callq 0x4050
leaq 0x668(%r14), %rsi
leaq 0xcf59(%rip), %rdx      # 0x14795
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x5e08
movq (%r12), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x4280
movq %r15, %rdi
callq 0x40b0
testb %al, %al
je 0x78e3
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, %r12
xorl %r15d, %r15d
movq 0x248(%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x268(%r14,%rax)
jne 0x78ba
movl $0xa00000, %edx         # imm = 0xA00000
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4340
movq 0x250(%r14), %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x7874
xorl %edx, %edx
cmpb $0xa, (%r12,%rcx)
sete %dl
addq %rdx, %r15
incq %rcx
jmp 0x78a3
movq %r12, %rdi
callq 0x4370
movq %rbx, %rdi
callq 0x4050
leaq 0x8(%rsp), %rdi
callq 0x4558
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x14706(%rip), %rdi     # 0x1bff0
leaq 0xcea9(%rip), %rsi      # 0x1479a
callq 0x42a0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
leaq 0xcc62(%rip), %rsi      # 0x1456c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
pushq $0x2
jmp 0x796e
jmp 0x7a31
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x7a34
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0x146af(%rip), %rdi     # 0x1bff0
leaq 0xce91(%rip), %rsi      # 0x147d9
callq 0x42a0
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
pushq $0x4
popq %rdi
callq 0x4310
movq %rax, %rbx
callq 0x4470
jmp 0x7a34
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x7a34
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0x14651(%rip), %rdi     # 0x1bff0
leaq 0xce15(%rip), %rsi      # 0x147bb
callq 0x42a0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
leaq 0xd03e(%rip), %rsi      # 0x149fd
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x28(%rsp), %rdi
callq *0x20(%rax)
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
leaq 0x28(%rsp), %rdi
callq 0x4558
leaq 0xce10(%rip), %rdi      # 0x14812
callq 0x4250
pushq $0x1
jmp 0x796e
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x4558
jmp 0x7a22
jmp 0x7a1f
movq %rax, %rbx
callq 0x4470
jmp 0x7a34
movq %rax, %rdi
callq 0x6194
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4558
movq %rbx, %rdi
callq 0x44d0