// File: st0ne[P]XReflectorPlus/dxrfd.cpp
// Function: link_to_xrf(char, char*, char, char*)
static int link_to_xrf(char local_mod, char *ref, char remote_mod, char *IP)
{
   short counter;
   char request[CALL_SIZE + 3];
   struct sockaddr_in sin;
   a_user_list_type::iterator user_pos;

   if (remote_mod == 'X')
      remote_mod = ' ';  /* unlink request */
   else
   {
      user_pos = a_user_list.find(IP);
      if (user_pos != a_user_list.end())
      {
         /* It already exists */
         traceit("Remote reflector [%s] ip=%s already linked, unlink first\n", ref, IP); 
         return 0;
      }
   }

   /* send the request to the remote XRF reflector */
   strcpy(request, OWNER);
   request[8] = local_mod;
   request[9] = remote_mod;
   request[10] = '\0';

   memset(&sin,0,sizeof(struct sockaddr_in));
   sin.sin_family = AF_INET;
   sin.sin_port = htons(LISTEN_PORT);
   sin.sin_addr.s_addr = inet_addr(IP);

   traceit("Sending request [%s] to reflector %s\n", request, ref);

   for (counter = 0; counter < 5; counter++)
      sendto(srv_sock, request, CALL_SIZE + 3,
             0,(struct sockaddr *)&sin,
             sizeof(struct sockaddr_in));

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movb %dl, %al
movb %dil, %dl
movb %dl, -0x5(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x13d50
movsbl -0x11(%rbp), %eax
cmpl $0x58, %eax
jne 0x103f9
movb $0x20, -0x11(%rbp)
jmp 0x104ef
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3520
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x11f00
jmp 0x1042d
leaq 0xef4c(%rip), %rdi      # 0x1f380
leaq -0x70(%rbp), %rsi
callq 0x14570
movq %rax, -0xa8(%rbp)
jmp 0x10446
movq -0xa8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31e0
leaq -0x71(%rbp), %rdi
callq 0x3330
leaq 0xef0e(%rip), %rdi      # 0x1f380
callq 0x13dd0
movq %rax, -0x90(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x13da0
testb $0x1, %al
jne 0x10494
jmp 0x104ed
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq 0x7c08(%rip), %rdi      # 0x180ab
movb $0x0, %al
callq 0x3820
movl $0x0, -0x4(%rbp)
jmp 0x1059d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x104df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31e0
leaq -0x71(%rbp), %rdi
callq 0x3330
jmp 0x105a9
jmp 0x104ef
leaq -0x2d(%rbp), %rdi
leaq 0x12686(%rip), %rsi     # 0x22b80
callq 0x32b0
movb -0x5(%rbp), %al
movb %al, -0x25(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x24(%rbp)
movb $0x0, -0x23(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x31a0
movw $0x2, -0x40(%rbp)
movl 0xedbd(%rip), %eax      # 0x1f2e8
movzwl %ax, %edi
callq 0x3070
movw %ax, -0x3e(%rbp)
movq -0x20(%rbp), %rdi
callq 0x32f0
movl %eax, -0x3c(%rbp)
leaq -0x2d(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq 0x7b93(%rip), %rdi      # 0x180e5
movb $0x0, %al
callq 0x3820
movw $0x0, -0x22(%rbp)
movswl -0x22(%rbp), %eax
cmpl $0x5, %eax
jge 0x10596
movl 0xed6a(%rip), %edi      # 0x1f2d8
leaq -0x2d(%rbp), %rsi
movl $0xb, %edx
xorl %ecx, %ecx
leaq -0x40(%rbp), %r8
movl $0x10, %r9d
callq 0x3080
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
jmp 0x1055f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x3500
nopw %cs:(%rax,%rax)