// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x3530
movq %rax, %r8
testq %r14, %r14
je 0x2054d
movq %r15, %rdi
movq %r15, 0x40(%rsp)
movq %r13, 0x10(%rsp)
movq %rbx, 0x30(%rsp)
movq %r8, 0x8(%rsp)
movq 0x8(%r14), %rax
movb (%rax), %cl
cmpb (%rbx), %cl
jne 0x20527
movb 0x1(%rax), %cl
cmpb 0x1(%rbx), %cl
jne 0x20527
movq 0x8(%rax), %rax
movq %rax, %rcx
testq %rcx, %rcx
je 0x20216
movq 0x8(%rcx), %rsi
movb (%rsi), %dl
cmpb (%r13), %dl
jne 0x2020b
movb 0x1(%rsi), %dl
cmpb 0x1(%r13), %dl
jne 0x2020b
xorl %edx, %edx
movq %rsi, %r15
jmp 0x20210
movq (%rcx), %rcx
movb $0x1, %dl
testb %dl, %dl
jne 0x201ea
jmp 0x20219
xorl %r15d, %r15d
testq %rax, %rax
je 0x20242
movq 0x8(%rax), %rdx
movb (%rdx), %cl
cmpb (%rdi), %cl
jne 0x20237
movb 0x1(%rdx), %cl
cmpb 0x1(%rdi), %cl
jne 0x20237
xorl %ecx, %ecx
movq %rdx, %r9
jmp 0x2023c
movq (%rax), %rax
movb $0x1, %cl
testb %cl, %cl
jne 0x20219
jmp 0x20245
xorl %r9d, %r9d
testq %r15, %r15
je 0x20527
testq %r9, %r9
je 0x20527
movq %r14, 0x18(%rsp)
movq 0x8(%r15), %rsi
movl (%r8), %r14d
testl %r14d, %r14d
movq %r9, 0x38(%rsp)
je 0x2029a
movsbl (%rsi), %ecx
testl %ecx, %ecx
movq %r15, (%rsp)
je 0x202a1
movb 0x1(%rsi), %al
testb %al, %al
je 0x202a3
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 0x20283
jmp 0x202a3
xorl %ebx, %ebx
jmp 0x2034d
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 0x20337
testb $0x1, %al
jne 0x2031a
movq 0x18(%r8), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r15
movl %r9d, %r14d
callq 0x34e0
movq 0x20(%rsp), %rdi
movl %r14d, %r9d
movq 0x28(%rsp), %r14
movq %r15, %rsi
movq 0x8(%rsp), %r8
testl %eax, %eax
je 0x20337
addl %r13d, %ebx
cmpl %r14d, %ebx
movl %r14d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebx
cmpl %r9d, %ebx
jne 0x202ce
movl %r14d, %ebx
jmp 0x20344
movl %ebp, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
cmovnel %r14d, %ebx
movq 0x10(%rsp), %r13
movq (%rsp), %r15
cmpl %r14d, %ebx
jne 0x20535
movq 0x8(%r15), %rbp
movl 0x8(%r8), %eax
cmpl 0xc(%r8), %eax
jb 0x20387
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 0x20df9
movq 0x8(%rsp), %r8
movl (%r8), %edi
movsbl (%rbp), %esi
testl %esi, %esi
je 0x203b9
movb 0x1(%rbp), %al
testb %al, %al
movq 0x18(%rsp), %r14
je 0x203c0
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 0x203a2
jmp 0x203c0
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 0x204a2
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 0x20470
testb $0x1, %al
jne 0x2044c
movq 0x18(%r8), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rbp, %rsi
callq 0x34e0
movl (%rsp), %edx
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %r11
movq 0x8(%rsp), %r8
testl %eax, %eax
je 0x20470
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 0x20401
jmp 0x20472
movl %edi, %eax
movl %eax, %r12d
cmpl %edi, %eax
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r14
jne 0x204a2
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 0x204ed
testb $0x1, %dil
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r9
je 0x20516
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 0x20516
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 (%r14), %r14
testq %r14, %r14
jne 0x201c9
jmp 0x2054d
leaq 0x7722(%rip), %rdi      # 0x27c5e
xorl %eax, %eax
callq 0x4d75
movq 0x8(%rsp), %r8
jmp 0x20356
movq %r8, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq