// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x1, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x30(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x3b, %eax
jne 0x45f99
movq -0x30(%rbp), %rax
movb $0x0, -0x1(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpb $0x0, (%rax)
je 0x45fcf
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
jne 0x45fbf
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x45fc1
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45fa1
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jle 0x46049
movslq -0x38(%rbp), %rdi
shlq $0x2, %rdi
callq 0x4670
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x46043
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x43520
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq (%rax), %r8
addq $0x1, %r8
movl $0x1, %edi
leaq 0xc29fc(%rip), %rsi     # 0x108a12
leaq 0xc2a06(%rip), %rdx     # 0x108a23
movb $0x0, %al
callq 0x9d90
movq -0x20(%rbp), %rax
movl 0xcc(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0xcc(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x462a6
movl -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
leaq 0xc29f3(%rip), %rsi     # 0x108a47
leaq -0x88(%rbp), %rdx
callq 0xd6380
movq %rax, -0x50(%rbp)
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x46281
movq -0x60(%rbp), %rax
movb $0x0, (%rax)
movq -0x98(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3e520
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movq -0x98(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x46235
movq -0x50(%rbp), %rcx
movl $0x3, %edi
leaq 0xc295a(%rip), %rsi     # 0x108a12
leaq 0xc298a(%rip), %rdx     # 0x108a49
movb $0x0, %al
callq 0x9d90
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4240
movq -0x50(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
leaq 0xc2987(%rip), %rsi     # 0x108a72
movb $0x0, %al
callq 0xd62e0
movq -0x18(%rbp), %rdi
movq -0xa0(%rbp), %rsi
leaq -0xb4(%rbp), %rdx
callq 0x3bbb0
movq %rax, -0xc0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x45a0
cmpq $0x0, -0xc0(%rbp)
je 0x4613e
movq -0x18(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x3ce30
movl %eax, -0xc8(%rbp)
jmp 0x4614b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xc8(%rbp)
jmp 0x4614b
movl -0xc8(%rbp), %eax
movl %eax, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
jge 0x4616c
movq -0xc0(%rbp), %rdi
callq 0x3b040
cmpl $0x0, -0xc4(%rbp)
jle 0x46184
movq -0x18(%rbp), %rdi
callq 0x3ae50
movl %eax, -0xc4(%rbp)
movq -0x98(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3e520
movl %eax, -0x8c(%rbp)
movq -0x20(%rbp), %rax
movl 0xcc(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0xcc(%rax)
cmpl $0x0, -0xc4(%rbp)
jne 0x461c7
movl -0x8c(%rbp), %eax
movq -0x98(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x46233
movq -0x50(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x43520
movq -0xd0(%rbp), %rcx
movq %rax, %r8
movq -0x20(%rbp), %rax
movq (%rax), %r9
addq $0x1, %r9
movl $0x1, %edi
leaq 0xc2812(%rip), %rsi     # 0x108a12
leaq 0xc2890(%rip), %rdx     # 0x108a97
movb $0x0, %al
callq 0x9d90
movq -0x20(%rbp), %rax
movl 0xcc(%rax), %ecx
orl $0x40, %ecx
movl %ecx, 0xcc(%rax)
movq -0x58(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x462a6
jmp 0x46235
movq -0x98(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x8c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %edx
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdx
movq %rsi, %rdi
callq 0xd6380
movq %rax, -0x50(%rbp)
jmp 0x4606b
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
movq -0x58(%rbp), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x442f0
movq -0x58(%rbp), %rdi
callq 0x45a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)