// File: /workspace/github_cpp_makefile_star2_O2/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 $0x70, %rsp
movq %rsi, %r14
movq %rdi, %rbx
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x349d0
testb %al, %al
je 0x443f3
leaq 0x1a8(%rbx), %r15
movq %r15, %rdi
callq 0x32c20
testb %al, %al
je 0x442e6
movq %r15, %rdi
callq 0x355a0
testb %al, %al
je 0x443f3
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32570
testb %al, %al
je 0x443f3
movq %r15, %rdi
movq %r14, %rsi
callq 0x35120
cmpl $0x2, %eax
je 0x443f3
cmpl $0x1, %eax
je 0x44332
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32570
testb %al, %al
je 0x443f3
movq %r15, %rdi
movq %r14, %rsi
callq 0x35120
jmp 0x44304
movb $0x1, 0x130(%r14)
movb $0x1, %al
jmp 0x443f5
jmp 0x44345
jmp 0x44345
movq %rax, %r14
cmpl $0x1, %edx
jne 0x44447
movq %r14, %rdi
callq 0x31bb0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %rax, %rsi
callq 0x31b30
leaq 0x177d8(%rip), %rsi     # 0x5bb53
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x355e0
leaq 0x10(%rsp), %rdi
callq 0x33a00
leaq 0x177d0(%rip), %rsi     # 0x5bb7f
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x335a0
leaq 0x10(%rsp), %rdi
callq 0x33a00
leaq 0x30(%rsp), %rdi
callq 0x33a00
leaq 0x50(%rsp), %rdi
callq 0x33a00
callq 0x34970
xorl %eax, %eax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x44421
jmp 0x44435
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x44429
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x44438
movq %rax, %r14
jmp 0x44442
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x44438
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x33a00
callq 0x34970
movq %r14, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
nop