// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_filter.cpp
// Function: BamTools::BamAlignmentChecker::checkAlignmentTag(BamTools::PropertyFilterValue const&, BamTools::BamAlignment const&)
bool checkAlignmentTag(const PropertyFilterValue& valueFilter, const BamAlignment& al) {
     
        // ensure filter contains string data
        Variant entireTagFilter = valueFilter.Value;
        if ( !entireTagFilter.is_type<string>() ) return false;

        // localize string from variant
        const string& entireTagFilterString = entireTagFilter.get<string>();

        // ensure we have at least "XX:x"
        if ( entireTagFilterString.length() < 4 ) return false;

        // get tagName & lookup in alignment
        // if found, set tagType to tag type character
        // if not found, return false
        const string& tagName = entireTagFilterString.substr(0,2);
        char tagType = '\0';
        if ( !al.GetTagType(tagName, tagType) ) return false;

        // remove tagName & ":" from beginning tagFilter
        string tagFilterString = entireTagFilterString.substr(3);

        // switch on tag type to set tag query value & parse filter token
        int8_t   asciiFilterValue,   asciiQueryValue;
        int32_t  intFilterValue,    intQueryValue;
        uint32_t uintFilterValue,   uintQueryValue;
        float    realFilterValue,   realQueryValue;
        string   stringFilterValue, stringQueryValue;

        PropertyFilterValue tagFilter;
        PropertyFilterValue::ValueCompareType compareType;
        bool keepAlignment = false;
        switch (tagType) {

            // ASCII tag type
            case 'A':
                if ( al.GetTag(tagName, asciiQueryValue) ) {
                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, asciiFilterValue, compareType) ) {
                        tagFilter.Value = asciiFilterValue;
                        tagFilter.Type  = compareType;
                        keepAlignment   = tagFilter.check(asciiQueryValue);
                    }
                }
                break;

            // signed int tag type
            case 'c' :
            case 's' :
            case 'i' :
                if ( al.GetTag(tagName, intQueryValue) ) {
                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, intFilterValue, compareType) ) {
                        tagFilter.Value = intFilterValue;
                        tagFilter.Type  = compareType;
                        keepAlignment   = tagFilter.check(intQueryValue);
                    }
                }
                break;

            // unsigned int tag type
            case 'C' :
            case 'S' :
            case 'I' :
                if ( al.GetTag(tagName, uintQueryValue) ) {
                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, uintFilterValue, compareType) ) {
                        tagFilter.Value = uintFilterValue;
                        tagFilter.Type  = compareType;
                        keepAlignment   = tagFilter.check(uintQueryValue);
                    }
                }
                break;

            // 'real' tag type
            case 'f' :
                if ( al.GetTag(tagName, realQueryValue) ) {
                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, realFilterValue, compareType) ) {
                        tagFilter.Value = realFilterValue;
                        tagFilter.Type  = compareType;
                        keepAlignment   = tagFilter.check(realQueryValue);
                    }
                }
                break;

            // string tag type

            case 'Z':
            case 'H':
                if ( al.GetTag(tagName, stringQueryValue) ) {
                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, stringFilterValue, compareType) ) {
                        tagFilter.Value = stringFilterValue;
                        tagFilter.Type  = compareType;
                        keepAlignment   = tagFilter.check(stringQueryValue);
                    }
                }
                break;

            // unknown tag type
            default :
                keepAlignment = false;
        }

        return keepAlignment;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %rbx
movq (%rsi), %rax
testq %rax, %rax
je 0x40285
incq 0x8(%rax)
leaq 0x28(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3a7b4
testb %al, %al
je 0x402aa
movq 0x28(%rsp), %rdi
callq 0x40bbe
movq %rax, %r14
cmpq $0x4, 0x18(%rax)
jae 0x402d3
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x402c2
decq 0x8(%rdi)
jne 0x402c2
movq (%rdi), %rax
callq *0x8(%rax)
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
addq $0x10, %r14
leaq 0x58(%rsp), %rdi
movl $0x2, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0x27600
leaq 0xf(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x277e0
testb %al, %al
je 0x40425
leaq 0x78(%rsp), %rdi
movl $0x3, %edx
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x27600
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
movq %rax, 0x10(%rsp)
movl $0x2, 0x18(%rsp)
movzbl 0xf(%rsp), %eax
cmpl $0x59, %eax
jg 0x4042c
leal -0x41(%rax), %ecx
cmpl $0x8, %ecx
ja 0x40641
leaq 0x31896(%rip), %rax     # 0x71c10
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x58(%rsp), %rsi
leaq 0xd(%rsp), %rdx
movq %rbx, %rdi
callq 0x410a2
testb %al, %al
je 0x40852
leaq 0x78(%rsp), %rdi
leaq 0xe(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x41110
testb %al, %al
je 0x40852
movb 0xe(%rsp), %bl
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4e527(%rip), %rax     # 0x8e8f8
movq %rax, (%r14)
movb %bl, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x403f6
decq 0x8(%rdi)
jne 0x403f6
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x4040a
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movl 0x8(%rsp), %eax
leaq 0x10(%rsp), %rdi
movl %eax, 0x8(%rdi)
leaq 0xd(%rsp), %rsi
callq 0x4156c
jmp 0x4084e
xorl %ebx, %ebx
jmp 0x408a4
cmpl $0x65, %eax
jle 0x40449
cmpl $0x66, %eax
je 0x406f3
cmpl $0x69, %eax
je 0x4045b
cmpl $0x73, %eax
je 0x4045b
jmp 0x406ec
cmpl $0x5a, %eax
je 0x404dd
cmpl $0x63, %eax
jne 0x406ec
cmpb $0x0, 0x130(%rbx)
jne 0x40852
movq 0x90(%rbx), %rax
testq %rax, %rax
je 0x40852
movq 0x88(%rbx), %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x54(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x50(%rsp), %r8
movl $0x0, (%r8)
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x27700
testb %al, %al
je 0x40852
movq 0x20(%rsp), %rsi
movzbl -0x1(%rsi), %eax
cmpl $0x68, %eax
jg 0x407a5
movl $0x1, %edx
cmpl $0x41, %eax
je 0x407bf
cmpl $0x63, %eax
je 0x407bf
jmp 0x40852
cmpb $0x0, 0x130(%rbx)
jne 0x40852
movq 0x90(%rbx), %rax
testq %rax, %rax
je 0x40852
movq 0x88(%rbx), %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x54(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x50(%rsp), %r8
movl $0x0, (%r8)
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x27700
testb %al, %al
je 0x40852
movq 0x20(%rsp), %rdi
callq 0x272f0
leaq 0x98(%rsp), %rdi
movq $0x0, 0x8(%rdi)
movq (%rdi), %rcx
movb $0x0, (%rcx)
movl %eax, %ebx
movq %rbx, %rsi
xorl %edx, %edx
callq 0x271f0
movq 0x98(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x274c0
leaq 0x78(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x38ff0
testb %al, %al
je 0x40852
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x2f10a
leaq 0x20(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x2f6a2
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x405dd
incq 0x8(%rdi)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x405fb
decq 0x8(%rax)
jne 0x405fb
movq (%rax), %rcx
movq %rax, %rdi
callq *0x8(%rcx)
movq 0x20(%rsp), %rdi
movq %rdi, 0x10(%rsp)
testq %rdi, %rdi
je 0x40611
decq 0x8(%rdi)
jne 0x40611
movq (%rdi), %rax
callq *0x8(%rax)
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x40623
callq 0x27560
movl 0x8(%rsp), %eax
leaq 0x10(%rsp), %rdi
movl %eax, 0x8(%rdi)
leaq 0x98(%rsp), %rsi
callq 0x3fdb8
jmp 0x4084e
cmpl $0x53, %eax
jne 0x406ec
leaq 0x58(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x41682
testb %al, %al
je 0x40852
leaq 0x78(%rsp), %rdi
leaq 0x44(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x38814
testb %al, %al
je 0x40852
movl 0x44(%rsp), %ebx
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4e1b8(%rip), %rax     # 0x8e850
movq %rax, (%r14)
movl %ebx, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x406bd
decq 0x8(%rdi)
jne 0x406bd
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x406d1
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movl 0x8(%rsp), %eax
leaq 0x10(%rsp), %rdi
movl %eax, 0x8(%rdi)
leaq 0x40(%rsp), %rsi
callq 0x3fcaa
jmp 0x4084e
xorl %ebx, %ebx
jmp 0x4086a
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x418f6
testb %al, %al
je 0x40852
leaq 0x78(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x419ae
testb %al, %al
je 0x40852
movss 0x3c(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4e1e7(%rip), %rax     # 0x8e930
movq %rax, (%r14)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x40776
decq 0x8(%rdi)
jne 0x40776
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x4078a
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movl 0x8(%rsp), %eax
leaq 0x10(%rsp), %rdi
movl %eax, 0x8(%rdi)
leaq 0x38(%rsp), %rsi
callq 0x41dfc
jmp 0x4084e
cmpl $0x69, %eax
je 0x407ba
cmpl $0x73, %eax
jne 0x40852
movl $0x2, %edx
jmp 0x407bf
movl $0x4, %edx
leaq 0x48(%rsp), %rdi
movl $0x0, (%rdi)
callq 0x274c0
leaq 0x78(%rsp), %rdi
leaq 0x4c(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x37856
testb %al, %al
je 0x40852
movl 0x4c(%rsp), %ebx
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4e019(%rip), %rax     # 0x8e818
movq %rax, (%r14)
movl %ebx, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x40824
decq 0x8(%rdi)
jne 0x40824
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x40838
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movl 0x8(%rsp), %eax
leaq 0x10(%rsp), %rdi
movl %eax, 0x8(%rdi)
leaq 0x48(%rsp), %rsi
callq 0x3ff28
movl %eax, %ebx
jmp 0x40854
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4086a
decq 0x8(%rdi)
jne 0x4086a
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x4087c
callq 0x27560
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4088e
callq 0x27560
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408a4
callq 0x27560
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x402ac
callq 0x27560
jmp 0x402ac
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x40930
decq 0x8(%rdi)
jne 0x40930
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x40930
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40956
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40956
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40956
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40956
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40956
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40956
jmp 0x40953
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40956
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40956
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x40956
callq 0x27560
jmp 0x40956
jmp 0x40953
jmp 0x40953
jmp 0x40953
jmp 0x40953
movq %rax, %rbx
jmp 0x4096c
jmp 0x409a8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4096c
decq 0x8(%rdi)
jne 0x4096c
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x4097e
callq 0x27560
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x40990
callq 0x27560
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x409ab
callq 0x27560
jmp 0x409ab
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x409c7
callq 0x27560
jmp 0x409c7
jmp 0x409c4
jmp 0x409c4
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x409dd
decq 0x8(%rdi)
jne 0x409dd
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x27b10
movq %rax, %rdi
callq 0x2e1cd
nop