// File: /workspace/github_cpp_makefile_star2_O3/Distrotech[P]stund/udp.cxx
// Function: sendMessage(int, char*, int, unsigned int, unsigned short, bool)
bool 
sendMessage( Socket fd, char* buf, int l, 
             unsigned int dstIp, unsigned short dstPort,
             bool verbose)
{
   assert( fd != INVALID_SOCKET );
    
   int s;
   if ( dstPort == 0 )
   {
      // sending on a connected port 
      assert( dstIp == 0 );
		
      s = send(fd,buf,l,0);
   }
   else
   {
      assert( dstIp != 0 );
      assert( dstPort != 0 );
        
      struct sockaddr_in to;
      int toLen = sizeof(to);
      memset(&to,0,toLen);
        
      to.sin_family = AF_INET;
      to.sin_port = htons(dstPort);
      to.sin_addr.s_addr = htonl(dstIp);
        
      s = sendto(fd, buf, l, 0,(sockaddr*)&to, toLen);
   }
    
   if ( s == SOCKET_ERROR )
   {
      int e = getErrno();
      switch (e)
      {
         case ECONNREFUSED:
         case EHOSTDOWN:
         case EHOSTUNREACH:
         {
            // quietly ignore this 
         }
         break;
         case EAFNOSUPPORT:
         {
            cerr << "err EAFNOSUPPORT in send" << endl;
         }
         break;
         default:
         {
            cerr << "err " << e << " "  << strerror(e) << " in send" << endl;
         }
      }
      return false;
   }
    
   if ( s == 0 )
   {
      cerr << "no data sent in send" << endl;
      return false;
   }
    
   if ( s != l )
   {
      if (verbose)
      {
         cerr << "only " << s << " out of " << l << " bytes sent" << endl;
      }
      return false;
   }
    
   return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
cmpl $-0x1, %edi
je 0x832d
movl %r9d, %ebp
movl %edx, %ebx
testw %r8w, %r8w
je 0x8194
testl %ecx, %ecx
je 0x834c
leaq 0x8(%rsp), %rax
movq $0x0, 0x8(%rax)
movw $0x2, (%rax)
rolw $0x8, %r8w
movw %r8w, 0x2(%rax)
bswapl %ecx
movl %ecx, 0x4(%rax)
movslq %ebx, %rdx
xorl %ecx, %ecx
movq %rax, %r8
movl $0x10, %r9d
callq 0x2050
jmp 0x81a6
testl %ecx, %ecx
jne 0x836b
movslq %ebx, %rdx
xorl %ecx, %ecx
callq 0x20e0
movq %rax, %r14
testl %r14d, %r14d
je 0x81e8
cmpl $-0x1, %r14d
jne 0x8200
callq 0x2040
movl (%rax), %r14d
leal -0x6f(%r14), %eax
cmpl $0x3, %eax
jb 0x8298
movq 0x4e20(%rip), %rbx      # 0xcff0
cmpl $0x61, %r14d
jne 0x82a5
leaq 0x240c(%rip), %rsi      # 0xa5ed
movl $0x18, %edx
jmp 0x81fb
movq 0x4e01(%rip), %rbx      # 0xcff0
leaq 0x2415(%rip), %rsi      # 0xa60b
movl $0x14, %edx
movq %rbx, %rdi
jmp 0x826c
cmpl %ebx, %r14d
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x829a
movq 0x4dd6(%rip), %r15      # 0xcff0
leaq 0x23ff(%rip), %rsi      # 0xa620
movl $0x5, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2290
movq %rax, %r14
leaq 0x23e3(%rip), %rsi      # 0xa626
movl $0x8, %edx
movq %rax, %rdi
callq 0x21f0
movq %r14, %rdi
movl %ebx, %esi
callq 0x2290
movq %rax, %rbx
leaq 0x23cb(%rip), %rsi      # 0xa62f
movl $0xb, %edx
movq %rax, %rdi
callq 0x21f0
movq (%rbx), %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
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x235a(%rip), %rsi      # 0xa606
movl $0x4, %edx
movq %rbx, %rdi
callq 0x21f0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x2290
movq %rax, %rbx
leaq 0x11b7(%rip), %rsi      # 0x9485
movl $0x1, %edx
movq %rax, %rdi
callq 0x21f0
movl %r14d, %edi
callq 0x20a0
testq %rax, %rax
je 0x8303
movq %rax, %r14
movq %rax, %rdi
callq 0x20c0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
jmp 0x831c
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2280
leaq 0x22da(%rip), %rsi      # 0xa5fd
movl $0x8, %edx
jmp 0x81fb
leaq 0x2132(%rip), %rdi      # 0xa466
leaq 0x2140(%rip), %rsi      # 0xa47b
leaq 0x224b(%rip), %rcx      # 0xa58d
movl $0xbb, %edx
callq 0x2120
leaq 0x228f(%rip), %rdi      # 0xa5e2
leaq 0x2121(%rip), %rsi      # 0xa47b
leaq 0x222c(%rip), %rcx      # 0xa58d
movl $0xc7, %edx
callq 0x2120
leaq 0x2265(%rip), %rdi      # 0xa5d7
leaq 0x2102(%rip), %rsi      # 0xa47b
leaq 0x220d(%rip), %rcx      # 0xa58d
movl $0xc1, %edx
callq 0x2120