// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/bam/BamReader_p.cpp
// Function: BamTools::Internal::BamReaderPrivate::GetNextAlignmentCore(BamTools::BamAlignment&)
bool BamReaderPrivate::GetNextAlignmentCore(BamAlignment& alignment) {

    // skip if stream not opened
    if ( !m_stream.IsOpen() )
        return false;

    try {

        // skip if region is set but has no alignments
        if ( m_randomAccessController.HasRegion() &&
             !m_randomAccessController.RegionHasAlignments() )
        {
            return false;
        }

        // if can't read next alignment
        if ( !LoadNextAlignment(alignment) )
            return false;

        // check alignment's region-overlap state
        BamRandomAccessController::RegionState state = m_randomAccessController.AlignmentState(alignment);

        // if alignment starts after region, no need to keep reading
        if ( state == BamRandomAccessController::AfterRegion )
            return false;

        // read until overlap is found
        while ( state != BamRandomAccessController::OverlapsRegion ) {

            // if can't read next alignment
            if ( !LoadNextAlignment(alignment) )
                return false;

            // check alignment's region-overlap state
            state = m_randomAccessController.AlignmentState(alignment);

            // if alignment starts after region, no need to keep reading
            if ( state == BamRandomAccessController::AfterRegion )
                return false;
        }

        // if we get here, we found the next 'valid' alignment
        // (e.g. overlaps current region if one was set, simply the next alignment if not)
        alignment.SupportData.HasCoreOnly = true;
        return true;

    } catch ( BamException& e ) {
        const string streamError = e.what();
        const string message = string("encountered error reading BAM alignment: \n\t") + streamError;
        SetErrorString("BamReader::GetNextAlignmentCore", message);
        return false;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rsi, %r14
movq %rdi, %rbx
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x28820
testb %al, %al
je 0x3b151
leaq 0x1a8(%rbx), %r15
movq %r15, %rdi
callq 0x272e0
testb %al, %al
je 0x3b022
movq %r15, %rdi
callq 0x29100
testb %al, %al
je 0x3b151
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26ea0
testb %al, %al
je 0x3b151
movq %r15, %rdi
movq %r14, %rsi
callq 0x28df0
cmpl $0x2, %eax
je 0x3b151
cmpl $0x1, %eax
je 0x3b06e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26ea0
testb %al, %al
je 0x3b151
movq %r15, %rdi
movq %r14, %rsi
callq 0x28df0
jmp 0x3b040
movb $0x1, 0x130(%r14)
movb $0x1, %al
jmp 0x3b153
jmp 0x3b081
jmp 0x3b081
movq %rax, %r14
cmpl $0x1, %edx
jne 0x3b1b6
movq %r14, %rdi
callq 0x267d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movq %rax, %rsi
callq 0x26770
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1aa4e(%rip), %rsi     # 0x55b0e
leaq 0x1aa72(%rip), %rdx     # 0x55b39
movq %rsp, %rdi
callq 0x26750
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
callq 0x29130
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b0ef
callq 0x27560
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x1aa3e(%rip), %rsi     # 0x55b3a
leaq 0x1aa56(%rip), %rdx     # 0x55b59
callq 0x26750
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x27a10
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b126
callq 0x27560
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b139
callq 0x27560
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b14c
callq 0x27560
callq 0x287e0
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b173
callq 0x27560
jmp 0x3b173
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3b18f
jmp 0x3b199
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b199
callq 0x27560
jmp 0x3b199
movq %rax, %r14
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b1b1
callq 0x27560
jmp 0x3b1b1
movq %rax, %r14
callq 0x287e0
movq %r14, %rdi
callq 0x28c20
movq %rax, %rdi
callq 0x2f0bd