// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_end_send
SOAP_FMAC2
soap_end_send(struct soap *soap)
{ 
#ifndef WITH_LEANER
  if (soap->dime.list)
  { /* SOAP body referenced attachments must appear first */
    soap->dime.last->next = soap->dime.first;
    soap->dime.first = soap->dime.list->next;
    soap->dime.list->next = NULL;
    soap->dime.last = soap->dime.list;
  }
  if (soap_putdime(soap) || soap_putmime(soap))
    return soap->error;
  soap->mime.list = NULL;
  soap->mime.first = NULL;
  soap->mime.last = NULL;
  soap->dime.list = NULL;
  soap->dime.first = NULL;
  soap->dime.last = NULL;
#endif
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send\n"));
  if (soap->mode & SOAP_IO) /* need to flush the remaining data in buffer */
  { if (soap_flush(soap))
#ifdef WITH_ZLIB
    { if (soap->mode & SOAP_ENC_ZLIB && soap->zlib_state == SOAP_ZLIB_DEFLATE)
      { soap->zlib_state = SOAP_ZLIB_NONE;
        deflateEnd(soap->d_stream);
      }
      return soap->error;
    }
#else
      return soap->error;
#endif
#ifdef WITH_ZLIB
    if (soap->mode & SOAP_ENC_ZLIB)
    { int r;
      soap->d_stream->avail_in = 0;
      do
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n"));
        r = deflate(soap->d_stream, Z_FINISH);
        if (soap->d_stream->avail_out != SOAP_BUFLEN)
        { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream->avail_out))
          { soap->zlib_state = SOAP_ZLIB_NONE;
            deflateEnd(soap->d_stream);
            return soap->error;
          }
          soap->d_stream->next_out = (Byte*)soap->z_buf;
          soap->d_stream->avail_out = SOAP_BUFLEN;
        }
      } while (r == Z_OK);
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated total %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out));
      soap->z_ratio_out = (float)soap->d_stream->total_out / (float)soap->d_stream->total_in;
      soap->mode &= ~SOAP_ENC_ZLIB;
      soap->zlib_state = SOAP_ZLIB_NONE;
      if (deflateEnd(soap->d_stream) != Z_OK || r != Z_STREAM_END)
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
        return soap->error = SOAP_ZLIB_ERROR;
      }
#ifdef WITH_GZIP
      if (soap->zlib_out != SOAP_ZLIB_DEFLATE)
      { soap->z_buf[0] = soap->z_crc & 0xFF;
        soap->z_buf[1] = (soap->z_crc >> 8) & 0xFF;
        soap->z_buf[2] = (soap->z_crc >> 16) & 0xFF;
        soap->z_buf[3] = (soap->z_crc >> 24) & 0xFF;
        soap->z_buf[4] = soap->d_stream->total_in & 0xFF;
        soap->z_buf[5] = (soap->d_stream->total_in >> 8) & 0xFF;
        soap->z_buf[6] = (soap->d_stream->total_in >> 16) & 0xFF;
        soap->z_buf[7] = (soap->d_stream->total_in >> 24) & 0xFF;
        if (soap_flush_raw(soap, soap->z_buf, 8))
          return soap->error;
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip crc32=%lu\n", (unsigned long)soap->z_crc));
      }
#endif
    }
#endif
    if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
    { char *p;
#ifndef WITH_NOHTTP
      if (!(soap->mode & SOAP_ENC_XML))
      { soap->mode--;
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size));
        if (soap->status >= SOAP_POST)
          soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size);
        else if (soap->status != SOAP_STOP)
          soap->error = soap->fresponse(soap, soap->status, soap->blist->size);
        if (soap->error || soap_flush(soap))
          return soap->error;
        soap->mode++;
      }
#endif
      for (p = soap_first_block(soap, NULL); p; p = soap_next_block(soap, NULL))
      { DBGMSG(SENT, p, soap_block_size(soap, NULL));
        if ((soap->error = soap->fsend(soap, p, soap_block_size(soap, NULL))))
        { soap_end_block(soap, NULL);
          return soap->error;
        }
      }
      soap_end_block(soap, NULL);
    }
