// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: bcf_hdr_combine
int bcf_hdr_combine(bcf_hdr_t *dst, const bcf_hdr_t *src)
{
    int i, ndst_ori = dst->nhrec, need_sync = 0, ret = 0, res;
    for (i=0; i<src->nhrec; i++)
    {
        if ( src->hrec[i]->type==BCF_HL_GEN && src->hrec[i]->value )
        {
            int j;
            for (j=0; j<ndst_ori; j++)
            {
                if ( dst->hrec[j]->type!=BCF_HL_GEN ) continue;

                // Checking only the key part of generic lines, otherwise
                // the VCFs are too verbose. Should we perhaps add a flag
                // to bcf_hdr_combine() and make this optional?
                if ( !strcmp(src->hrec[i]->key,dst->hrec[j]->key) ) break;
            }
            if ( j>=ndst_ori ) {
                res = bcf_hdr_add_hrec(dst, bcf_hrec_dup(src->hrec[i]));
                if (res < 0) return -1;
                need_sync += res;
            }
        }
        else if ( src->hrec[i]->type==BCF_HL_STR )
        {
            // NB: we are ignoring fields without ID
            int j = bcf_hrec_find_key(src->hrec[i],"ID");
            if ( j>=0 )
            {
                bcf_hrec_t *rec = bcf_hdr_get_hrec(dst, src->hrec[i]->type, "ID", src->hrec[i]->vals[j], src->hrec[i]->key);
                if ( !rec ) {
                    res = bcf_hdr_add_hrec(dst, bcf_hrec_dup(src->hrec[i]));
                    if (res < 0) return -1;
                    need_sync += res;
                }
            }
        }
        else
        {
            int j = bcf_hrec_find_key(src->hrec[i],"ID");
            assert( j>=0 ); // this should always be true for valid VCFs

            bcf_hrec_t *rec = bcf_hdr_get_hrec(dst, src->hrec[i]->type, "ID", src->hrec[i]->vals[j], NULL);
            if ( !rec ) {
                res = bcf_hdr_add_hrec(dst, bcf_hrec_dup(src->hrec[i]));
                if (res < 0) return -1;
                need_sync += res;
            } else if ( src->hrec[i]->type==BCF_HL_INFO || src->hrec[i]->type==BCF_HL_FMT )
            {
                // Check that both records are of the same type. The bcf_hdr_id2length
                // macro cannot be used here because dst header is not synced yet.
                vdict_t *d_src = (vdict_t*)src->dict[BCF_DT_ID];
                vdict_t *d_dst = (vdict_t*)dst->dict[BCF_DT_ID];
                khint_t k_src  = kh_get(vdict, d_src, src->hrec[i]->vals[0]);
                khint_t k_dst  = kh_get(vdict, d_dst, src->hrec[i]->vals[0]);
                if ( (kh_val(d_src,k_src).info[rec->type]>>8 & 0xf) != (kh_val(d_dst,k_dst).info[rec->type]>>8 & 0xf) )
                {
                    hts_log_warning("Trying to combine \"%s\" tag definitions of different lengths",
                        src->hrec[i]->vals[0]);
                    ret |= 1;
                }
                if ( (kh_val(d_src,k_src).info[rec->type]>>4 & 0xf) != (kh_val(d_dst,k_dst).info[rec->type]>>4 & 0xf) )
                {
                    hts_log_warning("Trying to combine \"%s\" tag definitions of different types",
                        src->hrec[i]->vals[0]);
                    ret |= 1;
                }
            }
        }
    }
    if ( need_sync ) {
        if (bcf_hdr_sync(dst) < 0) return -1;
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbp
cmpl $0x0, 0x50(%rsi)
jle 0x3c94c
movq %rsi, %r15
movslq 0x50(%rbp), %r13
movl %r13d, %eax
testl %eax, %eax
setg 0xb(%rsp)
negq %rax
movq %rax, 0x70(%rsp)
leaq 0x708d1(%rip), %rbx     # 0xacd57
movq $0x0, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x1c(%rsp)
movq %rbp, 0x10(%rsp)
movq %rsi, 0x48(%rsp)
movq %r13, 0x68(%rsp)
movq 0x48(%r15), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %r12
movl (%r12), %r13d
cmpl $0x4, %r13d
je 0x3c53f
cmpl $0x5, %r13d
jne 0x3c5a8
cmpq $0x0, 0x10(%r12)
je 0x3c539
movq 0x68(%rsp), %r13
testl %r13d, %r13d
jle 0x3c690
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rbx
movl $0x1, %r15d
movb 0xb(%rsp), %bpl
movq -0x8(%rbx,%r15,8), %rax
cmpl $0x5, (%rax)
jne 0x3c519
movq 0x8(%r12), %rdi
movq 0x8(%rax), %rsi
callq 0x46e0
testl %eax, %eax
je 0x3c681
cmpq %r13, %r15
setl %bpl
movq 0x70(%rsp), %rax
addq %r15, %rax
incq %rax
incq %r15
cmpq $0x1, %rax
jne 0x3c4f9
jmp 0x3c690
cmpl $0x4, %r13d
jne 0x3c5a8
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2c40b
movq %rbx, %rdx
movb $0x1, %bl
testl %eax, %eax
js 0x3c5a1
movq 0x8(%r12), %r8
movq 0x28(%r12), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rcx
movq %rbp, %rdi
movl %r13d, %esi
callq 0x2dff0
testq %rax, %rax
jne 0x3c5a1
movq 0x48(%r15), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2bdad
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2ce41
testl %eax, %eax
setns %bl
movl $0x0, %ecx
cmovsl %ecx, %eax
addl %eax, 0xc(%rsp)
testb %bl, %bl
jmp 0x3c6c0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2c40b
testl %eax, %eax
js 0x3c976
movq 0x28(%r12), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rcx
movq %rbp, %rdi
movl %r13d, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x2dff0
movq 0x48(%r15), %rcx
movq 0x20(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
testq %rax, %rax
je 0x3c65a
movl (%rdi), %ecx
decl %ecx
movb $0x1, %r12b
cmpl $0x1, %ecx
ja 0x3c91f
movq 0x28(%r15), %rdx
movq 0x28(%rbp), %rcx
movq %rcx, 0x38(%rsp)
movq 0x28(%rdi), %rcx
movq (%rcx), %r8
movq %rdx, 0x40(%rsp)
movl (%rdx), %edi
xorl %edx, %edx
movl $0x0, %esi
testl %edi, %edi
movq %rax, 0x30(%rsp)
movq %r8, 0x60(%rsp)
je 0x3c775
movb (%r8), %cl
testb %cl, %cl
je 0x3c6d2
leaq 0x1(%r8), %rax
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r13d, %ecx
imull $0x1000193, %ecx, %r13d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3c642
jmp 0x3c6d8
callq 0x2bdad
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2ce41
testl %eax, %eax
setns %r12b
movl $0x0, %ecx
cmovsl %ecx, %eax
addl %eax, 0xc(%rsp)
jmp 0x3c91f
movb $0x1, %cl
testb $0x1, %bpl
je 0x3c690
movq 0x10(%rsp), %rbp
jmp 0x3c6b9
movq %r12, %rdi
callq 0x2bdad
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2ce41
testl %eax, %eax
setns %cl
movl $0x0, %edx
cmovsl %edx, %eax
addl %eax, 0xc(%rsp)
testb %cl, %cl
movq 0x48(%rsp), %r15
leaq 0x70690(%rip), %rbx     # 0xacd57
jne 0x3c924
jmp 0x3c960
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movq %rdi, 0x28(%rsp)
leal -0x1(%rdi), %r14d
andl %r14d, %r13d
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r12d
movl %r13d, %ebx
movq %rsi, 0x50(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r15d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3c753
testb $0x1, %al
jne 0x3c73e
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x46e0
movq 0x50(%rsp), %rsi
movq 0x60(%rsp), %r8
testl %eax, %eax
je 0x3c753
addl %r12d, %ebx
andl %r14d, %ebx
incl %r12d
cmpl %r13d, %ebx
jne 0x3c6fb
movq 0x28(%rsp), %rax
jmp 0x3c764
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x28(%rsp), %rax
cmovel %ebx, %eax
movl %eax, %esi
movq 0x10(%rsp), %rbp
movb $0x1, %r12b
movq 0x30(%rsp), %rax
xorl %edx, %edx
movq 0x38(%rsp), %rcx
movl (%rcx), %edi
testl %edi, %edi
je 0x3c856
movb (%r8), %cl
testb %cl, %cl
movl %esi, 0x28(%rsp)
je 0x3c7b1
leaq 0x1(%r8), %rax
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r13d, %ecx
imull $0x1000193, %ecx, %r13d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3c799
jmp 0x3c7b7
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movq %rdi, 0x58(%rsp)
leal -0x1(%rdi), %r14d
andl %r14d, %r13d
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r12d
movl %r13d, %ebx
movq %rsi, 0x50(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r15d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3c832
testb $0x1, %al
jne 0x3c81d
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x46e0
movq 0x50(%rsp), %rsi
movq 0x60(%rsp), %r8
testl %eax, %eax
je 0x3c832
addl %r12d, %ebx
andl %r14d, %ebx
incl %r12d
cmpl %r13d, %ebx
jne 0x3c7da
movq 0x58(%rsp), %rax
jmp 0x3c843
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x58(%rsp), %rax
cmovel %ebx, %eax
movl %eax, %edx
movq 0x10(%rsp), %rbp
movb $0x1, %r12b
movq 0x30(%rsp), %rax
movl 0x28(%rsp), %esi
movl %esi, %ecx
imulq $0x38, %rcx, %rbx
movq 0x40(%rsp), %rcx
movq 0x20(%rcx), %rsi
addq %rbx, %rsi
movslq (%rax), %rcx
movl %edx, %edx
imulq $0x38, %rdx, %r15
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rdx
addq %r15, %rdx
movl (%rdx,%rcx,8), %edx
xorl (%rsi,%rcx,8), %edx
testl $0xf00, %edx            # imm = 0xF00
je 0x3c8b0
movl $0x3, %edi
leaq 0x72719(%rip), %rsi     # 0xaefb0
leaq 0x72722(%rip), %rdx     # 0xaefc0
movq %r8, %rcx
xorl %eax, %eax
callq 0x9774
movl $0x1, 0x1c(%rsp)
movq 0x40(%rsp), %rax
addq 0x20(%rax), %rbx
movq 0x30(%rsp), %rax
movslq (%rax), %rax
movq 0x38(%rsp), %rcx
addq 0x20(%rcx), %r15
movl (%r15,%rax,8), %ecx
xorl (%rbx,%rax,8), %ecx
testb $-0x10, %cl
je 0x3c913
movq 0x48(%rsp), %r15
movq 0x48(%r15), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
movl $0x3, %edi
leaq 0x726b5(%rip), %rsi     # 0xaefb0
leaq 0x726fa(%rip), %rdx     # 0xaeffc
xorl %eax, %eax
callq 0x9774
movl $0x1, 0x1c(%rsp)
jmp 0x3c918
movq 0x48(%rsp), %r15
leaq 0x70438(%rip), %rbx     # 0xacd57
testb %r12b, %r12b
je 0x3c960
movq 0x20(%rsp), %rdx
incq %rdx
movslq 0x50(%r15), %rax
movq %rdx, 0x20(%rsp)
cmpq %rax, %rdx
jl 0x3c4ae
cmpl $0x0, 0xc(%rsp)
sete %al
movl 0x1c(%rsp), %ebx
jmp 0x3c950
movb $0x1, %al
xorl %ebx, %ebx
testb %al, %al
jne 0x3c965
movq %rbp, %rdi
callq 0x2bc46
testl %eax, %eax
jns 0x3c965
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x725fa(%rip), %rdi     # 0xaef77
leaq 0x71c9f(%rip), %rsi     # 0xae623
leaq 0x725f1(%rip), %rcx     # 0xaef7c
movl $0x1217, %edx           # imm = 0x1217
callq 0x42e0