// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header_merge
void *sam_header_merge(int n, const void **_dicts)
{
	const HeaderDict **dicts = (const HeaderDict**)_dicts;
    HeaderDict *out_dict;
    int idict, status;

    if ( n<2 ) return NULL;

    out_dict = sam_header_clone(dicts[0]);

    for (idict=1; idict<n; idict++)
    {
        const list_t *tmpl_hlines = dicts[idict];

        while ( tmpl_hlines )
        {
            list_t *out_hlines = out_dict;
            int inserted = 0;
            while ( out_hlines )
            {
                status = sam_header_compare_lines(tmpl_hlines->data, out_hlines->data);
                if ( status==0 )
                {
                    out_hlines = out_hlines->next;
                    continue;
                }
                
                if ( status==2 ) 
                {
                    print_header_line(stderr,tmpl_hlines->data);
                    print_header_line(stderr,out_hlines->data);
                    debug("Conflicting lines, cannot merge the headers.\n");
					return 0;
                }
                if ( status==3 )
                    sam_header_line_merge_with(out_hlines->data, tmpl_hlines->data);

                inserted = 1;
                break;
            }
            if ( !inserted )
                out_dict = list_append(out_dict, sam_header_line_clone(tmpl_hlines->data));

            tmpl_hlines = tmpl_hlines->next;
        }
    }

    return out_dict;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x2, %edi
jge 0x167cb
xorl %r12d, %r12d
jmp 0x16cf4
movl %edi, %ebp
movq %rsi, 0x28(%rsp)
movq (%rsi), %rdi
callq 0x15a97
movq %rax, %r12
movl %ebp, %eax
movq %rax, 0x20(%rsp)
movl $0x1, %eax
leaq 0xc180(%rip), %r15      # 0x22970
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq (%rax,%rcx,8), %rax
movq %rax, %r9
testq %rax, %rax
je 0x16cd8
testq %r12, %r12
movq %r9, (%rsp)
je 0x16bcc
movq %r12, %r13
movq %r12, 0x8(%rsp)
movq 0x10(%r9), %r14
movq 0x10(%r13), %rbx
movsbl (%r14), %esi
xorl %ecx, %ecx
cmpb (%rbx), %sil
jne 0x16bbb
movsbl 0x1(%r14), %edx
cmpb 0x1(%rbx), %dl
jne 0x16bbb
movq 0xc122(%rip), %rdi      # 0x22970
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x16875
xorl %ecx, %ecx
cmpb %sil, (%rdi)
jne 0x16864
cmpb %dl, 0x1(%rdi)
je 0x16873
movq 0x8(%r15,%rcx,8), %rdi
incq %rcx
testq %rdi, %rdi
jne 0x1685a
jmp 0x16875
movl %ecx, %eax
cmpl $-0x1, %eax
je 0x16b89
movslq %eax, %rcx
leaq 0xc178(%rip), %rax      # 0x22a00
movq %rcx, 0x18(%rsp)
movq (%rax,%rcx,8), %rbp
testq %rbp, %rbp
je 0x1693f
movq (%rbp), %rcx
movq 0x8(%r14), %rdx
testq %rdx, %rdx
je 0x168d2
movq 0x10(%rdx), %rdi
movb (%rdi), %sil
cmpb (%rcx), %sil
jne 0x168c4
movb 0x1(%rdi), %sil
cmpb 0x1(%rcx), %sil
jne 0x168c4
xorl %esi, %esi
movq %rdi, %rax
jmp 0x168cb
movq 0x8(%rdx), %rdx
movb $0x1, %sil
testb %sil, %sil
jne 0x168a2
jmp 0x168d4
xorl %eax, %eax
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x16908
movq 0x10(%rsi), %r8
movb (%r8), %dil
cmpb (%rcx), %dil
jne 0x168fa
movb 0x1(%r8), %dil
cmpb 0x1(%rcx), %dil
jne 0x168fa
xorl %edi, %edi
movq %r8, %rdx
jmp 0x16901
movq 0x8(%rsi), %rsi
movb $0x1, %dil
testb %dil, %dil
jne 0x168d8
jmp 0x1690a
xorl %edx, %edx
movl $0x2, %ecx
testq %rax, %rax
je 0x16bbb
testq %rdx, %rdx
je 0x16bbb
movq 0x8(%rax), %rdi
movq 0x8(%rdx), %rsi
callq 0x3300
movq (%rsp), %r9
movl $0x0, %ecx
testl %eax, %eax
jne 0x16bbb
movq %rbp, 0x10(%rsp)
leaq 0xc085(%rip), %rax      # 0x229d0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %r10
testq %r10, %r10
je 0x16a2a
xorl %r12d, %r12d
xorl %r15d, %r15d
movq (%r10,%r12,8), %rcx
testq %rcx, %rcx
je 0x16a67
movq 0x8(%r14), %rdx
testq %rdx, %rdx
je 0x169a4
movq 0x10(%rdx), %rdi
movb (%rdi), %sil
cmpb (%rcx), %sil
jne 0x16996
movb 0x1(%rdi), %sil
cmpb 0x1(%rcx), %sil
jne 0x16996
xorl %esi, %esi
movq %rdi, %rax
jmp 0x1699d
movq 0x8(%rdx), %rdx
movb $0x1, %sil
testb %sil, %sil
jne 0x16974
jmp 0x169a6
xorl %eax, %eax
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x169da
movq 0x10(%rsi), %r8
movb (%r8), %dil
cmpb (%rcx), %dil
jne 0x169cc
movb 0x1(%r8), %dil
cmpb 0x1(%rcx), %dil
jne 0x169cc
xorl %edi, %edi
movq %r8, %rdx
jmp 0x169d3
movq 0x8(%rsi), %rsi
movb $0x1, %dil
testb %dil, %dil
jne 0x169aa
jmp 0x169dc
xorl %edx, %edx
movq %rax, %rcx
orq %rdx, %rcx
je 0x16b82
movl $0x1, %ebp
testq %rax, %rax
je 0x16a19
testq %rdx, %rdx
je 0x16a19
movq 0x8(%rax), %rdi
movq 0x8(%rdx), %rsi
movq %r10, %rbp
callq 0x3300
movq %rbp, %r10
movq (%rsp), %r9
movl %r15d, %ebp
testl %eax, %eax
jne 0x16ba2
incq %r12
movl %ebp, %r15d
testq %r10, %r10
jne 0x16963
jmp 0x16a6a
xorl %ebp, %ebp
leaq 0xbf6d(%rip), %rax      # 0x229a0
cmpq $0x0, (%rax,%rcx,8)
jne 0x16a6a
movq 0x8(%r14), %rax
movq 0x10(%rax), %rax
movq 0x8(%rbx), %rcx
movq 0x10(%rcx), %rcx
movq 0x8(%rax), %rdi
movq 0x8(%rcx), %rsi
callq 0x3300
movq (%rsp), %r9
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
jmp 0x16baf
movl %r15d, %ebp
leaq 0xbf2f(%rip), %rax      # 0x229a0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %r15
testq %r15, %r15
je 0x16b70
movq (%r15), %rax
testq %rax, %rax
je 0x16b70
movq 0x8(%r14), %r14
movq 0x8(%rbx), %rbx
xorl %ecx, %ecx
movq %rcx, %r12
movq %r14, %rdx
testq %rdx, %rdx
je 0x16acf
movq 0x10(%rdx), %rdi
movb (%rdi), %sil
cmpb (%rax), %sil
jne 0x16ac1
movb 0x1(%rdi), %sil
cmpb 0x1(%rax), %sil
jne 0x16ac1
xorl %esi, %esi
movq %rdi, %rcx
jmp 0x16ac8
movq 0x8(%rdx), %rdx
movb $0x1, %sil
testb %sil, %sil
jne 0x16a9f
jmp 0x16ad1
xorl %ecx, %ecx
movq %rbx, %rsi
testq %rsi, %rsi
je 0x16b04
movq 0x10(%rsi), %r8
movb (%r8), %dil
cmpb (%rax), %dil
jne 0x16af6
movb 0x1(%r8), %dil
cmpb 0x1(%rax), %dil
jne 0x16af6
xorl %edi, %edi
movq %r8, %rdx
jmp 0x16afd
movq 0x8(%rsi), %rsi
movb $0x1, %dil
testb %dil, %dil
jne 0x16ad4
jmp 0x16b06
xorl %edx, %edx
movq %rcx, %rax
orq %rdx, %rax
jne 0x16b1d
movq 0x8(%r15,%r12,8), %rax
incq %r12
testq %rax, %rax
jne 0x16a9c
jmp 0x16b70
movl $0x1, %esi
testq %rcx, %rcx
je 0x16b43
testq %rdx, %rdx
je 0x16b43
movq 0x8(%rcx), %rdi
movq 0x8(%rdx), %rsi
callq 0x3300
movq (%rsp), %r9
movl %ebp, %esi
testl %eax, %eax
jne 0x16ba2
shlq $0x20, %r12
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r12
movq %r12, %rcx
sarq $0x20, %rcx
sarq $0x1d, %r12
movq (%r15,%r12), %rax
movl %esi, %ebp
testq %rax, %rax
jne 0x16a99
jmp 0x16b72
movl %ebp, %esi
xorl %eax, %eax
testl %esi, %esi
setne %al
leal 0x1(,%rax,2), %ecx
jmp 0x16baf
movl $0x2, %ecx
jmp 0x16baf
leaq 0x53c7(%rip), %rdi      # 0x1bf57
xorl %eax, %eax
callq 0x42f1
movq (%rsp), %r9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x16bbb
xorl %ecx, %ecx
cmpq $0x0, 0x10(%rsp)
setne %cl
addl %ecx, %ecx
movq 0x8(%rsp), %r12
leaq 0xbdb5(%rip), %r15      # 0x22970
testl %ecx, %ecx
jne 0x16bec
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x16822
movq 0x10(%r9), %rdi
callq 0x15b27
movq %r12, %rdi
movq %rax, %rsi
callq 0x15ad6
movq (%rsp), %r9
movq %rax, %r12
jmp 0x16cca
cmpl $0x3, %ecx
je 0x16c13
cmpl $0x2, %ecx
jne 0x16cca
movq %r9, %rdi
movq %r13, %rsi
callq 0x4389
movq (%rsp), %r9
xorl %ecx, %ecx
movq %r9, %rax
jmp 0x16cd0
movq 0x10(%r13), %rbx
movq 0x10(%r9), %rax
movb (%rbx), %cl
cmpb (%rax), %cl
jne 0x16cca
movb 0x1(%rbx), %cl
cmpb 0x1(%rax), %cl
jne 0x16cca
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x16cca
movq 0x10(%r14), %r15
movq 0x8(%rbx), %r13
movq %r13, %rax
testq %rax, %rax
je 0x16c75
movq 0x10(%rax), %rsi
movb (%rsi), %dl
cmpb (%r15), %dl
jne 0x16c69
movb 0x1(%rsi), %dl
cmpb 0x1(%r15), %dl
jne 0x16c69
xorl %edx, %edx
movq %rsi, %rcx
jmp 0x16c6f
movq 0x8(%rax), %rax
movb $0x1, %dl
testb %dl, %dl
jne 0x16c49
jmp 0x16c77
xorl %ecx, %ecx
testq %rcx, %rcx
jne 0x16cb6
movl $0x10, %edi
callq 0x33e0
movq %rax, %rbp
movb (%r15), %al
movb %al, (%rbp)
movb 0x1(%r15), %al
movb %al, 0x1(%rbp)
movq 0x8(%r15), %rdi
callq 0x3590
movq %rax, 0x8(%rbp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x15ad6
movq (%rsp), %r9
movq %rax, 0x8(%rbx)
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x16c3e
leaq 0xbca6(%rip), %r15      # 0x22970
movq 0x8(%r9), %rax
movb $0x1, %cl
testb %cl, %cl
jne 0x16801
testq %r9, %r9
jne 0x167c3
movq 0x30(%rsp), %rax
incq %rax
cmpq 0x20(%rsp), %rax
jne 0x167f0
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq