// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
movq (%rsi), %rax
testq %rax, %rax
je 0x4035d
incq 0x8(%rax)
leaq 0x28(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3a81a
testb %al, %al
je 0x40382
movq 0x28(%rsp), %rdi
callq 0x40c94
movq %rax, %rbx
cmpq $0x4, 0x18(%rax)
jae 0x403ab
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x4039a
decq 0x8(%rdi)
jne 0x4039a
movq (%rdi), %rax
callq *0x8(%rax)
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
addq $0x10, %rbx
leaq 0x58(%rsp), %rdi
movl $0x2, %ecx
movq %rbx, %rsi
xorl %edx, %edx
callq 0x27600
leaq 0xf(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x58(%rsp), %rsi
movq %r14, %rdi
callq 0x277f0
testb %al, %al
je 0x404fd
leaq 0x78(%rsp), %rdi
movl $0x3, %edx
movq %rbx, %rsi
movq $-0x1, %rcx
callq 0x27600
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %ebx, %ebx
movq %rbx, -0x8(%r15)
movb %bl, (%r15)
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rbx, -0x8(%r12)
movb %bl, (%r12)
movq %rbx, 0x10(%rsp)
movl $0x2, 0x18(%rsp)
movzbl 0xf(%rsp), %eax
cmpl $0x59, %eax
jg 0x40504
leal -0x41(%rax), %ecx
cmpl $0x8, %ecx
ja 0x40723
leaq 0x327be(%rip), %rax     # 0x72c10
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x58(%rsp), %rsi
leaq 0xd(%rsp), %rdx
movq %r14, %rdi
callq 0x41160
testb %al, %al
je 0x4092d
leaq 0x78(%rsp), %rdi
leaq 0xe(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x411ce
testb %al, %al
je 0x4092d
movb 0xe(%rsp), %bl
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4f44f(%rip), %rax     # 0x8f8f8
movq %rax, (%r14)
movb %bl, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x404ce
decq 0x8(%rdi)
jne 0x404ce
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x404e2
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 0x41632
jmp 0x40929
xorl %ebx, %ebx
jmp 0x4097f
cmpl $0x65, %eax
jle 0x40521
cmpl $0x66, %eax
je 0x407ce
cmpl $0x69, %eax
je 0x40533
cmpl $0x73, %eax
je 0x40533
jmp 0x4092f
cmpl $0x5a, %eax
je 0x405b6
cmpl $0x63, %eax
jne 0x4092f
cmpb $0x0, 0x130(%r14)
jne 0x4092d
movq 0x90(%r14), %rax
testq %rax, %rax
je 0x4092d
movq 0x88(%r14), %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 %r14, %rdi
callq 0x27710
testb %al, %al
je 0x4092d
movq 0x20(%rsp), %rsi
movzbl -0x1(%rsi), %eax
cmpl $0x68, %eax
jg 0x40880
movl $0x1, %edx
cmpl $0x41, %eax
je 0x4089a
cmpl $0x63, %eax
je 0x4089a
jmp 0x4092d
cmpb $0x0, 0x130(%r14)
jne 0x4092d
movq 0x90(%r14), %rax
testq %rax, %rax
je 0x4092d
movq 0x88(%r14), %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 %r14, %rdi
callq 0x27710
movl %eax, %ebx
testb %al, %al
je 0x4092d
movq 0x20(%rsp), %rdi
callq 0x272f0
leaq 0x98(%rsp), %rdi
movq $0x0, 0x8(%rdi)
movq (%rdi), %rcx
movb $0x0, (%rcx)
movl %eax, %r14d
movq %r14, %rsi
xorl %edx, %edx
callq 0x271f0
movq 0x98(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %r14, %rdx
callq 0x274c0
testb %bl, %bl
je 0x4092d
leaq 0x78(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x39058
testb %al, %al
je 0x4092d
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x2f122
leaq 0x20(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x2f6ae
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x406c2
incq 0x8(%rax)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x406d8
decq 0x8(%rdi)
jne 0x406d8
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x20(%rsp), %rdi
movq %rdi, 0x10(%rsp)
testq %rdi, %rdi
je 0x406f3
decq 0x8(%rdi)
jne 0x406f3
movq (%rdi), %rax
callq *0x8(%rax)
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x40705
callq 0x27560
movl 0x8(%rsp), %eax
leaq 0x10(%rsp), %rdi
movl %eax, 0x8(%rdi)
leaq 0x98(%rsp), %rsi
callq 0x3fe90
jmp 0x40929
cmpl $0x53, %eax
jne 0x4092f
leaq 0x58(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %r14, %rdi
callq 0x41748
testb %al, %al
je 0x4092d
leaq 0x78(%rsp), %rdi
leaq 0x44(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x38870
testb %al, %al
je 0x4092d
movl 0x44(%rsp), %ebx
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4f0d6(%rip), %rax     # 0x8f850
movq %rax, (%r14)
movl %ebx, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4079f
decq 0x8(%rdi)
jne 0x4079f
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x407b3
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 0x3fd82
jmp 0x40929
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r14, %rdi
callq 0x419bc
testb %al, %al
je 0x4092d
leaq 0x78(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x41a74
testb %al, %al
je 0x4092d
movss 0x3c(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4f10c(%rip), %rax     # 0x8f930
movq %rax, (%r14)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x40851
decq 0x8(%rdi)
jne 0x40851
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x40865
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 0x41eca
jmp 0x40929
cmpl $0x69, %eax
je 0x40895
cmpl $0x73, %eax
jne 0x4092d
movl $0x2, %edx
jmp 0x4089a
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 0x3789a
testb %al, %al
je 0x4092d
movl 0x4c(%rsp), %ebx
movl $0x18, %edi
callq 0x275c0
movq %rax, %r14
leaq 0x4ef3e(%rip), %rax     # 0x8f818
movq %rax, (%r14)
movl %ebx, 0x10(%r14)
movq $0x2, 0x8(%r14)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x408ff
decq 0x8(%rdi)
jne 0x408ff
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, 0x10(%rsp)
decq 0x8(%r14)
jne 0x40913
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 0x40000
movl %eax, %ebx
jmp 0x4092f
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x40945
decq 0x8(%rdi)
jne 0x40945
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x40957
callq 0x27560
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x40969
callq 0x27560
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4097f
callq 0x27560
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40384
callq 0x27560
jmp 0x40384
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x409f7
decq 0x8(%rdi)
jne 0x409f7
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x409f7
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40a31
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40a31
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40a31
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40a31
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40a31
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40a31
jmp 0x40a2e
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x40a31
callq 0x27560
jmp 0x40a31
movq %rax, %rbx
decq 0x8(%r14)
jne 0x40a31
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x40a31
jmp 0x40a2e
jmp 0x40a2e
jmp 0x40a2e
jmp 0x40a2e
movq %rax, %rbx
jmp 0x40a47
jmp 0x40a83
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x40a47
decq 0x8(%rdi)
jne 0x40a47
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x40a59
callq 0x27560
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x40a6b
callq 0x27560
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40a86
callq 0x27560
jmp 0x40a86
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40aa2
callq 0x27560
jmp 0x40aa2
jmp 0x40a9f
jmp 0x40a9f
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x40ab8
decq 0x8(%rdi)
jne 0x40ab8
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x27b20
movq %rax, %rdi
callq 0x2e1ed