// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/bgzf.c
// Function: bgzf_check_EOF
int bgzf_check_EOF(BGZF *fp) {
    int has_eof;

    if (fp->mt) {
        pthread_mutex_lock(&fp->mt->command_m);
        // fp->mt->command state transitions should be:
        // NONE -> HAS_EOF -> HAS_EOF_DONE -> NONE
        // (HAS_EOF -> HAS_EOF_DONE happens in bgzf_mt_reader thread)
        if (fp->mt->command != CLOSE)
            fp->mt->command = HAS_EOF;
        pthread_cond_signal(&fp->mt->command_c);
        hts_tpool_wake_dispatch(fp->mt->out_queue);
        do {
            if (fp->mt->command == CLOSE) {
                // possible error in bgzf_mt_reader
                pthread_mutex_unlock(&fp->mt->command_m);
                return 0;
            }
            pthread_cond_wait(&fp->mt->command_c, &fp->mt->command_m);
            switch (fp->mt->command) {
            case HAS_EOF_DONE: break;
            case HAS_EOF:
                // Resend signal intended for bgzf_mt_reader()
                pthread_cond_signal(&fp->mt->command_c);
                break;
            case CLOSE:
                continue;
            default:
                abort();  // Should not get to any other state
            }
        } while (fp->mt->command != HAS_EOF_DONE);
        fp->mt->command = NONE;
        has_eof = fp->mt->eof;
        pthread_mutex_unlock(&fp->mt->command_m);
    } else {
        has_eof = bgzf_check_EOF_common(fp);
    }

    fp->no_eof_block = (has_eof == 0);

    return has_eof;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x1093b
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x80, %rdi
callq 0x4730
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x5, 0xd8(%rax)
je 0x10832
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl $0x3, 0xd8(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0xa8, %rdi
callq 0x4040
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x20(%rax), %rdi
callq 0x4e6f0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x5, 0xd8(%rax)
jne 0x10888
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x80, %rdi
callq 0x4330
movl $0x0, -0x4(%rbp)
jmp 0x1096f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
movq %rsi, %rdi
addq $0xa8, %rdi
subq $-0x80, %rsi
callq 0x47a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl 0xd8(%rax), %eax
movl %eax, -0x18(%rbp)
subl $0x3, %eax
je 0x108d1
jmp 0x108bb
movl -0x18(%rbp), %eax
subl $0x4, %eax
je 0x108cf
jmp 0x108c5
movl -0x18(%rbp), %eax
subl $0x5, %eax
je 0x108e7
jmp 0x108e9
jmp 0x108ee
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0xa8, %rdi
callq 0x4040
jmp 0x108ee
jmp 0x108f0
callq 0x4260
jmp 0x108f0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x4, 0xd8(%rax)
jne 0x10857
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl $0x0, 0xd8(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x78(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x80, %rdi
callq 0x4330
jmp 0x10947
movq -0x10(%rbp), %rdi
callq 0x10980
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %edx
shll $0x12, %edx
andl $0xfffbffff, %ecx       # imm = 0xFFFBFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)