LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: deflate_block
static int deflate_block(BGZF *fp, int block_length)
{
    size_t comp_size = BGZF_MAX_BLOCK_SIZE;
    int ret;
    if ( !fp->is_gzip )
        ret = bgzf_compress(fp->compressed_block, &comp_size, fp->uncompressed_block, block_length, fp->compress_level);
    else
        ret = bgzf_gzip_compress(fp, fp->compressed_block, &comp_size, fp->uncompressed_block, block_length, fp->compress_level);

    if ( ret != 0 )
    {
        hts_log_debug("Compression error %d", ret);
        fp->errcode |= BGZF_ERR_ZLIB;
        return -1;
    }
    fp->block_offset = 0;
    return comp_size;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq $0x10000, (%rsp)        # imm = 0x10000
movl (%rdi), %r8d
movq 0x30(%rdi), %rdi
movq 0x28(%rbx), %rdx
testl %r8d, %r8d
js 0xcf1d
movslq %esi, %rcx
shll $0x3, %r8d
sarl $0x17, %r8d
movq %rsp, %rsi
callq 0xabfa
testl %eax, %eax
jne 0xcf92
movq (%rsp), %r14
jmp 0xcfc9
movq 0x60(%rbx), %r14
xorl %eax, %eax
testl %esi, %esi
sete %al
leal 0x1(%rax,%rax,2), %eax
movq %rdx, (%r14)
movl %esi, 0x8(%r14)
movq %rdi, 0x18(%r14)
movl $0x10000, 0x20(%r14)    # imm = 0x10000
movq %r14, %rdi
movl %eax, %esi
callq 0x41f0
cmpl $-0x2, %eax
jne 0xcf71
leaq 0x884ce(%rip), %rsi     # 0x95423
leaq 0x87a99(%rip), %rdx     # 0x949f5
leaq 0x881f1(%rip), %rcx     # 0x95154
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0xcf92
cmpl $0x0, 0x8(%r14)
je 0xcfbc
leaq 0x884a4(%rip), %rsi     # 0x95423
leaq 0x884b0(%rip), %rdx     # 0x95436
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
leaq 0x88467(%rip), %rsi     # 0x95400
leaq 0x8846e(%rip), %rdx     # 0x9540e
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0x5, %edi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x13de5
orb $0x1, (%rbx)
jmp 0xcfd0
movl 0x20(%r14), %eax
movl $0x10000, %r14d         # imm = 0x10000
subq %rax, %r14
movl $0x0, 0x10(%rbx)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_write
ssize_t bgzf_write(BGZF *fp, const void *data, size_t length)
{
    if ( !fp->is_compressed ) {
        size_t push = length + (size_t) fp->block_offset;
        fp->block_offset = push % BGZF_MAX_BLOCK_SIZE;
        fp->block_address += (push - fp->block_offset);
        return hwrite(fp->fp, data, length);
    }

    const uint8_t *input = (const uint8_t*)data;
    ssize_t remaining = length;
    assert(fp->is_write);
    while (remaining > 0) {
        uint8_t* buffer = (uint8_t*)fp->uncompressed_block;
        int copy_length = BGZF_BLOCK_SIZE - fp->block_offset;
        if (copy_length > remaining) copy_length = remaining;
        memcpy(buffer + fp->block_offset, input, copy_length);
        fp->block_offset += copy_length;
        input += copy_length;
        remaining -= copy_length;
        if (fp->block_offset == BGZF_BLOCK_SIZE) {
            if (lazy_flush(fp) != 0) return -1;
        }
    }
    return length - remaining;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl (%rdi), %eax
btl $0x1e, %eax
jb 0xd0a7
movslq 0x10(%r15), %rax
addq %rbx, %rax
movzwl %ax, %ecx
movl %ecx, 0x10(%r15)
andq $-0x10000, %rax         # imm = 0xFFFF0000
addq %rax, 0x18(%r15)
movq 0x40(%r15), %r15
testb $0x2, 0x30(%r15)
movq 0x18(%r15), %r12
jne 0xd06f
movq %r12, %rax
subq 0x8(%r15), %rax
cmpq %rbx, %rax
jae 0xd06f
addq %rbx, %r12
subq (%r15), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xee24
movq 0x18(%r15), %r12
movq %r12, 0x10(%r15)
movq 0x8(%r15), %rdi
subq %rdi, %r12
cmpq %rbx, %r12
ja 0xd084
cmpq (%r15), %rdi
je 0xd128
cmpq %rbx, %r12
movq %rbx, %r13
cmovbq %r12, %r13
movq %r14, %rsi
movq %r13, %rdx
callq 0x43c0
addq %r13, 0x8(%r15)
cmpq %rbx, %r12
jae 0xd11b
jmp 0xd12b
btl $0x11, %eax
jae 0xd145
movq %rbx, %r13
testq %rbx, %rbx
jle 0xd10c
movq %rbx, %r13
movslq 0x10(%r15), %rdi
movl $0xff00, %eax           # imm = 0xFF00
subq %rdi, %rax
cmpq %rax, %r13
movl %r13d, %ecx
cmovgel %eax, %ecx
addq 0x28(%r15), %rdi
movslq %ecx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x43c0
movl 0x10(%r15), %eax
addl %r12d, %eax
movl %eax, 0x10(%r15)
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0xd101
movq %r15, %rdi
callq 0xcfed
testl %eax, %eax
jne 0xd114
addq %r12, %r14
subq %r12, %r13
testq %r13, %r13
jg 0xd0bc
subq %r13, %rbx
movq %rbx, %r13
jmp 0xd11b
movq $-0x1, %r13
movq %r13, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf300
leaq 0x87bff(%rip), %rdi     # 0x94d4b
leaq 0x87acd(%rip), %rsi     # 0x94c20
leaq 0x87bfe(%rip), %rcx     # 0x94d58
movl $0x7d8, %edx            # imm = 0x7D8
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_close_mt
static void bgzf_close_mt(BGZF *fp) {
    if (fp->mt) {
        if (!fp->mt->free_block)
            fp->uncompressed_block = NULL;
        if (mt_destroy(fp->mt) < 0)
            fp->errcode = BGZF_ERR_IO;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
testq %rdi, %rdi
je 0xd672
cmpq $0x0, 0x60(%rdi)
jne 0xd664
movq $0x0, 0x28(%rbx)
callq 0xb605
testl %eax, %eax
jns 0xd672
movw $0x4, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_index_destroy
void bgzf_index_destroy(BGZF *fp)
{
    if ( !fp->idx ) return;
    free(fp->idx->offs);
    free(fp->idx);
    fp->idx = NULL;
    fp->idx_build_otf = 0;
}

// Assembly:
movq 0x50(%rdi), %rax
testq %rax, %rax
je 0xd6a3
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rax), %rdi
callq 0x45c0
movq 0x50(%rbx), %rdi
callq 0x45c0
movq $0x0, 0x50(%rbx)
movl $0x0, 0x58(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_check_EOF
int bgzf_check_EOF(BGZF *fp) {
    int has_eof;

    if (fp->mt) {
        pthread_mutex_lock(&fp->mt->command_m);
        // fp->mt->command state transitions should be:
        // NONE -> HAS_EOF -> HAS_EOF_DONE -> NONE
        // (HAS_EOF -> HAS_EOF_DONE happens in bgzf_mt_reader thread)
        if (fp->mt->command != CLOSE)
            fp->mt->command = HAS_EOF;
        pthread_cond_signal(&fp->mt->command_c);
        hts_tpool_wake_dispatch(fp->mt->out_queue);
        do {
            if (fp->mt->command == CLOSE) {
                // possible error in bgzf_mt_reader
                pthread_mutex_unlock(&fp->mt->command_m);
                return 0;
            }
            pthread_cond_wait(&fp->mt->command_c, &fp->mt->command_m);
            switch (fp->mt->command) {
            case HAS_EOF_DONE: break;
            case HAS_EOF:
                // Resend signal intended for bgzf_mt_reader()
                pthread_cond_signal(&fp->mt->command_c);
                break;
            case CLOSE:
                continue;
            default:
                abort();  // Should not get to any other state
            }
        } while (fp->mt->command != HAS_EOF_DONE);
        fp->mt->command = NONE;
        has_eof = fp->mt->eof;
        pthread_mutex_unlock(&fp->mt->command_m);
    } else {
        has_eof = bgzf_check_EOF_common(fp);
    }

    fp->no_eof_block = (has_eof == 0);

    return has_eof;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
testq %rdi, %rdi
je 0xd77b
subq $-0x80, %rdi
callq 0x4750
movq 0x48(%rbx), %rdi
cmpl $0x5, 0xd8(%rdi)
je 0xd6ef
movl $0x3, 0xd8(%rdi)
addq $0xa8, %rdi
callq 0x4040
movq 0x48(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x36d54
movq 0x48(%rbx), %rsi
movl 0xd8(%rsi), %eax
cmpl $0x5, %eax
je 0xd79c
leaq 0xa8(%rsi), %rdi
subq $-0x80, %rsi
callq 0x47c0
movq 0x48(%rbx), %rsi
movl 0xd8(%rsi), %eax
leal -0x4(%rax), %ecx
cmpl $0x2, %ecx
jb 0xd75b
cmpl $0x3, %eax
jne 0xd7b3
addq $0xa8, %rsi
movq %rsi, %rdi
callq 0x4040
movq 0x48(%rbx), %rsi
movl 0xd8(%rsi), %eax
cmpl $0x4, %eax
jne 0xd712
movl $0x0, 0xd8(%rsi)
movl 0x78(%rsi), %ebp
subq $-0x80, %rsi
movq %rsi, %rdi
callq 0x4340
jmp 0xd785
movq %rbx, %rdi
callq 0xd7b8
movl %eax, %ebp
xorl %eax, %eax
testl %ebp, %ebp
sete %al
shll $0x12, %eax
movl $0xfffbffff, %ecx       # imm = 0xFFFBFFFF
andl (%rbx), %ecx
orl %eax, %ecx
movl %ecx, (%rbx)
jmp 0xd7aa
subq $-0x80, %rsi
movq %rsi, %rdi
callq 0x4340
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x4270
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_check_EOF_common
static int bgzf_check_EOF_common(BGZF *fp)
{
    uint8_t buf[28];
    off_t offset = htell(fp->fp);
    if (hseek(fp->fp, -28, SEEK_END) < 0) {
        if (errno == ESPIPE) { hclearerr(fp->fp); return 2; }
#ifdef _WIN32
        if (errno == EINVAL) { hclearerr(fp->fp); return 2; }
#else
        // Assume that EINVAL was due to the file being less than 28 bytes
        // long, rather than being a random error return from an hfile backend.
        // This should be reported as "no EOF block" rather than an error.
        if (errno == EINVAL) { hclearerr(fp->fp); return 0; }
#endif
        return -1;
    }
    if ( hread(fp->fp, buf, 28) != 28 ) return -1;
    if ( hseek(fp->fp, offset, SEEK_SET) < 0 ) return -1;
    return (memcmp("\037\213\010\4\0\0\0\0\0\377\6\0\102\103\2\0\033\0\3\0\0\0\0\0\0\0\0\0", buf, 28) == 0)? 1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
movq 0x28(%rdi), %r14
addq 0x8(%rdi), %r14
subq (%rdi), %r14
movq $-0x1c, %rsi
movl $0x2, %edx
callq 0xf3b3
testq %rax, %rax
js 0xd899
movq 0x40(%rbx), %r12
movq 0x8(%r12), %r13
movq 0x10(%r12), %rbp
subq %r13, %rbp
cmpq $0x1c, %rbp
movl $0x1c, %r15d
cmovbq %rbp, %r15
movq %rsp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, %r13
movq %r13, 0x8(%r12)
cmpq $0x1b, %rbp
ja 0xd84b
testb $0x2, 0x30(%r12)
je 0xd84b
movq %rsp, %rsi
movl $0x1c, %edx
movq %r12, %rdi
movq %r15, %rcx
callq 0xf129
movq %rax, %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq $0x1c, %r15
jne 0xd8ce
movq 0x40(%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xf3b3
testq %rax, %rax
js 0xd8ce
movdqu 0xc(%rsp), %xmm0
pcmpeqb 0x87129(%rip), %xmm0    # 0x949a0
movdqa (%rsp), %xmm1
pcmpeqb 0x8712c(%rip), %xmm1    # 0x949b0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
xorl %ebp, %ebp
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %bpl
jmp 0xd8ce
callq 0x4050
movl (%rax), %eax
cmpl $0x16, %eax
je 0xd8c1
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x1d, %eax
jne 0xd8ce
movq 0x40(%rbx), %rax
movl $0x0, 0x34(%rax)
movl $0x2, %ebp
jmp 0xd8ce
movq 0x40(%rbx), %rax
movl $0x0, 0x34(%rax)
xorl %ebp, %ebp
movl %ebp, %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/bgzf.c
// Function: bgzf_seek
int64_t bgzf_seek(BGZF* fp, int64_t pos, int where)
{
    if (fp->is_write || where != SEEK_SET || fp->is_gzip) {
        fp->errcode |= BGZF_ERR_MISUSE;
        return -1;
    }

    // This is a flag to indicate we've jumped elsewhere in the stream, to act
    // as a hint to any other code which is wrapping up bgzf for its own
    // purposes.  We may not be able to tell when seek happens as it can be
    // done on our behalf, eg by the iterator.
    //
    // This is never cleared here.  Any tool that needs to handle it is also
    // responsible for clearing it.
    fp->seeked = pos;

    return bgzf_seek_common(fp, pos >> 16, pos & 0xFFFF);
}

// Assembly:
movl (%rdi), %eax
testl %eax, %eax
js 0xd904
movl %eax, %ecx
andl $0x20000, %ecx          # imm = 0x20000
orl %edx, %ecx
jne 0xd904
movq %rsi, 0x68(%rdi)
movq %rsi, %rax
sarq $0x10, %rax
movzwl %si, %edx
movq %rax, %rsi
jmp 0xd911
orl $0x8, %eax
movl %eax, (%rdi)
movq $-0x1, %rax
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_is_bgzf
int bgzf_is_bgzf(const char *fn)
{
    uint8_t buf[16];
    int n;
    hFILE *fp;
    if ((fp = hopen(fn, "r")) == 0) return 0;
    n = hread(fp, buf, 16);
    if (hclose(fp) < 0) return 0;
    if (n != 16) return 0;
    return check_header(buf) == 0? 1 : 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
leaq 0x8ab88(%rip), %rsi     # 0x985cb
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xfe44
testq %rax, %rax
je 0xdac8
movq %rax, %r14
movq 0x8(%rax), %r12
movq 0x10(%rax), %r13
subq %r12, %r13
cmpq $0x10, %r13
movl $0x10, %r15d
cmovbq %r13, %r15
movq %rsp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, %r12
movq %r12, 0x8(%r14)
cmpq $0xf, %r13
ja 0xdaa5
testb $0x2, 0x30(%r14)
je 0xdaa5
movq %rsp, %rsi
movl $0x10, %edx
movq %r14, %rdi
movq %r15, %rcx
callq 0xf129
movq %rax, %r15
movq %r14, %rdi
callq 0xf4df
testl %eax, %eax
js 0xdac8
movl %r15d, %eax
cmpl $0x10, %eax
jne 0xdac8
movq %rsp, %rdi
callq 0xbbc1
xorl %ebx, %ebx
testl %eax, %eax
sete %bl
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_getc
int bgzf_getc(BGZF *fp)
{
    if (fp->block_offset+1 < fp->block_length) {
        fp->uncompressed_address++;
        return ((unsigned char*)fp->uncompressed_block)[fp->block_offset++];
    }

    int c;
    if (fp->block_offset >= fp->block_length) {
        if (bgzf_read_block(fp) != 0) return -2; /* error */
        if (fp->block_length == 0) return -1; /* end-of-file */
    }
    c = ((unsigned char*)fp->uncompressed_block)[fp->block_offset++];
    if (fp->block_offset == fp->block_length) {
        fp->block_address = bgzf_htell(fp);
        fp->block_offset = 0;
        fp->block_length = 0;
    }
    fp->uncompressed_address++;
    return c;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0x10(%rdi), %edx
leal 0x1(%rdx), %ecx
cmpl %eax, %ecx
jge 0xdb10
incq 0x20(%rbx)
movslq %edx, %rax
movq 0x28(%rbx), %rdx
movl %ecx, 0x10(%rbx)
movzbl (%rdx,%rax), %ebp
jmp 0xdb51
cmpl %eax, %edx
jge 0xdb40
movq 0x28(%rbx), %rsi
movl %ecx, 0x10(%rbx)
movslq %edx, %rdx
movzbl (%rsi,%rdx), %ebp
cmpl %eax, %ecx
jne 0xdb3a
movq %rbx, %rdi
callq 0xb7a5
movq %rax, 0x18(%rbx)
xorl %eax, %eax
movl %eax, 0x10(%rbx)
movl %eax, 0x8(%rbx)
incq 0x20(%rbx)
jmp 0xdb51
movq %rbx, %rdi
callq 0xae59
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testl %eax, %eax
je 0xdb5a
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0xdb69
movl 0x10(%rbx), %edx
leal 0x1(%rdx), %ecx
jmp 0xdb14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xdb51
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_index_build_init
int bgzf_index_build_init(BGZF *fp)
{
    bgzf_index_destroy(fp);
    fp->idx = (bgzidx_t*) calloc(1,sizeof(bgzidx_t));
    if ( !fp->idx ) return -1;
    fp->idx_build_otf = 1;  // build index on the fly
    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0xd674
movl $0x1, %edi
movl $0x18, %esi
callq 0x4300
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0xdd78
movl $0x1, 0x58(%rbx)
xorl %eax, %eax
jmp 0xdd7d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_index_dump
int bgzf_index_dump(BGZF *fp, const char *bname, const char *suffix)
{
    const char *name = bname, *msg = NULL;
    char *tmp = NULL;
    hFILE *idx = NULL;

    if (!fp->idx) {
        hts_log_error("Called for BGZF handle with no index");
        errno = EINVAL;
        return -1;
    }

    if ( suffix )
    {
        tmp = get_name_suffix(bname, suffix);
        if ( !tmp ) return -1;
        name = tmp;
    }

    idx = hopen(name, "wb");
    if ( !idx ) {
        msg = "Error opening";
        goto fail;
    }

    if (bgzf_index_dump_hfile(fp, idx, name) != 0) goto fail;

    if (hclose(idx) < 0)
    {
        idx = NULL;
        msg = "Error on closing";
        goto fail;
    }

    free(tmp);
    return 0;

 fail:
    if (msg != NULL) {
        hts_log_error("%s %s : %s", msg, name, strerror(errno));
    }
    if (idx) hclose_abruptly(idx);
    free(tmp);
    return -1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x50(%rdi)
je 0xe086
movq %rsi, %rbx
movq %rdi, %r15
testq %rdx, %rdx
je 0xe0ad
movq %rbx, %rdi
movq %rdx, %rsi
callq 0xe152
movq %rax, %rbx
movq %rax, %r14
testq %rax, %rax
jne 0xe0b0
jmp 0xe123
leaq 0x86dcd(%rip), %rsi     # 0x94e5a
leaq 0x86d88(%rip), %rdx     # 0x94e1c
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
callq 0x4050
movl $0x16, (%rax)
jmp 0xe123
xorl %r14d, %r14d
leaq 0x86db3(%rip), %rsi     # 0x94e6a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xfe44
testq %rax, %rax
je 0xe0e5
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0xdd7f
movq %r12, %rdi
testl %eax, %eax
je 0xe134
callq 0xf53f
jmp 0xe11b
leaq 0x86d81(%rip), %r15     # 0x94e6d
callq 0x4050
movl (%rax), %edi
callq 0x4150
leaq 0x86d5b(%rip), %rsi     # 0x94e5a
leaq 0x86d86(%rip), %rdx     # 0x94e8c
movl $0x1, %edi
movq %r15, %rcx
movq %rbx, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x13de5
movq %r14, %rdi
callq 0x45c0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0xf4df
testl %eax, %eax
js 0xe149
movq %r14, %rdi
callq 0x45c0
xorl %eax, %eax
jmp 0xe128
leaq 0x86d2b(%rip), %r15     # 0x94e7b
jmp 0xe0ec
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: get_name_suffix
static char * get_name_suffix(const char *bname, const char *suffix)
{
    size_t len = strlen(bname) + strlen(suffix) + 1;
    char *buff = malloc(len);
    if (!buff) return NULL;
    snprintf(buff, len, "%s%s", bname, suffix);
    return buff;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x41d0
movq %rax, %r15
movq %rbx, %rdi
callq 0x41d0
leaq (%r15,%rax), %r12
incq %r12
movq %r12, %rdi
callq 0x4680
movq %rax, %r15
testq %rax, %rax
je 0xe1a1
leaq 0x87d82(%rip), %rdx     # 0x95f10
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x4800
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_index_load
int bgzf_index_load(BGZF *fp, const char *bname, const char *suffix)
{
    const char *name = bname, *msg = NULL;
    char *tmp = NULL;
    hFILE *idx = NULL;
    if ( suffix )
    {
        tmp = get_name_suffix(bname, suffix);
        if ( !tmp ) return -1;
        name = tmp;
    }

    idx = hopen(name, "rb");
    if ( !idx ) {
        msg = "Error opening";
        goto fail;
    }

    if (bgzf_index_load_hfile(fp, idx, name) != 0) goto fail;

    if (hclose(idx) != 0) {
        idx = NULL;
        msg = "Error closing";
        goto fail;
    }

    free(tmp);
    return 0;

 fail:
    if (msg != NULL) {
        hts_log_error("%s %s : %s", msg, name, strerror(errno));
    }
    if (idx) hclose_abruptly(idx);
    free(tmp);
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0xe422
movq %r14, %rdi
movq %rdx, %rsi
callq 0xe152
movq %rax, %r14
movq %rax, %rbx
testq %rax, %rax
jne 0xe424
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xe4ae
xorl %ebx, %ebx
leaq 0x86a98(%rip), %rsi     # 0x94ec3
movq %r14, %rdi
xorl %eax, %eax
callq 0xfe44
testq %rax, %rax
je 0xe459
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xe1b0
movq %r12, %rdi
testl %eax, %eax
je 0xe462
callq 0xf53f
jmp 0xe4a1
leaq 0x86a0d(%rip), %r15     # 0x94e6d
jmp 0xe472
callq 0xf4df
testl %eax, %eax
je 0xe4b9
leaq 0x86a54(%rip), %r15     # 0x94ec6
callq 0x4050
movl (%rax), %edi
callq 0x4150
leaq 0x86a4f(%rip), %rsi     # 0x94ed4
leaq 0x86a00(%rip), %rdx     # 0x94e8c
movl $0x1, %edi
movq %r15, %rcx
movq %r14, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x13de5
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x45c0
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0xe4a6
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_decode_func
static void *bgzf_decode_func(void *arg) {
    bgzf_job *j = (bgzf_job *)arg;

    j->uncomp_len = BGZF_MAX_BLOCK_SIZE;
    uint32_t crc = le_to_u32((uint8_t *)j->comp_data + j->comp_len-8);
    int ret = bgzf_uncompress(j->uncomp_data, &j->uncomp_len,
                              j->comp_data+18, j->comp_len-18, crc);
    if (ret != 0)
        j->errcode |= BGZF_ERR_ZLIB;

    return arg;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x20010(%rdi), %rsi
movq $0x10000, 0x20010(%rdi) # imm = 0x10000
movq 0x10008(%rdi), %rcx
movl (%rdi,%rcx), %r8d
addq $0x10010, %rdi          # imm = 0x10010
leaq 0x1a(%rbx), %rdx
addq $-0x12, %rcx
callq 0xe65e
testl %eax, %eax
je 0xeb24
orb $0x1, 0x20018(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_mt_seek
static void bgzf_mt_seek(BGZF *fp) {
    mtaux_t *mt = fp->mt;

    hts_tpool_process_reset(mt->out_queue, 0);
    pthread_mutex_lock(&mt->job_pool_m);
    mt->errcode = 0;

    if (hseek(fp->fp, mt->block_address, SEEK_SET) < 0)
        mt->errcode = errno;

    pthread_mutex_unlock(&mt->job_pool_m);
    mt->command = SEEK_DONE;
    pthread_cond_signal(&mt->command_c);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r15
movq 0x48(%rdi), %rbx
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0x362ef
leaq 0x30(%rbx), %r14
movq %r14, %rdi
callq 0x4750
movl $0x0, 0x6c(%rbx)
movq 0x40(%r15), %rdi
movq 0x70(%rbx), %rsi
xorl %edx, %edx
callq 0xf3b3
testq %rax, %rax
jns 0xeba4
callq 0x4050
movl (%rax), %eax
movl %eax, 0x6c(%rbx)
movq %r14, %rdi
callq 0x4340
movl $0x2, 0xd8(%rbx)
addq $0xa8, %rbx
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4040
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_encode_func
static void *bgzf_encode_func(void *arg) {
    bgzf_job *j = (bgzf_job *)arg;

    j->comp_len = BGZF_MAX_BLOCK_SIZE;
    int ret = bgzf_compress(j->comp_data, &j->comp_len,
                            j->uncomp_data, j->uncomp_len,
                            j->fp->compress_level);
    if (ret != 0)
        j->errcode |= BGZF_ERR_ZLIB;

    return arg;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x10008(%rdi), %rsi
movq $0x10000, 0x10008(%rdi) # imm = 0x10000
addq $0x8, %rdi
leaq 0x10010(%rbx), %rdx
movq 0x20010(%rbx), %rcx
movq (%rbx), %rax
movl (%rax), %r8d
shll $0x3, %r8d
sarl $0x17, %r8d
callq 0xabfa
testl %eax, %eax
je 0xecbb
orb $0x1, 0x20018(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_init
HTSLIB_EXPORT
hFILE *hfile_init(size_t struct_size, const char *mode, size_t capacity)
{
    hFILE *fp = (hFILE *) malloc(struct_size);
    if (fp == NULL) goto error;

    const int maxcap = 128*1024;

    if (capacity == 0) capacity = maxcap;
    // FIXME For now, clamp input buffer sizes so mpileup doesn't eat memory
    if (strchr(mode, 'r') && capacity > maxcap) capacity = maxcap;

#ifdef HAVE_POSIX_MEMALIGN
    fp->buffer = NULL;
    if (posix_memalign((void **)&fp->buffer, 256, capacity) < 0)
        goto error;
#else
    fp->buffer = (char *) malloc(capacity);
    if (fp->buffer == NULL) goto error;
#endif

    fp->begin = fp->end = fp->buffer;
    fp->limit = &fp->buffer[capacity];

    fp->offset = 0;
    fp->at_eof = 0;
    fp->mobile = 1;
    fp->readonly = (strchr(mode, 'r') && ! strchr(mode, '+'));
    fp->preserve = 0;
    fp->has_errno = 0;
    return fp;

error:
    hfile_destroy(fp);
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r12
movq %rsi, %r14
callq 0x4680
testq %rax, %rax
je 0xed55
movq %rax, %rbx
testq %r12, %r12
movl $0x20000, %r15d         # imm = 0x20000
cmoveq %r15, %r12
movq %r14, %rdi
movl $0x72, %esi
callq 0x4190
cmpq %r15, %r12
cmovbq %r12, %r15
movq %rax, %r13
testq %rax, %rax
cmoveq %r12, %r15
movq %r15, %rdi
callq 0x4680
movq %rax, (%rbx)
testq %rax, %rax
je 0xed4d
addq %rax, %r15
movq %rax, 0x10(%rbx)
movq %rax, 0x8(%rbx)
movq %r15, 0x18(%rbx)
movq $0x0, 0x28(%rbx)
testq %r13, %r13
je 0xed59
movq %r14, %rdi
movl $0x2b, %esi
callq 0x4190
testq %rax, %rax
sete %al
shlb $0x2, %al
orb $0x2, %al
jmp 0xed5b
movq %rbx, %rdi
callq 0xed72
xorl %ebx, %ebx
jmp 0xed65
movb $0x2, %al
movb %al, 0x30(%rbx)
movl $0x0, 0x34(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_init_fixed
hFILE *hfile_init_fixed(size_t struct_size, const char *mode,
                        char *buffer, size_t buf_filled, size_t buf_size)
{
    hFILE *fp = (hFILE *) malloc(struct_size);
    if (fp == NULL) return NULL;

    fp->buffer = fp->begin = buffer;
    fp->end = &fp->buffer[buf_filled];
    fp->limit = &fp->buffer[buf_size];

    fp->offset = 0;
    fp->at_eof = 1;
    fp->mobile = 0;
    fp->readonly = (strchr(mode, 'r') && ! strchr(mode, '+'));
    fp->preserve = 0;
    fp->has_errno = 0;
    return fp;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %r15
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r14
callq 0x4680
movq %rax, %rbx
testq %rax, %rax
je 0xee17
movq %r12, 0x8(%rbx)
movq %r12, (%rbx)
addq %r12, %r13
movq %r13, 0x10(%rbx)
addq %r12, %r15
movq %r15, 0x18(%rbx)
movq $0x0, 0x28(%rbx)
movq %r14, %rdi
movl $0x72, %esi
callq 0x4190
testq %rax, %rax
je 0xee0b
movq %r14, %rdi
movl $0x2b, %esi
callq 0x4190
testq %rax, %rax
sete %al
shlb $0x2, %al
incb %al
jmp 0xee0d
movb $0x1, %al
movb %al, 0x30(%rbx)
movl $0x0, 0x34(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_set_blksize
HTSLIB_EXPORT
int hfile_set_blksize(hFILE *fp, size_t bufsiz) {
    char *buffer;
    ptrdiff_t curr_used;
    if (!fp) return -1;
    curr_used = (fp->begin > fp->end ? fp->begin : fp->end) - fp->buffer;
    if (bufsiz == 0) bufsiz = 32768;

    // Ensure buffer resize will not erase live data
    if (bufsiz < curr_used)
        return -1;

    if (!(buffer = (char *) realloc(fp->buffer, bufsiz))) return -1;

    fp->begin  = buffer + (fp->begin - fp->buffer);
    fp->end    = buffer + (fp->end   - fp->buffer);
    fp->buffer = buffer;
    fp->limit  = &fp->buffer[bufsiz];

    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0xee94
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rcx, %rax
cmovaq %rax, %rcx
movq (%rdi), %rdi
subq %rdi, %rcx
testq %rsi, %rsi
movl $0x8000, %r14d          # imm = 0x8000
cmovneq %rsi, %r14
cmpq %rcx, %r14
jb 0xee94
movq %r14, %rsi
callq 0x4840
testq %rax, %rax
je 0xee94
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
addq %rax, %rdx
movq %rdx, 0x8(%rbx)
movq 0x10(%rbx), %rdx
subq %rcx, %rdx
addq %rax, %rdx
movq %rdx, 0x10(%rbx)
movq %rax, (%rbx)
addq %rax, %r14
movq %r14, 0x18(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: refill_buffer
static ssize_t refill_buffer(hFILE *fp)
{
    ssize_t n;

    // Move any unread characters to the start of the buffer
    if (fp->mobile && fp->begin > fp->buffer) {
        fp->offset += fp->begin - fp->buffer;
        memmove(fp->buffer, fp->begin, fp->end - fp->begin);
        fp->end = &fp->buffer[fp->end - fp->begin];
        fp->begin = fp->buffer;
    }

    // Read into the available buffer space at fp->[end,limit)
    if (fp->at_eof || fp->end == fp->limit) n = 0;
    else {
        n = fp->backend->read(fp, fp->end, fp->limit - fp->end);
        if (n < 0) { fp->has_errno = errno; return n; }
        else if (n == 0) fp->at_eof = 1;
    }

    fp->end += n;
    return n;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x30(%rdi), %al
testb $0x2, %al
je 0xef07
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movq %rsi, %rcx
subq %rdi, %rcx
jbe 0xef07
addq %rcx, 0x28(%rbx)
movq 0x10(%rbx), %rdx
subq %rsi, %rdx
callq 0x4830
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
subq 0x8(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq %rax, 0x8(%rbx)
movb 0x30(%rbx), %al
testb $0x1, %al
jne 0xef32
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
cmpq %rdx, %rsi
je 0xef32
movq 0x20(%rbx), %rax
subq %rsi, %rdx
movq %rbx, %rdi
callq *(%rax)
movq %rax, %r14
testq %rax, %rax
js 0xef44
jne 0xef35
orb $0x1, 0x30(%rbx)
xorl %r14d, %r14d
addq %r14, 0x10(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x4050
movl (%rax), %eax
movl %eax, 0x34(%rbx)
jmp 0xef39
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hgetdelim
ssize_t hgetdelim(char *buffer, size_t size, int delim, hFILE *fp)
{
    char *found;
    size_t n, copied = 0;
    ssize_t got;

    if (size < 1 || size > SSIZE_MAX) {
        fp->has_errno = errno = EINVAL;
        return -1;
    }
    if (writebuffer_is_nonempty(fp)) {
        fp->has_errno = errno = EBADF;
        return -1;
    }

    --size; /* to allow space for the NUL terminator */

    do {
        n = fp->end - fp->begin;
        if (n > size - copied) n = size - copied;

        /* Look in the hFILE buffer for the delimiter */
        found = memchr(fp->begin, delim, n);
        if (found != NULL) {
            n = found - fp->begin + 1;
            memcpy(buffer + copied, fp->begin, n);
            buffer[n + copied] = '\0';
            fp->begin += n;
            return n + copied;
        }

        /* No delimiter yet, copy as much as we can and refill if necessary */
        memcpy(buffer + copied, fp->begin, n);
        fp->begin += n;
        copied += n;

        if (copied == size) { /* Output buffer full */
            buffer[copied] = '\0';
            return copied;
        }

        got = refill_buffer(fp);
    } while (got > 0);

    if (got < 0) return -1; /* Error on refill. */

    buffer[copied] = '\0';  /* EOF, return anything that was copied. */
    return copied;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, 0x14(%rsp)
movq %rdi, 0x8(%rsp)
testq %rsi, %rsi
jle 0xef85
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
jbe 0xefad
callq 0x4050
movl $0x9, %ecx
jmp 0xef8f
callq 0x4050
movl $0x16, %ecx
movl %ecx, (%rax)
movl %ecx, 0x34(%rbx)
movq $-0x1, %rbp
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbp
decq %rbp
xorl %r14d, %r14d
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rax
subq %r12, %rax
movq %rbp, %r13
subq %r14, %r13
cmpq %r13, %rax
cmovbq %rax, %r13
movq %r12, %rdi
movl 0x14(%rsp), %esi
movq %r13, %rdx
callq 0x4550
testq %rax, %rax
jne 0xf023
movq 0x8(%rsp), %rax
leaq (%rax,%r14), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x43c0
addq %r13, 0x8(%rbx)
addq %r13, %r14
cmpq %rbp, %r14
je 0xf057
movq %rbx, %rdi
callq 0xeec1
testq %rax, %rax
jg 0xefb6
js 0xef94
movq 0x8(%rsp), %rax
movb $0x0, (%rax,%r14)
movq %r14, %rbp
jmp 0xef9b
movq %rax, %r15
subq %r12, %r15
leaq 0x1(%r15), %rdx
movq 0x8(%rsp), %r13
leaq (%r14,%r13), %rdi
movq %r12, %rsi
movq %rdx, %r12
callq 0x43c0
leaq (%r15,%r14), %rbp
incq %rbp
movb $0x0, (%r13,%rbp)
addq %r12, 0x8(%rbx)
jmp 0xef9b
movq 0x8(%rsp), %rax
movb $0x0, (%rax,%rbp)
jmp 0xef9b
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hgets
char *hgets(char *buffer, int size, hFILE *fp)
{
    if (size < 1) {
        fp->has_errno = errno = EINVAL;
        return NULL;
    }
    return hgetln(buffer, size, fp) > 0 ? buffer : NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
testl %esi, %esi
jle 0xf090
movq %rdi, %r14
movl %esi, %esi
movl $0xa, %edx
movq %rbx, %rcx
callq 0xef50
movq %rax, %rcx
xorl %eax, %eax
testq %rcx, %rcx
cmovgq %r14, %rax
jmp 0xf0a1
callq 0x4050
movl $0x16, %ecx
movl %ecx, (%rax)
movl %ecx, 0x34(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hpeek
ssize_t hpeek(hFILE *fp, void *buffer, size_t nbytes)
{
    size_t n = fp->end - fp->begin;
    while (n < nbytes) {
        ssize_t ret = refill_buffer(fp);
        if (ret < 0) return ret;
        else if (ret == 0) break;
        else n += ret;
    }

    if (n > nbytes) n = nbytes;
    memcpy(buffer, fp->begin, n);
    return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x10(%rdi), %r13
subq 0x8(%rdi), %r13
movl $0x1, %ebp
cmpq %rbx, %r13
jae 0xf0fe
movq %r15, %rdi
callq 0xeec1
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
leal (%rcx,%rcx,2), %ecx
movl $0x0, %edx
cmovgq %rax, %rdx
cmovsq %rax, %r12
cmovsl %ebp, %ecx
addq %rdx, %r13
testl %ecx, %ecx
je 0xf0ca
cmpl $0x3, %ecx
jne 0xf117
cmpq %rbx, %r13
cmovbq %r13, %rbx
movq 0x8(%r15), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x43c0
movq %rbx, %r12
movq %r12, %rax
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/hfile.c
// Function: hread2
HTSLIB_EXPORT
ssize_t hread2(hFILE *fp, void *destv, size_t nbytes, size_t nread)
{
    const size_t capacity = fp->limit - fp->buffer;
    int buffer_invalidated = 0;
    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;
        else buffer_invalidated = 1;
        fp->offset += n;
        dest += n, nbytes -= n;
        nread += n;
    }

    if (buffer_invalidated) {
        // Our unread buffer is empty, so begin == end, but our already-read
        // buffer [buffer,begin) is likely non-empty and is no longer valid as
        // its contents are no longer adjacent to the file position indicator.
        // Discard it so that hseek() can't try to take advantage of it.
        fp->offset += fp->begin - fp->buffer;
        fp->begin = fp->end = fp->buffer;
    }

    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, %r12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x18(%rdi), %rcx
subq (%rdi), %rcx
addq %r12, %r15
subq %r12, %r14
leaq (%r14,%r14), %rax
movq %rcx, (%rsp)
cmpq %rcx, %rax
jb 0xf1c1
xorl %ebp, %ebp
testb $0x1, 0x30(%rbx)
jne 0xf1a5
movq 0x20(%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq *(%rax)
movq %rax, %r13
testq %rax, %rax
js 0xf20f
movl $0x1, %eax
jne 0xf18a
orb $0x1, 0x30(%rbx)
movl %ebp, %eax
addq %r13, 0x28(%rbx)
addq %r13, %r15
subq %r13, %r14
addq %r13, %r12
leaq (%r14,%r14), %rcx
movl %eax, %ebp
cmpq (%rsp), %rcx
jae 0xf15c
jmp 0xf1a7
movl %ebp, %eax
testl %eax, %eax
je 0xf1c1
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
addq %rcx, 0x28(%rbx)
movq %rax, 0x10(%rbx)
movq %rax, 0x8(%rbx)
movq %r12, %r13
testq %r14, %r14
je 0xf219
testb $0x1, 0x30(%rbx)
jne 0xf219
movq %rbx, %rdi
callq 0xeec1
testq %rax, %rax
js 0xf20a
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %r12
subq %rsi, %r12
cmpq %r14, %r12
cmovaeq %r14, %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x8(%rbx)
addq %r12, %r15
addq %r12, %r13
subq %r12, %r14
jne 0xf1c9
jmp 0xf219
movq %rax, %r13
jmp 0xf219
callq 0x4050
movl (%rax), %eax
movl %eax, 0x34(%rbx)
movq %r13, %rax
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/hfile.c
// Function: hflush
int hflush(hFILE *fp)
{
    if (flush_buffer(fp) < 0) return EOF;
    if (fp->backend->flush) {
        if (fp->backend->flush(fp) < 0) { fp->has_errno = errno; return EOF; }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xf270
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
js 0xf267
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0xf267
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
jns 0xf267
callq 0x4050
movl (%rax), %eax
movl %eax, 0x34(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: flush_buffer
static ssize_t flush_buffer(hFILE *fp)
{
    const char *buffer = fp->buffer;
    while (buffer < fp->begin) {
        ssize_t n = fp->backend->write(fp, buffer, fp->begin - buffer);
        if (n < 0) { fp->has_errno = errno; return n; }
        buffer += n;
        fp->offset += n;
    }

    fp->begin = fp->buffer;  // Leave the buffer empty
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
movq 0x8(%rdi), %rdx
cmpq %rdx, %r14
jae 0xf2af
movq 0x20(%rbx), %rax
subq %r14, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
movq %rax, %r15
testq %rax, %rax
js 0xf2b8
addq %r15, 0x28(%rbx)
addq %r15, %r14
movq 0x8(%rbx), %rdx
cmpq %rdx, %r14
jb 0xf284
movq (%rbx), %r14
movq %r14, 0x8(%rbx)
xorl %r15d, %r15d
jmp 0xf2c2
callq 0x4050
movl (%rax), %eax
movl %eax, 0x34(%rbx)
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hwrite2
HTSLIB_EXPORT
ssize_t hwrite2(hFILE *fp, const void *srcv, size_t totalbytes, size_t ncopied)
{
    const char *src = (const char *) srcv;
    ssize_t ret;
    const size_t capacity = fp->limit - fp->buffer;
    size_t remaining = totalbytes - ncopied;
    src += ncopied;

    ret = flush_buffer(fp);
    if (ret < 0) return ret;

    // Write large blocks out directly from the source buffer
    while (remaining * 2 >= capacity) {
        ssize_t n = fp->backend->write(fp, src, remaining);
        if (n < 0) { fp->has_errno = errno; return n; }
        fp->offset += n;
        src += n, remaining -= n;
    }

    // Just buffer any remaining characters
    memcpy(fp->begin, src, remaining);
    fp->begin += remaining;

    return totalbytes;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x18(%rdi), %rbp
subq (%rdi), %rbp
callq 0xf270
testq %rax, %rax
js 0xf373
movq %rbx, %r12
subq %r13, %r12
addq %r13, %r15
leaq (%r12,%r12), %rax
cmpq %rbp, %rax
jb 0xf35e
movq 0x20(%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x8(%rax)
movq %rax, %r13
testq %rax, %rax
js 0xf378
addq %r13, 0x28(%r14)
addq %r13, %r15
subq %r13, %r12
jmp 0xf331
movq 0x8(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x8(%r14)
jmp 0xf386
movq %rax, %rbx
jmp 0xf386
callq 0x4050
movl (%rax), %eax
movl %eax, 0x34(%r14)
movq %r13, %rbx
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_O3/samtools[P]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->preserve) {
        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 0xf501
movq %rbx, %rdi
callq 0xf22b
testl %eax, %eax
jns 0xf501
movl 0x34(%rbx), %ebp
testb $0x8, 0x30(%rbx)
jne 0xf524
movq 0x20(%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
testl %eax, %eax
jns 0xf51c
callq 0x4050
movl (%rax), %ebp
movq %rbx, %rdi
callq 0xed72
testl %ebp, %ebp
je 0xf536
callq 0x4050
movl %ebp, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xf538
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hclose_abruptly
void hclose_abruptly(hFILE *fp)
{
    int save = errno;
    if (fp->preserve)
        return;
    if (fp->backend->close(fp) < 0) { /* Ignore subsequent errors */ }
    hfile_destroy(fp);
    errno = save;
}

// Assembly:
testb $0x8, 0x30(%rdi)
jne 0xf56f
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x4050
movq %rax, %r14
movl (%rax), %ebp
movq 0x20(%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq %rbx, %rdi
callq 0xed72
movl %ebp, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hdopen
hFILE *hdopen(int fd, const char *mode)
{
    hFILE_fd *fp = (hFILE_fd*) hfile_init(sizeof (hFILE_fd), mode, blksize(fd));
    if (fp == NULL) return NULL;

    fp->fd = fd;
    fp->is_socket = (strchr(mode, 's') != NULL);
    fp->is_shared = (strchr(mode, 'S') != NULL);
    fp->base.backend = &fd_backend;
    return &fp->base;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movq %rsp, %rsi
callq 0x4890
testl %eax, %eax
je 0xf590
xorl %edx, %edx
jmp 0xf5aa
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%rsp), %eax
movl $0x20000, %edx          # imm = 0x20000
cmpl $0x1000, %eax           # imm = 0x1000
je 0xf5aa
movq 0x38(%rsp), %rdx
movl $0x40, %edi
movq %rbx, %rsi
callq 0xecc0
movq %rax, %r14
testq %rax, %rax
je 0xf610
movl %ebp, 0x38(%r14)
movq %rbx, %rdi
movl $0x73, %esi
callq 0x4190
testq %rax, %rax
setne %al
movb 0x3c(%r14), %bpl
andb $-0x2, %bpl
orb %al, %bpl
movb %bpl, 0x3c(%r14)
movq %rbx, %rdi
movl $0x53, %esi
callq 0x4190
testq %rax, %rax
setne %al
addb %al, %al
andb $-0x3, %bpl
orb %al, %bpl
movb %bpl, 0x3c(%r14)
leaq 0xa61e4(%rip), %rax     # 0xb57f0
movq %rax, 0x20(%r14)
movq %r14, %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_oflags
HTSLIB_EXPORT
int hfile_oflags(const char *mode)
{
    int rdwr = 0, flags = 0;
    const char *s;
    for (s = mode; *s; s++)
        switch (*s) {
        case 'r': rdwr = O_RDONLY;  break;
        case 'w': rdwr = O_WRONLY; flags |= O_CREAT | O_TRUNC;  break;
        case 'a': rdwr = O_WRONLY; flags |= O_CREAT | O_APPEND;  break;
        case '+': rdwr = O_RDWR;  break;
#ifdef O_CLOEXEC
        case 'e': flags |= O_CLOEXEC;  break;
#endif
#ifdef O_EXCL
        case 'x': flags |= O_EXCL;  break;
#endif
        default:  break;
        }

#ifdef O_BINARY
    flags |= O_BINARY;
#endif

    return rdwr | flags;
}

// Assembly:
xorl %ecx, %ecx
xorl %eax, %eax
movzbl (%rdi), %edx
cmpl $0x71, %edx
jle 0xf63e
cmpl $0x78, %edx
je 0xf64f
cmpl $0x77, %edx
je 0xf656
cmpl $0x72, %edx
jne 0xf66d
xorl %ecx, %ecx
jmp 0xf66d
cmpl $0x2b, %edx
je 0xf662
cmpl $0x61, %edx
jne 0xf669
orl $0x440, %eax            # imm = 0x440
jmp 0xf65b
orl $0x80, %eax
jmp 0xf66d
orl $0x240, %eax            # imm = 0x240
movl $0x1, %ecx
jmp 0xf66d
movl $0x2, %ecx
jmp 0xf66d
testl %edx, %edx
je 0xf672
incq %rdi
jmp 0xf623
orl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_mem_get_buffer
char *hfile_mem_get_buffer(hFILE *file, size_t *length) {
    if (file->backend != &mem_backend) {
        errno = EINVAL;
        return NULL;
    }

    if (length)
        *length = file->buffer - file->limit;

    return file->buffer;
}

// Assembly:
leaq 0xa619c(%rip), %rax     # 0xb5818
cmpq %rax, 0x20(%rdi)
je 0xf695
pushq %rax
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
retq
movq (%rdi), %rax
testq %rsi, %rsi
je 0xf6a7
movq %rax, %rcx
subq 0x18(%rdi), %rcx
movq %rcx, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_mem_steal_buffer
char *hfile_mem_steal_buffer(hFILE *file, size_t *length) {
    char *buf = hfile_mem_get_buffer(file, length);
    if (buf)
        file->buffer = NULL;
    return buf;
}

// Assembly:
leaq 0xa6169(%rip), %rax     # 0xb5818
cmpq %rax, 0x20(%rdi)
je 0xf6c8
pushq %rax
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
retq
movq (%rdi), %rax
testq %rsi, %rsi
je 0xf6da
movq %rax, %rcx
subq 0x18(%rdi), %rcx
movq %rcx, (%rsi)
testq %rax, %rax
je 0xf6e7
movq $0x0, (%rdi)
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hopenv_mem
static hFILE *hopenv_mem(const char *filename, const char *mode, va_list args)
{
    char* buffer = va_arg(args, char*);
    size_t sz = va_arg(args, size_t);
    va_end(args);

    hFILE* hf;

    if(!(hf = create_hfile_mem(buffer, mode, sz, sz))){
        free(buffer);
        return NULL;
    }

    return hf;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl (%rdx), %ecx
cmpq $0x29, %rcx
jae 0xf74c
movq 0x10(%rdx), %rdi
movq %rcx, %rax
addq $0x8, %rax
movl %eax, (%rdx)
movq (%rdi,%rcx), %rbx
cmpl $0x20, %ecx
ja 0xf75b
addq 0x10(%rdx), %rax
addl $0x10, %ecx
movl %ecx, (%rdx)
jmp 0xf767
movq 0x8(%rdx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdx)
movq (%rax), %rbx
movq 0x8(%rdx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdx)
movq (%rax), %rcx
movl $0x38, %edi
movq %rbx, %rdx
movq %rcx, %r8
callq 0xeda0
movq %rax, %r14
testq %rax, %rax
je 0xf78f
leaq 0xa608f(%rip), %rax     # 0xb5818
movq %rax, 0x20(%r14)
jmp 0xf797
movq %rbx, %rdi
callq 0x45c0
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: crypt4gh_needed
static hFILE *crypt4gh_needed(const char *url, const char *mode)
{
    const char *u = strncmp(url, "crypt4gh:", 9) == 0 ? url + 9 : url;
#if defined(ENABLE_PLUGINS)
    const char *enable_plugins = "";
#else
    const char *enable_plugins = "You also need to rebuild HTSlib with plug-ins enabled.\n";
#endif

    hts_log_error("Accessing \"%s\" needs the crypt4gh plug-in.\n"
                  "It can be found at "
                  "https://github.com/samtools/htslib-crypt4gh\n"
                  "%s"
                  "If you have the plug-in, please ensure it can be "
                  "found on your HTS_PATH.",
                  u, enable_plugins);

    errno = EPROTONOSUPPORT;
    return NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x85a9a(%rip), %rsi     # 0x95554
movl $0x9, %edx
callq 0x4210
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leaq (%rcx,%rcx,8), %rcx
addq %rbx, %rcx
leaq 0x85abd(%rip), %rsi     # 0x95596
leaq 0x85ac6(%rip), %rdx     # 0x955a6
leaq 0x85a77(%rip), %r8      # 0x9555e
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
callq 0x4050
movl $0x5d, (%rax)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile.c
// Function: hfile_shutdown
void hfile_shutdown(int do_close_plugin)
{
    pthread_mutex_lock(&plugins_lock);

    if (schemes) {
        kh_destroy(scheme_string, schemes);
        schemes = NULL;
    }

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

    pthread_mutex_unlock(&plugins_lock);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0xa6cc0(%rip), %rdi     # 0xb67d0
callq 0x4750
movq 0xa6cdc(%rip), %rbx     # 0xb67f8
testq %rbx, %rbx
je 0xfb4f
movq 0x18(%rbx), %rdi
callq 0x45c0
movq 0x10(%rbx), %rdi
callq 0x45c0
movq 0x20(%rbx), %rdi
callq 0x45c0
movq %rbx, %rdi
callq 0x45c0
movq $0x0, 0xa6ca9(%rip) # 0xb67f8
movq 0xa6caa(%rip), %rbx     # 0xb6800
testq %rbx, %rbx
je 0xfb81
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0xfb66
callq *%rax
movq 0x20(%rbx), %r14
movq %r14, 0xa6c8f(%rip)     # 0xb6800
movq %rbx, %rdi
callq 0x45c0
movq %r14, %rbx
testq %r14, %r14
jne 0xfb5b
leaq 0xa6c48(%rip), %rdi     # 0xb67d0
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4340