LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_idx_save
int sam_idx_save(htsFile *fp) {
    if (fp->format.format == bam || fp->format.format == bcf ||
        fp->format.format == vcf || fp->format.format == sam) {
        int ret;
        if ((ret = sam_state_destroy(fp)) < 0) {
            errno = -ret;
            return -1;
        }
        if (!fp->is_bgzf || bgzf_flush(fp->fp.bgzf) < 0)
            return -1;
        hts_idx_amend_last(fp->idx, bgzf_tell(fp->fp.bgzf));

        if (hts_idx_finish(fp->idx, bgzf_tell(fp->fp.bgzf)) < 0)
            return -1;

        return hts_idx_save_but_not_close(fp->idx, fp->fnidx, hts_idx_fmt(fp->idx));

    } else if (fp->format.format == cram) {
        // flushed and closed by cram_close
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl 0x4c(%rdi), %eax
xorl %ebp, %ebp
cmpl $0x9, %eax
ja 0x1f37c
movl $0x318, %ecx            # imm = 0x318
btl %eax, %ecx
jae 0x1f37c
movq %rdi, %rbx
callq 0x1f383
testl %eax, %eax
js 0x1f36e
pushq $-0x1
popq %rbp
testb $0x10, (%rbx)
je 0x1f37c
movq 0x38(%rbx), %rdi
callq 0xb609
testl %eax, %eax
js 0x1f37c
movq 0x38(%rbx), %rax
movq 0x68(%rbx), %rdi
movq 0x18(%rax), %rcx
shlq $0x10, %rcx
movzwl 0x10(%rax), %esi
orq %rcx, %rsi
callq 0x13dfb
movq 0x38(%rbx), %rax
movq 0x68(%rbx), %rdi
movq 0x18(%rax), %rcx
shlq $0x10, %rcx
movzwl 0x10(%rax), %esi
orq %rcx, %rsi
callq 0x13265
testl %eax, %eax
js 0x1f37c
movq 0x68(%rbx), %r14
movq 0x70(%rbx), %rbx
movq %r14, %rdi
callq 0x13e00
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x14273
movl %eax, %ebp
negl %ebp
callq 0x4050
movl %ebp, (%rax)
pushq $-0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_passes_filter
int sam_passes_filter(const sam_hdr_t *h, const bam1_t *b, hts_filter_t *filt)
{
    hb_pair hb = {h, b};
    hts_expr_val_t res = HTS_EXPR_VAL_INIT;
    if (hts_filter_eval2(filt, &hb, bam_sym_lookup, &res)) {
        hts_log_error("Couldn't process filter expression");
        hts_expr_val_free(&res);
        return -1;
    }

    int t = res.is_true;
    hts_expr_val_free(&res);

    return t;
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movq %rdx, %r8
leaq 0x30(%rsp), %rax
movq %rdi, (%rax)
movq %rsi, 0x8(%rax)
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, 0x10(%rcx)
movaps %xmm0, (%rcx)
andq $0x0, 0x20(%rcx)
leaq 0x43(%rip), %rdx        # 0x1f68d
movq %r8, %rdi
movq %rax, %rsi
callq 0x18e2d
testl %eax, %eax
je 0x1f676
leaq 0x5a21f(%rip), %rsi     # 0x7987f
leaq 0x5a22a(%rip), %rdx     # 0x79891
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
pushq $-0x1
popq %rbx
jmp 0x1f67b
movsbl 0x1(%rsp), %ebx
leaq 0x8(%rsp), %rdi
callq 0x22fef
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: index_load
static hts_idx_t *index_load(htsFile *fp, const char *fn, const char *fnidx, int flags)
{
    switch (fp->format.format) {
    case bam:
    case sam:
        return hts_idx_load3(fn, fnidx, HTS_FMT_BAI, flags);

    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
movq %rdi, %rbx
movl 0x4c(%rdi), %eax
leal -0x3(%rax), %edi
cmpl $0x2, %edi
jae 0x200e9
pushq $0x1
popq %rax
movq %rsi, %rdi
movq %rdx, %rsi
movl %eax, %edx
popq %rbx
jmp 0x1755d
cmpl $0x6, %eax
jne 0x20118
movq 0x38(%rbx), %rdi
callq 0x3cd68
testl %eax, %eax
js 0x20118
pushq $0x10
popq %rdi
callq 0x4680
testq %rax, %rax
je 0x20118
movl $0x3, (%rax)
movq 0x38(%rbx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x2011a
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_itr_queryi
hts_itr_t *sam_itr_queryi(const hts_idx_t *idx, int tid, hts_pos_t beg, hts_pos_t 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_readrec_rest);
    else if (cidx->fmt == HTS_FMT_CRAI)
        return cram_itr_query(idx, tid, beg, end, sam_readrec);
    else
        return hts_itr_query(idx, tid, beg, end, sam_readrec);
}

// Assembly:
testq %rdi, %rdi
je 0x2013b
cmpl $0x3, (%rdi)
jne 0x20149
leaq 0x103(%rip), %r8        # 0x2023c
jmp 0x20166
leaq 0x13(%rip), %r8         # 0x20155
xorl %edi, %edi
jmp 0x145e5
leaq 0xec(%rip), %r8         # 0x2023c
jmp 0x145e5
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: cram_itr_query
static hts_itr_t *cram_itr_query(const hts_idx_t *idx, int tid, hts_pos_t beg, hts_pos_t 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->is_cram = 1;
    iter->read_rest = 1;
    iter->off = NULL;
    iter->bins.a = NULL;
    iter->readrec = readrec;

    if (tid >= 0 || tid == HTS_IDX_NOCOOR || tid == HTS_IDX_START) {
        cram_range r = { 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:
        hts_log_error("Query with tid=%d not implemented for CRAM files", tid);
        abort();
        break;
    }

    return iter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbp
movq %rcx, %r15
movq %rdx, %r12
movl %esi, %r14d
movq %rdi, %r13
pushq $0x1
popq %rdi
movl $0x90, %esi
callq 0x4300
testq %rax, %rax
je 0x201f4
movq %rax, %rbx
movl $0x5, (%rax)
movq %rbp, 0x68(%rax)
testl %r14d, %r14d
sets %al
leal 0x3(%r14), %ecx
cmpl $0x2, %ecx
setae %cl
testb %cl, %al
jne 0x201f8
movq %rsp, %rdx
movl %r14d, (%rdx)
leaq 0x1(%r12), %rax
movq %rax, 0x8(%rdx)
movq %r15, 0x10(%rdx)
movq 0x8(%r13), %rdi
pushq $0x5
popq %rsi
xorl %eax, %eax
callq 0x451f7
movl %r14d, 0x4(%rbx)
movq %r12, 0x18(%rbx)
movq %r15, 0x20(%rbx)
testl %eax, %eax
je 0x2020a
cmpl $-0x2, %eax
je 0x20204
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
jmp 0x2020a
cmpl $-0x4, %r14d
je 0x2020a
cmpl $-0x5, %r14d
jne 0x2021c
movl $0x7, (%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x59e39(%rip), %rsi     # 0x7a05c
leaq 0x58409(%rip), %rdx     # 0x78633
pushq $0x1
popq %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x110c6
callq 0x4270
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_readrec
static int sam_readrec(BGZF *ignored, void *fpv, void *bv, int *tid, hts_pos_t *beg, hts_pos_t *end)
{
    htsFile *fp = (htsFile *)fpv;
    bam1_t *b = bv;
    fp->line.l = 0;
    int ret = sam_read1(fp, fp->bam_header, b);
    if (ret >= 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 %rsi, %rdi
andq $0x0, 0x10(%rsi)
movq 0x78(%rsi), %rsi
callq 0x233e2
movl %eax, %ebp
testl %eax, %eax
js 0x20280
movl 0x8(%r14), %eax
movl %eax, (%r12)
movq (%r14), %rax
movq %rax, (%r15)
movq %r14, %rdi
callq 0x1e518
movq %rax, (%rbx)
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_itr_regarray
hts_itr_t *sam_itr_regarray(const hts_idx_t *idx, sam_hdr_t *hdr, char **regarray, unsigned int regcount)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;
    hts_reglist_t *r_list = NULL;
    int r_count = 0;

    if (!cidx || !hdr)
        return NULL;

    hts_itr_t *itr = NULL;
    if (cidx->fmt == HTS_FMT_CRAI) {
        r_list = hts_reglist_create(regarray, regcount, &r_count, cidx->cram, cram_name2id);
        if (!r_list)
            return NULL;
        itr = hts_itr_regions(idx, r_list, r_count, cram_name2id, cidx->cram,
                   hts_itr_multi_cram, cram_readrec, cram_pseek, cram_ptell);
    } else {
        r_list = hts_reglist_create(regarray, regcount, &r_count, hdr, (hts_name2id_f)(bam_name2id));
        if (!r_list)
            return NULL;
        itr = hts_itr_regions(idx, r_list, r_count, (hts_name2id_f)(bam_name2id), hdr,
                   hts_itr_multi_bam, sam_readrec, bam_pseek, bam_ptell);
    }

    if (!itr)
        hts_reglist_free(r_list, r_count);

    return itr;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
andl $0x0, 0xc(%rsp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
jne 0x203c5
movq %rdi, %r14
cmpl $0x3, (%rdi)
jne 0x2034e
movq 0x8(%r14), %rax
leaq 0xdb(%rip), %r8         # 0x203d1
leaq 0xc(%rsp), %r9
movq %rdx, %rdi
movl %ecx, %esi
movq %r9, %rdx
movq %rax, %rcx
callq 0x1cc34
testq %rax, %rax
je 0x203c5
movq %rax, %rbx
movl 0xc(%rsp), %edx
movq 0x8(%r14), %r8
subq $0x8, %rsp
leaq 0x1e6(%rip), %rax       # 0x20510
leaq 0x166(%rip), %r10       # 0x20497
leaq 0xa2(%rip), %r11        # 0x203da
leaq 0x92(%rip), %rcx        # 0x203d1
leaq -0xaa69(%rip), %r9      # 0x158dd
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x203a6
leaq -0x2496(%rip), %r8      # 0x1debf
leaq 0xc(%rsp), %rax
movq %rdx, %rdi
movl %ecx, %esi
movq %rax, %rdx
movq %r15, %rcx
callq 0x1cc34
testq %rax, %rax
je 0x203c5
movq %rax, %rbx
movl 0xc(%rsp), %edx
subq $0x8, %rsp
leaq 0x1e3(%rip), %rax       # 0x20564
leaq 0x1d7(%rip), %r10       # 0x2055f
leaq -0x153(%rip), %r11      # 0x2023c
leaq -0x24d7(%rip), %rcx     # 0x1debf
leaq -0xb13b(%rip), %r9      # 0x15262
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %r8
pushq %rax
pushq %r10
pushq %r11
callq 0x16621
addq $0x20, %rsp
testq %rax, %rax
jne 0x203c7
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x1d2dd
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: cram_readrec
static int cram_readrec(BGZF *ignored, void *fpv, void *bv, int *tid, hts_pos_t *beg, hts_pos_t *end)
{
    htsFile *fp = fpv;
    bam1_t *b = bv;
    int pass_filter, ret;

    do {
        ret = cram_get_bam_seq(fp->fp.cram, &b);
        if (ret < 0)
            return cram_eof(fp->fp.cram) ? -1 : -2;

        if (bam_tag2cigar(b, 1, 1) < 0)
            return -2;

        *tid = b->core.tid;
        *beg = b->core.pos;
        *end = bam_endpos(b);

        if (fp->filter) {
            pass_filter = sam_passes_filter(fp->bam_header, b, fp->filter);
            if (pass_filter < 0)
                return -2;
        } else {
            pass_filter = 1;
        }
    } while (pass_filter == 0);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r14
movq %rcx, %r15
movq %rsi, %r12
leaq 0x8(%rsp), %rax
movq %rdx, (%rax)
pushq $0x1
popq %r13
movq 0x38(%r12), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3340c
testl %eax, %eax
js 0x20473
movl %eax, %ebp
movq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x1e8b9
testl %eax, %eax
js 0x2046e
movq 0x8(%rsp), %rbx
movl 0x8(%rbx), %eax
movl %eax, (%r15)
movq (%rbx), %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x1e518
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x80(%r12), %rdx
testq %rdx, %rdx
je 0x20486
movq 0x78(%r12), %rdi
movq %rbx, %rsi
callq 0x1f61d
testl %eax, %eax
js 0x2046e
je 0x20402
jmp 0x20486
pushq $-0x2
popq %rbp
jmp 0x20486
movq 0x38(%r12), %rdi
callq 0x451f0
cmpl $0x1, %eax
pushq $-0x1
popq %rbp
sbbl $0x0, %ebp
movl %ebp, %eax
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/sam.c
// Function: cram_pseek
static int cram_pseek(void *fp, int64_t offset, int whence)
{
    cram_fd *fd =  (cram_fd *)fp;

    if ((0 != cram_seek(fd, offset, SEEK_SET))
     && (0 != cram_seek(fd, offset - fd->first_container, SEEK_CUR)))
        return -1;

    fd->curr_position = offset;

    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;
    }

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
movq %rdi, %r14
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x44dc2
testl %eax, %eax
je 0x204cd
movq %r15, %rsi
subq 0x8880(%r14), %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x44dc2
testl %eax, %eax
je 0x204cd
pushq $-0x1
popq %rbx
jmp 0x20508
movq %r15, 0x8888(%r14)
movq 0x38(%r14), %rdi
testq %rdi, %rdi
je 0x20508
leaq 0x38(%r14), %r15
callq 0x4237d
movq 0x40(%r14), %rdi
testq %rdi, %rdi
je 0x204f9
cmpq (%r15), %rdi
je 0x204f9
callq 0x4237d
andl $0x0, 0x8978(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: cram_ptell
static int64_t cram_ptell(void *fp)
{
    cram_fd *fd = (cram_fd *)fp;
    cram_container *c;
    cram_slice *s;
    int64_t ret = -1L;

    if (fd) {
        if ((c = fd->ctr) != NULL) {
            if ((s = c->slice) != NULL && s->max_rec) {
                if ((c->curr_slice + s->curr_rec/s->max_rec) >= (c->max_slice + 1))
                    fd->curr_position += c->offset + c->length;
            }
        }
        ret = fd->curr_position;
    }

    return ret;
}

// Assembly:
testq %rdi, %rdi
je 0x2055b
movq 0x38(%rdi), %rcx
testq %rcx, %rcx
je 0x20553
movq 0x90(%rcx), %rax
testq %rax, %rax
je 0x20553
movl 0xe0(%rax), %esi
testl %esi, %esi
je 0x20553
movl 0xe4(%rax), %eax
cltd
idivl %esi
addl 0x5c(%rcx), %eax
cmpl 0x58(%rcx), %eax
jle 0x20553
movslq (%rcx), %rax
addq 0x40(%rcx), %rax
addq %rax, 0x8888(%rdi)
movq 0x8888(%rdi), %rax
retq
pushq $-0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_itr_regions
hts_itr_t *sam_itr_regions(const hts_idx_t *idx, sam_hdr_t *hdr, hts_reglist_t *reglist, unsigned int regcount)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;

    if(!cidx || !hdr || !reglist)
        return NULL;

    if (cidx->fmt == HTS_FMT_CRAI)
        return hts_itr_regions(idx, reglist, regcount, cram_name2id, cidx->cram,
                   hts_itr_multi_cram, cram_readrec, cram_pseek, cram_ptell);
    else
        return hts_itr_regions(idx, reglist, regcount, (hts_name2id_f)(bam_name2id), hdr,
                   hts_itr_multi_bam, sam_readrec, bam_pseek, bam_ptell);
}

// Assembly:
pushq %rbx
movq %rsi, %r8
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
testq %rdx, %rdx
sete %al
orb %sil, %al
jne 0x205ce
cmpl $0x3, (%rdi)
jne 0x205d2
movq 0x8(%rdi), %r8
subq $0x8, %rsp
leaq -0xa0(%rip), %r10       # 0x20510
leaq -0x120(%rip), %r11      # 0x20497
leaq -0x1e4(%rip), %rbx      # 0x203da
leaq -0x1f4(%rip), %rax      # 0x203d1
leaq -0xacef(%rip), %r9      # 0x158dd
jmp 0x205f9
xorl %eax, %eax
jmp 0x2060f
subq $0x8, %rsp
leaq -0x79(%rip), %r10       # 0x20564
leaq -0x85(%rip), %r11       # 0x2055f
leaq -0x3af(%rip), %rbx      # 0x2023c
leaq -0x2733(%rip), %rax     # 0x1debf
leaq -0xb397(%rip), %r9      # 0x15262
movq %rdx, %rsi
movl %ecx, %edx
movq %rax, %rcx
pushq %r10
pushq %r11
pushq %rbx
callq 0x16621
addq $0x20, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_hdr_parse
sam_hdr_t *sam_hdr_parse(size_t l_text, const char *text)
{
    sam_hdr_t *bh = sam_hdr_init();
    if (!bh) return NULL;

    if (sam_hdr_add_lines(bh, text, l_text) != 0) {
        sam_hdr_destroy(bh);
        return NULL;
    }

    return bh;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
movq %rdi, %r14
callq 0x1d600
testq %rax, %rax
je 0x20643
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6a11d
testl %eax, %eax
je 0x20645
movq %rbx, %rdi
callq 0x1d61e
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/./htslib/kstring.h
// Function: kputc
static inline int kputc(int c, kstring_t *s)
{
	if (ks_resize(s, s->l + 2) < 0)
		return EOF;
	s->s[s->l++] = c;
	s->s[s->l] = 0;
	return (unsigned char)c;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
movq (%rsi), %rsi
addq $0x2, %rsi
movq %r14, %rdi
callq 0x24d14
testl %eax, %eax
js 0x2158e
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movb %bl, (%rcx,%rax)
movq (%r14), %rax
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rax)
movzbl %bl, %eax
jmp 0x21591
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/./sam_internal.h
// Function: possibly_expand_bam_data
static inline int possibly_expand_bam_data(bam1_t *b, size_t bytes) {
    size_t new_len = (size_t) b->l_data + bytes;

    if (new_len > INT32_MAX || new_len < bytes) { // Too big or overflow
        errno = ENOMEM;
        return -1;
    }
    if (new_len <= b->m_data) return 0;
    return sam_realloc_bam_data(b, new_len);
}

// Assembly:
movq %rsi, %rax
movslq 0x40(%rdi), %rsi
addq %rax, %rsi
setae %al
testq $-0x80000000, %rsi      # imm = 0x80000000
sete %cl
testb %al, %cl
jne 0x2203e
pushq %rax
callq 0x4050
movl $0xc, (%rax)
pushq $-0x1
popq %rax
addq $0x8, %rsp
retq
movl 0x44(%rdi), %ecx
xorl %eax, %eax
cmpq %rcx, %rsi
ja 0x1decf
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/./textutils_internal.h
// Function: hts_str2uint
static inline uint64_t hts_str2uint(const char *in, char **end, int bits,
                                    int *failed) {
    uint64_t n = 0, limit = (bits < 64 ? (1ULL << bits) : 0) - 1;
    const unsigned char *v = (const unsigned char *) in;
    const unsigned int ascii_zero = '0'; // Prevents conversion to signed
    uint32_t fast = bits * 1000 / 3322 + 1; // log(10)/log(2) ~= 3.322
    unsigned int d;

    if (*v == '+')
        v++;

    while (--fast && *v>='0' && *v<='9')
        n = n*10 + *v++ - ascii_zero;

    if ((unsigned)(*v - ascii_zero) < 10 && !fast) {
        uint64_t limit_d_10 = limit / 10;
        uint64_t limit_m_10 = limit - 10 * limit_d_10;
        while ((d = *v - ascii_zero) < 10) {
            if (n < limit_d_10 || (n == limit_d_10 && d <= limit_m_10)) {
                n = n*10 + d;
                v++;
            } else {
                do { v++; } while (*v - ascii_zero < 10);
                n = limit;
                *failed = 1;
                break;
            }
        }
    }

    *end = (char *)v;
    return n;
}

// Assembly:
movq %rcx, %r9
movl %edx, %ecx
pushq $-0x1
popq %r8
shlq %cl, %r8
notq %r8
imull $0x3e8, %edx, %eax      # imm = 0x3E8
xorl %r10d, %r10d
movl $0xcfa, %ecx            # imm = 0xCFA
xorl %edx, %edx
divl %ecx
xorl %ecx, %ecx
cmpb $0x2b, (%rdi)
sete %cl
addq %rdi, %rcx
movl %eax, %edx
movb (%rcx), %dil
movzbl %dil, %r11d
addl $-0x1, %edx
jae 0x220a4
addb $-0x30, %dil
cmpb $0x9, %dil
ja 0x22107
imulq $0xa, %r10, %rax
incq %rcx
leaq (%rax,%r11), %r10
addq $-0x30, %r10
movl %edx, %eax
jmp 0x2207b
testl %eax, %eax
jne 0x22107
addl $-0x3a, %r11d
cmpl $-0xa, %r11d
jb 0x22107
pushq $0xa
popq %r11
movq %r8, %rax
xorl %edx, %edx
divq %r11
imulq $-0xa, %rax, %rdx
addq %r8, %rdx
movzbl %dil, %edi
addl $-0x30, %edi
cmpl $0x9, %edi
ja 0x22107
movl %edi, %edi
cmpq %rax, %r10
jb 0x220df
jne 0x220ef
cmpq %rdi, %rdx
jb 0x220ef
imulq $0xa, %r10, %r10
addq %rdi, %r10
movb 0x1(%rcx), %dil
incq %rcx
jmp 0x220c5
movzbl 0x1(%rcx), %eax
incq %rcx
addl $-0x30, %eax
cmpl $0xa, %eax
jb 0x220ef
movl $0x1, (%r9)
jmp 0x2210a
movq %r10, %r8
movq %rcx, (%rsi)
movq %r8, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_parse_cigar
ssize_t bam_parse_cigar(const char *in, char **end, bam1_t *b) {
    size_t n_cigar = 0;
    int diff;

    if (!in || !b) {
        hts_log_error("NULL pointer arguments");
        return -1;
    }
    if (end) *end = (char *)in;

    n_cigar = (*in == '*') ? 0 : read_ncigar(in);
    if (!n_cigar && b->core.n_cigar == 0) {
        if (end) *end = (char *)in+1;
        return 0;
    }

    ssize_t cig_diff = n_cigar - b->core.n_cigar;
    if (cig_diff > 0 &&
        possibly_expand_bam_data(b, cig_diff * sizeof(uint32_t)) < 0) {
        hts_log_error("Memory allocation error");
        return -1;
    }

    uint32_t *cig = bam_get_cigar(b);
    if ((uint8_t *)cig != b->data + b->l_data) {
        // Modifying an BAM existing BAM record
        uint8_t  *seq = bam_get_seq(b);
        memmove(cig + n_cigar, seq, (b->data + b->l_data) - seq);
    }

    if (n_cigar) {
        if (!(diff = parse_cigar(in, cig, n_cigar)))
            return -1;
    } else {
        diff = 1; // handle "*"
    }

    b->l_data += cig_diff * sizeof(uint32_t);
    b->core.n_cigar = n_cigar;
    if (end) *end = (char *)in + diff;

    return n_cigar;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
setne %al
testq %rdx, %rdx
setne %cl
testb %cl, %al
je 0x22162
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x2213d
movq %r14, (%rbx)
cmpb $0x2a, (%r14)
je 0x2218f
movq %r14, %rdi
callq 0x22b16
testl %eax, %eax
je 0x2218f
movl %eax, %r13d
movl %eax, %ebp
movl 0x14(%r15), %eax
movl $0x0, 0x4(%rsp)
jmp 0x221a6
leaq 0x579c3(%rip), %rsi     # 0x79b2c
leaq 0x5798d(%rip), %rdx     # 0x79afd
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
pushq $-0x1
popq %rbp
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x14(%r15), %eax
testl %eax, %eax
je 0x2224e
xorl %ebp, %ebp
movb $0x1, %cl
movl %ecx, 0x4(%rsp)
xorl %r13d, %r13d
movl %eax, %eax
movq %rbp, %r12
subq %rax, %r12
jle 0x221c8
leaq (,%r12,4), %rsi
movq %r15, %rdi
callq 0x2200f
testl %eax, %eax
js 0x22260
movl %r13d, (%rsp)
movq 0x38(%r15), %rdx
movzwl 0x12(%r15), %ecx
leaq (%rdx,%rcx), %r13
movslq 0x40(%r15), %rax
cmpq %rax, %rcx
je 0x22202
addq %rax, %rdx
movl 0x14(%r15), %esi
shll $0x2, %esi
addq %r13, %rsi
leaq (,%rbp,4), %rdi
addq %r13, %rdi
subq %rsi, %rdx
callq 0x4830
cmpb $0x0, 0x4(%rsp)
je 0x22212
pushq $0x1
popq %rax
movl (%rsp), %r13d
jmp 0x2222c
movq %r14, %rdi
movq %r13, %rsi
movl (%rsp), %r13d
movl %r13d, %edx
callq 0x22b78
testl %eax, %eax
je 0x2217a
shll $0x2, %r12d
addl %r12d, 0x40(%r15)
movl %r13d, 0x14(%r15)
testq %rbx, %rbx
je 0x2217d
cltq
addq %rax, %r14
movq %r14, (%rbx)
jmp 0x2217d
testq %rbx, %rbx
je 0x22259
incq %r14
movq %r14, (%rbx)
xorl %ebp, %ebp
jmp 0x2217d
leaq 0x578c5(%rip), %rsi     # 0x79b2c
leaq 0x578a6(%rip), %rdx     # 0x79b14
jmp 0x22170
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_parse_cigar
ssize_t sam_parse_cigar(const char *in, char **end, uint32_t **a_cigar, size_t *a_mem) {
    size_t n_cigar = 0;
    int diff;

    if (!in || !a_cigar || !a_mem) {
        hts_log_error("NULL pointer arguments");
        return -1;
    }
    if (end) *end = (char *)in;

    if (*in == '*') {
        if (end) (*end)++;
        return 0;
    }
    n_cigar = read_ncigar(in);
    if (!n_cigar) return 0;
    if (n_cigar > *a_mem) {
        uint32_t *a_tmp = realloc(*a_cigar, n_cigar*sizeof(**a_cigar));
        if (a_tmp) {
            *a_cigar = a_tmp;
            *a_mem = n_cigar;
        } else {
            hts_log_error("Memory allocation error");
            return -1;
        }
    }

    if (!(diff = parse_cigar(in, *a_cigar, n_cigar))) return -1;
    if (end) *end = (char *)in+diff;

    return n_cigar;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r15
testq %rdi, %rdi
setne %al
testq %rdx, %rdx
setne %cl
andb %al, %cl
testq %r15, %r15
setne %al
testb %al, %cl
je 0x22a6b
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x22a88
movq %r14, (%rbx)
cmpb $0x2a, (%r14)
jne 0x22a8e
incq %r14
movq %r14, (%rbx)
jmp 0x22af7
leaq 0x5707b(%rip), %rsi     # 0x79aed
leaq 0x57084(%rip), %rdx     # 0x79afd
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
pushq $-0x1
popq %rax
jmp 0x22af9
cmpb $0x2a, (%r14)
je 0x22af7
movq %r14, %rdi
callq 0x22b16
testl %eax, %eax
je 0x22af7
movl %eax, %r12d
movq (%r13), %rsi
cmpq %r12, (%r15)
jae 0x22ac8
leaq (,%r12,4), %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x4840
testq %rax, %rax
je 0x22b03
movq %rax, %rsi
movq %rax, (%r13)
movq %r12, (%r15)
movq %r14, %rdi
movl %r12d, %edx
callq 0x22b78
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
sbbq %rax, %rax
orq %r12, %rax
testq %rbx, %rbx
je 0x22af9
testl %ecx, %ecx
je 0x22af9
movslq %ecx, %rax
addq %rax, %r14
movq %r14, (%rbx)
movq %r12, %rax
jmp 0x22af9
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x56fe3(%rip), %rsi     # 0x79aed
leaq 0x57003(%rip), %rdx     # 0x79b14
jmp 0x22a79
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: read_ncigar
static uint32_t read_ncigar(const char *q) {
    uint32_t n_cigar = 0;
    for (; *q && *q != '\t'; ++q)
        if (!isdigit_c(*q)) ++n_cigar;
    if (!n_cigar) {
        hts_log_error("No CIGAR operations");
        return 0;
    }
    if (n_cigar >= 2147483647) {
        hts_log_error("Too many CIGAR operations");
        return 0;
    }

    return n_cigar;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
xorl %ebx, %ebx
movzbl (%r14), %eax
testl %eax, %eax
je 0x22b3f
cmpl $0x9, %eax
je 0x22b3f
movsbl %al, %edi
callq 0x291f8
cmpl $0x1, %eax
adcl $0x0, %ebx
incq %r14
jmp 0x22b1f
testl %ebx, %ebx
je 0x22b54
cmpl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
jb 0x22b6e
leaq 0x57a74(%rip), %rdx     # 0x7a5c6
jmp 0x22b5b
leaq 0x57a57(%rip), %rdx     # 0x7a5b2
leaq 0x57a44(%rip), %rsi     # 0x7a5a6
xorl %ebx, %ebx
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: parse_cigar
static int parse_cigar(const char *in, uint32_t *a_cigar, uint32_t n_cigar) {
    int i, overflow = 0;
    const char *p = in;
    for (i = 0; i < n_cigar; i++) {
        uint32_t len;
        int op;
        char *q;
        len = hts_str2uint(p, &q, 28, &overflow)<<BAM_CIGAR_SHIFT;
        if (q == p) {
            hts_log_error("CIGAR length invalid at position %d (%s)", (int)(i+1), p);
            return 0;
        }
        if (overflow) {
            hts_log_error("CIGAR length too long at position %d (%.*s)", (int)(i+1), (int)(q-p+1), p);
            return 0;
        }
        p = q;
        op = bam_cigar_table[(unsigned char)*p++];
        if (op < 0) {
            hts_log_error("Unrecognized CIGAR operator");
            return 0;
        }
        a_cigar[i] = len;
        a_cigar[i] |= op;
    }

    return p-in;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x4(%rsp), %r12
andl $0x0, (%r12)
movq %rsi, %r13
movq %rdi, %r14
movl %edx, %ebp
xorl %ebx, %ebx
pushq $0x1c
popq %r15
movq %rdi, 0x8(%rsp)
cmpq %rbx, %rbp
je 0x22bf4
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl %r15d, %edx
movq %r12, %rcx
callq 0x2204d
movq 0x10(%rsp), %r8
cmpq %r14, %r8
je 0x22bfb
cmpl $0x0, 0x4(%rsp)
jne 0x22c1c
movzbl (%r8), %ecx
leaq 0x56789(%rip), %rdx     # 0x79360
movsbl (%rcx,%rdx), %ecx
testl %ecx, %ecx
js 0x22c43
shll $0x4, %eax
incq %r8
orl %ecx, %eax
movl %eax, (%r13,%rbx,4)
incq %rbx
movq %r8, %r14
jmp 0x22ba3
subl 0x8(%rsp), %r14d
jmp 0x22c5e
incl %ebx
leaq 0x56f2c(%rip), %rsi     # 0x79b30
leaq 0x579d5(%rip), %rdx     # 0x7a5e0
pushq $0x1
popq %rdi
movl %ebx, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x110c6
jmp 0x22c5b
incl %ebx
subl %r14d, %r8d
incl %r8d
leaq 0x56f05(%rip), %rsi     # 0x79b30
leaq 0x579d7(%rip), %rdx     # 0x7a609
pushq $0x1
popq %rdi
movl %ebx, %ecx
movq %r14, %r9
xorl %eax, %eax
callq 0x110c6
jmp 0x22c5b
leaq 0x56ee6(%rip), %rsi     # 0x79b30
leaq 0x579e4(%rip), %rdx     # 0x7a635
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
xorl %r14d, %r14d
movl %r14d, %eax
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/sam.c
// Function: sam_free_sp_bams
static void sam_free_sp_bams(sp_bams *b) {
    if (!b)
        return;

    if (b->bams) {
        int i;
        for (i = 0; i < b->abams; i++) {
            if (b->bams[i].data)
                free(b->bams[i].data);
        }
        free(b->bams);
    }
    free(b);
}

// Assembly:
testq %rdi, %rdi
je 0x22e59
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpq $0x0, 0x10(%rdi)
je 0x22e4c
pushq $0x38
popq %r14
xorl %r15d, %r15d
movslq 0x1c(%rbx), %rax
movq 0x10(%rbx), %rdi
cmpq %rax, %r15
jge 0x22e47
movq (%rdi,%r14), %rdi
callq 0x45c0
incq %r15
addq $0x50, %r14
jmp 0x22e28
callq 0x45c0
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x45c0
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_set_thread_pool
int sam_set_thread_pool(htsFile *fp, htsThreadPool *p) {
    if (fp->state)
        return 0;

    if (!(fp->state = sam_state_create(fp)))
        return -1;
    SAM_state *fd = (SAM_state *)fp->state;

    pthread_mutex_init(&fd->lines_m, NULL);
    pthread_mutex_init(&fd->command_m, NULL);
    pthread_cond_init(&fd->command_c, NULL);
    fd->p = p->pool;
    int qsize = p->qsize;
    if (!qsize)
        qsize = 2*hts_tpool_size(fd->p);
    fd->q = hts_tpool_process_init(fd->p, qsize, 0);
    if (!fd->q) {
        sam_state_destroy(fp);
        return -1;
    }

    if (fp->format.compression == bgzf)
        return bgzf_thread_pool(fp->fp.bgzf, p->pool, p->qsize);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
xorl %ebp, %ebp
cmpq $0x0, 0x40(%rdi)
jne 0x22f24
movq %rdi, %rbx
movl 0x4c(%rdi), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x22f1c
movq %rsi, %r14
pushq $0x1
popq %rdi
movl $0xe0, %esi
callq 0x4300
testq %rax, %rax
je 0x22f1c
movq %rax, %r15
movq %rbx, 0xd8(%rax)
movq %rax, 0x40(%rbx)
leaq 0x18(%rax), %rdi
xorl %esi, %esi
callq 0x4780
leaq 0x78(%r15), %rdi
xorl %esi, %esi
callq 0x4780
movq %r15, %rdi
addq $0xa0, %rdi
xorl %esi, %esi
callq 0x45d0
movq (%r14), %rdi
movq %rdi, 0x8(%r15)
movl 0x8(%r14), %esi
testl %esi, %esi
jne 0x22eea
callq 0x2c89b
movl %eax, %esi
addl %eax, %esi
movq 0x8(%r15), %rdi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x2bfc7
movq %rax, 0x40(%r15)
testq %rax, %rax
je 0x22f31
cmpl $0x2, 0x54(%rbx)
jne 0x22f24
movq 0x38(%rbx), %rdi
movq (%r14), %rsi
movl 0x8(%r14), %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xae43
andq $0x0, 0x40(%rbx)
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x1f383
jmp 0x22f21
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_set_threads
int sam_set_threads(htsFile *fp, int nthreads) {
    if (nthreads <= 0)
        return 0;

    htsThreadPool p;
    p.pool = hts_tpool_init(nthreads);
    p.qsize = nthreads*2;

    int ret = sam_set_thread_pool(fp, &p);
    if (ret < 0)
        return ret;

    SAM_state *fd = (SAM_state *)fp->state;
    fd->own_pool = 1;

    return 0;
}

// Assembly:
testl %esi, %esi
jle 0x22f7e
pushq %rbp
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %edi
callq 0x2c2cf
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
addl %ebp, %ebp
movl %ebp, 0x8(%rsi)
movq %rbx, %rdi
callq 0x22e5a
testl %eax, %eax
js 0x22f77
movq 0x40(%rbx), %rax
movl $0x1, 0x10(%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: fastq_state_destroy
void fastq_state_destroy(htsFile *fp) {
    if (fp->state) {
        fastq_state *x = (fastq_state *)fp->state;
        if (x->tags)
            kh_destroy(tag, x->tags);
        ks_free(&x->name);
        ks_free(&x->seq);
        ks_free(&x->qual);
        free(fp->state);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x40(%rdi), %r14
testq %r14, %r14
je 0x22fe9
movq %rdi, %rbx
movq 0x70(%r14), %r15
testq %r15, %r15
je 0x22fbe
movq 0x18(%r15), %rdi
callq 0x45c0
movq 0x10(%r15), %rdi
callq 0x45c0
movq 0x20(%r15), %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x22fef
leaq 0x30(%r14), %rdi
callq 0x22fef
addq $0x48, %r14
movq %r14, %rdi
callq 0x22fef
movq 0x40(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x45c0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: fastq_state_init
static fastq_state *fastq_state_init(int name_char) {
    fastq_state *x = (fastq_state *)calloc(1, sizeof(*x));
    if (!x)
        return NULL;
    strcpy(x->BC, "BC");
    x->nprefix = name_char;

    return x;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
pushq $0x1
popq %rdi
movl $0x80, %esi
callq 0x4300
testq %rax, %rax
je 0x233e0
movb $0x0, 0x6e(%rax)
movw $0x4342, 0x6c(%rax)     # imm = 0x4342
movb %bl, 0x78(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux_get
uint8_t *bam_aux_get(const bam1_t *b, const char tag[2])
{
    uint8_t *s;
    for (s = bam_aux_first(b); s; s = bam_aux_next(b, s))
        if (s[-2] == tag[0] && s[-1] == tag[1]) {
            // Check the tag value is valid and complete
            uint8_t *e = skip_aux(s, b->data + b->l_data);
            if (e == NULL) goto bad_aux;
            if ((*s == 'Z' || *s == 'H') && *(e - 1) != '\0') goto bad_aux;

            return s;
        }

    // errno now as set by bam_aux_first()/bam_aux_next()
    return NULL;

 bad_aux:
    hts_log_error("Corrupted aux data for read %s flag %d",
                  bam_get_qname(b), b->core.flag);
    errno = EINVAL;
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
movq %rdi, %r14
callq 0x258e2
movq %rax, %rbx
testq %rax, %rax
je 0x24566
movzbl -0x2(%rbx), %eax
movsbl (%r15), %ecx
cmpl %ecx, %eax
jne 0x24559
movzbl -0x1(%rbx), %eax
movsbl 0x1(%r15), %ecx
cmpl %ecx, %eax
je 0x2456a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x25930
jmp 0x24538
xorl %ebx, %ebx
jmp 0x245c2
movq 0x38(%r14), %r15
movslq 0x40(%r14), %rsi
addq %r15, %rsi
movq %rbx, %rdi
callq 0x24c6e
testq %rax, %rax
je 0x24595
movzbl (%rbx), %ecx
cmpl $0x5a, %ecx
je 0x2458f
cmpl $0x48, %ecx
jne 0x245c2
cmpb $0x0, -0x1(%rax)
je 0x245c2
movzwl 0x10(%r14), %r8d
leaq 0x55761(%rip), %rsi     # 0x79d02
leaq 0x55733(%rip), %rdx     # 0x79cdb
xorl %ebx, %ebx
pushq $0x1
popq %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x110c6
callq 0x4050
movl $0x16, (%rax)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: skip_aux
static inline uint8_t *skip_aux(uint8_t *s, uint8_t *end)
{
    int size;
    uint32_t n;
    if (s >= end) return end;
    size = aux_type2size(*s); ++s; // skip type
    switch (size) {
    case 'Z':
    case 'H':
        s = memchr(s, 0, end-s);
        return s ? s+1 : end;
    case 'B':
        if (end - s < 5) return NULL;
        size = aux_type2size(*s); ++s;
        n = le_to_u32(s);
        s += 4;
        if (size == 0 || end - s < size * n) return NULL;
        return s + size * n;
    case 0:
        return NULL;
    default:
        if (end - s < size) return NULL;
        return s + size;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpq %rsi, %rdi
jae 0x24d09
movq %rdi, %r14
movzbl (%rdi), %edi
callq 0x260de
testb %al, %al
je 0x24cf1
leaq 0x1(%r14), %rdi
movzbl %al, %ecx
cmpl $0x42, %ecx
je 0x24cbd
cmpl $0x5a, %ecx
je 0x24ca3
cmpl $0x48, %ecx
jne 0x24cf5
movq %rbx, %rdx
subq %rdi, %rdx
xorl %esi, %esi
callq 0x4550
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmovneq %rcx, %rbx
jmp 0x24d09
movq %rbx, %rax
subq %rdi, %rax
cmpq $0x5, %rax
jl 0x24cf1
movzbl (%rdi), %edi
callq 0x260de
testl %eax, %eax
je 0x24cf1
leaq 0x6(%r14), %rcx
subq %rcx, %rbx
imull 0x2(%r14), %eax
xorl %ecx, %ecx
cmpq %rax, %rbx
leaq 0x6(%r14,%rax), %rax
cmovgeq %rax, %rcx
jmp 0x24d06
xorl %ebx, %ebx
jmp 0x24d09
subq %rdi, %rbx
movl %eax, %eax
addq %rax, %rdi
xorl %ecx, %ecx
cmpq %rax, %rbx
cmovgeq %rdi, %rcx
movq %rcx, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: cleanup_sp_lines
static void cleanup_sp_lines(void *arg) {
    sp_lines *gl = (sp_lines *)arg;
    if (!gl) return;

    // Should always be true for lines passed to / from thread workers.
    assert(gl->next == NULL);

    free(gl->data);
    sam_free_sp_bams(gl->bams);
    free(gl);
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x257f2
movq %rdi, %rbx
cmpq $0x0, (%rdi)
jne 0x257f4
movq 0x10(%rbx), %rdi
callq 0x45c0
movq 0x28(%rbx), %rdi
callq 0x22e0d
movq %rbx, %rdi
popq %rbx
jmp 0x45c0
popq %rbx
retq
leaq 0x54fb8(%rip), %rdi     # 0x7a7b3
leaq 0x5447f(%rip), %rsi     # 0x79c81
leaq 0x54fbb(%rip), %rcx     # 0x7a7c4
movl $0xd5c, %edx            # imm = 0xD5C
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux_append
int bam_aux_append(bam1_t *b, const char tag[2], char type, int len, const uint8_t *data)
{
    uint32_t new_len;

    assert(b->l_data >= 0);
    new_len = b->l_data + 3 + len;
    if (new_len > INT32_MAX || new_len < b->l_data) goto nomem;

    if (realloc_bam_data(b, new_len) < 0) return -1;

    b->data[b->l_data] = tag[0];
    b->data[b->l_data + 1] = tag[1];
    b->data[b->l_data + 2] = type;

#ifdef HTS_LITTLE_ENDIAN
    memcpy(b->data + b->l_data + 3, data, len);
#else
    if (aux_to_le(type, b->data + b->l_data + 3, data, len) != 0) {
        errno = EINVAL;
        return -1;
    }
#endif

    b->l_data = new_len;

    return 0;

 nomem:
    errno = ENOMEM;
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x40(%rdi), %eax
testl %eax, %eax
js 0x258c3
movl %ecx, %r15d
leal 0x3(%r15), %r13d
addl %eax, %r13d
setb %al
sets %cl
orb %al, %cl
je 0x2584a
callq 0x4050
movl $0xc, (%rax)
jmp 0x258b1
movq %r8, %r14
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movl %r13d, %esi
callq 0x1e02a
testl %eax, %eax
js 0x258b1
movb (%r12), %al
movq 0x38(%rbx), %rcx
movslq 0x40(%rbx), %rdx
movb %al, (%rcx,%rdx)
movb 0x1(%r12), %al
movq 0x38(%rbx), %rcx
movslq 0x40(%rbx), %rdx
movb %al, 0x1(%rcx,%rdx)
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rcx
movb %bpl, 0x2(%rax,%rcx)
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rcx
leaq (%rax,%rcx), %rdi
addq $0x3, %rdi
movslq %r15d, %rdx
movq %r14, %rsi
callq 0x43c0
movl %r13d, 0x40(%rbx)
xorl %eax, %eax
jmp 0x258b4
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x543a8(%rip), %rdi     # 0x79c72
leaq 0x543b0(%rip), %rsi     # 0x79c81
leaq 0x543af(%rip), %rcx     # 0x79c87
movl $0x12ed, %edx           # imm = 0x12ED
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux_next
uint8_t *bam_aux_next(const bam1_t *b, const uint8_t *s)
{
    uint8_t *end = b->data + b->l_data;
    uint8_t *next = s? skip_aux((uint8_t *) s, end) : end;
    if (next == NULL) goto bad_aux;
    if (end - next <= 2) { errno = ENOENT; return NULL; }
    return next+2;

 bad_aux:
    hts_log_error("Corrupted aux data for read %s flag %d",
                  bam_get_qname(b), b->core.flag);
    errno = EINVAL;
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movq 0x38(%rdi), %r14
movslq 0x40(%rdi), %r12
addq %r14, %r12
movq %r12, %rbx
testq %rsi, %rsi
je 0x2595c
movq %rsi, %rdi
movq %r12, %rsi
callq 0x24c6e
movq %rax, %rbx
testq %rbx, %rbx
je 0x25979
subq %rbx, %r12
cmpq $0x2, %r12
jg 0x259a8
callq 0x4050
movl $0x2, (%rax)
xorl %ebx, %ebx
jmp 0x259ac
movzwl 0x10(%r15), %r8d
leaq 0x54349(%rip), %rsi     # 0x79cce
leaq 0x5434f(%rip), %rdx     # 0x79cdb
xorl %ebx, %ebx
pushq $0x1
popq %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x110c6
callq 0x4050
movl $0x16, (%rax)
jmp 0x259ac
addq $0x2, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux_remove
uint8_t *bam_aux_remove(bam1_t *b, uint8_t *s)
{
    uint8_t *end = b->data + b->l_data;
    uint8_t *next = skip_aux(s, end);
    if (next == NULL) goto bad_aux;

    b->l_data -= next - (s-2);
    if (next >= end) { errno = ENOENT; return NULL; }

    memmove(s-2, next, end - next);
    return s;

 bad_aux:
    hts_log_error("Corrupted aux data for read %s flag %d",
                  bam_get_qname(b), b->core.flag);
    errno = EINVAL;
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r15
movq 0x38(%rdi), %r12
movslq 0x40(%rdi), %r13
leaq (%r12,%r13), %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x24c6e
testq %rax, %rax
je 0x25a2e
leaq -0x2(%rbx), %rdi
movl %edi, %ecx
subl %eax, %ecx
addl %r13d, %ecx
movl %ecx, 0x40(%r15)
cmpq %r14, %rax
jae 0x25a5d
subq %rax, %r14
movq %rax, %rsi
movq %r14, %rdx
callq 0x4830
jmp 0x25a6a
movzwl 0x10(%r15), %r8d
leaq 0x542d4(%rip), %rsi     # 0x79d0e
leaq 0x5429a(%rip), %rdx     # 0x79cdb
xorl %ebx, %ebx
pushq $0x1
popq %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x110c6
callq 0x4050
movl $0x16, (%rax)
jmp 0x25a6a
callq 0x4050
movl $0x2, (%rax)
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux_update_float
int bam_aux_update_float(bam1_t *b, const char tag[2], float val)
{
    uint8_t *s = bam_aux_get(b, tag);
    int shrink = 0, new = 0;

    if (s) { // Tag present - what was it?
        switch (*s) {
            case 'f': break;
            case 'd': shrink = 1; break;
            default: errno = EINVAL; return -1;  // Not a float
        }
    } else {
        if (errno == ENOENT) {  // Tag doesn't exist - add a new one
            new = 1;
        }  else { // Invalid aux data, give up.
            return -1;
        }
    }

    if (new) { // Ensure there's room
        if (possibly_expand_bam_data(b, 3 + 4) < 0)
            return -1;
        s = b->data + b->l_data;
        *s++ = tag[0];
        *s++ = tag[1];
    } else if (shrink) { // Convert non-standard double tag to float
        memmove(s + 5, s + 9, b->l_data - ((s + 9) - b->data));
        b->l_data -= 4;
    }
    *s++ = 'f';
    float_to_le(val, s);
    if (new) b->l_data += 7;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movss %xmm0, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
callq 0x24528
testq %rax, %rax
je 0x25ea5
movq %rax, %r15
movzbl (%rax), %eax
cmpl $0x64, %eax
je 0x25eee
cmpl $0x66, %eax
je 0x25f0d
callq 0x4050
movl $0x16, (%rax)
pushq $-0x1
popq %rbp
jmp 0x25f1f
callq 0x4050
pushq $-0x1
popq %rbp
cmpl $0x2, (%rax)
jne 0x25f1f
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0x2200f
testl %eax, %eax
js 0x25f1f
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rcx
movb (%r14), %dl
movb %dl, (%rax,%rcx)
movb 0x1(%r14), %dl
movb %dl, 0x1(%rax,%rcx)
movb $0x66, 0x2(%rax,%rcx)
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x3(%rax,%rcx)
addl $0x7, 0x40(%rbx)
jmp 0x25f1d
leaq 0x5(%r15), %rdi
movq %r15, %rsi
addq $0x9, %rsi
movslq 0x40(%rbx), %rdx
subq %rsi, %rdx
addq 0x38(%rbx), %rdx
callq 0x4830
addl $-0x4, 0x40(%rbx)
movb $0x66, (%r15)
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x1(%r15)
xorl %ebp, %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/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 0x26105
leal -0x63(%rdi), %ecx
cmpl $0x6, %ecx
ja 0x26116
leaq 0x53244(%rip), %rdx     # 0x7933c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
pushq $0x8
jmp 0x2612b
leaq 0x5320c(%rip), %rdx     # 0x79318
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
retq
cmpl $0x73, %edi
je 0x26125
cmpl $0x5a, %edi
je 0x2612d
cmpl $0x53, %edi
jne 0x26132
pushq $0x2
jmp 0x2612b
pushq $0x4
popq %rax
retq
movzbl %dil, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: get_int_aux_val
static inline int64_t get_int_aux_val(uint8_t type, const uint8_t *s,
                                      uint32_t idx)
{
    switch (type) {
        case 'c': return le_to_i8(s + idx);
        case 'C': return s[idx];
        case 's': return le_to_i16(s + 2 * idx);
        case 'S': return le_to_u16(s + 2 * idx);
        case 'i': return le_to_i32(s + 4 * idx);
        case 'I': return le_to_u32(s + 4 * idx);
        default:
            errno = EINVAL;
            return 0;
    }
}

// Assembly:
cmpl $0x43, %edi
je 0x26199
cmpl $0x49, %edi
je 0x26192
cmpl $0x53, %edi
je 0x26168
cmpl $0x73, %edi
je 0x26177
cmpl $0x69, %edi
je 0x2616f
cmpl $0x63, %edi
jne 0x2617f
movl %edx, %eax
movsbq (%rsi,%rax), %rax
retq
addl %edx, %edx
movzwl (%rsi,%rdx), %eax
retq
shll $0x2, %edx
movslq (%rsi,%rdx), %rax
retq
addl %edx, %edx
movswq (%rsi,%rdx), %rax
retq
pushq %rax
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
retq
shll $0x2, %edx
movl (%rsi,%rdx), %eax
retq
movl %edx, %eax
movzbl (%rsi,%rax), %eax
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux2f
double bam_aux2f(const uint8_t *s)
{
    int type;
    type = *s++;
    if (type == 'd') return le_to_double(s);
    else if (type == 'f') return le_to_float(s);
    else return get_int_aux_val(type, s, 0);
}

// Assembly:
movq %rdi, %rsi
movzbl (%rdi), %eax
incq %rsi
cmpl $0x66, %eax
je 0x261b8
cmpl $0x64, %eax
jne 0x261bd
movsd (%rsi), %xmm0
retq
cvtss2sd (%rsi), %xmm0
retq
pushq %rax
movzbl %al, %edi
xorl %edx, %edx
callq 0x26142
cvtsi2sd %rax, %xmm0
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_aux2Z
char *bam_aux2Z(const uint8_t *s)
{
    int type;
    type = *s++;
    if (type == 'Z' || type == 'H') return (char*)s;
    errno = EINVAL;
    return 0;
}

// Assembly:
movq %rdi, %rax
movzbl (%rdi), %ecx
cmpl $0x5a, %ecx
je 0x261fe
cmpl $0x48, %ecx
jne 0x26202
incq %rax
retq
pushq %rax
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_auxB_len
uint32_t bam_auxB_len(const uint8_t *s)
{
    if (s[0] != 'B') {
        errno = EINVAL;
        return 0;
    }
    return le_to_u32(s + 2);
}

// Assembly:
cmpb $0x42, (%rdi)
jne 0x2621e
movl 0x2(%rdi), %eax
retq
pushq %rax
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
retq