// File: /workspace/github_c_makefile_star2_O3/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: tcp_select
static int
tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout)
{ register int r;
  struct timeval tv;
  fd_set fd[3], *rfd, *sfd, *efd;
  soap->errnum = 0;
#ifndef WIN32
  /* if fd max set size exceeded, use poll() when available */
#if defined(__QNX__) || defined(QNX) /* select() is not MT safe on some QNX */
  if (1)
#else
  if ((int)s >= (int)FD_SETSIZE)
#endif
#ifdef HAVE_POLL
  { struct pollfd pollfd;
    int retries = 0;
    pollfd.fd = (int)s;
    pollfd.events = 0;
    if (flags & SOAP_TCP_SELECT_RCV)
      pollfd.events |= POLLIN;
    if (flags & SOAP_TCP_SELECT_SND)
      pollfd.events |= POLLOUT;
    if (flags & SOAP_TCP_SELECT_ERR)
      pollfd.events |= POLLERR;
    if (timeout < 0)
      timeout /= -1000; /* -usec -> ms */
    else if (timeout <= 1000000) /* avoid overflow */
      timeout *= 1000; /* sec -> ms */
    else
    { retries = timeout / 1000000;
      timeout = 1000000000;
    }
    do r = poll(&pollfd, 1, timeout);
    while (r == 0 && retries--);
    if (r > 0)
    { r = 0;
      if ((flags & SOAP_TCP_SELECT_RCV) && (pollfd.revents & POLLIN))
        r |= SOAP_TCP_SELECT_RCV;
      if ((flags & SOAP_TCP_SELECT_SND) && (pollfd.revents & POLLOUT))
        r |= SOAP_TCP_SELECT_SND;
      if ((flags & SOAP_TCP_SELECT_ERR) && (pollfd.revents & POLLERR))
        r |= SOAP_TCP_SELECT_ERR;
    }
    else if (r < 0)
      soap->errnum = soap_socket_errno(s);
    return r;
  }
#else
  { soap->error = SOAP_FD_EXCEEDED;
    return -1;
  }
#endif
#endif
  rfd = sfd = efd = NULL;
  if (flags & SOAP_TCP_SELECT_RCV)
  { rfd = &fd[0];
    FD_ZERO(rfd);
    FD_SET(s, rfd);
  }
  if (flags & SOAP_TCP_SELECT_SND)
  { sfd = &fd[1];
    FD_ZERO(sfd);
    FD_SET(s, sfd);
  }
  if (flags & SOAP_TCP_SELECT_ERR)
  { efd = &fd[2];
    FD_ZERO(efd);
    FD_SET(s, efd);
  }
  if (timeout >= 0)
  { tv.tv_sec = timeout;
    tv.tv_usec = 0;
  }
  else
  { tv.tv_sec = -timeout / 1000000;
    tv.tv_usec = -timeout % 1000000;
  }
  r = select((int)s + 1, rfd, sfd, efd, &tv);
  if (r > 0)
  { r = 0;
    if ((flags & SOAP_TCP_SELECT_RCV) && FD_ISSET(s, rfd))
      r |= SOAP_TCP_SELECT_RCV;
    if ((flags & SOAP_TCP_SELECT_SND) && FD_ISSET(s, sfd))
      r |= SOAP_TCP_SELECT_SND;
    if ((flags & SOAP_TCP_SELECT_ERR) && FD_ISSET(s, efd))
      r |= SOAP_TCP_SELECT_ERR;
  }
  else if (r < 0)
    soap->errnum = soap_socket_errno(s);
  return r;
}

