// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_io.c
// Function: cram_free_container
void cram_free_container(cram_container *c) {
    enum cram_DS_ID id;
    int i;

    if (!c)
        return;

    if (c->refs_used)
        free(c->refs_used);

    if (c->landmark)
        free(c->landmark);

    if (c->comp_hdr)
        cram_free_compression_header(c->comp_hdr);

    if (c->comp_hdr_block)
        cram_free_block(c->comp_hdr_block);

    // Free the slices; filled out by encoder only
    if (c->slices) {
        for (i = 0; i < c->max_slice; i++) {
            if (c->slices[i])
                cram_free_slice(c->slices[i]);
            if (c->slices[i] == c->slice)
                c->slice = NULL;
        }
        free(c->slices);
    }

    // Free the current slice; set by both encoder & decoder
    if (c->slice) {
        cram_free_slice(c->slice);
        c->slice = NULL;
    }

    for (id = DS_RN; id < DS_TN; id++)
        if (c->stats[id]) cram_stats_free(c->stats[id]);

    //if (c->aux_B_stats) cram_stats_free(c->aux_B_stats);

    if (c->tags_used) {
        khint_t k;

        for (k = kh_begin(c->tags_used); k != kh_end(c->tags_used); k++) {
            if (!kh_exist(c->tags_used, k))
                continue;

            cram_tag_map *tm = (cram_tag_map *)kh_val(c->tags_used, k);
            if (tm) {
                cram_codec *c = tm->codec;

                if (c) c->free(c);

                // If tm->blk or tm->blk2 is set, then we haven't yet got to
                // cram_encode_container which copies the blocks to s->aux_block
                // and NULLifies tm->blk*.  In this case we failed to complete
                // the container construction, so we have to free up our partially
                // converted CRAM.
                cram_free_block(tm->blk);
                cram_free_block(tm->blk2);
                free(tm);
            }
        }

        kh_destroy(m_tagmap, c->tags_used);
    }

    if (c->ref_free)
        free(c->ref);

    if (c->bams)
        free_bam_list(c->bams, c->max_c_rec);

    free(c);
}

// Assembly:
testq %rdi, %rdi
je 0x52b21
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x278(%rdi), %rdi
testq %rdi, %rdi
je 0x52982
callq 0x45c0
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x52990
callq 0x45c0
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x5299e
callq 0x52b22
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x529ac
callq 0x4f82d
cmpq $0x0, 0x88(%rbx)
je 0x52a0b
cmpl $0x0, 0x58(%rbx)
jle 0x529ff
xorl %r14d, %r14d
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x529d4
callq 0x52c5d
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
cmpq 0x90(%rbx), %rax
jne 0x529f3
movq $0x0, 0x90(%rbx)
incq %r14
movslq 0x58(%rbx), %rax
cmpq %rax, %r14
jl 0x529bf
movq 0x88(%rbx), %rdi
callq 0x45c0
movq 0x90(%rbx), %rdi
testq %rdi, %rdi
je 0x52a27
callq 0x52c5d
movq $0x0, 0x90(%rbx)
movl $0x2a, %r14d
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x52a3b
callq 0x59055
incq %r14
cmpq $0x46, %r14
jne 0x52a2d
cmpq $0x0, 0x270(%rbx)
je 0x52ae6
movq 0x270(%rbx), %r14
cmpl $0x0, (%r14)
je 0x52ac3
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x10(%r14), %rax
movl %r15d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x52ab1
movq 0x20(%r14), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %r14
testq %r14, %r14
je 0x52ab1
movq (%r14), %rdi
testq %rdi, %rdi
je 0x52a97
callq *0x20(%rdi)
movq 0x8(%r14), %rdi
callq 0x4f82d
movq 0x10(%r14), %rdi
callq 0x4f82d
movq %r14, %rdi
callq 0x45c0
incl %r15d
movq 0x270(%rbx), %r14
addl $0x2, %ebp
cmpl (%r14), %r15d
jne 0x52a64
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
cmpl $0x0, 0x29c(%rbx)
je 0x52afb
movq 0xe0(%rbx), %rdi
callq 0x45c0
movq 0xf0(%rbx), %rdi
testq %rdi, %rdi
je 0x52b0f
movl 0x6c(%rbx), %esi
callq 0x52e36
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x45c0
retq