// File: /workspace/github_c_makefile_star2_O1/hkshenSmart[P]ONVIF-discovery_cs/stdsoap2.c
// Function: soap_begin_send
SOAP_FMAC2
soap_begin_send(struct soap *soap)
{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for output\n"));
  soap_free_ns(soap);
  soap->error = SOAP_OK;
  soap->mode = soap->omode | (soap->mode & (SOAP_IO_LENGTH | SOAP_ENC_DIME));
#ifdef WITH_ZLIB
  if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH)
  { if (soap->mode & SOAP_ENC_XML)
      soap->mode |= SOAP_IO_BUFFER;
    else
      soap->mode |= SOAP_IO_STORE;
  }
#endif
#ifndef WITH_LEAN
  if ((soap->mode & SOAP_IO_UDP))
  { soap->mode |= SOAP_ENC_XML;
    if (soap->count > SOAP_BUFLEN)
      return soap->error = SOAP_UDP_ERROR;
  }
#endif
  if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket))
  { if (soap->count || (soap->mode & SOAP_IO_LENGTH) || (soap->mode & SOAP_ENC_XML))
      soap->mode |= SOAP_IO_BUFFER;
    else
      soap->mode |= SOAP_IO_STORE;
  }
  soap->mode &= ~SOAP_IO_LENGTH;
  if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
    if (soap_new_block(soap) == NULL)
      return soap->error;
  if (!(soap->mode & SOAP_IO_KEEPALIVE))
    soap->keep_alive = 0;
  if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH))
    soap->mode |= SOAP_XML_TREE;
#ifndef WITH_LEANER
  if ((soap->mode & SOAP_ENC_MTOM) && (soap->mode & SOAP_ENC_DIME))
  { soap->mode |= SOAP_ENC_MIME;
    soap->mode &= ~SOAP_ENC_DIME;
  }
  else if (!(soap->mode & SOAP_ENC_MIME))
    soap->mode &= ~SOAP_ENC_MTOM;
  if (soap->mode & SOAP_ENC_MIME)
    soap_select_mime_boundary(soap);
#ifdef WIN32
#ifndef UNDER_CE
#ifndef WITH_FASTCGI
  if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */
#ifdef __BORLANDC__
    setmode(soap->sendfd, _O_BINARY);
#else
    _setmode(soap->sendfd, _O_BINARY);
#endif
#endif
#endif
#endif
#endif
  if (soap->mode & SOAP_IO)
  { soap->bufidx = 0;
    soap->buflen = 0;
  }
  soap->chunksize = 0;
  soap->ns = 0;
  soap->null = 0;
  soap->position = 0;
  soap->mustUnderstand = 0;
  soap->encoding = 0;
  soap->idnum = 0;
  soap->level = 0;
  soap_clr_attr(soap);
  soap_set_local_namespaces(soap);
#ifdef WITH_ZLIB
  soap->z_ratio_out = 1.0;
  if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE)
  { if (!soap->z_buf)
      soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
    soap->d_stream->next_out = (Byte*)soap->z_buf;
    soap->d_stream->avail_out = SOAP_BUFLEN;
#ifdef WITH_GZIP
    if (soap->zlib_out != SOAP_ZLIB_DEFLATE)
    { memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10);
      soap->d_stream->next_out = (Byte*)soap->z_buf + 10;
      soap->d_stream->avail_out = SOAP_BUFLEN - 10;
      soap->z_crc = crc32(0L, NULL, 0);
      soap->zlib_out = SOAP_ZLIB_GZIP;
      if (soap->z_dict)
        *((Byte*)soap->z_buf + 2) = 0xff;
      if (deflateInit2(soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK)
        return soap->error = SOAP_ZLIB_ERROR;
    }
    else
#endif
    if (deflateInit(soap->d_stream, soap->z_level) != Z_OK)
      return soap->error = SOAP_ZLIB_ERROR;
    if (soap->z_dict)
    { if (deflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len) != Z_OK)
        return soap->error = SOAP_ZLIB_ERROR;
    }
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n"));
    soap->zlib_state = SOAP_ZLIB_DEFLATE;
  }
