// File: /workspace/github_cpp_makefile_star2_O1/Distrotech[P]stund/client.cxx
// Function: main
int
main(int argc, char* argv[])
{
   assert( sizeof(UInt8 ) == 1 );
   assert( sizeof(UInt16) == 2 );
   assert( sizeof(UInt32) == 4 );
    
   initNetwork();
    
   cout << "STUN client version " << STUN_VERSION << endl;
   
   int testNum = 0;
   bool verbose = false;
	
   StunAddress4 stunServerAddr;
   stunServerAddr.addr=0;

   int srcPort=0;
   StunAddress4 sAddr[MAX_NIC];
   int retval[MAX_NIC];
   int numNic=0;

   for ( int i=0; i<MAX_NIC; i++ )
   {
      sAddr[i].addr=0; 
      sAddr[i].port=0; 
      retval[i]=0;
   }
   
   for ( int arg = 1; arg<argc; arg++ )
   {
      if ( !strcmp( argv[arg] , "-v" ) )
      {
         verbose = true;
      }
      else if ( !strcmp( argv[arg] , "-i" ) )
      {
         arg++;
         if ( argc <= arg ) 
         {
            usage();
            exit(-1);
         }
         if ( numNic >= MAX_NIC )
         {  
            cerr << "Can not have more than "<<  MAX_NIC <<" -i options" << endl;
            usage();
            exit(-1);
         }
         
         stunParseServerName(argv[arg], sAddr[numNic++]);
      }
      else if ( !strcmp( argv[arg] , "-p" ) )
      {
         arg++;
         if ( argc <= arg ) 
         {
            usage();
            exit(-1);
         }
         srcPort = strtol( argv[arg], NULL, 10);
      }
      else    
      {
        char* ptr;
        int t =  strtol( argv[arg], &ptr, 10 );
        if ( *ptr == 0 )
        { 
           // conversion worked
           testNum = t;
           cout << "running test number " << testNum  << endl; 
        }
        else
        {
           bool ret = stunParseServerName( argv[arg], stunServerAddr);
           if ( ret != true )
           {
              cerr << argv[arg] << " is not a valid host name " << endl;
              usage();
              exit(-1);
           }
	}	
      }
   }

   if ( srcPort == 0 )
   {
      srcPort = stunRandomPort();
   }
   
   if ( numNic == 0 )
   {
      // use default 
      numNic = 1;
   }
   
   for ( int nic=0; nic<numNic; nic++ )
   {
      sAddr[nic].port=srcPort;
      if ( stunServerAddr.addr == 0 )
      {
         usage();
         exit(-1);
      }
   
      if (testNum==0)
      {
         bool presPort=false;
         bool hairpin=false;
		
         NatType stype = stunNatType( stunServerAddr, verbose, &presPort, &hairpin, 
                                      srcPort, &sAddr[nic]);
		
         if ( nic == 0 )
         {
            cout << "Primary: ";
         }
         else
         {
            cout << "Secondary: ";
         }
         
         switch (stype)
         {
            case StunTypeFailure:
               cout << "Some stun error detetecting NAT type";
	       retval[nic] = -1;
               exit(-1);
               break;
            case StunTypeUnknown:
               cout << "Some unknown type error detetecting NAT type";
	       retval[nic] = 0xEE;
               break;
            case StunTypeOpen:
               cout << "Open";
	       retval[nic] = 0x00; 
               break;
            case StunTypeIndependentFilter:
               cout << "Independent Mapping, Independent Filter";
               if ( presPort ) cout << ", preserves ports"; else cout << ", random port";
               if ( hairpin  ) cout << ", will hairpin"; else cout << ", no hairpin";
               retval[nic] = 0x02;
               break;
            case StunTypeDependentFilter:
               cout << "Independent Mapping, Address Dependent Filter";
               if ( presPort ) cout << ", preserves ports"; else cout << ", random port";
               if ( hairpin  ) cout << ", will hairpin"; else cout << ", no hairpin";
               retval[nic] = 0x04;
               break;
            case StunTypePortDependedFilter:
               cout << "Independent Mapping, Port Dependent Filter";
               if ( presPort ) cout << ", preserves ports"; else cout << ", random port";
               if ( hairpin  ) cout << ", will hairpin"; else cout << ", no hairpin";
               retval[nic] = 0x06;
               break;
            case StunTypeDependentMapping:
               cout << "Dependent Mapping";
               if ( presPort ) cout << ", preserves ports"; else cout << ", random port";
               if ( hairpin  ) cout << ", will hairpin"; else cout << ", no hairpin";
               retval[nic] = 0x08;
               break;
            case StunTypeFirewall:
               cout << "Firewall";
               retval[nic] = 0x0A;
               break;
            case StunTypeBlocked:
               cout << "Blocked or could not reach STUN server";
               retval[nic] = 0x0C;
               break;
            default:
               cout << stype;
               cout << "Unkown NAT type";
               retval[nic] = 0x0E;  // Unknown NAT type
               break;
         }
         cout << "\t"; cout.flush();
         
         if (!hairpin)
         {
             retval[nic] |= 0x10;
         }       

         if (presPort)
         {
             retval[nic] |= 0x01;
         }
      }
      else if (testNum==100)
      {
         Socket myFd = openPort(srcPort,sAddr[nic].addr,verbose);
      
         StunMessage req;
         memset(&req, 0, sizeof(StunMessage));
      
         StunAtrString username;
         StunAtrString password;
         username.sizeValue = 0;
         password.sizeValue = 0;
      
         stunBuildReqSimple( &req, username, 
                             false , false , 
                             0x0c );
      
         char buf[STUN_MAX_MESSAGE_SIZE];
         int len = STUN_MAX_MESSAGE_SIZE;
      
         len = stunEncodeMessage( req, buf, len, password,verbose );
      
         if ( verbose )
         {
            cout << "About to send msg of len " << len 
                 << " to " << stunServerAddr << endl;
         }
      
         while (1)
         {
            for ( int i=0; i<100; i++ )
            {
               sendMessage( myFd,
                            buf, len, 
                            stunServerAddr.addr, 
                            stunServerAddr.port,verbose );
            }
#ifdef WIN32 // !cj! TODO - should fix this up in windows
            clock_t now = clock();
            assert( CLOCKS_PER_SEC == 1000 );
            while ( clock() <= now+10 ) { };
#else
            usleep(10*1000);
#endif
         }
      }
      else if (testNum==-2)
      {
         const int numPort = 5;
         int fd[numPort];
         StunAddress4 mappedAddr;
         
         for( int i=0; i<numPort; i++ )
         {
            fd[i] = stunOpenSocket( stunServerAddr, &mappedAddr,
                                    (srcPort==0)?0:(srcPort+i), &sAddr[nic],
                                    verbose );
            cout << "Got port at " << mappedAddr.port << endl;
         }
          
         for( int i=0; i<numPort; i++ )
         {
            closesocket(fd[i]);
         }
      }
      else if (testNum==-1)
      {
         int fd3,fd4;
         StunAddress4 mappedAddr;
         
         bool ok = stunOpenSocketPair(stunServerAddr,
                                      &mappedAddr,
                                      &fd3,
                                      &fd4,
                                      srcPort, 
                                      &sAddr[nic],
                                      verbose);
         if ( ok )
         {
            closesocket(fd3);
            closesocket(fd4);
            cout << "Got port pair at " << mappedAddr.port << endl;
         }
         else
         {
            cerr << "Opened a stun socket pair FAILED" << endl;
         }
      }
      else
      {
         stunTest( stunServerAddr,testNum,verbose,&(sAddr[nic]) );
      }
   } // end of for loop 
   cout << endl;
   
   UInt32 ret=0;
   for ( int i=numNic-1; i>=0; i-- )
   {
      if ( retval[i] == -1 )
      {
         ret = 0xFFFFFFFF;
         break;
      }
      ret = ret << 8;
      ret = ret | ( retval[i] & 0xFF );
   }
   
   cout << "Return value is " << hex << "0x";
   cout.fill('0');
   cout.width(6);
   cout << ret << dec << endl;
   cout.fill(' ');
   
   return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf58, %rsp            # imm = 0xF58
movq %rsi, %rbx
movl %edi, %ebp
callq 0x834f
movq 0xa956(%rip), %r14      # 0xcfd0
leaq 0x6af1(%rip), %rsi      # 0x9172
movl $0x14, %edx
movq %r14, %rdi
callq 0x21f0
leaq 0x6af2(%rip), %rsi      # 0x9187
movl $0x4, %edx
movq %r14, %rdi
callq 0x21f0
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
xorl %eax, %eax
movl %eax, 0x14(%rsp)
movl %eax, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x0, 0x64(%rsp,%rax,8)
movw $0x0, 0x60(%rsp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x26dc
movq $0x0, 0x18(%rsp)
movl $0x0, %r14d
movl $0x0, %eax
movq %rax, 0x30(%rsp)
movl $0x0, %eax
movq %rax, 0x28(%rsp)
cmpl $0x2, %ebp
jl 0x2897
movl $0x1, %r15d
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
xorl %r14d, %r14d
movq $0x0, 0x18(%rsp)
movslq %r15d, %r12
movq (%rbx,%r12,8), %r13
movq %r13, %rdi
leaq 0x6a37(%rip), %rsi      # 0x918c
callq 0x2210
testl %eax, %eax
je 0x27cc
movq %r13, %rdi
leaq 0x6a27(%rip), %rsi      # 0x918f
callq 0x2210
testl %eax, %eax
je 0x27d8
movq %r13, %rdi
leaq 0x6a3b(%rip), %rsi      # 0x91b6
callq 0x2210
testl %eax, %eax
je 0x2812
movq %r13, %rdi
leaq 0x650(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq %rax, %r13
movq 0x650(%rsp), %rax
cmpb $0x0, (%rax)
je 0x2836
movq (%rbx,%r12,8), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4f07
testb %al, %al
jne 0x288b
jmp 0x31f0
movb $0x1, %al
movq %rax, 0x30(%rsp)
jmp 0x288b
incl %r15d
cmpl %ebp, %r15d
jge 0x3217
movq 0x18(%rsp), %rcx
cmpl $0x3, %ecx
jge 0x31c7
movslq %r15d, %rax
movq (%rbx,%rax,8), %rdi
movslq %ecx, %rax
incl %ecx
movq %rcx, 0x18(%rsp)
leaq (%rsp,%rax,8), %rsi
addq $0x60, %rsi
callq 0x4f07
jmp 0x288b
incl %r15d
cmpl %ebp, %r15d
jge 0x3217
movslq %r15d, %rax
movq (%rbx,%rax,8), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2220
movq %rax, %r14
jmp 0x288b
movl $0x14, %edx
movq 0xa78e(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x696d(%rip), %rsi      # 0x91b9
callq 0x21f0
movq %r12, %rdi
movl %r13d, %esi
callq 0x22a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %r13, 0x28(%rsp)
incl %r15d
cmpl %ebp, %r15d
jl 0x2744
testl %r14d, %r14d
jne 0x28a4
callq 0x4b6e
movl %eax, %r14d
movq 0x18(%rsp), %rax
cmpl $0x1, %eax
adcl $0x0, %eax
movl %eax, 0x24(%rsp)
testl %eax, %eax
movq 0x28(%rsp), %rbx
jle 0x2f0e
movl 0x24(%rsp), %ecx
movl %r14d, %eax
movzbl 0x30(%rsp), %ebp
andl $0x1, %ebp
leaq 0x84(%rsp), %r15
xorl %r13d, %r13d
movq %rax, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movw %r14w, 0x60(%rsp,%r13,8)
cmpl $0x0, 0x14(%rsp)
je 0x3217
leaq (%rsp,%r13,8), %r9
addq $0x60, %r9
testl %ebx, %ebx
jns 0x2990
cmpl $-0x2, %ebx
je 0x29e9
cmpl $-0x1, %ebx
jne 0x2ac5
movq %r14, %r8
movq %rcx, %r12
movl %ebp, (%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x650(%rsp), %rsi
movq %r15, %rdx
leaq 0x54c(%rsp), %rcx
callq 0x78ca
testb %al, %al
je 0x2ae7
movl 0x84(%rsp), %edi
callq 0x22c0
movl 0x54c(%rsp), %edi
callq 0x22c0
movl $0x11, %edx
movq 0xa667(%rip), %r15      # 0xcfd0
movq %r15, %rdi
leaq 0x6a20(%rip), %rsi      # 0x9393
callq 0x21f0
movzwl 0x650(%rsp), %esi
movq %r15, %rdi
callq 0x2130
movq %rax, %r15
jmp 0x2b02
jne 0x2abc
xorl %eax, %eax
movb %al, 0x650(%rsp)
movb %al, 0x84(%rsp)
leaq 0x10(%rsp), %rdi
movl %ebp, %esi
leaq 0x650(%rsp), %rdx
movq %r15, %rcx
movl %r14d, %r8d
callq 0x6c43
movl %eax, %r15d
movq %r13, 0x38(%rsp)
testq %r13, %r13
je 0x2b39
movl $0xb, %edx
movq 0xa5f3(%rip), %rdi      # 0xcfd0
leaq 0x680f(%rip), %rsi      # 0x91f3
jmp 0x2b4c
movq %r13, 0x38(%rsp)
xorl %ebx, %ebx
leaq 0x10(%rsp), %r12
movq 0x58(%rsp), %rax
leal (%rax,%rbx), %edx
testl %r14d, %r14d
cmovel %r14d, %edx
movq %r12, %rdi
leaq 0x84(%rsp), %rsi
movq %r9, %rcx
movl %ebp, %r8d
movq %r9, %r15
callq 0x773c
movl %eax, 0x650(%rsp,%rbx,4)
movl $0xc, %edx
movq 0xa5a0(%rip), %r13      # 0xcfd0
movq %r13, %rdi
leaq 0x694c(%rip), %rsi      # 0x9386
callq 0x21f0
movzwl 0x84(%rsp), %esi
movq %r13, %rdi
callq 0x2130
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %r15, %r9
incq %rbx
cmpq $0x5, %rbx
jne 0x29f5
xorl %ebx, %ebx
movl 0x650(%rsp,%rbx,4), %edi
callq 0x22c0
incq %rbx
cmpq $0x5, %rbx
jne 0x2a8b
movq 0x28(%rsp), %rbx
movq 0x50(%rsp), %rcx
leaq 0x84(%rsp), %r15
movq 0x38(%rsp), %r13
jmp 0x2d79
cmpl $0x64, %ebx
je 0x3097
leaq 0x10(%rsp), %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r14, %r12
movq %rcx, %r14
movq %r9, %rcx
callq 0x676c
movq %r14, %rcx
movq %r12, %r14
jmp 0x2d79
movl $0x20, %edx
movq 0xa4fd(%rip), %r15      # 0xcff0
movq %r15, %rdi
leaq 0x68a8(%rip), %rsi      # 0x93a5
callq 0x21f0
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
leaq 0x84(%rsp), %r15
movq %r12, %rcx
jmp 0x2d79
movl $0x9, %edx
movq 0xa48b(%rip), %rdi      # 0xcfd0
leaq 0x669d(%rip), %rsi      # 0x91e9
callq 0x21f0
cmpl $0x8, %r15d
ja 0x2cfb
movl %r15d, %eax
leaq 0x649f(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2c, %edx
movq 0xa456(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x66a0(%rip), %rsi      # 0x9224
callq 0x21f0
movl $0xee, %eax
jmp 0x2d26
movl $0x2d, %edx
movq 0xa431(%rip), %r15      # 0xcfd0
movq %r15, %rdi
leaq 0x6711(%rip), %rsi      # 0x92ba
callq 0x21f0
cmpb $0x1, 0x650(%rsp)
jne 0x2d8a
movl $0x11, %edx
movq %r15, %rdi
leaq 0x66b3(%rip), %rsi      # 0x927e
jmp 0x2d99
movl $0x4, %edx
movq 0xa3f4(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x666b(%rip), %rsi      # 0x9251
callq 0x21f0
xorl %eax, %eax
jmp 0x2d26
movl $0x27, %edx
movq 0xa3d2(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x664e(%rip), %rsi      # 0x9256
callq 0x21f0
cmpb $0x1, 0x650(%rsp)
leaq 0x84(%rsp), %r15
jne 0x2ded
movl $0x11, %edx
movq %r12, %rdi
leaq 0x664c(%rip), %rsi      # 0x927e
jmp 0x2dfc
movl $0x26, %edx
movq 0xa38d(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x66e1(%rip), %rsi      # 0x932e
callq 0x21f0
movl $0xc, %eax
jmp 0x2d26
movl $0x8, %edx
movq 0xa368(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x66b3(%rip), %rsi      # 0x9325
callq 0x21f0
movl $0xa, %eax
jmp 0x2d26
movl $0x2a, %edx
movq 0xa343(%rip), %r15      # 0xcfd0
movq %r15, %rdi
leaq 0x6651(%rip), %rsi      # 0x92e8
callq 0x21f0
cmpb $0x1, 0x650(%rsp)
jne 0x2e48
movl $0x11, %edx
movq %r15, %rdi
leaq 0x65c5(%rip), %rsi      # 0x927e
jmp 0x2e57
movl $0x11, %edx
movq 0xa306(%rip), %r15      # 0xcfd0
movq %r15, %rdi
leaq 0x663f(%rip), %rsi      # 0x9313
callq 0x21f0
cmpb $0x1, 0x650(%rsp)
jne 0x2eab
movl $0x11, %edx
movq %r15, %rdi
leaq 0x6588(%rip), %rsi      # 0x927e
jmp 0x2eba
movq 0xa2ce(%rip), %r12      # 0xcfd0
movq %r12, %rdi
movl %r15d, %esi
callq 0x22a0
movl $0xf, %edx
movq %r12, %rdi
leaq 0x6639(%rip), %rsi      # 0x9355
callq 0x21f0
movl $0xe, %eax
leaq 0x84(%rsp), %r15
movq 0x38(%rsp), %r13
movl %eax, 0x40(%rsp,%r13,4)
movl $0x1, %edx
movq %r12, %rdi
leaq 0x661e(%rip), %rsi      # 0x9365
callq 0x21f0
movq %r12, %rdi
callq 0x2140
cmpb $0x0, 0x84(%rsp)
jne 0x2d64
orb $0x10, 0x40(%rsp,%r13,4)
cmpb $0x1, 0x650(%rsp)
movq 0x50(%rsp), %rcx
jne 0x2d79
orb $0x1, 0x40(%rsp,%r13,4)
incq %r13
cmpq %rcx, %r13
jne 0x28e4
jmp 0x2f0e
movl $0xd, %edx
movq %r15, %rdi
leaq 0x64f7(%rip), %rsi      # 0x9290
callq 0x21f0
leaq 0x84(%rsp), %r15
cmpb $0x1, 0x84(%rsp)
jne 0x2dc8
movl $0xe, %edx
movq 0xa214(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x64d8(%rip), %rsi      # 0x929e
jmp 0x2dde
movl $0xc, %edx
movq 0xa1fc(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x64cf(%rip), %rsi      # 0x92ad
callq 0x21f0
movl $0x4, %eax
jmp 0x2d2e
movl $0xd, %edx
movq %r12, %rdi
leaq 0x6494(%rip), %rsi      # 0x9290
callq 0x21f0
cmpb $0x1, 0x84(%rsp)
jne 0x2e23
movl $0xe, %edx
movq 0xa1b9(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x647d(%rip), %rsi      # 0x929e
jmp 0x2e39
movl $0xc, %edx
movq 0xa1a1(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x6474(%rip), %rsi      # 0x92ad
callq 0x21f0
movl $0x2, %eax
jmp 0x2d2e
movl $0xd, %edx
movq %r15, %rdi
leaq 0x6439(%rip), %rsi      # 0x9290
callq 0x21f0
leaq 0x84(%rsp), %r15
cmpb $0x1, 0x84(%rsp)
jne 0x2e86
movl $0xe, %edx
movq 0xa156(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x641a(%rip), %rsi      # 0x929e
jmp 0x2e9c
movl $0xc, %edx
movq 0xa13e(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x6411(%rip), %rsi      # 0x92ad
callq 0x21f0
movl $0x6, %eax
jmp 0x2d2e
movl $0xd, %edx
movq %r15, %rdi
leaq 0x63d6(%rip), %rsi      # 0x9290
callq 0x21f0
leaq 0x84(%rsp), %r15
cmpb $0x1, 0x84(%rsp)
jne 0x2ee9
movl $0xe, %edx
movq 0xa0f3(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x63b7(%rip), %rsi      # 0x929e
jmp 0x2eff
movl $0xc, %edx
movq 0xa0db(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x63ae(%rip), %rsi      # 0x92ad
callq 0x21f0
movl $0x8, %eax
jmp 0x2d2e
movq 0xa0bb(%rip), %r15      # 0xcfd0
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
cmpl $0x0, 0x24(%rsp)
jle 0x2f6f
movq 0x18(%rsp), %rcx
cmpl $0x1, %ecx
adcl $0x0, %ecx
incq %rcx
xorl %ebx, %ebx
movl 0x38(%rsp,%rcx,4), %eax
cmpl $-0x1, %eax
je 0x2f73
shll $0x8, %ebx
movzbl %al, %eax
orl %eax, %ebx
decq %rcx
cmpq $0x1, %rcx
jg 0x2f53
jmp 0x2f78
xorl %ebx, %ebx
jmp 0x2f78
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x6447(%rip), %rsi      # 0x93c6
movl $0x10, %edx
movq %r15, %rdi
callq 0x21f0
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r15,%rax)
leaq 0x642d(%rip), %rsi      # 0x93d7
movl $0x2, %edx
movq %r15, %rdi
callq 0x21f0
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %r14
cmpb $0x0, 0xe1(%r15,%rax)
jne 0x2fe9
movq %r14, %rdi
movl $0x20, %esi
callq 0x21b0
movb %al, 0xe0(%r14)
movb $0x1, 0xe1(%r14)
movb $0x30, 0xe0(%r14)
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%r15,%rax)
movl %ebx, %esi
movq %r15, %rdi
callq 0x2130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rcx
movl 0x18(%r14,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%r14,%rcx)
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 (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %r14
cmpb $0x0, 0xe1(%r15,%rax)
jne 0x307b
movq %r14, %rdi
movl $0x20, %esi
callq 0x21b0
movb %al, 0xe0(%r14)
movb $0x1, 0xe1(%r14)
movb $0x20, 0xe0(%r14)
movl %ebx, %eax
addq $0xf58, %rsp            # imm = 0xF58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r9), %esi
movzwl %r14w, %edi
movl %ebp, %edx
callq 0x7c10
movl %eax, %ebx
leaq 0x84(%rsp), %r14
xorl %r12d, %r12d
movl $0x4c8, %edx            # imm = 0x4C8
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
leaq 0x54c(%rsp), %rsi
movw %r12w, 0x100(%rsi)
leaq 0xe56(%rsp), %r15
movw %r12w, 0x100(%r15)
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xc, %r8d
callq 0x664e
leaq 0x650(%rsp), %rsi
movq %r14, %rdi
movl $0x800, %edx            # imm = 0x800
movq %r15, %rcx
movl %ebp, %r8d
callq 0x40bb
movl %eax, %r14d
testb $0x1, 0x30(%rsp)
je 0x318d
movq 0x9eb0(%rip), %r15      # 0xcfd0
leaq 0x6240(%rip), %rsi      # 0x9367
movl $0x19, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x22a0
movq %rax, %r15
leaq 0x6238(%rip), %rsi      # 0x9381
movl $0x4, %edx
movq %rax, %rdi
callq 0x21f0
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x3f5b
movq %rax, %r15
movq (%rax), %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
leaq 0x650(%rsp), %r15
movl 0x14(%rsp), %ecx
movzwl 0x10(%rsp), %r8d
movl %ebx, %edi
movq %r15, %rsi
movl %r14d, %edx
movl %ebp, %r9d
callq 0x8101
incl %r12d
cmpl $0x64, %r12d
jne 0x3195
movl $0x2710, %edi           # imm = 0x2710
callq 0x2240
xorl %r12d, %r12d
jmp 0x3195
movq 0x9e22(%rip), %rdi      # 0xcff0
leaq 0x5fbd(%rip), %rsi      # 0x9192
callq 0x21d0
movq %rax, %rdi
movl $0x3, %esi
callq 0x22a0
leaq 0x5fbc(%rip), %rsi      # 0x91aa
jmp 0x3207
movq (%rbx,%r12,8), %rsi
movq 0x9df5(%rip), %rdi      # 0xcff0
callq 0x21d0
leaq 0x5fc7(%rip), %rsi      # 0x91ce
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20d0
callq 0x244c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2200
movq 0x9da3(%rip), %rdi      # 0xcfd0
leaq 0x5fcb(%rip), %rsi      # 0x91ff
callq 0x21d0
movq 0x38(%rsp), %rax
movl $0xffffffff, 0x40(%rsp,%rax,4) # imm = 0xFFFFFFFF
jmp 0x321c