// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/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;
    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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x38, %rdi
callq 0x6ae0
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x9ce5c
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x1, 0x18(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9ce2c
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x18(%rbp), %rdi
addq $0x60, %rdi
callq 0x6240
movq -0x18(%rbp), %rdi
addq $0x38, %rdi
callq 0x64e0
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x9f400
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x9ce9f
jmp 0x9ce8e
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x9cef2
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x8(%rbp), %rax
movl (%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
orl %ecx, %edx
movl (%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, (%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9cea6
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x9cf77
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0xc(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
callq 0x9d090
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0xc(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpq %rcx, %rax
je 0x9cf6a
movq -0x8(%rbp), %rax
movl (%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
orl $0x4, %edx
movl (%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, (%rax)
jmp 0x9cf77
jmp 0x9cf6c
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9cef9
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)