// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: vcf_parse_filter
static int vcf_parse_filter(kstring_t *str, const bcf_hdr_t *h, bcf1_t *v, char *p, char *q) {
    int i, n_flt = 1, max_n_flt = 0;
    char *r, *t;
    int32_t *a_flt = NULL;
    ks_tokaux_t aux1;
    khint_t k;
    vdict_t *d = (vdict_t*)h->dict[BCF_DT_ID];
    // count the number of filters
    if (*(q-1) == ';') *(q-1) = 0;
    for (r = p; *r; ++r)
        if (*r == ';') ++n_flt;
    if (n_flt > max_n_flt) {
        a_flt = malloc(n_flt * sizeof(*a_flt));
        if (!a_flt) {
            hts_log_error("Could not allocate memory at %s:%"PRIhts_pos, bcf_seqname_safe(h,v), v->pos+1);
            v->errcode |= BCF_ERR_LIMITS; // No appropriate code?
            return -1;
        }
        max_n_flt = n_flt;
    }
    // add filters
    for (t = kstrtok(p, ";", &aux1), i = 0; t; t = kstrtok(0, 0, &aux1)) {
        *(char*)aux1.p = 0;
        k = kh_get(vdict, d, t);
        if (k == kh_end(d))
        {
            // Simple error recovery for FILTERs not defined in the header. It will not help when VCF header has
            // been already printed, but will enable tools like vcfcheck to proceed.
            hts_log_warning("FILTER '%s' is not defined in the header", t);
            kstring_t tmp = {0,0,0};
            int l;
            ksprintf(&tmp, "##FILTER=<ID=%s,Description=\"Dummy\">", t);
            bcf_hrec_t *hrec = bcf_hdr_parse_line(h,tmp.s,&l);
            free(tmp.s);
            int res = hrec ? bcf_hdr_add_hrec((bcf_hdr_t*)h, hrec) : -1;
            if (res < 0) bcf_hrec_destroy(hrec);
            if (res > 0) res = bcf_hdr_sync((bcf_hdr_t*)h);
            k = kh_get(vdict, d, t);
            v->errcode |= BCF_ERR_TAG_UNDEF;
            if (res || k == kh_end(d)) {
                hts_log_error("Could not add dummy header for FILTER '%s' at %s:%"PRIhts_pos, t, bcf_seqname_safe(h,v), v->pos+1);
                v->errcode |= BCF_ERR_TAG_INVALID;
                free(a_flt);
                return -1;
            }
        }
        a_flt[i++] = kh_val(d, k).id;
    }

    bcf_enc_vint(str, n_flt, a_flt, -1);
    free(a_flt);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, 0x50(%rsp)
movq 0x28(%rsi), %r13
cmpb $0x3b, -0x1(%r8)
jne 0x34b95
movb $0x0, -0x1(%r8)
movl $0x1, %ebp
movq %rbx, %rax
movzbl (%rax), %ecx
cmpl $0x3b, %ecx
je 0x34bab
testl %ecx, %ecx
jne 0x34bad
jmp 0x34bb2
incl %ebp
incq %rax
jmp 0x34b9d
movq %rsi, 0x8(%rsp)
testl %ebp, %ebp
jle 0x34be2
movl %ebp, %edi
shlq $0x2, %rdi
callq 0x46a0
movq %rax, 0x18(%rsp)
testq %rax, %rax
jne 0x34beb
testq %r14, %r14
je 0x34f27
movl 0x10(%r14), %eax
jmp 0x34f2c
movq $0x0, 0x18(%rsp)
movl %ebp, 0x3c(%rsp)
movq %r14, 0x40(%rsp)
leaq 0x7adcc(%rip), %rsi     # 0xaf9c7
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
callq 0x8b5b7
testq %rax, %rax
je 0x34ee9
movq %rax, %r8
xorl %r14d, %r14d
movq %r13, (%rsp)
movq 0xa0(%rsp), %rax
movb $0x0, (%rax)
movl (%r13), %edx
movl $0x0, %ebp
testl %edx, %edx
movq %r8, 0x28(%rsp)
movq %r14, 0x20(%rsp)
je 0x34d08
movb (%r8), %cl
testb %cl, %cl
je 0x34c6a
leaq 0x1(%r8), %rax
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r15d, %ecx
imull $0x1000193, %ecx, %r15d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x34c52
jmp 0x34c70
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movq %rdx, 0x10(%rsp)
decl %edx
andl %edx, %r15d
movq 0x10(%r13), %rsi
movl $0x1, %r12d
movl %r15d, %ebp
movq %rsi, 0x30(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r14d
leal (,%rbp,2), %ebx
andl $0x1e, %ebx
movl %r14d, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x34cee
testb $0x1, %al
jne 0x34cd8
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
movl %edx, %r13d
callq 0x46e0
movq 0x30(%rsp), %rsi
movl %r13d, %edx
movq 0x28(%rsp), %r8
testl %eax, %eax
je 0x34cee
addl %r12d, %ebp
andl %edx, %ebp
incl %r12d
cmpl %r15d, %ebp
jne 0x34c8c
movq 0x10(%rsp), %rdx
movl %edx, %ebp
jmp 0x34cff
movl %ebx, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x10(%rsp), %rdx
cmovnel %edx, %ebp
movq (%rsp), %r13
movq 0x20(%rsp), %r14
cmpl %edx, %ebp
jne 0x34eb5
movl $0x3, %edi
leaq 0x7ac76(%rip), %rsi     # 0xaf992
leaq 0x7aca6(%rip), %rdx     # 0xaf9c9
movq %r8, %rcx
xorl %eax, %eax
movq %r8, %rbx
callq 0x9774
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x7aca5(%rip), %rsi     # 0xaf9f2
movq %rbx, %rdx
xorl %eax, %eax
callq 0x8b533
movq 0x70(%rsp), %rsi
leaq 0x5c(%rsp), %rdx
callq 0x2c456
movq %rax, %r12
movq 0x70(%rsp), %rdi
callq 0x45c0
testq %r12, %r12
je 0x34d8d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2ce41
movl %eax, %r15d
jmp 0x34d98
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rbx
testl %r15d, %r15d
jns 0x34da5
movq %r12, %rdi
callq 0x2bd39
testl %r15d, %r15d
jle 0x34db5
movq %rbx, %rdi
callq 0x2bc46
movl %eax, %r15d
movl (%r13), %edx
testl %edx, %edx
je 0x34df0
movl %r15d, 0x10(%rsp)
movq 0x28(%rsp), %r10
movb (%r10), %cl
testb %cl, %cl
je 0x34dfc
leaq 0x1(%r10), %rax
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r15d, %ecx
imull $0x1000193, %ecx, %r15d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x34dd8
jmp 0x34e02
xorl %ebp, %ebp
movq 0x28(%rsp), %r10
jmp 0x34ea0
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movq %rdx, 0x48(%rsp)
decl %edx
andl %edx, %r15d
movq 0x10(%r13), %rsi
movl $0x1, %ebx
movl %r15d, %ebp
movq %rsi, 0x30(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r14d
leal (,%rbp,2), %r12d
andl $0x1e, %r12d
movl %r14d, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x34e80
testb $0x1, %al
jne 0x34e6c
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
movq %r10, %rsi
movl %edx, %r13d
callq 0x46e0
movq 0x30(%rsp), %rsi
movl %r13d, %edx
movq 0x28(%rsp), %r10
testl %eax, %eax
je 0x34e80
addl %ebx, %ebp
andl %edx, %ebp
incl %ebx
cmpl %r15d, %ebp
jne 0x34e1d
movq 0x48(%rsp), %rdx
movl %edx, %ebp
jmp 0x34e92
movl %r12d, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x48(%rsp), %rdx
cmovnel %edx, %ebp
movq (%rsp), %r13
movq 0x20(%rsp), %r14
movl 0x10(%rsp), %r15d
movq 0x40(%rsp), %rax
orb $0x2, 0xcc(%rax)
testl %r15d, %r15d
jne 0x34f13
cmpl %edx, %ebp
je 0x34f13
movq 0x20(%r13), %rax
movl %ebp, %ecx
imulq $0x38, %rcx, %rcx
movl 0x30(%rax,%rcx), %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
incq %r14
xorl %edi, %edi
xorl %esi, %esi
leaq 0x78(%rsp), %rdx
callq 0x8b5b7
movq %rax, %r8
testq %rax, %rax
jne 0x34c1b
movq 0x50(%rsp), %rdi
movl 0x3c(%rsp), %esi
movq 0x18(%rsp), %rbx
movq %rbx, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3321b
movq %rbx, %rdi
callq 0x45c0
xorl %eax, %eax
jmp 0x35001
movq 0x40(%rsp), %rbx
testq %rbx, %rbx
movq 0x8(%rsp), %rsi
je 0x34f8f
movl 0x10(%rbx), %eax
jmp 0x34f94
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
sete %cl
testl %eax, %eax
sets %dl
orb %cl, %dl
jne 0x34f55
cmpl %eax, 0x4(%rsi)
jle 0x34f55
movq 0x18(%rsi), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x34f57
xorl %eax, %eax
testq %rax, %rax
leaq 0x7a9fe(%rip), %rcx     # 0xaf95f
cmovneq %rax, %rcx
movq (%r14), %r8
incq %r8
leaq 0x7aa20(%rip), %rsi     # 0xaf992
leaq 0x7aa2a(%rip), %rdx     # 0xaf9a3
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
orb $0x8, 0xcc(%r14)
jmp 0x34ffc
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rsi, %rsi
sete %cl
testl %eax, %eax
sets %dl
orb %cl, %dl
jne 0x34fb8
cmpl %eax, 0x4(%rsi)
jle 0x34fb8
movq 0x18(%rsi), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x34fba
xorl %eax, %eax
testq %rax, %rax
leaq 0x7a99b(%rip), %r8      # 0xaf95f
cmovneq %rax, %r8
movq (%rbx), %r9
incq %r9
leaq 0x7a9bd(%rip), %rsi     # 0xaf992
leaq 0x7aa3b(%rip), %rdx     # 0xafa17
movl $0x1, %edi
movq %r10, %rcx
xorl %eax, %eax
callq 0x9774
orb $0x40, 0xcc(%rbx)
movq 0x18(%rsp), %rdi
callq 0x45c0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq