// File: /workspace/github_c_makefile_star2_O0/hkshenSmart[P]ONVIF-discovery_cs/stdsoap2.c
// Function: soap_accept
SOAP_FMAC2
soap_accept(struct soap *soap)
{ int n = (int)sizeof(soap->peer);
#ifndef WITH_LEAN
#ifndef WITH_WIN32
  int len = SOAP_BUFLEN;
#else
  int len = SOAP_BUFLEN + 1; /* speeds up windows xfer */
#endif
  int set = 1;
#endif
  soap->error = SOAP_OK;
#ifndef WITH_LEAN
  if ((soap->omode & SOAP_IO_UDP))
    return soap->socket = soap->master;
#endif
  memset((void*)&soap->peer, 0, sizeof(soap->peer));
  soap->socket = SOAP_INVALID_SOCKET;
  soap->errmode = 0;
  soap->keep_alive = 0;
  if (soap_valid_socket(soap->master))
  { register int err;
    for (;;)
    { if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout)
      { for (;;)
        { register int r;
          r = tcp_select(soap, soap->master, SOAP_TCP_SELECT_ALL, soap->accept_timeout ? soap->accept_timeout : 60);
          if (r > 0)
            break;
          if (!r && soap->accept_timeout)
          { soap_set_receiver_error(soap, "Timeout", "accept failed in soap_accept()", SOAP_TCP_ERROR);
            return SOAP_INVALID_SOCKET;
          }
          if (r < 0)
          { r = soap->errnum;
            if (r != SOAP_EINTR)
            { soap_closesock(soap);
              soap_set_sender_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR);
              return SOAP_INVALID_SOCKET;
            }
          }
        }
      }
      if (soap->accept_timeout)
        SOAP_SOCKNONBLOCK(soap->master)
      else
        SOAP_SOCKBLOCK(soap->master)
      soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&soap->peer, &n);
      soap->peerlen = (size_t)n;
      if (soap_valid_socket(soap->socket))
      {
#ifdef WITH_IPV6
/* Use soap->host to store the numeric form of the remote host */
        getnameinfo((struct sockaddr*)&soap->peer, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);
        DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d from %s\n", soap->socket, soap->host));
        soap->ip = 0; /* info stored in soap->peer and soap->host */
        soap->port = 0; /* info stored in soap->peer and soap->host */
#else
        soap->ip = ntohl(soap->peer.sin_addr.s_addr);
        soap->port = (int)ntohs(soap->peer.sin_port); /* does not return port number on some systems */
        DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d at port %d from IP %d.%d.%d.%d\n", soap->socket, soap->port, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF));
#endif
#ifndef WITH_LEAN
        if (soap->accept_flags == SO_LINGER)
        { struct linger linger;
          memset((void*)&linger, 0, sizeof(linger));
          linger.l_onoff = 1;
          linger.l_linger = soap->linger_time;
          if (setsockopt(soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger)))
          { soap->errnum = soap_socket_errno(soap->socket);
            soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR);
            soap_closesock(soap);
            return SOAP_INVALID_SOCKET;
          }
        }
        else if (soap->accept_flags && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags, (char*)&set, sizeof(int)))
        { soap->errnum = soap_socket_errno(soap->socket);
          soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_accept()", SOAP_TCP_ERROR);
          soap_closesock(soap);
          return SOAP_INVALID_SOCKET;
        }
        if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int)))
        { soap->errnum = soap_socket_errno(soap->socket);
          soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR);
          soap_closesock(soap);
          return SOAP_INVALID_SOCKET;
        }
        if (setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
        { soap->errnum = soap_socket_errno(soap->socket);
          soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR);
          soap_closesock(soap);
          return SOAP_INVALID_SOCKET;
        }
        if (setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
        { soap->errnum = soap_socket_errno(soap->socket);
          soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR);
          soap_closesock(soap);
          return SOAP_INVALID_SOCKET;
        }
