// File: /workspace/github_c_makefile_star2_O3/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 $0x68, %rsp
cmpl $0x2, %edi
jl 0x174c4
movq %rsi, %rbx
movl %edi, %ebp
movq (%rsi), %rdi
callq 0x16086
movq %rax, 0x8(%rsp)
movl %ebp, %eax
movq %rax, 0x30(%rsp)
movl $0x1, %r14d
movq %rbx, 0x38(%rsp)
movq (%rbx,%r14,8), %rax
testq %rax, %rax
je 0x174a4
movq %r14, 0x18(%rsp)
movq %rax, 0x60(%rsp)
movq 0x10(%rax), %r9
cmpq $0x0, 0x8(%rsp)
je 0x173d0
movsbl (%r9), %ebp
movq 0xc90a(%rip), %rax      # 0x23970
movq %rax, 0x50(%rsp)
movq 0x8(%rsp), %r13
movq %r9, 0x20(%rsp)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
cmpb (%rax), %bpl
jne 0x1718e
movsbl 0x1(%r9), %edx
movq 0x10(%rsp), %rax
cmpb 0x1(%rax), %dl
jne 0x1718e
movq 0x50(%rsp), %rcx
testq %rcx, %rcx
movabsq $0x100000000, %rsi      # imm = 0x100000000
movq 0x18(%rsp), %r14
je 0x17492
leaq 0xc8ba(%rip), %rax      # 0x23978
xorl %ebx, %ebx
cmpb %bpl, (%rcx)
jne 0x170ca
cmpb %dl, 0x1(%rcx)
je 0x170de
movq (%rax), %rcx
addq %rsi, %rbx
addq $0x8, %rax
testq %rcx, %rcx
jne 0x170c0
jmp 0x17492
movq %rbx, %rax
sarq $0x1d, %rax
leaq 0xc914(%rip), %rcx      # 0x23a00
movq (%rax,%rcx), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x171a0
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0x8(%r9), %rdx
testq %rdx, %rdx
je 0x17137
movb (%rax), %sil
movq 0x10(%rsp), %r8
movq 0x10(%rdx), %rcx
cmpb %sil, (%rcx)
jne 0x1712a
movb 0x1(%rcx), %dil
cmpb 0x1(%rax), %dil
je 0x1713e
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
jne 0x17117
xorl %ecx, %ecx
jmp 0x1713e
xorl %ecx, %ecx
movq 0x10(%rsp), %r8
movq 0x8(%r8), %rdx
testq %rdx, %rdx
je 0x174b9
movb (%rax), %sil
movq 0x10(%rdx), %r8
cmpb %sil, (%r8)
jne 0x17161
movb 0x1(%r8), %dil
cmpb 0x1(%rax), %dil
je 0x1716f
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
jne 0x1714e
jmp 0x174b9
testq %rcx, %rcx
je 0x174b9
movq 0x8(%rcx), %rdi
movq 0x8(%r8), %rsi
callq 0x3300
movq 0x20(%rsp), %r9
testl %eax, %eax
je 0x171a0
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x17075
jmp 0x173d0
sarq $0x20, %rbx
leaq 0xc825(%rip), %rax      # 0x239d0
movq (%rax,%rbx,8), %r11
testq %r11, %r11
je 0x17281
movq (%r11), %rax
testq %rax, %rax
je 0x172c8
movq 0x8(%r9), %r15
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %r12
xorl %r10d, %r10d
xorl %r14d, %r14d
movq %r11, 0x40(%rsp)
testq %r15, %r15
je 0x17201
movb (%rax), %dl
movq %r15, %rsi
movq 0x10(%rsi), %rcx
cmpb %dl, (%rcx)
jne 0x171f8
movb 0x1(%rcx), %dil
cmpb 0x1(%rax), %dil
je 0x17203
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
jne 0x171e6
xorl %ecx, %ecx
testq %r12, %r12
je 0x17229
movb (%rax), %dl
movq %r12, %rsi
movq 0x10(%rsi), %r8
cmpb %dl, (%r8)
jne 0x17220
movb 0x1(%r8), %dil
cmpb 0x1(%rax), %dil
je 0x1724a
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
jne 0x1720d
movl $0x1, %r10d
testq %rcx, %rcx
je 0x174b9
movq 0x8(%r11,%r14,8), %rax
incq %r14
testq %rax, %rax
jne 0x171dc
jmp 0x172cb
testq %rcx, %rcx
je 0x17279
movq 0x8(%rcx), %rdi
movq 0x8(%r8), %rsi
movq %r10, 0x48(%rsp)
callq 0x3300
movq 0x40(%rsp), %r11
movq 0x48(%rsp), %r10
movq 0x20(%rsp), %r9
testl %eax, %eax
je 0x17238
jmp 0x173bf
movl $0x1, %r10d
jmp 0x17238
leaq 0xc718(%rip), %rax      # 0x239a0
movq (%rax,%rbx,8), %rbx
xorl %r10d, %r10d
testq %rbx, %rbx
jne 0x172df
movq 0x8(%r9), %rax
movq 0x10(%rax), %rax
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x10(%rcx), %rcx
movq 0x8(%rax), %rdi
movq 0x8(%rcx), %rsi
callq 0x3300
movq 0x20(%rsp), %r9
testl %eax, %eax
jne 0x1718e
jmp 0x17479
xorl %r10d, %r10d
leaq 0xc6ce(%rip), %rax      # 0x239a0
movq (%rax,%rbx,8), %rbx
testq %rbx, %rbx
je 0x173ef
movq (%rbx), %rax
testq %rax, %rax
je 0x173ef
movq 0x8(%r9), %r14
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %r15
xorl %ecx, %ecx
movq %r13, 0x58(%rsp)
movq %rcx, %r12
testq %r14, %r14
je 0x17327
movb (%rax), %dl
movq %r14, %rsi
movq 0x10(%rsi), %rcx
cmpb %dl, (%rcx)
jne 0x1731e
movb 0x1(%rcx), %dil
cmpb 0x1(%rax), %dil
je 0x17329
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
jne 0x1730c
xorl %ecx, %ecx
testq %r15, %r15
je 0x1734f
movb (%rax), %dl
movq %r15, %rsi
movq 0x10(%rsi), %r8
cmpb %dl, (%r8)
jne 0x17346
movb 0x1(%r8), %dil
cmpb 0x1(%rax), %dil
je 0x17366
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
jne 0x17333
testq %rcx, %rcx
jne 0x1738e
movq 0x8(%rbx,%r12,8), %rax
incq %r12
testq %rax, %rax
jne 0x17302
jmp 0x173ef
testq %rcx, %rcx
je 0x1738e
movq 0x8(%rcx), %rdi
movq 0x8(%r8), %rsi
movq %r10, %r13
callq 0x3300
movq %r13, %r10
movq 0x58(%rsp), %r13
movq 0x20(%rsp), %r9
testl %eax, %eax
je 0x17394
jmp 0x173bf
movl $0x1, %r10d
shlq $0x20, %r12
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r12
movq %r12, %rcx
sarq $0x20, %rcx
sarq $0x1d, %r12
movq (%rbx,%r12), %rax
testq %rax, %rax
jne 0x172ff
jmp 0x173ef
cmpq $0x0, 0x28(%rsp)
je 0x1718e
jmp 0x174b9
movq %r9, %rdi
callq 0x16116
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x160c5
movq %rax, 0x8(%rsp)
jmp 0x17479
testl %r10d, %r10d
je 0x17479
movq 0x8(%r9), %rbx
testq %rbx, %rbx
je 0x17479
movq 0x10(%rsp), %r15
movq 0x8(%r15), %r12
movq 0x10(%rbx), %r14
testq %r12, %r12
je 0x17436
movb (%r14), %bpl
movq %r12, %rax
movq 0x10(%rax), %rcx
cmpb %bpl, (%rcx)
jne 0x1742b
movb 0x1(%rcx), %cl
cmpb 0x1(%r14), %cl
je 0x17470
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x17419
jmp 0x17439
movb (%r14), %bpl
movl $0x10, %edi
callq 0x33e0
movq %rax, %r13
movb %bpl, (%rax)
movb 0x1(%r14), %al
movb %al, 0x1(%r13)
movq 0x8(%r14), %rdi
callq 0x3590
movq %rax, 0x8(%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x160c5
movq %rax, %r12
movq %rax, 0x8(%r15)
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x1740a
movq 0x18(%rsp), %r14
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x17046
jmp 0x174a4
leaq 0x5bdb(%rip), %rdi      # 0x1d074
movl %ebp, %esi
xorl %eax, %eax
callq 0x45d0
jmp 0x1747e
incq %r14
cmpq 0x30(%rsp), %r14
movq 0x38(%rsp), %rbx
jne 0x17034
jmp 0x174cd
movq %r13, %rdi
movq %r9, %rsi
callq 0x4668
movq $0x0, 0x8(%rsp)
movq 0x8(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq