LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_init
hts_idx_t *hts_idx_init(int n, int fmt, uint64_t offset0, int min_shift, int n_lvls)
{
    hts_idx_t *idx;
    idx = (hts_idx_t*)calloc(1, sizeof(hts_idx_t));
    if (idx == NULL) return NULL;
    idx->fmt = fmt;
    idx->min_shift = min_shift;
    idx->n_lvls = n_lvls;
    idx->n_bins = ((1<<(3 * n_lvls + 3)) - 1) / 7;
    idx->z.save_bin = idx->z.save_tid = idx->z.last_tid = idx->z.last_bin = 0xffffffffu;
    idx->z.save_off = idx->z.last_off = idx->z.off_beg = idx->z.off_end = offset0;
    idx->z.last_coor = 0xffffffffu;
    if (n) {
        idx->n = idx->m = n;
        idx->bidx = (bidx_t**)calloc(n, sizeof(bidx_t*));
        if (idx->bidx == NULL) { free(idx); return NULL; }
        idx->lidx = (lidx_t*) calloc(n, sizeof(lidx_t));
        if (idx->lidx == NULL) { free(idx->bidx); free(idx); return NULL; }
    }
    return idx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r15d
movl %ecx, %r12d
movq %rdx, %r14
movl %esi, %r13d
movl %edi, %ebp
pushq $0x1
popq %rdi
movl $0x88, %esi
callq 0x4370
testq %rax, %rax
je 0xe20d
movq %rax, %rbx
movl %r13d, (%rax)
leal (%r15,%r15,2), %ecx
addb $0x3, %cl
pushq $-0x1
popq %rax
shll %cl, %eax
movl %r12d, 0x4(%rbx)
movl %r15d, 0x8(%rbx)
notl %eax
pushq $0x7
popq %rcx
xorl %edx, %edx
divl %ecx
movl %eax, 0xc(%rbx)
orl $-0x1, 0x50(%rbx)
movq %r14, 0x70(%rbx)
movq %r14, 0x68(%rbx)
movq %r14, 0x58(%rbx)
movq %r14, 0x60(%rbx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x40(%rbx)
testl %ebp, %ebp
je 0xe20f
movl %ebp, 0x18(%rbx)
movl %ebp, 0x14(%rbx)
movslq %ebp, %r15
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x4370
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0xe205
movq %rax, %r14
pushq $0x10
popq %rsi
movq %r15, %rdi
callq 0x4370
movq %rax, 0x30(%rbx)
testq %rax, %rax
jne 0xe20f
movq %r14, %rdi
callq 0x4600
movq %rbx, %rdi
callq 0x4600
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_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: insert_to_b
static inline void insert_to_b(bidx_t *b, int bin, uint64_t beg, uint64_t end)
{
    khint_t k;
    bins_t *l;
    int absent;
    k = kh_put(bin, b, bin, &absent);
    l = &kh_value(b, k);
    if (absent) {
        l->m = 1; l->n = 0;
        l->list = (hts_pair64_t*)calloc(l->m, sizeof(hts_pair64_t));
    }
    if (l->n == l->m) {
        l->m <<= 1;
        l->list = (hts_pair64_t*)realloc(l->list, l->m * sizeof(hts_pair64_t));
    }
    l->list[l->n].u = beg;
    l->list[l->n++].v = end;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
leaq 0xc(%rsp), %r12
movq %r12, %rdx
callq 0x104a1
movl %eax, %eax
imulq $0x18, %rax, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0xe6a9
movq $0x1, (%r13)
leaq 0x4(%r13), %r15
pushq $0x1
popq %rdi
pushq $0x10
popq %rsi
callq 0x4370
movq %rax, 0x10(%r13)
xorl %ecx, %ecx
jmp 0xe6d9
leaq 0x4(%r13), %r15
movl (%r13), %eax
movl 0x4(%r13), %ecx
cmpl %eax, %ecx
jne 0xe6d9
addl %eax, %eax
movl %eax, (%r13)
movq 0x10(%r13), %rdi
movslq %eax, %rsi
shlq $0x4, %rsi
callq 0x48c0
movq %rax, 0x10(%r13)
movl 0x4(%r13), %ecx
jmp 0xe6dd
movq 0x10(%r13), %rax
movslq %ecx, %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movq %r14, (%rax,%rdx)
incl %ecx
movl %ecx, (%r15)
movq %rbx, 0x8(%rax,%rdx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_destroy
void hts_idx_destroy(hts_idx_t *idx)
{
    khint_t k;
    int i;
    if (idx == 0) return;

    // For HTS_FMT_CRAI, idx actually points to a different type -- see sam.c
    if (idx->fmt == HTS_FMT_CRAI) {
        hts_cram_idx_t *cidx = (hts_cram_idx_t *) idx;
        cram_index_free(cidx->cram);
        free(cidx);
        return;
    }

    for (i = 0; i < idx->m; ++i) {
        bidx_t *bidx = idx->bidx[i];
        free(idx->lidx[i].offset);
        if (bidx == 0) continue;
        for (k = kh_begin(bidx); k != kh_end(bidx); ++k)
            if (kh_exist(bidx, k))
                free(kh_value(bidx, k).list);
        kh_destroy(bin, bidx);
    }
    free(idx->bidx); free(idx->lidx); free(idx->meta);
    free(idx);
}

// Assembly:
testq %rdi, %rdi
je 0xecbd
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
cmpl $0x3, (%rdi)
jne 0xecbe
movq 0x8(%rbx), %rdi
callq 0x25f65
jmp 0xed71
retq
xorl %r15d, %r15d
movslq 0x18(%rbx), %rax
movq 0x28(%rbx), %rdi
cmpq %rax, %r15
jge 0xed5a
movq (%rdi,%r15,8), %r14
movq 0x30(%rbx), %rax
movq %r15, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rdi
callq 0x4600
testq %r14, %r14
je 0xed52
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpl (%r14), %r12d
je 0xed2f
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 0xed27
movq 0x20(%r14), %rax
movl %r12d, %ecx
imulq $0x18, %rcx, %rcx
movq 0x10(%rax,%rcx), %rdi
callq 0x4600
incl %r12d
addl $0x2, %ebp
jmp 0xecf5
movq 0x18(%r14), %rdi
callq 0x4600
movq 0x10(%r14), %rdi
callq 0x4600
movq 0x20(%r14), %rdi
callq 0x4600
movq %r14, %rdi
callq 0x4600
incq %r15
jmp 0xecc1
callq 0x4600
movq 0x30(%rbx), %rdi
callq 0x4600
movq 0x38(%rbx), %rdi
callq 0x4600
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4600
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_save
int hts_idx_save(const hts_idx_t *idx, const char *fn, int fmt)
{
    int ret, save;
    char *fnidx = (char*)calloc(1, strlen(fn) + 5);
    if (fnidx == NULL) return -1;

    strcpy(fnidx, fn);
    switch (fmt) {
    case HTS_FMT_BAI: strcat(fnidx, ".bai"); break;
    case HTS_FMT_CSI: strcat(fnidx, ".csi"); break;
    case HTS_FMT_TBI: strcat(fnidx, ".tbi"); break;
    default: abort();
    }

    ret = hts_idx_save_as(idx, fn, fnidx, fmt);
    save = errno;
    free(fnidx);
    errno = save;
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r12
movq %rsi, %rdi
callq 0x4210
leaq 0x5(%rax), %rsi
pushq $0x1
popq %rdi
callq 0x4370
testq %rax, %rax
je 0xedd8
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x44e0
testl %ebx, %ebx
je 0xedef
cmpl $0x2, %ebx
je 0xeddd
cmpl $0x1, %ebx
jne 0xee37
movq %r15, %rdi
callq 0x4210
movl $0x6961622e, (%r15,%rax) # imm = 0x6961622E
jmp 0xedff
pushq $-0x1
popq %rax
jmp 0xee2e
movq %r15, %rdi
callq 0x4210
movl $0x6962742e, (%r15,%rax) # imm = 0x6962742E
jmp 0xedff
movq %r15, %rdi
callq 0x4210
movl $0x6973632e, (%r15,%rax) # imm = 0x6973632E
movb $0x0, 0x4(%r15,%rax)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebx, %ecx
callq 0xee3c
movl %eax, %ebx
callq 0x4060
movq %rax, %r14
movl (%rax), %ebp
movq %r15, %rdi
callq 0x4600
movl %ebp, (%r14)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x42f0
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_set_meta
void hts_idx_set_meta(hts_idx_t *idx, int l_meta, uint8_t *meta, int is_copy)
{
    if (idx->meta) free(idx->meta);
    idx->l_meta = l_meta;
    if (is_copy) {
        idx->meta = (uint8_t*)malloc(l_meta);
        memcpy(idx->meta, meta, l_meta);
    } else idx->meta = meta;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r15d
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq 0x38(%rdi), %rdi
callq 0x4600
movl %ebp, 0x10(%r14)
testl %r15d, %r15d
je 0xf1cf
movslq %ebp, %r15
movq %r15, %rdi
callq 0x46f0
movq %rax, 0x38(%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4420
movq %rbx, 0x38(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_seqnames
const char **hts_idx_seqnames(const hts_idx_t *idx, int *n, hts_id2name_f getid, void *hdr)
{
    if ( !idx->n )
    {
        *n = 0;
        return NULL;
    }

    int tid = 0, i;
    const char **names = (const char**) calloc(idx->n,sizeof(const char*));
    for (i=0; i<idx->n; i++)
    {
        bidx_t *bidx = idx->bidx[i];
        if ( !bidx ) continue;
        names[tid++] = getid(hdr,i);
    }
    *n = tid;
    return names;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, 0x10(%rsp)
movslq 0x14(%rdi), %rbx
testq %rbx, %rbx
je 0xf25c
movq %rdx, %r15
movq %rdi, %r12
movq %rsi, 0x8(%rsp)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x4370
movq %rax, %r13
xorl %ebp, %ebp
xorl %r14d, %r14d
movslq %ebx, %rax
cmpq %rax, %rbp
jge 0xf255
movq 0x28(%r12), %rax
cmpq $0x0, (%rax,%rbp,8)
je 0xf250
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq *%r15
movslq %r14d, %rcx
incl %r14d
movq %rax, (%r13,%rcx,8)
movl 0x14(%r12), %ebx
incq %rbp
jmp 0xf222
movq 0x8(%rsp), %rsi
jmp 0xf262
xorl %r14d, %r14d
xorl %r13d, %r13d
movl %r14d, (%rsi)
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_get_stat
int hts_idx_get_stat(const hts_idx_t* idx, int tid, uint64_t* mapped, uint64_t* unmapped)
{
    if ( idx->fmt == HTS_FMT_CRAI ) {
        *mapped = 0; *unmapped = 0;
        return -1;
    }

    bidx_t *h = idx->bidx[tid];
    khint_t k = kh_get(bin, h, META_BIN(idx));
    if (k != kh_end(h)) {
        *mapped = kh_val(h, k).list[1].u;
        *unmapped = kh_val(h, k).list[1].v;
        return 0;
    } else {
        *mapped = 0; *unmapped = 0;
        return -1;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
cmpl $0x3, (%rdi)
je 0xf2a4
movq 0x28(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %r15
movl 0xc(%rdi), %esi
incl %esi
movq %r15, %rdi
callq 0xf2d4
cmpl (%r15), %eax
jne 0xf2af
andq $0x0, (%r14)
pushq $-0x1
popq %rax
xorl %ecx, %ecx
jmp 0xf2cb
movq 0x20(%r15), %rcx
movl %eax, %eax
imulq $0x18, %rax, %rax
movq 0x10(%rcx,%rax), %rax
movq 0x10(%rax), %rcx
movq %rcx, (%r14)
movq 0x18(%rax), %rcx
xorl %eax, %eax
movq %rcx, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_parse_reg
const char *hts_parse_reg(const char *s, int *beg, int *end)
{
    char *hyphen;
    const char *colon = strrchr(s, ':');
    if (colon == NULL) {
        *beg = 0; *end = INT_MAX;
        return s + strlen(s);
    }

    *beg = hts_parse_decimal(colon+1, &hyphen, HTS_PARSE_THOUSANDS_SEP) - 1;
    if (*beg < 0) *beg = 0;

    if (*hyphen == '\0') *end = INT_MAX;
    else if (*hyphen == '-') *end = hts_parse_decimal(hyphen+1, NULL, HTS_PARSE_THOUSANDS_SEP);
    else return NULL;

    if (*beg >= *end) return NULL;
    return colon;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
pushq $0x3a
popq %rsi
callq 0x45a0
testq %rax, %rax
je 0xfb46
movq %rax, %r15
leaq 0x1(%rax), %rdi
movq %rsp, %r12
pushq $0x1
popq %rdx
movq %r12, %rsi
callq 0xf88b
movq %rax, %rcx
decl %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movl %ecx, (%rbx)
movq (%r12), %rdi
movzbl (%rdi), %ecx
testl %ecx, %ecx
je 0xfb5d
cmpl $0x2d, %ecx
jne 0xfb6d
incq %rdi
pushq $0x1
popq %rdx
xorl %esi, %esi
callq 0xf88b
movq %rax, %rcx
jmp 0xfb62
andl $0x0, (%rbx)
movl $0x7fffffff, (%r14)     # imm = 0x7FFFFFFF
movq %r12, %rdi
callq 0x4210
addq %r12, %rax
jmp 0xfb6d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, (%r14)
xorl %eax, %eax
cmpl %ecx, (%rbx)
cmovlq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_itr_querys
hts_itr_t *hts_itr_querys(const hts_idx_t *idx, const char *reg, hts_name2id_f getid, void *hdr, hts_itr_query_func *itr_query, hts_readrec_func *readrec)
{
    int tid, beg, end;
    const char *q;

    if (strcmp(reg, ".") == 0)
        return itr_query(idx, HTS_IDX_START, 0, 0, readrec);
    else if (strcmp(reg, "*") == 0)
        return itr_query(idx, HTS_IDX_NOCOOR, 0, 0, readrec);

    q = hts_parse_reg(reg, &beg, &end);
    if (q) {
        char *tmp = (char*)alloca(q - reg + 1);
        strncpy(tmp, reg, q - reg);
        tmp[q - reg] = 0;
        tid = getid(hdr, tmp);
    }
    else {
        // not parsable as a region, but possibly a sequence named "foo:a"
        tid = getid(hdr, reg);
        beg = 0; end = INT_MAX;
    }

    if (tid < 0) return NULL;
    return itr_query(idx, tid, beg, end, readrec);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r14
movq %r8, %r9
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r15
movzbl (%rsi), %eax
cmpl $0x2a, %eax
je 0xfbb4
cmpl $0x2e, %eax
jne 0xfbbf
cmpb $0x0, 0x1(%r13)
jne 0xfbbf
pushq $-0x3
jmp 0xfc65
cmpb $0x0, 0x1(%r13)
je 0xfc63
movq %rcx, -0x38(%rbp)
movq %r9, -0x48(%rbp)
leaq -0x30(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %r13, %rdi
callq 0xfae3
testq %rax, %rax
je 0xfc22
movq %rax, %rbx
subq %r13, %rbx
leaq 0x10(%rbx), %rax
andq $-0x10, %rax
movq %r12, -0x40(%rbp)
movq %r15, %r12
movq %r14, %r15
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x42c0
movb $0x0, (%rbx,%r14)
movq -0x38(%rbp), %rdi
movq %r14, %rsi
movq %r15, %r14
movq %r12, %r15
callq *-0x40(%rbp)
jmp 0xfc37
movq -0x38(%rbp), %rdi
movq %r13, %rsi
callq *%r12
andl $0x0, -0x30(%rbp)
movl $0x7fffffff, -0x2c(%rbp) # imm = 0x7FFFFFFF
testl %eax, %eax
movq -0x48(%rbp), %r9
js 0xfc52
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
movq %r15, %rdi
movl %eax, %esi
movq %r14, %r8
callq *%r9
jmp 0xfc54
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x2
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%r9
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_getfn
char *hts_idx_getfn(const char *fn, const char *ext)
{
    int i, l_fn, l_ext;
    char *fnidx, *ret;
    l_fn = strlen(fn); l_ext = strlen(ext);
    fnidx = (char*)calloc(l_fn + l_ext + 1, 1);
    strcpy(fnidx, fn); strcpy(fnidx + l_fn, ext);
    if ((ret = test_and_fetch(fnidx)) == 0) {
        for (i = l_fn - 1; i > 0; --i)
            if (fnidx[i] == '.') break;
        strcpy(fnidx + i, ext);
        ret = test_and_fetch(fnidx);
    }
    if (ret == 0) {
        free(fnidx);
        return 0;
    }
    l_fn = strlen(ret);
    memmove(fnidx, ret, l_fn + 1);
    return fnidx;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r12
callq 0x4210
movq %rax, %r15
movq %r14, %rdi
callq 0x4210
addl %r15d, %eax
incl %eax
movslq %eax, %rdi
pushq $0x1
popq %rsi
callq 0x4370
movq %rax, %rbx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movslq %r15d, %rdi
addq %rbx, %rdi
movq %r14, %rsi
callq 0x44e0
movq %rbx, %rdi
callq 0xff06
testq %rax, %rax
jne 0xfeb7
movl %r15d, %eax
decl %r15d
movslq %r15d, %rdx
movq %rbx, %rcx
addq %rdx, %rcx
movq %rcx, %rdi
cmpl $0x2, %eax
jl 0xfea2
decq %rax
movl %eax, %edx
leaq -0x1(%rdi), %rcx
cmpb $0x2e, (%rbx,%rdx)
jne 0xfe8b
movq %r14, %rsi
callq 0x44e0
movq %rbx, %rdi
callq 0xff06
testq %rax, %rax
je 0xfef0
movq %rax, %r12
movabsq $0x100000000, %r14      # imm = 0x100000000
movq %rax, %rdi
callq 0x4210
shlq $0x20, %rax
addq %rax, %r14
sarq $0x20, %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x48b0
movq %rbx, %rdi
callq 0x4600
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_load
hts_idx_t *hts_idx_load(const char *fn, int fmt)
{
    char *fnidx;
    hts_idx_t *idx;
    fnidx = hts_idx_getfn(fn, ".csi");
    if (! fnidx) fnidx = hts_idx_getfn(fn, fmt == HTS_FMT_BAI? ".bai" : ".tbi");
    if (fnidx == 0) return 0;

    idx = hts_idx_load2(fn, fnidx);
    free(fnidx);
    return idx;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x33e92(%rip), %rsi     # 0x43fa9
callq 0xfe25
testq %rax, %rax
jne 0x10143
cmpl $0x1, %ebp
leaq 0x33e79(%rip), %rax     # 0x43fa4
leaq 0x33e7c(%rip), %rsi     # 0x43fae
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0xfe25
testq %rax, %rax
je 0x10164
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x10168
movq %rax, %rbx
movq %r14, %rdi
callq 0x4600
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
jmp 0x1015f
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/./htslib/kstring.h
// Function: ks_resize
static inline int ks_resize(kstring_t *s, size_t size)
{
	if (s->m < size) {
		char *tmp;
		kroundup_size_t(size);
		tmp = (char*)realloc(s->s, size);
		if (!tmp)
			return -1;
		s->s = tmp;
		s->m = size;
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %ebx, %ebx
cmpq %rsi, 0x8(%rdi)
jae 0x10499
movq %rdi, %r14
decq %rsi
movq %rsi, %rax
shrq %rax
orq %rsi, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
movq %rax, %r15
shrq $0x20, %r15
orq %rax, %r15
incq %r15
movq 0x10(%rdi), %rdi
movq %r15, %rsi
callq 0x48c0
testq %rax, %rax
je 0x10496
movq %rax, 0x10(%r14)
movq %r15, 0x8(%r14)
jmp 0x10499
pushq $-0x1
popq %rbx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_hdr_destroy
void bam_hdr_destroy(bam_hdr_t *h)
{
    int32_t i;
    if (h == NULL) return;
    if (h->target_name) {
        for (i = 0; i < h->n_targets; ++i)
            free(h->target_name[i]);
        free(h->target_name);
        free(h->target_len);
    }
    free(h->text); free(h->cigar_tab);
    if (h->sdict) kh_destroy(s2i, (sdict_t*)h->sdict);
    free(h);
}

// Assembly:
testq %rdi, %rdi
je 0x10bb0
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x20(%rdi)
je 0x10b81
xorl %r14d, %r14d
movslq (%rbx), %rax
movq 0x20(%rbx), %rdi
cmpq %rax, %r14
jge 0x10b73
movq (%rdi,%r14,8), %rdi
callq 0x4600
incq %r14
jmp 0x10b59
callq 0x4600
movq 0x10(%rbx), %rdi
callq 0x4600
movq 0x28(%rbx), %rdi
callq 0x4600
movq 0x18(%rbx), %rdi
callq 0x4600
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x10ba1
callq 0xb95c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4600
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_hdr_dup
bam_hdr_t *bam_hdr_dup(const bam_hdr_t *h0)
{
    if (h0 == NULL) return NULL;
    bam_hdr_t *h;
    if ((h = bam_hdr_init()) == NULL) return NULL;
    // copy the simple data
    h->n_targets = h0->n_targets;
    h->ignore_sam_err = h0->ignore_sam_err;
    h->l_text = h0->l_text;
    // Then the pointery stuff
    h->cigar_tab = NULL;
    h->sdict = NULL;
    // TODO Check for memory allocation failures
    h->text = (char*)calloc(h->l_text + 1, 1);
    memcpy(h->text, h0->text, h->l_text);
    h->target_len = (uint32_t*)calloc(h->n_targets, sizeof(uint32_t));
    h->target_name = (char**)calloc(h->n_targets, sizeof(char*));
    int i;
    for (i = 0; i < h->n_targets; ++i) {
        h->target_len[i] = h0->target_len[i];
        h->target_name[i] = strdup(h0->target_name[i]);
    }
    return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x10c67
movq %rdi, %r14
callq 0x10b38
xorl %ebp, %ebp
testq %rax, %rax
je 0x10c67
movq %rax, %rbx
movq (%r14), %r12
movq %r12, (%rax)
movl 0x8(%r14), %r15d
movl %r15d, 0x8(%rax)
andq $0x0, 0x18(%rax)
andq $0x0, 0x30(%rax)
leal 0x1(%r15), %edi
pushq $0x1
popq %rsi
callq 0x4370
movq %rax, 0x28(%rbx)
movq 0x28(%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x4420
movslq %r12d, %r15
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x4370
movq %rax, %r12
movq %rax, 0x10(%rbx)
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x4370
movq %rax, %r13
movq %rax, 0x20(%rbx)
testl %r15d, %r15d
cmovlel %ebp, %r15d
cmpq %rbp, %r15
je 0x10c69
movq 0x10(%r14), %rax
movl (%rax,%rbp,4), %eax
movl %eax, (%r12,%rbp,4)
movq 0x20(%r14), %rax
movq (%rax,%rbp,8), %rdi
callq 0x49a0
movq %rax, (%r13,%rbp,8)
incq %rbp
jmp 0x10c40
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_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_name2id
int bam_name2id(bam_hdr_t *h, const char *ref)
{
    sdict_t *d = (sdict_t*)h->sdict;
    khint_t k;
    if (h->sdict == 0) {
        int i, absent;
        d = kh_init(s2i);
        for (i = 0; i < h->n_targets; ++i) {
            k = kh_put(s2i, d, h->target_name[i], &absent);
            kh_val(d, k) = i;
        }
        h->sdict = d;
    }
    k = kh_get(s2i, d, ref);
    return k == kh_end(d)? -1 : kh_val(d, k);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq 0x30(%rdi), %r14
testq %r14, %r14
jne 0x111e9
movq %rdi, %r15
xorl %r13d, %r13d
callq 0xb951
movq %rax, %r14
leaq 0xc(%rsp), %r12
movslq (%r15), %rax
cmpq %rax, %r13
jge 0x111e5
movq 0x20(%r15), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0xbd19
movq 0x20(%r14), %rcx
movl %eax, %eax
movq %r13, (%rcx,%rax,8)
incq %r13
jmp 0x111bb
movq %r14, 0x30(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb9c0
cmpl (%r14), %eax
jne 0x111fe
pushq $-0x1
popq %rax
jmp 0x11207
movq 0x20(%r14), %rcx
movl %eax, %eax
movl (%rcx,%rax,8), %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_copy1
bam1_t *bam_copy1(bam1_t *bdst, const bam1_t *bsrc)
{
    uint8_t *data = bdst->data;
    int m_data = bdst->m_data;   // backup data and m_data
    if (m_data < bsrc->l_data) { // double the capacity
        m_data = bsrc->l_data; kroundup32(m_data);
        data = (uint8_t*)realloc(data, m_data);
    }
    memcpy(data, bsrc->data, bsrc->l_data); // copy var-len data
    *bdst = *bsrc; // copy the rest
    // restore the backup
    bdst->m_data = m_data;
    bdst->data = data;
    return bdst;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x28(%rdi), %r15
movl 0x24(%rdi), %ebp
movl 0x20(%rsi), %eax
cmpl %eax, %ebp
jge 0x1128f
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ebp
sarl $0x10, %ebp
orl %eax, %ebp
incl %ebp
movslq %ebp, %rsi
movq %r15, %rdi
callq 0x48c0
movq %rax, %r15
movl 0x20(%r14), %eax
movq 0x28(%r14), %rsi
movslq %eax, %rdx
movq %r15, %rdi
callq 0x4420
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rbx)
movups %xmm0, (%rbx)
movups %xmm1, 0x10(%rbx)
movq 0x30(%r14), %rax
movq %rax, 0x30(%rbx)
movl %ebp, 0x24(%rbx)
movq %r15, 0x28(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_dup1
bam1_t *bam_dup1(const bam1_t *bsrc)
{
    if (bsrc == NULL) return NULL;
    bam1_t *bdst = bam_init1();
    if (bdst == NULL) return NULL;
    return bam_copy1(bdst, bsrc);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x112fa
movq %rdi, %r14
callq 0x11215
testq %rax, %rax
je 0x112fa
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1123c
jmp 0x112fc
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_cigar2qlen
int bam_cigar2qlen(int n_cigar, const uint32_t *cigar)
{
    int k, l;
    for (k = l = 0; k < n_cigar; ++k)
        if (bam_cigar_type(bam_cigar_op(cigar[k]))&1)
            l += bam_cigar_oplen(cigar[k]);
    return l;
}

// Assembly:
xorl %ecx, %ecx
testl %edi, %edi
cmovlel %ecx, %edi
movl $0x3c1a7, %edx          # imm = 0x3C1A7
xorl %eax, %eax
cmpq %rcx, %rdi
je 0x11341
movl (%rsi,%rcx,4), %r8d
leal (%r8,%r8), %r9d
btl %r9d, %edx
movl $0x0, %r9d
sbbl %r9d, %r9d
shrl $0x4, %r8d
andl %r9d, %r8d
addl %eax, %r8d
incq %rcx
movl %r8d, %eax
jmp 0x11315
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_cigar2rlen
int bam_cigar2rlen(int n_cigar, const uint32_t *cigar)
{
    int k, l;
    for (k = l = 0; k < n_cigar; ++k)
        if (bam_cigar_type(bam_cigar_op(cigar[k]))&2)
            l += bam_cigar_oplen(cigar[k]);
    return l;
}

// Assembly:
xorl %edx, %edx
testl %edi, %edi
cmovlel %edx, %edi
xorl %eax, %eax
cmpq %rdx, %rdi
je 0x1137b
movl (%rsi,%rdx,4), %r8d
leal (%r8,%r8), %ecx
movl $0x3c1a7, %r9d          # imm = 0x3C1A7
shrl %cl, %r9d
shll $0x1e, %r9d
sarl $0x1f, %r9d
shrl $0x4, %r8d
andl %r9d, %r8d
addl %eax, %r8d
incq %rdx
movl %r8d, %eax
jmp 0x1134b
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_write1
int bam_write1(BGZF *fp, const bam1_t *b)
{
    const bam1_core_t *c = &b->core;
    uint32_t x[8], block_len = b->l_data + 32, y;
    int i, ok;
    x[0] = c->tid;
    x[1] = c->pos;
    x[2] = (uint32_t)c->bin<<16 | c->qual<<8 | c->l_qname;
    x[3] = (uint32_t)c->flag<<16 | c->n_cigar;
    x[4] = c->l_qseq;
    x[5] = c->mtid;
    x[6] = c->mpos;
    x[7] = c->isize;
    ok = (bgzf_flush_try(fp, 4 + block_len) >= 0);
    if (fp->is_be) {
        for (i = 0; i < 8; ++i) ed_swap_4p(x + i);
        y = block_len;
        if (ok) ok = (bgzf_write(fp, ed_swap_4p(&y), 4) >= 0);
        swap_data(c, b->l_data, b->data, 1);
    } else {
        if (ok) ok = (bgzf_write(fp, &block_len, 4) >= 0);
    }
    if (ok) ok = (bgzf_write(fp, x, 32) >= 0);
    if (ok) ok = (bgzf_write(fp, b->data, b->l_data) >= 0);
    if (fp->is_be) swap_data(c, b->l_data, b->data, 0);
    return ok? 4 + block_len : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x20(%rsi), %esi
leal 0x20(%rsi), %ebp
movl %ebp, 0x8(%rsp)
movq (%rbx), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rbx), %rax
movl %eax, %ecx
shll $0x10, %ecx
movl %eax, %edx
shrl $0x8, %edx
andl $0xff00, %edx           # imm = 0xFF00
orl %ecx, %edx
movl %eax, %ecx
shrl $0x18, %ecx
orl %edx, %ecx
movl %ecx, 0x18(%rsp)
movq %rax, %rcx
shrq $0x10, %rcx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
shrq $0x30, %rax
orl %ecx, %eax
movl %eax, 0x1c(%rsp)
movups 0x10(%rbx), %xmm0
movaps %xmm0, 0x20(%rsp)
addl $0x24, %esi
callq 0x37690
testb $0xc, 0x2(%r14)
je 0x117b6
xorl %ecx, %ecx
cmpq $0x8, %rcx
je 0x1178f
movl 0x10(%rsp,%rcx,4), %edx
bswapl %edx
movl %edx, 0x10(%rsp,%rcx,4)
incq %rcx
jmp 0x1177a
movl %ebp, 0xc(%rsp)
testl %eax, %eax
js 0x117d5
bswapl %ebp
leaq 0xc(%rsp), %rsi
movl %ebp, (%rsi)
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x376df
xorl %ebp, %ebp
testq %rax, %rax
setns %bpl
jmp 0x117d7
testl %eax, %eax
js 0x1181e
leaq 0x8(%rsp), %rsi
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x376df
xorl %ebp, %ebp
testq %rax, %rax
setns %bpl
jmp 0x117e9
xorl %ebp, %ebp
movl 0x20(%rbx), %esi
movq 0x28(%rbx), %rdx
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0x11564
movb $0x1, %r15b
testl %ebp, %ebp
je 0x11821
leaq 0x10(%rsp), %rsi
pushq $0x20
popq %rdx
movq %r14, %rdi
callq 0x376df
testq %rax, %rax
js 0x11821
movq 0x28(%rbx), %rsi
movslq 0x20(%rbx), %rdx
movq %r14, %rdi
callq 0x376df
movq %rax, %r15
shrq $0x3f, %r15
jmp 0x11821
movb $0x1, %r15b
testb $0xc, 0x2(%r14)
je 0x11839
movl 0x20(%rbx), %esi
movq 0x28(%rbx), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x11564
movl 0x8(%rsp), %ecx
addl $0x4, %ecx
testb %r15b, %r15b
pushq $-0x1
popq %rax
cmovel %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: sam_index_build2
int sam_index_build2(const char *fn, const char *fnidx, int min_shift)
{
    hts_idx_t *idx;
    htsFile *fp;
    int ret = 0;

    if ((fp = hts_open(fn, "r")) == 0) return -2;
    switch (fp->format.format) {
    case cram:
        ret = cram_index_build(fp->fp.cram, fn, fnidx);
        break;

    case bam:
        idx = bam_index(fp->fp.bgzf, min_shift);
        if (idx) {
            ret = hts_idx_save_as(idx, fn, fnidx, (min_shift > 0)? HTS_FMT_CSI : HTS_FMT_BAI);
            if (ret < 0) ret = -4;
            hts_idx_destroy(idx);
        }
        else ret = -1;
        break;

    default:
        ret = -3;
        break;
    }
    hts_close(fp);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x33044(%rip), %rsi     # 0x448b5
callq 0xca17
testq %rax, %rax
je 0x118a1
movq %rax, %rbx
movl 0x44(%rax), %eax
cmpl $0x4, %eax
je 0x118a9
cmpl $0x6, %eax
jne 0x11905
movq 0x38(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x26190
movl %eax, %ebp
jmp 0x119ca
pushq $-0x2
popq %rbp
jmp 0x119d2
movl %ebp, 0x4(%rsp)
movq 0x38(%rbx), %r13
movq %r13, %rdi
callq 0x10c7b
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x119ca
movq %rax, %r12
movl (%rax), %edi
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
movq %r14, 0x10(%rsp)
movq %r15, 0x8(%rsp)
jle 0x1192d
xorl %r8d, %r8d
testl %edi, %edi
movl $0x0, %edx
cmovgl %edi, %edx
xorl %eax, %eax
cmpq %r8, %rdx
je 0x1190c
movq 0x10(%r12), %rsi
movl (%rsi,%r8,4), %esi
cmpq %rsi, %rax
cmovleq %rsi, %rax
incq %r8
jmp 0x118eb
pushq $-0x3
jmp 0x119c9
pushq $0x1
popq %rdx
shll %cl, %edx
addq $0x100, %rax            # imm = 0x100
movslq %edx, %rdx
xorl %esi, %esi
xorl %r8d, %r8d
cmpq %rdx, %rax
jle 0x11937
incl %r8d
shlq $0x3, %rdx
jmp 0x1191f
pushq $0xe
popq %rcx
pushq $0x5
popq %r8
pushq $0x1
popq %rsi
movq 0x10(%r13), %rax
shlq $0x10, %rax
movzwl 0xc(%r13), %edx
orq %rax, %rdx
callq 0xe153
movq %rax, %r14
movq %r12, %rdi
callq 0x10b43
callq 0x11215
movq %rax, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x113b4
testl %eax, %eax
js 0x119b2
movl (%r12), %ebp
movl 0x4(%r12), %r15d
movq %r12, %rdi
callq 0x1137c
movq 0x10(%r13), %rcx
shlq $0x10, %rcx
movzwl 0xc(%r13), %r8d
orq %rcx, %r8
xorl %r9d, %r9d
btq $0x22, 0x8(%r12)
setae %r9b
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
movl %eax, %ecx
callq 0xe86c
testl %eax, %eax
jns 0x1195f
jmp 0x119b7
cmpl $-0x1, %eax
je 0x119e3
movq %r12, %rdi
callq 0x11220
movq %r14, %rdi
callq 0xec9a
pushq $-0x1
popq %rbp
movq %rbx, %rdi
callq 0xd170
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r13), %rax
shlq $0x10, %rax
movzwl 0xc(%r13), %esi
orq %rax, %rsi
movq %r14, %rdi
callq 0xe221
movq %r12, %rdi
callq 0x11220
testq %r14, %r14
pushq $-0x1
popq %rbp
je 0x119ca
xorl %ecx, %ecx
cmpl $0x0, 0x4(%rsp)
setle %cl
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0xee3c
testl %eax, %eax
pushq $-0x4
popq %rbp
cmovnsl %eax, %ebp
movq %r14, %rdi
callq 0xec9a
jmp 0x119ca
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: sam_index_load2
hts_idx_t *sam_index_load2(htsFile *fp, const char *fn, const char *fnidx)
{
    switch (fp->format.format) {
    case bam:
        return fnidx? hts_idx_load2(fn, fnidx) : hts_idx_load(fn, HTS_FMT_BAI);

    case cram: {
        if (cram_index_load(fp->fp.cram, fn, fnidx) < 0) return NULL;
        // Cons up a fake "index" just pointing at the associated cram_fd:
        hts_cram_idx_t *idx = malloc(sizeof (hts_cram_idx_t));
        if (idx == NULL) return NULL;
        idx->fmt = HTS_FMT_CRAI;
        idx->cram = fp->fp.cram;
        return (hts_idx_t *) idx;
        }

    default:
        return NULL; // TODO Would use tbx_index_load if it returned hts_idx_t
    }
}

// Assembly:
pushq %rbx
movl 0x44(%rdi), %eax
cmpl $0x6, %eax
je 0x11a6a
cmpl $0x4, %eax
jne 0x11a97
testq %rdx, %rdx
je 0x11a9b
movq %rsi, %rdi
movq %rdx, %rsi
popq %rbx
jmp 0x10168
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
callq 0x25870
testl %eax, %eax
js 0x11a97
pushq $0x10
popq %rdi
callq 0x46f0
testq %rax, %rax
je 0x11a97
movl $0x3, (%rax)
movq 0x38(%rbx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x11a99
xorl %eax, %eax
popq %rbx
retq
pushq $0x1
popq %rax
movq %rsi, %rdi
movl %eax, %esi
popq %rbx
jmp 0x10107
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: sam_itr_queryi
hts_itr_t *sam_itr_queryi(const hts_idx_t *idx, int tid, int beg, int end)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;
    if (idx == NULL)
        return hts_itr_query(NULL, tid, beg, end, sam_bam_cram_readrec);
    else if (cidx->fmt == HTS_FMT_CRAI)
        return cram_itr_query(idx, tid, beg, end, cram_readrec);
    else
        return hts_itr_query(idx, tid, beg, end, bam_readrec);
}

// Assembly:
testq %rdi, %rdi
je 0x11ac3
cmpl $0x3, (%rdi)
jne 0x11ad1
leaq 0x139(%rip), %r8        # 0x11bfa
jmp 0x11b27
leaq 0x13(%rip), %r8         # 0x11add
xorl %edi, %edi
jmp 0xf34a
leaq 0x137(%rip), %r8        # 0x11c0f
jmp 0xf34a
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: sam_bam_cram_readrec
static int sam_bam_cram_readrec(BGZF *bgzfp, void *fpv, void *bv, int *tid, int *beg, int *end)
{
    htsFile *fp = fpv;
    bam1_t *b = bv;
    switch (fp->format.format) {
    case bam:   return bam_read1(bgzfp, b);
    case cram:  return cram_get_bam_seq(fp->fp.cram, &b);
    default:
        // TODO Need headers available to implement this for SAM files
        fprintf(stderr, "[sam_bam_cram_readrec] Not implemented for SAM files -- Exiting\n");
        abort();
    }
}

// Assembly:
pushq %rax
movq %rdx, (%rsp)
movl 0x44(%rsi), %eax
cmpl $0x6, %eax
je 0x11af8
cmpl $0x4, %eax
jne 0x11b06
movq %rdx, %rsi
popq %rax
jmp 0x113b4
movq 0x38(%rsi), %rdi
movq %rsp, %rsi
callq 0x1c043
popq %rcx
retq
movq 0x454c3(%rip), %rax     # 0x56fd0
movq (%rax), %rcx
leaq 0x32ccb(%rip), %rdi     # 0x447e2
pushq $0x40
popq %rsi
pushq $0x1
popq %rdx
callq 0x4a20
callq 0x42f0
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: cram_itr_query
static hts_itr_t *cram_itr_query(const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;
    hts_itr_t *iter = (hts_itr_t *) calloc(1, sizeof(hts_itr_t));
    if (iter == NULL) return NULL;

    // Cons up a dummy iterator for which hts_itr_next() will simply invoke
    // the readrec function:
    iter->read_rest = 1;
    iter->off = NULL;
    iter->bins.a = NULL;
    iter->readrec = readrec;

    if (tid >= 0 || tid == HTS_IDX_NOCOOR) {
        cram_range r = { tid == HTS_IDX_NOCOOR ? -1 : tid, beg+1, end };
        int ret = cram_set_option(cidx->cram, CRAM_OPT_RANGE, &r);

        iter->curr_off = 0;
        // The following fields are not required by hts_itr_next(), but are
        // filled in in case user code wants to look at them.
        iter->tid = tid;
        iter->beg = beg;
        iter->end = end;

        switch (ret) {
        case 0:
            break;

        case -2:
            // No data vs this ref, so mark iterator as completed.
            // Same as HTS_IDX_NONE.
            iter->finished = 1;
            break;

        default:
            free(iter);
            return NULL;
        }
    }
    else switch (tid) {
    case HTS_IDX_REST:
        iter->curr_off = 0;
        break;
    case HTS_IDX_NONE:
        iter->curr_off = 0;
        iter->finished = 1;
        break;
    default:
        fprintf(stderr, "[cram_itr_query] tid=%d not implemented for CRAM files -- Exiting\n", tid);
        abort();
        break;
    }

    return iter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r13
movl %ecx, %r14d
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %r12
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0x4370
testq %rax, %rax
je 0x11bb5
movq %rax, %rbx
movl $0x1, (%rax)
movq %r13, 0x38(%rax)
testl %ebp, %ebp
sets %al
cmpl $-0x2, %ebp
setne %cl
testb %cl, %al
jne 0x11bb9
cmpl $-0x2, %ebp
pushq $-0x1
popq %rax
cmovnel %ebp, %eax
leaq 0xc(%rsp), %rdx
movl %eax, (%rdx)
leal 0x1(%r15), %eax
movl %eax, 0x4(%rdx)
movl %r14d, 0x8(%rdx)
movq 0x8(%r12), %rdi
pushq $0x5
popq %rsi
xorl %eax, %eax
callq 0x2dcd2
movl %ebp, 0x4(%rbx)
movl %r15d, 0x8(%rbx)
movl %r14d, 0xc(%rbx)
testl %eax, %eax
je 0x11bc9
cmpl $-0x2, %eax
je 0x11bc3
movq %rbx, %rdi
callq 0x4600
xorl %ebx, %ebx
jmp 0x11bc9
cmpl $-0x4, %ebp
je 0x11bc9
cmpl $-0x5, %ebp
jne 0x11bdb
movl $0x3, (%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x453ee(%rip), %rax     # 0x56fd0
movq (%rax), %rdi
leaq 0x32c37(%rip), %rsi     # 0x44823
movl %ebp, %edx
xorl %eax, %eax
callq 0x4770
callq 0x42f0
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_readrec
static int bam_readrec(BGZF *fp, void *ignored, void *bv, int *tid, int *beg, int *end)
{
    bam1_t *b = bv;
    int ret;
    if ((ret = bam_read1(fp, b)) >= 0) {
        *tid = b->core.tid;
        *beg = b->core.pos;
        *end = bam_endpos(b);
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r9, %rbx
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r14
movq %rdx, %rsi
callq 0x113b4
movl %eax, %ebp
testl %eax, %eax
js 0x11c49
movl (%r14), %eax
movl %eax, (%r12)
movl 0x4(%r14), %eax
movl %eax, (%r15)
movq %r14, %rdi
callq 0x1137c
movl %eax, (%rbx)
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/./htslib/kstring.h
// Function: kputsn
static inline int kputsn(const char *p, int l, kstring_t *s)
{
	if (ks_resize(s, s->l + l + 2) < 0)
		return EOF;
	memcpy(s->s + s->l, p, l);
	s->l += l;
	s->s[s->l] = 0;
	return l;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r15
movq (%rdx), %rdi
movslq %esi, %r14
leaq (%rdi,%r14), %rax
addq $0x2, %rax
cmpq %rax, 0x8(%rdx)
jae 0x25ead
addq %r14, %rdi
incq %rdi
movq %rdi, %rax
shrq %rax
orq %rdi, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
movq %rax, %r12
shrq $0x20, %r12
orq %rax, %r12
incq %r12
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x48c0
testq %rax, %rax
je 0x25ece
movq %rax, 0x10(%rbx)
movq %r12, 0x8(%rbx)
movq (%rbx), %rdi
jmp 0x25eb1
movq 0x10(%rbx), %rax
addq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4420
addq (%rbx), %r14
movq %r14, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/./htslib/hfile.h
// Function: hwrite
static inline ssize_t HTS_RESULT_USED
hwrite(hFILE *fp, const void *buffer, size_t nbytes)
{
    extern ssize_t hwrite2(hFILE *, const void *, size_t, size_t);

    size_t n = fp->limit - fp->begin;
    if (n > nbytes) n = nbytes;
    memcpy(fp->begin, buffer, n);
    fp->begin += n;
    return (n==nbytes)? (ssize_t) n : hwrite2(fp, buffer, nbytes, n);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%rdi), %rdi
movq 0x18(%r15), %r13
subq %rdi, %r13
cmpq %rdx, %r13
movq %rdx, %r12
cmovbq %r13, %r12
movq %r12, %rdx
callq 0x4420
addq %r12, 0x8(%r15)
cmpq %rbx, %r13
jae 0x12403
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3a256
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: sam_read1
int sam_read1(htsFile *fp, bam_hdr_t *h, bam1_t *b)
{
    switch (fp->format.format) {
    case bam: {
        int r = bam_read1(fp->fp.bgzf, b);
        if (r >= 0) {
            if (b->core.tid  >= h->n_targets || b->core.tid  < -1 ||
                b->core.mtid >= h->n_targets || b->core.mtid < -1)
                return -3;
        }
        return r;
        }

    case cram: {
        int ret = cram_get_bam_seq(fp->fp.cram, &b);
        return ret >= 0
            ? ret
            : (cram_eof(fp->fp.cram) ? -1 : -2);
    }

    case sam: {
        int ret;
err_recover:
        if (fp->line.l == 0) {
            ret = hts_getline(fp, KS_SEP_LINE, &fp->line);
            if (ret < 0) return -1;
        }
        ret = sam_parse1(&fp->line, h, b);
        fp->line.l = 0;
        if (ret < 0) {
            if (hts_verbose >= 1)
                fprintf(stderr, "[W::%s] parse error at line %lld\n", __func__, (long long)fp->lineno);
            if (h->ignore_sam_err) goto err_recover;
        }
        return ret;
        }

    default:
        abort();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq %rdx, (%rsp)
movl 0x44(%rdi), %eax
cmpl $0x6, %eax
je 0x133a2
movq %rdx, %rbx
movq %rsi, %r15
cmpl $0x4, %eax
je 0x13363
cmpl $0x3, %eax
jne 0x133dc
leaq 0x10(%r14), %r12
leaq 0x44257(%rip), %r13     # 0x57548
cmpq $0x0, (%r12)
jne 0x1330e
movq %r14, %rdi
pushq $0x2
popq %rsi
movq %r12, %rdx
callq 0xd37f
testl %eax, %eax
js 0x133c8
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x12410
movl %eax, %ebp
andq $0x0, (%r12)
testl %eax, %eax
jns 0x133cb
cmpl $0x0, (%r13)
jg 0x1333e
cmpl $0x0, 0x4(%r15)
jne 0x132f1
jmp 0x133cb
movq 0x43c8b(%rip), %rax     # 0x56fd0
movq (%rax), %rdi
movq 0x8(%r14), %rcx
leaq 0x312c4(%rip), %rsi     # 0x44617
leaq 0x312df(%rip), %rdx     # 0x44639
xorl %eax, %eax
callq 0x4770
jmp 0x13332
movq 0x38(%r14), %rdi
movq %rbx, %rsi
callq 0x113b4
testl %eax, %eax
js 0x1339e
movl (%rbx), %edx
movl (%r15), %ecx
cmpl %ecx, %edx
setge %sil
cmpl $-0x1, %edx
setl %dl
orb %sil, %dl
pushq $-0x3
popq %rbp
jne 0x133cb
movl 0x14(%rbx), %edx
cmpl %ecx, %edx
setge %cl
cmpl $-0x1, %edx
setl %dl
orb %cl, %dl
jne 0x133cb
movl %eax, %ebp
jmp 0x133cb
movq 0x38(%r14), %rdi
movq %rsp, %rsi
callq 0x1c043
movl %eax, %ebp
testl %eax, %eax
jns 0x133cb
movq 0x38(%r14), %rdi
callq 0x2dccb
cmpl $0x1, %eax
pushq $-0x1
popq %rbp
sbbl $0x0, %ebp
jmp 0x133cb
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x42f0
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/./htslib/kstring.h
// Function: kputuw
static inline int kputuw(unsigned c, kstring_t *s)
{
	char buf[16];
	int l, i;
	unsigned x;
	if (c == 0) return kputc('0', s);
	for (l = 0, x = c; x > 0; x /= 10) buf[l++] = x%10 + '0';
	if (ks_resize(s, s->l + l + 2) < 0)
		return EOF;
	for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
	s->s[s->l] = 0;
	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
testl %edi, %edi
je 0x13aa7
movl %edi, %eax
xorl %r14d, %r14d
pushq $0xa
popq %rcx
testl %eax, %eax
je 0x13a61
xorl %edx, %edx
divl %ecx
orb $0x30, %dl
movb %dl, (%rsp,%r14)
incq %r14
jmp 0x13a4d
leal 0x2(%r14), %esi
addq (%rbx), %rsi
movq %rbx, %rdi
callq 0x13205
testl %eax, %eax
js 0x13a9f
testq %r14, %r14
jle 0x13a94
movb -0x1(%rsp,%r14), %al
decq %r14
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movb %al, (%rdx,%rcx)
jmp 0x13a74
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
addq $0x18, %rsp
popq %rbx
popq %r14
retq
pushq $0x30
popq %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x120dc
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: aux_type2size
static inline int aux_type2size(uint8_t type)
{
    switch (type) {
    case 'A': case 'c': case 'C':
        return 1;
    case 's': case 'S':
        return 2;
    case 'i': case 'I': case 'f':
        return 4;
    case 'd':
        return 8;
    case 'Z': case 'H': case 'B':
        return type;
    default:
        return 0;
    }
}

// Assembly:
pushq $0x1
popq %rax
leal -0x41(%rdi), %ecx
cmpl $0x8, %ecx
jbe 0x13ae0
leal -0x63(%rdi), %ecx
cmpl $0x6, %ecx
ja 0x13af1
leaq 0x306fd(%rip), %rdx     # 0x441d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
pushq $0x8
jmp 0x13b06
leaq 0x306c5(%rip), %rdx     # 0x441ac
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
retq
cmpl $0x73, %edi
je 0x13b00
cmpl $0x5a, %edi
je 0x13b08
cmpl $0x53, %edi
jne 0x13b0d
pushq $0x2
jmp 0x13b06
pushq $0x4
popq %rax
retq
movzbl %dil, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: sam_write1
int sam_write1(htsFile *fp, const bam_hdr_t *h, const bam1_t *b)
{
    switch (fp->format.format) {
    case binary_format:
        fp->format.category = sequence_data;
        fp->format.format = bam;
        /* fall-through */
    case bam:
        return bam_write1(fp->fp.bgzf, b);

    case cram:
        return cram_put_bam_seq(fp->fp.cram, (bam1_t *)b);

    case text_format:
        fp->format.category = sequence_data;
        fp->format.format = sam;
        /* fall-through */
    case sam:
        if (sam_format1(h, b, &fp->line) < 0) return -1;
        kputc('\n', &fp->line);
        if ( hwrite(fp->fp.hfile, fp->line.s, fp->line.l) != fp->line.l ) return -1;
        return fp->line.l;

    default:
        abort();
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0x44(%rdi), %eax
decl %eax
cmpl $0x5, %eax
ja 0x13bc3
movq %rdi, %rbx
leaq 0x306c0(%rip), %rcx     # 0x441ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movabsq $0x400000001, %rax      # imm = 0x400000001
movq %rax, 0x40(%rbx)
movq 0x38(%rbx), %rdi
movq %rdx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x11706
movq 0x38(%rbx), %rdi
movq %rdx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x243f7
movabsq $0x300000001, %rax      # imm = 0x300000001
movq %rax, 0x40(%rbx)
leaq 0x10(%rbx), %r14
movq %rsi, %rdi
movq %rdx, %rsi
movq %r14, %rdx
callq 0x133e1
testl %eax, %eax
js 0x13bb8
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0x120dc
movq 0x38(%rbx), %rdi
movq 0x10(%rbx), %rdx
movq 0x20(%rbx), %rsi
callq 0x123b1
movq 0x10(%rbx), %rcx
cmpq %rcx, %rax
pushq $-0x1
popq %rax
cmovel %ecx, %eax
jmp 0x13bbb
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x42f0
// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/sam.c
// Function: bam_aux_append
void bam_aux_append(bam1_t *b, const char tag[2], char type, int len, const uint8_t *data)
{
    int ori_len = b->l_data;
    b->l_data += 3 + len;
    if (b->m_data < b->l_data) {
        b->m_data = b->l_data;
        kroundup32(b->m_data);
        b->data = (uint8_t*)realloc(b->data, b->m_data);
    }
    b->data[ori_len] = tag[0]; b->data[ori_len + 1] = tag[1];
    b->data[ori_len + 2] = type;
    memcpy(b->data + ori_len + 3, data, len);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movl %ecx, %r14d
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r15
movslq 0x20(%rdi), %r13
leal (%r14,%r13), %eax
addl $0x3, %eax
movl %eax, 0x20(%rdi)
cmpl %eax, 0x24(%rdi)
jge 0x13c30
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
incl %ecx
movl %ecx, 0x24(%r15)
movq 0x28(%r15), %rdi
movslq %ecx, %rsi
callq 0x48c0
movq %rax, 0x28(%r15)
jmp 0x13c34
movq 0x28(%r15), %rax
movb (%r12), %cl
movb %cl, (%rax,%r13)
movb 0x1(%r12), %al
movq 0x28(%r15), %rcx
movb %al, 0x1(%rcx,%r13)
movq 0x28(%r15), %rax
movb %bpl, 0x2(%rax,%r13)
movq 0x28(%r15), %rax
leaq (%rax,%r13), %rdi
addq $0x3, %rdi
movslq %r14d, %rdx
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4420