LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hread2
ssize_t hread2(hFILE *fp, void *destv, size_t nbytes, size_t nread)
{
    const size_t capacity = fp->limit - fp->buffer;
    char *dest = (char *) destv;
    dest += nread, nbytes -= nread;

    // Read large requests directly into the destination buffer
    while (nbytes * 2 >= capacity && !fp->at_eof) {
        ssize_t n = fp->backend->read(fp, dest, nbytes);
        if (n < 0) { fp->has_errno = errno; return n; }
        else if (n == 0) fp->at_eof = 1;
        fp->offset += n;
        dest += n, nbytes -= n;
        nread += n;
    }

    while (nbytes > 0 && !fp->at_eof) {
        size_t n;
        ssize_t ret = refill_buffer(fp);
        if (ret < 0) return ret;

        n = fp->end - fp->begin;
        if (n > nbytes) n = nbytes;
        memcpy(dest, fp->begin, n);
        fp->begin += n;
        dest += n, nbytes -= n;
        nread += n;
    }

    return nread;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x18(%rdi), %r13
subq (%rdi), %r13
addq %rcx, %r15
subq %rcx, %r14
leaq (%r14,%r14), %rax
cmpq %r13, %rax
jb 0x6b127
testb $0x1, 0x30(%r12)
jne 0x6b127
movq 0x20(%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq *(%rax)
movq %rax, %rbp
testq %rax, %rax
js 0x6b0c0
jne 0x6b0b0
orb $0x1, 0x30(%r12)
addq %rbp, 0x28(%r12)
addq %rbp, %r15
subq %rbp, %r14
addq %rbp, %rbx
jmp 0x6b0d0
callq 0x6060
movl (%rax), %eax
movl %eax, 0x34(%r12)
movq %rbp, (%rsp)
testq %rbp, %rbp
jns 0x6b077
jmp 0x6b130
testb $0x1, 0x30(%r12)
jne 0x6b12c
movq %r12, %rdi
callq 0x6af4c
movq %rax, %rbp
testq %rax, %rax
js 0x6b11e
movq 0x8(%r12), %rsi
movq 0x10(%r12), %r13
subq %rsi, %r13
cmpq %r14, %r13
cmovaeq %r14, %r13
movq %r15, %rdi
movq %r13, %rdx
callq 0x6570
addq %r13, 0x8(%r12)
addq %r13, %r15
subq %r13, %r14
addq %r13, %rbx
jmp 0x6b122
movq %rbp, (%rsp)
testq %rbp, %rbp
js 0x6b130
testq %r14, %r14
jne 0x6b0d7
movq %rbx, (%rsp)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hseek
off_t hseek(hFILE *fp, off_t offset, int whence)
{
    off_t curpos, pos;

    if (writebuffer_is_nonempty(fp)) {
        int ret = flush_buffer(fp);
        if (ret < 0) return ret;
    }

    curpos = htell(fp);

    // Relative offsets are given relative to the hFILE's stream position,
    // which may differ from the backend's physical position due to buffering
    // read-ahead.  Correct for this by converting to an absolute position.
    if (whence == SEEK_CUR) {
        if (curpos + offset < 0) {
            // Either a negative offset resulted in a position before the
            // start of the file, or we overflowed when given a positive offset
            fp->has_errno = errno = (offset < 0)? EINVAL : EOVERFLOW;
            return -1;
        }

        whence = SEEK_SET;
        offset = curpos + offset;
    }

    // TODO Avoid seeking if the desired position is within our read buffer

    pos = fp->backend->seek(fp, offset, whence);
    if (pos < 0) { fp->has_errno = errno; return pos; }

    // Seeking succeeded, so discard any non-empty read buffer
    fp->begin = fp->end = fp->buffer;
    fp->at_eof = 0;

    fp->offset = pos;
    return pos;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rax
cmpq 0x10(%rdi), %rax
jbe 0x6b301
movq %rbx, %rdi
callq 0x6b188
testl %eax, %eax
js 0x6b367
cmpl $0x1, %ebp
jne 0x6b33b
movq 0x28(%rbx), %rsi
addq %r14, %rsi
addq 0x8(%rbx), %rsi
xorl %ebp, %ebp
subq (%rbx), %rsi
jns 0x6b33e
testq %r14, %r14
movl $0x16, %eax
movl $0x4b, %ebp
cmovsl %eax, %ebp
callq 0x6060
movl %ebp, (%rax)
movl %ebp, 0x34(%rbx)
movq $-0x1, %r14
jmp 0x6b376
movq %r14, %rsi
movq 0x20(%rbx), %rax
movq %rbx, %rdi
movl %ebp, %edx
callq *0x10(%rax)
movq %rax, %r14
testq %rax, %rax
js 0x6b36c
movq (%rbx), %rax
movq %rax, 0x10(%rbx)
movq %rax, 0x8(%rbx)
andb $-0x2, 0x30(%rbx)
movq %r14, 0x28(%rbx)
jmp 0x6b376
movslq %eax, %r14
jmp 0x6b376
callq 0x6060
movl (%rax), %eax
movl %eax, 0x34(%rbx)
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hclose
int hclose(hFILE *fp)
{
    int err = fp->has_errno;

    if (writebuffer_is_nonempty(fp) && hflush(fp) < 0) err = fp->has_errno;
    if (fp->backend->close(fp) < 0) err = errno;
    hfile_destroy(fp);

    if (err) {
        errno = err;
        return EOF;
    }
    else return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x34(%rdi), %ebp
movq 0x8(%rdi), %rax
cmpq 0x10(%rdi), %rax
jbe 0x6b3a0
movq %rbx, %rdi
callq 0x6b143
testl %eax, %eax
jns 0x6b3a0
movl 0x34(%rbx), %ebp
movq 0x20(%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
testl %eax, %eax
jns 0x6b3b5
callq 0x6060
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x6aef8
testl %ebp, %ebp
je 0x6b3cf
callq 0x6060
movl %ebp, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6b3d1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hclose_abruptly
void hclose_abruptly(hFILE *fp)
{
    int save = errno;
    if (fp->backend->close(fp) < 0) { /* Ignore subsequent errors */ }
    hfile_destroy(fp);
    errno = save;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x6060
movq %rax, %r14
movl (%rax), %ebp
movq 0x20(%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq %rbx, %rdi
callq 0x6aef8
movl %ebp, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hopen
hFILE *hopen(const char *fname, const char *mode)
{
    const struct hFILE_scheme_handler *handler = find_scheme_handler(fname);
    if (handler) return handler->open(fname, mode);
    else if (strcmp(fname, "-") == 0) return hopen_fd_stdinout(mode);
    else return hopen_fd(fname, mode);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x6b777
testq %rax, %rax
je 0x6b72d
movq (%rax), %rax
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *%rax
leaq 0x288a6(%rip), %rsi     # 0x93fda
movq %r14, %rdi
callq 0x6a50
testl %eax, %eax
je 0x6b752
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6ba25
movq %rbx, %rdi
movl $0x72, %esi
callq 0x6270
xorl %edi, %edi
testq %rax, %rax
sete %dil
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6b403
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: fd_write
static ssize_t fd_write(hFILE *fpv, const void *buffer, size_t nbytes)
{
    hFILE_fd *fp = (hFILE_fd *) fpv;
    ssize_t n;
    do {
        n = fp->is_socket?  send(fp->fd, buffer, nbytes, 0)
                         : write(fp->fd, buffer, nbytes);
    } while (n < 0 && errno == EINTR);
    return n;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
testb $0x1, 0x3c(%r15)
jne 0x6bb5e
movl 0x38(%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6260
jmp 0x6bb6f
movl 0x38(%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x6350
movq %rax, %r12
testq %rax, %rax
jns 0x6bb81
callq 0x6060
cmpl $0x4, (%rax)
je 0x6bb46
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: fd_flush
static int fd_flush(hFILE *fpv)
{
    hFILE_fd *fp = (hFILE_fd *) fpv;
    int ret;
    do {
#ifdef HAVE_FDATASYNC
        ret = fdatasync(fp->fd);
#else
        ret = fsync(fp->fd);
#endif
        // Ignore invalid-for-fsync(2) errors due to being, e.g., a pipe,
        // and operation-not-supported errors (Mac OS X)
        if (ret < 0 && (errno == EINVAL || errno == ENOTSUP)) ret = 0;
    } while (ret < 0 && errno == EINTR);
    return ret;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x38(%rbx), %edi
callq 0x65c0
movl %eax, %ebp
testl %eax, %eax
jns 0x6bbbf
callq 0x6060
movl (%rax), %eax
cmpl $0x5f, %eax
je 0x6bbbd
cmpl $0x16, %eax
jne 0x6bbbf
xorl %ebp, %ebp
testl %ebp, %ebp
jns 0x6bbcd
callq 0x6060
cmpl $0x4, (%rax)
je 0x6bb9e
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hopen_mem
static hFILE *hopen_mem(const char *data, const char *mode)
{
    if (strncmp(data, "data:", 5) == 0) data += 5;

    // TODO Implement write modes, which will require memory allocation
    if (strchr(mode, 'r') == NULL) { errno = EINVAL; return NULL; }

    hFILE_mem *fp = (hFILE_mem *) hfile_init(sizeof (hFILE_mem), mode, 0);
    if (fp == NULL) return NULL;

    fp->buffer = data;
    fp->length = strlen(data);
    fp->pos = 0;
    fp->base.backend = &mem_backend;
    return &fp->base;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x2e1d7(%rip), %rsi     # 0x9a0d8
movl $0x5, %edx
callq 0x6330
xorl %r12d, %r12d
testl %eax, %eax
sete %bpl
movq %r14, %rdi
movl $0x72, %esi
callq 0x6270
testq %rax, %rax
je 0x6bf72
xorl %r15d, %r15d
movl $0x50, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x6ae68
testq %rax, %rax
je 0x6bf80
movq %rax, %r14
movb %bpl, %r12b
leaq (%r12,%r12,4), %rax
addq %rax, %rbx
movq %rbx, 0x38(%r14)
movq %rbx, %rdi
callq 0x62d0
movq %rax, 0x40(%r14)
movq $0x0, 0x48(%r14)
leaq 0x52cbf(%rip), %rax     # 0xbec28
movq %rax, 0x20(%r14)
movq %r14, %r15
jmp 0x6bf80
callq 0x6060
movl $0x16, (%rax)
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hopen_fd_fileuri
static hFILE *hopen_fd_fileuri(const char *url, const char *mode)
{
    if (strncmp(url, "file://localhost/", 17) == 0) url += 16;
    else if (strncmp(url, "file:///", 8) == 0) url += 7;
    else { errno = EPROTONOSUPPORT; return NULL; }

    return hopen_fd(url, mode);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2e141(%rip), %rsi     # 0x9a0de
movl $0x11, %edx
callq 0x6330
testl %eax, %eax
je 0x6bfd8
leaq 0x2e13e(%rip), %rsi     # 0x9a0f0
movl $0x8, %edx
movq %r14, %rdi
callq 0x6330
testl %eax, %eax
je 0x6bfdf
callq 0x6060
movl $0x5d, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x10, %eax
jmp 0x6bfe4
movl $0x7, %eax
addq %rax, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6ba25
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: mem_read
static ssize_t mem_read(hFILE *fpv, void *buffer, size_t nbytes)
{
    hFILE_mem *fp = (hFILE_mem *) fpv;
    size_t avail = fp->length - fp->pos;
    if (nbytes > avail) nbytes = avail;
    memcpy(buffer, fp->buffer + fp->pos, nbytes);
    fp->pos += nbytes;
    return nbytes;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
movq 0x40(%rdi), %r14
movq 0x48(%rdi), %rsi
subq %rsi, %r14
cmpq %rdx, %r14
cmovaeq %rdx, %r14
addq 0x38(%rdi), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x48(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: mem_seek
static off_t mem_seek(hFILE *fpv, off_t offset, int whence)
{
    hFILE_mem *fp = (hFILE_mem *) fpv;
    size_t absoffset = (offset >= 0)? offset : -offset;
    size_t origin;

    switch (whence) {
    case SEEK_SET: origin = 0; break;
    case SEEK_CUR: origin = fp->pos; break;
    case SEEK_END: origin = fp->length; break;
    default: errno = EINVAL; return -1;
    }

    if ((offset  < 0 && absoffset > origin) ||
        (offset >= 0 && absoffset > fp->length - origin)) {
        errno = EINVAL;
        return -1;
    }

    fp->pos = origin + offset;
    return fp->pos;
}

// Assembly:
pushq %rax
movq %rsi, %rcx
negq %rcx
cmovsq %rsi, %rcx
testl %edx, %edx
je 0x6c05e
cmpl $0x1, %edx
je 0x6c053
cmpl $0x2, %edx
jne 0x6c083
movl $0x40, %eax
jmp 0x6c058
movl $0x48, %eax
movq (%rdi,%rax), %rax
jmp 0x6c060
movl %edx, %eax
testq %rsi, %rsi
sets %dl
cmpq %rax, %rcx
seta %r8b
testb %r8b, %dl
jne 0x6c083
testq %rsi, %rsi
js 0x6c097
movq 0x40(%rdi), %rdx
subq %rax, %rdx
cmpq %rdx, %rcx
jbe 0x6c097
callq 0x6060
movl $0x16, (%rax)
movq $-0x1, %rax
jmp 0x6c09e
addq %rsi, %rax
movq %rax, 0x48(%rdi)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile.c
// Function: hfile_exit
static void hfile_exit()
{
    kh_destroy(scheme_string, schemes);

    while (plugins != NULL) {
        struct hFILE_plugin_list *p = plugins;
        if (p->plugin.destroy) p->plugin.destroy();
#ifdef ENABLE_PLUGINS
        if (p->plugin.obj) close_plugin(p->plugin.obj);
#endif
        plugins = p->next;
        free(p);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x68652(%rip), %rbx     # 0xd4700
testq %rbx, %rbx
je 0x6c0d6
movq 0x18(%rbx), %rdi
callq 0x68a0
movq 0x10(%rbx), %rdi
callq 0x68a0
movq 0x20(%rbx), %rdi
callq 0x68a0
movq %rbx, %rdi
callq 0x68a0
movq 0x68653(%rip), %rbx     # 0xd4730
testq %rbx, %rbx
je 0x6c108
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x6c0ed
callq *%rax
movq 0x20(%rbx), %r14
movq %r14, 0x68638(%rip)     # 0xd4730
movq %rbx, %rdi
callq 0x68a0
movq %r14, %rbx
testq %r14, %r14
jne 0x6c0e2
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile_net.c
// Function: hopen_net
hFILE *hopen_net(const char *filename, const char *mode)
{
    hFILE_net *fp;

    // Do any networking initialisation if this is the first use.
    if (! net_inited) { if (net_init() < 0) return NULL; }

    fp = (hFILE_net *) hfile_init(sizeof (hFILE_net), mode, 0);
    if (fp == NULL) return NULL;

    fp->netfp = knet_open(filename, mode);
    if (fp->netfp == NULL) { hfile_destroy((hFILE *) fp); return NULL; }

    fp->base.backend = &net_backend;
    return &fp->base;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x0, 0x68613(%rip)     # 0xd4738
jne 0x6c12e
movb $0x1, 0x6860a(%rip)     # 0xd4738
xorl %r12d, %r12d
movl $0x40, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x6ae68
testq %rax, %rax
je 0x6c177
movq %rax, %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8791c
movq %rax, 0x38(%r15)
testq %rax, %rax
je 0x6c16c
leaq 0x52aed(%rip), %rax     # 0xbec50
movq %rax, 0x20(%r15)
movq %r15, %r12
jmp 0x6c177
movq %r15, %rdi
callq 0x6aef8
xorl %r12d, %r12d
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/hfile_net.c
// Function: hfile_plugin_init_net
int hfile_plugin_init_net(struct hFILE_plugin *self)
{
    static const struct hFILE_scheme_handler handler =
        { hopen_net, hfile_always_remote, "knetfile", 0 };

    self->name = "knetfile";
    hfile_add_scheme_handler("https", &handler);
    hfile_add_scheme_handler("http", &handler);
    hfile_add_scheme_handler("ftp",  &handler);
    return 0;
}

// Assembly:
pushq %rbx
leaq 0x2df41(%rip), %rax     # 0x9a0cf
movq %rax, 0x10(%rdi)
leaq 0x25d0e(%rip), %rdi     # 0x91ea7
leaq 0x52ad8(%rip), %rbx     # 0xbec78
movq %rbx, %rsi
callq 0x6b4ec
leaq 0x25cf3(%rip), %rdi     # 0x91ea2
movq %rbx, %rsi
callq 0x6b4ec
leaq 0x28d97(%rip), %rdi     # 0x94f55
movq %rbx, %rsi
callq 0x6b4ec
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_hdr_destroy
void bam_hdr_destroy(bam_hdr_t *h)
{
    int32_t i;
    if (h == NULL) return;
    if (h->target_name) {
        for (i = 0; i < h->n_targets; ++i)
            free(h->target_name[i]);
        free(h->target_name);
        free(h->target_len);
    }
    free(h->text); free(h->cigar_tab);
    if (h->sdict) kh_destroy(s2i, (sdict_t*)h->sdict);
    free(h);
}

// Assembly:
testq %rdi, %rdi
je 0x6cd17
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x20(%rdi)
je 0x6cce8
cmpl $0x0, (%rbx)
jle 0x6ccd6
xorl %r14d, %r14d
movq 0x20(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x68a0
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x6ccbe
movq 0x20(%rbx), %rdi
callq 0x68a0
movq 0x10(%rbx), %rdi
callq 0x68a0
movq 0x28(%rbx), %rdi
callq 0x68a0
movq 0x18(%rbx), %rdi
callq 0x68a0
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x6cd08
callq 0x4c5b0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x68a0
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_hdr_dup
bam_hdr_t *bam_hdr_dup(const bam_hdr_t *h0)
{
    if (h0 == NULL) return NULL;
    bam_hdr_t *h;
    if ((h = bam_hdr_init()) == NULL) return NULL;
    // copy the simple data
    h->n_targets = h0->n_targets;
    h->ignore_sam_err = h0->ignore_sam_err;
    h->l_text = h0->l_text;
    // Then the pointery stuff
    h->cigar_tab = NULL;
    h->sdict = NULL;
    // TODO Check for memory allocation failures
    h->text = (char*)calloc(h->l_text + 1, 1);
    memcpy(h->text, h0->text, h->l_text);
    h->target_len = (uint32_t*)calloc(h->n_targets, sizeof(uint32_t));
    h->target_name = (char**)calloc(h->n_targets, sizeof(char*));
    int i;
    for (i = 0; i < h->n_targets; ++i) {
        h->target_len[i] = h0->target_len[i];
        h->target_name[i] = strdup(h0->target_name[i]);
    }
    return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x6cdea
movq %rdi, %r15
movl $0x1, %edi
movl $0x38, %esi
callq 0x6470
testq %rax, %rax
je 0x6cdea
movq %rax, %rbx
movslq (%r15), %r14
movl %r14d, (%rax)
movl 0x4(%r15), %eax
movl %eax, 0x4(%rbx)
movl 0x8(%r15), %r12d
movl %r12d, 0x8(%rbx)
xorl %eax, %eax
movq %rax, 0x18(%rbx)
movq %rax, 0x30(%rbx)
leal 0x1(%r12), %edi
movl $0x1, %esi
callq 0x6470
movq %rax, 0x28(%rbx)
movq 0x28(%r15), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x6570
movl $0x4, %esi
movq %r14, %rdi
callq 0x6470
movq %rax, %r12
movq %rax, 0x10(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x6470
movq %rax, 0x20(%rbx)
testq %r14, %r14
jle 0x6cdec
movq %rax, %r13
movq %rbx, (%rsp)
movq 0x10(%r15), %rbp
movq 0x20(%r15), %r15
xorl %ebx, %ebx
movl (%rbp,%rbx,4), %eax
movl %eax, (%r12,%rbx,4)
movq (%r15,%rbx,8), %rdi
callq 0x6dd0
movq %rax, (%r13,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x6cdc6
movq (%rsp), %rbx
jmp 0x6cdec
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_copy1
bam1_t *bam_copy1(bam1_t *bdst, const bam1_t *bsrc)
{
    uint8_t *data = bdst->data;
    int m_data = bdst->m_data;   // backup data and m_data
    if (m_data < bsrc->l_data) { // double the capacity
        m_data = bsrc->l_data; kroundup32(m_data);
        data = (uint8_t*)realloc(data, m_data);
    }
    memcpy(data, bsrc->data, bsrc->l_data); // copy var-len data
    *bdst = *bsrc; // copy the rest
    // restore the backup
    bdst->m_data = m_data;
    bdst->data = data;
    return bdst;
}

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

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x6d422
movq %rdi, %r14
movl $0x1, %edi
movl $0x38, %esi
callq 0x6470
testq %rax, %rax
je 0x6d422
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x6d35d
jmp 0x6d424
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_cigar2qlen
int bam_cigar2qlen(int n_cigar, const uint32_t *cigar)
{
    int k, l;
    for (k = l = 0; k < n_cigar; ++k)
        if (bam_cigar_type(bam_cigar_op(cigar[k]))&1)
            l += bam_cigar_oplen(cigar[k]);
    return l;
}

// Assembly:
testl %edi, %edi
jle 0x6d466
movl %edi, %ecx
xorl %edx, %edx
movl $0x3c1a7, %edi          # imm = 0x3C1A7
xorl %eax, %eax
movl (%rsi,%rdx,4), %r8d
leal (%r8,%r8), %r9d
btl %r9d, %edi
movl $0x0, %r9d
sbbl %r9d, %r9d
shrl $0x4, %r8d
andl %r9d, %r8d
addl %r8d, %eax
incq %rdx
cmpq %rdx, %rcx
jne 0x6d43e
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_cigar2rlen
int bam_cigar2rlen(int n_cigar, const uint32_t *cigar)
{
    int k, l;
    for (k = l = 0; k < n_cigar; ++k)
        if (bam_cigar_type(bam_cigar_op(cigar[k]))&2)
            l += bam_cigar_oplen(cigar[k]);
    return l;
}

// Assembly:
testl %edi, %edi
jle 0x6d49f
movl %edi, %edx
xorl %edi, %edi
xorl %eax, %eax
movl (%rsi,%rdi,4), %r8d
leal (%r8,%r8), %ecx
movl $0x3c1a7, %r9d          # imm = 0x3C1A7
shrl %cl, %r9d
shll $0x1e, %r9d
sarl $0x1f, %r9d
shrl $0x4, %r8d
andl %r9d, %r8d
addl %r8d, %eax
incq %rdi
cmpq %rdi, %rdx
jne 0x6d473
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_endpos
int32_t bam_endpos(const bam1_t *b)
{
    if (!(b->core.flag & BAM_FUNMAP) && b->core.n_cigar > 0)
        return b->core.pos + bam_cigar2rlen(b->core.n_cigar, bam_get_cigar(b));
    else
        return b->core.pos + 1;
}

// Assembly:
movq 0x8(%rdi), %rdx
movq %rdx, %rax
shrq $0x22, %rax
andl $0x1, %eax
movq %rdx, %r8
shrq $0x30, %r8
sete %cl
orb %al, %cl
movl 0x4(%rdi), %esi
je 0x6d4c6
incl %esi
movl %esi, %eax
retq
shrl $0x18, %edx
addq 0x28(%rdi), %rdx
xorl %edi, %edi
xorl %eax, %eax
movl (%rdx,%rdi,4), %r9d
leal (%r9,%r9), %ecx
movl $0x3c1a7, %r10d         # imm = 0x3C1A7
shrl %cl, %r10d
shll $0x1e, %r10d
sarl $0x1f, %r10d
shrl $0x4, %r9d
andl %r10d, %r9d
addl %r9d, %eax
incq %rdi
cmpq %rdi, %r8
jne 0x6d4d1
addl %esi, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_write1
int bam_write1(BGZF *fp, const bam1_t *b)
{
    const bam1_core_t *c = &b->core;
    uint32_t x[8], block_len = b->l_data + 32, y;
    int i, ok;
    x[0] = c->tid;
    x[1] = c->pos;
    x[2] = (uint32_t)c->bin<<16 | c->qual<<8 | c->l_qname;
    x[3] = (uint32_t)c->flag<<16 | c->n_cigar;
    x[4] = c->l_qseq;
    x[5] = c->mtid;
    x[6] = c->mpos;
    x[7] = c->isize;
    ok = (bgzf_flush_try(fp, 4 + block_len) >= 0);
    if (fp->is_be) {
        for (i = 0; i < 8; ++i) ed_swap_4p(x + i);
        y = block_len;
        if (ok) ok = (bgzf_write(fp, ed_swap_4p(&y), 4) >= 0);
        swap_data(c, b->l_data, b->data, 1);
    } else {
        if (ok) ok = (bgzf_write(fp, &block_len, 4) >= 0);
    }
    if (ok) ok = (bgzf_write(fp, x, 32) >= 0);
    if (ok) ok = (bgzf_write(fp, b->data, b->l_data) >= 0);
    if (fp->is_be) swap_data(c, b->l_data, b->data, 0);
    return ok? 4 + block_len : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x20(%rsi), %esi
leal 0x20(%rsi), %eax
movl %eax, 0x8(%rsp)
movl (%rbx), %eax
movl %eax, 0x10(%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0x14(%rsp)
movq 0x8(%rbx), %rax
movl %eax, %ecx
shll $0x10, %ecx
movl %eax, %edx
shrl $0x8, %edx
andl $0xff00, %edx           # imm = 0xFF00
orl %ecx, %edx
movl %eax, %ecx
shrl $0x18, %ecx
orl %edx, %ecx
movl %ecx, 0x18(%rsp)
movq %rax, %rcx
shrq $0x10, %rcx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
shrq $0x30, %rax
orl %ecx, %eax
movl %eax, 0x1c(%rsp)
movl 0x10(%rbx), %eax
movl %eax, 0x20(%rsp)
movl 0x14(%rbx), %eax
movl %eax, 0x24(%rsp)
movl 0x18(%rbx), %eax
movl %eax, 0x28(%rsp)
movl 0x1c(%rbx), %eax
movl %eax, 0x2c(%rsp)
addl $0x24, %esi
callq 0x67fb5
movl %eax, %ebp
notl %ebp
shrl $0x1f, %ebp
testb $0xc, 0x2(%r14)
je 0x6da45
xorl %ecx, %ecx
movl 0x10(%rsp,%rcx,4), %edx
bswapl %edx
movl %edx, 0x10(%rsp,%rcx,4)
incq %rcx
cmpq $0x8, %rcx
jne 0x6d9f1
movl 0x8(%rsp), %ecx
movl %ecx, 0xc(%rsp)
testl %eax, %eax
js 0x6da2f
bswapl %ecx
leaq 0xc(%rsp), %rsi
movl %ecx, (%rsi)
movl $0x4, %edx
movq %r14, %rdi
callq 0x68002
xorl %ebp, %ebp
testq %rax, %rax
setns %bpl
movl 0x20(%rbx), %esi
movq 0x28(%rbx), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x6d6d3
jmp 0x6da64
testl %eax, %eax
js 0x6da64
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x68002
xorl %ebp, %ebp
testq %rax, %rax
setns %bpl
movb $0x1, %r15b
testl %ebp, %ebp
je 0x6da99
leaq 0x10(%rsp), %rsi
movl $0x20, %edx
movq %r14, %rdi
callq 0x68002
testq %rax, %rax
js 0x6da99
movq 0x28(%rbx), %rsi
movslq 0x20(%rbx), %rdx
movq %r14, %rdi
callq 0x68002
movq %rax, %r15
shrq $0x3f, %r15
testb $0xc, 0x2(%r14)
je 0x6dab1
movl 0x20(%rbx), %esi
movq 0x28(%rbx), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6d6d3
movl 0x8(%rsp), %ecx
addl $0x4, %ecx
testb %r15b, %r15b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: sam_index_load2
hts_idx_t *sam_index_load2(htsFile *fp, const char *fn, const char *fnidx)
{
    switch (fp->format.format) {
    case bam:
        return fnidx? hts_idx_load2(fn, fnidx) : hts_idx_load(fn, HTS_FMT_BAI);

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

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

// Assembly:
pushq %rbx
movl 0x44(%rdi), %eax
cmpl $0x6, %eax
je 0x6dd13
cmpl $0x4, %eax
jne 0x6dd42
movq %rsi, %rdi
testq %rdx, %rdx
je 0x6dd46
movq %rdx, %rsi
popq %rbx
jmp 0x51c30
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
callq 0x531b0
testl %eax, %eax
js 0x6dd42
movl $0x10, %edi
callq 0x69d0
testq %rax, %rax
je 0x6dd42
movl $0x3, (%rax)
movq 0x38(%rbx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x6dd44
xorl %eax, %eax
popq %rbx
retq
movl $0x1, %esi
popq %rbx
jmp 0x51bcc
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: sam_itr_queryi
hts_itr_t *sam_itr_queryi(const hts_idx_t *idx, int tid, int beg, int end)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;
    if (idx == NULL)
        return hts_itr_query(NULL, tid, beg, end, sam_bam_cram_readrec);
    else if (cidx->fmt == HTS_FMT_CRAI)
        return cram_itr_query(idx, tid, beg, end, cram_readrec);
    else
        return hts_itr_query(idx, tid, beg, end, bam_readrec);
}

// Assembly:
testq %rdi, %rdi
je 0x6dd6b
cmpl $0x3, (%rdi)
jne 0x6dd79
leaq 0x140(%rip), %r8        # 0x6dea9
jmp 0x6ddb3
leaq 0x13(%rip), %r8         # 0x6dd85
xorl %edi, %edi
jmp 0x50c5b
leaq 0x13e(%rip), %r8        # 0x6debe
jmp 0x50c5b
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: sam_bam_cram_readrec
static int sam_bam_cram_readrec(BGZF *bgzfp, void *fpv, void *bv, int *tid, int *beg, int *end)
{
    htsFile *fp = fpv;
    bam1_t *b = bv;
    switch (fp->format.format) {
    case bam:   return bam_read1(bgzfp, b);
    case cram:  return cram_get_bam_seq(fp->fp.cram, &b);
    default:
        // TODO Need headers available to implement this for SAM files
        fprintf(stderr, "[sam_bam_cram_readrec] Not implemented for SAM files -- Exiting\n");
        abort();
    }
}

// Assembly:
pushq %rax
movq %rdx, (%rsp)
movl 0x44(%rsi), %eax
cmpl $0x6, %eax
je 0x6dda0
cmpl $0x4, %eax
jne 0x6ddae
movq %rdx, %rsi
popq %rax
jmp 0x6d4ff
movq 0x38(%rsi), %rdi
movq %rsp, %rsi
callq 0x7c8e7
popq %rcx
retq
callq 0x7df2
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: cram_itr_query
static hts_itr_t *cram_itr_query(const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;
    hts_itr_t *iter = (hts_itr_t *) calloc(1, sizeof(hts_itr_t));
    if (iter == NULL) return NULL;

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

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

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

        switch (ret) {
        case 0:
            break;

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

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

    return iter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r13
movl %ecx, %r14d
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %r12
movl $0x1, %edi
movl $0x50, %esi
callq 0x6470
testq %rax, %rax
je 0x6de69
movq %rax, %rbx
movl %r14d, %esi
movl (%rax), %r14d
movl %r14d, %eax
orl $0x1, %eax
movl %eax, (%rbx)
xorl %eax, %eax
movq %rax, 0x30(%rbx)
movq %rax, 0x48(%rbx)
movq %r13, 0x38(%rbx)
testl %ebp, %ebp
sets %al
cmpl $-0x2, %ebp
setne %cl
testb %cl, %al
jne 0x6de6d
cmpl $-0x2, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovnel %ebp, %eax
leaq 0xc(%rsp), %rdx
movl %eax, (%rdx)
leal 0x1(%r15), %eax
movl %eax, 0x4(%rdx)
movl %esi, %r13d
movl %esi, 0x8(%rdx)
movq 0x8(%r12), %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0x5cc4b
movq $0x0, 0x28(%rbx)
movl %ebp, 0x4(%rbx)
movl %r15d, 0x8(%rbx)
movl %r13d, 0xc(%rbx)
testl %eax, %eax
je 0x6de90
cmpl $-0x2, %eax
je 0x6de89
movq %rbx, %rdi
callq 0x68a0
xorl %ebx, %ebx
jmp 0x6de90
cmpl $-0x5, %ebp
je 0x6de81
cmpl $-0x4, %ebp
jne 0x6dea2
movq $0x0, 0x28(%rbx)
jmp 0x6de90
movq $0x0, 0x28(%rbx)
orl $0x3, %r14d
movl %r14d, (%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %edi
callq 0x7e14
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_readrec
static int bam_readrec(BGZF *fp, void *ignored, void *bv, int *tid, int *beg, int *end)
{
    bam1_t *b = bv;
    int ret;
    if ((ret = bam_read1(fp, b)) >= 0) {
        *tid = b->core.tid;
        *beg = b->core.pos;
        *end = bam_endpos(b);
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r9, %rbx
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r14
movq %rdx, %rsi
callq 0x6d4ff
movl %eax, %ebp
testl %eax, %eax
js 0x6def8
movl (%r14), %eax
movl %eax, (%r12)
movl 0x4(%r14), %eax
movl %eax, (%r15)
movq %r14, %rdi
callq 0x6d4a2
movl %eax, (%rbx)
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/./htslib/kstring.h
// Function: kputsn_
static inline int kputsn_(const void *p, int l, kstring_t *s)
{
	if (s->l + l > s->m) {
		char *tmp;
		s->m = s->l + l;
		kroundup32(s->m);
		if ((tmp = (char*)realloc(s->s, s->m)))
			s->s = tmp;
		else
			return EOF;
	}
	memcpy(s->s + s->l, p, l);
	s->l += l;
	return l;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rdi, %r15
movslq %esi, %r14
movq (%rdx), %rax
addq %r14, %rax
cmpq 0x8(%rdx), %rax
jbe 0x6f920
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x6f935
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/./htslib/kstring.h
// Function: ks_resize
static inline int ks_resize(kstring_t *s, size_t size)
{
	if (s->m < size) {
		char *tmp;
		s->m = size;
		kroundup32(s->m);
		if ((tmp = (char*)realloc(s->s, s->m)))
			s->s = tmp;
		else
			return -1;
	}
	return 0;
}

// Assembly:
cmpq %rsi, 0x8(%rdi)
jae 0x6f993
pushq %rbx
movq %rdi, %rbx
decq %rsi
movq %rsi, %rax
shrq %rax
orq %rsi, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rdi)
movq 0x10(%rdi), %rdi
callq 0x6c80
testq %rax, %rax
je 0x6f992
movq %rax, 0x10(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/./htslib/kstring.h
// Function: kputc_
static inline int kputc_(int c, kstring_t *s)
{
	if (s->l + 1 > s->m) {
		char *tmp;
		s->m = s->l + 1;
		kroundup32(s->m);
		if ((tmp = (char*)realloc(s->s, s->m)))
			s->s = tmp;
		else
			return EOF;
	}
	s->s[s->l++] = c;
	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
movq (%rsi), %rax
leaq 0x1(%rax), %rcx
cmpq 0x8(%rsi), %rcx
jbe 0x6f9f4
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%r14)
movq 0x10(%r14), %rdi
callq 0x6c80
testq %rax, %rax
je 0x6fa05
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movb %bl, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: sam_read1
int sam_read1(htsFile *fp, bam_hdr_t *h, bam1_t *b)
{
    switch (fp->format.format) {
    case bam: {
        int r = bam_read1(fp->fp.bgzf, b);
        if (r >= 0) {
            if (b->core.tid  >= h->n_targets || b->core.tid  < -1 ||
                b->core.mtid >= h->n_targets || b->core.mtid < -1)
                return -3;
        }
        return r;
        }

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

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

    default:
        abort();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rdx, (%rsp)
movl 0x44(%rdi), %eax
cmpl $0x6, %eax
je 0x6fae9
movq %rsi, %r14
cmpl $0x4, %eax
je 0x6faa3
cmpl $0x3, %eax
jne 0x6fb27
leaq 0x10(%rbx), %r15
leaq 0x8(%rbx), %r12
leaq 0x5137d(%rip), %r13     # 0xc0dc8
cmpq $0x0, (%r15)
jne 0x6fa69
movq %rbx, %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0x4e761
testl %eax, %eax
js 0x6fb11
movq (%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x6e959
movl %eax, %ebp
movq $0x0, (%r15)
testl %eax, %eax
jns 0x6fb16
cmpl $0x0, (%r13)
jg 0x6fa99
cmpl $0x0, 0x4(%r14)
jne 0x6fa4b
jmp 0x6fb16
movq %r12, %rdi
callq 0x8001
jmp 0x6fa90
movq 0x38(%rbx), %rdi
movq %rdx, %rsi
callq 0x6d4ff
testl %eax, %eax
js 0x6fae5
movq (%rsp), %rcx
movl (%rcx), %esi
movl (%r14), %edx
cmpl %edx, %esi
setge %dil
cmpl $-0x1, %esi
setl %sil
orb %dil, %sil
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jne 0x6fb16
movl 0x14(%rcx), %ecx
cmpl %edx, %ecx
setge %dl
cmpl $-0x1, %ecx
setl %cl
orb %dl, %cl
jne 0x6fb16
movl %eax, %ebp
jmp 0x6fb16
movq 0x38(%rbx), %rdi
movq %rsp, %rsi
callq 0x7c8e7
movl %eax, %ebp
testl %eax, %eax
jns 0x6fb16
movq 0x38(%rbx), %rdi
callq 0x5cc44
cmpl $0x1, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
sbbl $0x0, %ebp
jmp 0x6fb16
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x63c0
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: sam_write1
int sam_write1(htsFile *fp, const bam_hdr_t *h, const bam1_t *b)
{
    switch (fp->format.format) {
    case binary_format:
        fp->format.category = sequence_data;
        fp->format.format = bam;
        /* fall-through */
    case bam:
        return bam_write1(fp->fp.bgzf, b);

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

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

    default:
        abort();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x44(%rdi), %eax
decl %eax
cmpl $0x5, %eax
ja 0x725e7
movq %rdi, %r14
leaq 0x27e5f(%rip), %rcx     # 0x9a2ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movabsq $0x400000001, %rax      # imm = 0x400000001
movq %rax, 0x40(%r14)
movq 0x38(%r14), %rdi
movq %rdx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6d95e
movq 0x38(%r14), %rdi
movq %rdx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8561f
movabsq $0x300000001, %rax      # imm = 0x300000001
movq %rax, 0x40(%r14)
leaq 0x10(%r14), %rbx
movq %rsi, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
callq 0x6fb2c
testl %eax, %eax
js 0x725d3
movq 0x10(%r14), %rax
incq %rax
cmpq 0x18(%r14), %rax
jb 0x72557
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%r14)
movq 0x20(%r14), %rdi
callq 0x6c80
testq %rax, %rax
je 0x72577
movq %rax, 0x20(%r14)
movq 0x10(%r14), %rax
movq 0x20(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%r14)
movb $0xa, (%rcx,%rax)
movq 0x10(%r14), %rax
movq 0x20(%r14), %rcx
movb $0x0, (%rcx,%rax)
movq 0x38(%r14), %r12
movq 0x10(%r14), %r15
movq 0x20(%r14), %r13
movq 0x8(%r12), %rdi
movq 0x18(%r12), %rbp
subq %rdi, %rbp
cmpq %r15, %rbp
movq %r15, %r14
cmovbq %rbp, %r14
movq %r13, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x8(%r12)
cmpq %r15, %rbp
jae 0x725c3
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x6b222
movq %rax, %r14
movq (%rbx), %rcx
cmpq %rcx, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %ecx, %eax
jmp 0x725d8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x63c0
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_aux_get
uint8_t *bam_aux_get(const bam1_t *b, const char tag[2])
{
    uint8_t *s;
    int y = tag[0]<<8 | tag[1];
    s = bam_get_aux(b);
    while (s < b->data + b->l_data) {
        int x = (int)s[0]<<8 | s[1];
        s += 2;
        if (x == y) return s;
        s = skip_aux(s);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movsbl (%rsi), %eax
shll $0x8, %eax
movsbl 0x1(%rsi), %ebp
orl %eax, %ebp
movq 0x8(%rdi), %rcx
movq %rcx, %rdx
shrq $0x30, %rdx
shlq $0x2, %rdx
addq 0x28(%rdi), %rdx
shrl $0x18, %ecx
movslq 0x10(%rdi), %rsi
leal 0x1(%rsi), %eax
sarl %eax
cltq
addq %rcx, %rax
addq %rsi, %rax
addq %rdx, %rax
movslq 0x20(%rbx), %rcx
addq 0x28(%rbx), %rcx
cmpq %rcx, %rax
jae 0x7270f
movzwl (%rax), %ecx
rolw $0x8, %cx
movzwl %cx, %r15d
addq $0x2, %rax
cmpl %ebp, %r15d
jne 0x72700
movq %rax, %r14
jmp 0x72708
movq %rax, %rdi
callq 0x72720
cmpl %ebp, %r15d
jne 0x726da
jmp 0x72712
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: skip_aux
static inline uint8_t *skip_aux(uint8_t *s)
{
    int size = aux_type2size(*s); ++s; // skip type
    uint32_t n;
    switch (size) {
    case 'Z':
    case 'H':
        while (*s) ++s;
        return s + 1;
    case 'B':
        size = aux_type2size(*s); ++s;
        memcpy(&n, s, 4); s += 4;
        return s + size * n;
    case 0:
        abort();
        break;
    default:
        return s + size;
    }
}

// Assembly:
pushq %rax
movzbl (%rdi), %ecx
movl $0x1, %eax
cmpl $0x59, %ecx
jg 0x72746
leal -0x41(%rcx), %edx
cmpl $0x8, %edx
ja 0x7277a
leaq 0x27bc7(%rip), %rsi     # 0x9a304
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
leal -0x63(%rcx), %edx
cmpl $0x6, %edx
ja 0x72765
leaq 0x27bd3(%rip), %rcx     # 0x9a328
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl $0x4, %eax
jmp 0x72788
cmpl $0x5a, %ecx
je 0x72776
cmpl $0x73, %ecx
jne 0x7277f
movl $0x2, %eax
jmp 0x72788
movl %ecx, %eax
jmp 0x72788
cmpl $0x53, %ecx
je 0x7276f
xorl %eax, %eax
jmp 0x72788
movl $0x8, %eax
leaq 0x1(%rdi), %rcx
cmpl $0x47, %eax
jle 0x727ac
cmpl $0x5a, %eax
je 0x7279b
cmpl $0x48, %eax
jne 0x727da
leaq 0x1(%rcx), %rax
cmpb $0x0, (%rcx)
movq %rax, %rcx
jne 0x7279b
jmp 0x72831
cmpl $0x42, %eax
jne 0x727d6
movzbl (%rcx), %ecx
movl $0x1, %eax
cmpl $0x59, %ecx
jg 0x727e4
leal -0x41(%rcx), %edx
cmpl $0x8, %edx
ja 0x72818
leaq 0x27b77(%rip), %rsi     # 0x9a344
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
testl %eax, %eax
je 0x72833
movl %eax, %eax
addq %rax, %rcx
movq %rcx, %rax
jmp 0x72831
leal -0x63(%rcx), %edx
cmpl $0x6, %edx
ja 0x72803
leaq 0x27b75(%rip), %rcx     # 0x9a368
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl $0x4, %eax
jmp 0x72826
cmpl $0x5a, %ecx
je 0x72814
cmpl $0x73, %ecx
jne 0x7281d
movl $0x2, %eax
jmp 0x72826
movl %ecx, %eax
jmp 0x72826
cmpl $0x53, %ecx
je 0x7280d
xorl %eax, %eax
jmp 0x72826
movl $0x8, %eax
imull 0x2(%rdi), %eax
addq %rdi, %rax
addq $0x6, %rax
popq %rcx
retq
callq 0x63c0
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_aux_del
int bam_aux_del(bam1_t *b, uint8_t *s)
{
    uint8_t *p, *aux;
    int l_aux = bam_get_l_aux(b);
    aux = bam_get_aux(b);
    p = s - 2;
    s = skip_aux(s);
    memmove(p, s, l_aux - (s - aux));
    b->l_data -= s - p;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x20(%rdi), %ebp
movq 0x8(%rdi), %rcx
movq %rcx, %rax
shrq $0x2e, %rax
andl $-0x4, %eax
shrl $0x18, %ecx
movslq 0x10(%rdi), %rdx
leal 0x1(%rdx), %edi
sarl %edi
leal (%rdx,%rcx), %r8d
addl %eax, %r8d
addl %edi, %r8d
subl %r8d, %ebp
addq 0x28(%rbx), %rax
movslq %edi, %r14
addq %rcx, %r14
addq %rdx, %r14
addq %rax, %r14
leaq -0x2(%rsi), %r15
movq %rsi, %rdi
callq 0x72720
movq %rax, %r12
movslq %ebp, %rax
subq %r12, %r14
addq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6c60
subl %r12d, %r15d
addl %r15d, 0x20(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_aux2i
int32_t bam_aux2i(const uint8_t *s)
{
    int type;
    type = *s++;
    if (type == 'c') return (int32_t)*(int8_t*)s;
    else if (type == 'C') return (int32_t)*(uint8_t*)s;
    else if (type == 's') return (int32_t)*(int16_t*)s;
    else if (type == 'S') return (int32_t)*(uint16_t*)s;
    else if (type == 'i' || type == 'I') return *(int32_t*)s;
    else return 0;
}

// Assembly:
movb (%rdi), %cl
leal -0x43(%rcx), %eax
rolb $0x4, %al
cmpb $0x3, %al
ja 0x728e8
movzbl %al, %eax
leaq 0x27ab9(%rip), %rcx     # 0x9a384
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0x1(%rdi), %eax
retq
movsbl 0x1(%rdi), %eax
retq
movswl 0x1(%rdi), %eax
retq
movzwl 0x1(%rdi), %eax
retq
andb $-0x21, %cl
xorl %eax, %eax
cmpb $0x49, %cl
jne 0x728f5
movl 0x1(%rdi), %eax
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: bam_aux2f
double bam_aux2f(const uint8_t *s)
{
    int type;
    type = *s++;
    if (type == 'd') return *(double*)s;
    else if (type == 'f') return *(float*)s;
    else return 0.0;
}

// Assembly:
movzbl (%rdi), %eax
cmpl $0x66, %eax
je 0x7290c
xorps %xmm0, %xmm0
cmpl $0x64, %eax
jne 0x72911
movsd 0x1(%rdi), %xmm0
retq
cvtss2sd 0x1(%rdi), %xmm0
retq
// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/sam.c
// Function: sam_open_mode
int sam_open_mode(char *mode, const char *fn, const char *format)
{
    // TODO Parse "bam5" etc for compression level
    if (format == NULL) {
        // Try to pick a format based on the filename extension
        const char *ext = fn? strrchr(fn, '.') : NULL;
        if (ext == NULL || strchr(ext, '/')) return -1;
        return sam_open_mode(mode, fn, ext+1);
    }
    else if (strcmp(format, "bam") == 0) strcpy(mode, "b");
    else if (strcmp(format, "cram") == 0) strcpy(mode, "c");
    else if (strcmp(format, "sam") == 0) strcpy(mode, "");
    else return -1;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
jne 0x72985
testq %r15, %r15
je 0x72966
movq %r15, %rdi
movl $0x2e, %esi
callq 0x67c0
movq %rax, %r14
jmp 0x72969
xorl %r14d, %r14d
testq %r14, %r14
je 0x729d6
movq %r14, %rdi
movl $0x2f, %esi
callq 0x6270
testq %rax, %rax
jne 0x729d6
incq %r14
jmp 0x7294a
leaq 0x25c23(%rip), %rsi     # 0x985af
movq %r14, %rdi
callq 0x6a50
testl %eax, %eax
je 0x729c8
leaq 0x25c14(%rip), %rsi     # 0x985b3
movq %r14, %rdi
callq 0x6a50
testl %eax, %eax
je 0x729cf
leaq 0x25bf9(%rip), %rsi     # 0x985ab
movq %r14, %rdi
callq 0x6a50
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x729d6
movb $0x0, (%rbx)
jmp 0x729d4
movw $0x62, (%rbx)
jmp 0x729d4
movw $0x63, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq