// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_decode.c
// Function: cram_first_slice
static cram_container *cram_first_slice(cram_fd *fd) {
    cram_container *c;

    do {
        if (fd->ctr)
            cram_free_container(fd->ctr);

        if (!(c = fd->ctr = cram_read_container(fd)))
            return NULL;
        c->curr_slice_mt = c->curr_slice;
    } while (c->length == 0);

    /*
     * The first container may be a result of a sub-range query.
     * In which case it may still not be the optimal starting point
     * due to skipped containers/slices in the index.
     */
    // No need for locks here as we're in the main thread.
    if (fd->range.refid != -2) {
        while (c->ref_seq_id != -2 &&
               (c->ref_seq_id < fd->range.refid ||
                (fd->range.refid >= 0 && c->ref_seq_id == fd->range.refid
                 && c->ref_seq_start + c->ref_seq_span-1 < fd->range.start))) {
            if (0 != cram_seek(fd, c->length, SEEK_CUR))
                return NULL;
            cram_free_container(fd->ctr);
            do {
                if (!(c = fd->ctr = cram_read_container(fd)))
                    return NULL;
            } while (c->length == 0);
        }

        if (c->ref_seq_id != -2 && c->ref_seq_id != fd->range.refid) {
            fd->eof = 1;
            return NULL;
        }
    }

    if (!(c->comp_hdr_block = cram_read_block(fd)))
        return NULL;
    if (c->comp_hdr_block->content_type != COMPRESSION_HEADER)
        return NULL;

    c->comp_hdr = cram_decode_compression_header(fd, c->comp_hdr_block);
    if (!c->comp_hdr)
        return NULL;
    if (!c->comp_hdr->AP_delta &&
        sam_hrecs_sort_order(fd->header->hrecs) != ORDER_COORD) {
        pthread_mutex_lock(&fd->ref_lock);
        fd->unsorted = 1;
        pthread_mutex_unlock(&fd->ref_lock);
    }

    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x59044
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x74a70
movq -0x10(%rbp), %rdi
callq 0x75260
movq -0x10(%rbp), %rcx
movq %rax, 0x38(%rcx)
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x5906c
movq $0x0, -0x8(%rbp)
jmp 0x59294
movq -0x18(%rbp), %rax
movl 0x5c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5902c
movq -0x10(%rbp), %rax
cmpl $-0x2, 0x258(%rax)
je 0x591ca
jmp 0x59096
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $-0x2, 0x4(%rcx)
movb %al, -0x19(%rbp)
je 0x59118
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rdx
movb $0x1, %al
cmpl 0x258(%rdx), %ecx
movb %al, -0x1a(%rbp)
jl 0x59112
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x258(%rcx)
movb %al, -0x1b(%rbp)
jl 0x5910c
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x258(%rdx), %ecx
movb %al, -0x1b(%rbp)
jne 0x5910c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x10(%rcx), %rax
subq $0x1, %rax
movq -0x10(%rbp), %rcx
cmpq 0x260(%rcx), %rax
setl %al
movb %al, -0x1b(%rbp)
movb -0x1b(%rbp), %al
movb %al, -0x1a(%rbp)
movb -0x1a(%rbp), %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb $0x1, %al
jne 0x59121
jmp 0x59190
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movl $0x1, %edx
callq 0x79840
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x5914b
movq $0x0, -0x8(%rbp)
jmp 0x59294
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x74a70
movq -0x10(%rbp), %rdi
callq 0x75260
movq -0x10(%rbp), %rcx
movq %rax, 0x38(%rcx)
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x59180
movq $0x0, -0x8(%rbp)
jmp 0x59294
jmp 0x59182
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x59158
jmp 0x59096
movq -0x18(%rbp), %rax
cmpl $-0x2, 0x4(%rax)
je 0x591c8
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x258(%rcx), %eax
je 0x591c8
movq -0x10(%rbp), %rax
movl $0x1, 0x8890(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x59294
jmp 0x591ca
movq -0x10(%rbp), %rdi
callq 0x6eec0
movq -0x18(%rbp), %rcx
movq %rax, 0x50(%rcx)
cmpq $0x0, %rax
jne 0x591ee
movq $0x0, -0x8(%rbp)
jmp 0x59294
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
cmpl $0x1, 0x8(%rax)
je 0x59209
movq $0x0, -0x8(%rbp)
jmp 0x59294
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0x4f0d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x5923a
movq $0x0, -0x8(%rbp)
jmp 0x59294
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x5928c
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x38(%rax), %rdi
callq 0xde810
cmpl $0x2, %eax
je 0x5928c
movq -0x10(%rbp), %rdi
addq $0x88f0, %rdi           # imm = 0x88F0
callq 0x4730
movq -0x10(%rbp), %rax
movl $0x1, 0x88a4(%rax)
movq -0x10(%rbp), %rdi
addq $0x88f0, %rdi           # imm = 0x88F0
callq 0x4330
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nop