// File: /workspace/github_c_makefile_star2_O1/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_begin_recv
SOAP_FMAC2
soap_begin_recv(struct soap *soap)
{ soap_wchar c;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for input\n"));
  soap->error = SOAP_OK;
  soap_free_temp(soap);
  soap_set_local_namespaces(soap);
  soap->version = 0;	/* don't assume we're parsing SOAP content by default */
#ifndef WITH_NOIDREF
  soap_free_iht(soap);
#endif
  if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
    soap->omode |= SOAP_IO_CHUNK;
  soap->imode &= ~(SOAP_IO | SOAP_ENC_MIME);
  soap->mode = soap->imode;
  if (!soap->keep_alive)
  { soap->buflen = 0;
    soap->bufidx = 0;
  }
  if (!(soap->mode & SOAP_IO_KEEPALIVE))
    soap->keep_alive = 0;
  soap->ahead = 0;
  soap->peeked = 0;
  soap->level = 0;
  soap->part = SOAP_BEGIN;
  soap->alloced = 0;
  soap->count = 0;
  soap->length = 0;
  soap->cdata = 0;
  *soap->endpoint = '\0';
  soap->action = NULL;
  soap->header = NULL;
  soap->fault = NULL;
  soap->status = 0;
#ifndef WITH_LEANER
  soap->dom = NULL;
  soap->dime.chunksize = 0;
  soap->dime.buflen = 0;
  soap->dime.list = NULL;
  soap->dime.first = NULL;
  soap->dime.last = NULL;
  soap->mime.list = NULL;
  soap->mime.first = NULL;
  soap->mime.last = NULL;
  soap->mime.boundary = NULL;
  soap->mime.start = NULL;
#endif
#ifdef WIN32
#ifndef UNDER_CE
#ifndef WITH_FASTCGI
  if (!soap_valid_socket(soap->socket))
#ifdef __BORLANDC__
    setmode(soap->recvfd, _O_BINARY);
#else
    _setmode(soap->recvfd, _O_BINARY);
#endif
#endif
#endif
#endif
#ifdef WITH_ZLIB
  soap->mode &= ~SOAP_ENC_ZLIB;
  soap->zlib_in = SOAP_ZLIB_NONE;
  soap->zlib_out = SOAP_ZLIB_NONE;
  soap->d_stream->next_in = Z_NULL;
  soap->d_stream->avail_in = 0;
  soap->d_stream->next_out = (Byte*)soap->buf;
  soap->d_stream->avail_out = SOAP_BUFLEN;
  soap->z_ratio_in = 1.0;
#endif
#ifdef WITH_OPENSSL
  if (soap->ssl)
    ERR_clear_error();
#endif
#ifndef WITH_LEANER
  if (soap->fprepareinitrecv && (soap->error = soap->fprepareinitrecv(soap)))
    return soap->error;
#endif
  c = soap_getchar(soap);
#ifdef WITH_GZIP
  if (c == 0x1F)
  { if (soap_getgziphdr(soap))
      return soap->error;
    if (inflateInit2(soap->d_stream, -MAX_WBITS) != Z_OK)
      return soap->error = SOAP_ZLIB_ERROR;
    if (soap->z_dict)
    { if (inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len) != Z_OK)
        return soap->error = SOAP_ZLIB_ERROR;
    }
    soap->zlib_state = SOAP_ZLIB_INFLATE;
    soap->mode |= SOAP_ENC_ZLIB;
    soap->zlib_in = SOAP_ZLIB_GZIP;
    soap->z_crc = crc32(0L, NULL, 0);
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n"));
    if (!soap->z_buf)
      soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
    memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
    /* should not chunk over plain transport, so why bother to check? */
    /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */
    /*   soap->z_buflen = soap->bufidx; */
    /* else */
    soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
    soap->d_stream->avail_in = soap->buflen - soap->bufidx;
    soap->z_buflen = soap->buflen;
    soap->buflen = soap->bufidx;
    c = ' ';
  }
#endif
  while (soap_blank(c))
    c = soap_getchar(soap);
#ifndef WITH_LEANER
  if (c == '-' && soap_get0(soap) == '-')
    soap->mode |= SOAP_ENC_MIME;
  else if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20)
    soap->mode |= SOAP_ENC_DIME;
  else
#endif
  { /* skip BOM */
    if (c == 0xEF && (c = soap_getchar(soap)) == 0xBB && (c = soap_getchar(soap)) == 0xBF)
      c = soap_getchar(soap);
    /* skip space */
    while (soap_blank(c))
      c = soap_getchar(soap);
  }
  if ((int)c == EOF)
    return soap->error = SOAP_EOF;
  soap_unget(soap, c);
#ifndef WITH_NOHTTP
  /* if not XML or MIME/DIME/ZLIB, assume HTTP header */
  if (c != '<' && !(soap->mode & (SOAP_ENC_MIME | SOAP_ENC_DIME | SOAP_ENC_ZLIB)))
  { soap_mode m = soap->imode;
    soap->mode &= ~SOAP_IO;
    soap->error = soap->fparse(soap);
    if (soap->error && soap->error < SOAP_STOP)
    { soap->keep_alive = 0; /* force close later */
      return soap->error;
    }
    if (soap->error == SOAP_STOP)
      return soap->error;
    soap->mode = soap->imode; /* if imode is changed, effectuate */
    soap->imode = m; /* restore imode */
#ifdef WITH_ZLIB
    soap->mode &= ~SOAP_ENC_ZLIB;
#endif
    if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
    { soap->chunkbuflen = soap->buflen;
      soap->buflen = soap->bufidx;
      soap->chunksize = 0;
    }
#ifndef WITH_LEANER
    else if (soap->fpreparerecv && soap->buflen != soap->bufidx)
      soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx);
#endif
    /* Note: fparse should not use soap_unget to push back last char */
    if (soap_get0(soap) == (int)EOF)
    { if (soap->status == 200)
        return soap->error = SOAP_NO_DATA; /* HTTP OK: always expect data */
      return soap->error = soap->status;
    }
#ifdef WITH_ZLIB
    if (soap->zlib_in != SOAP_ZLIB_NONE)
    {
#ifdef WITH_GZIP
      if (soap->zlib_in != SOAP_ZLIB_DEFLATE)
      { c = soap_get1(soap);
        if (c == 0x1F)
        { if (soap_getgziphdr(soap))
            return soap->error;
          if (inflateInit2(soap->d_stream, -MAX_WBITS) != Z_OK)
            return soap->error = SOAP_ZLIB_ERROR;
          soap->z_crc = crc32(0L, NULL, 0);
          DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n"));
        }
        else
        { soap_revget1(soap);
          if (inflateInit(soap->d_stream) != Z_OK)
            return soap->error = SOAP_ZLIB_ERROR;
          soap->zlib_in = SOAP_ZLIB_DEFLATE;
        }
      }
      else
#endif
      if (inflateInit(soap->d_stream) != Z_OK)
        return soap->error = SOAP_ZLIB_ERROR;
      if (soap->z_dict)
      { if (inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len) != Z_OK)
          return soap->error = SOAP_ZLIB_ERROR;
      }
      soap->zlib_state = SOAP_ZLIB_INFLATE;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n"));
      soap->mode |= SOAP_ENC_ZLIB;
      if (!soap->z_buf)
        soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
      memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
      soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
      soap->d_stream->avail_in = soap->buflen - soap->bufidx;
      soap->z_buflen = soap->buflen;
      soap->buflen = soap->bufidx;
    }
#endif
    if (soap->error)
    { if (soap->error == SOAP_FORM && soap->fform)
      { soap->error = soap->fform(soap);
        if (soap->error == SOAP_OK)
          soap->error = SOAP_STOP; /* prevents further processing */
      }
      return soap->error;
    }
  }
#endif
#ifndef WITH_LEANER
  if (soap->mode & SOAP_ENC_MIME)
  { if (soap_getmimehdr(soap))
      return soap->error;
    if (soap->mime.start)
    { do
      { if (!soap->mime.last->id)
          break;
        if (!soap_match_cid(soap, soap->mime.start, soap->mime.last->id))
          break;
      } while (soap_get_mime_attachment(soap, NULL));
    }
    if (soap_get_header_attribute(soap, soap->mime.first->type, "application/dime"))
      soap->mode |= SOAP_ENC_DIME;
  }
  if (soap->mode & SOAP_ENC_DIME)
  { if (soap_getdimehdr(soap))
      return soap->error;
    if (soap->dime.flags & SOAP_DIME_CF)
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n"));
      soap->dime.chunksize = soap->dime.size;
      if (soap->buflen - soap->bufidx >= soap->dime.chunksize)
      { soap->dime.buflen = soap->buflen;
        soap->buflen = soap->bufidx + soap->dime.chunksize;
      }
      else
        soap->dime.chunksize -= soap->buflen - soap->bufidx;
    }
    soap->count = soap->buflen - soap->bufidx;
  }