#endif
#ifdef WITH_OPENSSL
  if (soap->ssl)
    ERR_clear_error();
#endif
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count));
  soap->part = SOAP_BEGIN;
#ifndef WITH_LEANER
  if (soap->fprepareinitsend && (soap->mode & SOAP_IO) == SOAP_IO_STORE && (soap->error = soap->fprepareinitsend(soap)))
    return soap->error;
#endif
  return SOAP_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x88(%rdi), %rdi
testq %rdi, %rdi
je 0x17a4f
movq (%rdi), %r14
callq 0x3030
movq %r14, %rdi
testq %r14, %r14
jne 0x17a3f
movq $0x0, 0x88(%rbx)
movl $0x0, 0x1f274(%rbx)
movl $0x88, %eax
andl 0x4(%rbx), %eax
movl 0xc(%rbx), %ecx
orl %ecx, %eax
movl %eax, 0x4(%rbx)
testb $0x4, %cl
je 0x17aa0
orl $0x40, %eax
movl %eax, 0x4(%rbx)
cmpq $0x10001, 0xc170(%rbx) # imm = 0x10001
jb 0x17aa0
movl $0x1b, 0x1f274(%rbx)
movl $0x1b, %eax
jmp 0x17bfc
movl 0x4(%rbx), %eax
testb $0x3, %al
jne 0x17acc
cmpl $-0x1, 0xc134(%rbx)
je 0x17acc
cmpq $0x0, 0xc170(%rbx)
sete %cl
testb $0x48, %al
sete %dl
andb %cl, %dl
movzbl %dl, %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x4(%rbx)
movl 0x4(%rbx), %r14d
movl %r14d, %ebp
andl $-0x9, %ebp
movl %ebp, 0x4(%rbx)
movl %r14d, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x17b20
movl $0x18, %edi
callq 0x3240
testq %rax, %rax
je 0x17b0d
movq 0x90(%rbx), %rcx
movq %rcx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq %rax, 0x90(%rbx)
jmp 0x17b17
movl $0x14, 0x1f274(%rbx)
testq %rax, %rax
je 0x17bf6
testb $0x10, %r14b
jne 0x17b2f
movw $0x0, 0x1f22c(%rbx)
btl $0x12, %r14d
jb 0x17b46
cmpq $0x0, 0x38(%rbx)
jne 0x17b46
orl $0x20000, %ebp          # imm = 0x20000
movl %ebp, 0x4(%rbx)
movl 0x4(%rbx), %eax
movl %eax, %ecx
notl %ecx
testl $0x280, %ecx            # imm = 0x280
jne 0x17b61
andl $0xfffffe7f, %eax       # imm = 0xFFFFFE7F
orl $0x100, %eax            # imm = 0x100
jmp 0x17b6c
btl $0x8, %eax
jb 0x17b6f
andl $0xfffffcff, %eax       # imm = 0xFFFFFCFF
movl %eax, 0x4(%rbx)
testb $0x1, 0x5(%rbx)
je 0x17b7d
movq %rbx, %rdi
callq 0x18129
testb $0x3, 0x4(%rbx)
je 0x17b8d
xorps %xmm0, %xmm0
movups %xmm0, 0xc150(%rbx)
xorl %r14d, %r14d
movq %r14, 0x1e5f8(%rbx)
movw %r14w, 0x1e59a(%rbx)
movl %r14d, 0xbf40(%rbx)
movl %r14d, 0xc168(%rbx)
movq %r14, 0x1e5e8(%rbx)
movq %rbx, %rdi
callq 0x1825f
movq %rbx, %rdi
callq 0x182ba
movw %r14w, 0x1e5f0(%rbx)
movq 0xc088(%rbx), %rax
testq %rax, %rax
je 0x17bf2
movl 0x4(%rbx), %ecx
andl $0x3, %ecx
cmpl $0x2, %ecx
jne 0x17bf2
movq %rbx, %rdi
callq *%rax
movl %eax, 0x1f274(%rbx)
testl %eax, %eax
jne 0x17bfc
xorl %eax, %eax
jmp 0x17bfc
movl 0x1f274(%rbx), %eax
popq %rbx
popq %r14
popq %rbp
retq