// File: /workspace/github_cpp_makefile_star2_O3/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 0x28810
testb %al, %al
je 0x3b0c5
leaq 0x1a8(%rbx), %r15
movq %r15, %rdi
callq 0x272e0
testb %al, %al
je 0x3af96
movq %r15, %rdi
callq 0x290f0
testb %al, %al
je 0x3b0c5
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26ea0
testb %al, %al
je 0x3b0c5
movq %r15, %rdi
movq %r14, %rsi
callq 0x28de0
cmpl $0x2, %eax
je 0x3b0c5
cmpl $0x1, %eax
je 0x3afe2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26ea0
testb %al, %al
je 0x3b0c5
movq %r15, %rdi
movq %r14, %rsi
callq 0x28de0
jmp 0x3afb4
movb $0x1, 0x130(%r14)
movb $0x1, %al
jmp 0x3b0c7
jmp 0x3aff5
jmp 0x3aff5
movq %rax, %r14
cmpl $0x1, %edx
jne 0x3b12a
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 0x1aada(%rip), %rsi     # 0x55b0e
leaq 0x1aafe(%rip), %rdx     # 0x55b39
movq %rsp, %rdi
callq 0x26750
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
callq 0x29120
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b063
callq 0x27560
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x1aaca(%rip), %rsi     # 0x55b3a
leaq 0x1aae2(%rip), %rdx     # 0x55b59
callq 0x26750
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x27a10
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b09a
callq 0x27560
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b0ad
callq 0x27560
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b0c0
callq 0x27560
callq 0x287d0
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b0e7
callq 0x27560
jmp 0x3b0e7
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3b103
jmp 0x3b10d
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3b10d
callq 0x27560
jmp 0x3b10d
movq %rax, %r14
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b125
callq 0x27560
jmp 0x3b125
movq %rax, %r14
callq 0x287d0
movq %r14, %rdi
callq 0x28c10
movq %rax, %rdi
callq 0x2f047