// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header2tbl
void *sam_header2tbl(const void *_dict, char type[2], char key_tag[2], char value_tag[2])
{
	const HeaderDict *dict = (const HeaderDict*)_dict;
    const list_t *l   = dict;
    khash_t(str) *tbl = kh_init(str);
    khiter_t k;
    int ret;

	if (_dict == 0) return tbl; // return an empty (not null) hash table
    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] ) 
        {
            l = l->next;
            continue;
        }
        
        HeaderTag *key, *value;
        key   = header_line_has_tag(hline,key_tag);
        value = header_line_has_tag(hline,value_tag); 
        if ( !key || !value )
        {
            l = l->next;
            continue;
        }
        
        k = kh_get(str, tbl, key->value);
        if ( k != kh_end(tbl) )
            debug("[sam_header_lookup_table] They key %s not unique.\n", key->value);
        k = kh_put(str, tbl, key->value, &ret);
        kh_value(tbl, k) = value->value;

        l = l->next;
    }
    return tbl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
movl $0x1, %edi
movl $0x28, %esi
callq 0x32e0
movq %rax, %r8
testq %r14, %r14
je 0x16493
movq %r15, %rdi
movq %r15, 0x40(%rsp)
movq %r13, 0x10(%rsp)
movq %rbx, 0x30(%rsp)
movq %r8, 0x8(%rsp)
movq 0x10(%r14), %rax
movb (%rax), %cl
cmpb (%rbx), %cl
jne 0x1646c
movb 0x1(%rax), %cl
cmpb 0x1(%rbx), %cl
jne 0x1646c
movq 0x8(%rax), %rax
movq %rax, %rcx
testq %rcx, %rcx
je 0x1615a
movq 0x10(%rcx), %rsi
movb (%rsi), %dl
cmpb (%r13), %dl
jne 0x1614e
movb 0x1(%rsi), %dl
cmpb 0x1(%r13), %dl
jne 0x1614e
xorl %edx, %edx
movq %rsi, %r15
jmp 0x16154
movq 0x8(%rcx), %rcx
movb $0x1, %dl
testb %dl, %dl
jne 0x1612d
jmp 0x1615d
xorl %r15d, %r15d
testq %rax, %rax
je 0x16187
movq 0x10(%rax), %rdx
movb (%rdx), %cl
cmpb (%rdi), %cl
jne 0x1617b
movb 0x1(%rdx), %cl
cmpb 0x1(%rdi), %cl
jne 0x1617b
xorl %ecx, %ecx
movq %rdx, %r9
jmp 0x16181
movq 0x8(%rax), %rax
movb $0x1, %cl
testb %cl, %cl
jne 0x1615d
jmp 0x1618a
xorl %r9d, %r9d
testq %r15, %r15
je 0x1646c
testq %r9, %r9
je 0x1646c
movq %r14, 0x18(%rsp)
movq 0x8(%r15), %rsi
movl (%r8), %r14d
testl %r14d, %r14d
movq %r9, 0x38(%rsp)
je 0x161df
movsbl (%rsi), %ecx
testl %ecx, %ecx
movq %r15, (%rsp)
je 0x161e6
movb 0x1(%rsi), %al
testb %al, %al
je 0x161e8
leaq 0x2(%rsi), %rdx
movl %ecx, %edi
shll $0x5, %edi
subl %ecx, %edi
movsbl %al, %ecx
addl %edi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x161c8
jmp 0x161e8
xorl %ebx, %ebx
jmp 0x16292
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl %edx, %r9d
leal -0x1(%r14), %edi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %edx, %r13d
incl %r13d
movq 0x10(%r8), %rdi
movl %r9d, %ebx
movq %r14, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r12d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r12d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x1627c
testb $0x1, %al
jne 0x1625f
movq 0x18(%r8), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r15
movl %r9d, %r14d
callq 0x3300
movq 0x20(%rsp), %rdi
movl %r14d, %r9d
movq 0x28(%rsp), %r14
movq %r15, %rsi
movq 0x8(%rsp), %r8
testl %eax, %eax
je 0x1627c
addl %r13d, %ebx
cmpl %r14d, %ebx
movl %r14d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebx
cmpl %r9d, %ebx
jne 0x16213
movl %r14d, %ebx
jmp 0x16289
movl %ebp, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
cmovnel %r14d, %ebx
movq 0x10(%rsp), %r13
movq (%rsp), %r15
cmpl %r14d, %ebx
jne 0x1647b
movq 0x8(%r15), %rbp
movl 0x8(%r8), %eax
cmpl 0xc(%r8), %eax
jb 0x162cc
movl 0x4(%r8), %eax
addl %eax, %eax
cmpl %r14d, %eax
movl $0x0, %esi
sbbl %esi, %esi
orl $0x1, %esi
addl %r14d, %esi
movq %r8, %rdi
callq 0x16f46
movq 0x8(%rsp), %r8
movl (%r8), %edi
movsbl (%rbp), %esi
testl %esi, %esi
je 0x162fe
movb 0x1(%rbp), %al
testb %al, %al
movq 0x18(%rsp), %r14
je 0x16305
leaq 0x2(%rbp), %rcx
movl %esi, %edx
shll $0x5, %edx
subl %esi, %edx
movsbl %al, %esi
addl %edx, %esi
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x162e7
jmp 0x16305
xorl %esi, %esi
movq 0x18(%rsp), %r14
movl %esi, %eax
xorl %edx, %edx
divl %edi
movl %edx, %r12d
movq 0x10(%r8), %r11
movl %edx, %eax
shrl $0x4, %eax
movl (%r11,%rax,4), %eax
leal (%r12,%r12), %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x163e7
leal -0x1(%rdi), %ecx
movl %esi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %r12d, %r15d
movl %edi, %ebx
movq %rdi, 0x28(%rsp)
movq %r11, 0x20(%rsp)
movl %edx, (%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r11,%rax,4), %r14d
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %r14d, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x163b5
testb $0x1, %al
jne 0x16391
movq 0x18(%r8), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rbp, %rsi
callq 0x3300
movl (%rsp), %edx
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %r11
movq 0x8(%rsp), %r8
testl %eax, %eax
je 0x163b5
btl %r13d, %r14d
cmovbl %r15d, %ebx
addl %edx, %r15d
cmpl %edi, %r15d
movl %edi, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r15d
movl %ebx, %eax
cmpl %r12d, %r15d
jne 0x16346
jmp 0x163b7
movl %edi, %eax
movl %eax, %r12d
cmpl %edi, %eax
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r14
jne 0x163e7
movl %r15d, %eax
shrl $0x4, %eax
movl (%r11,%rax,4), %eax
leal (%r15,%r15), %ecx
shrl %cl, %eax
cmpl %edi, %ebx
cmovel %r15d, %ebx
testb $0x2, %al
cmovel %r15d, %ebx
movl %ebx, %r12d
movl %r12d, %eax
shrl $0x4, %eax
movl (%r11,%rax,4), %edx
leal (%r12,%r12), %ecx
andl $0x1e, %ecx
movl %edx, %edi
shrl %cl, %edi
movl %r12d, %esi
testb $0x2, %dil
jne 0x16432
testb $0x1, %dil
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r9
je 0x1645b
movl $0x3, %edi
shll %cl, %edi
movq 0x18(%r8), %rcx
movq %rbp, (%rcx,%rsi,8)
notl %edi
andl %edi, %edx
movl %edx, (%r11,%rax,4)
incl 0x4(%r8)
jmp 0x1645b
movl $0x3, %edi
shll %cl, %edi
movq 0x18(%r8), %rcx
movq %rbp, (%rcx,%rsi,8)
notl %edi
andl %edi, %edx
movl %edx, (%r11,%rax,4)
incl 0x4(%r8)
incl 0x8(%r8)
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r9
movq 0x8(%r9), %rax
movq 0x20(%r8), %rcx
movq %rax, (%rcx,%rsi,8)
movq 0x40(%rsp), %rdi
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x1610c
jmp 0x16493
leaq 0x5952(%rip), %rdi      # 0x1bdd4
xorl %eax, %eax
callq 0x42f1
movq 0x8(%rsp), %r8
jmp 0x1629b
movq %r8, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq