// File: /workspace/github_c_makefile_star2_O0/zhou-lab[P]tbmate/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x38, %rdi
callq 0x37b0
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x18(%rcx)
movb %al, -0x25(%rbp)
jne 0x3e2f5
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x0, 0xc(%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0x3e2fe
jmp 0x3e31b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x60, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
addq $0x38, %rsi
callq 0x3680
jmp 0x3e2d3
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x0, 0xc(%rax)
je 0x3e32f
movl $0x1, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x38, %rdi
callq 0x3850
cmpl $0x0, -0x18(%rbp)
je 0x3e35c
movl $0x1, -0x4(%rbp)
jmp 0x3e4ab
movq -0x10(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3e499
movq $0x10000, -0x20(%rbp)   # imm = 0x10000
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movslq (%rax,%rcx,4), %rcx
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %r8d
leaq -0x20(%rbp), %rsi
callq 0x39e30
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x3e447
leaq 0x470b5(%rip), %rax     # 0x85490
cmpl $0x2, (%rax)
jl 0x3e402
movq 0x46c01(%rip), %rax     # 0x84fe8
movq (%rax), %rdi
movl -0x24(%rbp), %ecx
leaq 0x3a277(%rip), %rsi     # 0x7866b
leaq 0x3a290(%rip), %rdx     # 0x7868b
movb $0x0, %al
callq 0x37f0
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x14(%rax)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3e445
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x3e40f
jmp 0x3e499
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3860
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3e485
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x3e371
movq -0x10(%rbp), %rax
movq (%rax), %rax
lock
incl 0x10(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)