// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hfile_libcurl.c
// Function: wait_perform
static int wait_perform(hFILE_libcurl *fp)
{
    fd_set rd, wr, ex;
    int maxfd, nrunning;
    long timeout;
    CURLMcode errm;

    if (!fp->perform_again) {
        FD_ZERO(&rd);
        FD_ZERO(&wr);
        FD_ZERO(&ex);
        if (curl_multi_fdset(fp->multi, &rd, &wr, &ex, &maxfd) != CURLM_OK)
            maxfd = -1, timeout = 1000;
        else {
            if (curl_multi_timeout(fp->multi, &timeout) != CURLM_OK)
                timeout = 1000;
            else if (timeout < 0) {
                timeout = 10000;  // as recommended by curl_multi_timeout(3)
            }
        }
        if (maxfd < 0) {
            if (timeout > 100)
                timeout = 100; // as recommended by curl_multi_fdset(3)
#ifdef _WIN32
            /* Windows ignores the first argument of select, so calling select
             * with maxfd=-1 does not give the expected result of sleeping for
             * timeout milliseconds in the conditional block below.
             * So sleep here and skip the next block.
             */
            Sleep(timeout);
            timeout = 0;
#endif
        }

        if (timeout > 0) {
            struct timeval tval;
            tval.tv_sec  = (timeout / 1000);
            tval.tv_usec = (timeout % 1000) * 1000;

            if (select(maxfd + 1, &rd, &wr, &ex, &tval) < 0) return -1;
        }
    }

    errm = curl_multi_perform(fp->multi, &nrunning);
    fp->perform_again = 0;
    if (errm == CURLM_CALL_MULTI_PERFORM) fp->perform_again = 1;
    else if (errm != CURLM_OK) { errno = multi_errno(errm); return -1; }

    if (nrunning < fp->nrunning) process_messages(fp);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, %rbx
testb $0x8, 0x64(%rdi)
jne 0x7f7bd
xorps %xmm0, %xmm0
leaq 0x120(%rsp), %rsi
movaps %xmm0, 0x70(%rsi)
movaps %xmm0, 0x60(%rsi)
movaps %xmm0, 0x50(%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x30(%rdx)
movaps %xmm0, 0x40(%rdx)
movaps %xmm0, 0x50(%rdx)
movaps %xmm0, 0x60(%rdx)
movaps %xmm0, 0x70(%rdx)
leaq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx)
movaps %xmm0, 0x10(%rcx)
movaps %xmm0, 0x20(%rcx)
movaps %xmm0, 0x30(%rcx)
movaps %xmm0, 0x40(%rcx)
movaps %xmm0, 0x50(%rcx)
movaps %xmm0, 0x60(%rcx)
movaps %xmm0, 0x70(%rcx)
movq 0x40(%rbx), %rdi
leaq 0x8(%rsp), %r8
callq 0x4500
testl %eax, %eax
je 0x7f71f
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
jmp 0x7f733
movq 0x40(%rbx), %rdi
movq %rsp, %rsi
callq 0x4120
testl %eax, %eax
je 0x7f84d
movq $0x3e8, (%rsp)          # imm = 0x3E8
movl $0x3e8, %ecx            # imm = 0x3E8
movl 0x8(%rsp), %edi
testl %edi, %edi
setns %al
cmpq $0x65, %rcx
setb %dl
orb %al, %dl
jne 0x7f763
movq $0x64, (%rsp)
movl $0x64, %ecx
jmp 0x7f768
testq %rcx, %rcx
je 0x7f7bd
movq %rcx, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
mulq %rdx
shrq $0x4, %rdx
leaq 0x10(%rsp), %r8
movq %rdx, (%r8)
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
subq %rax, %rcx
imulq $0x3e8, %rcx, %rax      # imm = 0x3E8
movq %rax, 0x8(%r8)
incl %edi
leaq 0x120(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x4480
testl %eax, %eax
js 0x7f83a
movq 0x40(%rbx), %rdi
leaq 0xc(%rsp), %rsi
callq 0x4360
movb 0x64(%rbx), %cl
movl %ecx, %edx
andb $-0x9, %dl
movb %dl, 0x64(%rbx)
testl %eax, %eax
je 0x7f7e5
cmpl $-0x1, %eax
jne 0x7f82a
orb $0x8, %cl
movb %cl, 0x64(%rbx)
movl 0xc(%rsp), %eax
xorl %ebp, %ebp
cmpl 0x68(%rbx), %eax
jge 0x7f83f
movq 0x40(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x48b0
testq %rax, %rax
je 0x7f83f
leaq 0x10(%rsp), %r14
cmpl $0x1, (%rax)
jne 0x7f817
orb $0x4, 0x64(%rbx)
movl 0x10(%rax), %eax
movl %eax, 0x60(%rbx)
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x48b0
testq %rax, %rax
jne 0x7f808
jmp 0x7f83f
movl %eax, %edi
callq 0x7f626
movl %eax, %ebx
callq 0x4050
movl %ebx, (%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbx
popq %r14
popq %rbp
retq
movq (%rsp), %rcx
testq %rcx, %rcx
jns 0x7f740
movq $0x2710, (%rsp)         # imm = 0x2710
movl $0x2710, %ecx           # imm = 0x2710
jmp 0x7f740