// File: /workspace/github_c_makefile_star2_O3/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 0x17733
movq (%rdi), %r14
callq 0x3030
movq %r14, %rdi
testq %r14, %r14
jne 0x17723
movq $0x0, 0x88(%rbx)
movl $0x0, 0x1f274(%rbx)
movl 0xc(%rbx), %eax
movl $0x88, %r14d
andl 0x4(%rbx), %r14d
orl %eax, %r14d
testb $0x4, %al
je 0x17785
orl $0x40, %r14d
movl %r14d, 0x4(%rbx)
cmpq $0x10001, 0xc170(%rbx) # imm = 0x10001
jb 0x17785
movl $0x1b, 0x1f274(%rbx)
movl $0x1b, %eax
jmp 0x178db
testb $0x3, %r14b
je 0x178a6
movl %r14d, %ebp
andl $-0x9, %ebp
movl %ebp, 0x4(%rbx)
movl %r14d, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x177ce
movl $0x18, %edi
callq 0x3240
testq %rax, %rax
je 0x178cc
movq 0x90(%rbx), %rcx
movq %rcx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq %rax, 0x90(%rbx)
testb $0x10, %r14b
jne 0x177dd
movw $0x0, 0x1f22c(%rbx)
btl $0x12, %r14d
jb 0x177f4
cmpq $0x0, 0x38(%rbx)
jne 0x177f4
orl $0x20000, %ebp          # imm = 0x20000
movl %ebp, 0x4(%rbx)
movl %ebp, %eax
notl %eax
testl $0x280, %eax            # imm = 0x280
jne 0x1780d
andl $0xfffffe7f, %ebp       # imm = 0xFFFFFE7F
orl $0x100, %ebp            # imm = 0x100
jmp 0x17819
btl $0x8, %ebp
jb 0x1781c
andl $0xfffffcff, %ebp       # imm = 0xFFFFFCFF
movl %ebp, 0x4(%rbx)
btl $0x8, %ebp
jae 0x1782d
movq %rbx, %rdi
callq 0x17de2
movl 0x4(%rbx), %ebp
testb $0x3, %bpl
je 0x1783d
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 0x17f1a
movq %rbx, %rdi
callq 0x17f7b
movw %r14w, 0x1e5f0(%rbx)
movq 0xc088(%rbx), %rax
testq %rax, %rax
je 0x178a2
movl 0x4(%rbx), %ecx
andl $0x3, %ecx
cmpl $0x2, %ecx
jne 0x178a2
movq %rbx, %rdi
callq *%rax
movl %eax, 0x1f274(%rbx)
testl %eax, %eax
jne 0x178db
xorl %eax, %eax
jmp 0x178db
cmpl $-0x1, 0xc134(%rbx)
je 0x1778f
testb $0x48, %r14b
jne 0x178e0
cmpq $0x0, 0xc170(%rbx)
jne 0x178e0
orl $0x2, %r14d
jmp 0x1778f
movl $0x14, 0x1f274(%rbx)
movl $0x14, %eax
popq %rbx
popq %r14
popq %rbp
retq
orl $0x1, %r14d
jmp 0x1778f