// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/sam_header.c
// Function: sam_hdr_find
SAM_hdr_type *sam_hdr_find(SAM_hdr *hdr, char *type,
			   char *ID_key, char *ID_value) {
    SAM_hdr_type *t1, *t2;
    int itype = (type[0]<<8)|(type[1]);
    khint_t k;

    /* Special case for types we have prebuilt hashes on */
    if (ID_key) {
	if (type[0]   == 'S' && type[1]   == 'Q' &&
	    ID_key[0] == 'S' && ID_key[1] == 'N') {
	    k = kh_get(m_s2i, hdr->ref_hash, ID_value);
	    return k != kh_end(hdr->ref_hash)
		? hdr->ref[kh_val(hdr->ref_hash, k)].ty
		: NULL;
	}

	if (type[0]   == 'R' && type[1]   == 'G' &&
	    ID_key[0] == 'I' && ID_key[1] == 'D') {
	    k = kh_get(m_s2i, hdr->rg_hash, ID_value);
	    return k != kh_end(hdr->rg_hash)
		? hdr->rg[kh_val(hdr->rg_hash, k)].ty
		: NULL;
	}

	if (type[0]   == 'P' && type[1]   == 'G' &&
	    ID_key[0] == 'I' && ID_key[1] == 'D') {
	    k = kh_get(m_s2i, hdr->pg_hash, ID_value);
	    return k != kh_end(hdr->pg_hash)
		? hdr->pg[kh_val(hdr->pg_hash, k)].ty
		: NULL;
	}
    }

    k = kh_get(sam_hdr, hdr->h, itype);
    if (k == kh_end(hdr->h))
	return NULL;
    
    if (!ID_key)
	return kh_val(hdr->h, k);

    t1 = t2 = kh_val(hdr->h, k);
    do {
	SAM_hdr_tag *tag;
	for (tag = t1->tag; tag; tag = tag->next) {
	    if (tag->str[0] == ID_key[0] && tag->str[1] == ID_key[1]) {
		char *cp1 = tag->str+3;
		char *cp2 = ID_value;
		while (*cp1 && *cp1 == *cp2)
		    cp1++, cp2++;
		if (*cp2 || *cp1)
		    continue;
		return t1;
	    }
	}
	t1 = t1->next;
    } while (t1 != t2);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
shll $0x8, %eax
movq -0x18(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x3c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x9543a
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x53, %eax
jne 0x952f7
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x51, %eax
jne 0x952f7
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x53, %eax
jne 0x952f7
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x4e, %eax
jne 0x952f7
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x955c0
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl (%rcx), %eax
je 0x952e2
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movq 0x20(%rcx), %rcx
movl -0x40(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x952ea
xorl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x952ea
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x955ad
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x52, %eax
jne 0x95391
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x47, %eax
jne 0x95391
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x49, %eax
jne 0x95391
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x44, %eax
jne 0x95391
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x955c0
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x60(%rcx), %rcx
cmpl (%rcx), %eax
je 0x9537c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x60(%rcx), %rcx
movq 0x20(%rcx), %rcx
movl -0x40(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x95384
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0x95384
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x955ad
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x50, %eax
jne 0x95438
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x47, %eax
jne 0x95438
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x49, %eax
jne 0x95438
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x44, %eax
jne 0x95438
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x955c0
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
cmpl (%rcx), %eax
je 0x95423
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
movq 0x20(%rcx), %rcx
movl -0x40(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x9542b
xorl %eax, %eax
movq %rax, -0x70(%rbp)
jmp 0x9542b
movq -0x70(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x955ad
jmp 0x9543a
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x3c(%rbp), %esi
callq 0x95710
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x95469
movq $0x0, -0x8(%rbp)
jmp 0x955ad
cmpq $0x0, -0x20(%rbp)
jne 0x9548c
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x955ad
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x9558c
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x9557a
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
movq -0x20(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x9557a
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x3, %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x71(%rbp)
je 0x95533
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
movq -0x58(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x9553c
jmp 0x95556
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x9550c
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x9556e
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x95570
jmp 0x9557c
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x955ad
jmp 0x9557c
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x954b3
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x954a7
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)