// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x1921c(%rax)
cmpl $0x400, -0x14(%rbp)     # imm = 0x400
jl 0x597a9
movq -0x10(%rbp), %rax
movl $0x2e, 0x19214(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x59be3
movq $0x0, -0x1c8(%rbp)
movq $0x0, -0x1c0(%rbp)
movq $0x0, -0x1b8(%rbp)
movl -0x18(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x59885
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movl $0x0, -0x1cc(%rbp)
movl -0x1cc(%rbp), %eax
cmpq $0x10, %rax
jae 0x59831
movq -0x1d8(%rbp), %rax
movl -0x1cc(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x1cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1cc(%rbp)
jmp 0x597ff
jmp 0x59833
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x208(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x200(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x208(%rbp), %rdx
movl %eax, %ecx
movq -0x200(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x59946
leaq -0x1b0(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movl $0x0, -0x1dc(%rbp)
movl -0x1dc(%rbp), %eax
cmpq $0x10, %rax
jae 0x598f2
movq -0x1e8(%rbp), %rax
movl -0x1dc(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x1dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1dc(%rbp)
jmp 0x598c0
jmp 0x598f4
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x218(%rbp)
movq -0x1c0(%rbp), %rax
movq %rax, -0x210(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x218(%rbp), %rdx
movl %eax, %ecx
movq -0x210(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x59a07
leaq -0x1b0(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movl $0x0, -0x1ec(%rbp)
movl -0x1ec(%rbp), %eax
cmpq $0x10, %rax
jae 0x599b3
movq -0x1f8(%rbp), %rax
movl -0x1ec(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x1ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ec(%rbp)
jmp 0x59981
jmp 0x599b5
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x228(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x220(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x228(%rbp), %rdx
movl %eax, %ecx
movq -0x220(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
cmpl $0x0, -0x1c(%rbp)
jl 0x59a1f
movslq -0x1c(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x59a46
xorl %eax, %eax
subl -0x1c(%rbp), %eax
movl $0xf4240, %ecx          # imm = 0xF4240
cltd
idivl %ecx
cltq
movq %rax, -0x30(%rbp)
xorl %eax, %eax
subl -0x1c(%rbp), %eax
movl $0xf4240, %ecx          # imm = 0xF4240
cltd
idivl %ecx
movslq %edx, %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movq -0x1b8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
movq -0x1c8(%rbp), %rcx
leaq -0x30(%rbp), %r8
callq 0x3260
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jle 0x59bc4
movl $0x0, -0x20(%rbp)
movl -0x18(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x59aea
movq -0x1b8(%rbp), %rax
movq %rax, -0x238(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x238(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x230(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x230(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x59aea
movl -0x20(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x59b56
movq -0x1c0(%rbp), %rax
movq %rax, -0x248(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x248(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x240(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x240(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x59b56
movl -0x20(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x59bc2
movq -0x1c8(%rbp), %rax
movq %rax, -0x258(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x258(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x250(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x250(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x59bc2
movl -0x20(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x20(%rbp)
jmp 0x59bdd
cmpl $0x0, -0x20(%rbp)
jge 0x59bdb
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
jmp 0x59bdd
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nop