#ifndef WITH_LEANER
    else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
    { DBGMSG(SENT, "\r\n0\r\n\r\n", 7);
      if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7)))
        return soap->error;
    }
#endif
  }
#ifdef WITH_TCPFIN
#ifdef WITH_OPENSSL
  if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP))
    soap->fshutdownsocket(soap, soap->socket, 1); /* Send TCP FIN */
#else
  if (soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP))
    soap->fshutdownsocket(soap, soap->socket, 1); /* Send TCP FIN */
#endif
#endif
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send phase\n"));
  soap->omode &= ~SOAP_XML_SEC;
  soap->count = 0;
  soap->part = SOAP_END;
  return SOAP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x19270(%rax)
je 0x5ce54
movq -0x10(%rbp), %rax
movq 0x19278(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x19280(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x19270(%rax), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19278(%rax)
movq -0x10(%rbp), %rax
movq 0x19270(%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x19270(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19280(%rax)
movq -0x10(%rbp), %rdi
callq 0x5d180
cmpl $0x0, %eax
jne 0x5ce70
movq -0x10(%rbp), %rdi
callq 0x5d5a0
cmpl $0x0, %eax
je 0x5ce82
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d16d
movq -0x10(%rbp), %rax
movq $0x0, 0x19298(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x192a0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x192a8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19270(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19278(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19280(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x5d13a
movq -0x10(%rbp), %rdi
callq 0x4f060
cmpl $0x0, %eax
je 0x5cf0f
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d16d
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x5d0ea
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x5d03c
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0x7d0, 0x19210(%rax)   # imm = 0x7D0
jl 0x5cfba
movq -0x10(%rbp), %rax
movq 0x5f68(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x185a8, %rsi          # imm = 0x185A8
movq -0x10(%rbp), %rdx
addq $0x18da8, %rdx          # imm = 0x18DA8
movq -0x10(%rbp), %rcx
movl 0x191c8(%rcx), %ecx
movq -0x10(%rbp), %r8
addq $0x189a8, %r8           # imm = 0x189A8
movq -0x10(%rbp), %r9
movq 0x191a8(%r9), %r9
movq -0x10(%rbp), %r10
movq 0x90(%r10), %r10
movq 0x10(%r10), %r10
movq %r10, (%rsp)
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19214(%rax)
jmp 0x5d002
movq -0x10(%rbp), %rax
cmpl $0x3e8, 0x19210(%rax)   # imm = 0x3E8
je 0x5d000
movq -0x10(%rbp), %rax
movq 0x5fa0(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl 0x19210(%rcx), %esi
movq -0x10(%rbp), %rcx
movq 0x90(%rcx), %rcx
movq 0x10(%rcx), %rdx
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19214(%rax)
jmp 0x5d002
movq -0x10(%rbp), %rax
cmpl $0x0, 0x19214(%rax)
jne 0x5d01d
movq -0x10(%rbp), %rdi
callq 0x4f060
cmpl $0x0, %eax
je 0x5d02f
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d16d
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x53fe0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5d0db
movq -0x10(%rbp), %rax
movq 0x6000(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x54110
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq %rax, %rdx
movq -0x20(%rbp), %rax
callq *%rax
movq -0x10(%rbp), %rcx
movl %eax, 0x19214(%rcx)
cmpl $0x0, %eax
je 0x5d0c3
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x54140
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d16d
jmp 0x5d0c5
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x54080
movq %rax, -0x18(%rbp)
jmp 0x5d04d
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x54140
jmp 0x5d138
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x3, %eax
jne 0x5d136
movq -0x10(%rbp), %rax
movq 0x6000(%rax), %rax
movq -0x10(%rbp), %rdi
leaq 0x1d7ad(%rip), %rsi     # 0x7a8bc
movl $0x7, %edx
callq *%rax
movq -0x10(%rbp), %rcx
movl %eax, 0x19214(%rcx)
cmpl $0x0, %eax
je 0x5d134
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d16d
jmp 0x5d136
jmp 0x5d138
jmp 0x5d13a
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x6110(%rax)
movq -0x10(%rbp), %rax
movw $0x9, 0x18590(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)