// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_accept
SOAP_FMAC2
soap_accept(struct soap *soap)
{ int n = (int)sizeof(soap->peer);
#ifndef WITH_LEAN
  int len = SOAP_BUFLEN;
  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 (;;)
    { 
#ifndef WITH_LEAN
      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->send_timeout || soap->recv_timeout)
        SOAP_SOCKNONBLOCK(soap->master)
      else
        SOAP_SOCKBLOCK(soap->master)
#endif
      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);
        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 $0x90, %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, 0x19214(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x59c4d
movq -0x10(%rbp), %rax
movl 0x60d0(%rax), %eax
movq -0x10(%rbp), %rcx
movl %eax, 0x60d4(%rcx)
movl %eax, -0x4(%rbp)
jmp 0x5a2ff
movq -0x10(%rbp), %rdi
addq $0x1b324, %rdi          # imm = 0x1B324
xorl %esi, %esi
movl $0x10, %edx
callq 0x3190
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x60d4(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movl $0x0, 0x19218(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x191cc(%rax)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x60d0(%rax)
je 0x5a2bb
jmp 0x59ca0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
jne 0x59cc2
movq -0x10(%rbp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x59cc2
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x59db3
jmp 0x59cc4
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x60d0(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x59cef
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x59cf9
movl $0x3c, %eax
movl %eax, -0x3c(%rbp)
jmp 0x59cf9
movl -0x30(%rbp), %esi
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %ecx
movl $0x7, %edx
callq 0x59760
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x59d1b
jmp 0x59db1
cmpl $0x0, -0x24(%rbp)
jne 0x59d53
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x59d53
movq -0x10(%rbp), %rdi
leaq 0x20a2a(%rip), %rsi     # 0x7a760
leaq 0x20a2b(%rip), %rdx     # 0x7a768
movl $0x1c, %ecx
callq 0x59640
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
cmpl $0x0, -0x24(%rbp)
jge 0x59dac
movq -0x10(%rbp), %rax
movl 0x1921c(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
je 0x59daa
movq -0x10(%rbp), %rdi
callq 0x55cf0
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x48(%rbp), %rdi
movq %rax, %rsi
leaq 0x209d4(%rip), %rdx     # 0x7a768
movl $0x1c, %ecx
callq 0x5a310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
jmp 0x59dac
jmp 0x59cc4
jmp 0x59db3
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
jne 0x59dd1
movq -0x10(%rbp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x59dd1
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x59e0d
movq -0x10(%rbp), %rax
movl 0x60d0(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movl 0x60d0(%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 0x59e47
movq -0x10(%rbp), %rax
movl 0x60d0(%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl 0x60d0(%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 0x5ff0(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl 0x60d0(%rcx), %esi
movq -0x10(%rbp), %rdx
addq $0x1b324, %rdx          # imm = 0x1B324
leaq -0x14(%rbp), %rcx
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x60d4(%rax)
movslq -0x14(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b338(%rax)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x60d4(%rax)
je 0x5a246
movq -0x10(%rbp), %rax
movl 0x1b328(%rax), %edi
callq 0x3390
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x191c0(%rax)
movq -0x10(%rbp), %rax
movzwl 0x1b326(%rax), %edi
callq 0x32e0
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x191c8(%rax)
movq -0x10(%rbp), %rax
cmpl $0xd, 0x6c(%rax)
jne 0x59f84
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 0x60d4(%rax), %edi
movl $0x1, %esi
movl $0xd, %edx
leaq -0x2c(%rbp), %rcx
movl $0x8, %r8d
callq 0x30b0
cmpl $0x0, %eax
je 0x59f7f
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x58(%rbp), %rdi
movq %rax, %rsi
leaq 0x20827(%rip), %rdx     # 0x7a787
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
jmp 0x5a009
movq -0x10(%rbp), %rax
cmpl $0x0, 0x6c(%rax)
je 0x5a007
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movq -0x10(%rbp), %rax
movl 0x6c(%rax), %edx
movl $0x1, %esi
leaq -0x1c(%rbp), %rcx
movl $0x4, %r8d
callq 0x30b0
cmpl $0x0, %eax
je 0x5a007
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
leaq 0x207cc(%rip), %rdx     # 0x7a7b4
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
jmp 0x5a009
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
orl 0xc(%rcx), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x5a096
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movl $0x1, %esi
movl $0x9, %edx
leaq -0x1c(%rbp), %rcx
movl $0x4, %r8d
callq 0x30b0
cmpl $0x0, %eax
je 0x5a096
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x68(%rbp), %rdi
movq %rax, %rsi
leaq 0x20760(%rip), %rdx     # 0x7a7d7
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movl $0x1, %esi
movl $0x7, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x30b0
cmpl $0x0, %eax
je 0x5a10d
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
leaq 0x20719(%rip), %rdx     # 0x7a807
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movl $0x1, %esi
movl $0x8, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x30b0
cmpl $0x0, %eax
je 0x5a184
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
leaq 0x206cf(%rip), %rdx     # 0x7a834
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x5a20a
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %edi
movl $0x6, %esi
movl $0x1, %edx
leaq -0x1c(%rbp), %rcx
movl $0x4, %r8d
callq 0x30b0
cmpl $0x0, %eax
je 0x5a20a
callq 0x3060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x80(%rbp), %rdi
movq %rax, %rsi
leaq 0x20676(%rip), %rdx     # 0x7a861
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
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, 0x191cc(%rax)
movq -0x10(%rbp), %rax
movl 0x60d4(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5a2ff
callq 0x3060
movl (%rax), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x5a2b6
cmpl $0x4, -0x20(%rbp)
je 0x5a2b6
cmpl $0xb, -0x20(%rbp)
je 0x5a2b6
cmpl $0xb, -0x20(%rbp)
je 0x5a2b6
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x88(%rbp), %rdi
movq %rax, %rsi
leaq 0x204ce(%rip), %rdx     # 0x7a768
movl $0x1c, %ecx
callq 0x59640
movq -0x10(%rbp), %rdi
callq 0x55cf0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a2ff
jmp 0x59ca0
movq -0x10(%rbp), %rax
movl $0x0, 0x1921c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0x596a0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
leaq 0x205a2(%rip), %rdx     # 0x7a890
movl $0x1c, %ecx
callq 0x59640
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)