// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_filter.cpp
// Function: BamTools::BamAlignmentChecker::check(BamTools::PropertyFilter const&, BamTools::BamAlignment const&)
bool check(const PropertyFilter& filter, const BamAlignment& al) {
      
        bool keepAlignment = true;
        const PropertyMap& properties = filter.Properties;
        PropertyMap::const_iterator propertyIter = properties.begin();
        PropertyMap::const_iterator propertyEnd  = properties.end();
        for ( ; propertyIter != propertyEnd; ++propertyIter ) {
          
            // check alignment data field depending on propertyName
            const string& propertyName = (*propertyIter).first;
            const PropertyFilterValue& valueFilter = (*propertyIter).second;
            
            if      ( propertyName == ALIGNMENTFLAG_PROPERTY )  keepAlignment &= valueFilter.check(al.AlignmentFlag);
            else if ( propertyName == CIGAR_PROPERTY ) {
                stringstream cigarSs;
                const vector<CigarOp>& cigarData = al.CigarData;
                if ( !cigarData.empty() ) {
                    vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
                    vector<CigarOp>::const_iterator cigarIter = cigarBegin;
                    vector<CigarOp>::const_iterator cigarEnd  = cigarData.end();
                    for ( ; cigarIter != cigarEnd; ++cigarIter ) {
                        const CigarOp& op = (*cigarIter);
                        cigarSs << op.Length << op.Type;
                    }
                    keepAlignment &= valueFilter.check(cigarSs.str());
                }
            }
            else if ( propertyName == INSERTSIZE_PROPERTY )           keepAlignment &= valueFilter.check(al.InsertSize);
            else if ( propertyName == ISDUPLICATE_PROPERTY )          keepAlignment &= valueFilter.check(al.IsDuplicate());
            else if ( propertyName == ISFAILEDQC_PROPERTY )           keepAlignment &= valueFilter.check(al.IsFailedQC());
            else if ( propertyName == ISFIRSTMATE_PROPERTY )          keepAlignment &= valueFilter.check(al.IsFirstMate());
            else if ( propertyName == ISMAPPED_PROPERTY )             keepAlignment &= valueFilter.check(al.IsMapped());
            else if ( propertyName == ISMATEMAPPED_PROPERTY )         keepAlignment &= valueFilter.check(al.IsMateMapped());
            else if ( propertyName == ISMATEREVERSESTRAND_PROPERTY )  keepAlignment &= valueFilter.check(al.IsMateReverseStrand());
            else if ( propertyName == ISPAIRED_PROPERTY )             keepAlignment &= valueFilter.check(al.IsPaired());
            else if ( propertyName == ISPRIMARYALIGNMENT_PROPERTY )   keepAlignment &= valueFilter.check(al.IsPrimaryAlignment());
            else if ( propertyName == ISPROPERPAIR_PROPERTY )         keepAlignment &= valueFilter.check(al.IsProperPair());
            else if ( propertyName == ISREVERSESTRAND_PROPERTY )      keepAlignment &= valueFilter.check(al.IsReverseStrand());
            else if ( propertyName == ISSECONDMATE_PROPERTY )         keepAlignment &= valueFilter.check(al.IsSecondMate());
            else if ( propertyName == ISSINGLETON_PROPERTY ) {
                const bool isSingleton = al.IsPaired() && al.IsMapped() && !al.IsMateMapped();
                keepAlignment &= valueFilter.check(isSingleton);
            }
            else if ( propertyName == LENGTH_PROPERTY )               keepAlignment &= valueFilter.check(al.Length);
            else if ( propertyName == MAPQUALITY_PROPERTY )           keepAlignment &= valueFilter.check(al.MapQuality);
            else if ( propertyName == MATEPOSITION_PROPERTY )         keepAlignment &= ( al.IsPaired() && al.IsMateMapped() && valueFilter.check(al.MateRefID) );
            else if ( propertyName == MATEREFERENCE_PROPERTY ) {
                if ( !al.IsPaired() || !al.IsMateMapped() ) return false;
                BAMTOOLS_ASSERT_MESSAGE( (al.MateRefID>=0 && (al.MateRefID<(int)filterToolReferences.size())), "Invalid MateRefID");
                const string& refName = filterToolReferences.at(al.MateRefID).RefName;
                keepAlignment &= valueFilter.check(refName);
            }
            else if ( propertyName == NAME_PROPERTY )                 keepAlignment &= valueFilter.check(al.Name);
            else if ( propertyName == POSITION_PROPERTY )             keepAlignment &= valueFilter.check(al.Position);
            else if ( propertyName == QUERYBASES_PROPERTY )           keepAlignment &= valueFilter.check(al.QueryBases);
            else if ( propertyName == REFERENCE_PROPERTY ) {
                BAMTOOLS_ASSERT_MESSAGE( (al.RefID>=0 && (al.RefID<(int)filterToolReferences.size())), "Invalid RefID");
                const string& refName = filterToolReferences.at(al.RefID).RefName;
                keepAlignment &= valueFilter.check(refName);
            }
            else if ( propertyName == TAG_PROPERTY ) keepAlignment &= checkAlignmentTag(valueFilter, al);
            else BAMTOOLS_ASSERT_UNREACHABLE;
            
            // if alignment fails at ANY point, just quit and return false
            if ( !keepAlignment ) return false;
        }
      
        BAMTOOLS_ASSERT_MESSAGE( keepAlignment, "Error in BamAlignmentChecker... keepAlignment should be true here");
        return keepAlignment;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, %r15
movq %rdi, 0x10(%rsp)
movq 0x18(%rsi), %rbp
addq $0x8, %rsi
movq %rsi, 0x48(%rsp)
leaq 0x28(%rdx), %rax
movq %rax, 0x18(%rsp)
leaq 0xac(%rdx), %rax
movq %rax, 0x20(%rsp)
leaq 0xd0(%rdx), %rax
movq %rax, 0x8(%rsp)
leaq 0xb2(%rdx), %rax
movq %rax, 0x28(%rsp)
leaq 0x20(%rdx), %rax
movq %rax, 0x30(%rsp)
leaq 0xd8(%rdx), %rax
movq %rax, 0x38(%rsp)
leaq 0xb4(%rdx), %rax
movq %rax, 0x40(%rsp)
movb $0x1, %bl
leaq 0x1d8(%rsp), %r13
cmpq 0x48(%rsp), %rbp
je 0x45e33
leaq 0x20(%rbp), %r14
leaq 0x40(%rbp), %r12
movq %r14, %rdi
leaq 0x4fd8d(%rip), %rsi     # 0x95788
callq 0x3a2a9
testb %al, %al
je 0x45a16
movq %r12, %rdi
movq 0x40(%rsp), %rsi
callq 0x48e32
jmp 0x45c44
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0x4fd84(%rip), %rsi     # 0x957a8
callq 0x3a2a9
testb %al, %al
je 0x45a79
movq %r13, %r12
leaq 0x50(%rsp), %rdi
callq 0x35430
movq 0xb8(%r15), %r14
movq %r15, %r13
movq 0xc0(%r15), %r15
cmpq %r15, %r14
je 0x45aee
cmpq %r15, %r14
je 0x45a9f
movl 0x4(%r14), %esi
leaq 0x60(%rsp), %rdi
callq 0x35400
movsbl (%r14), %esi
movq %rax, %rdi
callq 0x356e0
addq $0x8, %r14
jmp 0x45a54
movq %r14, %rdi
leaq 0x4fd45(%rip), %rsi     # 0x957c8
callq 0x3a2a9
testb %al, %al
je 0x45ace
movq (%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x49012
jmp 0x45c44
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
callq 0x359c0
movq %r13, %r15
movq %r12, %r13
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x48f0e
movl %eax, %r14d
movq %r13, %rdi
callq 0x35730
andb %r14b, %bl
jmp 0x45af4
movq %r14, %rdi
leaq 0x4fd10(%rip), %rsi     # 0x957e8
callq 0x3a2a9
testb %al, %al
je 0x45b03
movq %r15, %rdi
callq 0x35bc0
jmp 0x45c32
movq %r13, %r15
movq %r12, %r13
leaq 0x50(%rsp), %rdi
callq 0x35490
jmp 0x45c46
movq %r14, %rdi
leaq 0x4fcfb(%rip), %rsi     # 0x95808
callq 0x3a2a9
testb %al, %al
je 0x45b23
movq %r15, %rdi
callq 0x35640
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fcfb(%rip), %rsi     # 0x95828
callq 0x3a2a9
testb %al, %al
je 0x45b43
movq %r15, %rdi
callq 0x352c0
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fcfb(%rip), %rsi     # 0x95848
callq 0x3a2a9
testb %al, %al
je 0x45b63
movq %r15, %rdi
callq 0x350c0
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fcfb(%rip), %rsi     # 0x95868
callq 0x3a2a9
testb %al, %al
je 0x45b83
movq %r15, %rdi
callq 0x356d0
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fcfb(%rip), %rsi     # 0x95888
callq 0x3a2a9
testb %al, %al
je 0x45ba3
movq %r15, %rdi
callq 0x35880
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fcfb(%rip), %rsi     # 0x958a8
callq 0x3a2a9
testb %al, %al
je 0x45bc0
movq %r15, %rdi
callq 0x35320
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fcfe(%rip), %rsi     # 0x958c8
callq 0x3a2a9
testb %al, %al
je 0x45bdd
movq %r15, %rdi
callq 0x35470
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fd01(%rip), %rsi     # 0x958e8
callq 0x3a2a9
testb %al, %al
je 0x45bfa
movq %r15, %rdi
callq 0x35c20
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fd04(%rip), %rsi     # 0x95908
callq 0x3a2a9
testb %al, %al
je 0x45c17
movq %r15, %rdi
callq 0x35830
jmp 0x45c32
movq %r14, %rdi
leaq 0x4fd07(%rip), %rsi     # 0x95928
callq 0x3a2a9
testb %al, %al
je 0x45c5f
movq %r15, %rdi
callq 0x35ba0
movb %al, 0x50(%rsp)
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x490ee
andb %al, %bl
testb $0x1, %bl
je 0x45e31
movq %rbp, %rdi
callq 0x356b0
movq %rax, %rbp
jmp 0x459de
movq %r14, %rdi
leaq 0x4fcdf(%rip), %rsi     # 0x95948
callq 0x3a2a9
testb %al, %al
je 0x45c96
movq %r15, %rdi
callq 0x35320
testb %al, %al
je 0x45cb7
movq %r15, %rdi
callq 0x350c0
testb %al, %al
je 0x45cb7
movq %r15, %rdi
callq 0x356d0
xorb $0x1, %al
jmp 0x45cb9
movq %r14, %rdi
leaq 0x4fcc8(%rip), %rsi     # 0x95968
callq 0x3a2a9
testb %al, %al
je 0x45cc2
movq (%rsp), %rdi
movq 0x30(%rsp), %rsi
jmp 0x45a95
xorl %eax, %eax
movb %al, 0x50(%rsp)
jmp 0x45c36
movq %r14, %rdi
leaq 0x4fcbc(%rip), %rsi     # 0x95988
callq 0x3a2a9
testb %al, %al
je 0x45ce8
movq (%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x491d0
jmp 0x45c44
movq %r14, %rdi
leaq 0x4fcb6(%rip), %rsi     # 0x959a8
callq 0x3a2a9
testb %al, %al
je 0x45d26
movq %r15, %r14
movq %r15, %rdi
callq 0x35320
testb %al, %al
je 0x45d76
movq %r14, %rdi
callq 0x356d0
testb %al, %al
je 0x45d76
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x49012
jmp 0x45d78
movq %r14, %rdi
leaq 0x4fc98(%rip), %rsi     # 0x959c8
callq 0x3a2a9
testb %al, %al
je 0x45d82
movq %r15, %rdi
callq 0x35320
testb %al, %al
je 0x45e31
movq %r15, %rdi
callq 0x356d0
testb %al, %al
je 0x45e31
movq 0x8(%rsp), %rax
movslq (%rax), %rsi
leaq 0x4fd60(%rip), %rdi     # 0x95ac8
callq 0x3a2cc
movq (%rsp), %rdi
movq %rax, %rsi
jmp 0x45d9c
xorl %eax, %eax
andb %al, %bl
movq %r14, %r15
jmp 0x45c46
movq %r14, %rdi
leaq 0x4fc5c(%rip), %rsi     # 0x959e8
callq 0x3a2a9
testb %al, %al
je 0x45da6
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x48f0e
jmp 0x45c44
movq %r14, %rdi
leaq 0x4fc58(%rip), %rsi     # 0x95a08
callq 0x3a2a9
testb %al, %al
je 0x45dc7
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
jmp 0x45a95
movq %r14, %rdi
leaq 0x4fc57(%rip), %rsi     # 0x95a28
callq 0x3a2a9
testb %al, %al
je 0x45de5
movq (%rsp), %rdi
movq 0x18(%rsp), %rsi
jmp 0x45d9c
movq %r14, %rdi
leaq 0x4fc59(%rip), %rsi     # 0x95a48
callq 0x3a2a9
testb %al, %al
je 0x45e04
movslq 0xa8(%r15), %rsi
jmp 0x45d61
movq %r14, %rdi
leaq 0x4fc5a(%rip), %rsi     # 0x95a68
callq 0x3a2a9
testb %al, %al
je 0x45c46
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movq %r15, %rdx
callq 0x492ba
jmp 0x45c44
xorl %ebx, %ebx
andb $0x1, %bl
movl %ebx, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x35730
jmp 0x45e61
jmp 0x45e5e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x35490
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198
nop