// File: /workspace/github_cpp_makefile_star2_O3/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 0x5d1c
testl %ebp, %ebp
jle 0x675c
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 0x65ea
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, %r12
leal 0x1(%r13), %eax
movl %eax, 0x4(%rsp)
leaq 0x30(%rsp), %rbx
leaq 0x138(%rsp), %r14
leaq 0x1b8(%rsp), %r15
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movl $0x10, %ecx
leaq 0xb8(%rsp), %rax
movq %rax, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
movq %r14, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
movq %r15, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x0, (%r12)
movl 0x4(%rsp), %edi
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
movq 0x10(%rsp), %r8
callq 0x32f0
testl %eax, %eax
jns 0x66df
cmpl $0x4, (%r12)
je 0x666c
movl %eax, %ebp
jmp 0x675c
sete %al
testl %r13d, %r13d
sets %cl
xorl %ebp, %ebp
orb %al, %cl
movq 0x8(%rsp), %r10
jne 0x675c
movl 0x4(%rsp), %eax
xorl %ecx, %ecx
xorl %ebp, %ebp
movl %ecx, %edx
shrl $0x6, %edx
movq 0x1b8(%rsp,%rdx,8), %rsi
movl %ecx, %edi
andl $0x3f, %edi
xorl %r8d, %r8d
btq %rdi, %rsi
setb %r8b
movq 0x138(%rsp,%rdx,8), %rsi
xorl %r9d, %r9d
btq %rdi, %rsi
setb %r9b
leal (%r8,%r9,2), %esi
movq 0xb8(%rsp,%rdx,8), %rdx
xorl %r8d, %r8d
btq %rdi, %rdx
setb %r8b
shll $0x2, %r8d
xorl %edx, %edx
orl %esi, %r8d
movl %r8d, (%r10,%rcx,4)
setne %dl
addl %edx, %ebp
incq %rcx
cmpq %rcx, %rax
jne 0x66fb
movl %ebp, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq