// File: /workspace/github_cpp_makefile_star2_O1/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 0x5aab
movq %rdx, %r14
cmpw $0x0, (%rdx)
je 0x5aca
movq %rsi, %r15
cmpl $0x0, 0x4(%rsi)
je 0x5ae9
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 0x59be
movb $0x1, 0x20(%rbx)
movl $0x38, %eax
movl %r12d, -0x10(%rbx,%rax)
movl $0x0, -0xc(%rbx,%rax)
movq $0x0, (%rbx,%rax)
incl %r12d
addq $0x18, %rax
cmpq $0x2f18, %rax           # imm = 0x2F18
jne 0x5998
jmp 0x59c2
movb $0x0, 0x20(%rbx)
movzwl (%r15), %edi
movl 0x4(%r15), %esi
movzbl %bpl, %ebp
movl %ebp, %edx
callq 0x7c10
movl %eax, (%r13)
cmpl $-0x1, %eax
je 0x5a3e
movzwl (%r14), %edi
movl 0x4(%r15), %esi
movl %ebp, %edx
callq 0x7c10
movl %eax, 0x14(%rbx)
cmpl $-0x1, %eax
je 0x5a3e
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
movl 0x4(%r14), %esi
testl %esi, %esi
je 0x5a17
movzwl (%r15), %edi
movl %ebp, %edx
callq 0x7c10
movl %eax, 0x18(%rbx)
cmpl $-0x1, %eax
je 0x5a41
movl $0xffffffff, 0x1c(%rbx) # imm = 0xFFFFFFFF
movl 0x4(%r14), %esi
movb $0x1, %r15b
testl %esi, %esi
je 0x5a99
movzwl (%r14), %edi
movl %ebp, %edx
callq 0x7c10
movl %eax, 0x1c(%rbx)
cmpl $-0x1, %eax
jne 0x5a99
jmp 0x5a41
movq %r15, %r14
movq 0x7570(%rip), %r15      # 0xcfb8
leaq 0x4393(%rip), %rsi      # 0x9de2
movl $0xb, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movq %r14, %rsi
callq 0x3f5b
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x5b08
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42a0(%rip), %rdi      # 0x9d52
leaq 0x3c9c(%rip), %rsi      # 0x9755
leaq 0x42a3(%rip), %rcx      # 0x9d63
movl $0x4e3, %edx            # imm = 0x4E3
callq 0x2120
leaq 0x42ef(%rip), %rdi      # 0x9dc0
leaq 0x3c7d(%rip), %rsi      # 0x9755
leaq 0x4284(%rip), %rcx      # 0x9d63
movl $0x4e4, %edx            # imm = 0x4E4
callq 0x2120
leaq 0x42e1(%rip), %rdi      # 0x9dd1
leaq 0x3c5e(%rip), %rsi      # 0x9755
leaq 0x4265(%rip), %rcx      # 0x9d63
movl $0x4e5, %edx            # imm = 0x4E5
callq 0x2120