// File: /workspace/github_c_makefile_star2_O0/hkshenSmart[P]ONVIF-discovery_cs/stdsoap2.c
// Function: soap_end_send
SOAP_FMAC2
soap_end_send(struct soap *soap)
{
#ifndef WITH_LEANER
  int err;
  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 (!(err = soap_putdime(soap)))
    err = soap_putmime(soap);
  soap->mime.list = NULL;
  soap->mime.first = NULL;
  soap->mime.last = NULL;
  soap->dime.list = NULL;
  soap->dime.first = NULL;
  soap->dime.last = NULL;
  if (err)
    return err;
#endif
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send mode=0x%x\n", soap->mode));
  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, SOAP_SHUT_WR); /* Send TCP FIN */
#else
  if (soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP))
    soap->fshutdownsocket(soap, soap->socket, SOAP_SHUT_WR); /* Send TCP FIN */
#endif
#endif
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send phase\n"));
  soap->omode &= ~SOAP_SEC_WSUID;
  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, 0x1f2d0(%rax)
je 0x25814
movq -0x10(%rbp), %rax
movq 0x1f2d8(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x1f2e0(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x1f2d0(%rax), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1f2d8(%rax)
movq -0x10(%rbp), %rax
movq 0x1f2d0(%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x1f2d0(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1f2e0(%rax)
movq -0x10(%rbp), %rdi
callq 0x25b40
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jne 0x25831
movq -0x10(%rbp), %rdi
callq 0x25f60
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x1f2f8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1f300(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1f308(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1f2d0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1f2d8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1f2e0(%rax)
cmpl $0x0, -0x14(%rbp)
je 0x2589c
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x25b2d
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x25afa
movq -0x10(%rbp), %rdi
callq 0x16dd0
cmpl $0x0, %eax
je 0x258cf
movq -0x10(%rbp), %rax
movl 0x1f274(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x25b2d
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x25aaa
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x259fc
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0x7d0, 0x1f270(%rax)   # imm = 0x7D0
jl 0x2597a
movq -0x10(%rbp), %rax
movq 0xbf88(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x1e608, %rsi          # imm = 0x1E608
movq -0x10(%rbp), %rdx
addq $0x1ee08, %rdx          # imm = 0x1EE08
movq -0x10(%rbp), %rcx
movl 0x1f228(%rcx), %ecx
movq -0x10(%rbp), %r8
addq $0x1ea08, %r8           # imm = 0x1EA08
movq -0x10(%rbp), %r9
movq 0x1f208(%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, 0x1f274(%rax)
jmp 0x259c2
movq -0x10(%rbp), %rax
cmpl $0x3e8, 0x1f270(%rax)   # imm = 0x3E8
je 0x259c0
movq -0x10(%rbp), %rax
movq 0xbfc8(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl 0x1f270(%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, 0x1f274(%rax)
jmp 0x259c2
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1f274(%rax)
jne 0x259dd
movq -0x10(%rbp), %rdi
callq 0x16dd0
cmpl $0x0, %eax
je 0x259ef
movq -0x10(%rbp), %rax
movl 0x1f274(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x25b2d
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 0x1bfa0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x25a9b
movq -0x10(%rbp), %rax
movq 0xc028(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c0d0
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rax, %rdx
movq -0x28(%rbp), %rax
callq *%rax
movq -0x10(%rbp), %rcx
movl %eax, 0x1f274(%rcx)
cmpl $0x0, %eax
je 0x25a83
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c100
movq -0x10(%rbp), %rax
movl 0x1f274(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x25b2d
jmp 0x25a85
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c040
movq %rax, -0x20(%rbp)
jmp 0x25a0d
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c100
jmp 0x25af8
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x3, %eax
jne 0x25af6
movq -0x10(%rbp), %rax
movq 0xc028(%rax), %rax
movq -0x10(%rbp), %rdi
leaq 0x13d23(%rip), %rsi     # 0x397f2
movl $0x7, %edx
callq *%rax
movq -0x10(%rbp), %rcx
movl %eax, 0x1f274(%rcx)
cmpl $0x0, %eax
je 0x25af4
movq -0x10(%rbp), %rax
movl 0x1f274(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x25b2d
jmp 0x25af6
jmp 0x25af8
jmp 0x25afa
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xc170(%rax)
movq -0x10(%rbp), %rax
movw $0x9, 0x1e5f0(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)