LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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 0x80da2
movq %rdi, %r14
testl %edx, %edx
je 0x80d60
cmpl $0x2, %edx
je 0x80d55
cmpl $0x1, %edx
jne 0x80daf
callq 0x4050
movl $0x26, (%rax)
jmp 0x80dba
movq 0x48(%r14), %rbx
testq %rbx, %rbx
jns 0x80d62
jmp 0x80da2
movl %edx, %ebx
testq %rsi, %rsi
js 0x80d83
movq 0x48(%r14), %rcx
testq %rcx, %rcx
setns %dl
subq %rbx, %rcx
cmpq %rsi, %rcx
setl %cl
testb %cl, %dl
jne 0x80daf
addq %rsi, %rbx
jmp 0x80d88
addq %rsi, %rbx
js 0x80daf
testb %al, %al
js 0x80dcc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7f86c
testl %eax, %eax
js 0x80da2
orb $-0x80, 0x64(%r14)
jmp 0x80dc1
callq 0x4050
movl $0x1d, (%rax)
jmp 0x80dba
callq 0x4050
movl $0x16, (%rax)
movq $-0x1, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpq $0x0, 0xd0(%r14)
jns 0x80df0
movq 0x28(%r14), %rax
addq 0x10(%r14), %rax
subq (%r14), %rax
movq %rax, 0xd8(%r14)
movq %r14, %rdi
callq 0x80f06
movq %rbx, 0xd0(%r14)
jmp 0x80dc1
// File: /workspace/github_c_makefile_star2_O3/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)
testb $0x4, %al
jne 0x80e3a
movq 0x38(%rbx), %rdi
xorl %esi, %esi
callq 0x4970
testl %eax, %eax
je 0x80e3a
movq 0x38(%rbx), %rdi
movl %eax, %esi
callq 0x7e55c
movl %eax, %ebp
testl %eax, %eax
jne 0x80e5d
testb $0x5, 0x64(%rbx)
jne 0x80e5b
movq %rbx, %rdi
callq 0x7f676
xorl %ebp, %ebp
testl %eax, %eax
jns 0x80e55
callq 0x4050
movl (%rax), %ebp
testl %ebp, %ebp
je 0x80e3a
jmp 0x80e5d
xorl %ebp, %ebp
testb $0x4, 0x64(%rbx)
je 0x80e75
movl 0x60(%rbx), %esi
testl %esi, %esi
je 0x80e75
movq 0x38(%rbx), %rdi
callq 0x7e55c
movl %eax, %ebp
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdi
callq 0x4160
testl %eax, %eax
je 0x80e93
testl %ebp, %ebp
jne 0x80e93
movl %eax, %edi
callq 0x7f626
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 0x80ec3
movq 0x98(%rbx), %rdi
xorl %esi, %esi
callq *%rax
movq %r14, %rdi
movl $0x1, %esi
callq 0x7fb64
leaq 0x80(%rbx), %rdi
movl $0x1, %esi
callq 0x7fb64
movq 0xe0(%rbx), %rdi
callq 0x45c0
testl %ebp, %ebp
je 0x80eff
callq 0x4050
movl %ebp, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x80f01
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x80f3f
movq 0xe0(%rbx), %rdi
testq %rdi, %rdi
je 0x80f43
movq 0x18(%rbx), %r12
movq 0xf0(%rbx), %rax
subq (%rbx), %r12
cmpq %r12, %rax
jb 0x80f4a
jmp 0x80f6b
xorl %eax, %eax
jmp 0x80f86
movq 0x18(%rbx), %r12
subq (%rbx), %r12
movq %r12, %rdi
callq 0x4680
movq %rax, 0xe0(%rbx)
testq %rax, %rax
je 0x80f8d
movq %rax, %rdi
movq %r12, 0xf0(%rbx)
movq %r12, %rax
subq %r14, %r15
cmpq %rax, %r15
ja 0x80f99
movq %r14, %rsi
movq %r15, %rdx
callq 0x43c0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
movq %rax, 0xe8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x2043b(%rip), %rdi     # 0xa13db
leaq 0x203f6(%rip), %rsi     # 0xa139d
leaq 0x20461(%rip), %rcx     # 0xa140f
movl $0x398, %edx            # imm = 0x398
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O3/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 0x81435
addl $0xfffffe0b, %edi       # imm = 0xFFFFFE0B
movl $0x5, %eax
cmpl $0x4, %edi
jae 0x8145e
movl %edi, %eax
leaq 0x1fe1d(%rip), %rcx     # 0xa1250
jmp 0x81458
xorl %eax, %eax
cmpl $0x190, %edi            # imm = 0x190
jl 0x8145e
addl $0xfffffe6f, %edi       # imm = 0xFFFFFE6F
movl $0x16, %eax
cmpl $0xa, %edi
jae 0x8145e
movl %edi, %eax
leaq 0x1fdd0(%rip), %rcx     # 0xa1228
leaq (%rcx,%rax,4), %rax
movl (%rax), %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x814df
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
jle 0x8148e
xorl %r14d, %r14d
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x45c0
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x81475
movq 0x10(%rbx), %rdi
callq 0x45c0
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x814c3
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 0x814d0
callq 0xd3cd
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x45c0
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x82989
testl %eax, %eax
je 0x82f0b
xorl %eax, %eax
jmp 0x82f28
leaq 0x10(%rsp), %rsi
movq 0x20(%rsi), %rdx
movq 0x8(%rsp), %rcx
movq (%rsp), %r8
movq %r14, %rdi
movq %rbx, %r9
callq 0x82bb7
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x82ee4
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_O3/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 0x8316b
movq %rdi, %r12
testq %rdi, %rdi
je 0x8316b
movq %rdx, %r15
testq %rdx, %rdx
je 0x8316b
movq %rcx, %r14
testq %rcx, %rcx
je 0x8316b
cmpl %esi, 0x8(%r12)
jle 0x8316b
movq (%r15), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %r13
movl %esi, %ebp
movq 0x10(%r12), %rax
movq 0x18(%r12), %rdi
movq (%rax,%rbp,8), %rcx
movq $0x0, (%rsp)
xorl %esi, %esi
xorl %edx, %edx
movq %r15, %r8
movq %r14, %r9
callq 0x8317c
testl %eax, %eax
je 0x83140
movq 0x10(%r12), %rax
movq (%rax,%rbp,8), %rcx
leaq 0x1e3bd(%rip), %rsi     # 0xa14e8
leaq 0x1e3c8(%rip), %rdx     # 0xa14fa
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x8316b
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_O3/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 0x8371c
movq %rdi, %rbx
leaq 0x127ef(%rip), %rsi     # 0x95ee0
callq 0x40e0
testq %rax, %rax
je 0x8373b
addq $0x7, %rax
movq %rax, %rdi
callq 0x4930
testq %rax, %rax
jne 0x8375b
leaq 0x1de1e(%rip), %rsi     # 0xa1531
leaq 0x1de3c(%rip), %rdx     # 0xa1556
jmp 0x8372a
leaq 0x1de0e(%rip), %rsi     # 0xa1531
leaq 0x1de10(%rip), %rdx     # 0xa153a
xorl %r14d, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x8375e
movq %rbx, %rdi
callq 0x101ec
testl %eax, %eax
je 0x83769
leaq 0x17e6f(%rip), %rsi     # 0x9b5bd
movq %rbx, %rdi
callq 0x1b292
testq %rax, %rax
je 0x837a9
movq %rax, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rsp, %r14
movq %rbx, %rdi
movl $0x4, %esi
movq %r14, %rdx
callq 0x1ae7b
testl %eax, %eax
sete %al
movq (%r14), %r14
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8375e
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x814e2
cmpl $-0x1, %eax
je 0x837cb
movq (%rsp), %r14
jmp 0x8375e
leaq 0x1dd81(%rip), %rsi     # 0xa1531
leaq 0x1ddb9(%rip), %rdx     # 0xa1570
xorl %r14d, %r14d
movl $0x1, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x13de5
jmp 0x8375e
leaq 0x1dd5f(%rip), %rsi     # 0xa1531
leaq 0x1ddd2(%rip), %rdx     # 0xa15ab
xorl %r14d, %r14d
movl $0x1, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x13de5
movq (%rsp), %rdi
callq 0x45c0
jmp 0x8375e
// File: /workspace/github_c_makefile_star2_O3/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 0x848b5
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
testq %r14, %r14
je 0x8479e
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 0x847ca
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 0x847d8
callq 0x45c0
movq 0x50(%rbx), %r14
testq %r14, %r14
je 0x84804
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 0x84812
callq 0x45c0
movq 0x70(%rbx), %r14
testq %r14, %r14
je 0x8483e
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 0x8484c
callq 0x45c0
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x8485a
callq 0x45c0
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x84868
callq 0x57d65
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x84876
callq 0x57d65
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x84884
callq 0x57ec7
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0x84895
callq 0x45c0
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
je 0x848a6
callq 0x45c0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x45c0
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x84d1d
movq 0x38(%rdi), %r14
testq %r14, %r14
je 0x84d1d
movl 0x94(%r14), %edx
testl %edx, %edx
js 0x84d1b
movq %r14, %rsi
callq 0x83eac
testl %eax, %eax
jne 0x84d1d
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_O3/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 0x84e5e
movq %rdi, %r14
movq 0x38(%rdi), %r15
testq %r15, %r15
je 0x84e00
cmpl $0x0, 0x94(%r15)
js 0x84d90
movq %r14, %rdi
callq 0x84ce2
testl %eax, %eax
js 0x84e0b
cmpl $0x0, 0x90(%r15)
je 0x84e40
cmpl $0x0, 0x98(%r15)
je 0x84db8
movq %r14, %rdi
callq 0x84ea7
testl %eax, %eax
js 0x84e44
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movq %r15, %rdi
callq 0x85247
testl %eax, %eax
je 0x84e1b
movq 0x10(%rsp), %rdi
callq 0x45c0
leaq 0x1cf41(%rip), %rsi     # 0xa1d27
leaq 0x1cf8e(%rip), %rdx     # 0xa1d7b
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x84e5e
xorl %ebx, %ebx
cmpq $0x1, 0x28(%r14)
sbbl %ebx, %ebx
jmp 0x84e5e
leaq 0x1cf15(%rip), %rsi     # 0xa1d27
leaq 0x1cf1e(%rip), %rdx     # 0xa1d37
jmp 0x84e52
movl $0x0, 0x90(%r15)
movq 0x28(%r14), %rdi
callq 0x45c0
movq (%rsp), %rax
movq %rax, 0x8(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x28(%r14)
xorl %ebx, %ebx
jmp 0x84e5e
leaq 0x1cedc(%rip), %rsi     # 0xa1d27
leaq 0x1cf0c(%rip), %rdx     # 0xa1d5e
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x85304
cmpl $0x0, 0x4(%rax)
je 0x85304
movq 0x8(%rdi), %r12
testq %r12, %r12
je 0x85304
xorl %r13d, %r13d
movq %r12, %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %rbx, %rsi
callq 0x85dac
testl %eax, %eax
jne 0x8533c
movq (%rbx), %rcx
leaq 0x2(%rcx), %rax
cmpq %rax, 0x8(%rbx)
jae 0x852df
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 0x8533c
movq %rax, 0x10(%rbx)
movq %r15, 0x8(%rbx)
movq (%rbx), %rcx
jmp 0x852e3
movq 0x10(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movb $0xa, (%rax,%rcx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%r14), %r14
cmpq %r12, %r14
jne 0x8528a
jmp 0x8533a
movq 0x10(%rbx), %rax
cmpq $0x1, 0x8(%rbx)
ja 0x85332
movl $0x3, %esi
movq %rax, %rdi
callq 0x4840
testq %rax, %rax
je 0x8534d
movq %rax, 0x10(%rbx)
movq $0x3, 0x8(%rbx)
movq (%rbx), %rcx
jmp 0x85334
xorl %ecx, %ecx
addq %rcx, %rax
movb $0x0, (%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x8533c
// File: /workspace/github_c_makefile_star2_O3/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 0x853db
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
testq %rdx, %rdx
jne 0x85387
cmpb $0x0, (%r12)
je 0x853cb
movq 0x38(%r14), %r13
testq %r13, %r13
je 0x853cf
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x848b6
testl %eax, %eax
jne 0x853db
cmpl $0x0, 0x94(%r13)
js 0x853b8
movq %r14, %rdi
callq 0x84ce2
testl %eax, %eax
jne 0x853db
movl $0x1, 0x90(%r13)
movq %r14, %rdi
callq 0x853ed
xorl %ebx, %ebx
jmp 0x853db
movq %r14, %rdi
callq 0x8413e
testl %eax, %eax
je 0x853e7
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x38(%r14), %r13
jmp 0x85390
// File: /workspace/github_c_makefile_star2_O3/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 0x85422
cmpl $0x0, 0x90(%rax)
je 0x85422
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 0x1cf07(%rip), %rdi     # 0xa2330
leaq 0x1ca3b(%rip), %rsi     # 0xa1e6b
leaq 0x1cf17(%rip), %rcx     # 0xa234e
movl $0x492, %edx            # imm = 0x492
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O3/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 0x8549d
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 0x8553c
movq %rsi, %r15
movq %rdi, %rbx
movq 0x38(%rdi), %r14
testq %r14, %r14
je 0x85530
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 %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x85555
movl %eax, %ebp
testl %eax, %eax
jne 0x8553c
cmpl $0x0, 0x94(%r14)
js 0x8551a
movq %rbx, %rdi
callq 0x84ce2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x8553c
xorl %ebp, %ebp
cmpl $0x0, 0x90(%r14)
je 0x8553c
movq %rbx, %rdi
callq 0x853ed
jmp 0x8553c
movq %rbx, %rdi
callq 0x8413e
testl %eax, %eax
je 0x8554c
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%rbx), %r14
jmp 0x854c5
// File: /workspace/github_c_makefile_star2_O3/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 0x85b44
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x85b2d
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x85b55
testq %rax, %rax
je 0x85b3f
movq $0x0, (%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x85dac
xorl %ebp, %ebp
jmp 0x85b44
movq %r13, %rdi
callq 0x8413e
testl %eax, %eax
jne 0x85b44
movq 0x38(%r13), %rdi
jmp 0x85b04
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_O3/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 0x86068
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x8604f
movq %r14, %rsi
movl %ebp, %edx
callq 0x86074
testq %rax, %rax
je 0x86062
movq $0x0, (%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x85dac
xorl %r15d, %r15d
jmp 0x86068
movq %r12, %rdi
callq 0x8413e
testl %eax, %eax
jne 0x86068
movq 0x38(%r12), %rdi
jmp 0x86029
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_O3/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 0x860e4
movl %edx, %ebx
movzbl (%rsi), %eax
cmpl $0x50, %eax
je 0x860c8
cmpl $0x52, %eax
je 0x860ac
cmpl $0x53, %eax
jne 0x860e9
cmpb $0x51, 0x1(%rsi)
jne 0x860e9
cmpl %ebx, 0x28(%rdi)
jle 0x860e4
movq 0x30(%rdi), %rax
movl %ebx, %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0x10(%rax,%rcx,8), %r14
jmp 0x86123
cmpb $0x47, 0x1(%rsi)
jne 0x860e9
cmpl %ebx, 0x40(%rdi)
jle 0x860e4
movq 0x48(%rdi), %rax
movl %ebx, %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %r14
jmp 0x86123
cmpb $0x47, 0x1(%rsi)
jne 0x860e9
cmpl %ebx, 0x58(%rdi)
jle 0x860e4
movq 0x68(%rdi), %rax
movl %ebx, %ecx
shlq $0x5, %rcx
movq 0x8(%rax,%rcx), %r14
jmp 0x86123
xorl %r14d, %r14d
jmp 0x86123
xorl %r14d, %r14d
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x85b55
testq %rax, %rax
je 0x86123
testl %ebx, %ebx
je 0x86120
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0x86115
leal -0x1(%rbx), %edx
cmpl $0x1, %ebx
movl %edx, %ebx
jg 0x86101
xorl %ebx, %ebx
xorl %r14d, %r14d
testl %ebx, %ebx
cmoveq %rcx, %r14
jmp 0x86123
movq %rax, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x861fb
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r14
movq 0x38(%rdi), %r15
testq %r15, %r15
je 0x861ef
cmpb $0x50, (%r12)
jne 0x86196
cmpb $0x47, 0x1(%r12)
jne 0x86196
leaq 0x1bc1c(%rip), %rsi     # 0xa1d9d
leaq 0x1bc2c(%rip), %rdx     # 0xa1db4
movl $0x3, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x861fb
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x85b55
testq %rax, %rax
je 0x861eb
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x86215
testl %eax, %eax
jne 0x861fb
cmpl $0x0, 0x94(%r15)
js 0x861d9
movq %r14, %rdi
callq 0x84ce2
testl %eax, %eax
jne 0x861fb
cmpl $0x0, 0x90(%r15)
je 0x861eb
movq %r14, %rdi
callq 0x853ed
xorl %ebx, %ebx
jmp 0x861fb
movq %r14, %rdi
callq 0x8413e
testl %eax, %eax
je 0x8620c
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%r14), %r15
jmp 0x8616b
// File: /workspace/github_c_makefile_star2_O3/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
je 0x868b5
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
movq 0x38(%rdi), %r12
testq %r12, %r12
je 0x86955
cmpb $0x50, (%r15)
jne 0x868f3
cmpb $0x47, 0x1(%r15)
jne 0x868f3
leaq 0x1b4fa(%rip), %rsi     # 0xa1dd8
leaq 0x1b4cf(%rip), %rdx     # 0xa1db4
movl $0x3, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x868aa
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x86074
testq %rax, %rax
je 0x868aa
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x86215
testl %eax, %eax
jne 0x868aa
cmpl $0x0, 0x94(%r12)
js 0x86937
movq %r14, %rdi
callq 0x84ce2
testl %eax, %eax
jne 0x868aa
xorl %ebx, %ebx
cmpl $0x0, 0x90(%r12)
je 0x868aa
movq %r14, %rdi
callq 0x853ed
jmp 0x868aa
movq %r14, %rdi
callq 0x8413e
testl %eax, %eax
jne 0x868aa
movq 0x38(%r14), %r12
jmp 0x868ca
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/header.c
// Function: sam_hrecs_vupdate
int sam_hrecs_vupdate(sam_hrecs_t *hrecs, sam_hrec_type_t *type, va_list ap) {
    if (!hrecs)
        return -1;

    for (;;) {
        char *k, *v, *str;
        sam_hrec_tag_t *tag, *prev = NULL;

        if (!(k = (char *)va_arg(ap, char *)))
            break;
        if (!(v = va_arg(ap, char *)))
            v = "";

        tag = sam_hrecs_find_key(type, k, &prev);
        if (!tag) {
            if (!(tag = pool_alloc(hrecs->tag_pool)))
                return -1;
            if (prev)
                prev->next = tag;
            else
                type->tag = tag;

            tag->next = NULL;
        }

        tag->len = 3 + strlen(v);
        str = string_alloc(hrecs->str_pool, tag->len+1);
        if (!str)
            return -1;

        if (snprintf(str, tag->len+1, "%2.2s:%s", k, v) < 0)
            return -1;

        tag->str = str;
    }

    hrecs->dirty = 1; //mark text as dirty and force a rebuild

    return 0;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x871f3
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rdi, %r15
leaq 0x20(%rsi), %rax
movq %rax, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movl (%r14), %eax
cmpq $0x28, %rax
ja 0x870d5
movq %rax, %rcx
addq 0x10(%r14), %rcx
addl $0x8, %eax
movl %eax, (%r14)
jmp 0x870e1
movq 0x8(%r14), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%r14)
movq (%rcx), %rbp
testq %rbp, %rbp
je 0x871d8
cmpl $0x28, %eax
ja 0x87100
movl %eax, %ecx
addq 0x10(%r14), %rcx
addl $0x8, %eax
movl %eax, (%r14)
jmp 0x8710c
movq 0x8(%r14), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x8(%r14)
movq (%rcx), %rbx
testq %rbx, %rbx
leaq 0xec54(%rip), %rax      # 0x95d6d
cmoveq %rax, %rbx
testq %rsi, %rsi
je 0x87150
movq 0x8(%rsp), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x87150
movb (%rbp), %al
movq %rcx, %r12
movq 0x8(%rcx), %rcx
cmpb %al, (%rcx)
jne 0x87145
movb 0x1(%rcx), %cl
cmpb 0x1(%rbp), %cl
je 0x87178
movq (%r12), %rcx
testq %rcx, %rcx
jne 0x87132
jmp 0x87153
xorl %r12d, %r12d
movq 0x20(%r15), %rdi
callq 0x57daa
testq %rax, %rax
je 0x871d1
testq %r12, %r12
cmoveq 0x8(%rsp), %r12
movq %rax, (%r12)
movq $0x0, (%rax)
movq %rax, %r12
movq %rbx, %rdi
callq 0x41d0
leal 0x3(%rax), %ecx
movl %ecx, 0x10(%r12)
movq 0x10(%r15), %rdi
addl $0x4, %eax
movslq %eax, %rsi
callq 0x57f0c
testq %rax, %rax
je 0x871d1
movq %rax, %r13
movslq 0x10(%r12), %rsi
incq %rsi
movq %rax, %rdi
leaq 0x1b29f(%rip), %rdx     # 0xa2450
movq %rbp, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x4800
testl %eax, %eax
js 0x871d1
movq %r13, 0x8(%r12)
movq 0x10(%rsp), %rsi
jmp 0x870bd
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x871e5
movl $0x1, 0x90(%r15)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x87317
movq 0x20(%rdi), %r8
testq %r8, %r8
je 0x8731a
movb (%rsi), %dil
xorl %ecx, %ecx
movq %r8, %rax
movq 0x8(%r8), %r8
cmpb %dil, (%r8)
jne 0x8730a
movb 0x1(%r8), %r8b
cmpb 0x1(%rsi), %r8b
je 0x87324
movq (%rax), %r8
movq %rax, %rcx
testq %r8, %r8
jne 0x872f4
jmp 0x8731c
xorl %eax, %eax
retq
xorl %eax, %eax
movq %rax, %rcx
movl $0x0, %eax
testq %rdx, %rdx
je 0x87319
movq %rcx, (%rdx)
retq
// File: /workspace/github_c_makefile_star2_O3/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
movzbl (%rsi), %eax
cmpl $0x52, %eax
je 0x882ec
cmpl $0x53, %eax
jne 0x88334
cmpb $0x51, 0x1(%rbx)
jne 0x88334
movl $0x0, 0x28(%r14)
movq 0x38(%r14), %r15
jmp 0x882fe
cmpb $0x47, 0x1(%rbx)
jne 0x88334
movl $0x0, 0x40(%r14)
movq 0x50(%r14), %r15
testq %r15, %r15
je 0x88334
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x88334
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 0x883af
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 0x883a5
testb $0x1, %r12b
jne 0x88393
movq 0x18(%rax), %r12
movl %esi, %r13d
cmpl %edi, (%r12,%r13,4)
je 0x883a5
addl %r11d, %esi
andl %r8d, %esi
incl %r11d
cmpl %r9d, %esi
jne 0x88365
xorl %ebp, %ebp
jmp 0x88403
shrl %cl, %r15d
testb $0x3, %r15b
cmovnel %edx, %esi
cmpl %edx, %esi
je 0x88403
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 0x8753f
cmpl $-0x1, %eax
je 0x883e4
movq (%r15), %r15
cmpq %r12, %r15
jne 0x883c0
jmp 0x88403
leaq 0x1a33e(%rip), %rsi     # 0xa2729
leaq 0x1a344(%rip), %rdx     # 0xa2736
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
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_O3/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 0x88825
movq %rsi, %r14
movq %rax, 0x10(%rsp)
leal -0x1(%rax), %edx
movb (%rsi), %cl
testb %cl, %cl
je 0x8882c
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 0x8880d
jmp 0x88832
xorl %eax, %eax
jmp 0x888b7
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 0x888a6
testb $0x1, %al
jne 0x88892
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 0x888a6
addl %r15d, %ebx
andl %edx, %ebx
incl %r15d
cmpl %r13d, %ebx
jne 0x88850
movq 0x10(%rsp), %rax
jmp 0x888b7
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
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/header.c
// Function: sam_hdr_count_lines
int sam_hdr_count_lines(sam_hdr_t *bh, const char *type) {
    int count;
    sam_hrec_type_t *first_ty, *itr_ty;

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

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

    // Deal with types that have counts
    switch (type[0]) {
    case 'S':
        if (type[1] == 'Q')
            return bh->hrecs->nref;
        break;
    case 'R':
        if (type[1] == 'G')
            return bh->hrecs->nrg;
        break;
    case 'P':
        if (type[1] == 'G')
            return bh->hrecs->npg;
        break;
    default:
        break;
    }

    first_ty = sam_hrecs_find_type_id(bh->hrecs, type, NULL, NULL);
    if (!first_ty)
        return 0;

    count = 1;
    for (itr_ty = first_ty->next;
         itr_ty && itr_ty != first_ty; itr_ty = itr_ty->next) {
        count++;
    }

    return count;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x88973
movq %rsi, %rbx
movq %rdi, %r15
cmpq $0x0, 0x38(%rdi)
je 0x88914
movzbl (%rbx), %eax
cmpl $0x50, %eax
je 0x88932
cmpl $0x52, %eax
je 0x88922
cmpl $0x53, %eax
jne 0x88945
cmpb $0x51, 0x1(%rbx)
movq 0x38(%r15), %rdi
jne 0x88949
addq $0x28, %rdi
jmp 0x88940
movq %r15, %rdi
callq 0x8413e
testl %eax, %eax
jne 0x88973
jmp 0x888f2
cmpb $0x47, 0x1(%rbx)
movq 0x38(%r15), %rdi
jne 0x88949
addq $0x40, %rdi
jmp 0x88940
cmpb $0x47, 0x1(%rbx)
movq 0x38(%r15), %rdi
jne 0x88949
addq $0x58, %rdi
movl (%rdi), %r14d
jmp 0x88973
movq 0x38(%r15), %rdi
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x85b55
testq %rax, %rax
je 0x88973
xorl %r14d, %r14d
movq %rax, %rcx
movq (%rcx), %rcx
incl %r14d
testq %rcx, %rcx
je 0x88973
cmpq %rax, %rcx
jne 0x88963
movl %r14d, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/header.c
// Function: sam_hdr_line_name
const char *sam_hdr_line_name(sam_hdr_t *bh,
                              const char *type,
                              int pos) {
    sam_hrecs_t *hrecs;
    if (!bh || !type || pos < 0)
        return NULL;

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

    switch (type[0]) {
    case 'S':
        if (type[1] == 'Q') {
            if (pos < hrecs->nref)
                return hrecs->ref[pos].name;
        } else {
            hts_log_warning("Type '%s' not supported. Only @SQ, @RG and @PG lines are indexed", type);
        }
        break;
    case 'R':
        if (type[1] == 'G') {
            if (pos < hrecs->nrg)
                return hrecs->rg[pos].name;
        } else {
            hts_log_warning("Type '%s' not supported. Only @SQ, @RG and @PG lines are indexed", type);
        }
        break;
    case 'P':
        if (type[1] == 'G') {
            if (pos < hrecs->npg)
                return hrecs->pg[pos].name;
        } else {
            hts_log_warning("Type '%s' not supported. Only @SQ, @RG and @PG lines are indexed", type);
        }
        break;
    default:
        hts_log_warning("Type '%s' not supported. Only @SQ, @RG and @PG lines are indexed", type);
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testl %edx, %edx
sets %al
orb %cl, %al
je 0x88d1a
xorl %r14d, %r14d
jmp 0x88db6
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x88d4e
movzbl (%rbx), %ecx
cmpl $0x50, %ecx
je 0x88d7b
cmpl $0x52, %ecx
je 0x88d60
cmpl $0x53, %ecx
jne 0x88d96
cmpb $0x51, 0x1(%rbx)
jne 0x88d96
cmpl %ebp, 0x28(%rax)
jle 0x88d12
movq 0x30(%rax), %rax
jmp 0x88d6f
movq %r14, %rdi
callq 0x8413e
testl %eax, %eax
jne 0x88d12
movq 0x38(%r14), %rax
jmp 0x88d2b
cmpb $0x47, 0x1(%rbx)
jne 0x88d96
cmpl %ebp, 0x40(%rax)
jle 0x88d12
movq 0x48(%rax), %rax
movl %ebp, %ecx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r14
jmp 0x88db6
cmpb $0x47, 0x1(%rbx)
jne 0x88d96
cmpl %ebp, 0x58(%rax)
jle 0x88d12
movq 0x68(%rax), %rax
movl %ebp, %ecx
shlq $0x5, %rcx
movq (%rax,%rcx), %r14
jmp 0x88db6
leaq 0x19236(%rip), %rsi     # 0xa1fd3
leaq 0x191ee(%rip), %rdx     # 0xa1f92
xorl %r14d, %r14d
movl $0x3, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x13de5
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq