// File: /workspace/github_cpp_makefile_star2_O2/Distrotech[P]stund/stun.cxx
// Function: stunSendTest(int, StunAddress4&, StunAtrString const&, StunAtrString const&, int, bool)
static void 
stunSendTest( Socket myFd, StunAddress4& dest, 
              const StunAtrString& username, const StunAtrString& password, 
              int testNum, bool verbose )
{ 
   assert( dest.addr != 0 );
   assert( dest.port != 0 );
	
   bool changePort=false;
   bool changeIP=false;
   bool discard=false;
	
   switch (testNum)
   {
      case 1:
      case 10:
      case 11:
         break;
      case 2:
         //changePort=true;
         changeIP=true;
         break;
      case 3:
         changePort=true;
         break;
      case 4:
         changeIP=true;
         break;
      case 5:
         discard=true;
         break;
      default:
         cerr << "Test " << testNum <<" is unkown\n";
         assert(0);
   }
	
   StunMessage req;
   memset(&req, 0, sizeof(StunMessage));
	
   stunBuildReqSimple( &req, username, 
                       changePort , changeIP , 
                       testNum );
	
   char buf[STUN_MAX_MESSAGE_SIZE];
   int len = STUN_MAX_MESSAGE_SIZE;
	
   len = stunEncodeMessage( req, buf, len, password,verbose );
	
   if ( verbose )
   {
      clog << "About to send msg of len " << len << " to " << dest << endl;
   }
	
   sendMessage( myFd, buf, len, dest.addr, dest.port, verbose );
	
   // add some delay so the packets don't get sent too quickly 
#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

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xcd8, %rsp            # imm = 0xCD8
cmpl $0x0, 0x4(%rsi)
je 0x5a97
movq %rsi, %r14
cmpw $0x0, (%rsi)
je 0x5ab6
movl %r8d, %r15d
movq %rcx, 0x8(%rsp)
movl %edi, 0x4(%rsp)
leal -0x1(%r15), %r12d
cmpl $0xb, %r12d
jae 0x5a4b
movl $0x61f, %eax            # imm = 0x61F
btl %r12d, %eax
jae 0x5a4b
movl %r9d, %ebp
movq %rdx, %r13
leaq 0x810(%rsp), %rbx
movl $0x4c8, %edx            # imm = 0x4C8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2110
pushq $0x4
popq %rax
xorl %edx, %edx
btl %r12d, %eax
setb %dl
pushq $0xa
popq %rax
xorl %ecx, %ecx
btl %r12d, %eax
setb %cl
movq %rbx, %rdi
movq %r13, %rsi
movl %r15d, %r8d
callq 0x562c
movzbl %bpl, %ebp
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
movl $0x800, %edx            # imm = 0x800
movq 0x8(%rsp), %rcx
movl %ebp, %r8d
callq 0x3849
movl %eax, %r15d
testb %bpl, %bpl
je 0x5a13
movq 0x55e1(%rip), %rdi      # 0xafb8
leaq 0x1980(%rip), %rsi      # 0x735e
callq 0x21d0
movq %rax, %rdi
movl %r15d, %esi
callq 0x22a0
leaq 0x1983(%rip), %rsi      # 0x7378
movq %rax, %rdi
callq 0x21d0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3732
movq %rbx, %rdi
callq 0x20c0
movl 0x4(%r14), %ecx
movzwl (%r14), %r8d
leaq 0x10(%rsp), %rsi
movl 0x4(%rsp), %edi
movl %r15d, %edx
movl %ebp, %r9d
callq 0x6b66
movl $0x2710, %edi           # imm = 0x2710
callq 0x2240
addq $0xcd8, %rsp            # imm = 0xCD8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x559e(%rip), %rdi      # 0xaff0
leaq 0x28eb(%rip), %rsi      # 0x8344
callq 0x21d0
movq %rax, %rdi
movl %r15d, %esi
callq 0x22a0
leaq 0x28da(%rip), %rsi      # 0x834a
movq %rax, %rdi
callq 0x21d0
leaq 0x2b6c(%rip), %rdi      # 0x85eb
leaq 0x1cc7(%rip), %rsi      # 0x774d
leaq 0x2854(%rip), %rcx      # 0x82e1
movl $0x6e5, %edx            # imm = 0x6E5
callq 0x2120
leaq 0x2428(%rip), %rdi      # 0x7ec6
leaq 0x1ca8(%rip), %rsi      # 0x774d
leaq 0x2835(%rip), %rcx      # 0x82e1
movl $0x6c9, %edx            # imm = 0x6C9
callq 0x2120
leaq 0x2418(%rip), %rdi      # 0x7ed5
leaq 0x1c89(%rip), %rsi      # 0x774d
leaq 0x2816(%rip), %rcx      # 0x82e1
movl $0x6ca, %edx            # imm = 0x6CA
callq 0x2120