// File: /workspace/github_cpp_makefile_star2_O1/ctSkennerton[P]fxtract/util/sock.c
// Function: sock_status
int
sock_status(int nsocks, int const sockv[], int statusv[], int waitsecs)
{
    dyninit();

    if (nsocks <= 0) return nsocks;
    int i, ret, maxfd = -1;

    fd_set fds;
    FD_ZERO(&fds);
    for (i = 0; i < nsocks; ++i) {
        FD_SET(sockv[i], &fds);
        if (maxfd < sockv[i])  maxfd = sockv[i];
    }

    fd_set rfds, wfds, efds = fds;
    do {
        struct timeval to = { waitsecs, 0 }, *top = waitsecs == WAIT_FOREVER ? NULL : &to;
        rfds = wfds = efds = fds;
        errno = 0;
        ret = select(maxfd + 1, &rfds, &wfds, &efds, top);
    } while (ret < 0 && errno == EINTR);

    if (ret > 0)
        for (i = ret = 0; i <= maxfd; ++i)
            ret += !!(statusv[i] = (FD_ISSET(i, &rfds) ? SOCK_CAN_RECV : 0)
                                 | (FD_ISSET(i, &wfds) ? SOCK_CAN_SEND : 0)
                                 | (FD_ISSET(i, &efds) ? SOCK_IN_ERROR : 0));

    return ret;   
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl %ecx, %r14d
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %ebp
callq 0x5d2c
testl %ebp, %ebp
jle 0x675f
movq %rbx, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movl %ebp, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %edx, %edx
movl %r13d, %esi
movl (%r15,%rdx,4), %r13d
leal 0x3f(%r13), %edi
testl %r13d, %r13d
cmovnsl %r13d, %edi
movl %edi, %r8d
andl $-0x40, %r8d
movl %r13d, %ecx
subl %r8d, %ecx
movl $0x1, %r8d
shlq %cl, %r8
sarl $0x6, %edi
movslq %edi, %rcx
orq %r8, 0x30(%rsp,%rcx,8)
cmpl %r13d, %esi
cmovgl %esi, %r13d
incq %rdx
cmpq %rdx, %rax
jne 0x65e9
leaq 0xb8(%rsp), %rdi
leaq 0x30(%rsp), %r12
movl $0x10, %ecx
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movslq %r14d, %rcx
xorl %eax, %eax
movq %rcx, 0x18(%rsp)
cmpl $-0x1, %ecx
leaq 0x20(%rsp), %rcx
cmoveq %rax, %rcx
movq %rcx, 0x10(%rsp)
callq 0x3040
movq %rax, %rbx
leal 0x1(%r13), %r10d
leaq 0x138(%rsp), %r15
leaq 0x1b8(%rsp), %r14
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movl $0x10, %ecx
leaq 0xb8(%rsp), %rax
movq %rax, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
movq %r15, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
movq %r14, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x0, (%rbx)
movl %r10d, %edi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
movq 0x10(%rsp), %r8
movq %r10, %rbp
callq 0x32f0
movq %rbp, %r10
movl %eax, %ebp
testl %eax, %eax
jns 0x66ec
cmpl $0x4, (%rbx)
je 0x667a
testl %ebp, %ebp
jle 0x675f
testl %r13d, %r13d
js 0x675d
xorl %eax, %eax
xorl %ebp, %ebp
movq 0x8(%rsp), %r9
movl %eax, %ecx
shrl $0x6, %ecx
movq 0x1b8(%rsp,%rcx,8), %rdx
movl %eax, %esi
andl $0x3f, %esi
xorl %edi, %edi
btq %rsi, %rdx
setb %dil
movq 0x138(%rsp,%rcx,8), %rdx
xorl %r8d, %r8d
btq %rsi, %rdx
setb %r8b
leal (%rdi,%r8,2), %edx
movq 0xb8(%rsp,%rcx,8), %rcx
xorl %edi, %edi
btq %rsi, %rcx
setb %dil
shll $0x2, %edi
xorl %ecx, %ecx
orl %edx, %edi
movl %edi, (%r9,%rax,4)
setne %cl
addl %ecx, %ebp
incq %rax
cmpq %rax, %r10
jne 0x66fe
jmp 0x675f
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq