// File: /workspace/github_c_makefile_star2_O1/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 0x3dfe5
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 0x3e007
xorl %r15d, %r15d
jmp 0x3e05a
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 0x3e065
xorl %r12d, %r12d
jmp 0x3e0c6
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 0x3e0d1
xorl %r13d, %r13d
jmp 0x3e12b
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 0x3e13f
movl %eax, %eax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
jmp 0x3e159
negl %eax
imulq $0x431bde83, %rax, %rcx # imm = 0x431BDE83
shrq $0x32, %rcx
movq %rcx, 0x10(%rsp)
imull $0xf4240, %ecx, %ecx    # imm = 0xF4240
subl %ecx, %eax
leaq 0x10(%rsp), %r8
movq %rax, 0x8(%r8)
leal 0x1(%rbx), %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3250
testl %eax, %eax
jle 0x3e1e4
xorl %eax, %eax
testb $0x1, %bpl
je 0x3e199
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 0x3e1bd
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 0x3e203
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 0x3e203
movl %eax, %r14d
xorl %eax, %eax
testl %r14d, %r14d
jns 0x3e203
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