// File: /workspace/github_cpp_makefile_star2_O3/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 $0xf48, %rsp            # imm = 0xF48
movq %rsi, %rbx
movl %edi, %ebp
callq 0x838a
movq 0xa966(%rip), %r14      # 0xcfd0
leaq 0x6b01(%rip), %rsi      # 0x9172
movl $0x14, %edx
movq %r14, %rdi
callq 0x21f0
leaq 0x6b02(%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, 0x10(%rsp)
movl %eax, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movl $0x0, 0x54(%rsp,%rax,8)
movw $0x0, 0x50(%rsp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x26cc
movq $0x0, 0x20(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x0, %eax
movq %rax, 0x18(%rsp)
cmpl $0x2, %ebp
jl 0x2870
movl $0x1, %r14d
movq $0x0, 0x20(%rsp)
movl $0x0, 0x14(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x18(%rsp)
movslq %r14d, %r12
movq (%rbx,%r12,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x2767
cmpb $0x76, 0x1(%rdi)
jne 0x2747
cmpb $0x0, 0x2(%rdi)
je 0x27fb
cmpb $0x69, 0x1(%rdi)
jne 0x2757
cmpb $0x0, 0x2(%rdi)
je 0x2803
cmpb $0x70, 0x1(%rdi)
jne 0x2767
cmpb $0x0, 0x2(%rdi)
je 0x283d
leaq 0x640(%rsp), %rsi
movl $0xa, %edx
callq 0x2210
movq %rax, %r13
movq 0x640(%rsp), %rax
cmpb $0x0, (%rax)
je 0x27a4
movq (%rbx,%r12,8), %rdi
leaq 0xc(%rsp), %rsi
callq 0x4f18
testb %al, %al
jne 0x285f
jmp 0x3137
movl $0x14, %edx
movq 0xa820(%rip), %r12      # 0xcfd0
movq %r12, %rdi
leaq 0x69f6(%rip), %rsi      # 0x91b0
callq 0x21f0
movq %r12, %rdi
movl %r13d, %esi
callq 0x2290
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, 0x20(%rsp)
jmp 0x285f
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0x285f
incl %r14d
cmpl %ebp, %r14d
jge 0x315e
movq 0x18(%rsp), %rcx
cmpl $0x3, %ecx
jge 0x316d
movslq %r14d, %rax
movq (%rbx,%rax,8), %rdi
movslq %ecx, %rax
incl %ecx
movq %rcx, 0x18(%rsp)
leaq (%rsp,%rax,8), %rsi
addq $0x50, %rsi
callq 0x4f18
jmp 0x285f
incl %r14d
cmpl %ebp, %r14d
jge 0x315e
movslq %r14d, %rax
movq (%rbx,%rax,8), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2210
movq %rax, %r15
incl %r14d
cmpl %ebp, %r14d
jl 0x272b
testl %r15d, %r15d
jne 0x2878
callq 0x4b7f
movl %eax, %r15d
movq 0x18(%rsp), %rax
cmpl $0x1, %eax
adcl $0x0, %eax
testl %eax, %eax
jle 0x2eb7
movl %eax, 0x44(%rsp)
movl %eax, %ecx
movl %r15d, %eax
movzbl 0x14(%rsp), %ebp
andl $0x1, %ebp
leaq 0xc(%rsp), %r14
movq 0xa728(%rip), %r12      # 0xcfd0
xorl %r13d, %r13d
movq 0x20(%rsp), %rbx
movq %rax, 0x48(%rsp)
movq %rcx, 0x28(%rsp)
movw %r15w, 0x50(%rsp,%r13,8)
cmpl $0x0, 0x10(%rsp)
je 0x315e
leaq (%rsp,%r13,8), %r9
addq $0x50, %r9
testl %ebx, %ebx
jns 0x2955
cmpl $-0x2, %ebx
je 0x29ad
cmpl $-0x1, %ebx
jne 0x2a85
movq %r15, %r8
movl %ebp, (%rsp)
movq %r14, %rdi
leaq 0x640(%rsp), %rsi
leaq 0x178(%rsp), %rdx
leaq 0x74(%rsp), %rcx
callq 0x78d6
testb %al, %al
je 0x2ab0
movl 0x178(%rsp), %edi
callq 0x22b0
movl 0x74(%rsp), %edi
callq 0x22b0
movl $0x11, %edx
movq %r12, %rdi
leaq 0x6a52(%rip), %rsi      # 0x938a
callq 0x21f0
movzwl 0x640(%rsp), %esi
movq %r12, %rdi
callq 0x2130
movq %rax, %r14
jmp 0x2acb
jne 0x2a7c
xorl %eax, %eax
movb %al, 0x640(%rsp)
movb %al, 0x178(%rsp)
movq %r14, %rdi
movl %ebp, %esi
leaq 0x640(%rsp), %rdx
leaq 0x178(%rsp), %rcx
movl %r15d, %r8d
callq 0x6ce4
movl %eax, %r14d
movq %r13, 0x30(%rsp)
testq %r13, %r13
je 0x2b01
movl $0xb, %edx
movq %r12, %rdi
leaq 0x6842(%rip), %rsi      # 0x91ea
jmp 0x2b10
movq %r13, 0x30(%rsp)
movq %r12, %r13
xorl %r12d, %r12d
movq 0x48(%rsp), %rax
leal (%rax,%r12), %edx
testl %r15d, %r15d
cmovel %r15d, %edx
leaq 0xc(%rsp), %rdi
leaq 0x178(%rsp), %rsi
movq %r9, %rcx
movl %ebp, %r8d
movq %r9, %r14
callq 0x7748
movl %eax, 0x640(%rsp,%r12,4)
movl $0xc, %edx
movq %r13, %rdi
leaq 0x6983(%rip), %rsi      # 0x937d
callq 0x21f0
movzwl 0x178(%rsp), %esi
movq %r13, %rdi
callq 0x2130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %r14, %r9
incq %r12
cmpq $0x5, %r12
jne 0x29b8
movq %r13, %r12
xorl %ebx, %ebx
movl 0x640(%rsp,%rbx,4), %edi
callq 0x22b0
incq %rbx
cmpq $0x5, %rbx
jne 0x2a4e
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rcx
leaq 0xc(%rsp), %r14
movq 0x30(%rsp), %r13
jmp 0x2d01
cmpl $0x64, %ebx
je 0x300a
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r12, %r14
movq %r15, %r12
movq %rcx, %r15
movq %r9, %rcx
callq 0x67fc
movq %r15, %rcx
movq %r12, %r15
movq %r14, %r12
leaq 0xc(%rsp), %r14
jmp 0x2d01
movl $0x20, %edx
movq 0xa534(%rip), %r14      # 0xcff0
movq %r14, %rdi
leaq 0x68d6(%rip), %rsi      # 0x939c
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
leaq 0xc(%rsp), %r14
movq 0x28(%rsp), %rcx
jmp 0x2d01
movl $0x9, %edx
movq %r12, %rdi
leaq 0x66d0(%rip), %rsi      # 0x91e0
callq 0x21f0
cmpl $0x8, %r14d
ja 0x2c84
movl %r14d, %eax
leaq 0x64db(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2c, %edx
movq %r12, %rdi
leaq 0x66da(%rip), %rsi      # 0x921b
callq 0x21f0
movl $0xee, %ebx
jmp 0x2ca8
movl $0x2d, %edx
movq %r12, %rdi
leaq 0x6752(%rip), %rsi      # 0x92b1
callq 0x21f0
cmpb $0x1, 0x640(%rsp)
jne 0x2d12
movl $0x11, %edx
movq %r12, %rdi
leaq 0x66f4(%rip), %rsi      # 0x9275
jmp 0x2d21
movl $0x4, %edx
movq %r12, %rdi
leaq 0x66b3(%rip), %rsi      # 0x9248
callq 0x21f0
xorl %ebx, %ebx
jmp 0x2ca8
movl $0x27, %edx
movq %r12, %rdi
leaq 0x669d(%rip), %rsi      # 0x924d
callq 0x21f0
cmpb $0x1, 0x640(%rsp)
leaq 0xc(%rsp), %r14
jne 0x2d64
movl $0x11, %edx
movq %r12, %rdi
leaq 0x669e(%rip), %rsi      # 0x9275
jmp 0x2d73
movl $0x26, %edx
movq %r12, %rdi
leaq 0x673a(%rip), %rsi      # 0x9325
callq 0x21f0
movl $0xc, %ebx
jmp 0x2ca8
movl $0x8, %edx
movq %r12, %rdi
leaq 0x6713(%rip), %rsi      # 0x931c
callq 0x21f0
movl $0xa, %ebx
jmp 0x2ca8
movl $0x2a, %edx
movq %r12, %rdi
leaq 0x66b8(%rip), %rsi      # 0x92df
callq 0x21f0
cmpb $0x1, 0x640(%rsp)
jne 0x2db1
movl $0x11, %edx
movq %r12, %rdi
leaq 0x662c(%rip), %rsi      # 0x9275
jmp 0x2dc0
movl $0x11, %edx
movq %r12, %rdi
leaq 0x66ad(%rip), %rsi      # 0x930a
callq 0x21f0
cmpb $0x1, 0x640(%rsp)
jne 0x2e03
movl $0x11, %edx
movq %r12, %rdi
leaq 0x65f6(%rip), %rsi      # 0x9275
jmp 0x2e12
movq %r12, %rdi
movl %r14d, %esi
callq 0x2290
movl $0xf, %edx
movq %r12, %rdi
leaq 0x66ae(%rip), %rsi      # 0x934c
callq 0x21f0
movl $0xe, %ebx
leaq 0xc(%rsp), %r14
movq 0x30(%rsp), %r13
movl %ebx, 0x38(%rsp,%r13,4)
movl $0x1, %edx
movq %r12, %rdi
leaq 0x6696(%rip), %rsi      # 0x935c
callq 0x21f0
movq %r12, %rdi
callq 0x2140
cmpb $0x0, 0x178(%rsp)
jne 0x2ce5
orl $0x10, %ebx
movl %ebx, 0x38(%rsp,%r13,4)
movq 0x28(%rsp), %rcx
cmpb $0x1, 0x640(%rsp)
jne 0x2cfc
orl $0x1, %ebx
movl %ebx, 0x38(%rsp,%r13,4)
movq 0x20(%rsp), %rbx
incq %r13
cmpq %rcx, %r13
jne 0x28ba
jmp 0x2e55
movl $0xd, %edx
movq %r12, %rdi
leaq 0x6566(%rip), %rsi      # 0x9287
callq 0x21f0
leaq 0xc(%rsp), %r14
cmpb $0x1, 0x178(%rsp)
jne 0x2d46
movl $0xe, %edx
movq %r12, %rdi
leaq 0x6551(%rip), %rsi      # 0x9295
jmp 0x2d55
movl $0xc, %edx
movq %r12, %rdi
leaq 0x654f(%rip), %rsi      # 0x92a4
callq 0x21f0
movl $0x4, %ebx
jmp 0x2cad
movl $0xd, %edx
movq %r12, %rdi
leaq 0x6514(%rip), %rsi      # 0x9287
callq 0x21f0
cmpb $0x1, 0x178(%rsp)
jne 0x2d93
movl $0xe, %edx
movq %r12, %rdi
leaq 0x6504(%rip), %rsi      # 0x9295
jmp 0x2da2
movl $0xc, %edx
movq %r12, %rdi
leaq 0x6502(%rip), %rsi      # 0x92a4
callq 0x21f0
movl $0x2, %ebx
jmp 0x2cad
movl $0xd, %edx
movq %r12, %rdi
leaq 0x64c7(%rip), %rsi      # 0x9287
callq 0x21f0
leaq 0xc(%rsp), %r14
cmpb $0x1, 0x178(%rsp)
jne 0x2de5
movl $0xe, %edx
movq %r12, %rdi
leaq 0x64b2(%rip), %rsi      # 0x9295
jmp 0x2df4
movl $0xc, %edx
movq %r12, %rdi
leaq 0x64b0(%rip), %rsi      # 0x92a4
callq 0x21f0
movl $0x6, %ebx
jmp 0x2cad
movl $0xd, %edx
movq %r12, %rdi
leaq 0x6475(%rip), %rsi      # 0x9287
callq 0x21f0
leaq 0xc(%rsp), %r14
cmpb $0x1, 0x178(%rsp)
jne 0x2e37
movl $0xe, %edx
movq %r12, %rdi
leaq 0x6460(%rip), %rsi      # 0x9295
jmp 0x2e46
movl $0xc, %edx
movq %r12, %rdi
leaq 0x645e(%rip), %rsi      # 0x92a4
callq 0x21f0
movl $0x8, %ebx
jmp 0x2cad
movq (%r12), %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
cmpl $0x0, 0x44(%rsp)
jle 0x2ee9
movq 0x18(%rsp), %rcx
cmpl $0x1, %ecx
adcl $0x0, %ecx
incq %rcx
xorl %ebx, %ebx
movq 0xa135(%rip), %r15      # 0xcfd0
movl 0x30(%rsp,%rcx,4), %eax
cmpl $-0x1, %eax
je 0x2ef4
shll $0x8, %ebx
movzbl %al, %eax
orl %eax, %ebx
decq %rcx
cmpq $0x1, %rcx
ja 0x2e9b
jmp 0x2ef9
movq 0xa112(%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
xorl %ebx, %ebx
jmp 0x2ef9
xorl %ebx, %ebx
movq 0xa0de(%rip), %r15      # 0xcfd0
jmp 0x2ef9
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x64bd(%rip), %rsi      # 0x93bd
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 0x64a3(%rip), %rsi      # 0x93ce
movl $0x2, %edx
movq %r15, %rdi
callq 0x21f0
movq (%r15), %rax
movq -0x18(%rax), %rcx
leaq (%r15,%rcx), %r14
cmpb $0x0, 0xe1(%r15,%rcx)
jne 0x2f66
movq %r14, %rdi
movl $0x20, %esi
callq 0x21b0
movb $0x1, 0xe1(%r14)
movq (%r15), %rax
movb $0x30, 0xe0(%r14)
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 0x2fee
movq %r14, %rdi
movl $0x20, %esi
callq 0x21b0
movb $0x1, 0xe1(%r14)
movb $0x20, 0xe0(%r14)
movl %ebx, %eax
addq $0xf48, %rsp            # imm = 0xF48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r9), %esi
movzwl %r15w, %edi
movl %ebp, %edx
callq 0x7c14
movl %eax, %ebx
leaq 0x178(%rsp), %r14
xorl %r12d, %r12d
movl $0x4c8, %edx            # imm = 0x4C8
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
leaq 0x74(%rsp), %rsi
movw %r12w, 0x100(%rsi)
leaq 0xe46(%rsp), %r15
movw %r12w, 0x100(%r15)
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xc, %r8d
callq 0x66de
leaq 0x640(%rsp), %rsi
movq %r14, %rdi
movl $0x800, %edx            # imm = 0x800
movq %r15, %rcx
movl %ebp, %r8d
callq 0x3f1b
movl %eax, %r14d
testb $0x1, 0x14(%rsp)
je 0x30fd
movq 0x9f40(%rip), %r15      # 0xcfd0
leaq 0x62c7(%rip), %rsi      # 0x935e
movl $0x19, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2290
movq %rax, %r15
leaq 0x62bf(%rip), %rsi      # 0x9378
movl $0x4, %edx
movq %rax, %rdi
callq 0x21f0
leaq 0xc(%rsp), %rsi
movq %r15, %rdi
callq 0x3dbb
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 0x640(%rsp), %r15
movl 0x10(%rsp), %ecx
movzwl 0xc(%rsp), %r8d
movl %ebx, %edi
movq %r15, %rsi
movl %r14d, %edx
movl %ebp, %r9d
callq 0x8138
incl %r12d
cmpl $0x64, %r12d
jne 0x3105
movl $0x2710, %edi           # imm = 0x2710
callq 0x2230
xorl %r12d, %r12d
jmp 0x3105
movq (%rbx,%r12,8), %rsi
movq 0x9eae(%rip), %rdi      # 0xcff0
callq 0x21d0
leaq 0x6077(%rip), %rsi      # 0x91c5
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20d0
callq 0x243c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2200
movq 0x9e7c(%rip), %rdi      # 0xcff0
leaq 0x6011(%rip), %rsi      # 0x918c
callq 0x21d0
movq %rax, %rdi
movl $0x3, %esi
callq 0x2290
leaq 0x6010(%rip), %rsi      # 0x91a4
jmp 0x314e
movq 0x9e33(%rip), %rdi      # 0xcfd0
leaq 0x6052(%rip), %rsi      # 0x91f6
callq 0x21d0
jmp 0x3163
nop