// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %rdi, %r14
movl 0x50(%rdi), %ebp
xorl %eax, %eax
testl %ebp, %ebp
cmovlel %eax, %ebp
movq %rsi, %rbx
xorl %r12d, %r12d
movl $0x0, 0x1c(%rsp)
movl $0x0, 0xc(%rsp)
movq %rsi, 0x10(%rsp)
movslq 0x50(%rbx), %rax
cmpq %rax, %r12
jge 0x2ccb5
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %r13
movl (%r13), %ebx
cmpl $0x4, %ebx
je 0x2cc1c
cmpl $0x5, %ebx
jne 0x2cad3
cmpq $0x0, 0x10(%r13)
je 0x2cad3
xorl %ebx, %ebx
cmpq %rbx, %rbp
je 0x2cc85
movq 0x48(%r14), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x5, (%rax)
jne 0x2cace
movq 0x8(%r13), %rdi
movq 0x8(%rax), %rsi
callq 0x46e0
testl %eax, %eax
je 0x2cc7e
incq %rbx
jmp 0x2caa3
movq %r13, %rdi
leaq 0x581f8(%rip), %r15     # 0x84cd5
movq %r15, %rsi
callq 0x22ef9
testl %eax, %eax
js 0x2cce5
movq 0x28(%r13), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x244fd
movq %rax, %r13
movq 0x10(%rsp), %rbx
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %rdi
testq %r13, %r13
je 0x2cc60
movl (%rdi), %eax
decl %eax
cmpl $0x1, %eax
ja 0x2ccad
movq 0x28(%rbx), %r15
movq 0x28(%r14), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rdi), %rax
movq (%rax), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x246ef
movl %eax, 0x20(%rsp)
movq 0x28(%rsp), %rdi
movq %rbx, 0x30(%rsp)
movq %rbx, %rsi
callq 0x246ef
movl 0x20(%rsp), %ecx
imulq $0x38, %rcx, %rbx
movq %r15, 0x20(%rsp)
movq 0x20(%r15), %rcx
addq %rbx, %rcx
movslq (%r13), %rdx
movl %eax, %eax
imulq $0x38, %rax, %r15
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
addq %r15, %rax
movq (%rax,%rdx,8), %rax
xorq (%rcx,%rdx,8), %rax
testw $0xf00, %ax             # imm = 0xF00
je 0x2cbdc
pushq $0x3
popq %rdi
leaq 0x5a118(%rip), %rsi     # 0x86cbc
leaq 0x5a121(%rip), %rdx     # 0x86ccc
movq 0x30(%rsp), %rcx
xorl %eax, %eax
callq 0x8132
movslq (%r13), %rcx
movq 0x20(%rsp), %rax
addq 0x20(%rax), %rbx
movq 0x28(%rsp), %rax
addq 0x20(%rax), %r15
movq (%r15,%rcx,8), %rax
xorq (%rbx,%rcx,8), %rax
pushq $0x1
popq %rcx
movl %ecx, 0x1c(%rsp)
testb $-0x10, %al
je 0x2cc7e
movq 0x10(%rsp), %rbx
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
pushq $0x3
popq %rdi
leaq 0x5a0ba(%rip), %rsi     # 0x86cbc
leaq 0x5a0ff(%rip), %rdx     # 0x86d08
xorl %eax, %eax
callq 0x8132
pushq $0x1
popq %rax
movl %eax, 0x1c(%rsp)
jmp 0x2ccad
movq %r13, %rdi
leaq 0x580af(%rip), %rbx     # 0x84cd5
movq %rbx, %rsi
callq 0x22ef9
testl %eax, %eax
js 0x2cc7e
movq 0x8(%r13), %r8
movq 0x28(%r13), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
pushq $0x4
popq %rsi
movq %rbx, %rdx
callq 0x244fd
testq %rax, %rax
movq 0x10(%rsp), %rbx
jne 0x2ccad
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x228bb
movq %r14, %rdi
movq %rax, %rsi
callq 0x238dd
testl %eax, %eax
movl $0x0, %ecx
cmovsl %ecx, %eax
jns 0x2cca9
jmp 0x2ccd1
movq 0x10(%rsp), %rbx
jmp 0x2ccad
movq %r13, %rdi
callq 0x228bb
movq %r14, %rdi
movq %rax, %rsi
callq 0x238dd
testl %eax, %eax
movl $0x0, %ecx
cmovsl %ecx, %eax
movq 0x10(%rsp), %rbx
js 0x2ccd1
addl %eax, 0xc(%rsp)
incq %r12
jmp 0x2ca73
cmpl $0x0, 0xc(%rsp)
pushq $-0x1
popq %rbx
je 0x2cccb
movq %r14, %rdi
callq 0x2276e
testl %eax, %eax
js 0x2ccd4
movl 0x1c(%rsp), %ebx
jmp 0x2ccd4
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x59f97(%rip), %rdi     # 0x86c83
leaq 0x59630(%rip), %rsi     # 0x86323
leaq 0x59f8e(%rip), %rcx     # 0x86c88
movl $0x1217, %edx           # imm = 0x1217
callq 0x42e0