// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/cram/sam_header.c
// Function: sam_hdr_free
void sam_hdr_free(SAM_hdr *hdr) {
    if (!hdr)
	return;

    if (--hdr->ref_count > 0)
	return;

    if (ks_str(&hdr->text))
	KS_FREE(&hdr->text);

    if (hdr->h)
	kh_destroy(sam_hdr, hdr->h);

    if (hdr->ref_hash)
	kh_destroy(m_s2i, hdr->ref_hash);

    if (hdr->ref) {
	int i;
	for (i = 0; i < hdr->nref; i++)
	    if (hdr->ref[i].name)
		free(hdr->ref[i].name);
	free(hdr->ref);
    }

    if (hdr->rg_hash)
	kh_destroy(m_s2i, hdr->rg_hash);

    if (hdr->rg) {
	int i;
	for (i = 0; i < hdr->nrg; i++)
	    if (hdr->rg[i].name)
		free(hdr->rg[i].name);
	free(hdr->rg);
    }

    if (hdr->pg_hash)
	kh_destroy(m_s2i, hdr->pg_hash);

    if (hdr->pg) {
	int i;
	for (i = 0; i < hdr->npg; i++)
	    if (hdr->pg[i].name)
		free(hdr->pg[i].name);
	free(hdr->pg);
    }

    if (hdr->pg_end)
	free(hdr->pg_end);

    if (hdr->type_pool)
	pool_destroy(hdr->type_pool);

    if (hdr->tag_pool)
	pool_destroy(hdr->tag_pool);

    if (hdr->str_pool)
	string_pool_destroy(hdr->str_pool);

    free(hdr);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x63d8e
movq %rdi, %rbx
movl 0x498(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x498(%rdi)
cmpl $0x1, %eax
jle 0x63d94
popq %rbx
popq %r14
popq %r15
retq
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x63da2
callq 0x68a0
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x63dce
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x63dfa
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x63e3d
movl 0x38(%rbx), %eax
testl %eax, %eax
jle 0x63e38
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x40(%rbx), %rcx
movq (%rcx,%r14), %rdi
testq %rdi, %rdi
je 0x63e25
callq 0x68a0
movl 0x38(%rbx), %eax
incq %r15
movslq %eax, %rcx
addq $0x20, %r14
cmpq %rcx, %r15
jl 0x63e10
movq 0x40(%rbx), %rdi
callq 0x68a0
movq 0x60(%rbx), %r14
testq %r14, %r14
je 0x63e69
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x63eac
movl 0x50(%rbx), %eax
testl %eax, %eax
jle 0x63ea7
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x58(%rbx), %rcx
movq (%rcx,%r14), %rdi
testq %rdi, %rdi
je 0x63e94
callq 0x68a0
movl 0x50(%rbx), %eax
incq %r15
movslq %eax, %rcx
addq $0x20, %r14
cmpq %rcx, %r15
jl 0x63e7f
movq 0x58(%rbx), %rdi
callq 0x68a0
movq 0x80(%rbx), %r14
testq %r14, %r14
je 0x63edb
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x63f1e
movl 0x68(%rbx), %eax
testl %eax, %eax
jle 0x63f19
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x78(%rbx), %rcx
movq (%rcx,%r14), %rdi
testq %rdi, %rdi
je 0x63f06
callq 0x68a0
movl 0x68(%rbx), %eax
incq %r15
movslq %eax, %rcx
addq $0x28, %r14
cmpq %rcx, %r15
jl 0x63ef1
movq 0x78(%rbx), %rdi
callq 0x68a0
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x63f2f
callq 0x68a0
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x63f3d
callq 0x868fd
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x63f4b
callq 0x868fd
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x63f59
callq 0x650c3
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x68a0