// File: /workspace/github_cpp_makefile_star2_O3/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 0x5b96
movq %rdx, %r14
cmpw $0x0, (%rdx)
je 0x5bb5
movq %rsi, %r15
cmpl $0x0, 0x4(%rsi)
je 0x5bd4
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 0x5a4c
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 0x5a26
jmp 0x5a50
movb $0x0, 0x20(%rbx)
movzwl (%r15), %edi
movl 0x4(%r15), %esi
movzbl %bpl, %ebp
movl %ebp, %edx
callq 0x7c14
movl %eax, (%r13)
cmpl $-0x1, %eax
je 0x5b20
movzwl (%r14), %edi
movl 0x4(%r15), %esi
movl %ebp, %edx
callq 0x7c14
movl %eax, 0x14(%rbx)
cmpl $-0x1, %eax
je 0x5b20
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
movl 0x4(%r14), %esi
testl %esi, %esi
je 0x5b8a
movzwl (%r15), %edi
movl %ebp, %edx
callq 0x7c14
movl %eax, 0x18(%rbx)
cmpl $-0x1, %eax
je 0x5ade
movl 0x4(%r14), %esi
movl $0xffffffff, 0x1c(%rbx) # imm = 0xFFFFFFFF
movb $0x1, %r15b
testl %esi, %esi
je 0x5b78
movzwl (%r14), %edi
movl %ebp, %edx
callq 0x7c14
movl %eax, 0x1c(%rbx)
cmpl $-0x1, %eax
jne 0x5b78
movq 0x74d3(%rip), %r15      # 0xcfb8
leaq 0x42ee(%rip), %rsi      # 0x9dda
movl $0xb, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movq %r14, %rsi
callq 0x3dbb
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
jmp 0x5b60
movq 0x7491(%rip), %r14      # 0xcfb8
leaq 0x42ac(%rip), %rsi      # 0x9dda
movl $0xb, %edx
movq %r14, %rdi
callq 0x21f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x3dbb
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x5bf3
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, 0x1c(%rbx) # imm = 0xFFFFFFFF
movb $0x1, %r15b
jmp 0x5b78
leaq 0x41ad(%rip), %rdi      # 0x9d4a
leaq 0x3ba9(%rip), %rsi      # 0x974d
leaq 0x41b0(%rip), %rcx      # 0x9d5b
movl $0x4e3, %edx            # imm = 0x4E3
callq 0x2120
leaq 0x41fc(%rip), %rdi      # 0x9db8
leaq 0x3b8a(%rip), %rsi      # 0x974d
leaq 0x4191(%rip), %rcx      # 0x9d5b
movl $0x4e4, %edx            # imm = 0x4E4
callq 0x2120
leaq 0x41ee(%rip), %rdi      # 0x9dc9
leaq 0x3b6b(%rip), %rsi      # 0x974d
leaq 0x4172(%rip), %rcx      # 0x9d5b
movl $0x4e5, %edx            # imm = 0x4E5
callq 0x2120