// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq 0x40(%rdi), %r12
leaq 0x38(%r12), %r14
movq %r14, %rdi
callq 0x6ae0
movslq (%r12), %rdx
testq %rdx, %rdx
jle 0x67edb
movq 0x28(%r12), %rax
leal 0x3(%rdx), %ecx
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %ecx
shlq $0x7, %rcx
movdqa 0x26883(%rip), %xmm1    # 0x8e680
movdqa 0x2688b(%rip), %xmm2    # 0x8e690
xorl %edx, %edx
movdqa 0x25ba1(%rip), %xmm3    # 0x8d9b0
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x26881(%rip), %xmm5    # 0x8e6a0
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0x67e5c
movl $0x1, 0x18(%rax,%rdx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0x67e73
movl $0x1, 0x38(%rax,%rdx)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %esi
testb $0x1, %sil
je 0x67eb3
movl $0x1, 0x58(%rax,%rdx)
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0x67ec6
movl $0x1, 0x78(%rax,%rdx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
subq $-0x80, %rdx
cmpq %rdx, %rcx
jne 0x67e1f
movl $0x0, 0x10(%r12)
leaq 0x60(%r12), %rdi
callq 0x6250
movq %r14, %rdi
callq 0x64f0
movq 0x28(%r12), %rdi
callq 0x692cc
movl (%r12), %eax
movl 0x10(%r12), %ecx
cmpl %eax, %ecx
jl 0x67f04
testl %eax, %eax
jle 0x67f39
movl (%r15), %eax
movl $0x14, %ecx
xorl %edx, %edx
movq 0x28(%r12), %rsi
movzwl (%rsi,%rcx), %esi
orl %esi, %eax
movl %eax, (%r15)
incq %rdx
movslq (%r12), %rsi
addq $0x20, %rcx
cmpq %rsi, %rdx
jl 0x67f1b
cmpl $0x0, 0x8(%r12)
jle 0x67fcf
movq 0x20(%r12), %rax
xorl %ebx, %ebx
movq %r15, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq 0x38(%r15), %r15
movq 0x18(%r12), %rcx
movq (%rcx,%rbx,8), %r12
movslq (%rax,%rbx,4), %r13
movq 0x8(%r15), %rdi
movq 0x18(%r15), %rbp
subq %rdi, %rbp
cmpq %r13, %rbp
movq %r13, %r14
cmovbq %rbp, %r14
movq %r12, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x8(%r15)
cmpq %r13, %rbp
jae 0x67fa4
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x6b241
movq %rax, %r14
movq 0x8(%rsp), %r12
movq 0x20(%r12), %rax
movslq (%rax,%rbx,4), %rcx
cmpq %rcx, %r14
movq 0x10(%rsp), %r15
jne 0x67fcb
incq %rbx
movslq 0x8(%r12), %rcx
cmpq %rcx, %rbx
jl 0x67f56
jmp 0x67fcf
orb $0x4, (%r15)
movl $0x0, 0x8(%r12)
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