// File: /workspace/github_c_makefile_star2_O2/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 0x34c88
leaq 0x18598(%rbx), %r12
leaq 0x185a0(%rbx), %rbp
leaq 0x6138(%rbx), %r14
movq 0x18598(%rbx), %rcx
pushq $0x1
popq %r15
testq %rcx, %rcx
jne 0x34d00
movq (%rbp), %rax
testq %rax, %rax
je 0x34b45
movq 0x60f8(%rbx), %rcx
movq %rcx, 0x60f0(%rbx)
jmp 0x34b6e
movl $0x10000, %edx          # imm = 0x10000
movq %rbx, %rdi
movq %r14, %rsi
callq *0x6008(%rbx)
movq %rax, 0x185a0(%rbx)
andq $0x0, 0x60f0(%rbx)
testq %rax, %rax
je 0x34cd6
movq %rax, 0x60f8(%rbx)
movq %rbx, %rdi
callq 0x34d4d
leal -0x3a(%rax), %ecx
cmpl $-0xb, %ecx
ja 0x34b9c
movl %eax, %ecx
andl $-0x21, %ecx
addl $-0x47, %ecx
cmpl $-0x6, %ecx
jae 0x34b9c
cmpl $-0x1, %eax
jne 0x34b75
jmp 0x34cd6
movq %rbp, (%rsp)
movq %r14, %rbp
movq %r12, %r14
movq %r15, %r12
leaq 0x10(%rsp), %r13
movb %al, (%r13)
incq %r13
movq %rbx, %rdi
callq 0x34d4d
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 0x34be5
leaq 0x1(%r15), %rcx
cmpq $0x7, %r15
movq %rcx, %r15
jl 0x34bae
movq %r13, 0x8(%rsp)
movq %r12, %r15
movq %r14, %r12
movq %rbp, %r14
movq (%rsp), %rbp
cmpl $-0x1, %eax
je 0x34cd6
cmpl $0xa, %eax
je 0x34c0f
movq %rbx, %rdi
callq 0x34d4d
jmp 0x34bf7
movb $0x0, (%r13)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3350
movq %rax, (%r12)
testq %rax, %rax
je 0x34d36
movq 0x60f0(%rbx), %rdx
leaq (%rdx,%rax), %r13
movq %r13, 0x60f8(%rbx)
movq 0x185a0(%rbx), %rsi
movq %r13, %rcx
subq %rsi, %rcx
jbe 0x34c6a
movq %rsi, 0x60f8(%rbx)
movq %rcx, 0x18598(%rbx)
movq %rbp, %rax
movq %rsi, %r13
jmp 0x34c74
testq %rsi, %rsi
je 0x34c83
movq %r12, %rax
xorl %ecx, %ecx
andq $0x0, (%rax)
subq %rdx, %r13
je 0x34b23
jmp 0x34caf
movq %rax, %rcx
jmp 0x34c78
andq $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 0x34ce2
leaq 0x6138(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq *%rax
testl %eax, %eax
je 0x34ce2
movl %eax, 0x19214(%rbx)
jmp 0x34cf1
orl $-0x1, 0x6100(%rbx)
pushq $-0x1
popq %rax
jmp 0x34cf1
addq %r13, 0x6110(%rbx)
xorl %eax, %eax
testq %r13, %r13
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10000, %edx          # imm = 0x10000
cmpq %rdx, %rcx
cmovbq %rcx, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x6008(%rbx)
movq %rax, %r13
movq %rax, 0x60f8(%rbx)
andq $0x0, 0x60f0(%rbx)
subq %rax, 0x18598(%rbx)
jmp 0x34caf
andq $0x0, 0x185a0(%rbx)
orl $-0x1, 0x6100(%rbx)
xorl %r13d, %r13d
jmp 0x34caf