// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/vcf.c
// Function: bcf_hdr_get_hrec
bcf_hrec_t *bcf_hdr_get_hrec(const bcf_hdr_t *hdr, int type, const char *key, const char *value, const char *str_class)
{
    int i;
    if ( type==BCF_HL_GEN )
    {
        // e.g. ##fileformat=VCFv4.2
        //      ##source=GenomicsDBImport
        //      ##bcftools_viewVersion=1.16-80-gdfdb0923+htslib-1.16-34-g215d364
        if ( value )
        {
            kstring_t str = {0,0,0};
            ksprintf(&str, "##%s=%s", key,value);
            bcf_hdr_aux_t *aux = get_hdr_aux(hdr);
            khint_t k = kh_get(hdict, aux->gen, str.s);
            free(str.s);
            if ( k == kh_end(aux->gen) ) return NULL;
            return kh_val(aux->gen, k);
        }
        for (i=0; i<hdr->nhrec; i++)
        {
            if ( hdr->hrec[i]->type!=type ) continue;
            if ( strcmp(hdr->hrec[i]->key,key) ) continue;
            return hdr->hrec[i];
        }
        return NULL;
    }
    else if ( type==BCF_HL_STR )
    {
        // e.g. ##GATKCommandLine=<ID=GenomicsDBImport,CommandLine="GenomicsDBImport....">
        //      ##ALT=<ID=NON_REF,Description="Represents any possible alternative allele not already represented at this location by REF and ALT">
        if (!str_class) return NULL;
        if ( !strcmp("ID",key) )
        {
            kstring_t str = {0,0,0};
            ksprintf(&str, "##%s=<%s=%s>",str_class,key,value);
            bcf_hdr_aux_t *aux = get_hdr_aux(hdr);
            khint_t k = kh_get(hdict, aux->gen, str.s);
            free(str.s);
            if ( k == kh_end(aux->gen) ) return NULL;
            return kh_val(aux->gen, k);
        }
        for (i=0; i<hdr->nhrec; i++)
        {
            if ( hdr->hrec[i]->type!=type ) continue;
            if ( strcmp(hdr->hrec[i]->key,str_class) ) continue;
            int j = bcf_hrec_find_key(hdr->hrec[i],key);
            if ( j>=0 && !strcmp(hdr->hrec[i]->vals[j],value) ) return hdr->hrec[i];
        }
        return NULL;
    }
    vdict_t *d = type==BCF_HL_CTG ? (vdict_t*)hdr->dict[BCF_DT_CTG] : (vdict_t*)hdr->dict[BCF_DT_ID];
    khint_t k = kh_get(vdict, d, value);
    if ( k == kh_end(d) ) return NULL;
    return kh_val(d, k).hrec[type==BCF_HL_CTG?0:type];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r13
movq %rcx, %r8
movq %rdx, %r14
movq %rdi, %rbx
cmpl $0x4, %esi
je 0x2456e
movl %esi, %ebp
cmpl $0x5, %esi
jne 0x24602
testq %r8, %r8
je 0x24643
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r13
movaps %xmm0, (%r13)
andq $0x0, 0x10(%r13)
leaq 0x61f49(%rip), %rsi     # 0x86492
xorl %r15d, %r15d
movq %r13, %rdi
movq %r14, %rdx
movq %r8, %rcx
xorl %eax, %eax
callq 0x69048
movq 0x28(%rbx), %r12
movq 0x28(%r12), %rdi
movq 0x10(%r13), %r14
jmp 0x246b8
testq %r13, %r13
je 0x2467b
movzbl (%r14), %eax
subl $0x49, %eax
jne 0x2458f
movzbl 0x1(%r14), %eax
subl $0x44, %eax
jne 0x2458f
movzbl 0x2(%r14), %eax
negl %eax
testl %eax, %eax
je 0x24680
movq %r8, 0x8(%rsp)
movl 0x50(%rbx), %ebp
xorl %eax, %eax
testl %ebp, %ebp
cmovlel %eax, %ebp
xorl %r12d, %r12d
cmpq %r12, %rbp
je 0x2467b
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %r15
cmpl $0x4, (%r15)
jne 0x245fd
movq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x46e0
testl %eax, %eax
jne 0x245fd
movq %r15, %rdi
movq %r14, %rsi
callq 0x22ef9
testl %eax, %eax
js 0x245fd
movq 0x28(%r15), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rdi
movq 0x8(%rsp), %rsi
callq 0x46e0
testl %eax, %eax
je 0x246dd
incq %r12
jmp 0x245ab
xorl %eax, %eax
cmpl $0x3, %ebp
sete %al
movq 0x28(%rbx,%rax,8), %rbx
movq %rbx, %rdi
movq %r8, %rsi
callq 0x246ef
xorl %r15d, %r15d
cmpl (%rbx), %eax
je 0x246dd
cmpl $0x3, %ebp
movl %eax, %eax
cmovnel %ebp, %r15d
movslq %r15d, %rcx
imulq $0x38, %rax, %rax
addq 0x20(%rbx), %rax
movq 0x18(%rax,%rcx,8), %r15
jmp 0x246dd
movl 0x50(%rbx), %r12d
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x2467b
movq 0x48(%rbx), %rax
movq (%rax,%r13,8), %r15
cmpl $0x5, (%r15)
jne 0x24676
movq 0x8(%r15), %rdi
movq %r14, %rsi
callq 0x46e0
testl %eax, %eax
je 0x246dd
incq %r13
jmp 0x24653
xorl %r15d, %r15d
jmp 0x246dd
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rbp
movaps %xmm0, (%rbp)
andq $0x0, 0x10(%rbp)
leaq 0x61e1a(%rip), %rsi     # 0x864b2
xorl %r15d, %r15d
movq %rbp, %rdi
movq %r13, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x69048
movq 0x28(%rbx), %r12
movq 0x28(%r12), %rdi
movq 0x10(%rbp), %r14
movq %r14, %rsi
callq 0x243d3
movl %eax, %ebx
movq %r14, %rdi
callq 0x45c0
movq 0x28(%r12), %rax
cmpl (%rax), %ebx
je 0x246dd
movq 0x20(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %r15
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq