LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: header_callback
static size_t header_callback(void *contents, size_t size, size_t nmemb,
                              void *userp)
{
    size_t realsize = size * nmemb;
    kstring_t *resp = (kstring_t *)userp;

    if (kputsn((const char *)contents, realsize, resp) == EOF) {
        return 0;
    }

    return realsize;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rsi, %rbx
imulq %rdx, %rbx
movq (%rcx), %rcx
leaq (%rbx,%rcx), %rax
addq $0x2, %rax
cmpq %rcx, %rax
jbe 0x81b47
movq %rdi, %r15
cmpq %rax, 0x8(%r14)
jae 0x81b18
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r13
shrq %r13
xorl %r12d, %r12d
testq %rcx, %rcx
cmovneq %r12, %r13
addq %rax, %r13
movq 0x10(%r14), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
je 0x81b55
movq %rax, 0x10(%r14)
movq %r13, 0x8(%r14)
movq 0x10(%r14), %rdi
addq (%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x43c0
movq (%r14), %rax
addq %rbx, %rax
movq %rax, (%r14)
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rax)
xorl %r12d, %r12d
cmpl $-0x1, %ebx
cmovneq %rbx, %r12
jmp 0x81b55
callq 0x4050
movl $0x4b, (%rax)
xorl %r12d, %r12d
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: free_headers
static void free_headers(hdrlist *hdrs, int completely) {
    unsigned int i;
    for (i = 0; i < hdrs->num; i++) {
        free(hdrs->list[i].data);
        hdrs->list[i].data = NULL;
        hdrs->list[i].next = NULL;
    }
    hdrs->num = 0;
    if (completely) {
        free(hdrs->list);
        hdrs->size = 0;
        hdrs->list = NULL;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
je 0x820cf
xorl %r14d, %r14d
xorl %r15d, %r15d
movq (%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x45c0
movq (%rbx), %rax
incq %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%r14)
movl 0x8(%rbx), %eax
addq $0x10, %r14
cmpq %rax, %r15
jb 0x820a9
movl $0x0, 0x8(%rbx)
testl %ebp, %ebp
je 0x820f0
movq (%rbx), %rdi
callq 0x45c0
movl $0x0, 0xc(%rbx)
movq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: free_auth
static void free_auth(auth_token *tok) {
    if (!tok) return;
    if (pthread_mutex_destroy(&tok->lock)) abort();
    free(tok->path);
    free(tok->token);
    free(tok);
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x8240b
movq %rdi, %rbx
addq $0x20, %rdi
callq 0x4590
testl %eax, %eax
jne 0x8240d
movq (%rbx), %rdi
callq 0x45c0
movq 0x8(%rbx), %rdi
callq 0x45c0
movq %rbx, %rdi
popq %rbx
jmp 0x45c0
popq %rbx
retq
callq 0x4270
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: libcurl_write
static ssize_t libcurl_write(hFILE *fpv, const void *bufferv, size_t nbytes)
{
    hFILE_libcurl *fp = (hFILE_libcurl *) fpv;
    const char *buffer = (const char *) bufferv;
    CURLcode err;

    fp->buffer.ptr.wr = buffer;
    fp->buffer.len = nbytes;
    fp->paused = 0;
    err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
    if (err != CURLE_OK) { errno = easy_errno(fp->easy, err); return -1; }

    while (! fp->paused && ! fp->finished)
        if (wait_perform(fp) < 0) return -1;

    nbytes = fp->buffer.ptr.wr - buffer;
    fp->buffer.ptr.wr = NULL;
    fp->buffer.len = 0;

    if (fp->finished && fp->final_result != CURLE_OK) {
        errno = easy_errno(fp->easy, fp->final_result);
        return -1;
    }

    return nbytes;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x50(%rdi)
movq %rdx, 0x58(%rdi)
andb $-0x2, 0x64(%rdi)
movq 0x38(%rdi), %rdi
xorl %esi, %esi
callq 0x4970
movl %eax, %esi
testl %eax, %eax
je 0x831f6
movq 0x38(%rbx), %rdi
callq 0x80a55
movl %eax, %ebx
callq 0x4050
movl %ebx, (%rax)
jmp 0x8320e
leaq 0x50(%rbx), %r15
movb 0x64(%rbx), %cl
testb $0x5, %cl
jne 0x8321b
movq %rbx, %rdi
callq 0x81bb2
testl %eax, %eax
jns 0x831fa
movq $-0x1, %rax
popq %rbx
popq %r14
popq %r15
retq
movq (%r15), %rax
subq %r14, %rax
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
testb $0x4, %cl
je 0x83215
movl 0x60(%rbx), %esi
testl %esi, %esi
jne 0x831e2
jmp 0x83215
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: libcurl_seek
static off_t libcurl_seek(hFILE *fpv, off_t offset, int whence)
{
    hFILE_libcurl *fp = (hFILE_libcurl *) fpv;
    off_t origin, pos;

    if (!fp->is_read || !fp->can_seek) {
        // Cowardly refuse to seek when writing or a previous seek failed.
        errno = ESPIPE;
        return -1;
    }

    switch (whence) {
    case SEEK_SET:
        origin = 0;
        break;
    case SEEK_CUR:
        errno = ENOSYS;
        return -1;
    case SEEK_END:
        if (fp->file_size < 0) { errno = ESPIPE; return -1; }
        origin = fp->file_size;
        break;
    default:
        errno = EINVAL;
        return -1;
    }

    // Check 0 <= origin+offset < fp->file_size carefully, avoiding overflow
    if ((offset < 0)? origin + offset < 0
                : (fp->file_size >= 0 && offset > fp->file_size - origin)) {
        errno = EINVAL;
        return -1;
    }

    pos = origin + offset;

    if (fp->tried_seek) {
        /* Seeking has worked at least once, so now we can delay doing
           the actual work until the next read.  This avoids lots of pointless
           http or ftp reconnections if the caller does lots of seeks
           without any intervening reads. */
        if (fp->delayed_seek < 0) {
            fp->last_offset = fp->base.offset + (fp->base.end - fp->base.buffer);
            // Stash the current hFILE buffer content in case it's useful later
            preserve_buffer_content(fp);
        }
        fp->delayed_seek = pos;
        return pos;
    }

    if (restart_from_position(fp, pos) < 0) {
        /* This value for errno may not be entirely true, but the caller may be
           able to carry on with the existing handle. */
        errno = ESPIPE;
        return -1;
    }

    fp->tried_seek = 1;
    return pos;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movb 0x64(%rdi), %al
movl %eax, %ecx
notb %cl
testb $0x30, %cl
jne 0x832c2
movq %rdi, %r14
testl %edx, %edx
je 0x8326f
cmpl $0x2, %edx
je 0x83264
cmpl $0x1, %edx
jne 0x83290
callq 0x4050
movl $0x26, (%rax)
jmp 0x832cd
movq 0x48(%r14), %rbx
testq %rbx, %rbx
jns 0x83271
jmp 0x832c2
movl %edx, %ebx
testq %rsi, %rsi
js 0x8329d
movq 0x48(%r14), %rcx
testq %rcx, %rcx
setns %dl
subq %rbx, %rcx
cmpq %rsi, %rcx
setl %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x832a5
callq 0x4050
movl $0x16, (%rax)
jmp 0x832cd
movq %rbx, %rcx
addq %rsi, %rcx
js 0x83290
addq %rsi, %rbx
testb %al, %al
js 0x832df
movq %r14, %rdi
movq %rbx, %rsi
callq 0x81d94
testl %eax, %eax
js 0x832c2
orb $-0x80, 0x64(%r14)
jmp 0x832d4
callq 0x4050
movl $0x1d, (%rax)
movq $-0x1, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpq $0x0, 0xd0(%r14)
jns 0x83303
movq 0x28(%r14), %rax
addq 0x10(%r14), %rax
subq (%r14), %rax
movq %rax, 0xd8(%r14)
movq %r14, %rdi
callq 0x83417
movq %rbx, 0xd0(%r14)
jmp 0x832d4
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: libcurl_close
static int libcurl_close(hFILE *fpv)
{
    hFILE_libcurl *fp = (hFILE_libcurl *) fpv;
    CURLcode err;
    CURLMcode errm;
    int save_errno = 0;

    // Before closing the file, unpause it and perform on it so that uploads
    // have the opportunity to signal EOF to the server -- see send_callback().

    fp->buffer.len = 0;
    fp->closing = 1;
    fp->paused = 0;
    if (!fp->finished) {
        err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
        if (err != CURLE_OK) save_errno = easy_errno(fp->easy, err);
    }

    while (save_errno == 0 && ! fp->paused && ! fp->finished)
        if (wait_perform(fp) < 0) save_errno = errno;

    if (fp->finished && fp->final_result != CURLE_OK)
        save_errno = easy_errno(fp->easy, fp->final_result);

    errm = curl_multi_remove_handle(fp->multi, fp->easy);
    if (errm != CURLM_OK && save_errno == 0) save_errno = multi_errno(errm);
    fp->nrunning--;

    curl_easy_cleanup(fp->easy);
    curl_multi_cleanup(fp->multi);

    if (fp->headers.callback) // Tell callback to free any data it needs to
        fp->headers.callback(fp->headers.callback_data, NULL);
    free_headers(&fp->headers.fixed, 1);
    free_headers(&fp->headers.extra, 1);

    free(fp->preserved);

    if (save_errno) { errno = save_errno; return -1; }
    else return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq $0x0, 0x58(%rdi)
movb 0x64(%rdi), %al
movl %eax, %ecx
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x64(%rdi)
xorl %ebp, %ebp
testb $0x4, %al
jne 0x8336a
movq 0x38(%rbx), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x4970
testl %eax, %eax
je 0x8336a
movq 0x38(%rbx), %rdi
movl %eax, %esi
callq 0x80a55
movl %eax, %ebp
jmp 0x8336a
testb $0x5, 0x64(%rbx)
jne 0x8336e
movq %rbx, %rdi
callq 0x81bb2
xorl %ebp, %ebp
testl %eax, %eax
jns 0x8336a
callq 0x4050
movl (%rax), %ebp
testl %ebp, %ebp
je 0x8334f
testb $0x4, 0x64(%rbx)
je 0x83386
movl 0x60(%rbx), %esi
testl %esi, %esi
je 0x83386
movq 0x38(%rbx), %rdi
callq 0x80a55
movl %eax, %ebp
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdi
callq 0x4160
testl %eax, %eax
je 0x833a4
testl %ebp, %ebp
jne 0x833a4
movl %eax, %edi
callq 0x81b62
movl %eax, %ebp
decl 0x68(%rbx)
movq 0x38(%rbx), %rdi
callq 0x4620
movq 0x40(%rbx), %rdi
callq 0x4850
leaq 0x70(%rbx), %r14
movq 0x90(%rbx), %rax
testq %rax, %rax
je 0x833d4
movq 0x98(%rbx), %rdi
xorl %esi, %esi
callq *%rax
movq %r14, %rdi
movl $0x1, %esi
callq 0x82091
leaq 0x80(%rbx), %rdi
movl $0x1, %esi
callq 0x82091
movq 0xe0(%rbx), %rdi
callq 0x45c0
testl %ebp, %ebp
je 0x83410
callq 0x4050
movl %ebp, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x83412
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: preserve_buffer_content
static void preserve_buffer_content(hFILE_libcurl *fp)
{
    if (fp->base.begin == fp->base.end) {
        fp->preserved_bytes = 0;
        return;
    }
    if (!fp->preserved
        || fp->preserved_size < fp->base.limit - fp->base.buffer) {
        fp->preserved = malloc(fp->base.limit - fp->base.buffer);
        if (!fp->preserved) return;
        fp->preserved_size = fp->base.limit - fp->base.buffer;
    }

    assert(fp->base.end - fp->base.begin <= fp->preserved_size);

    memcpy(fp->preserved, fp->base.begin, fp->base.end - fp->base.begin);
    fp->preserved_bytes = fp->base.end - fp->base.begin;
    return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movq 0x10(%rdi), %r15
cmpq %r15, %r14
je 0x83493
cmpq $0x0, 0xe0(%rbx)
je 0x83449
movq 0x18(%rbx), %rax
subq (%rbx), %rax
cmpq %rax, 0xf0(%rbx)
jae 0x8346b
movq 0x18(%rbx), %r12
subq (%rbx), %r12
movq %r12, %rdi
callq 0x4680
movq %rax, 0xe0(%rbx)
testq %rax, %rax
je 0x8349c
movq %r12, 0xf0(%rbx)
subq %r14, %r15
cmpq 0xf0(%rbx), %r15
ja 0x834a8
movq 0xe0(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x43c0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
jmp 0x83495
xorl %eax, %eax
movq %rax, 0xe8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x2079c(%rip), %rdi     # 0xa3c4b
leaq 0x20757(%rip), %rsi     # 0xa3c0d
leaq 0x207c2(%rip), %rcx     # 0xa3c7f
movl $0x398, %edx            # imm = 0x398
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: http_status_errno
static int http_status_errno(int status)
{
    if (status >= 500)
        switch (status) {
        case 501: return ENOSYS;
        case 503: return EBUSY;
        case 504: return ETIMEDOUT;
        default:  return EIO;
        }
    else if (status >= 400)
        switch (status) {
        case 401: return EPERM;
        case 403: return EACCES;
        case 404: return ENOENT;
        case 405: return EROFS;
        case 407: return EPERM;
        case 408: return ETIMEDOUT;
        case 410: return ENOENT;
        default:  return EINVAL;
        }
    else return 0;
}

// Assembly:
cmpl $0x1f4, %edi            # imm = 0x1F4
jl 0x83941
addl $0xfffffe0b, %edi       # imm = 0xFFFFFE0B
movl $0x5, %eax
cmpl $0x4, %edi
jae 0x8396a
movl %edi, %eax
leaq 0x20181(%rip), %rcx     # 0xa3ac0
jmp 0x83964
xorl %eax, %eax
cmpl $0x190, %edi            # imm = 0x190
jl 0x8396a
addl $0xfffffe6f, %edi       # imm = 0xFFFFFE6F
movl $0x16, %eax
cmpl $0xa, %edi
jae 0x8396a
movl %edi, %eax
leaq 0x20134(%rip), %rcx     # 0xa3a98
leaq (%rcx,%rax,4), %rax
movl (%rax), %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: fai_destroy
void fai_destroy(faidx_t *fai)
{
    int i;
    if (!fai) return;
    for (i = 0; i < fai->n; ++i) free(fai->name[i]);
    free(fai->name);
    kh_destroy(s, fai->hash);
    if (fai->bgzf) bgzf_close(fai->bgzf);
    free(fai);
}

// Assembly:
testq %rdi, %rdi
je 0x839eb
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
jle 0x8399a
xorl %r14d, %r14d
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x45c0
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x83981
movq 0x10(%rbx), %rdi
callq 0x45c0
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x839cf
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x839dc
callq 0xd4a4
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x45c0
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: fai_fetchqual64
char *fai_fetchqual64(const faidx_t *fai, const char *str, hts_pos_t *len) {
    faidx1_t val;
    int64_t beg, end;

    if (fai_get_val(fai, str, len, &val, &beg, &end)) {
        return NULL;
    }

    // now retrieve the sequence
    return fai_retrieve(fai, &val, val.qual_offset, beg, end, len);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %rsp, %r9
callq 0x84ee6
testl %eax, %eax
je 0x85457
xorl %eax, %eax
jmp 0x85474
leaq 0x10(%rsp), %rsi
movq 0x20(%rsi), %rdx
movq 0x8(%rsp), %rcx
movq (%rsp), %r8
movq %r14, %rdi
movq %rbx, %r9
callq 0x8512d
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: fai_fetchqual
char *fai_fetchqual(const faidx_t *fai, const char *str, int *len) {
    hts_pos_t len64;
    char *ret = fai_fetchqual64(fai, str, &len64);
    *len = len64 < INT_MAX ? len64 : INT_MAX; // trunc
    return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsp, %r14
movq %r14, %rdx
callq 0x85430
movq (%r14), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
cmovlq %rcx, %rdx
movl %edx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: fai_adjust_region
int fai_adjust_region(const faidx_t *fai, int tid,
                      hts_pos_t *beg, hts_pos_t *end)
{
    hts_pos_t orig_beg, orig_end;

    if (!fai || !beg || !end || tid < 0 || tid >= fai->n)
        return -1;

    orig_beg = *beg;
    orig_end = *end;
    if (faidx_adjust_position(fai, 0, NULL, fai->name[tid], beg, end, NULL) != 0) {
        hts_log_error("Inconsistent faidx internal state - couldn't find \"%s\"",
                      fai->name[tid]);
        return -1;
    }

    return ((orig_beg != *beg ? 1 : 0) |
            (orig_end != *end && orig_end < HTS_POS_MAX ? 2 : 0));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %esi, %esi
js 0x856b6
movq %rdi, %r12
testq %rdi, %rdi
je 0x856b6
movq %rdx, %r15
testq %rdx, %rdx
je 0x856b6
movq %rcx, %r14
testq %rcx, %rcx
je 0x856b6
cmpl %esi, 0x8(%r12)
jle 0x856b6
movq (%r15), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %r13
movq 0x10(%r12), %rax
movl %esi, %ebp
movq (%rax,%rbp,8), %rcx
movq $0x0, (%rsp)
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r15, %r8
movq %r14, %r9
callq 0x856c7
testl %eax, %eax
je 0x8568b
movq 0x10(%r12), %rax
movq (%rax,%rbp,8), %rcx
leaq 0x1e6e2(%rip), %rsi     # 0xa3d58
leaq 0x1e6ed(%rip), %rdx     # 0xa3d6a
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
jmp 0x856b6
xorl %eax, %eax
movq 0x10(%rsp), %rcx
cmpq (%r15), %rcx
setne %al
cmpq (%r14), %r13
setne %cl
movabsq $0x7fffffff7fffffff, %rdx # imm = 0x7FFFFFFF7FFFFFFF
cmpq %rdx, %r13
setl %dl
andb %cl, %dl
movzbl %dl, %ecx
leal (%rax,%rcx,2), %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: faidx_fetch_seq
char *faidx_fetch_seq(const faidx_t *fai, const char *c_name, int p_beg_i, int p_end_i, int *len)
{
    hts_pos_t len64;
    char *ret = faidx_fetch_seq64(fai, c_name, p_beg_i, p_end_i, &len64);
    *len = len64 < INT_MAX ? len64 : INT_MAX;  // trunc
    return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %r8, %rbx
movslq %edx, %rdx
movslq %ecx, %rcx
movq %rsp, %r14
movq %r14, %r8
callq 0x85892
movq (%r14), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
cmovlq %rcx, %rdx
movl %edx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: faidx_fetch_qual
char *faidx_fetch_qual(const faidx_t *fai, const char *c_name, int p_beg_i, int p_end_i, int *len)
{
    hts_pos_t len64;
    char *ret = faidx_fetch_qual64(fai, c_name, p_beg_i, p_end_i, &len64);
    *len = len64 < INT_MAX ? len64 : INT_MAX;  // trunc
    return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %r8, %rbx
movslq %edx, %rdx
movslq %ecx, %rcx
movq %rsp, %r14
movq %r14, %r8
callq 0x8592a
movq (%r14), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
cmovlq %rcx, %rdx
movl %edx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: fai_path
char *fai_path(const char *fa) {
    char *fai = NULL;
    if (!fa) {
        hts_log_error("No reference file specified");
    } else {
        char *fai_tmp = strstr(fa, HTS_IDX_DELIM);
        if (fai_tmp) {
            fai_tmp += strlen(HTS_IDX_DELIM);
            fai = strdup(fai_tmp);
            if (!fai)
                hts_log_error("Failed to allocate memory");
        } else {
            if (hisremote(fa)) {
                fai = hts_idx_locatefn(fa, ".fai");       // get the remote fai file name, if any, but do not download the file
                if (!fai)
                    hts_log_error("Failed to locate index file for remote reference file '%s'", fa);
            } else{
                if (hts_idx_check_local(fa, HTS_FMT_FAI, &fai) == 0 && fai) {
                    if (fai_build3(fa, fai, NULL) == -1) {      // create local fai file by indexing local fasta
                        hts_log_error("Failed to build index file for reference file '%s'", fa);
                        free(fai);
                        fai = NULL;
                    }
                }
            }
        }
    }

    return fai;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq $0x0, (%rsp)
testq %rdi, %rdi
je 0x85c5b
movq %rdi, %rbx
leaq 0x13214(%rip), %rsi     # 0x98e40
callq 0x40e0
testq %rax, %rax
je 0x85c81
addq $0x7, %rax
movq %rax, %rdi
callq 0x4930
movq %rax, (%rsp)
testq %rax, %rax
jne 0x85c75
leaq 0x1e14f(%rip), %rsi     # 0xa3da1
leaq 0x1e16d(%rip), %rdx     # 0xa3dc6
jmp 0x85c69
leaq 0x1e13f(%rip), %rsi     # 0xa3da1
leaq 0x1e141(%rip), %rdx     # 0xa3daa
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x103cd
testl %eax, %eax
je 0x85cc4
leaq 0x18731(%rip), %rsi     # 0x9e3c5
movq %rbx, %rdi
callq 0x1b7df
movq %rax, (%rsp)
testq %rax, %rax
jne 0x85c75
leaq 0x1e0f5(%rip), %rsi     # 0xa3da1
leaq 0x1e12d(%rip), %rdx     # 0xa3de0
movl $0x1, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x14378
jmp 0x85c75
movq %rsp, %r14
movq %rbx, %rdi
movl $0x4, %esi
movq %r14, %rdx
callq 0x1b3b7
testl %eax, %eax
sete %al
movq (%r14), %rsi
testq %rsi, %rsi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x85c75
movq %rbx, %rdi
xorl %edx, %edx
callq 0x839ee
cmpl $-0x1, %eax
jne 0x85c75
leaq 0x1e09b(%rip), %rsi     # 0xa3da1
leaq 0x1e10e(%rip), %rdx     # 0xa3e1b
movl $0x1, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x14378
movq (%rsp), %rdi
callq 0x45c0
movq $0x0, (%rsp)
jmp 0x85c75
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_free
void sam_hrecs_free(sam_hrecs_t *hrecs) {
    if (!hrecs)
        return;

    if (hrecs->h)
        kh_destroy(sam_hrecs_t, hrecs->h);

    if (hrecs->ref_hash)
        kh_destroy(m_s2i, hrecs->ref_hash);

    if (hrecs->ref)
        free(hrecs->ref);

    if (hrecs->rg_hash)
        kh_destroy(m_s2i, hrecs->rg_hash);

    if (hrecs->rg)
        free(hrecs->rg);

    if (hrecs->pg_hash)
        kh_destroy(m_s2i, hrecs->pg_hash);

    if (hrecs->pg)
        free(hrecs->pg);

    if (hrecs->pg_end)
        free(hrecs->pg_end);

    if (hrecs->type_pool)
        pool_destroy(hrecs->type_pool);

    if (hrecs->tag_pool)
        pool_destroy(hrecs->tag_pool);

    if (hrecs->str_pool)
        string_pool_destroy(hrecs->str_pool);

    if (hrecs->type_order)
        free(hrecs->type_order);

    if (hrecs->ID_buf)
        free(hrecs->ID_buf);

    free(hrecs);
}

// Assembly:
testq %rdi, %rdi
je 0x86e20
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
testq %r14, %r14
je 0x86d09
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x38(%rbx), %r14
testq %r14, %r14
je 0x86d35
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x86d43
callq 0x45c0
movq 0x50(%rbx), %r14
testq %r14, %r14
je 0x86d6f
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x86d7d
callq 0x45c0
movq 0x70(%rbx), %r14
testq %r14, %r14
je 0x86da9
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x86db7
callq 0x45c0
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x86dc5
callq 0x45c0
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x86dd3
callq 0x5a7dd
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x86de1
callq 0x5a7dd
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x86def
callq 0x5a947
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0x86e00
callq 0x45c0
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
je 0x86e11
callq 0x45c0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x45c0
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: rebuild_target_arrays
static int rebuild_target_arrays(sam_hdr_t *bh) {
    if (!bh || !bh->hrecs)
        return -1;

    sam_hrecs_t *hrecs = bh->hrecs;
    if (hrecs->refs_changed < 0)
        return 0;

    if (sam_hdr_update_target_arrays(bh, hrecs, hrecs->refs_changed) != 0)
        return -1;

    hrecs->refs_changed = -1;
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x87301
movq 0x38(%rdi), %r14
testq %r14, %r14
je 0x87301
movl 0x94(%r14), %edx
testl %edx, %edx
js 0x872ff
movq %r14, %rsi
callq 0x86410
testl %eax, %eax
jne 0x87301
movl $0xffffffff, 0x94(%r14) # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_rebuild
int sam_hdr_rebuild(sam_hdr_t *bh) {
    sam_hrecs_t *hrecs;
    if (!bh)
        return -1;

    if (!(hrecs = bh->hrecs))
        return bh->text ? 0 : -1;

    if (hrecs->refs_changed >= 0) {
        if (rebuild_target_arrays(bh) < 0) {
            hts_log_error("Header target array rebuild has failed");
            return -1;
        }
    }

    /* If header text wasn't changed or header is empty, don't rebuild it. */
    if (!hrecs->dirty)
        return 0;

    if (hrecs->pgs_changed && sam_hdr_link_pg(bh) < 0) {
        hts_log_error("Linking @PG lines has failed");
        return -1;
    }

    kstring_t ks = KS_INITIALIZE;
    if (sam_hrecs_rebuild_text(hrecs, &ks) != 0) {
        ks_free(&ks);
        hts_log_error("Header text rebuild has failed");
        return -1;
    }

    hrecs->dirty = 0;

    /* Sync */
    free(bh->text);
    bh->l_text = ks_len(&ks);
    bh->text = ks_release(&ks);

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x87466
movq %rdi, %r14
movq 0x38(%rdi), %r15
testq %r15, %r15
je 0x873f8
cmpl $0x0, 0x94(%r15)
js 0x87378
movq %r14, %rdi
callq 0x872c6
testl %eax, %eax
js 0x87403
cmpl $0x0, 0x90(%r15)
je 0x87448
cmpl $0x0, 0x98(%r15)
je 0x873a0
movq %r14, %rdi
callq 0x874af
testl %eax, %eax
js 0x8744c
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movq %r15, %rdi
callq 0x87816
testl %eax, %eax
je 0x87413
movq 0x10(%rsp), %rdi
callq 0x45c0
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x1d1ca(%rip), %rsi     # 0xa45a8
leaq 0x1d217(%rip), %rdx     # 0xa45fc
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x87466
xorl %ebx, %ebx
cmpq $0x1, 0x28(%r14)
sbbl %ebx, %ebx
jmp 0x87466
leaq 0x1d19e(%rip), %rsi     # 0xa45a8
leaq 0x1d1a7(%rip), %rdx     # 0xa45b8
jmp 0x8745a
movl $0x0, 0x90(%r15)
movq 0x28(%r14), %rdi
callq 0x45c0
movq (%rsp), %rax
movq %rax, 0x8(%r14)
movq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %rax, 0x28(%r14)
xorl %ebx, %ebx
jmp 0x87466
leaq 0x1d155(%rip), %rsi     # 0xa45a8
leaq 0x1d185(%rip), %rdx     # 0xa45df
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_rebuild_text
int sam_hrecs_rebuild_text(const sam_hrecs_t *hrecs, kstring_t *ks) {
    ks->l = 0;

    if (!hrecs->h || !hrecs->h->size) {
        return kputsn("", 0, ks) >= 0 ? 0 : -1;
    }
    if (sam_hrecs_rebuild_lines(hrecs, ks) != 0)
        return -1;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq $0x0, (%rsi)
movq (%rdi), %rax
testq %rax, %rax
je 0x878d5
cmpl $0x0, 0x4(%rax)
je 0x878d5
movq 0x8(%rdi), %r12
testq %r12, %r12
je 0x87900
xorl %r13d, %r13d
movq %r12, %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %rbx, %rsi
callq 0x88448
testl %eax, %eax
jne 0x87931
movq (%rbx), %rax
addq $0x2, %rax
cmpq %rax, 0x8(%rbx)
jae 0x878ad
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r15
shrq %r15
testq %rcx, %rcx
cmovneq %r13, %r15
addq %rax, %r15
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x4840
testq %rax, %rax
je 0x87931
movq %rax, 0x10(%rbx)
movq %r15, 0x8(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0xa, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%r14), %r14
cmpq %r12, %r14
jne 0x87859
jmp 0x8792f
cmpq $0x1, 0x8(%rbx)
ja 0x87924
movq 0x10(%rbx), %rdi
movl $0x3, %esi
callq 0x4840
testq %rax, %rax
je 0x8791d
leaq 0x8(%rbx), %r14
movq %rax, 0x10(%rbx)
movq $0x3, (%r14)
jmp 0x87924
leaq 0x8(%rbx), %r14
cmpq $0x1, (%r14)
ja 0x87924
movq 0x10(%rbx), %rdi
movl $0x3, %esi
callq 0x4840
testq %rax, %rax
jne 0x878f3
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x87931
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_add_lines
int sam_hdr_add_lines(sam_hdr_t *bh, const char *lines, size_t len) {
    sam_hrecs_t *hrecs;

    if (!bh || !lines)
        return -1;

    if (len == 0 && *lines == '\0')
        return 0;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -1;
        hrecs = bh->hrecs;
    }

    if (sam_hrecs_parse_lines(hrecs, lines, len) != 0)
        return -1;

    if (hrecs->refs_changed >= 0 && rebuild_target_arrays(bh) != 0)
        return -1;

    hrecs->dirty = 1;
    redact_header_text(bh);

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x879c9
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
testq %rdx, %rdx
jne 0x87975
cmpb $0x0, (%r12)
je 0x879b9
movq 0x38(%r14), %r13
testq %r13, %r13
je 0x879bd
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x86e21
testl %eax, %eax
jne 0x879c9
cmpl $0x0, 0x94(%r13)
js 0x879a6
movq %r14, %rdi
callq 0x872c6
testl %eax, %eax
jne 0x879c9
movl $0x1, 0x90(%r13)
movq %r14, %rdi
callq 0x879db
xorl %ebx, %ebx
jmp 0x879c9
movq %r14, %rdi
callq 0x866a8
testl %eax, %eax
je 0x879d5
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x38(%r14), %r13
jmp 0x8797e
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: redact_header_text
static void redact_header_text(sam_hdr_t *bh) {
    assert(bh->hrecs && bh->hrecs->dirty);
    bh->l_text = 0;
    free(bh->text);
    bh->text = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x87a10
cmpl $0x0, 0x90(%rax)
je 0x87a10
movq %rdi, %rbx
xorl %r14d, %r14d
movq %r14, 0x8(%rdi)
movq 0x28(%rdi), %rdi
callq 0x45c0
movq %r14, 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x1d19a(%rip), %rdi     # 0xa4bb1
leaq 0x1ccce(%rip), %rsi     # 0xa46ec
leaq 0x1d1aa(%rip), %rcx     # 0xa4bcf
movl $0x492, %edx            # imm = 0x492
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_add_line
int sam_hdr_add_line(sam_hdr_t *bh, const char *type, ...) {
    va_list args;
    sam_hrecs_t *hrecs;

    if (!bh || !type)
        return -1;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -1;
        hrecs = bh->hrecs;
    }

    va_start(args, type);
    int ret = sam_hrecs_vadd(hrecs, type, args, NULL);
    va_end(args);

    if (ret == 0) {
        if (hrecs->refs_changed >= 0 && rebuild_target_arrays(bh) != 0)
            return -1;

        if (hrecs->dirty)
            redact_header_text(bh);
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x87a8b
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x87b17
movq %rsi, %r14
movq %rdi, %rbx
movq 0x38(%rdi), %r15
testq %r15, %r15
je 0x87aef
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0x100(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x87b3b
movl %eax, %r14d
testl %eax, %eax
je 0x87b01
movl %r14d, %ebp
jmp 0x87b17
movq %rbx, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x87b17
movq 0x38(%rbx), %r15
jmp 0x87aaf
cmpl $0x0, 0x94(%r15)
js 0x87b27
movq %rbx, %rdi
callq 0x872c6
testl %eax, %eax
je 0x87b27
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x90(%r15)
je 0x87aea
movq %rbx, %rdi
callq 0x879db
jmp 0x87aea
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_find_line_id
int sam_hdr_find_line_id(sam_hdr_t *bh, const char *type,
                      const char *ID_key, const char *ID_val, kstring_t *ks) {
    sam_hrecs_t *hrecs;
    if (!bh || !type)
        return -2;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -2;
        hrecs = bh->hrecs;
    }

    sam_hrec_type_t *ty = sam_hrecs_find_type_id(hrecs, type, ID_key, ID_val);
    if (!ty)
        return -1;

    ks->l = 0;
    if (build_header_line(ty, ks) < 0) {
        return -2;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
orb %al, %cl
jne 0x881df
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x881c8
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x881f0
testq %rax, %rax
je 0x881da
movq $0x0, (%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x88448
xorl %ebp, %ebp
jmp 0x881df
movq %r13, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x881df
movq 0x38(%r13), %rdi
jmp 0x8819f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_find_line_pos
int sam_hdr_find_line_pos(sam_hdr_t *bh, const char *type,
                          int pos, kstring_t *ks) {
    sam_hrecs_t *hrecs;
    if (!bh || !type)
        return -2;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -2;
        hrecs = bh->hrecs;
    }

    sam_hrec_type_t *ty = sam_hrecs_find_type_pos(hrecs, type, pos);
    if (!ty)
        return -1;

    ks->l = 0;
    if (build_header_line(ty, ks) < 0) {
        return -2;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xfffffffe, %r15d      # imm = 0xFFFFFFFE
orb %al, %cl
jne 0x886f4
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x886db
movq %r14, %rsi
movl %ebp, %edx
callq 0x88700
testq %rax, %rax
je 0x886ee
movq $0x0, (%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x88448
xorl %r15d, %r15d
jmp 0x886f4
movq %r12, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x886f4
movq 0x38(%r12), %rdi
jmp 0x886b5
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_find_type_pos
static sam_hrec_type_t *sam_hrecs_find_type_pos(sam_hrecs_t *hrecs,
                                                const char *type, int idx) {
    sam_hrec_type_t *first, *itr;

    if (idx < 0)
        return NULL;

    if (type[0] == 'S' && type[1] == 'Q')
        return idx < hrecs->nref ? hrecs->ref[idx].ty : NULL;

    if (type[0] == 'R' && type[1] == 'G')
        return idx < hrecs->nrg ? hrecs->rg[idx].ty : NULL;

    if (type[0] == 'P' && type[1] == 'G')
        return idx < hrecs->npg ? hrecs->pg[idx].ty : NULL;

    first = itr = sam_hrecs_find_type_id(hrecs, type, NULL, NULL);
    if (!first)
        return NULL;

    while (idx > 0) {
        itr = itr->next;
        if (itr == first)
            break;
        --idx;
    }

    return idx == 0 ? itr : NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testl %edx, %edx
js 0x88782
movl %edx, %ebx
movzbl (%rsi), %eax
cmpl $0x50, %eax
je 0x88766
cmpl $0x52, %eax
je 0x88745
cmpl $0x53, %eax
jne 0x88787
cmpb $0x51, 0x1(%rsi)
jne 0x8873b
cmpl %ebx, 0x28(%rdi)
jle 0x88782
movq 0x30(%rdi), %rax
movl %ebx, %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0x10(%rax,%rcx,8), %r14
jmp 0x887cb
cmpl $0x50, %eax
je 0x88766
cmpl $0x52, %eax
jne 0x88787
cmpb $0x47, 0x1(%rsi)
jne 0x88761
cmpl %ebx, 0x40(%rdi)
jle 0x88782
movq 0x48(%rdi), %rax
movl %ebx, %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %r14
jmp 0x887cb
cmpl $0x50, %eax
jne 0x88787
cmpb $0x47, 0x1(%rsi)
jne 0x88787
cmpl %ebx, 0x58(%rdi)
jle 0x88782
movq 0x68(%rdi), %rax
movl %ebx, %ecx
shlq $0x5, %rcx
movq 0x8(%rax,%rcx), %r14
jmp 0x887cb
xorl %r14d, %r14d
jmp 0x887cb
xorl %r14d, %r14d
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x881f0
testq %rax, %rax
je 0x887cb
testl %ebx, %ebx
je 0x887c8
movl $0x1, %edx
cmovlel %ebx, %edx
decl %edx
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0x887bd
leal -0x1(%rbx), %esi
cmpl $0x1, %ebx
movl %esi, %ebx
jg 0x887a9
movl %edx, %ebx
xorl %r14d, %r14d
testl %ebx, %ebx
cmoveq %rcx, %r14
jmp 0x887cb
movq %rax, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_remove_line_id
int sam_hdr_remove_line_id(sam_hdr_t *bh, const char *type, const char *ID_key, const char *ID_value) {
    sam_hrecs_t *hrecs;
    if (!bh || !type)
        return -1;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -1;
        hrecs = bh->hrecs;
    }

    if (!strncmp(type, "PG", 2)) {
        hts_log_warning("Removing PG lines is not supported!");
        return -1;
    }

    sam_hrec_type_t *type_found = sam_hrecs_find_type_id(hrecs, type, ID_key, ID_value);
    if (!type_found)
        return 0;

    int ret = sam_hrecs_remove_line(hrecs, type, type_found, 1);
    if (ret == 0) {
        if (hrecs->refs_changed >= 0 && rebuild_target_arrays(bh) != 0)
            return -1;

        if (hrecs->dirty)
            redact_header_text(bh);
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r13
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x8888a
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r14
movq 0x38(%rdi), %r15
testq %r15, %r15
je 0x8885a
leaq 0x1be05(%rip), %rsi     # 0xa461b
movl $0x2, %edx
movq %r12, %rdi
callq 0x4210
testl %eax, %eax
je 0x8886c
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x881f0
testq %rax, %rax
je 0x88888
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x888c5
movl %eax, %ebp
testl %eax, %eax
je 0x8889b
movl %ebp, %ebx
jmp 0x8888a
movq %r14, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x8888a
movq 0x38(%r14), %r15
jmp 0x8880f
leaq 0x1bdab(%rip), %rsi     # 0xa461e
leaq 0x1bdbb(%rip), %rdx     # 0xa4635
movl $0x3, %edi
xorl %eax, %eax
callq 0x14378
jmp 0x8888a
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x94(%r15)
js 0x888b1
movq %r14, %rdi
callq 0x872c6
testl %eax, %eax
jne 0x8888a
cmpl $0x0, 0x90(%r15)
je 0x88856
movq %r14, %rdi
callq 0x879db
jmp 0x88856
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hdr_remove_line_pos
int sam_hdr_remove_line_pos(sam_hdr_t *bh, const char *type, int position) {
    sam_hrecs_t *hrecs;
    if (!bh || !type || position < 0)
        return -1;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -1;
        hrecs = bh->hrecs;
    }

    if (!strncmp(type, "PG", 2)) {
        hts_log_warning("Removing PG lines is not supported!");
        return -1;
    }

    sam_hrec_type_t *type_found = sam_hrecs_find_type_pos(hrecs, type,
                                                          position);
    if (!type_found)
        return -1;

    int ret = sam_hrecs_remove_line(hrecs, type, type_found, 1);
    if (ret == 0) {
        if (hrecs->refs_changed >= 0 && rebuild_target_arrays(bh) != 0)
            return -1;

        if (hrecs->dirty)
            redact_header_text(bh);
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testl %edx, %edx
sets %al
orb %cl, %al
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x89006
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
movq 0x38(%rdi), %r12
testq %r12, %r12
je 0x88fda
leaq 0x1b681(%rip), %rsi     # 0xa461b
movl $0x2, %edx
movq %r15, %rdi
callq 0x4210
testl %eax, %eax
je 0x88fec
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x88700
testq %rax, %rax
je 0x89006
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x888c5
movl %eax, %ebp
testl %eax, %eax
je 0x89011
movl %ebp, %ebx
jmp 0x89006
movq %r14, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x89006
movq 0x38(%r14), %r12
jmp 0x88f93
leaq 0x1b666(%rip), %rsi     # 0xa4659
leaq 0x1b63b(%rip), %rdx     # 0xa4635
movl $0x3, %edi
xorl %eax, %eax
callq 0x14378
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x94(%r12)
js 0x89028
movq %r14, %rdi
callq 0x872c6
testl %eax, %eax
jne 0x89006
cmpl $0x0, 0x90(%r12)
je 0x88fd6
movq %r14, %rdi
callq 0x879db
jmp 0x88fd6
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_find_key
sam_hrec_tag_t *sam_hrecs_find_key(sam_hrec_type_t *type,
                                   const char *key,
                                   sam_hrec_tag_t **prev) {
    sam_hrec_tag_t *tag, *p = NULL;
    if (!type)
        return NULL;

    for (tag = type->tag; tag; p = tag, tag = tag->next) {
        if (tag->str[0] == key[0] && tag->str[1] == key[1]) {
            if (prev)
                *prev = p;
            return tag;
        }
    }

    if (prev)
        *prev = p;

    return NULL;
}

// Assembly:
testq %rdi, %rdi
je 0x89a41
movq 0x20(%rdi), %r8
testq %r8, %r8
je 0x89a44
movb (%rsi), %dil
xorl %ecx, %ecx
movq %r8, %rax
movq 0x8(%r8), %r8
cmpb %dil, (%r8)
jne 0x89a34
movb 0x1(%r8), %r8b
cmpb 0x1(%rsi), %r8b
je 0x89a4e
movq (%rax), %r8
movq %rax, %rcx
testq %r8, %r8
jne 0x89a1e
jmp 0x89a46
xorl %eax, %eax
retq
xorl %eax, %eax
movq %rax, %rcx
movl $0x0, %eax
testq %rdx, %rdx
je 0x89a43
movq %rcx, (%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: rebuild_hash
static int rebuild_hash(sam_hrecs_t *hrecs, const char *type) {
    sam_hrec_type_t *head, *step;
    khiter_t k;

    if (strncmp(type, "SQ", 2) == 0) {
        hrecs->nref = 0;
        kh_clear(m_s2i, hrecs->ref_hash);
    } else if (strncmp(type, "RG", 2) == 0) {
        hrecs->nrg = 0;
        kh_clear(m_s2i, hrecs->rg_hash);
    }

    k = kh_get(sam_hrecs_t, hrecs->h, TYPEKEY(type));

    if (k != kh_end(hrecs->h)) { // something to rebuild
        head = kh_val(hrecs->h, k);
        step = head;

        do {
            if (sam_hrecs_update_hashes(hrecs, TYPEKEY(type), step) == -1) {
                hts_log_error("Unable to rebuild hashes");
                return -1;
            }

            step = step->next;
        } while (step != head);
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x106b4(%rip), %rsi     # 0x9b1bb
movl $0x2, %edx
movq %rbx, %rdi
callq 0x4210
testl %eax, %eax
je 0x8ab3e
leaq 0x105c6(%rip), %rsi     # 0x9b0e5
movl $0x2, %edx
movq %rbx, %rdi
callq 0x4210
testl %eax, %eax
jne 0x8ab80
movl $0x0, 0x40(%r14)
movq 0x50(%r14), %r15
jmp 0x8ab4a
movl $0x0, 0x28(%r14)
movq 0x38(%r14), %r15
testq %r15, %r15
je 0x8ab80
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x8ab80
movl (%r15), %eax
movl %eax, %ecx
shrl $0x2, %ecx
andl $-0x4, %ecx
cmpl $0x10, %eax
movl $0x4, %edx
cmovael %ecx, %edx
movl $0xaa, %esi
callq 0x4260
movq $0x0, 0x4(%r15)
movq (%r14), %rax
movl (%rax), %edx
xorl %ebp, %ebp
movl $0x0, %esi
testl %edx, %edx
je 0x8abfb
movzwl (%rbx), %ecx
rolw $0x8, %cx
movzwl %cx, %edi
leal -0x1(%rdx), %r8d
movl %r8d, %r9d
andl %edi, %r9d
movq 0x10(%rax), %r10
movl $0x1, %r11d
movl %r9d, %esi
movl %esi, %ecx
shrl $0x4, %ecx
movl (%r10,%rcx,4), %r15d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %r15d, %r12d
shrl %cl, %r12d
testb $0x2, %r12b
jne 0x8abf1
testb $0x1, %r12b
jne 0x8abdf
movq 0x18(%rax), %r12
movl %esi, %r13d
cmpl %edi, (%r12,%r13,4)
je 0x8abf1
addl %r11d, %esi
andl %r8d, %esi
incl %r11d
cmpl %r9d, %esi
jne 0x8abb1
movl %edx, %esi
jmp 0x8abfb
shrl %cl, %r15d
testb $0x3, %r15b
cmovnel %edx, %esi
cmpl %edx, %esi
je 0x8ac4f
movq 0x20(%rax), %rax
movl %esi, %ecx
movq (%rax,%rcx,8), %r12
movq %r12, %r15
movzwl (%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x89c4a
cmpl $-0x1, %eax
je 0x8ac30
movq (%r15), %r15
cmpq %r12, %r15
jne 0x8ac0c
jmp 0x8ac4f
leaq 0x1a373(%rip), %rsi     # 0xa4faa
leaq 0x1a379(%rip), %rdx     # 0xa4fb7
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: kh_get_rm
KHASH_SET_INIT_STR(rm)
// Used for long refs in SAM files
KHASH_DECLARE(s2i, kh_cstr_t, int64_t)

typedef khash_t(rm) rmhash_t;

static int sam_hdr_link_pg(sam_hdr_t *bh);

static int sam_hrecs_vupdate(sam_hrecs_t *hrecs, sam_hrec_type_t *type, va_list ap);
static int sam_hrecs_update(sam_hrecs_t *hrecs, sam_hrec_type_t *type, ...);


#define MAX_ERROR_QUOTE 320 // Prevent over-long error messages
static void sam_hrecs_error(const char *msg, const char *line, size_t len, size_t lno) {
    int j;

    if (len > MAX_ERROR_QUOTE)
        len = MAX_ERROR_QUOTE;
    for (j = 0; j < len && line[j] != '\n'; j++)
        ;
    hts_log_error("%s at line %zd: \"%.*s\"", msg, lno, j, line);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movl (%rdi), %eax
testl %eax, %eax
je 0x8b0a4
movq %rsi, %r14
movq %rax, 0x10(%rsp)
leal -0x1(%rax), %edx
movb (%rsi), %cl
testb %cl, %cl
je 0x8b0ab
leaq 0x1(%r14), %rax
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r13d, %ecx
imull $0x1000193, %ecx, %r13d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x8b08c
jmp 0x8b0b1
xorl %eax, %eax
jmp 0x8b136
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
andl %edx, %r13d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r15d
movl %r13d, %ebx
movl %edx, 0xc(%rsp)
movq %rdi, 0x20(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r12d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r12d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x8b125
testb $0x1, %al
jne 0x8b111
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r14, %rsi
callq 0x46c0
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %edx
testl %eax, %eax
je 0x8b125
addl %r15d, %ebx
andl %edx, %ebx
incl %r15d
cmpl %r13d, %ebx
jne 0x8b0cf
movq 0x10(%rsp), %rax
jmp 0x8b136
movl %ebp, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
movq 0x10(%rsp), %rax
cmovel %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq