// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: frecv
static size_t
frecv(struct soap *soap, char *s, size_t n)
{ register int r;
#ifndef WITH_LEAN
  register int retries = 100; /* max 100 retries with non-blocking sockets */
#endif
  soap->errnum = 0;
#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
  if (soap->is)
  { if (soap->is->good())
      return soap->is->read(s, (std::streamsize)n).gcount();
    return 0;
  }
#endif
  if (soap_valid_socket(soap->socket))
  { for (;;)
    { 
#ifdef WITH_OPENSSL
      register int err = 0;
#endif
#ifndef WITH_LEAN
#ifdef WITH_OPENSSL
      if (soap->recv_timeout && !soap->ssl) /* SSL: sockets are nonblocking */
#else
      if (soap->recv_timeout)
#endif
      { for (;;)
        { r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout);
          if (r > 0)
            break;
          if (!r)
            return 0;
	  r = soap->errnum;
          if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
            return 0;
        }
      }
#endif
#ifdef WITH_OPENSSL
      if (soap->ssl)
      { r = SSL_read(soap->ssl, s, (int)n);
        if (r > 0)
          return (size_t)r;
        err = SSL_get_error(soap->ssl, r);
        if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE)
          return 0;
      }
      else if (soap->bio)
      { r = BIO_read(soap->bio, s, (int)n);
        if (r > 0)
          return (size_t)r;
        return 0;
      }
      else
#endif
      { 
#ifndef WITH_LEAN
        if ((soap->omode & SOAP_IO_UDP))
        { SOAP_SOCKLEN_T k = (SOAP_SOCKLEN_T)sizeof(soap->peer);
          memset((void*)&soap->peer, 0, sizeof(soap->peer));
          r = recvfrom(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, &k);	/* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */
          soap->peerlen = (size_t)k;
#ifndef WITH_IPV6
          soap->ip = ntohl(soap->peer.sin_addr.s_addr);
#endif
        }
        else
#endif
          r = recv(soap->socket, s, (int)n, soap->socket_flags);
#ifdef PALM
        /* CycleSyncDisplay(curStatusMsg); */
#endif
        if (r >= 0)
          return (size_t)r;
        r = soap_socket_errno(soap->socket);
        if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
        { soap->errnum = r;
          return 0;
        }
      }
#ifndef WITH_LEAN
      {
#ifdef WITH_OPENSSL
        if (soap->ssl && err == SSL_ERROR_WANT_WRITE)
          r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5);
        else
          r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5);
#else
        r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5);
#endif
        if (!r && soap->recv_timeout)
          return 0;
        if (r < 0)
        { r = soap->errnum;
          if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
            return 0;
        }
        if (retries-- <= 0)
          return 0;
      }
#endif
#ifdef PALM
      r = soap_socket_errno(soap->socket);
      if (r != SOAP_EINTR && retries-- <= 0)
      { soap->errnum = r;
        return 0;
      }
#endif
    }
  }
#ifdef WITH_FASTCGI
  return fread(s, 1, n, stdin);
#else
#ifdef UNDER_CE
  return fread(s, 1, n, soap->recvfd);
#else
#ifdef WMW_RPM_IO
  if (soap->rpmreqid)
    r = httpBlockRead(soap->rpmreqid, s, n);
  else
#endif
#ifdef WIN32
    r = _read(soap->recvfd, s, (unsigned int)n);
#else
    r = read(soap->recvfd, s, (unsigned int)n);
#endif
  if (r >= 0)
    return (size_t)r;
  soap->errnum = soap_errno;
  return 0;
#endif
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x64, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x1921c(%rax)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x60d4(%rax)
je 0x58e68
jmp 0x58c3c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x58cb5
jmp 0x58c48
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %ecx
movl $0x5, %edx
callq 0x59760
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x58c72
jmp 0x58cb3
cmpl $0x0, -0x24(%rbp)
jne 0x58c85
movq $0x0, -0x8(%rbp)
jmp 0x58eaf
movq -0x10(%rbp), %rax
movl 0x1921c(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
je 0x58cb1
cmpl $0xb, -0x24(%rbp)
je 0x58cb1
cmpl $0xb, -0x24(%rbp)
je 0x58cb1
movq $0x0, -0x8(%rbp)
jmp 0x58eaf
jmp 0x58c48
jmp 0x58cb5
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x58d42
movl $0x10, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1b324, %rdi          # imm = 0x1B324
xorl %esi, %esi
movl $0x10, %edx
callq 0x3190
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rax
movl 0x60(%rax), %ecx
movq -0x10(%rbp), %r8
addq $0x1b324, %r8           # imm = 0x1B324
leaq -0x2c(%rbp), %r9
callq 0x32c0
movl %eax, -0x24(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b338(%rax)
movq -0x10(%rbp), %rax
movl 0x1b328(%rax), %edi
callq 0x3390
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x191c0(%rax)
jmp 0x58d66
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movslq %eax, %rdx
movq -0x10(%rbp), %rax
movl 0x60(%rax), %ecx
callq 0x3040
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x58d79
movslq -0x24(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x58eaf
callq 0x3060
movl (%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
je 0x58daf
cmpl $0xb, -0x24(%rbp)
je 0x58daf
cmpl $0xb, -0x24(%rbp)
je 0x58daf
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x58eaf
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x58dda
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x58de4
movl $0x5, %eax
movl %eax, -0x3c(%rbp)
jmp 0x58de4
movl -0x30(%rbp), %esi
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %ecx
movl $0x5, %edx
callq 0x59760
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x58e18
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x58e18
movq $0x0, -0x8(%rbp)
jmp 0x58eaf
cmpl $0x0, -0x24(%rbp)
jge 0x58e49
movq -0x10(%rbp), %rax
movl 0x1921c(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
je 0x58e47
cmpl $0xb, -0x24(%rbp)
je 0x58e47
cmpl $0xb, -0x24(%rbp)
je 0x58e47
movq $0x0, -0x8(%rbp)
jmp 0x58eaf
jmp 0x58e49
movl -0x28(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x28(%rbp)
cmpl $0x0, %eax
jg 0x58e63
movq $0x0, -0x8(%rbp)
jmp 0x58eaf
jmp 0x58c3c
movq -0x10(%rbp), %rax
movl 0x60ec(%rax), %edi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %eax
movl %eax, %edx
callq 0x31d0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x58e96
movslq -0x24(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x58eaf
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)