LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_index_query_last
cram_index *cram_index_query_last(cram_fd *fd, int refid, hts_pos_t end) {
    cram_index *e = NULL, *prev_e;
    do {
        prev_e = e;
        e = cram_index_query(fd, refid, end, prev_e);
    } while (e);

    if (!prev_e)
        return NULL;
    e = prev_e;

    // Note: offset of e and e->e_next may be the same if we're using a
    // multi-ref container where a single container generates multiple
    // index entries.
    //
    // We need to keep iterating until offset differs in order to find
    // the genuine file offset for the end of container.
    do {
        prev_e = e;
        e = e->e_next;
    } while (e && e->offset == prev_e->offset);

    return prev_e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
xorl %eax, %eax
movq %rax, %rbx
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0x3d600
testq %rax, %rax
jne 0x3d85d
testq %rbx, %rbx
je 0x3d892
movq %rbx, %rax
movq 0x30(%rbx), %rbx
testq %rbx, %rbx
je 0x3d894
movq 0x28(%rbx), %rcx
cmpq 0x28(%rax), %rcx
je 0x3d87a
jmp 0x3d894
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_seek_to_refpos
int cram_seek_to_refpos(cram_fd *fd, cram_range *r) {
    int ret = 0;
    cram_index *e;

    if (r->refid == HTS_IDX_NONE) {
        ret = -2; goto err;
    }

    // Ideally use an index, so see if we have one.
    if ((e = cram_index_query(fd, r->refid, r->start, NULL))) {
        if (0 != cram_seek(fd, e->offset, SEEK_SET)) {
            ret = -1; goto err;
        }
    } else {
        // Absent from index, but this most likely means it simply has no data.
        ret = -2; goto err;
    }

    pthread_mutex_lock(&fd->range_lock);
    fd->range = *r;
    if (r->refid == HTS_IDX_NOCOOR) {
        fd->range.refid = -1;
        fd->range.start = 0;
    } else if (r->refid == HTS_IDX_START || r->refid == HTS_IDX_REST) {
        fd->range.refid = -2; // special case in cram_next_slice
    }
    pthread_mutex_unlock(&fd->range_lock);

    if (fd->ctr) {
        cram_free_container(fd->ctr);
        if (fd->ctr_mt && fd->ctr_mt != fd->ctr)
            cram_free_container(fd->ctr_mt);
        fd->ctr = NULL;
        fd->ctr_mt = NULL;
        fd->ooc = 0;
        fd->eof = 0;
    }

    return 0;

 err:
    // It's unlikely fd->range will be accessed after EOF or error,
    // but this maintains identical behaviour to the previous code.
    pthread_mutex_lock(&fd->range_lock);
    fd->range = *r;
    pthread_mutex_unlock(&fd->range_lock);
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %esi
pushq $-0x2
popq %rbp
cmpl $-0x5, %esi
je 0x3d8de
movq 0x8(%r14), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x3d600
testq %rax, %rax
je 0x3d8de
movq 0x28(%rax), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x44dc2
testl %eax, %eax
je 0x3d918
pushq $-0x1
popq %rbp
leaq 0x8918(%rbx), %r15
movq %r15, %rdi
callq 0x4750
movups (%r14), %xmm0
movups %xmm0, 0x258(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x268(%rbx)
movq %r15, %rdi
callq 0x4340
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8918(%rbx), %r15
movq %r15, %rdi
callq 0x4750
movq 0x10(%r14), %rax
movq %rax, 0x268(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x258(%rbx)
movl (%r14), %eax
leal 0x4(%rax), %ecx
cmpl $0x2, %ecx
jae 0x3d957
leaq 0x258(%rbx), %rax
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
jmp 0x3d96b
cmpl $-0x2, %eax
jne 0x3d96b
orl $-0x1, 0x258(%rbx)
andq $0x0, 0x260(%rbx)
movq %r15, %rdi
callq 0x4340
movq 0x38(%rbx), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x3d90b
leaq 0x38(%rbx), %r14
callq 0x4237d
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x3d99a
cmpq (%r14), %rdi
je 0x3d99a
callq 0x4237d
andl $0x0, 0x8978(%rbx)
andl $0x0, 0x8890(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
jmp 0x3d90b
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_num_containers_between
int64_t cram_num_containers_between(cram_fd *fd,
                                    off_t cstart, off_t cend,
                                    int64_t *first, int64_t *last) {
    int64_t nc = 0, i;
    int64_t last_pos = -99;
    int64_t l_first = -1, l_last = -1;

    for (i = 0; i < fd->index_sz; i++) {
        int j = i+1 == fd->index_sz ? 0 : i+1; // maps "*" to end
        nc += cram_num_containers_between_(&fd->index[j], &last_pos, nc,
                                           cstart, cend, &l_first, &l_last);
    }

    if (first)
        *first = l_first;
    if (last)
        *last = l_last;

    return l_last - l_first + 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movabsq $0x100000000, %rbp      # imm = 0x100000000
leaq 0x30(%rsp), %rax
leaq 0x10(%rsp), %rcx
orq $-0x1, (%rcx)
leaq 0x18(%rsp), %rcx
orq $-0x1, (%rcx)
movq $-0x63, (%rax)
pushq $0x1
popq %rbx
xorl %r14d, %r14d
leaq -0x1(%rbx), %rcx
movslq 0x8870(%r13), %rax
cmpq %rax, %rcx
jge 0x3dfcb
cmpq %rax, %rbx
je 0x3df88
movq %rbp, %rax
sarq $0x20, %rax
jmp 0x3df8a
xorl %eax, %eax
imulq $0x38, %rax, %rdi
addq 0x8878(%r13), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
leaq 0x10(%rsp), %r9
callq 0x3e006
addq %rax, %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbp
incq %rbx
jmp 0x3df6a
movq 0x20(%rsp), %rdx
testq %rdx, %rdx
movq 0x28(%rsp), %rcx
je 0x3dfe2
movq 0x10(%rsp), %rax
movq %rax, (%rdx)
movq 0x18(%rsp), %rax
testq %rcx, %rcx
je 0x3dfef
movq %rax, (%rcx)
subq 0x10(%rsp), %rax
incq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_num_containers_between_
static int64_t cram_num_containers_between_(cram_index *e, int64_t *last_pos,
                                            int64_t nct,
                                            off_t cstart, off_t cend,
                                            int64_t *first, int64_t *last) {
    int64_t nc = 0, i;

    if (e->offset) {
        if (e->offset != *last_pos) {
            if (e->offset >= cstart && (!cend || e->offset <= cend)) {
                if (first && *first < 0)
                    *first = nct;
                if (last)
                    *last = nct;
            }
            nc++;
        }
        // else a new multi-ref in same container
        *last_pos = e->offset;
    }

    for (i = 0; i < e->nslice; i++)
        nc += cram_num_containers_between_(&e->e[i], last_pos, nc + nct,
                                           cstart, cend, first, last);

    return nc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r12
movq %r8, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x60(%rsp), %r13
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x3e045
cmpq (%rbp), %rax
jne 0x3e04a
xorl %r14d, %r14d
jmp 0x3e08d
xorl %r14d, %r14d
jmp 0x3e095
pushq $0x1
popq %r14
cmpq 0x18(%rsp), %rax
jl 0x3e08d
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
setne %cl
cmpq %rdx, %rax
setg %al
testb %al, %cl
jne 0x3e08d
testq %r12, %r12
je 0x3e07f
cmpq $0x0, (%r12)
jns 0x3e07f
movq 0x8(%rsp), %rax
movq %rax, (%r12)
testq %r13, %r13
je 0x3e08d
movq 0x8(%rsp), %rax
movq %rax, (%r13)
movq 0x28(%rbx), %rax
movq %rax, (%rbp)
xorl %r15d, %r15d
xorl %edx, %edx
movslq (%rbx), %rax
cmpq %rax, %rdx
jge 0x3e0e1
movq 0x8(%rbx), %rdi
addq %r15, %rdi
movq 0x8(%rsp), %rax
movq %rdx, 0x20(%rsp)
leaq (%r14,%rax), %rdx
movq %r13, (%rsp)
movq %rbp, %rsi
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %r12, %r9
callq 0x3e006
movq 0x20(%rsp), %rdx
addq %rax, %r14
incq %rdx
addq $0x38, %r15
jmp 0x3e09a
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_container_num2offset
off_t cram_container_num2offset(cram_fd *fd, int64_t num) {
    int nc = 0, i;
    int64_t last_pos = -9;
    cram_index *e = NULL;

    for (i = 0; i < fd->index_sz; i++) {
        int j = i+1 == fd->index_sz ? 0 : i+1; // maps "*" to end
        if (!fd->index[j].nslice)
            continue;
        if ((e = cram_container_num2offset_(&fd->index[j], num,
                                            &last_pos, &nc)))
            break;
    }

    return e ? e->offset : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %r12
andl $0x0, (%r12)
leaq 0x10(%rsp), %r13
movq $-0x9, (%r13)
pushq $0x1
popq %rbp
xorl %r15d, %r15d
leal -0x1(%rbp), %ecx
movl 0x8870(%r14), %eax
cmpl %eax, %ecx
jge 0x3e172
cmpl %eax, %ebp
movl %ebp, %eax
cmovel %r15d, %eax
movq 0x8878(%r14), %rdi
imulq $0x38, %rax, %rax
cmpl $0x0, (%rdi,%rax)
je 0x3e16e
addq %rax, %rdi
movl %ebx, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0x3e18a
testq %rax, %rax
jne 0x3e177
incl %ebp
jmp 0x3e132
pushq $-0x1
popq %rax
jmp 0x3e17b
movq 0x28(%rax), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_container_num2offset_
static cram_index *cram_container_num2offset_(cram_index *e, int num,
                                              int64_t *last_pos, int *nc) {
    if (e->offset) {
        if (e->offset != *last_pos) {
            if (*nc == num)
                return e;
            (*nc)++;
        }
        // else a new multi-ref in same container
        *last_pos = e->offset;
    }

    int i;
    for (i = 0; i < e->nslice; i++) {
        cram_index *tmp = cram_container_num2offset_(&e->e[i], num,
                                                     last_pos, nc);
        if (tmp)
            return tmp;
    }


    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x3e1bd
cmpq (%r15), %rax
je 0x3e1ba
movl (%r14), %ecx
cmpl %ebp, %ecx
je 0x3e1f2
incl %ecx
movl %ecx, (%r14)
movq %rax, (%r15)
pushq $-0x1
popq %r12
xorl %edi, %edi
movslq (%rbx), %rax
incq %r12
cmpq %rax, %r12
jge 0x3e1f0
leaq 0x38(%rdi), %r13
addq 0x8(%rbx), %rdi
movl %ebp, %esi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3e18a
movq %r13, %rdi
testq %rax, %rax
je 0x3e1c3
movq %rax, %rbx
jmp 0x3e1f2
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_container_offset2num
int64_t cram_container_offset2num(cram_fd *fd, off_t pos) {
    int nc = 0, i;
    int64_t last_pos = -9;
    cram_index *e = NULL;

    for (i = 0; i < fd->index_sz; i++) {
        int j = i+1 == fd->index_sz ? 0 : i+1; // maps "*" to end
        if (!fd->index[j].nslice)
            continue;
        if ((e = cram_container_offset2num_(&fd->index[j], pos,
                                            &last_pos, &nc)))
            break;
    }

    return e ? nc : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %rax
andl $0x0, (%rax)
leaq 0x10(%rsp), %rax
movq $-0x9, (%rax)
pushq $0x1
popq %r13
xorl %ebp, %ebp
leal -0x1(%r13), %r15d
movl 0x8870(%r14), %r12d
cmpl %r12d, %r15d
jge 0x3e27b
cmpl %r12d, %r13d
movl %r13d, %eax
cmovel %ebp, %eax
movq 0x8878(%r14), %rdi
imulq $0x38, %rax, %rax
cmpl $0x0, (%rdi,%rax)
je 0x3e276
addq %rax, %rdi
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x3e29a
testq %rax, %rax
jne 0x3e27b
incl %r13d
jmp 0x3e232
cmpl %r12d, %r15d
jge 0x3e286
movl 0xc(%rsp), %eax
jmp 0x3e289
pushq $-0x1
popq %rax
cltq
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_container_offset2num_
static cram_index *cram_container_offset2num_(cram_index *e, off_t pos,
                                              int64_t *last_pos, int *nc) {
    if (e->offset) {
        if (e->offset != *last_pos) {
            if (e->offset >= pos)
                return e;
            (*nc)++;
        }
        // else a new multi-ref in same container
        *last_pos = e->offset;
    }

    int i;
    for (i = 0; i < e->nslice; i++) {
        cram_index *tmp = cram_container_offset2num_(&e->e[i], pos,
                                                     last_pos, nc);
        if (tmp)
            return tmp;
    }


    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x3e2ca
cmpq (%r15), %rax
je 0x3e2c7
cmpq %r12, %rax
jge 0x3e300
incl (%r14)
movq %rax, (%r15)
pushq $-0x1
popq %r13
xorl %edi, %edi
movslq (%rbx), %rax
incq %r13
cmpq %rax, %r13
jge 0x3e2fe
leaq 0x38(%rdi), %rbp
addq 0x8(%rbx), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3e29a
movq %rbp, %rdi
testq %rax, %rax
je 0x3e2d0
movq %rax, %rbx
jmp 0x3e300
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: cram_index_extents
int cram_index_extents(cram_fd *fd, int refid, hts_pos_t start, hts_pos_t end,
                       off_t *first, off_t *last) {
    cram_index *ci;

    if (first) {
        if (!(ci = cram_index_query(fd, refid, start, NULL)))
            return -1;
        *first = ci->offset;
    }

    if (last) {
        if (!(ci = cram_index_query_last(fd, refid, end)))
            return -1;
        *last = ci->offset;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %rcx, %r14
movl %esi, %r15d
movq %rdi, %r12
pushq $-0x1
popq %rbp
testq %r8, %r8
je 0x3e34e
movq %r8, %r13
movq %r12, %rdi
movl %r15d, %esi
xorl %ecx, %ecx
callq 0x3d600
testq %rax, %rax
je 0x3e36f
movq 0x28(%rax), %rax
movq %rax, (%r13)
testq %rbx, %rbx
je 0x3e36d
movq %r12, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x3d84c
testq %rax, %rax
je 0x3e36f
movq 0x28(%rax), %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_index.c
// Function: link_index_
static cram_index *link_index_(cram_index *e, cram_index *e_last) {
    int i;
    if (e_last)
        e_last->e_next = e;

    // We don't want to link in the top-level cram_index with
    // offset=0 and start/end = INT_MIN/INT_MAX.
    if (e->offset)
        e_last = e;

    for (i = 0; i < e->nslice; i++)
        e_last = link_index_(&e->e[i], e_last);

    return e_last;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rax
movq %rdi, %rbx
testq %rsi, %rsi
je 0x3e394
movq %rbx, 0x30(%rax)
cmpq $0x0, 0x28(%rbx)
cmovneq %rbx, %rax
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq (%rbx), %rcx
cmpq %rcx, %r15
jge 0x3e3c3
movq 0x8(%rbx), %rdi
addq %r14, %rdi
movq %rax, %rsi
callq 0x3e380
incq %r15
addq $0x38, %r14
jmp 0x3e3a3
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: itf8_put
static inline int itf8_put(char *cp, int32_t val) {
    unsigned char *up = (unsigned char *)cp;
    if        (!(val & ~0x00000007f)) { // 1 byte
        *up = val;
        return 1;
    } else if (!(val & ~0x00003fff)) { // 2 byte
        *up++ = (val >> 8 ) | 0x80;
        *up   = val & 0xff;
        return 2;
    } else if (!(val & ~0x01fffff)) { // 3 byte
        *up++ = (val >> 16) | 0xc0;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 3;
    } else if (!(val & ~0x0fffffff)) { // 4 byte
        *up++ = (val >> 24) | 0xe0;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 4;
    } else {                           // 5 byte
        *up++ = 0xf0 | ((val>>28) & 0xff);
        *up++ = (val >> 20) & 0xff;
        *up++ = (val >> 12) & 0xff;
        *up++ = (val >> 4 ) & 0xff;
        *up = val & 0x0f;
        return 5;
    }
}

// Assembly:
movl %esi, %eax
cmpl $0x7f, %esi
ja 0x3e722
movb %al, (%rdi)
pushq $0x1
jmp 0x3e79b
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x3e73a
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdi)
movb %al, 0x1(%rdi)
pushq $0x2
jmp 0x3e79b
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x3e753
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdi)
movb %ah, 0x1(%rdi)
movb %al, 0x2(%rdi)
pushq $0x3
jmp 0x3e79b
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x3e774
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rdi)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rdi)
movb %ah, 0x2(%rdi)
movb %al, 0x3(%rdi)
pushq $0x4
jmp 0x3e79b
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rdi)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rdi)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rdi)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rdi)
andb $0xf, %al
movb %al, 0x4(%rdi)
pushq $0x5
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: int32_get_blk
int int32_get_blk(cram_block *b, int32_t *val) {
    if (b->uncomp_size - BLOCK_SIZE(b) < 4)
        return -1;

    uint32_t v =
         ((uint32_t) b->data[b->byte  ])        |
        (((uint32_t) b->data[b->byte+1]) <<  8) |
        (((uint32_t) b->data[b->byte+2]) << 16) |
        (((uint32_t) b->data[b->byte+3]) << 24);
    // Avoid implementation-defined behaviour on negative values
    *val = v < 0x80000000U ? (int32_t) v : -((int32_t) (0xffffffffU - v)) - 1;
    BLOCK_SIZE(b) += 4;
    return 4;
}

// Assembly:
movslq 0x14(%rdi), %rcx
movq 0x30(%rdi), %rax
subq %rax, %rcx
cmpq $0x4, %rcx
jae 0x3f210
pushq $-0x1
popq %rax
retq
movq 0x20(%rdi), %rcx
movl (%rcx,%rax), %ecx
movl %ecx, (%rsi)
addq $0x4, %rax
movq %rax, 0x30(%rdi)
pushq $0x4
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_new_block
cram_block *cram_new_block(enum cram_content_type content_type,
                           int content_id) {
    cram_block *b = malloc(sizeof(*b));
    if (!b)
        return NULL;
    b->method = b->orig_method = RAW;
    b->content_type = content_type;
    b->content_id = content_id;
    b->comp_size = 0;
    b->uncomp_size = 0;
    b->data = NULL;
    b->alloc = 0;
    b->byte = 0;
    b->bit = 7; // MSB
    b->crc32 = 0;
    b->idx = 0;
    b->m = NULL;

    return b;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
pushq $0x50
popq %rdi
callq 0x4680
testq %rax, %rax
je 0x3f460
andq $0x0, (%rax)
movl %ebp, 0x8(%rax)
movl %ebx, 0xc(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
andq $0x0, 0x30(%rax)
movl $0x7, 0x38(%rax)
movups %xmm0, 0x10(%rax)
andq $0x0, 0x40(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: int32_decode
static int int32_decode(cram_fd *fd, int32_t *val) {
    int32_t i;
    if (4 != hread(fd->fp, &i, 4))
        return -1;

    *val = le_int4(i);
    return 4;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq (%rdi), %rdi
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x3e674
cmpq $0x4, %rax
jne 0x3f648
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
pushq $0x4
jmp 0x3f64a
pushq $-0x1
popq %rax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_block_size
uint32_t cram_block_size(cram_block *b) {
    unsigned char dat[100], *cp = dat;;
    uint32_t sz;

    *cp++ = b->method;
    *cp++ = b->content_type;
    cp += itf8_put((char*)cp, b->content_id);
    cp += itf8_put((char*)cp, b->comp_size);
    cp += itf8_put((char*)cp, b->uncomp_size);

    sz = cp-dat + 4;
    sz += b->method == RAW ? b->uncomp_size : b->comp_size;

    return sz;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
leaq 0x2(%rsp), %rdi
movl 0xc(%rbx), %esi
movl (%rbx), %ebp
callq 0x3e715
movl %eax, %eax
leaq (%rsp,%rax), %r14
addq $0x2, %r14
movl 0x10(%rbx), %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x3e715
testl %ebp, %ebp
movl %eax, %r12d
movl 0x14(%rbx), %esi
cmovel %esi, %r15d
addq %r14, %r12
movq %r12, %rdi
callq 0x3e715
addl %eax, %r12d
movq %rsp, %rax
subl %eax, %r12d
leal (%r15,%r12), %eax
addl $0x4, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: int32_encode
static int int32_encode(cram_fd *fd, int32_t val) {
    uint32_t v = le_int4(val);
    if (4 != hwrite(fd->fp, &v, 4))
        return -1;

    return 4;
}

// Assembly:
pushq %rax
leaq 0x4(%rsp), %rax
movl %esi, (%rax)
movq (%rdi), %rdi
pushq $0x4
popq %rdx
movq %rax, %rsi
callq 0x3e79d
xorl %ecx, %ecx
cmpq $0x4, %rax
sete %cl
leal (%rcx,%rcx,4), %eax
decl %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_free_block
void cram_free_block(cram_block *b) {
    if (!b)
        return;
    if (b->data)
        free(b->data);
    free(b);
}

// Assembly:
testq %rdi, %rdi
je 0x3f917
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x45c0
movq %rbx, %rdi
popq %rbx
jmp 0x45c0
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: refs_free
void refs_free(refs_t *r) {
    RP("refs_free()\n");

    if (--r->count > 0)
        return;

    if (!r)
        return;

    if (r->pool)
        string_pool_destroy(r->pool);

    if (r->h_meta) {
        khint_t k;

        for (k = kh_begin(r->h_meta); k != kh_end(r->h_meta); k++) {
            ref_entry *e;

            if (!kh_exist(r->h_meta, k))
                continue;
            if (!(e = kh_val(r->h_meta, k)))
                continue;
            ref_entry_free_seq(e);
            free(e);
        }

        kh_destroy(refs, r->h_meta);
    }

    if (r->ref_id)
        free(r->ref_id);

    if (r->fp)
        bgzf_close(r->fp);

    pthread_mutex_destroy(&r->lock);

    free(r);
}

// Assembly:
movl 0x30(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x30(%rdi)
cmpl $0x2, %eax
setge %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x40886
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x4082f
callq 0x4928e
movq 0x8(%rbx), %r14
testq %r14, %r14
je 0x408aa
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpl (%r14), %r12d
je 0x40887
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 0x4087e
movq 0x20(%r14), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %r15
testq %r15, %r15
je 0x4087e
movq %r15, %rdi
callq 0x408da
movq %r15, %rdi
callq 0x45c0
movq 0x8(%rbx), %r14
incl %r12d
addl $0x2, %ebp
jmp 0x4083d
retq
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x10(%rbx), %rdi
callq 0x45c0
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x408c1
callq 0xbc96
leaq 0x38(%rbx), %rdi
callq 0x4590
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x45c0
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: ref_entry_free_seq
static void ref_entry_free_seq(ref_entry *e) {
    if (e->mf)
        mfclose(e->mf);
    if (e->seq && !e->mf)
        free(e->seq);

    e->seq = NULL;
    e->mf = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
testq %rdi, %rdi
je 0x408ef
callq 0x48244
leaq 0x38(%rbx), %r14
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x40908
cmpq $0x0, 0x40(%rbx)
jne 0x40908
callq 0x45c0
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: refs2id
int refs2id(refs_t *r, sam_hdr_t *hdr) {
    int i;
    sam_hrecs_t *h = hdr->hrecs;

    if (r->ref_id)
        free(r->ref_id);
    if (r->last)
        r->last = NULL;

    r->ref_id = calloc(h->nref, sizeof(*r->ref_id));
    if (!r->ref_id)
        return -1;

    r->nref = h->nref;
    for (i = 0; i < h->nref; i++) {
        khint_t k = kh_get(refs, r->h_meta, h->ref[i].name);
        if (k != kh_end(r->h_meta)) {
            r->ref_id[i] = kh_val(r->h_meta, k);
        } else {
            hts_log_warning("Unable to find ref name '%s'", h->ref[i].name);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rsi), %r12
movq 0x10(%rdi), %rdi
callq 0x45c0
cmpq $0x0, 0x60(%rbx)
je 0x4093e
andq $0x0, 0x60(%rbx)
movl 0x28(%r12), %r14d
movslq %r14d, %rdi
pushq $0x8
popq %rsi
callq 0x4300
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x409d0
movl %r14d, 0x18(%rbx)
xorl %ebp, %ebp
xorl %r15d, %r15d
movslq %r14d, %rax
cmpq %rax, %r15
jge 0x409cc
movl %r14d, 0x4(%rsp)
movq 0x8(%rbx), %r14
movq 0x30(%r12), %rax
movq (%rax,%rbp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x409e2
cmpl (%r14), %eax
jne 0x409ac
pushq $0x3
popq %rdi
leaq 0x3c489(%rip), %rsi     # 0x7ce1d
leaq 0x3c48a(%rip), %rdx     # 0x7ce25
movq %r13, %rcx
xorl %eax, %eax
callq 0x110c6
movl 0x28(%r12), %r14d
jmp 0x409c3
movq 0x20(%r14), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movq 0x10(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movl 0x4(%rsp), %r14d
incq %r15
addq $0x18, %rbp
jmp 0x40960
xorl %eax, %eax
jmp 0x409d3
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_set_header2
int cram_set_header2(cram_fd *fd, const sam_hdr_t *hdr) {
    if (!fd || !hdr )
        return -1;

    if (fd->header != hdr) {
        if (fd->header)
            sam_hdr_destroy(fd->header);
        fd->header = sam_hdr_dup(hdr);
        if (!fd->header)
            return -1;
    }
    return refs_from_header(fd);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x40aed
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
cmpq %rsi, %rdi
je 0x40ae1
testq %rdi, %rdi
je 0x40ad0
callq 0x1d61e
movq %r14, %rdi
callq 0x1d74a
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x40aed
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x40af8
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_ref_incr_locked
static void cram_ref_incr_locked(refs_t *r, int id) {
    RP("%d INC REF %d, %d %p\n", gettid(), id,
       (int)(id>=0 && r->ref_id[id]?r->ref_id[id]->count+1:-999),
       id>=0 && r->ref_id[id]?r->ref_id[id]->seq:(char *)1);

    if (id < 0 || !r->ref_id[id] || !r->ref_id[id]->seq)
        return;

    if (r->last_id == id)
        r->last_id = -1;

    ++r->ref_id[id]->count;
}

// Assembly:
testl %esi, %esi
js 0x40d67
movq 0x10(%rdi), %rax
movl %esi, %ecx
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0x40d67
cmpq $0x0, 0x38(%rax)
je 0x40d67
cmpl %esi, 0x68(%rdi)
jne 0x40d63
orl $-0x1, 0x68(%rdi)
incq 0x30(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: bgzf_open_ref
static BGZF *bgzf_open_ref(char *fn, char *mode, int is_md5) {
    BGZF *fp;

    if (strncmp(fn, "file://", 7) == 0)
        fn += 7;

    if (!is_md5 && !hisremote(fn)) {
        char fai_file[PATH_MAX];

        snprintf(fai_file, PATH_MAX, "%s.fai", fn);
        if (access(fai_file, R_OK) != 0)
            if (fai_build(fn) != 0)
                return NULL;
    }

    if (!(fp = bgzf_open(fn, mode))) {
        perror(fn);
        return NULL;
    }

    if (fp->is_compressed == 1 && bgzf_index_load(fp, fn, ".gzi") < 0) {
        hts_log_error("Unable to load .gzi index '%s.gzi'", fn);
        bgzf_close(fp);
        return NULL;
    }

    return fp;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movl %esi, %ebp
movq %rdi, %r14
leaq 0x3c455(%rip), %rsi     # 0x7d3ae
pushq $0x7
popq %rdx
callq 0x4210
leaq 0x7(%r14), %rbx
testl %eax, %eax
cmovneq %r14, %rbx
testl %ebp, %ebp
jne 0x40f7b
movq %rbx, %rdi
callq 0xe4f2
testl %eax, %eax
je 0x40fdb
leaq 0x395a4(%rip), %rsi     # 0x7a526
movq %rbx, %rdi
callq 0x9596
testq %rax, %rax
je 0x4101b
movq %rax, %r14
testb $0x40, 0x3(%rax)
je 0x41026
leaq 0x41fb1(%rip), %rdx     # 0x82f58
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc898
testl %eax, %eax
jns 0x41026
leaq 0x3c400(%rip), %rsi     # 0x7d3bd
leaq 0x3c407(%rip), %rdx     # 0x7d3cb
pushq $0x1
popq %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x110c6
movq %r14, %rdi
callq 0xbc96
jmp 0x41023
leaq 0x3c3d4(%rip), %rdx     # 0x7d3b6
movq %rsp, %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x4800
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x4880
testl %eax, %eax
je 0x40f7b
movq %rbx, %rdi
callq 0x679b7
testl %eax, %eax
jne 0x41023
jmp 0x40f7b
movq %rbx, %rdi
callq 0x43d0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_load_reference
int cram_load_reference(cram_fd *fd, char *fn) {
    int ret = 0;

    if (fn) {
        fd->refs = refs_load_fai(fd->refs, fn,
                                 !(fd->embed_ref>0 && fd->mode == 'r'));
        fn = fd->refs ? fd->refs->fn : NULL;
        if (!fn)
            ret = -1;
        sanitise_SQ_lines(fd);
    }
    fd->ref_fn = fn;

    if ((!fd->refs || (fd->refs->nref == 0 && !fn)) && fd->header) {
        if (fd->refs)
            refs_free(fd->refs);
        if (!(fd->refs = refs_create()))
            return -1;
        if (-1 == refs_from_header(fd))
            return -1;
    }

    if (fd->header)
        if (-1 == refs2id(fd->refs, fd->header))
            return -1;

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testq %rsi, %rsi
je 0x41b9a
movq 0x50(%rbx), %rdi
cmpl $0x0, 0x220(%rbx)
jle 0x41ba2
xorl %edx, %edx
cmpl $0x72, 0x8(%rbx)
setne %dl
jmp 0x41ba5
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x41bce
pushq $0x1
popq %rdx
callq 0x41c43
movq %rax, 0x50(%rbx)
xorl %r14d, %r14d
testq %rax, %rax
je 0x41bbc
movq 0x20(%rax), %r15
jmp 0x41bbf
xorl %r15d, %r15d
cmpq $0x1, %r15
sbbl %r14d, %r14d
movq %rbx, %rdi
callq 0x4208d
movq %r15, 0x80(%rbx)
movq 0x50(%rbx), %rdi
pushq $-0x1
popq %rbp
testq %rdi, %rdi
je 0x41bfa
testq %r15, %r15
jne 0x41c1c
cmpl $0x0, 0x18(%rdi)
jne 0x41c1c
cmpq $0x0, 0x18(%rbx)
je 0x41c1c
callq 0x407fe
jmp 0x41c01
cmpq $0x0, 0x18(%rbx)
je 0x41c1c
callq 0x421be
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x41c36
movq %rbx, %rdi
callq 0x40af8
cmpl $-0x1, %eax
je 0x41c36
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x41c33
movq 0x50(%rbx), %rdi
callq 0x40917
cmpl $-0x1, %eax
je 0x41c36
movl %r14d, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: sanitise_SQ_lines
static void sanitise_SQ_lines(cram_fd *fd) {
    int i;

    if (!fd->header || !fd->header->hrecs)
        return;

    if (!fd->refs || !fd->refs->h_meta)
        return;

    for (i = 0; i < fd->header->hrecs->nref; i++) {
        const char *name = fd->header->hrecs->ref[i].name;
        khint_t k = kh_get(refs, fd->refs->h_meta, name);
        ref_entry *r;

        // We may have @SQ lines which have no known .fai, but do not
        // in themselves pose a problem because they are unused in the file.
        if (k == kh_end(fd->refs->h_meta))
            continue;

        if (!(r = (ref_entry *)kh_val(fd->refs->h_meta, k)))
            continue;

        if (r->length && r->length != fd->header->hrecs->ref[i].len) {
            assert(strcmp(r->name, fd->header->hrecs->ref[i].name) == 0);

            // Should we also check MD5sums here to ensure the correct
            // reference was given?
            hts_log_warning("Header @SQ length mismatch for ref %s, %"PRIhts_pos" vs %d",
                            r->name, fd->header->hrecs->ref[i].len, (int)r->length);

            // Fixing the parsed @SQ header will make MD:Z: strings work
            // and also stop it producing N for the sequence.
            fd->header->hrecs->ref[i].len = r->length;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x18(%rdi), %rax
testq %rax, %rax
je 0x42190
movq 0x38(%rax), %r15
testq %r15, %r15
je 0x42190
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rax
testq %rax, %rax
je 0x42190
cmpq $0x0, 0x8(%rax)
je 0x42190
pushq $0x8
popq %rbp
xorl %ebx, %ebx
movslq 0x28(%r15), %rax
cmpq %rax, %rbx
jge 0x42190
movq 0x30(%r15), %r13
movq -0x8(%r13,%rbp), %r12
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x409e2
cmpl (%r14), %eax
je 0x42184
movq 0x20(%r14), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x42184
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x42184
movq (%r13,%rbp), %r13
cmpq %r13, %rax
je 0x42184
movq %rax, 0x10(%rsp)
movq (%r14), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x46c0
testl %eax, %eax
jne 0x4219f
pushq $0x3
popq %rdi
leaq 0x3b494(%rip), %rsi     # 0x7d5e6
leaq 0x3b49f(%rip), %rdx     # 0x7d5f8
movq %r15, %rcx
movq %r13, %r8
movq 0x10(%rsp), %r9
xorl %eax, %eax
callq 0x110c6
movq 0x10(%r14), %rax
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x38(%rcx), %r15
movq 0x30(%r15), %rcx
movq %rax, (%rcx,%rbp)
incq %rbx
addq $0x18, %rbp
jmp 0x420dc
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b3e9(%rip), %rdi     # 0x7d58f
leaq 0x3aa8d(%rip), %rsi     # 0x7cc3a
leaq 0x3b410(%rip), %rcx     # 0x7d5c4
movl $0xa98, %edx            # imm = 0xA98
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: refs_create
static refs_t *refs_create(void) {
    refs_t *r = calloc(1, sizeof(*r));

    RP("refs_create()\n");

    if (!r)
        return NULL;

    if (!(r->pool = string_pool_create(8192)))
        goto err;

    r->ref_id = NULL; // see refs2id() to populate.
    r->count = 1;
    r->last = NULL;
    r->last_id = -1;

    if (!(r->h_meta = kh_init(refs)))
        goto err;

    pthread_mutex_init(&r->lock, NULL);

    return r;

 err:
    refs_free(r);
    return NULL;
}

// Assembly:
pushq %rbx
pushq $0x1
popq %rdi
pushq $0x70
popq %rsi
callq 0x4300
testq %rax, %rax
je 0x4221b
movq %rax, %rbx
movl $0x2000, %edi           # imm = 0x2000
callq 0x4925c
movq %rax, (%rbx)
testq %rax, %rax
je 0x42213
movl $0x1, 0x30(%rbx)
orl $-0x1, 0x68(%rbx)
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x4300
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x42213
movq %rbx, %rdi
addq $0x38, %rdi
xorl %esi, %esi
callq 0x4780
jmp 0x4221d
movq %rbx, %rdi
callq 0x407fe
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_new_container
cram_container *cram_new_container(int nrec, int nslice) {
    cram_container *c = calloc(1, sizeof(*c));
    enum cram_DS_ID id;

    if (!c)
        return NULL;

    c->curr_ref = -2;

    c->max_c_rec = nrec * nslice;
    c->curr_c_rec = 0;

    c->max_rec = nrec;
    c->record_counter = 0;
    c->num_bases = 0;
    c->s_num_bases = 0;

    c->max_slice = nslice;
    c->curr_slice = 0;

    c->pos_sorted = 1;
    c->max_apos   = 0;
    c->multi_seq  = 0;
    c->qs_seq_orient = 1;
    c->no_ref = 0;
    c->embed_ref = -1; // automatic selection

    c->bams = NULL;

    if (!(c->slices = calloc(nslice != 0 ? nslice : 1, sizeof(cram_slice *))))
        goto err;
    c->slice = NULL;

    if (!(c->comp_hdr = cram_new_compression_header()))
        goto err;
    c->comp_hdr_block = NULL;

    for (id = DS_RN; id < DS_TN; id++)
        if (!(c->stats[id] = cram_stats_create())) goto err;

    //c->aux_B_stats = cram_stats_create();

    if (!(c->tags_used = kh_init(m_tagmap)))
        goto err;
    c->refs_used = 0;
    c->ref_free = 0;

    return c;

 err:
    if (c) {
        if (c->slices)
            free(c->slices);
        free(c);
    }
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %r14d
pushq $0x1
popq %rdi
movl $0x2a0, %esi            # imm = 0x2A0
callq 0x4300
testq %rax, %rax
je 0x422f6
movq %rax, %rbx
movl $0xfffffffe, 0x78(%rax) # imm = 0xFFFFFFFE
movl %ebp, %eax
imull %r14d, %eax
movl %eax, 0x6c(%rbx)
movl %r14d, 0x64(%rbx)
movl %ebp, 0x58(%rbx)
pushq $0x1
popq %rax
movl %eax, 0x98(%rbx)
movl %eax, 0xb4(%rbx)
orl $-0x1, 0xe8(%rbx)
cmpl %eax, %ebp
adcl $0x0, %ebp
movslq %ebp, %rdi
pushq $0x8
popq %rsi
callq 0x4300
movq %rax, %r14
movq %rax, 0x88(%rbx)
testq %rax, %rax
je 0x422e6
callq 0x42306
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x422e6
pushq $0x2a
popq %r15
cmpq $0x46, %r15
je 0x422be
callq 0x4755c
movq %rax, (%rbx,%r15,8)
incq %r15
testq %rax, %rax
jne 0x422a5
jmp 0x422e6
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x4300
movq %rax, 0x270(%rbx)
testq %rax, %rax
je 0x422e6
andq $0x0, 0x278(%rbx)
andl $0x0, 0x29c(%rbx)
jmp 0x422f8
movq %r14, %rdi
callq 0x45c0
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_new_compression_header
cram_block_compression_hdr *cram_new_compression_header(void) {
    cram_block_compression_hdr *hdr = calloc(1, sizeof(*hdr));
    if (!hdr)
        return NULL;

    if (!(hdr->TD_blk = cram_new_block(CORE, 0))) {
        free(hdr);
        return NULL;
    }

    if (!(hdr->TD_hash = kh_init(m_s2i))) {
        cram_free_block(hdr->TD_blk);
        free(hdr);
        return NULL;
    }

    if (!(hdr->TD_keys = string_pool_create(8192))) {
        kh_destroy(m_s2i, hdr->TD_hash);
        cram_free_block(hdr->TD_blk);
        free(hdr);
        return NULL;
    }

    return hdr;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
pushq $0x1
popq %rdi
movl $0x418, %esi            # imm = 0x418
callq 0x4300
testq %rax, %rax
je 0x42372
movq %rax, %rbx
pushq $0x5
popq %rdi
xorl %esi, %esi
callq 0x3f426
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x4236a
movq %rax, %r14
callq 0x43594
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x42362
movq %rax, %r15
movl $0x2000, %edi           # imm = 0x2000
callq 0x4925c
movq %rax, 0x70(%rbx)
testq %rax, %rax
jne 0x42374
movq %r15, %rdi
callq 0x4359f
movq %r14, %rdi
callq 0x3f8fc
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_free_compression_header
void cram_free_compression_header(cram_block_compression_hdr *hdr) {
    int i;

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

    if (hdr->preservation_map)
        kh_destroy(map, hdr->preservation_map);

    for (i = 0; i < CRAM_MAP_HASH; i++) {
        cram_map *m, *m2;
        for (m = hdr->rec_encoding_map[i]; m; m = m2) {
            m2 = m->next;
            if (m->codec)
                m->codec->free(m->codec);
            free(m);
        }
    }

    for (i = 0; i < CRAM_MAP_HASH; i++) {
        cram_map *m, *m2;
        for (m = hdr->tag_encoding_map[i]; m; m = m2) {
            m2 = m->next;
            if (m->codec)
                m->codec->free(m->codec);
            free(m);
        }
    }

    for (i = 0; i < DS_END; i++) {
        if (hdr->codecs[i])
            hdr->codecs[i]->free(hdr->codecs[i]);
    }

    if (hdr->TL)
        free(hdr->TL);
    if (hdr->TD_blk)
        cram_free_block(hdr->TD_blk);
    if (hdr->TD_hash)
        kh_destroy(m_s2i, hdr->TD_hash);
    if (hdr->TD_keys)
        string_pool_destroy(hdr->TD_keys);

    free(hdr);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x45c0
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x42540
callq 0x435cd
xorl %r15d, %r15d
cmpq $0x20, %r15
je 0x42578
movq 0x80(%rbx,%r15,8), %r14
testq %r14, %r14
je 0x42573
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r12
testq %rdi, %rdi
je 0x42566
callq *0x20(%rdi)
movq %r14, %rdi
callq 0x45c0
movq %r12, %r14
jmp 0x42551
incq %r15
jmp 0x42543
xorl %r15d, %r15d
cmpq $0x20, %r15
je 0x425b0
movq 0x180(%rbx,%r15,8), %r14
testq %r14, %r14
je 0x425ab
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r12
testq %rdi, %rdi
je 0x4259e
callq *0x20(%rdi)
movq %r14, %rdi
callq 0x45c0
movq %r12, %r14
jmp 0x42589
incq %r15
jmp 0x4257b
pushq $0x50
popq %r14
cmpq $0x7f, %r14
je 0x425cb
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x425c6
callq *0x20(%rdi)
incq %r14
jmp 0x425b4
movq 0x60(%rbx), %rdi
callq 0x45c0
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x425e2
callq 0x3f8fc
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x425f0
callq 0x4359f
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x425fe
callq 0x4928e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x45c0
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: free_bam_list
static void free_bam_list(bam_seq_t **bams, int max_rec) {
    int i;
    for (i = 0; i < max_rec; i++)
        bam_free(bams[i]);

    free(bams);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
xorl %r15d, %r15d
testl %esi, %esi
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0x427a6
movq (%rbx,%r15,8), %rdi
callq 0x1df92
incq %r15
jmp 0x42793
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x45c0
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_flush_container2
static int cram_flush_container2(cram_fd *fd, cram_container *c) {
    int i, j;

    if (c->curr_slice > 0 && !c->slices)
        return -1;

    //fprintf(stderr, "Writing container %d, sum %u\n", c->record_counter, sum);

    off_t c_offset = htell(fd->fp); // File offset of container

    /* Write the container struct itself */
    if (0 != cram_write_container(fd, c))
        return -1;

    off_t hdr_size = htell(fd->fp) - c_offset;

    /* And the compression header */
    if (0 != cram_write_block(fd, c->comp_hdr_block))
        return -1;

    /* Followed by the slice blocks */
    off_t file_offset = htell(fd->fp);
    for (i = 0; i < c->curr_slice; i++) {
        cram_slice *s = c->slices[i];
        off_t spos = file_offset - c_offset - hdr_size;

        if (0 != cram_write_block(fd, s->hdr_block))
            return -1;

        for (j = 0; j < s->hdr->num_blocks; j++) {
            if (0 != cram_write_block(fd, s->block[j]))
                return -1;
        }

        file_offset = htell(fd->fp);
        off_t sz = file_offset - c_offset - hdr_size - spos;

        if (fd->idxfp) {
            if (cram_index_slice(fd, c, s, fd->idxfp, c_offset, spos, sz) < 0)
                return -1;
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %r15
cmpl $0x0, 0x5c(%rsi)
pushq $-0x1
popq %rbx
jle 0x430d3
cmpq $0x0, 0x88(%r14)
je 0x4310e
movq (%r15), %rax
movq 0x28(%rax), %r12
addq 0x8(%rax), %r12
subq (%rax), %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x42e04
testl %eax, %eax
jne 0x4310e
movq (%r15), %rax
movq (%rax), %rbp
movq 0x28(%rax), %r13
addq 0x8(%rax), %r13
movq 0x50(%r14), %rsi
movq %r15, %rdi
callq 0x3f6bc
testl %eax, %eax
je 0x4311f
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rax
movq 0x28(%rax), %rcx
addq 0x8(%rax), %rcx
subq %r13, %rbp
subq (%rax), %rcx
movq %rcx, 0x8(%rsp)
xorl %ecx, %ecx
movq %rbp, 0x10(%rsp)
movslq 0x5c(%r14), %rax
cmpq %rax, %rcx
jge 0x431fc
movq 0x88(%r14), %rax
movq %rcx, 0x20(%rsp)
movq (%rax,%rcx,8), %r13
movq 0x8(%r13), %rsi
movq %r15, %rdi
callq 0x3f6bc
testl %eax, %eax
jne 0x4310e
movq 0x8(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
movq (%r13), %rax
movslq 0x28(%rax), %rax
cmpq %rax, %rbp
jge 0x431a1
movq 0x10(%r13), %rax
movq (%rax,%rbp,8), %rsi
movq %r15, %rdi
callq 0x3f6bc
incq %rbp
testl %eax, %eax
je 0x43178
jmp 0x4310e
movq (%r15), %rax
movq 0x28(%rax), %rbp
addq 0x8(%rax), %rbp
subq (%rax), %rbp
movq 0x8988(%r15), %rcx
testq %rcx, %rcx
je 0x431e5
movq %rbp, %rax
subq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %r8
movq 0x18(%rsp), %r9
callq 0x3d9b4
testl %eax, %eax
js 0x4310e
movq 0x20(%rsp), %rcx
incq %rcx
movq %rbp, 0x8(%rsp)
movq 0x10(%rsp), %rbp
jmp 0x4313c
xorl %ebx, %ebx
jmp 0x4310e
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_flush_thread
void *cram_flush_thread(void *arg) {
    cram_job *j = (cram_job *)arg;

    /* Encode the container blocks and generate compression header */
    if (0 != cram_encode_container(j->fd, j->c)) {
        hts_log_error("Call to cram_encode_container failed");
        return NULL;
    }

    return arg;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x8(%rbx), %rsi
callq 0x34f17
testl %eax, %eax
je 0x43231
leaq 0x39d6b(%rip), %rsi     # 0x7cf89
leaq 0x39d76(%rip), %rdx     # 0x7cf9b
xorl %ebx, %ebx
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: reset_metrics
void reset_metrics(cram_fd *fd) {
    int i;

    if (fd->pool) {
        // If multi-threaded we have multiple blocks being
        // compressed already and several on the to-do list
        // (fd->rqueue->pending).  It's tricky to reset the
        // metrics exactly the correct point, so instead we
        // just flush the pool, reset, and then continue again.

        // Don't bother starting a new trial before then though.
        for (i = 0; i < DS_END; i++) {
            cram_metrics *m = fd->m[i];
            if (!m)
                continue;
            m->next_trial = 999;
        }

        pthread_mutex_unlock(&fd->metrics_lock);
        hts_tpool_process_flush(fd->rqueue);
        pthread_mutex_lock(&fd->metrics_lock);
    }

    for (i = 0; i < DS_END; i++) {
        cram_metrics *m = fd->m[i];
        if (!m)
            continue;

        m->trial = NTRIALS;
        m->next_trial = TRIAL_SPAN;
        m->revised_method = 0;
        m->unpackable = 0;

        memset(m->sz, 0, sizeof(m->sz));
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x88b8(%rdi)
je 0x4328b
xorl %eax, %eax
cmpq $0x2f, %rax
je 0x43268
movq 0x90(%rbx,%rax,8), %rcx
testq %rcx, %rcx
je 0x43263
movl $0x3e7, 0x4(%rcx)       # imm = 0x3E7
incq %rax
jmp 0x43249
leaq 0x88c8(%rbx), %r14
movq %r14, %rdi
callq 0x4340
movq 0x88c0(%rbx), %rdi
callq 0x2cb1f
movq %r14, %rdi
callq 0x4750
xorl %eax, %eax
movabsq $0x4600000003, %rcx     # imm = 0x4600000003
xorps %xmm0, %xmm0
cmpq $0x2f, %rax
je 0x432e3
movq 0x90(%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x432de
movq %rcx, (%rdx)
andl $0x0, 0x98(%rdx)
andl $0x0, 0x220(%rdx)
movups %xmm0, 0xc(%rdx)
movups %xmm0, 0x1c(%rdx)
movups %xmm0, 0x2c(%rdx)
movups %xmm0, 0x3c(%rdx)
movups %xmm0, 0x4c(%rdx)
movups %xmm0, 0x5c(%rdx)
movups %xmm0, 0x6c(%rdx)
movups %xmm0, 0x7c(%rdx)
incq %rax
jmp 0x4329a
addq $0x8, %rsp
popq %rbx
popq %r14
retq