LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: bgzf_read
ssize_t bgzf_read(BGZF *fp, void *data, size_t length)
{
    ssize_t bytes_read = 0;
    uint8_t *output = (uint8_t*)data;
    if (length <= 0) return 0;
    assert(fp->is_write == 0);
    while (bytes_read < length) {
        int copy_length, available = fp->block_length - fp->block_offset;
        uint8_t *buffer;
        if (available <= 0) {
            int ret = bgzf_read_block(fp);
            if (ret != 0) {
                if (hts_verbose >= 2) {
                    fprintf(stderr, "[E::%s] bgzf_read_block error %d after %zd of %zu bytes\n", __func__, ret, bytes_read, length);
                }
                fp->errcode |= BGZF_ERR_ZLIB;
                return -1;
            }
            available = fp->block_length - fp->block_offset;
            if (available <= 0) break;
        }
        copy_length = length - bytes_read < available? length - bytes_read : available;
        buffer = (uint8_t*)fp->uncompressed_block;
        memcpy(output, buffer + fp->block_offset, copy_length);
        fp->block_offset += copy_length;
        output += copy_length;
        bytes_read += copy_length;
    }
    if (fp->block_offset == fp->block_length) {
        fp->block_address = htell(fp->fp);
        fp->block_offset = fp->block_length = 0;
    }
    fp->uncompressed_address += bytes_read;
    return bytes_read;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x4499e
movq %rdi, %rbx
testb $0x3, 0x2(%rdi)
jne 0x449bc
movq %rdx, %r15
movq %rsi, %r12
xorl %r14d, %r14d
movq %r15, %r13
subq %r14, %r13
jbe 0x44975
movl 0x8(%rbx), %ebp
subl 0xc(%rbx), %ebp
jg 0x44915
movq %rbx, %rdi
callq 0x43e22
testl %eax, %eax
je 0x448fe
leaq 0x1fc63(%rip), %rcx     # 0x64550
cmpl $0x2, (%rcx)
jge 0x44947
orb $0x1, (%rbx)
movl $0x1, %eax
xorl %ecx, %ecx
jmp 0x44911
movl 0x8(%rbx), %ebp
subl 0xc(%rbx), %ebp
setg %cl
xorl %eax, %eax
testl %ebp, %ebp
setle %al
leal (%rax,%rax,2), %eax
testb %cl, %cl
je 0x44941
movslq %ebp, %rax
cmpq %rax, %r13
cmovbq %r13, %rax
movslq 0xc(%rbx), %rsi
addq 0x20(%rbx), %rsi
movslq %eax, %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x4420
addl %r13d, 0xc(%rbx)
addq %r13, %r12
addq %r13, %r14
xorl %eax, %eax
testl %eax, %eax
je 0x448c6
jmp 0x44970
movq 0x1f67a(%rip), %rcx     # 0x63fc8
movq (%rcx), %rdi
leaq 0x11162(%rip), %rsi     # 0x55aba
leaq 0x11194(%rip), %rdx     # 0x55af3
movl %eax, %ecx
movq %r14, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x4770
jmp 0x448f2
cmpl $0x3, %eax
jne 0x449a3
movl 0xc(%rbx), %eax
cmpl 0x8(%rbx), %eax
jne 0x44998
movq 0x38(%rbx), %rax
movq 0x28(%rax), %rcx
addq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, 0x10(%rbx)
movq $0x0, 0x8(%rbx)
addq %r14, 0x18(%rbx)
jmp 0x449aa
xorl %r14d, %r14d
jmp 0x449aa
movq $-0x1, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x110bb(%rip), %rdi     # 0x55a7e
leaq 0x10f7b(%rip), %rsi     # 0x55945
leaq 0x110bf(%rip), %rcx     # 0x55a90
movl $0x2b2, %edx            # imm = 0x2B2
callq 0x4350
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: bgzf_flush
int bgzf_flush(BGZF *fp)
{
    if (!fp->is_write) return 0;
#ifdef BGZF_MT
    if (fp->mt) {
        if (fp->block_offset) mt_queue(fp); // guaranteed that assertion does not fail
        return mt_flush_queue(fp);
    }
#endif
    while (fp->block_offset > 0) {
        int block_length;
        if ( fp->idx_build_otf )
        {
            bgzf_index_add_block(fp);
            fp->idx->ublock_addr += fp->block_offset;
        }
        block_length = deflate_block(fp, fp->block_offset);
        if (block_length < 0) {
            if (hts_verbose >= 3) fprintf(stderr, "[E::%s] deflate_block error %d\n", __func__, block_length);
            return -1;
        }
        if (hwrite(fp->fp, fp->compressed_block, block_length) != block_length) {
            if (hts_verbose >= 1) fprintf(stderr, "[E::%s] hwrite error (wrong size)\n", __func__);
            fp->errcode |= BGZF_ERR_IO; // possibly truncated file
            return -1;
        }
        fp->block_address += block_length;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testb $0x3, 0x2(%rdi)
je 0x44cc3
movq %rdi, %r14
cmpq $0x0, 0x40(%rdi)
movl 0xc(%rdi), %eax
je 0x44c34
testl %eax, %eax
je 0x44c1e
movq %r14, %rdi
callq 0x44d28
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x44d92
testl %eax, %eax
jle 0x44cc3
cmpl $0x0, 0x50(%r14)
je 0x44c57
movq %r14, %rdi
callq 0x44589
movslq 0xc(%r14), %rax
movq 0x48(%r14), %rcx
addq %rax, 0x10(%rcx)
movl 0xc(%r14), %esi
movq %r14, %rdi
callq 0x44edd
testl %eax, %eax
js 0x44cd6
movq 0x28(%r14), %r13
movq 0x38(%r14), %rbp
movl %eax, %r15d
movq 0x8(%rbp), %rdi
movq 0x18(%rbp), %rbx
subq %rdi, %rbx
cmpq %r15, %rbx
movq %r15, %r12
cmovbq %rbx, %r12
movq %r13, %rsi
movq %r12, %rdx
callq 0x4420
addq %r12, 0x8(%rbp)
cmpq %r15, %rbx
jae 0x44caf
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x48356
movq %rax, %r12
cmpq %r15, %r12
jne 0x44d0a
addq %r15, 0x10(%r14)
cmpl $0x0, 0xc(%r14)
jg 0x44c3c
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f873(%rip), %rcx     # 0x64550
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rcx)
jl 0x44cc5
movq 0x1f2da(%rip), %rcx     # 0x63fc8
movq (%rcx), %rdi
leaq 0x10e05(%rip), %rsi     # 0x55afd
leaq 0x10e1e(%rip), %rdx     # 0x55b1d
movl %eax, %ecx
xorl %eax, %eax
callq 0x4770
jmp 0x44cc5
leaq 0x1f83f(%rip), %rax     # 0x64550
cmpl $0x0, (%rax)
jg 0x44d21
orb $0x4, (%r14)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x44cc5
callq 0x5cac
jmp 0x44d16
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: mt_queue
static void mt_queue(BGZF *fp)
{
    mtaux_t *mt = fp->mt;
    assert(mt->curr < mt->n_blks); // guaranteed by the caller
    memcpy(mt->blk[mt->curr], fp->uncompressed_block, fp->block_offset);
    mt->len[mt->curr] = fp->block_offset;
    fp->block_offset = 0;
    ++mt->curr;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x40(%rdi), %r14
movslq 0x8(%r14), %rax
cmpl 0x4(%r14), %eax
jge 0x44d73
movq %rdi, %rbx
movq 0x18(%r14), %rcx
movq (%rcx,%rax,8), %rdi
movq 0x20(%rbx), %rsi
movslq 0xc(%rbx), %rdx
callq 0x4420
movl 0xc(%rbx), %eax
movq 0x20(%r14), %rcx
movslq 0x8(%r14), %rdx
movl %eax, (%rcx,%rdx,4)
movl $0x0, 0xc(%rbx)
incl 0x8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x1113f(%rip), %rdi     # 0x55eb9
leaq 0x10bc4(%rip), %rsi     # 0x55945
leaq 0x11147(%rip), %rcx     # 0x55ecf
movl $0x341, %edx            # imm = 0x341
callq 0x4350
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: mt_flush_queue
static int mt_flush_queue(BGZF *fp)
{
    int i;
    mtaux_t *mt = fp->mt;
    // signal all the workers to compress
    pthread_mutex_lock(&mt->lock);
    for (i = 0; i < mt->n_threads; ++i) mt->w[i].toproc = 1;
    mt->proc_cnt = 0;
    pthread_cond_broadcast(&mt->cv);
    pthread_mutex_unlock(&mt->lock);
    // worker 0 is doing things here
    worker_aux(&mt->w[0]);
    // wait for all the threads to complete
    while (mt->proc_cnt < mt->n_threads);
    // dump data to disk
    for (i = 0; i < mt->n_threads; ++i) fp->errcode |= mt->w[i].errcode;
    if (fp->errcode == 0) {
        /* Only try to write if all the threads worked, as otherwise we
           could get a file with holes in it */
        for (i = 0; i < mt->curr; ++i) {
            if (hwrite(fp->fp, mt->blk[i], mt->len[i]) != mt->len[i]) {
                fp->errcode |= BGZF_ERR_IO;
                break;
            }
        }
    }
    mt->curr = 0;
    return (fp->errcode == 0)? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq 0x40(%rdi), %rbp
leaq 0x38(%rbp), %r14
movq %r14, %rdi
callq 0x47a0
movslq (%rbp), %rax
testq %rax, %rax
jle 0x44dd7
movq 0x28(%rbp), %rcx
shlq $0x5, %rax
xorl %edx, %edx
movl $0x1, 0x18(%rcx,%rdx)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x44dc6
movl $0x0, 0x10(%rbp)
leaq 0x60(%rbp), %rdi
callq 0x41e0
movq %r14, %rdi
callq 0x43f0
movq 0x28(%rbp), %rdi
callq 0x461f9
movl (%rbp), %eax
movl 0x10(%rbp), %ecx
cmpl %eax, %ecx
jl 0x44dfb
cmpl $0x0, (%rbp)
jle 0x44e2a
movl $0x14, %eax
xorl %ecx, %ecx
movq 0x28(%rbp), %rdx
movzwl (%rdx,%rax), %edx
orl %edx, (%r15)
incq %rcx
movslq (%rbp), %rdx
addq $0x20, %rax
cmpq %rdx, %rcx
jl 0x44e0f
cmpw $0x0, (%r15)
je 0x44e4f
movl $0x0, 0x8(%rbp)
xorl %eax, %eax
cmpw (%r15), %ax
sbbl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x8(%rbp)
jle 0x44e31
xorl %ebx, %ebx
movq %r15, 0x8(%rsp)
movq 0x38(%r15), %r15
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rcx
movq (%rax,%rbx,8), %rsi
movslq (%rcx,%rbx,4), %r13
movq 0x8(%r15), %rdi
movq 0x18(%r15), %r12
subq %rdi, %r12
cmpq %r13, %r12
movq %r13, %r14
cmovbq %r12, %r14
movq %rsi, 0x10(%rsp)
movq %r14, %rdx
callq 0x4420
addq %r14, 0x8(%r15)
cmpq %r13, %r12
jae 0x44eb1
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x48356
movq %rax, %r14
movq 0x20(%rbp), %rax
movslq (%rax,%rbx,4), %rax
cmpq %rax, %r14
movq 0x8(%rsp), %r15
jne 0x44ed4
incq %rbx
movslq 0x8(%rbp), %rax
cmpq %rax, %rbx
jl 0x44e5c
jmp 0x44e31
orb $0x4, (%r15)
jmp 0x44e31
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 )
    {
        if (hts_verbose >= 3) {
            fprintf(stderr, "[E::%s] compression error %d\n", __func__, 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 0x28(%rdi), %rdi
movq 0x20(%rbx), %rdx
testl %r8d, %r8d
js 0x44f15
movslq %esi, %rcx
shll $0x3, %r8d
sarl $0x17, %r8d
movq %rsp, %rsi
callq 0x43c4d
testl %eax, %eax
jne 0x44f51
jmp 0x44f77
movq 0x58(%rbx), %r14
xorl %eax, %eax
testl %esi, %esi
sete %al
shll $0x2, %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 0x4260
cmpl $-0x2, %eax
jne 0x44f67
leaq 0x1f604(%rip), %rax     # 0x64550
cmpl $0x0, (%rax)
jg 0x44f90
leaq 0x1f5f8(%rip), %rax     # 0x64550
cmpl $0x3, (%rax)
jge 0x44f89
orb $0x1, (%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x44f81
movl 0x20(%r14), %eax
movl $0x10000, %ecx          # imm = 0x10000
subq %rax, %rcx
movq %rcx, (%rsp)
movl $0x0, 0xc(%rbx)
movl (%rsp), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x5cf1
jmp 0x44f5d
callq 0x5ccb
jmp 0x44f51
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: lazy_flush
static int lazy_flush(BGZF *fp)
{
    if (fp->mt) {
        if (fp->block_offset) mt_queue(fp);
        return (fp->mt->curr < fp->mt->n_blks)? 0 : mt_flush_queue(fp);
    }
    else return bgzf_flush(fp);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpq $0x0, 0x40(%rdi)
je 0x44fd2
cmpl $0x0, 0xc(%rbx)
je 0x44fc2
movq %rbx, %rdi
callq 0x44d28
movq 0x40(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl 0x4(%rax), %ecx
jge 0x44fdb
xorl %eax, %eax
popq %rbx
retq
movq %rbx, %rdi
popq %rbx
jmp 0x44bf0
movq %rbx, %rdi
popq %rbx
jmp 0x44d92
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: bgzf_write
ssize_t bgzf_write(BGZF *fp, const void *data, size_t length)
{
    if ( !fp->is_compressed )
        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
testl $0x60000000, %eax       # imm = 0x60000000
je 0x4506d
testl $0x30000, %eax          # imm = 0x30000
je 0x450cb
movq %rbx, %r13
testq %rbx, %rbx
jle 0x45065
movq %rbx, %r13
movslq 0xc(%r15), %rdi
movl $0xff00, %eax           # imm = 0xFF00
subq %rdi, %rax
cmpq %rax, %r13
movl %r13d, %ecx
cmovgel %eax, %ecx
addq 0x20(%r15), %rdi
movslq %ecx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x4420
movl 0xc(%r15), %eax
addl %r12d, %eax
movl %eax, 0xc(%r15)
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0x4505a
movq %r15, %rdi
callq 0x44fa9
testl %eax, %eax
jne 0x450b7
addq %r12, %r14
subq %r12, %r13
testq %r13, %r13
jg 0x45015
subq %r13, %rbx
movq %rbx, %r15
jmp 0x450be
movq 0x38(%r15), %r12
movq 0x8(%r12), %rdi
movq 0x18(%r12), %r13
subq %rdi, %r13
cmpq %rbx, %r13
movq %rbx, %r15
cmovbq %r13, %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x4420
addq %r15, 0x8(%r12)
cmpq %rbx, %r13
jae 0x450be
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x48356
movq $-0x1, %r15
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x10a79(%rip), %rdi     # 0x55b4b
leaq 0x1086c(%rip), %rsi     # 0x55945
leaq 0x10a78(%rip), %rcx     # 0x55b58
movl $0x3a9, %edx            # imm = 0x3A9
callq 0x4350
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: mt_destroy
static void mt_destroy(mtaux_t *mt)
{
    int i;
    // signal all workers to quit
    pthread_mutex_lock(&mt->lock);
    mt->done = 1; mt->proc_cnt = 0;
    pthread_cond_broadcast(&mt->cv);
    pthread_mutex_unlock(&mt->lock);
    for (i = 1; i < mt->n_threads; ++i) pthread_join(mt->tid[i], 0); // worker 0 is effectively launched by the master thread
    // free other data allocated on heap
    for (i = 0; i < mt->n_blks; ++i) free(mt->blk[i]);
    for (i = 0; i < mt->n_threads; ++i) free(mt->w[i].buf);
    free(mt->blk); free(mt->len); free(mt->w); free(mt->tid);
    pthread_cond_destroy(&mt->cv);
    pthread_mutex_destroy(&mt->lock);
    free(mt);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
movq %r14, %rdi
callq 0x47a0
movl $0x1, 0xc(%rbx)
movl $0x0, 0x10(%rbx)
leaq 0x60(%rbx), %r15
movq %r15, %rdi
callq 0x41e0
movq %r14, %rdi
callq 0x43f0
cmpl $0x2, (%rbx)
jl 0x453dc
movl $0x1, %r12d
movq 0x30(%rbx), %rax
movq (%rax,%r12,8), %rdi
xorl %esi, %esi
callq 0x4490
incq %r12
movslq (%rbx), %rax
cmpq %rax, %r12
jl 0x453c2
cmpl $0x0, 0x4(%rbx)
jle 0x453fe
xorl %r12d, %r12d
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x4610
incq %r12
movslq 0x4(%rbx), %rax
cmpq %rax, %r12
jl 0x453e5
cmpl $0x0, (%rbx)
jle 0x45428
movl $0x8, %r12d
xorl %r13d, %r13d
movq 0x28(%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x4610
incq %r13
movslq (%rbx), %rax
addq $0x20, %r12
cmpq %rax, %r13
jl 0x4540c
movq 0x18(%rbx), %rdi
callq 0x4610
movq 0x20(%rbx), %rdi
callq 0x4610
movq 0x28(%rbx), %rdi
callq 0x4610
movq 0x30(%rbx), %rdi
callq 0x4610
movq %r15, %rdi
callq 0x4a20
movq %r14, %rdi
callq 0x45e0
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x4610
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x48(%rdi), %rax
testq %rax, %rax
je 0x4549c
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rax), %rdi
callq 0x4610
movq 0x48(%rbx), %rdi
callq 0x4610
movq $0x0, 0x48(%rbx)
movl $0x0, 0x50(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: bgzf_check_EOF
int bgzf_check_EOF(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; }
        else 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 0x38(%rdi), %rdi
movq 0x28(%rdi), %r14
addq 0x8(%rdi), %r14
subq (%rdi), %r14
movq $-0x1c, %rsi
movl $0x2, %edx
callq 0x48413
testq %rax, %rax
js 0x45579
movq 0x38(%rbx), %r12
movq 0x8(%r12), %rsi
movq 0x10(%r12), %r13
subq %rsi, %r13
cmpq $0x1c, %r13
movl $0x1c, %r15d
cmovbq %r13, %r15
movq %rsp, %rdi
movq %r15, %rdx
callq 0x4420
addq %r15, 0x8(%r12)
cmpq $0x1b, %r13
ja 0x4552b
movq %rsp, %rsi
movl $0x1c, %edx
movq %r12, %rdi
movq %r15, %rcx
callq 0x48187
movq %rax, %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq $0x1c, %r15
jne 0x45598
movq 0x38(%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x48413
testq %rax, %rax
js 0x45598
movdqu 0xc(%rsp), %xmm0
pcmpeqb 0x10399(%rip), %xmm0    # 0x558f0
movdqa (%rsp), %xmm1
pcmpeqb 0x1039c(%rip), %xmm1    # 0x55900
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
xorl %ebp, %ebp
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %bpl
jmp 0x45598
callq 0x4070
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x1d, (%rax)
jne 0x45598
movq 0x38(%rbx), %rax
movl $0x0, 0x34(%rax)
movl $0x2, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: bgzf_seek
int64_t bgzf_seek(BGZF* fp, int64_t pos, int where)
{
    int block_offset;
    int64_t block_address;

    if (fp->is_write || where != SEEK_SET) {
        fp->errcode |= BGZF_ERR_MISUSE;
        return -1;
    }
    block_offset = pos & 0xFFFF;
    block_address = pos >> 16;
    if (hseek(fp->fp, block_address, SEEK_SET) < 0) {
        fp->errcode |= BGZF_ERR_IO;
        return -1;
    }
    fp->block_length = 0;  // indicates current block has not been loaded
    fp->block_address = block_address;
    fp->block_offset = block_offset;
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %eax
movl %eax, %ecx
andl $0x30000, %ecx          # imm = 0x30000
orl %edx, %ecx
je 0x455cd
orl $0x8, %eax
movl %eax, (%rbx)
movq $-0x1, %rax
jmp 0x455fe
movq %rsi, %r14
movq %rsi, %r15
sarq $0x10, %r15
movq 0x38(%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x48413
testq %rax, %rax
js 0x45604
movzwl %r14w, %eax
movl $0x0, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movl %eax, 0xc(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
orb $0x4, (%rbx)
jmp 0x455c4
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 -1;
    if (n != 16) return 0;
    return memcmp(g_magic, buf, 16) == 0? 1 : 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0xe2fe(%rip), %rsi      # 0x53919
callq 0x4883b
xorl %ebx, %ebx
testq %rax, %rax
je 0x456a2
movq %rax, %r14
movq 0x8(%rax), %rsi
movq 0x10(%rax), %r12
subq %rsi, %r12
cmpq $0x10, %r12
movl $0x10, %r15d
cmovbq %r12, %r15
movq %rsp, %rdi
movq %r15, %rdx
callq 0x4420
addq %r15, 0x8(%r14)
cmpq $0xf, %r12
ja 0x4566e
movq %rsp, %rsi
movl $0x10, %edx
movq %r14, %rdi
movq %r15, %rcx
callq 0x48187
movq %rax, %r15
movq %r14, %rdi
callq 0x484b2
testl %eax, %eax
js 0x4569d
cmpl $0x10, %r15d
jne 0x456a2
movdqa (%rsp), %xmm0
pcmpeqb 0x10273(%rip), %xmm0    # 0x55900
pmovmskb %xmm0, %eax
xorl %ebx, %ebx
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %bl
jmp 0x456a2
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: bgzf_getc
int bgzf_getc(BGZF *fp)
{
    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 = htell(fp->fp);
        fp->block_offset = 0;
        fp->block_length = 0;
    }
    fp->uncompressed_address++;
    return c;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0xc(%rdi), %eax
cmpl 0x8(%rdi), %eax
jge 0x456f4
movq 0x20(%rbx), %rax
movslq 0xc(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0xc(%rbx)
movzbl (%rax,%rcx), %eax
cmpl 0x8(%rbx), %edx
jne 0x456ee
movq 0x38(%rbx), %rcx
movq 0x28(%rcx), %rdx
addq 0x8(%rcx), %rdx
subq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq $0x0, 0x8(%rbx)
incq 0x18(%rbx)
jmp 0x45707
movq %rbx, %rdi
callq 0x43e22
movl %eax, %ecx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testl %ecx, %ecx
je 0x45709
popq %rbx
retq
cmpl $0x0, 0x8(%rbx)
jne 0x456bc
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x45707
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x4546d
movl $0x1, %edi
movl $0x18, %esi
callq 0x4360
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x4590b
movl $0x1, 0x50(%rbx)
xorl %eax, %eax
jmp 0x45910
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/bgzf.c
// Function: worker_aux
static int worker_aux(worker_t *w)
{
    int i, stop = 0;
    // wait for condition: to process or all done
    pthread_mutex_lock(&w->mt->lock);
    while (!w->toproc && !w->mt->done)
        pthread_cond_wait(&w->mt->cv, &w->mt->lock);
    if (w->mt->done) stop = 1;
    w->toproc = 0;
    pthread_mutex_unlock(&w->mt->lock);
    if (stop) return 1; // to quit the thread
    w->errcode = 0;
    for (i = w->i; i < w->mt->curr; i += w->mt->n_threads) {
        size_t clen = BGZF_MAX_BLOCK_SIZE;
        int ret = bgzf_compress(w->buf, &clen, w->mt->blk[i], w->mt->len[i], w->compress_level);
        if (ret != 0) {
            if (hts_verbose >= 2) fprintf(stderr, "[E::%s] bgzf_compress error %d\n", __func__, ret);
            w->errcode |= BGZF_ERR_ZLIB; // Report error
            // We're not going to do any more, so set remaining lengths to 0
            for (; i < w->mt->curr; i += w->mt->n_threads) w->mt->len[i] = 0;
            break; // Give up
        } else {
            memcpy(w->mt->blk[i], w->buf, clen);
            w->mt->len[i] = clen;
        }
    }
    __sync_fetch_and_add(&w->mt->proc_cnt, 1);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
addq $0x38, %rdi
callq 0x47a0
cmpl $0x0, 0x18(%rbx)
jne 0x46231
movq (%rbx), %rsi
cmpl $0x0, 0xc(%rsi)
jne 0x46231
leaq 0x60(%rsi), %rdi
addq $0x38, %rsi
callq 0x47f0
jmp 0x46213
movq (%rbx), %rdi
movl 0xc(%rdi), %ebp
movl $0x0, 0x18(%rbx)
addq $0x38, %rdi
callq 0x43f0
movl $0x1, %eax
testl %ebp, %ebp
jne 0x4631f
movl $0x0, 0x14(%rbx)
movl 0x10(%rbx), %r12d
movq (%rbx), %rax
cmpl 0x8(%rax), %r12d
jge 0x46316
movq %rsp, %r14
movq $0x10000, (%rsp)        # imm = 0x10000
movq 0x8(%rbx), %rdi
movslq %r12d, %r13
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rax
movq (%rcx,%r13,8), %rdx
movslq (%rax,%r13,4), %rcx
movl 0x1c(%rbx), %r8d
movq %r14, %rsi
callq 0x43c4d
movl %eax, %ebp
testl %eax, %eax
je 0x462d3
leaq 0x1e2a9(%rip), %rax     # 0x64550
cmpl $0x2, (%rax)
jge 0x4630f
orb $0x1, 0x14(%rbx)
movq (%rbx), %rax
cmpl 0x8(%rax), %r12d
jge 0x462f9
movq 0x20(%rax), %rcx
movslq %r12d, %r12
movl $0x0, (%rcx,%r12,4)
addl (%rax), %r12d
cmpl 0x8(%rax), %r12d
jl 0x462bd
jmp 0x462f9
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movq 0x18(%rax), %rax
movq (%rax,%r13,8), %rdi
movq (%rsp), %r15
movq %r15, %rdx
callq 0x4420
movq (%rbx), %rax
movq 0x20(%rax), %rax
movl %r15d, (%rax,%r13,4)
testl %ebp, %ebp
jne 0x46316
movq (%rbx), %rax
addl (%rax), %r12d
cmpl 0x8(%rax), %r12d
jl 0x4626f
jmp 0x46316
callq 0x5eff
jmp 0x462ac
movq (%rbx), %rax
lock
incl 0x10(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/faidx.c
// Function: fai_destroy
void fai_destroy(faidx_t *fai)
{
    int i;
    for (i = 0; i < fai->n; ++i) free(fai->name[i]);
    free(fai->name);
    kh_destroy(s, fai->hash);
    if (fai->bgzf) bgzf_close(fai->bgzf);
    free(fai);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
jle 0x46a47
xorl %r14d, %r14d
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x4610
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x46a2e
movq 0x10(%rbx), %rdi
callq 0x4610
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x46a7c
movq 0x18(%r14), %rdi
callq 0x4610
movq 0x10(%r14), %rdi
callq 0x4610
movq 0x20(%r14), %rdi
callq 0x4610
movq %r14, %rdi
callq 0x4610
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x46a89
callq 0x4514a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4610
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/faidx.c
// Function: fai_save
void fai_save(const faidx_t *fai, FILE *fp)
{
    khint_t k;
    int i;
    for (i = 0; i < fai->n; ++i) {
        faidx1_t x;
        k = kh_get(s, fai->hash, fai->name[i]);
        x = kh_value(fai->hash, k);
#ifdef _WIN32
        fprintf(fp, "%s\t%d\t%ld\t%d\t%d\n", fai->name[i], (int)x.len, (long)x.offset, (int)x.line_blen, (int)x.line_len);
#else
        fprintf(fp, "%s\t%d\t%lld\t%d\t%d\n", fai->name[i], (int)x.len, (long long)x.offset, (int)x.line_blen, (int)x.line_len);
#endif
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, 0x30(%rsp)
cmpl $0x0, 0x8(%rdi)
jle 0x46bfc
movq %rdi, %rbx
xorl %r14d, %r14d
movq %rdi, 0x18(%rsp)
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rax,%r14,8), %r10
movq %rcx, 0x10(%rsp)
movl (%rcx), %esi
movl $0x0, %eax
testl %esi, %esi
je 0x46bb3
movq %r14, 0x28(%rsp)
movsbl (%r10), %r14d
testl %r14d, %r14d
je 0x46b15
movb 0x1(%r10), %al
testb %al, %al
je 0x46b18
leaq 0x2(%r10), %rcx
movl %r14d, %edx
shll $0x5, %edx
subl %r14d, %edx
movsbl %al, %r14d
addl %edx, %r14d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x46afa
jmp 0x46b18
xorl %r14d, %r14d
movq %rsi, 0x20(%rsp)
leal -0x1(%rsi), %r12d
andl %r12d, %r14d
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r15d
movl %r14d, %ebx
movq %r10, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r13d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r13d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x46b98
testb $0x1, %al
jne 0x46b83
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r10, %rsi
callq 0x4750
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %r10
testl %eax, %eax
je 0x46b98
addl %r15d, %ebx
andl %r12d, %ebx
incl %r15d
cmpl %r14d, %ebx
jne 0x46b40
movq 0x20(%rsp), %rax
jmp 0x46ba9
movl %ebp, %ecx
shrl %cl, %r13d
testb $0x3, %r13b
movq 0x20(%rsp), %rax
cmovel %ebx, %eax
movq 0x18(%rsp), %rbx
movq 0x28(%rsp), %r14
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %rdx
movl %eax, %eax
leaq (%rax,%rax,2), %rax
movl (%rdx,%rax,8), %esi
movl 0x4(%rdx,%rax,8), %r9d
movl 0x8(%rdx,%rax,8), %ecx
movq 0x10(%rdx,%rax,8), %r8
movl %esi, (%rsp)
movq 0x30(%rsp), %rdi
leaq 0xf3f3(%rip), %rsi      # 0x55fd5
movq %r10, %rdx
xorl %eax, %eax
callq 0x4770
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x46ac0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/hfile.c
// Function: hfile_init
hFILE *hfile_init(size_t struct_size, const char *mode, size_t capacity)
{
    hFILE *fp = (hFILE *) malloc(struct_size);
    if (fp == NULL) goto error;

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

    fp->buffer = (char *) malloc(capacity);
    if (fp->buffer == NULL) goto error;

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

    fp->offset = 0;
    fp->at_eof = 0;
    fp->has_errno = 0;
    return fp;

error:
    hfile_destroy(fp);
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r12
callq 0x4700
movq %rax, %rbx
testq %rax, %rax
je 0x48013
testq %r15, %r15
movl $0x8000, %r14d          # imm = 0x8000
cmoveq %r14, %r15
movq %r12, %rdi
movl $0x72, %esi
callq 0x4200
cmpq %r14, %r15
cmovbq %r15, %r14
testq %rax, %rax
cmoveq %r15, %r14
movq %r14, %rdi
callq 0x4700
movq %rax, (%rbx)
testq %rax, %rax
je 0x48013
movq %rax, 0x10(%rbx)
movq %rax, 0x8(%rbx)
addq %rax, %r14
movq %r14, 0x18(%rbx)
movq $0x0, 0x28(%rbx)
andb $-0x2, 0x30(%rbx)
movl $0x0, 0x34(%rbx)
jmp 0x4801d
movq %rbx, %rdi
callq 0x4802c
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/hfile.c
// Function: hfile_destroy
void hfile_destroy(hFILE *fp)
{
    int save = errno;
    if (fp) free(fp->buffer);
    free(fp);
    errno = save;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x4070
movq %rax, %r14
movl (%rax), %ebp
testq %rbx, %rbx
je 0x4804a
movq (%rbx), %rdi
callq 0x4610
movq %rbx, %rdi
callq 0x4610
movl %ebp, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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->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
movq (%rdi), %rdi
movq 0x8(%rbx), %rsi
movq %rsi, %rax
subq %rdi, %rax
jbe 0x480bc
addq %rax, 0x28(%rbx)
movq 0x10(%rbx), %rdx
subq %rsi, %rdx
callq 0x48c0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
movq (%rbx), %rcx
addq %rcx, %rax
movq %rax, 0x10(%rbx)
movq %rcx, 0x8(%rbx)
testb $0x1, 0x30(%rbx)
jne 0x480e9
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
cmpq %rdx, %rsi
je 0x480e9
movq 0x20(%rbx), %rax
subq %rsi, %rdx
movq %rbx, %rdi
callq *(%rax)
movq %rax, %r14
testq %rax, %rax
js 0x480fb
jne 0x480ec
orb $0x1, 0x30(%rbx)
xorl %r14d, %r14d
addq %r14, 0x10(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x4070
movl (%rax), %eax
movl %eax, 0x34(%rbx)
jmp 0x480f0
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x4815c
movq %r15, %rdi
callq 0x48080
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 0x48128
cmpl $0x3, %ecx
jne 0x48175
cmpq %rbx, %r13
cmovbq %r13, %rbx
movq 0x8(%r15), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4420
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_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x4825b
testb $0x1, 0x30(%r12)
jne 0x4825b
movq 0x20(%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq *(%rax)
movq %rax, %rbp
testq %rax, %rax
js 0x481f4
jne 0x481e4
orb $0x1, 0x30(%r12)
addq %rbp, 0x28(%r12)
addq %rbp, %r15
subq %rbp, %r14
addq %rbp, %rbx
jmp 0x48204
callq 0x4070
movl (%rax), %eax
movl %eax, 0x34(%r12)
movq %rbp, (%rsp)
testq %rbp, %rbp
jns 0x481ab
jmp 0x48264
testb $0x1, 0x30(%r12)
jne 0x48260
movq %r12, %rdi
callq 0x48080
movq %rax, %rbp
testq %rax, %rax
js 0x48252
movq 0x8(%r12), %rsi
movq 0x10(%r12), %r13
subq %rsi, %r13
cmpq %r14, %r13
cmovaeq %r14, %r13
movq %r15, %rdi
movq %r13, %rdx
callq 0x4420
addq %r13, 0x8(%r12)
addq %r13, %r15
subq %r13, %r14
addq %r13, %rbx
jmp 0x48256
movq %rbp, (%rsp)
testq %rbp, %rbp
js 0x48264
testq %r14, %r14
jne 0x4820b
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_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x482bc
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
js 0x482b3
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0x482b3
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
jns 0x482b3
callq 0x4070
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_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
movq 0x8(%rbx), %rdx
cmpq %rdx, %r14
jae 0x48308
movq 0x20(%rbx), %rax
subq %r14, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
movq %rax, %r12
testq %rax, %rax
js 0x482f4
addq %r12, %r14
addq %r12, 0x28(%rbx)
jmp 0x48301
callq 0x4070
movl (%rax), %eax
movl %eax, 0x34(%rbx)
movq %r12, %r15
testq %r12, %r12
jns 0x482ca
jmp 0x48312
movq (%rbx), %rax
movq %rax, 0x8(%rbx)
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/hfile.c
// Function: hwrite2
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, %rbp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq 0x18(%rdi), %rbx
subq (%rdi), %rbx
callq 0x482bc
testq %rax, %rax
js 0x483ca
addq %rbp, %r15
movq %r12, (%rsp)
subq %rbp, %r12
leaq (%r12,%r12), %rax
cmpq %rbx, %rax
jb 0x483cf
movq 0x20(%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x8(%rax)
movq %rax, %rbp
testq %rax, %rax
js 0x483b5
addq %rbp, 0x28(%r14)
addq %rbp, %r15
subq %rbp, %r12
jmp 0x483c3
callq 0x4070
movl (%rax), %eax
movl %eax, 0x34(%r14)
movq %rbp, %r13
testq %rbp, %rbp
jns 0x48388
jmp 0x483e6
movq %rax, %r13
jmp 0x483e6
movq 0x8(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4420
addq %r12, 0x8(%r14)
movq (%rsp), %r13
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x48435
movq %rbx, %rdi
callq 0x482bc
testl %eax, %eax
js 0x4849b
cmpl $0x1, %ebp
jne 0x4846f
movq 0x28(%rbx), %rsi
addq %r14, %rsi
addq 0x8(%rbx), %rsi
xorl %ebp, %ebp
subq (%rbx), %rsi
jns 0x48472
testq %r14, %r14
movl $0x16, %eax
movl $0x4b, %ebp
cmovsl %eax, %ebp
callq 0x4070
movl %ebp, (%rax)
movl %ebp, 0x34(%rbx)
movq $-0x1, %r14
jmp 0x484aa
movq %r14, %rsi
movq 0x20(%rbx), %rax
movq %rbx, %rdi
movl %ebp, %edx
callq *0x10(%rax)
movq %rax, %r14
testq %rax, %rax
js 0x484a0
movq (%rbx), %rax
movq %rax, 0x10(%rbx)
movq %rax, 0x8(%rbx)
andb $-0x2, 0x30(%rbx)
movq %r14, 0x28(%rbx)
jmp 0x484aa
movslq %eax, %r14
jmp 0x484aa
callq 0x4070
movl (%rax), %eax
movl %eax, 0x34(%rbx)
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x484d4
movq %rbx, %rdi
callq 0x48277
testl %eax, %eax
jns 0x484d4
movl 0x34(%rbx), %ebp
movq 0x20(%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
testl %eax, %eax
jns 0x484e9
callq 0x4070
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x4802c
testl %ebp, %ebp
je 0x48503
callq 0x4070
movl %ebp, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x48505
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x4070
movq %rax, %r14
movl (%rax), %ebp
movq 0x20(%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq %rbx, %rdi
callq 0x4802c
movl %ebp, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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->base.backend = &fd_backend;
    return &fp->base;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x8(%rsp), %rsi
callq 0x4910
xorl %r14d, %r14d
movl $0x0, %edx
testl %eax, %eax
jne 0x48564
movq 0x40(%rsp), %rdx
movl $0x40, %edi
movq %rbx, %rsi
callq 0x47f9c
testq %rax, %rax
je 0x485aa
movq %rax, %r15
movl %ebp, 0x38(%rax)
movq %rbx, %rdi
movl $0x73, %esi
callq 0x4200
testq %rax, %rax
setne %al
movb 0x3c(%r15), %cl
andb $-0x2, %cl
orb %al, %cl
movb %cl, 0x3c(%r15)
leaq 0x1b5dd(%rip), %rax     # 0x63b80
movq %rax, 0x20(%r15)
movq %r15, %r14
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/hfile.c
// Function: hfile_oflags
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
jg 0x485dd
cmpl $0x60, %edx
jle 0x485f0
cmpl $0x61, %edx
je 0x485fc
cmpl $0x65, %edx
jne 0x48614
orl $0x80000, %eax          # imm = 0x80000
jmp 0x48614
cmpl $0x78, %edx
je 0x48603
cmpl $0x77, %edx
je 0x4860a
cmpl $0x72, %edx
jne 0x48614
xorl %ecx, %ecx
jmp 0x48614
cmpl $0x2b, %edx
jne 0x48619
movl $0x2, %ecx
jmp 0x48614
orl $0x440, %eax            # imm = 0x440
jmp 0x4860f
orl $0x80, %eax
jmp 0x48614
orl $0x240, %eax            # imm = 0x240
movl $0x1, %ecx
incq %rdi
jmp 0x485bf
testl %edx, %edx
jne 0x48614
orl %ecx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x488ab
testq %rax, %rax
je 0x48861
movq (%rax), %rax
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *%rax
leaq 0x7a0d(%rip), %rsi      # 0x50275
movq %r14, %rdi
callq 0x4750
testl %eax, %eax
je 0x48886
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x48b57
movq %rbx, %rdi
movl $0x72, %esi
callq 0x4200
xorl %edi, %edi
testq %rax, %rax
sete %dil
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x48537
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/hfile.c
// Function: hopen_fd
static hFILE *hopen_fd(const char *filename, const char *mode)
{
    hFILE_fd *fp = NULL;
    int fd = open(filename, hfile_oflags(mode), 0666);
    if (fd < 0) goto error;

    fp = (hFILE_fd *) hfile_init(sizeof (hFILE_fd), mode, blksize(fd));
    if (fp == NULL) goto error;

    fp->fd = fd;
    fp->is_socket = 0;
    fp->base.backend = &fd_backend;
    return &fp->base;

error:
    if (fd >= 0) { int save = errno; (void) close(fd); errno = save; }
    hfile_destroy((hFILE *) fp);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x485bb
movq %rbx, %rdi
movl %eax, %esi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x43c0
movl %eax, %ebx
testl %eax, %eax
js 0x48bc4
movq %rsp, %rsi
movl %ebx, %edi
callq 0x4910
testl %eax, %eax
jne 0x48b9c
movq 0x38(%rsp), %rdx
jmp 0x48b9e
xorl %edx, %edx
movl $0x40, %edi
movq %r14, %rsi
callq 0x47f9c
testq %rax, %rax
je 0x48bc4
movl %ebx, 0x38(%rax)
andb $-0x2, 0x3c(%rax)
leaq 0x1afc2(%rip), %rcx     # 0x63b80
movq %rcx, 0x20(%rax)
jmp 0x48bde
testl %ebx, %ebx
js 0x48bdc
callq 0x4070
movq %rax, %r14
movl (%rax), %ebp
movl %ebx, %edi
callq 0x4a50
movl %ebp, (%r14)
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/hfile.c
// Function: fd_read
static ssize_t fd_read(hFILE *fpv, void *buffer, size_t nbytes)
{
    hFILE_fd *fp = (hFILE_fd *) fpv;
    ssize_t n;
    do {
        n = fp->is_socket? recv(fp->fd, buffer, nbytes, 0)
                         : read(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 0x48c35
movl 0x38(%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4780
jmp 0x48c46
movl 0x38(%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x4190
movq %rax, %r12
testq %rax, %rax
jns 0x48c58
callq 0x4070
cmpl $0x4, (%rax)
je 0x48c1d
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq