// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdi, %rbx
movl 0x4(%rdi), %eax
notl %eax
testb $0x3, %al
jne 0x37cb1
leaq 0x18598(%rbx), %r15
leaq 0x6138(%rbx), %r14
leaq 0x185a0(%rbx), %r12
leaq 0x10(%rsp), %rax
movl $0x1, %ecx
subq %rax, %rcx
movq %rcx, 0x18(%rsp)
movl $0x10000, %ebp          # imm = 0x10000
movq %r15, 0x8(%rsp)
movq %r12, 0x20(%rsp)
movq (%r15), %rdx
testq %rdx, %rdx
je 0x37ac6
cmpq %rbp, %rdx
cmovaeq %rbp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x6008(%rbx)
movq %rax, %r13
movq %rax, 0x60f8(%rbx)
movq $0x0, 0x60f0(%rbx)
subq %rax, 0x18598(%rbx)
movl $0x2, %eax
jmp 0x37c80
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, (%r12)
je 0x37ae6
movq 0x60f8(%rbx), %rax
movq %rax, 0x60f0(%rbx)
jmp 0x37b15
movl $0x10000, %edx          # imm = 0x10000
movq %rbx, %rdi
movq %r14, %rsi
callq *0x6008(%rbx)
movq %rax, %r13
movq %rax, 0x185a0(%rbx)
movq $0x0, 0x60f0(%rbx)
testq %rax, %rax
je 0x37c37
movq 0x185a0(%rbx), %rax
movq %rax, 0x60f8(%rbx)
movq %rbx, %rdi
callq 0x37d2e
movl %eax, %ebp
leal -0x3a(%rbp), %eax
cmpl $-0xb, %eax
ja 0x37b5b
movl %ebp, %eax
andl $-0x21, %eax
addl $-0x47, %eax
cmpl $-0x6, %eax
jae 0x37b5b
cmpl $-0x1, %ebp
jne 0x37b23
movl $0xffffffff, 0x6100(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %eax
jmp 0x37c7b
movq %r14, %r12
movq (%rsp), %r15
movq 0x18(%rsp), %rax
leaq (%rax,%r15), %r14
movb %bpl, (%r15)
incq %r15
movq %rbx, %rdi
callq 0x37d2e
movl %eax, %ebp
leal -0x30(%rbp), %eax
cmpl $0xa, %eax
setae %al
movl %ebp, %ecx
andl $-0x21, %ecx
addl $-0x41, %ecx
cmpl $0x6, %ecx
setae %cl
testb %cl, %al
jne 0x37ba3
leaq 0x1(%r14), %rax
cmpq $0x7, %r14
movq %rax, %r14
jl 0x37b6b
movq %r15, (%rsp)
movq %r12, %r14
movq 0x20(%rsp), %r12
cmpl $-0x1, %ebp
je 0x37c21
cmpl $0xa, %ebp
je 0x37bc5
movq %rbx, %rdi
callq 0x37d2e
movl %eax, %ebp
jmp 0x37baf
movb $0x0, (%r15)
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
movl $0x10, %edx
callq 0x3330
movq 0x8(%rsp), %r15
movq %rax, (%r15)
testq %rax, %rax
je 0x37c4b
movq 0x60f0(%rbx), %rcx
addq %rcx, %rax
movq %rax, 0x60f8(%rbx)
movq 0x185a0(%rbx), %rdx
subq %rdx, %rax
jbe 0x37c8a
movq %rdx, 0x60f8(%rbx)
movq %rax, 0x18598(%rbx)
movq %r12, %rax
movl $0x10000, %ebp          # imm = 0x10000
jmp 0x37c97
movl $0xffffffff, 0x6100(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %eax
movq 0x8(%rsp), %r15
jmp 0x37c7b
movl $0xffffffff, 0x6100(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %eax
xorl %r13d, %r13d
jmp 0x37c80
movq $0x0, (%r12)
cmpl $-0x1, %ebp
je 0x37c69
cmpl $0xa, %ebp
je 0x37c69
movq %rbx, %rdi
callq 0x37d2e
movl %eax, %ebp
jmp 0x37c53
movl $0xffffffff, 0x6100(%rbx) # imm = 0xFFFFFFFF
movl $0x2, %eax
xorl %r13d, %r13d
movl $0x10000, %ebp          # imm = 0x10000
testl %eax, %eax
je 0x37a85
jmp 0x37cdd
movq %r15, %rax
testq %rdx, %rdx
movl $0x10000, %ebp          # imm = 0x10000
je 0x37c9e
movq $0x0, (%rax)
movq 0x60f8(%rbx), %r13
xorl %eax, %eax
subq %rcx, %r13
setne %al
addl %eax, %eax
jmp 0x37c80
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)
jmp 0x37ce2
cmpl $0x2, %eax
jne 0x37d1a
movq 0x6058(%rbx), %rax
testq %rax, %rax
je 0x37d09
leaq 0x6138(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq *%rax
testl %eax, %eax
je 0x37d09
movl %eax, 0x19214(%rbx)
jmp 0x37d1f
addq %r13, 0x6110(%rbx)
xorl %eax, %eax
testq %r13, %r13
sete %al
jmp 0x37d1f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq