// File: /workspace/github_cpp_makefile_star2_O2/Distrotech[P]stund/stun.cxx
// Function: stunInitServer(StunServerInfo&, StunAddress4 const&, StunAddress4 const&, int, bool)
bool
stunInitServer(StunServerInfo& info, const StunAddress4& myAddr,
               const StunAddress4& altAddr, int startMediaPort, bool verbose )
{
   assert( myAddr.port != 0 );
   assert( altAddr.port!= 0 );
   assert( myAddr.addr  != 0 );
   //assert( altAddr.addr != 0 );
	
   info.myAddr = myAddr;
   info.altAddr = altAddr;
	
   info.myFd = INVALID_SOCKET;
   info.altPortFd = INVALID_SOCKET;
   info.altIpFd = INVALID_SOCKET;
   info.altIpPortFd = INVALID_SOCKET;

   memset(info.relays, 0, sizeof(info.relays));
   if (startMediaPort > 0)
   {
      info.relay = true;

      for (int i=0; i<MAX_MEDIA_RELAYS; ++i)
      {
         StunMediaRelay* relay = &info.relays[i];
         relay->relayPort = startMediaPort+i;
         relay->fd = 0;
         relay->expireTime = 0;
      }
   }
   else
   {
      info.relay = false;
   }
   
   if ((info.myFd = openPort(myAddr.port, myAddr.addr,verbose)) == INVALID_SOCKET)
   {
      clog << "Can't open " << myAddr << endl;
      stunStopServer(info);

      return false;
   }
   //if (verbose) clog << "Opened " << myAddr.addr << ":" << myAddr.port << " --> " << info.myFd << endl;

   if ((info.altPortFd = openPort(altAddr.port,myAddr.addr,verbose)) == INVALID_SOCKET)
   {
      clog << "Can't open " << myAddr << endl;
      stunStopServer(info);
      return false;
   }
   //if (verbose) clog << "Opened " << myAddr.addr << ":" << altAddr.port << " --> " << info.altPortFd << endl;
   
   
   info.altIpFd = INVALID_SOCKET;
   if (  altAddr.addr != 0 )
   {
      if ((info.altIpFd = openPort( myAddr.port, altAddr.addr,verbose)) == INVALID_SOCKET)
      {
         clog << "Can't open " << altAddr << endl;
         stunStopServer(info);
         return false;
      }
      //if (verbose) clog << "Opened " << altAddr.addr << ":" << myAddr.port << " --> " << info.altIpFd << endl;;
   }
   
   info.altIpPortFd = INVALID_SOCKET;
   if (  altAddr.addr != 0 )
   {  if ((info.altIpPortFd = openPort(altAddr.port, altAddr.addr,verbose)) == INVALID_SOCKET)
      {
         clog << "Can't open " << altAddr << endl;
         stunStopServer(info);
         return false;
      }
      //if (verbose) clog << "Opened " << altAddr.addr << ":" << altAddr.port << " --> " << info.altIpPortFd << endl;;
   }
   
   return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpw $0x0, (%rsi)
je 0x4cc3
movq %rdx, %r14
cmpw $0x0, (%rdx)
je 0x4ce2
movq %rsi, %r15
cmpl $0x0, 0x4(%rsi)
je 0x4d01
movl %r8d, %ebp
movl %ecx, %r12d
movq %rdi, %rbx
movq (%r15), %rax
movq %rax, (%rdi)
movq (%r14), %rax
movq %rax, 0x8(%rdi)
leaq 0x10(%rdi), %r13
addq $0x28, %rdi
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x10(%rbx)
movl $0x2ee0, %edx           # imm = 0x2EE0
xorl %esi, %esi
callq 0x2110
testl %r12d, %r12d
jle 0x4bce
movb $0x1, 0x20(%rbx)
pushq $0x38
popq %rax
cmpq $0x2f18, %rax           # imm = 0x2F18
je 0x4bd2
movl %r12d, -0x10(%rbx,%rax)
andl $0x0, -0xc(%rbx,%rax)
andq $0x0, (%rbx,%rax)
incl %r12d
addq $0x18, %rax
jmp 0x4bae
movb $0x0, 0x20(%rbx)
movzwl (%r15), %edi
movl 0x4(%r15), %esi
movzbl %bpl, %ebp
movl %ebp, %edx
callq 0x67f4
movl %eax, (%r13)
cmpl $-0x1, %eax
je 0x4c74
movzwl (%r14), %edi
movl 0x4(%r15), %esi
movl %ebp, %edx
callq 0x67f4
movl %eax, 0x14(%rbx)
cmpl $-0x1, %eax
je 0x4c74
orl $-0x1, 0x18(%rbx)
movl 0x4(%r14), %esi
testl %esi, %esi
je 0x4cba
movzwl (%r15), %edi
movl %ebp, %edx
callq 0x67f4
movl %eax, 0x18(%rbx)
cmpl $-0x1, %eax
je 0x4c4e
movl 0x4(%r14), %esi
orl $-0x1, 0x1c(%rbx)
movb $0x1, %r15b
testl %esi, %esi
je 0x4ca8
movzwl (%r14), %edi
movl %ebp, %edx
callq 0x67f4
movl %eax, 0x1c(%rbx)
cmpl $-0x1, %eax
jne 0x4ca8
movq 0x6363(%rip), %rdi      # 0xafb8
leaq 0x317e(%rip), %rsi      # 0x7dda
callq 0x21d0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x3732
movq %r15, %rdi
jmp 0x4c98
movq 0x633d(%rip), %rdi      # 0xafb8
leaq 0x3158(%rip), %rsi      # 0x7dda
callq 0x21d0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x3732
movq %r14, %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x4d20
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
orl $-0x1, 0x1c(%rbx)
movb $0x1, %r15b
jmp 0x4ca8
leaq 0x3080(%rip), %rdi      # 0x7d4a
leaq 0x2a7c(%rip), %rsi      # 0x774d
leaq 0x3083(%rip), %rcx      # 0x7d5b
movl $0x4e3, %edx            # imm = 0x4E3
callq 0x2120
leaq 0x30cf(%rip), %rdi      # 0x7db8
leaq 0x2a5d(%rip), %rsi      # 0x774d
leaq 0x3064(%rip), %rcx      # 0x7d5b
movl $0x4e4, %edx            # imm = 0x4E4
callq 0x2120
leaq 0x30c1(%rip), %rdi      # 0x7dc9
leaq 0x2a3e(%rip), %rsi      # 0x774d
leaq 0x3045(%rip), %rcx      # 0x7d5b
movl $0x4e5, %edx            # imm = 0x4E5
callq 0x2120