// File: /workspace/github_c_makefile_star2_O3/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_recv_raw
SOAP_FMAC2
soap_recv_raw(struct soap *soap)
{ register size_t ret;
#if !defined(WITH_LEANER) || defined(WITH_ZLIB)
  register int r;
#endif
#ifdef WITH_ZLIB
  if (soap->mode & SOAP_ENC_ZLIB)
  { if (soap->d_stream->next_out == Z_NULL)
      return EOF;
    if (soap->d_stream->avail_in || !soap->d_stream->avail_out)
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n"));
      soap->d_stream->next_out = (Byte*)soap->buf;
      soap->d_stream->avail_out = SOAP_BUFLEN;
      r = inflate(soap->d_stream, Z_NO_FLUSH);
      if (r == Z_NEED_DICT && soap->z_dict)
	r = inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len);
      if (r == Z_OK || r == Z_STREAM_END)
      { soap->bufidx = 0;
        ret = soap->buflen = SOAP_BUFLEN - soap->d_stream->avail_out;
        if (soap->zlib_in == SOAP_ZLIB_GZIP)
          soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)ret);
        if (r == Z_STREAM_END)
        { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out));
          soap->z_ratio_in = (float)soap->d_stream->total_in / (float)soap->d_stream->total_out;
          soap->d_stream->next_out = Z_NULL;
        }
        if (ret)
        { soap->count += ret;
          DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- decompressed ----\n"));
          DBGMSG(RECV, soap->buf, ret);
          DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n----\n"));
          return SOAP_OK;
        }
      }
      else if (r != Z_BUF_ERROR)
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
        soap->d_stream->next_out = Z_NULL;
        soap->error = SOAP_ZLIB_ERROR;
        return EOF;
      }
    }
zlib_again:
    if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize)
    { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN);
      soap->buflen = soap->z_buflen;
    }
    DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- compressed ----\n"));
  }
#endif
#ifndef WITH_NOHTTP
  if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */
  { for (;;)
    { register soap_wchar c;
      char *t, tmp[8];
      if (soap->chunksize)
      { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize);
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret));
        DBGMSG(RECV, soap->buf, ret);
        soap->bufidx = 0;
        soap->chunksize -= ret;
        break;
      }
      t = tmp;
      if (!soap->chunkbuflen)
      { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN);
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes (chunked) from socket %d\n", (unsigned int)ret, soap->socket));
        DBGMSG(RECV, soap->buf, ret);
        soap->bufidx = 0;
        if (!ret)
          return soap->ahead = EOF;
      }
      else
        soap->bufidx = soap->buflen;
      soap->buflen = soap->chunkbuflen;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (idx=%u len=%u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen));
      while (!soap_isxdigit((int)(c = soap_getchunkchar(soap))))
      { if ((int)c == EOF)
          return soap->ahead = EOF;
      }
      do
        *t++ = (char)c;
      while (soap_isxdigit((int)(c = soap_getchunkchar(soap))) && t - tmp < 7);
      while ((int)c != EOF && c != '\n')
        c = soap_getchunkchar(soap);
      if ((int)c == EOF)
        return soap->ahead = EOF;
      *t = '\0';
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunk size = %s (hex)\n", tmp));
      soap->chunksize = soap_strtoul(tmp, &t, 16);
      if (!soap->chunksize)
      { soap->chunkbuflen = 0;
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n"));
        while ((int)c != EOF && c != '\n')
          c = soap_getchunkchar(soap);
        ret = 0;
        soap->ahead = EOF;
	break;
      }
      soap->buflen = soap->bufidx + soap->chunksize;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving buf len to idx=%u len=%u (%s)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen, tmp));
      if (soap->buflen > soap->chunkbuflen)
      { soap->buflen = soap->chunkbuflen;
        soap->chunksize -= soap->buflen - soap->bufidx;
        soap->chunkbuflen = 0;
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Passed end of buffer for chunked HTTP (%u bytes left)\n", (unsigned int)(soap->buflen - soap->bufidx)));
      }
      else if (soap->chunkbuflen)
        soap->chunksize = 0;
      ret = soap->buflen - soap->bufidx;
      if (ret)
        break;
    }
  }
  else
#endif
  { soap->bufidx = 0;
    soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN);
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes from socket %d\n", (unsigned int)ret, soap->socket));
    DBGMSG(RECV, soap->buf, ret);
  }
#ifndef WITH_LEANER
  if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret)))
    return soap->error = r;
#endif
#ifdef WITH_ZLIB
  if (soap->mode & SOAP_ENC_ZLIB)
  { memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
    soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
    soap->d_stream->avail_in = (unsigned int)ret;
    soap->d_stream->next_out = (Byte*)soap->buf;
    soap->d_stream->avail_out = SOAP_BUFLEN;
    r = inflate(soap->d_stream, Z_NO_FLUSH);
    if (r == Z_NEED_DICT && soap->z_dict)
      r = inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len);
    if (r == Z_OK || r == Z_STREAM_END)
    { soap->bufidx = 0;
      soap->z_buflen = soap->buflen;
      soap->buflen = SOAP_BUFLEN - soap->d_stream->avail_out;
      if (soap->zlib_in == SOAP_ZLIB_GZIP)
        soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen);
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)soap->buflen));
      if (ret && !soap->buflen && r != Z_STREAM_END)
        goto zlib_again;
      ret = soap->buflen;
      if (r == Z_STREAM_END)
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated total %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out));
        soap->z_ratio_in = (float)soap->d_stream->total_in / (float)soap->d_stream->total_out;
        soap->d_stream->next_out = Z_NULL;
      }
      DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- decompressed ----\n"));
      DBGMSG(RECV, soap->buf, ret);
    }
    else
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
      soap->d_stream->next_out = Z_NULL;
      soap->error = SOAP_ZLIB_ERROR;
      return EOF;
    }
  }
