// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/bgzf.c
// Function: mt_queue
static int mt_queue(BGZF *fp)
{
    mtaux_t *mt = fp->mt;

    mt->block_number++;

    // Also updated by writer thread
    pthread_mutex_lock(&mt->job_pool_m);
    bgzf_job *j = pool_alloc(mt->job_pool);
    if (j) mt->jobs_pending++;
    pthread_mutex_unlock(&mt->job_pool_m);
    if (!j) return -1;

    j->fp = fp;
    j->errcode = 0;
    j->uncomp_len  = fp->block_offset;
    if (fp->compress_level == 0) {
        memcpy(j->comp_data + BLOCK_HEADER_LENGTH + 5, fp->uncompressed_block,
               j->uncomp_len);
        if (hts_tpool_dispatch3(mt->pool, mt->out_queue,
                                bgzf_encode_level0_func, j,
                                job_cleanup, job_cleanup, 0) < 0) {
            goto fail;
        }
    } else {
        memcpy(j->uncomp_data, fp->uncompressed_block, j->uncomp_len);

        // Need non-block vers & job_pending?
        if (hts_tpool_dispatch3(mt->pool, mt->out_queue, bgzf_encode_func, j,
                                job_cleanup, job_cleanup, 0) < 0) {
            goto fail;
        }
    }

    fp->block_offset = 0;
    return 0;

 fail:
    job_cleanup(j);
    pthread_mutex_lock(&mt->job_pool_m);
    mt->jobs_pending--;
    pthread_mutex_unlock(&mt->job_pool_m);
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x110(%rax)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x4730
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x82110
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xfa6f
movq -0x18(%rbp), %rax
movl 0x58(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x58(%rax)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x4330
cmpq $0x0, -0x20(%rbp)
jne 0xfa8f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xfbda
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x20018(%rax)
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20010(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
sarl $0x17, %eax
cmpl $0x0, %eax
jne 0xfb30
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
addq $0x12, %rdi
addq $0x5, %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x20010(%rax), %rdx
callq 0x43b0
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rcx
leaq 0x3871(%rip), %rdx      # 0x13380
leaq 0x36ea(%rip), %r9       # 0x13200
xorl %eax, %eax
movq %r9, %r8
movl $0x0, (%rsp)
callq 0x4e2e0
cmpl $0x0, %eax
jge 0xfb2e
jmp 0xfba3
jmp 0xfb8f
movq -0x20(%rbp), %rdi
addq $0x10010, %rdi          # imm = 0x10010
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x20010(%rax), %rdx
callq 0x43b0
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rcx
leaq 0x3962(%rip), %rdx      # 0x134d0
leaq 0x368b(%rip), %r9       # 0x13200
xorl %eax, %eax
movq %r9, %r8
movl $0x0, (%rsp)
callq 0x4e2e0
cmpl $0x0, %eax
jge 0xfb8d
jmp 0xfba3
jmp 0xfb8f
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xfbda
movq -0x20(%rbp), %rdi
callq 0x13200
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x4730
movq -0x18(%rbp), %rax
movl 0x58(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x58(%rax)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x4330
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)