// File: /workspace/github_c_makefile_star2_O2/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 0x4251d
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x278(%rdi), %rdi
callq 0x45c0
movq 0x38(%rbx), %rdi
callq 0x45c0
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x423b4
callq 0x4251e
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x423c2
callq 0x3f8fc
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x42415
xorl %r14d, %r14d
movslq 0x58(%rbx), %rax
cmpq %rax, %r14
jge 0x42410
movq (%rdi,%r14,8), %rax
testq %rax, %rax
je 0x423f8
movq %rax, %rdi
callq 0x42611
movq 0x88(%rbx), %rdi
movq (%rdi,%r14,8), %rax
jmp 0x423fa
xorl %eax, %eax
cmpq 0x90(%rbx), %rax
jne 0x4240b
andq $0x0, 0x90(%rbx)
incq %r14
jmp 0x423d1
callq 0x45c0
movq 0x90(%rbx), %rdi
testq %rdi, %rdi
je 0x4242e
callq 0x42611
andq $0x0, 0x90(%rbx)
pushq $0x2a
popq %r14
cmpq $0x46, %r14
je 0x4244b
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x42446
callq 0x47b38
incq %r14
jmp 0x42432
movq 0x270(%rbx), %r14
testq %r14, %r14
je 0x424e4
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpl (%r14), %r12d
je 0x424c1
movq 0x10(%r14), %rax
movl %r12d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x424b9
movq 0x20(%r14), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %r15
testq %r15, %r15
je 0x424b9
movq (%r15), %rdi
testq %rdi, %rdi
je 0x42498
callq *0x20(%rdi)
movq 0x8(%r15), %rdi
callq 0x3f8fc
movq 0x10(%r15), %rdi
callq 0x3f8fc
movq %r15, %rdi
callq 0x45c0
movq 0x270(%rbx), %r14
incl %r12d
addl $0x2, %ebp
jmp 0x42460
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 0x424f9
movq 0xe0(%rbx), %rdi
callq 0x45c0
movq 0xf0(%rbx), %rdi
testq %rdi, %rdi
je 0x4250d
movl 0x6c(%rbx), %esi
callq 0x4277f
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x45c0
retq