// File: karel-brinda[P]ococo/ext/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x5e3b8
jmp 0x5e61b
movq -0x8(%rbp), %rcx
movl 0x498(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x498(%rcx)
cmpl $0x0, %eax
jle 0x5e3d5
jmp 0x5e61b
movq -0x8(%rbp), %rdi
callq 0x5b9e0
cmpq $0x0, %rax
je 0x5e402
jmp 0x5e3e6
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x5e3fe
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x46a0
jmp 0x5e400
jmp 0x5e402
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x5e41a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x5e2b0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x5e432
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x5eb10
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x5e49e
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jge 0x5e491
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x5e484
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x46a0
jmp 0x5e486
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x5e444
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x46a0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x5e4b6
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x5eb10
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x5e522
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x5e515
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x5e508
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x46a0
jmp 0x5e50a
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5e4c8
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x46a0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x5e540
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x5eb10
movq -0x8(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x5e5ac
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x68(%rcx), %eax
jge 0x5e59f
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x5e592
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x46a0
jmp 0x5e594
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5e552
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x46a0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x5e5ca
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0x46a0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x5e5e2
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x75e80
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x5e5fa
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x75e80
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x5e612
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x5ff50
movq -0x8(%rbp), %rdi
callq 0x46a0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)