// Assembly:
movl $0x0, 0x1921c(%rdi)
cmpl $0x400, %esi            # imm = 0x400
jl 0x3df6a
movl $0x2e, 0x19214(%rdi)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %ecx, %eax
movl %edx, %ebp
movl %esi, %ebx
testb $0x1, %bpl
jne 0x3df8c
xorl %r15d, %r15d
jmp 0x3dfdf
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r15
movaps %xmm0, 0x70(%r15)
movaps %xmm0, 0x60(%r15)
movaps %xmm0, 0x50(%r15)
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leal 0x3f(%rbx), %edx
testl %ebx, %ebx
cmovnsl %ebx, %edx
movl %edx, %esi
andl $-0x40, %esi
movl %ebx, %ecx
subl %esi, %ecx
movl $0x1, %esi
shlq %cl, %rsi
sarl $0x6, %edx
movslq %edx, %rcx
orq %rsi, 0x20(%rsp,%rcx,8)
testb $0x2, %bpl
jne 0x3dfea
xorl %r12d, %r12d
jmp 0x3e04b
leaq 0xa0(%rsp), %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%r12)
movaps %xmm0, 0x60(%r12)
movaps %xmm0, 0x50(%r12)
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
leal 0x3f(%rbx), %edx
testl %ebx, %ebx
cmovnsl %ebx, %edx
movl %edx, %esi
andl $-0x40, %esi
movl %ebx, %ecx
subl %esi, %ecx
movl $0x1, %esi
shlq %cl, %rsi
sarl $0x6, %edx
movslq %edx, %rcx
orq %rsi, 0xa0(%rsp,%rcx,8)
testb $0x4, %bpl
jne 0x3e056
xorl %r13d, %r13d
jmp 0x3e0b0
leaq 0x120(%rsp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%r13)
movaps %xmm0, 0x60(%r13)
movaps %xmm0, 0x50(%r13)
movaps %xmm0, 0x40(%r13)
movaps %xmm0, 0x30(%r13)
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
leal 0x3f(%rbx), %edx
testl %ebx, %ebx
cmovnsl %ebx, %edx
movl %edx, %esi
andl $-0x40, %esi
movl %ebx, %ecx
subl %esi, %ecx
movl $0x1, %esi
shlq %cl, %rsi
sarl $0x6, %edx
movslq %edx, %rcx
orq %rsi, 0x120(%rsp,%rcx,8)
testl %eax, %eax
movq %rdi, 0x8(%rsp)
js 0x3e0bd
xorl %ecx, %ecx
jmp 0x3e0d4
negl %eax
movl %eax, %ecx
imulq $0x431bde83, %rax, %rax # imm = 0x431BDE83
shrq $0x32, %rax
imull $0xf4240, %eax, %edx    # imm = 0xF4240
subl %edx, %ecx
movl %eax, %eax
leaq 0x10(%rsp), %r8
movq %rax, (%r8)
movq %rcx, 0x8(%r8)
leal 0x1(%rbx), %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3260
testl %eax, %eax
jle 0x3e164
xorl %eax, %eax
testb $0x1, %bpl
je 0x3e119
leal 0x3f(%rbx), %eax
testl %ebx, %ebx
cmovnsl %ebx, %eax
sarl $0x6, %eax
cltq
movq (%r15,%rax,8), %rcx
xorl %eax, %eax
btq %rbx, %rcx
setb %al
testb $0x2, %bpl
je 0x3e13d
leal 0x3f(%rbx), %ecx
testl %ebx, %ebx
cmovnsl %ebx, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq (%r12,%rcx,8), %rcx
leal 0x2(%rax), %edx
btq %rbx, %rcx
cmovael %eax, %edx
movl %edx, %eax
testb $0x4, %bpl
je 0x3e183
leal 0x3f(%rbx), %ecx
testl %ebx, %ebx
cmovnsl %ebx, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq (%r13,%rcx,8), %rcx
leal 0x4(%rax), %edx
btq %rbx, %rcx
cmovael %eax, %edx
movl %edx, %eax
jmp 0x3e183
movl %eax, %r14d
xorl %eax, %eax
testl %r14d, %r14d
jns 0x3e183
callq 0x3060
movl (%rax), %eax
movq 0x8(%rsp), %rcx
movl %eax, 0x1921c(%rcx)
movl %r14d, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq