// File: Distrotech[P]stund/stun.cxx
// Function: stunServerProcess(StunServerInfo&, bool)
bool
stunServerProcess(StunServerInfo& info, bool verbose)
{
   char msg[STUN_MAX_MESSAGE_SIZE];
   int msgLen = sizeof(msg);
   	
   bool ok = false;
   bool recvAltIp =false;
   bool recvAltPort = false;
	
   fd_set fdSet; 
   Socket maxFd=0;

   FD_ZERO(&fdSet); 
   FD_SET(info.myFd,&fdSet); 
   if ( info.myFd >= maxFd ) maxFd=info.myFd+1;
   FD_SET(info.altPortFd,&fdSet); 
   if ( info.altPortFd >= maxFd ) maxFd=info.altPortFd+1;

   if ( info.altIpFd != INVALID_SOCKET )
   {
      FD_SET(info.altIpFd,&fdSet);
      if (info.altIpFd>=maxFd) maxFd=info.altIpFd+1;
   }
   if ( info.altIpPortFd != INVALID_SOCKET )
   {
      FD_SET(info.altIpPortFd,&fdSet);
      if (info.altIpPortFd>=maxFd) maxFd=info.altIpPortFd+1;
   }

   if (info.relay)
   {
      for (int i=0; i<MAX_MEDIA_RELAYS; ++i)
      {
         StunMediaRelay* relay = &info.relays[i];
         if (relay->fd)
         {
            FD_SET(relay->fd, &fdSet);
            if (relay->fd >= maxFd) 
			{
				maxFd=relay->fd+1;
			}
         }
      }
   }
   
   if ( info.altIpFd != INVALID_SOCKET )
   {
      FD_SET(info.altIpFd,&fdSet);
      if (info.altIpFd>=maxFd) maxFd=info.altIpFd+1;
   }
   if ( info.altIpPortFd != INVALID_SOCKET )
   {
      FD_SET(info.altIpPortFd,&fdSet);
      if (info.altIpPortFd>=maxFd) maxFd=info.altIpPortFd+1;
   }
   
   struct timeval tv;
   tv.tv_sec = 0;
   tv.tv_usec = 1000;
	
   int e = select( maxFd, &fdSet, NULL,NULL, &tv );
   if (e < 0)
   {
      int err = getErrno();
      clog << "Error on select: " << strerror(err) << endl;
   }
   else if (e >= 0)
   {
      StunAddress4 from;

      // do the media relaying
      if (info.relay)
      {
         time_t now = time(0);
         for (int i=0; i<MAX_MEDIA_RELAYS; ++i)
         {
            StunMediaRelay* relay = &info.relays[i];
            if (relay->fd)
            {
               if (FD_ISSET(relay->fd, &fdSet))
               {
                  char msg[MAX_RTP_MSG_SIZE];
                  int msgLen = sizeof(msg);
                  
                  StunAddress4 rtpFrom;
                  ok = getMessage( relay->fd, msg, &msgLen, &rtpFrom.addr, &rtpFrom.port ,verbose);
                  if (ok)
                  {
                     sendMessage(info.myFd, msg, msgLen, relay->destination.addr, relay->destination.port, verbose);
                     relay->expireTime = now + MEDIA_RELAY_TIMEOUT;
                     if ( verbose ) clog << "Relay packet on " 
                                         << relay->fd 
                                         << " from " << rtpFrom 
                                         << " -> " << relay->destination 
                                         << endl;
                  }
               }
               else if (now > relay->expireTime)
               {
                  closesocket(relay->fd);
                  relay->fd = 0;
               }
            }
         }
      }
      
     
      if (FD_ISSET(info.myFd,&fdSet))
      {
         if (verbose) clog << "received on A1:P1" << endl;
         recvAltIp = false;
         recvAltPort = false;
         ok = getMessage( info.myFd, msg, &msgLen, &from.addr, &from.port,verbose );
      }
      else if (FD_ISSET(info.altPortFd, &fdSet))
      {
         if (verbose) clog << "received on A1:P2" << endl;
         recvAltIp = false;
         recvAltPort = true;
         ok = getMessage( info.altPortFd, msg, &msgLen, &from.addr, &from.port,verbose );
      }
      else if ( (info.altIpFd!=INVALID_SOCKET) && FD_ISSET(info.altIpFd,&fdSet))
      {
         if (verbose) clog << "received on A2:P1" << endl;
         recvAltIp = true;
         recvAltPort = false;
         ok = getMessage( info.altIpFd, msg, &msgLen, &from.addr, &from.port ,verbose);
      }
      else if ( (info.altIpPortFd!=INVALID_SOCKET) && FD_ISSET(info.altIpPortFd, &fdSet))
      {
         if (verbose) clog << "received on A2:P2" << endl;
         recvAltIp = true;
         recvAltPort = true;
         ok = getMessage( info.altIpPortFd, msg, &msgLen, &from.addr, &from.port,verbose );
      }
      else
      {
         return true;
      }

      int relayPort = 0;
      if (info.relay)
      {
         for (int i=0; i<MAX_MEDIA_RELAYS; ++i)
         {
            StunMediaRelay* relay = &info.relays[i];
            if (relay->destination.addr == from.addr && 
                relay->destination.port == from.port)
            {
               relayPort = relay->relayPort;
               relay->expireTime = time(0) + MEDIA_RELAY_TIMEOUT;
               break;
            }
         }

         if (relayPort == 0)
         {
            for (int i=0; i<MAX_MEDIA_RELAYS; ++i)
            {
               StunMediaRelay* relay = &info.relays[i];
               if (relay->fd == 0)
               {
                  if ( verbose ) clog << "Open relay port " << relay->relayPort << endl;
                  
                  relay->fd = openPort(relay->relayPort, info.myAddr.addr, verbose);
                  relay->destination.addr = from.addr;
                  relay->destination.port = from.port;
                  relay->expireTime = time(0) + MEDIA_RELAY_TIMEOUT;
                  relayPort = relay->relayPort;
                  break;
               }
            }
         }
      }
         
      if ( !ok ) 
      {
         if ( verbose ) clog << "Get message did not return a valid message" <<endl;
         return true;
      }
		
      if ( verbose ) clog << "Got a request (len=" << msgLen << ") from " << from << endl;
		
      if ( msgLen <= 0 )
      {
         return true;
      }
		
      bool changePort = false;
      bool changeIp = false;
		
      StunMessage resp;
      StunAddress4 dest;
      StunAtrString hmacPassword;  
      hmacPassword.sizeValue = 0;

      StunAddress4 secondary;
      secondary.port = 0;
      secondary.addr = 0;
               
      if (info.relay && relayPort)
      {
         secondary = from;
         
         from.addr = info.myAddr.addr;
         from.port = relayPort;
      }
      
      ok = stunServerProcessMsg( msg, msgLen, from, secondary,
                                 recvAltIp ? info.altAddr : info.myAddr,
                                 recvAltIp ? info.myAddr : info.altAddr, 
                                 &resp,
                                 &dest,
                                 &hmacPassword,
                                 &changePort,
                                 &changeIp,
                                 verbose );
		
      if ( !ok )
      {
         if ( verbose ) clog << "Failed to parse message" << endl;
         return true;
      }
		
      char buf[STUN_MAX_MESSAGE_SIZE];
      int len = sizeof(buf);
      		
      len = stunEncodeMessage( resp, buf, len, hmacPassword,verbose );
		
      if ( dest.addr == 0 )  ok=false;
      if ( dest.port == 0 ) ok=false;
		
      if ( ok )
      {
         assert( dest.addr != 0 );
         assert( dest.port != 0 );
			
         Socket sendFd;
			
         bool sendAltIp   = recvAltIp;   // send on the received IP address 
         bool sendAltPort = recvAltPort; // send on the received port
			
         if ( changeIp )   sendAltIp   = !sendAltIp;   // if need to change IP, then flip logic 
         if ( changePort ) sendAltPort = !sendAltPort; // if need to change port, then flip logic 
			
         if ( !sendAltPort )
         {
            if ( !sendAltIp )
            {
               sendFd = info.myFd;
            }
            else
            {
               sendFd = info.altIpFd;
            }
         }
         else
         {
            if ( !sendAltIp )
            {
               sendFd = info.altPortFd;
            }
            else
            {
               sendFd = info.altIpPortFd;
            }
         }
	
         if ( sendFd != INVALID_SOCKET )
         {
            sendMessage( sendFd, buf, len, dest.addr, dest.port, verbose );
         }
      }
   }
	
   return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1d88, %rsp           # imm = 0x1D88
movb %sil, %al
movq %rdi, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movl $0x800, -0x834(%rbp)    # imm = 0x800
movb $0x0, -0x835(%rbp)
movb $0x0, -0x836(%rbp)
movb $0x0, -0x837(%rbp)
movl $0x0, -0x8bc(%rbp)
leaq -0x8b8(%rbp), %rax
movq %rax, -0x8c8(%rbp)
movl $0x0, -0x8c0(%rbp)
movl -0x8c0(%rbp), %eax
cmpq $0x10, %rax
jae 0x65ff
movq -0x8c8(%rbp), %rax
movl -0x8c0(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x8c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c0(%rbp)
jmp 0x65cd
jmp 0x6601
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x665f
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x66bd
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
je 0x6727
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x6725
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
jmp 0x6727
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x1c(%rax)
je 0x6791
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x678f
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
jmp 0x6791
movq -0x28(%rbp), %rax
testb $0x1, 0x20(%rax)
je 0x6867
movl $0x0, -0x8cc(%rbp)
cmpl $0x1f4, -0x8cc(%rbp)    # imm = 0x1F4
jge 0x6865
movq -0x28(%rbp), %rax
addq $0x28, %rax
movslq -0x8cc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8d8(%rbp)
movq -0x8d8(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x684f
movq -0x8d8(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x8d8(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x8d8(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x684d
movq -0x8d8(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
jmp 0x684f
jmp 0x6851
movl -0x8cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8cc(%rbp)
jmp 0x67a9
jmp 0x6867
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
je 0x68d1
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x68cf
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
jmp 0x68d1
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x1c(%rax)
je 0x693b
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x8b8(%rbp,%rax,8), %rcx
movq %rcx, -0x8b8(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0x8bc(%rbp), %eax
jl 0x6939
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
jmp 0x693b
movq $0x0, -0x8e8(%rbp)
movq $0x3e8, -0x8e0(%rbp) # imm = 0x3E8
movl -0x8bc(%rbp), %edi
leaq -0x8b8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x8e8(%rbp), %r8
movq %rcx, %rdx
callq 0x21d0
movl %eax, -0x8ec(%rbp)
cmpl $0x0, -0x8ec(%rbp)
jge 0x69d3
callq 0x8e80
movl %eax, -0x8f0(%rbp)
movq 0x761e(%rip), %rdi      # 0xdfb0
leaq 0x4462(%rip), %rsi      # 0xadfb
callq 0x21f0
movq %rax, -0x1d18(%rbp)
movl -0x8f0(%rbp), %edi
callq 0x20b0
movq -0x1d18(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
movq %rax, %rdi
movq 0x75f7(%rip), %rsi      # 0xdfc0
callq 0x2200
jmp 0x7504
cmpl $0x0, -0x8ec(%rbp)
jl 0x7502
movq -0x28(%rbp), %rax
testb $0x1, 0x20(%rax)
je 0x6c13
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
movq %rax, -0x900(%rbp)
movl $0x0, -0x904(%rbp)
cmpl $0x1f4, -0x904(%rbp)    # imm = 0x1F4
jge 0x6c11
movq -0x28(%rbp), %rax
addq $0x28, %rax
movslq -0x904(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x910(%rbp)
movq -0x910(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x6bfb
movq -0x910(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x8b8(%rbp,%rax,8), %rax
movq %rax, -0x1d20(%rbp)
movq -0x910(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d20(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x6bc6
movl $0x5dc, -0xef4(%rbp)    # imm = 0x5DC
movq -0x910(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0xef0(%rbp), %rsi
leaq -0xefc(%rbp), %rcx
addq $0x4, %rcx
leaq -0xefc(%rbp), %r8
movb -0x29(%rbp), %al
leaq -0xef4(%rbp), %rdx
andb $0x1, %al
movzbl %al, %r9d
callq 0x91a0
andb $0x1, %al
movb %al, -0x835(%rbp)
testb $0x1, -0x835(%rbp)
je 0x6bc4
movq -0x28(%rbp), %rax
movl 0x10(%rax), %edi
leaq -0xef0(%rbp), %rsi
movl -0xef4(%rbp), %edx
movq -0x910(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x910(%rbp), %rax
movw 0x8(%rax), %r8w
movb -0x29(%rbp), %al
andb $0x1, %al
movzwl %r8w, %r8d
movzbl %al, %r9d
callq 0x93d0
movq -0x900(%rbp), %rcx
addq $0xb4, %rcx
movq -0x910(%rbp), %rax
movq %rcx, 0x10(%rax)
testb $0x1, -0x29(%rbp)
je 0x6bc2
movq 0x745b(%rip), %rdi      # 0xdfb0
leaq 0x42b1(%rip), %rsi      # 0xae0d
callq 0x21f0
movq %rax, %rdi
movq -0x910(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x433f(%rip), %rsi      # 0xaebc
callq 0x21f0
movq %rax, %rdi
leaq -0xefc(%rbp), %rsi
callq 0x4040
movq %rax, %rdi
leaq 0x4283(%rip), %rsi      # 0xae1e
callq 0x21f0
movq %rax, %rdi
movq -0x910(%rbp), %rsi
addq $0x8, %rsi
callq 0x4040
movq %rax, %rdi
movq 0x7403(%rip), %rsi      # 0xdfc0
callq 0x2200
jmp 0x6bc4
jmp 0x6bf9
movq -0x900(%rbp), %rax
movq -0x910(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0x6bf7
movq -0x910(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x31c0
movq -0x910(%rbp), %rax
movl $0x0, 0x4(%rax)
jmp 0x6bf9
jmp 0x6bfb
jmp 0x6bfd
movl -0x904(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x904(%rbp)
jmp 0x6a08
jmp 0x6c13
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x8b8(%rbp,%rax,8), %rax
movq %rax, -0x1d28(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d28(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x6cd7
testb $0x1, -0x29(%rbp)
je 0x6c87
movq 0x7344(%rip), %rdi      # 0xdfb0
leaq 0x41b0(%rip), %rsi      # 0xae23
callq 0x21f0
movq %rax, %rdi
movq 0x733e(%rip), %rsi      # 0xdfc0
callq 0x2200
movb $0x0, -0x836(%rbp)
movb $0x0, -0x837(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %edi
leaq -0x830(%rbp), %rsi
leaq -0x8f8(%rbp), %rcx
addq $0x4, %rcx
leaq -0x8f8(%rbp), %r8
movb -0x29(%rbp), %al
leaq -0x834(%rbp), %rdx
andb $0x1, %al
movzbl %al, %r9d
callq 0x91a0
andb $0x1, %al
movb %al, -0x835(%rbp)
jmp 0x6f4b
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x8b8(%rbp,%rax,8), %rax
movq %rax, -0x1d30(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d30(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x6d9b
testb $0x1, -0x29(%rbp)
je 0x6d4b
movq 0x7280(%rip), %rdi      # 0xdfb0
leaq 0x40fe(%rip), %rsi      # 0xae35
callq 0x21f0
movq %rax, %rdi
movq 0x727a(%rip), %rsi      # 0xdfc0
callq 0x2200
movb $0x0, -0x836(%rbp)
movb $0x1, -0x837(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %edi
leaq -0x830(%rbp), %rsi
leaq -0x8f8(%rbp), %rcx
addq $0x4, %rcx
leaq -0x8f8(%rbp), %r8
movb -0x29(%rbp), %al
leaq -0x834(%rbp), %rdx
andb $0x1, %al
movzbl %al, %r9d
callq 0x91a0
andb $0x1, %al
movb %al, -0x835(%rbp)
jmp 0x6f49
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
je 0x6e6d
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x8b8(%rbp,%rax,8), %rax
movq %rax, -0x1d38(%rbp)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d38(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x6e6d
testb $0x1, -0x29(%rbp)
je 0x6e1d
movq 0x71ae(%rip), %rdi      # 0xdfb0
leaq 0x403e(%rip), %rsi      # 0xae47
callq 0x21f0
movq %rax, %rdi
movq 0x71a8(%rip), %rsi      # 0xdfc0
callq 0x2200
movb $0x1, -0x836(%rbp)
movb $0x0, -0x837(%rbp)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x830(%rbp), %rsi
leaq -0x8f8(%rbp), %rcx
addq $0x4, %rcx
leaq -0x8f8(%rbp), %r8
movb -0x29(%rbp), %al
leaq -0x834(%rbp), %rdx
andb $0x1, %al
movzbl %al, %r9d
callq 0x91a0
andb $0x1, %al
movb %al, -0x835(%rbp)
jmp 0x6f47
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x1c(%rax)
je 0x6f3c
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x8b8(%rbp,%rax,8), %rax
movq %rax, -0x1d40(%rbp)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d40(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x6f3c
testb $0x1, -0x29(%rbp)
je 0x6eef
movq 0x70dc(%rip), %rdi      # 0xdfb0
leaq 0x3f7e(%rip), %rsi      # 0xae59
callq 0x21f0
movq %rax, %rdi
movq 0x70d6(%rip), %rsi      # 0xdfc0
callq 0x2200
movb $0x1, -0x836(%rbp)
movb $0x1, -0x837(%rbp)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %edi
leaq -0x830(%rbp), %rsi
leaq -0x8f8(%rbp), %rcx
addq $0x4, %rcx
leaq -0x8f8(%rbp), %r8
movb -0x29(%rbp), %al
leaq -0x834(%rbp), %rdx
andb $0x1, %al
movzbl %al, %r9d
callq 0x91a0
andb $0x1, %al
movb %al, -0x835(%rbp)
jmp 0x6f45
movb $0x1, -0x19(%rbp)
jmp 0x7508
jmp 0x6f47
jmp 0x6f49
jmp 0x6f4b
movl $0x0, -0xf00(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x20(%rax)
je 0x712f
movl $0x0, -0xf04(%rbp)
cmpl $0x1f4, -0xf04(%rbp)    # imm = 0x1F4
jge 0x7007
movq -0x28(%rbp), %rax
addq $0x28, %rax
movslq -0xf04(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xf10(%rbp)
movq -0xf10(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x8f4(%rbp), %eax
jne 0x6ff1
movq -0xf10(%rbp), %rax
movzwl 0x8(%rax), %eax
movzwl -0x8f8(%rbp), %ecx
cmpl %ecx, %eax
jne 0x6ff1
movq -0xf10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf00(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
movq %rax, %rcx
addq $0xb4, %rcx
movq -0xf10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x7007
jmp 0x6ff3
movl -0xf04(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf04(%rbp)
jmp 0x6f6d
cmpl $0x0, -0xf00(%rbp)
jne 0x712d
movl $0x0, -0xf14(%rbp)
cmpl $0x1f4, -0xf14(%rbp)    # imm = 0x1F4
jge 0x712b
movq -0x28(%rbp), %rax
addq $0x28, %rax
movslq -0xf14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xf20(%rbp)
movq -0xf20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x7115
testb $0x1, -0x29(%rbp)
je 0x7095
movq 0x6f47(%rip), %rdi      # 0xdfb0
leaq 0x3dfb(%rip), %rsi      # 0xae6b
callq 0x21f0
movq %rax, %rdi
movq -0xf20(%rbp), %rax
movl (%rax), %esi
callq 0x2300
movq %rax, %rdi
movq 0x6f30(%rip), %rsi      # 0xdfc0
callq 0x2200
movq -0xf20(%rbp), %rax
movl (%rax), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
movb -0x29(%rbp), %al
andb $0x1, %al
movzwl %cx, %edi
movzbl %al, %edx
callq 0x8e90
movl %eax, %ecx
movq -0xf20(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x8f4(%rbp), %ecx
movq -0xf20(%rbp), %rax
movl %ecx, 0xc(%rax)
movw -0x8f8(%rbp), %cx
movq -0xf20(%rbp), %rax
movw %cx, 0x8(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
movq %rax, %rcx
addq $0xb4, %rcx
movq -0xf20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xf20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf00(%rbp)
jmp 0x712b
jmp 0x7117
movl -0xf14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf14(%rbp)
jmp 0x701e
jmp 0x712d
jmp 0x712f
testb $0x1, -0x835(%rbp)
jne 0x7169
testb $0x1, -0x29(%rbp)
je 0x7160
movq 0x6e6b(%rip), %rdi      # 0xdfb0
leaq 0x3d30(%rip), %rsi      # 0xae7c
callq 0x21f0
movq %rax, %rdi
movq 0x6e65(%rip), %rsi      # 0xdfc0
callq 0x2200
movb $0x1, -0x19(%rbp)
jmp 0x7508
testb $0x1, -0x29(%rbp)
je 0x71bd
movq 0x6e3a(%rip), %rdi      # 0xdfb0
leaq 0x3d2a(%rip), %rsi      # 0xaea7
callq 0x21f0
movq %rax, %rdi
movl -0x834(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x3d21(%rip), %rsi      # 0xaebb
callq 0x21f0
movq %rax, %rdi
leaq -0x8f8(%rbp), %rsi
callq 0x4040
movq %rax, %rdi
movq 0x6e08(%rip), %rsi      # 0xdfc0
callq 0x2200
cmpl $0x0, -0x834(%rbp)
jg 0x71cf
movb $0x1, -0x19(%rbp)
jmp 0x7508
movb $0x0, -0xf21(%rbp)
movb $0x0, -0xf22(%rbp)
movw $0x0, -0x13f6(%rbp)
movw $0x0, -0x1500(%rbp)
movl $0x0, -0x14fc(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x20(%rax)
je 0x7234
cmpl $0x0, -0xf00(%rbp)
je 0x7234
movq -0x8f8(%rbp), %rax
movq %rax, -0x1500(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x8f4(%rbp)
movl -0xf00(%rbp), %eax
movw %ax, -0x8f8(%rbp)
leaq -0x830(%rbp), %rax
movq %rax, -0x1d50(%rbp)
movl -0x834(%rbp), %eax
movl %eax, -0x1d44(%rbp)
testb $0x1, -0x836(%rbp)
je 0x7268
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x1d58(%rbp)
jmp 0x7273
movq -0x28(%rbp), %rax
movq %rax, -0x1d58(%rbp)
movq -0x1d58(%rbp), %rax
movq %rax, -0x1d60(%rbp)
testb $0x1, -0x836(%rbp)
je 0x7297
movq -0x28(%rbp), %rax
movq %rax, -0x1d68(%rbp)
jmp 0x72a6
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x1d68(%rbp)
movq -0x1d60(%rbp), %r8
movl -0x1d44(%rbp), %esi
movq -0x1d50(%rbp), %rdi
movq -0x1d68(%rbp), %r9
movb -0x29(%rbp), %al
leaq -0x8f8(%rbp), %rdx
leaq -0x1500(%rbp), %rcx
leaq -0x13ec(%rbp), %r15
leaq -0x13f4(%rbp), %r14
leaq -0x14f6(%rbp), %rbx
leaq -0xf21(%rbp), %r11
leaq -0xf22(%rbp), %r10
andb $0x1, %al
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movzbl %al, %eax
movl %eax, 0x28(%rsp)
callq 0x5740
andb $0x1, %al
movb %al, -0x835(%rbp)
testb $0x1, -0x835(%rbp)
jne 0x735d
testb $0x1, -0x29(%rbp)
je 0x7354
movq 0x6c77(%rip), %rdi      # 0xdfb0
leaq 0x3b83(%rip), %rsi      # 0xaec3
callq 0x21f0
movq %rax, %rdi
movq 0x6c71(%rip), %rsi      # 0xdfc0
callq 0x2200
movb $0x1, -0x19(%rbp)
jmp 0x7508
movl $0x800, -0x1d04(%rbp)   # imm = 0x800
leaq -0x1d00(%rbp), %rsi
movl -0x1d04(%rbp), %edx
movb -0x29(%rbp), %al
leaq -0x13ec(%rbp), %rdi
leaq -0x14f6(%rbp), %rcx
andb $0x1, %al
movzbl %al, %r8d
callq 0x44c0
movl %eax, -0x1d04(%rbp)
cmpl $0x0, -0x13f0(%rbp)
jne 0x73a6
movb $0x0, -0x835(%rbp)
movzwl -0x13f4(%rbp), %eax
cmpl $0x0, %eax
jne 0x73b9
movb $0x0, -0x835(%rbp)
testb $0x1, -0x835(%rbp)
je 0x7500
cmpl $0x0, -0x13f0(%rbp)
je 0x73d1
jmp 0x73f0
leaq 0x3b03(%rip), %rdi      # 0xaedb
leaq 0x3376(%rip), %rsi      # 0xa755
movl $0x630, %edx            # imm = 0x630
leaq 0x3aff(%rip), %rcx      # 0xaeea
callq 0x2140
movzwl -0x13f4(%rbp), %eax
cmpl $0x0, %eax
je 0x73fe
jmp 0x741d
leaq 0x3b14(%rip), %rdi      # 0xaf19
leaq 0x3349(%rip), %rsi      # 0xa755
movl $0x631, %edx            # imm = 0x631
leaq 0x3ad2(%rip), %rcx      # 0xaeea
callq 0x2140
movb -0x836(%rbp), %al
andb $0x1, %al
movb %al, -0x1d09(%rbp)
movb -0x837(%rbp), %al
andb $0x1, %al
movb %al, -0x1d0a(%rbp)
testb $0x1, -0xf22(%rbp)
je 0x7452
movb -0x1d09(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x1d09(%rbp)
testb $0x1, -0xf21(%rbp)
je 0x746b
movb -0x1d0a(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x1d0a(%rbp)
testb $0x1, -0x1d0a(%rbp)
jne 0x749b
testb $0x1, -0x1d09(%rbp)
jne 0x748c
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x1d08(%rbp)
jmp 0x7499
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x1d08(%rbp)
jmp 0x74c2
testb $0x1, -0x1d09(%rbp)
jne 0x74b3
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x1d08(%rbp)
jmp 0x74c0
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x1d08(%rbp)
jmp 0x74c2
cmpl $-0x1, -0x1d08(%rbp)
je 0x74fe
movl -0x1d08(%rbp), %edi
leaq -0x1d00(%rbp), %rsi
movl -0x1d04(%rbp), %edx
movl -0x13f0(%rbp), %ecx
movw -0x13f4(%rbp), %r8w
movb -0x29(%rbp), %al
andb $0x1, %al
movzwl %r8w, %r8d
movzbl %al, %r9d
callq 0x93d0
jmp 0x7500
jmp 0x7502
jmp 0x7504
movb $0x1, -0x19(%rbp)
movb -0x19(%rbp), %al
andb $0x1, %al
addq $0x1d88, %rsp           # imm = 0x1D88
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)