// File: /workspace/github_c_makefile_star2_O3/hkshenSmart[P]ONVIF-discovery_cs/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->filterstop = 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 = (unsigned int)(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_get1(soap)) == 0xBB && (c = soap_get1(soap)) == 0xBF)
    { soap->mode &= ~SOAP_ENC_LATIN;
      c = soap_getchar(soap);
    }
    else
    { /* UTF-16 BOM? */
      if ((c == 0xFE && soap_get1(soap) == 0xFF)  /* UTF-16 BE */
       || (c == 0xFF && soap_get1(soap) == 0xFE)) /* UTF-16 LE */
        return soap->error = SOAP_UTF_ERROR;
    }
    /* 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;
    }
    /* 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 = (unsigned int)(soap->buflen - soap->bufidx);
      soap->z_buflen = soap->buflen;
      soap->buflen = soap->bufidx;
    }
#endif
#ifndef WITH_LEANER
    if (soap->fpreparerecv && (soap->mode & SOAP_IO) != SOAP_IO_CHUNK && soap->buflen > soap->bufidx)
    { int r;
      if ((r = soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx)))
        return soap->error = r;
    }
#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)
  { do /* skip preamble */
    { if ((int)(c = soap_getchar(soap)) == EOF)
        return soap->error = SOAP_EOF;
    } while (c != '-' || soap_get0(soap) != '-');
    soap_unget(soap, c);
    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 %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, 0x1f274(%rdi)
movl %eax, 0xc0b8(%rdi)
callq 0x152b9
movq %rbx, %rdi
callq 0x17f7b
movw $0x0, 0x2(%rbx)
movq %rbx, %rdi
callq 0x19da2
movl 0x8(%rbx), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
jne 0x21a2d
orb $0x3, 0xc(%rbx)
movl %eax, %ecx
andl $0xfffffefc, %ecx       # imm = 0xFFFFFEFC
movl %ecx, 0x8(%rbx)
movl %ecx, 0x4(%rbx)
cmpw $0x0, 0x1f22c(%rbx)
jne 0x21a4f
xorps %xmm0, %xmm0
movups %xmm0, 0xc150(%rbx)
testb $0x10, %al
jne 0x21a5c
movw $0x0, 0x1f22c(%rbx)
xorl %eax, %eax
movl %eax, 0xc160(%rbx)
movl %eax, 0xc168(%rbx)
movw %ax, 0x1e5f0(%rbx)
movl %eax, 0x1e5f4(%rbx)
movw %ax, 0xc164(%rbx)
movb $0x0, 0x1e608(%rbx)
movq %rax, 0x1f208(%rbx)
movl %eax, 0x1f270(%rbx)
movq %rax, 0x1f280(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xbf30(%rbx)
movups %xmm0, 0xc170(%rbx)
movups %xmm0, 0x1f298(%rbx)
movups %xmm0, 0x1f2d0(%rbx)
movups %xmm0, 0x1f2e0(%rbx)
movups %xmm0, 0x1f2f0(%rbx)
movups %xmm0, 0x1f300(%rbx)
movq 0xc090(%rbx), %rax
testq %rax, %rax
je 0x21aee
movq %rbx, %rdi
callq *%rax
movl %eax, %ebp
movl %eax, 0x1f274(%rbx)
testl %eax, %eax
jne 0x2201b
movq %rbx, %rdi
callq 0x10c37
cmpl $0x20, %eax
ja 0x21b08
movq %rbx, %rdi
callq 0x10c37
cmpl $0x21, %eax
jb 0x21afb
movl %eax, %ebp
cmpl $0x2d, %eax
jne 0x21b68
movq 0xc150(%rbx), %rax
cmpq 0xc158(%rbx), %rax
jb 0x21b3b
movq %rbx, %rdi
callq 0x109c7
movl $0x2d, %ebp
testl %eax, %eax
jne 0x21d30
movq 0xc150(%rbx), %rax
movl $0x2d, %ebp
cmpb $0x2d, 0xc198(%rbx,%rax)
jne 0x21d30
movl $0x100, %ecx            # imm = 0x100
orl 0x4(%rbx), %ecx
movl %ecx, 0x4(%rbx)
movl $0x2d, 0xc160(%rbx)
jmp 0x21d3e
movl %ebp, %eax
andl $0xfffc, %eax           # imm = 0xFFFC
cmpl $0xc, %eax
jne 0x21bb4
movq 0xc150(%rbx), %rax
cmpq 0xc158(%rbx), %rax
jb 0x21b97
movq %rbx, %rdi
callq 0x109c7
testl %eax, %eax
jne 0x21bb4
movq 0xc150(%rbx), %rax
movb 0xc198(%rbx,%rax), %al
andb $-0x10, %al
cmpb $0x20, %al
jne 0x21bb4
movl $0x80, %ecx
orl 0x4(%rbx), %ecx
movl %ecx, 0x4(%rbx)
jmp 0x21d33
cmpl $0xef, %ebp
jne 0x21c4d
movq 0xc150(%rbx), %rcx
cmpq 0xc158(%rbx), %rcx
jb 0x21be7
movq %rbx, %rdi
callq 0x109c7
testl %eax, %eax
jne 0x21cc6
movq 0xc150(%rbx), %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0xc150(%rbx)
movzbl 0xc198(%rbx,%rcx), %ebp
cmpl $0xbb, %ebp
jne 0x21c4d
cmpq 0xc158(%rbx), %rax
jb 0x21c22
movq %rbx, %rdi
callq 0x109c7
testl %eax, %eax
jne 0x21cc6
movq 0xc150(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xc150(%rbx)
movzbl 0xc198(%rbx,%rax), %ebp
cmpl $0xbf, %ebp
jne 0x21c4d
andb $-0x21, 0x4(%rbx)
movq %rbx, %rdi
callq 0x10c37
movl %eax, %ebp
jmp 0x21cad
cmpl $0xff, %ebp
je 0x21cda
cmpl $0xfe, %ebp
jne 0x21cad
movq 0xc150(%rbx), %rax
cmpq 0xc158(%rbx), %rax
jb 0x21c8d
movq %rbx, %rdi
callq 0x109c7
movl $0xfe, %ebp
testl %eax, %eax
jne 0x21d30
movq 0xc150(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xc150(%rbx)
movl $0xfe, %ebp
cmpb $-0x1, 0xc198(%rbx,%rax)
jne 0x21d30
jmp 0x21d1c
cmpl $0x20, %ebp
ja 0x21cc1
movq %rbx, %rdi
callq 0x10c37
cmpl $0x21, %eax
jb 0x21cb2
movl %eax, %ebp
cmpl $-0x1, %ebp
jne 0x21d30
movl $0xffffffff, 0x1f274(%rbx) # imm = 0xFFFFFFFF
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x2201b
movq 0xc150(%rbx), %rax
cmpq 0xc158(%rbx), %rax
jb 0x21d02
movq %rbx, %rdi
callq 0x109c7
movl $0xff, %ebp
testl %eax, %eax
jne 0x21d30
movq 0xc150(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xc150(%rbx)
movl $0xff, %ebp
cmpb $-0x2, 0xc198(%rbx,%rax)
jne 0x21d30
movl $0x2f, 0x1f274(%rbx)
movl $0x2f, %ebp
jmp 0x2201b
movl 0x4(%rbx), %ecx
movl %ebp, 0xc160(%rbx)
cmpl $0x3c, %ebp
je 0x21d4a
testl $0x580, %ecx            # imm = 0x580
je 0x21dfa
btl $0x8, %ecx
jb 0x21d91
xorl %ebp, %ebp
testb %cl, %cl
jns 0x2201b
movq %rbx, %rdi
callq 0x20c70
testl %eax, %eax
jne 0x21def
leaq 0xc170(%rbx), %rax
testb $0x1, 0x1f2a8(%rbx)
jne 0x21f05
movq 0xc150(%rbx), %rcx
movq 0xc158(%rbx), %rdx
jmp 0x21ff2
movq %rbx, %rdi
callq 0x10c37
cmpl $0x2d, %eax
je 0x21da8
cmpl $-0x1, %eax
jne 0x21d91
jmp 0x21cc6
movq 0xc150(%rbx), %rax
cmpq 0xc158(%rbx), %rax
jb 0x21dcb
movq %rbx, %rdi
callq 0x109c7
testl %eax, %eax
jne 0x21d91
movq 0xc150(%rbx), %rax
cmpb $0x2d, 0xc198(%rbx,%rax)
jne 0x21d91
movl $0x2d, 0xc160(%rbx)
movq %rbx, %rdi
callq 0x20f0b
testl %eax, %eax
je 0x21e95
movl 0x1f274(%rbx), %ebp
jmp 0x2201b
movl 0x8(%rbx), %r14d
andl $0xfffffa7c, %ecx       # imm = 0xFFFFFA7C
movl %ecx, 0x4(%rbx)
movq %rbx, %rdi
callq *0xbfd0(%rbx)
movl %eax, 0x1f274(%rbx)
testl %eax, %eax
sete %cl
cmpl $0x3e8, %eax            # imm = 0x3E8
setge %dl
orb %cl, %dl
jne 0x21e37
movw $0x0, 0x1f22c(%rbx)
movl %eax, %ebp
jmp 0x2201b
movl $0x3e8, %ebp            # imm = 0x3E8
cmpl $0x3e8, %eax            # imm = 0x3E8
je 0x2201b
movl 0x8(%rbx), %eax
movl %eax, 0x4(%rbx)
movl %r14d, 0x8(%rbx)
notl %eax
leaq 0xc150(%rbx), %r14
testb $0x3, %al
jne 0x21f42
leaq 0xc158(%rbx), %r15
movq 0xc150(%rbx), %rax
movq 0xc158(%rbx), %rcx
movq %rcx, 0x1e600(%rbx)
movq %rax, 0xc158(%rbx)
movq $0x0, 0x1e5f8(%rbx)
jmp 0x21f59
cmpq $0x0, 0x1f2f0(%rbx)
je 0x21ed1
movq 0x1f308(%rbx), %rax
movq 0x18(%rax), %rdx
testq %rdx, %rdx
je 0x21ed1
movq 0x1f2f0(%rbx), %rsi
movq %rbx, %rdi
callq 0x21673
testl %eax, %eax
je 0x21ed1
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21236
testq %rax, %rax
jne 0x21e9f
movq 0x1f300(%rbx), %rax
movq 0x20(%rax), %rsi
leaq 0x4919(%rip), %rdx      # 0x267fc
movq %rbx, %rdi
callq 0x172e5
movl 0x4(%rbx), %ecx
testq %rax, %rax
je 0x21d50
orl $0x80, %ecx
movl %ecx, 0x4(%rbx)
jmp 0x21d50
movq 0x1f290(%rbx), %rsi
movq %rsi, 0x1f298(%rbx)
movq 0xc150(%rbx), %rcx
movq 0xc158(%rbx), %rdx
movq %rdx, %r8
subq %rcx, %r8
movq %rsi, %rdi
subq %r8, %rdi
jbe 0x21fde
addq $0x1f298, %rbx          # imm = 0x1F298
movq %rdi, (%rbx)
jmp 0x21ff2
movq 0xc150(%rbx), %rax
leaq 0xc158(%rbx), %r15
cmpq 0xc158(%rbx), %rax
jb 0x21f8b
movq %rbx, %rdi
callq 0x109c7
testl %eax, %eax
je 0x21f8b
movl 0x1f270(%rbx), %ebp
cmpl $0xc8, %ebp
jne 0x22015
movl $0xe, 0x1f274(%rbx)
movl $0xe, %ebp
jmp 0x2201b
movq 0xc0a0(%rbx), %rax
testq %rax, %rax
je 0x21fc4
movl 0x4(%rbx), %ecx
notl %ecx
testb $0x3, %cl
je 0x21fc4
movq (%r15), %rdx
movq (%r14), %rcx
subq %rcx, %rdx
jbe 0x21fc4
leaq (%rbx,%rcx), %rsi
addq $0xc198, %rsi           # imm = 0xC198
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
je 0x21fc4
movl %eax, %ebp
jmp 0x22015
movl 0x1f274(%rbx), %ebp
cmpl $0x3e9, %ebp            # imm = 0x3E9
je 0x21ffa
testl %ebp, %ebp
jne 0x2201b
movl 0x4(%rbx), %ecx
jmp 0x21d4a
movq %rdx, 0x1f2a0(%rbx)
addq %rcx, %rsi
movq %rsi, 0xc158(%rbx)
movq %rsi, %rdx
subq %rcx, %rdx
movq %rdx, (%rax)
jmp 0x2201b
movq 0xbfb8(%rbx), %rax
testq %rax, %rax
je 0x22028
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
movl $0x3e8, %ebp            # imm = 0x3E8
cmovnel %eax, %ebp
movl %ebp, 0x1f274(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x3e9, %ebp            # imm = 0x3E9
jmp 0x2201b