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

    /*
     * I am using the line-end counting method. It is > 2-fold faster than reading lines with getline().
     */
    if (_varFile.is_open()) {
        _varFile.close();
    }
    try {
        _varFile.open(_fileName.c_str(), ios::in);
		if (!_varFile.is_open()) {
			cerr << "ERROR: failed to open HMP file " << _fileName << " for input" << endl;
			exit(2);
		}

    } catch (system_error &error) {
        cerr << "ERROR: cannot open HMP file " << _fileName << " for input: " << error.code().message() << flush;
        perror(" ");
        exit(1);

    }
    // skip header line if present.
    string trash;
    if (_head) {
        getline(_varFile, trash);
    }

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

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

    return N;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
leaq 0x8(%rdi), %rbx
leaq 0x88(%rdi), %r12
movq %r12, %rdi
callq 0x40b0
testb %al, %al
je 0x1161f
movq %rbx, %rdi
callq 0x4050
leaq 0x218(%r14), %r15
movq 0x218(%r14), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x4280
movq %r12, %rdi
callq 0x40b0
testb %al, %al
je 0x116e6
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpb $0x1, 0x238(%r14)
jne 0x11670
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4060
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, %r12
xorl %r15d, %r15d
movq 0x8(%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%r14,%rax)
jne 0x116bd
movl $0xa00000, %edx         # imm = 0xA00000
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4340
movq 0x10(%r14), %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x11680
xorl %edx, %edx
cmpb $0xa, (%r12,%rcx)
sete %dl
addq %rdx, %r15
incq %rcx
jmp 0x116a6
movq %rbx, %rdi
callq 0x4050
movq %r12, %rdi
callq 0x4370
leaq 0x8(%rsp), %rdi
callq 0x4558
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xa903(%rip), %rdi      # 0x1bff0
leaq 0x377a(%rip), %rsi      # 0x14e6e
callq 0x42a0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4270
leaq 0x2e61(%rip), %rsi      # 0x1456c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
pushq $0x2
jmp 0x11774
jmp 0x11835
jmp 0x11835
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x11838
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xa8a9(%rip), %rdi      # 0x1bff0
leaq 0x375d(%rip), %rsi      # 0x14eab
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 0x11838
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x11842
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xa84b(%rip), %rdi      # 0x1bff0
leaq 0x36e2(%rip), %rsi      # 0x14e8e
callq 0x42a0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4270
leaq 0x323a(%rip), %rsi      # 0x149fd
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x20(%rax)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
leaq 0x8(%rsp), %rdi
callq 0x4558
leaq 0x300c(%rip), %rdi      # 0x14812
callq 0x4250
pushq $0x1
jmp 0x11774
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4558
jmp 0x11826
jmp 0x11823
movq %rax, %rbx
callq 0x4470
jmp 0x11842
movq %rax, %rdi
callq 0x6194
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4558
movq %rbx, %rdi
callq 0x44d0