// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_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->fprepareinitsend(soap);   
#endif
  return SOAP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5ad20
movq -0x10(%rbp), %rax
movl $0x0, 0x19214(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x88, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x5b158
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x40, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpq $0x10000, 0x6110(%rax) # imm = 0x10000
jbe 0x5b156
movq -0x10(%rbp), %rax
movl $0x1b, 0x19214(%rax)
movl $0x1b, -0x4(%rbp)
jmp 0x5b3b3
jmp 0x5b158
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x5b1be
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x60d4(%rax)
je 0x5b1be
movq -0x10(%rbp), %rax
cmpq $0x0, 0x6110(%rax)
jne 0x5b1a0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x5b1a0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x5b1af
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x5b1bc
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x4(%rax)
jmp 0x5b1be
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $-0x9, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x5b1fd
movq -0x10(%rbp), %rdi
callq 0x539b0
cmpq $0x0, %rax
jne 0x5b1fb
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5b3b3
jmp 0x5b1fd
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x5b219
movq -0x10(%rbp), %rax
movw $0x0, 0x191cc(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x5b245
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
jne 0x5b245
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x20000, %ecx          # imm = 0x20000
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x5b289
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5b289
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
movl %ecx, 0x4(%rax)
jmp 0x5b2ac
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x5b2aa
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0xfffffdff, %ecx       # imm = 0xFFFFFDFF
movl %ecx, 0x4(%rax)
jmp 0x5b2ac
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x5b2c6
movq -0x10(%rbp), %rdi
callq 0x5ad80
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x5b2f3
movq -0x10(%rbp), %rax
movq $0x0, 0x60f0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x60f8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x18598(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x1858e(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x1858c(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x1853a(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x1858a(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x18588(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x5f40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x6108(%rax)
movq -0x10(%rbp), %rdi
callq 0x5aed0
movq -0x10(%rbp), %rdi
callq 0x5af90
movq -0x10(%rbp), %rax
movw $0x0, 0x18590(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x6040(%rax)
je 0x5b3ac
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x5b3ac
movq -0x10(%rbp), %rax
movq 0x6040(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)