#ifdef TCP_NODELAY
        if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
        { soap->errnum = soap_socket_errno(soap->socket);
          soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR);
          soap_closesock(soap);
          return SOAP_INVALID_SOCKET;
        }
#endif
#endif
        soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0);
        if (soap->send_timeout || soap->recv_timeout)
          SOAP_SOCKNONBLOCK(soap->socket)
        else
          SOAP_SOCKBLOCK(soap->socket)
        return soap->socket;
      }
      err = soap_socket_errno(soap->socket);
      if (err != 0 && err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK)
      { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host));
        soap->errnum = err;
        soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR);
        soap_closesock(soap);
        return SOAP_INVALID_SOCKET;
      }
    }
  }
  else
  { soap->errnum = 0;
    soap_set_receiver_error(soap, tcp_error(soap), "no master socket in soap_accept()", SOAP_TCP_ERROR);
    return SOAP_INVALID_SOCKET;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x10, -0x14(%rbp)
movl $0x10000, -0x18(%rbp)   # imm = 0x10000
movl $0x1, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x1f274(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1e5bd
movq -0x10(%rbp), %rax
movl 0xc130(%rax), %eax
movq -0x10(%rbp), %rcx
movl %eax, 0xc134(%rcx)
movl %eax, -0x4(%rbp)
jmp 0x1ecf1
movq -0x10(%rbp), %rdi
addq $0x27384, %rdi          # imm = 0x27384
xorl %esi, %esi
movl $0x10, %edx
callq 0x3190
movq -0x10(%rbp), %rax
movl $0xffffffff, 0xc134(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movl $0x0, 0x1f278(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x1f22c(%rax)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0xc130(%rax)
je 0x1ecad
jmp 0x1e610
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
jne 0x1e632
movq -0x10(%rbp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x1e632
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x1e723
jmp 0x1e634
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0xc130(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x1e65f
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x1e669
movl $0x3c, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1e669
movl -0x30(%rbp), %esi
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %ecx
movl $0x7, %edx
callq 0x1e0d0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x1e68b
jmp 0x1e721
cmpl $0x0, -0x24(%rbp)
jne 0x1e6c3
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x1e6c3
movq -0x10(%rbp), %rdi
leaq 0x1afba(%rip), %rsi     # 0x39660
leaq 0x1afbb(%rip), %rdx     # 0x39668
movl $0x1c, %ecx
callq 0x1dd20
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
cmpl $0x0, -0x24(%rbp)
jge 0x1e71c
movq -0x10(%rbp), %rax
movl 0x1f27c(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
je 0x1e71a
movq -0x10(%rbp), %rdi
callq 0x1de40
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x48(%rbp), %rdi
movq %rax, %rsi
leaq 0x1af64(%rip), %rdx     # 0x39668
movl $0x1c, %ecx
callq 0x1ed00
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
jmp 0x1e71c
jmp 0x1e634
jmp 0x1e723
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x1e769
movq -0x10(%rbp), %rax
movl 0xc130(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movl 0xc130(%rax), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x30c0
movl -0x4c(%rbp), %edi
movl %eax, %edx
orl $0x800, %edx            # imm = 0x800
movl $0x4, %esi
movb $0x0, %al
callq 0x30c0
jmp 0x1e7a3
movq -0x10(%rbp), %rax
movl 0xc130(%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl 0xc130(%rax), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x30c0
movl -0x50(%rbp), %edi
movl %eax, %edx
andl $0xfffff7ff, %edx       # imm = 0xFFFFF7FF
movl $0x4, %esi
movb $0x0, %al
callq 0x30c0
movq -0x10(%rbp), %rax
movq 0xc018(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl 0xc130(%rcx), %esi
movq -0x10(%rbp), %rdx
addq $0x27384, %rdx          # imm = 0x27384
leaq -0x14(%rbp), %rcx
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc134(%rax)
movslq -0x14(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x27398(%rax)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0xc134(%rax)
je 0x1ec38
movq -0x10(%rbp), %rax
movl 0x27388(%rax), %edi
callq 0x3340
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x1f220(%rax)
movq -0x10(%rbp), %rax
movzwl 0x27386(%rax), %edi
callq 0x32a0
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f228(%rax)
movq -0x10(%rbp), %rax
cmpl $0xd, 0x6c(%rax)
jne 0x1e8e0
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x3190
movl $0x1, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x70(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x1, %esi
movl $0xd, %edx
leaq -0x2c(%rbp), %rcx
movl $0x8, %r8d
callq 0x30a0
cmpl $0x0, %eax
je 0x1e8db
callq 0x3050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x58(%rbp), %rdi
movq %rax, %rsi
leaq 0x1adcb(%rip), %rdx     # 0x39687
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
jmp 0x1e965
movq -0x10(%rbp), %rax
cmpl $0x0, 0x6c(%rax)
je 0x1e963
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movq -0x10(%rbp), %rax
movl 0x6c(%rax), %edx
movl $0x1, %esi
leaq -0x1c(%rbp), %rcx
movl $0x4, %r8d
callq 0x30a0
cmpl $0x0, %eax
je 0x1e963
callq 0x3050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x60(%rbp), %rdi
movq %rax, %rsi
leaq 0x1ad70(%rip), %rdx     # 0x396b4
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
jmp 0x1e965
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
orl 0xc(%rcx), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x1e9f2
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x1, %esi
movl $0x9, %edx
leaq -0x1c(%rbp), %rcx
movl $0x4, %r8d
callq 0x30a0
cmpl $0x0, %eax
je 0x1e9f2
callq 0x3050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x68(%rbp), %rdi
movq %rax, %rsi
leaq 0x1ad04(%rip), %rdx     # 0x396d7
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x1, %esi
movl $0x7, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x30a0
cmpl $0x0, %eax
je 0x1ea69
callq 0x3050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x70(%rbp), %rdi
movq %rax, %rsi
leaq 0x1acbd(%rip), %rdx     # 0x39707
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x1, %esi
movl $0x8, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x30a0
cmpl $0x0, %eax
je 0x1eae0
callq 0x3050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x78(%rbp), %rdi
movq %rax, %rsi
leaq 0x1ac73(%rip), %rdx     # 0x39734
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1eb66
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x6, %esi
movl $0x1, %edx
leaq -0x1c(%rbp), %rcx
movl $0x4, %r8d
callq 0x30a0
cmpl $0x0, %eax
je 0x1eb66
callq 0x3050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x80(%rbp), %rdi
movq %rax, %rsi
leaq 0x1ac1a(%rip), %rdx     # 0x39761
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
orl 0xc(%rcx), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x1f22c(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x1eba4
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x1ebe6
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x30c0
movl -0x84(%rbp), %edi
movl %eax, %edx
orl $0x800, %edx            # imm = 0x800
movl $0x4, %esi
movb $0x0, %al
callq 0x30c0
jmp 0x1ec26
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x30c0
movl -0x88(%rbp), %edi
movl %eax, %edx
andl $0xfffff7ff, %edx       # imm = 0xFFFFF7FF
movl $0x4, %esi
movb $0x0, %al
callq 0x30c0
movq -0x10(%rbp), %rax
movl 0xc134(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1ecf1
callq 0x3050
movl (%rax), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x1eca8
cmpl $0x4, -0x20(%rbp)
je 0x1eca8
cmpl $0xb, -0x20(%rbp)
je 0x1eca8
cmpl $0xb, -0x20(%rbp)
je 0x1eca8
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x90(%rbp), %rdi
movq %rax, %rsi
leaq 0x1a9dc(%rip), %rdx     # 0x39668
movl $0x1c, %ecx
callq 0x1dd20
movq -0x10(%rbp), %rdi
callq 0x1de40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ecf1
jmp 0x1e610
movq -0x10(%rbp), %rax
movl $0x0, 0x1f27c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dd80
movq -0x98(%rbp), %rdi
movq %rax, %rsi
leaq 0x1aab0(%rip), %rdx     # 0x39790
movl $0x1c, %ecx
callq 0x1dd20
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)