#endif
  return SOAP_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x0, 0x19214(%rdi)
callq 0x3b8bf
movq %rbx, %rdi
callq 0x3edff
movw $0x0, 0x2(%rbx)
movq %rbx, %rdi
callq 0x40fae
movl 0x8(%rbx), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
jne 0x48e38
orb $0x3, 0xc(%rbx)
movl %eax, %ecx
andl $0xfffffefc, %ecx       # imm = 0xFFFFFEFC
movl %ecx, 0x8(%rbx)
movl %ecx, 0x4(%rbx)
cmpw $0x0, 0x191cc(%rbx)
jne 0x48e5a
xorps %xmm0, %xmm0
movups %xmm0, 0x60f0(%rbx)
testb $0x10, %al
jne 0x48e67
movw $0x0, 0x191cc(%rbx)
xorl %eax, %eax
movl %eax, 0x6100(%rbx)
movw %ax, 0x18594(%rbx)
movl %eax, 0x6108(%rbx)
movl %eax, 0x18590(%rbx)
movw %ax, 0x6104(%rbx)
movb $0x0, 0x185a8(%rbx)
movq %rax, 0x191a8(%rbx)
movl %eax, 0x19210(%rbx)
movq %rax, 0x19220(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x5f30(%rbx)
movups %xmm0, 0x6110(%rbx)
movups %xmm0, 0x19238(%rbx)
movups %xmm0, 0x19270(%rbx)
movups %xmm0, 0x19280(%rbx)
movups %xmm0, 0x19290(%rbx)
movups %xmm0, 0x192a0(%rbx)
movq 0x6048(%rbx), %rax
testq %rax, %rax
je 0x48ef9
movq %rbx, %rdi
callq *%rax
movl %eax, %ebp
movl %eax, 0x19214(%rbx)
testl %eax, %eax
jne 0x491c7
movq %rbx, %rdi
callq 0x37f8a
cmpl $0x20, %eax
ja 0x48f13
movq %rbx, %rdi
callq 0x37f8a
cmpl $0x21, %eax
jb 0x48f06
movl %eax, %ebp
cmpl $0x2d, %eax
jne 0x48f53
movq 0x60f0(%rbx), %rax
cmpq 0x60f8(%rbx), %rax
jb 0x48f36
movq %rbx, %rdi
callq 0x37dbb
testl %eax, %eax
jne 0x48f53
movq 0x60f0(%rbx), %rax
cmpb $0x2d, 0x6138(%rbx,%rax)
jne 0x48f53
movl $0x2d, %ebp
movl $0x100, %eax            # imm = 0x100
jmp 0x48f96
movl %ebp, %eax
andl $0xfffc, %eax           # imm = 0xFFFC
cmpl $0xc, %eax
jne 0x48f9b
movq 0x60f0(%rbx), %rax
cmpq 0x60f8(%rbx), %rax
jb 0x48f7b
movq %rbx, %rdi
callq 0x37dbb
testl %eax, %eax
jne 0x48f9b
movq 0x60f0(%rbx), %rax
movb 0x6138(%rbx,%rax), %cl
andb $-0x10, %cl
movl $0x80, %eax
cmpb $0x20, %cl
jne 0x48f9b
orl %eax, 0x4(%rbx)
jmp 0x48fdf
cmpl $0xef, %ebp
jne 0x48fcb
movq %rbx, %rdi
callq 0x37f8a
cmpl $0xbb, %eax
jne 0x48fc9
movq %rbx, %rdi
callq 0x37f8a
cmpl $0xbf, %eax
jne 0x48fc9
movq %rbx, %rdi
callq 0x37f8a
movl %eax, %ebp
cmpl $0x20, %ebp
ja 0x48fdf
movq %rbx, %rdi
callq 0x37f8a
cmpl $0x21, %eax
jb 0x48fd0
movl %eax, %ebp
cmpl $-0x1, %ebp
je 0x4903e
movl %ebp, 0x6100(%rbx)
cmpl $0x3c, %ebp
je 0x49151
movl 0x4(%rbx), %eax
testl $0x580, %eax            # imm = 0x580
jne 0x49151
movl 0x8(%rbx), %r14d
andl $0xfffffa7c, %eax       # imm = 0xFFFFFA7C
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
callq *0x5fa8(%rbx)
movl %eax, %ebp
movl %eax, 0x19214(%rbx)
testl %eax, %eax
sete %al
cmpl $0x3e8, %ebp            # imm = 0x3E8
setge %cl
orb %al, %cl
jne 0x49052
movw $0x0, 0x191cc(%rbx)
jmp 0x4914b
movl $0xffffffff, 0x19214(%rbx) # imm = 0xFFFFFFFF
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x491c7
cmpl $0x3e8, %ebp            # imm = 0x3E8
jne 0x49064
movl $0x3e8, %ebp            # imm = 0x3E8
jmp 0x4914b
movl 0x8(%rbx), %eax
movl %eax, 0x4(%rbx)
movl %r14d, 0x8(%rbx)
notl %eax
testb $0x3, %al
jne 0x4909d
movq 0x60f0(%rbx), %rax
movq 0x60f8(%rbx), %rcx
movq %rcx, 0x185a0(%rbx)
movq %rax, 0x60f8(%rbx)
movq $0x0, 0x18598(%rbx)
jmp 0x490cc
movq 0x6058(%rbx), %rax
testq %rax, %rax
je 0x490cc
movq 0x60f0(%rbx), %rcx
movq 0x60f8(%rbx), %rdx
subq %rcx, %rdx
je 0x490cc
leaq (%rbx,%rcx), %rsi
addq $0x6138, %rsi           # imm = 0x6138
movq %rbx, %rdi
callq *%rax
movq 0x60f0(%rbx), %rax
cmpq 0x60f8(%rbx), %rax
jb 0x49107
movq %rbx, %rdi
callq 0x37dbb
testl %eax, %eax
je 0x49107
movl 0x19210(%rbx), %ebp
cmpl $0xc8, %ebp
jne 0x49145
movl $0xe, 0x19214(%rbx)
movl $0xe, %ebp
jmp 0x4914b
movl 0x19214(%rbx), %eax
testl %eax, %eax
je 0x49141
cmpl $0x3e9, %eax            # imm = 0x3E9
jne 0x49139
movq 0x5f90(%rbx), %rax
testq %rax, %rax
je 0x49139
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cmovnel %eax, %ecx
movl %ecx, 0x19214(%rbx)
movl 0x19214(%rbx), %ebp
jmp 0x4914b
movb $0x1, %al
jmp 0x4914d
movl %ebp, 0x19214(%rbx)
xorl %eax, %eax
testb %al, %al
je 0x491c7
testb $0x1, 0x5(%rbx)
jne 0x491b5
xorl %ebp, %ebp
testb $-0x80, 0x4(%rbx)
je 0x491c7
movq %rbx, %rdi
callq 0x47ef4
testl %eax, %eax
jne 0x491c1
testb $0x1, 0x19248(%rbx)
je 0x49247
movq 0x19230(%rbx), %rax
movq %rax, 0x19238(%rbx)
movq 0x60f0(%rbx), %rcx
movq 0x60f8(%rbx), %rdx
movq %rdx, %rdi
subq %rcx, %rdi
movq %rax, %rsi
subq %rdi, %rsi
jbe 0x49236
leaq 0x19238(%rbx), %rax
movq %rsi, (%rax)
jmp 0x49247
movq %rbx, %rdi
callq 0x48199
testl %eax, %eax
je 0x491ce
movl 0x19214(%rbx), %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
cmpq $0x0, 0x19290(%rbx)
je 0x4920a
movq 0x192a8(%rbx), %rax
movq 0x18(%rax), %rdx
testq %rdx, %rdx
je 0x4920a
movq 0x19290(%rbx), %rsi
movq %rbx, %rdi
callq 0x489d3
testl %eax, %eax
je 0x4920a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x48596
testq %rax, %rax
jne 0x491d8
movq 0x192a0(%rbx), %rax
movq 0x20(%rax), %rsi
leaq 0x972c(%rip), %rdx      # 0x52948
movq %rbx, %rdi
callq 0x484f8
testq %rax, %rax
je 0x49157
orb $-0x80, 0x4(%rbx)
jmp 0x49157
movq %rdx, 0x19240(%rbx)
addq %rax, %rcx
movq %rcx, 0x60f8(%rbx)
movq 0x60f8(%rbx), %rax
subq 0x60f0(%rbx), %rax
movq %rax, 0x6110(%rbx)
jmp 0x491c7