#endif
  soap->count += ret;
  return !ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x4(%rdi), %eax
notl %eax
testb $0x3, %al
jne 0x37d78
movq 0x18598(%rbx), %rdi
testq %rdi, %rdi
je 0x37de0
leaq 0x6138(%rbx), %rsi
movl $0x10000, %edx          # imm = 0x10000
cmpq %rdx, %rdi
cmovbq %rdi, %rdx
movq %rbx, %rdi
callq *0x6008(%rbx)
movq %rax, %r13
movq %rax, 0x60f8(%rbx)
movq $0x0, 0x60f0(%rbx)
subq %rax, 0x18598(%rbx)
jmp 0x37da2
movq $0x0, 0x60f0(%rbx)
leaq 0x6138(%rbx), %rsi
movl $0x10000, %edx          # imm = 0x10000
movq %rbx, %rdi
callq *0x6008(%rbx)
movq %rax, %r13
movq %rax, 0x60f8(%rbx)
movq 0x6058(%rbx), %rax
testq %rax, %rax
je 0x37dcc
leaq 0x6138(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq *%rax
testl %eax, %eax
je 0x37dcc
movl %eax, 0x19214(%rbx)
jmp 0x37f8d
addq %r13, 0x6110(%rbx)
xorl %eax, %eax
testq %r13, %r13
sete %al
jmp 0x37f8d
leaq 0x18598(%rbx), %rbp
leaq 0x185a0(%rbx), %rax
movq %rax, (%rsp)
leaq 0x6138(%rbx), %r14
movq 0x185a0(%rbx), %rax
leaq 0x10(%rsp), %r15
testq %rax, %rax
je 0x37e1a
movq 0x60f8(%rbx), %rcx
movq %rcx, 0x60f0(%rbx)
jmp 0x37e46
movl $0x10000, %edx          # imm = 0x10000
movq %rbx, %rdi
movq %r14, %rsi
callq *0x6008(%rbx)
movq %rax, 0x185a0(%rbx)
movq $0x0, 0x60f0(%rbx)
testq %rax, %rax
je 0x37f7e
movq %rax, 0x60f8(%rbx)
movq %rbx, %rdi
callq 0x37fb9
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
jb 0x37e90
movl %eax, %ecx
andl $-0x21, %ecx
addl $-0x41, %ecx
cmpl $0x6, %ecx
jb 0x37e90
cmpl $-0x1, %eax
je 0x37f7e
movq %rbx, %rdi
callq 0x37fb9
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
jb 0x37e90
movl %eax, %ecx
andl $-0x21, %ecx
addl $-0x41, %ecx
cmpl $0x5, %ecx
ja 0x37e6a
movl $0x1, %r12d
movq %r15, %r13
movb %al, (%r13)
incq %r13
movq %rbx, %rdi
callq 0x37fb9
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
setae %cl
movl %eax, %edx
andl $-0x21, %edx
addl $-0x41, %edx
cmpl $0x6, %edx
setae %dl
testb %dl, %cl
jne 0x37ed1
leaq 0x1(%r12), %rcx
cmpq $0x7, %r12
movq %rcx, %r12
jl 0x37e99
movq %r13, 0x8(%rsp)
cmpl $-0x1, %eax
je 0x37f7e
cmpl $0xa, %eax
je 0x37eee
movq %rbx, %rdi
callq 0x37fb9
jmp 0x37ed6
movb $0x0, (%r13)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x10, %edx
callq 0x3340
movq %rax, (%rbp)
testq %rax, %rax
je 0x37f9c
movq %rax, %rcx
movq 0x60f0(%rbx), %rdx
leaq (%rdx,%rax), %r13
movq %r13, 0x60f8(%rbx)
movq 0x185a0(%rbx), %rax
movq %r13, %rdi
subq %rax, %rdi
jbe 0x37f4f
movq %rax, 0x60f8(%rbx)
movq %rdi, 0x18598(%rbx)
movq (%rsp), %rcx
movq %rax, %r13
xorl %eax, %eax
jmp 0x37f59
testq %rax, %rax
je 0x37f77
movq %rbp, %rcx
xorl %edi, %edi
movq $0x0, (%rcx)
subq %rdx, %r13
jne 0x37da2
testq %rdi, %rdi
je 0x37e05
jmp 0x37d3e
movq %rcx, %rdi
xorl %eax, %eax
jmp 0x37f60
movl $0xffffffff, 0x6100(%rbx) # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, 0x185a0(%rbx)
movl $0xffffffff, 0x6100(%rbx) # imm = 0xFFFFFFFF
xorl %r13d, %r13d
jmp 0x37da2