// File: /workspace/github_c_makefile_star2_O1/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 0x63d8b
movq %rdi, %rbx
movl 0x498(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x498(%rdi)
cmpl $0x1, %eax
jle 0x63d91
popq %rbx
popq %r14
popq %r15
retq
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x63d9f
callq 0x68a0
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x63dcb
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 0x63df7
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
cmpq $0x0, 0x40(%rbx)
je 0x63e35
cmpl $0x0, 0x38(%rbx)
jle 0x63e2c
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x63e1c
callq 0x68a0
incq %r15
movslq 0x38(%rbx), %rax
addq $0x20, %r14
cmpq %rax, %r15
jl 0x63e0a
movq 0x40(%rbx), %rdi
callq 0x68a0
movq 0x60(%rbx), %r14
testq %r14, %r14
je 0x63e61
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
cmpq $0x0, 0x58(%rbx)
je 0x63e9f
cmpl $0x0, 0x50(%rbx)
jle 0x63e96
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x58(%rbx), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x63e86
callq 0x68a0
incq %r15
movslq 0x50(%rbx), %rax
addq $0x20, %r14
cmpq %rax, %r15
jl 0x63e74
movq 0x58(%rbx), %rdi
callq 0x68a0
movq 0x80(%rbx), %r14
testq %r14, %r14
je 0x63ece
movq 0x18(%r14), %rdi
callq 0x68a0
movq 0x10(%r14), %rdi
callq 0x68a0
movq 0x20(%r14), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x68a0
cmpq $0x0, 0x78(%rbx)
je 0x63f0c
cmpl $0x0, 0x68(%rbx)
jle 0x63f03
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x78(%rbx), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x63ef3
callq 0x68a0
incq %r15
movslq 0x68(%rbx), %rax
addq $0x28, %r14
cmpq %rax, %r15
jl 0x63ee1
movq 0x78(%rbx), %rdi
callq 0x68a0
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x63f1d
callq 0x68a0
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x63f2b
callq 0x86d5d
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x63f39
callq 0x86d5d
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x63f47
callq 0x65093
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x68a0