// File: 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 %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x90(%rbp)
movq $0x0, -0x10(%rbp)
addq $0x248, %rdi            # imm = 0x248
callq 0x45e0
testb $0x1, %al
jne 0xbd74
jmp 0xbd87
movq -0x90(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0x4060
movq -0x90(%rbp), %rsi
addq $0x668, %rsi            # imm = 0x668
leaq 0x179e1(%rip), %rdx     # 0x2377d
leaq -0x30(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x7920
movq -0x90(%rbp), %rax
movq -0xa0(%rbp), %rdi
addq $0x248, %rax            # imm = 0x248
movq %rax, -0x98(%rbp)
callq 0x4140
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0xbde2
movq -0x90(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0x45e0
movb %al, -0xa1(%rbp)
jmp 0xbdfd
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0xbf5d
jmp 0xbe0d
movq 0x201dc(%rip), %rdi     # 0x2bff0
leaq 0x17967(%rip), %rsi     # 0x23782
callq 0x4310
movq %rax, -0xb0(%rbp)
jmp 0xbe29
movq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x42e0
movq %rax, -0xb8(%rbp)
jmp 0xbe42
movq -0xb8(%rbp), %rdi
leaq 0x17704(%rip), %rsi     # 0x23554
callq 0x4310
movq %rax, -0xc0(%rbp)
jmp 0xbe5e
movq -0xc0(%rbp), %rdi
movq 0x20144(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0xbe73
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xc19c
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x48(%rbp)
movq 0x20143(%rip), %rdi     # 0x2bff0
leaq 0x178ef(%rip), %rsi     # 0x237a3
callq 0x4310
movq %rax, -0xc8(%rbp)
jmp 0xbec2
movq -0xc8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x42e0
movq %rax, -0xd0(%rbp)
jmp 0xbedb
movq -0xd0(%rbp), %rdi
leaq 0x17afc(%rip), %rsi     # 0x239e5
callq 0x4310
movq %rax, -0xd8(%rbp)
jmp 0xbef7
movq -0x48(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x1eeb0
jmp 0xbf0e
movq -0xd8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x42e0
movq %rax, -0xe0(%rbp)
jmp 0xbf27
movq -0xe0(%rbp), %rdi
movq 0x20093(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0xbf3c
leaq -0x68(%rbp), %rdi
callq 0x46d8
leaq 0x178ae(%rip), %rdi     # 0x237fa
callq 0x42a0
jmp 0xbf53
movl $0x1, %edi
callq 0x4400
jmp 0xbf8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xbf82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0xbf89
jmp 0xc19c
movq $0xa00000, -0x70(%rbp)  # imm = 0xA00000
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, -0xe8(%rbp)
jmp 0xbfa9
movq -0xe8(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0xc05a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0xc19c
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x80(%rbp)
movq 0x20007(%rip), %rdi     # 0x2bff0
leaq 0x177d1(%rip), %rsi     # 0x237c1
callq 0x4310
movq %rax, -0xf0(%rbp)
jmp 0xbffe
movq -0x80(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x4310
movq %rax, -0xf8(%rbp)
jmp 0xc023
movq -0xf8(%rbp), %rdi
movq 0x1ff7f(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0xc038
movl $0x4, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4580
jmp 0xc055
jmp 0xc19c
jmp 0xc05c
movq -0x90(%rbp), %rax
movq 0x248(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x248(%rax,%rcx), %rdi
callq 0x4440
movb %al, -0xf9(%rbp)
jmp 0xc083
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0xc092
jmp 0xc146
movq -0x90(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
movq -0x78(%rbp), %rsi
movl $0xa00000, %edx         # imm = 0xA00000
callq 0x4450
jmp 0xc0b0
movq $0x0, -0x88(%rbp)
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rax
movq %rax, -0x110(%rbp)
addq $0x248, %rdi            # imm = 0x248
callq 0x46c0
movq %rax, -0x108(%rbp)
jmp 0xc0e5
movq -0x110(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpq %rcx, %rax
jae 0xc141
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xc128
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xc128
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc19c
jmp 0xc12a
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0xc0bb
jmp 0xc05c
movq -0x78(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, %rax
je 0xc163
movq -0x118(%rbp), %rdi
callq 0x4480
movq -0x90(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0x4060
jmp 0xc178
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x46d8
movq -0x120(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x46d8
movq -0x38(%rbp), %rdi
callq 0x4610
movq %rax, %rdi
callq 0x82c0
nopw %cs:(%rax,%rax)