// File: st0ne[P]XReflectorPlus/dxrfd.cpp
// Function: playback(void*)
static void *playback(void *arg)
{
   struct rcd *temp_rcd = (struct rcd *)arg;
   struct sigaction act;
   unsigned short int j;
   unsigned short int i;
   struct timespec nanos;

   act.sa_handler = sigCatch;
   sigemptyset(&act.sa_mask);
   act.sa_flags = SA_RESTART;
   if (sigaction(SIGTERM, &act, 0) != 0)
   {
      traceit("sigaction-TERM failed, error=%d\n", errno);
      keep_running = false;
      pthread_exit(NULL);
   }
   if (sigaction(SIGINT, &act, 0) != 0)
   {
      traceit("sigaction-INT failed, error=%d\n", errno);
      keep_running = false;
      pthread_exit(NULL);
   }

   /* delay 5 seconds here */
   sleep(5);

   /***
   if (temp_rcd->recvlen == 56)
      traceit("playback started for user=%.8s, streamid %d,%d\n", 
            &(temp_rcd->data[0][42]), temp_rcd->data[0][12], temp_rcd->data[0][13]);
   else
      traceit("playback started for user=%.8s, streamid %d,%d\n",
            &(temp_rcd->data[0][44]), temp_rcd->data[0][14], temp_rcd->data[0][15]);
   ***/

   /* first packet is header */

   /*** MUST CHANGE rpt1 and rpt2 if temp_rcd->recvlen is 58 ***/
   for (j = 0; j < 5; j++)
      sendto(ref_sock, (char *)temp_rcd->data[0], temp_rcd->recvlen, 0,
             (struct sockaddr *)&(temp_rcd->sin),
             sizeof(struct sockaddr_in));

   /*** header sent ***/
   i = 1;
   
   while ((keep_running) && (i < temp_rcd->idx))
   {
      time(&(temp_rcd->ts));
      sendto(ref_sock, (char *)temp_rcd->data[i], 
             (temp_rcd->recvlen == 56)?27:29,   /*** ? 32 ***/
             0,(struct sockaddr *)&(temp_rcd->sin),
             sizeof(struct sockaddr_in));
      i ++;
      nanos.tv_sec = 0;
      nanos.tv_nsec = 17000000;
      nanosleep(&nanos,0);
   }

   /***
   if (temp_rcd->recvlen == 56)
      traceit("Finished playback for user=%.8s, streamid %d,%d\n",
            &(temp_rcd->data[0][42]), temp_rcd->data[0][12], temp_rcd->data[0][13]);
   else
      traceit("Finished playback for user=%.8s, streamid %d,%d\n",
            &(temp_rcd->data[0][44]), temp_rcd->data[0][14], temp_rcd->data[0][15]);
   ***/

   temp_rcd->locked = false;

   pthread_exit(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq -0xaade(%rip), %rax     # 0x3d50
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
addq $0x8, %rdi
callq 0x33e0
movl $0x10000000, -0x20(%rbp) # imm = 0x10000000
movl $0xf, %edi
leaq -0xa8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x33f0
cmpl $0x0, %eax
je 0xe88b
callq 0x3050
movl (%rax), %esi
leaq 0x8836(%rip), %rdi      # 0x170aa
movb $0x0, %al
callq 0x3820
movb $0x0, 0x10a62(%rip)     # 0x1f2e4
xorl %eax, %eax
movl %eax, %edi
callq 0x3510
movl $0x2, %edi
leaq -0xa8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x33f0
cmpl $0x0, %eax
je 0xe8ca
callq 0x3050
movl (%rax), %esi
leaq 0x8818(%rip), %rdi      # 0x170cb
movb $0x0, %al
callq 0x3820
movb $0x0, 0x10a23(%rip)     # 0x1f2e4
xorl %eax, %eax
movl %eax, %edi
callq 0x3510
movl $0x5, %edi
callq 0x3220
movw $0x0, -0xaa(%rbp)
movzwl -0xaa(%rbp), %eax
cmpl $0x5, %eax
jge 0xe929
movl 0x109f1(%rip), %edi     # 0x1f2e0
movq -0x10(%rbp), %rsi
addq $0x24, %rsi
movq -0x10(%rbp), %rax
movswq 0x20(%rax), %rdx
movq -0x10(%rbp), %r8
addq $0x10, %r8
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x3080
movw -0xaa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xaa(%rbp)
jmp 0xe8dd
movw $0x1, -0xac(%rbp)
xorl %eax, %eax
testb $0x1, 0x109a9(%rip)     # 0x1f2e4
movb %al, -0xc1(%rbp)
je 0xe95d
movzwl -0xac(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x22(%rcx), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0xe96c
jmp 0xea02
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x32a0
movl 0x10961(%rip), %edi     # 0x1f2e0
movq -0x10(%rbp), %rsi
addq $0x24, %rsi
movzwl -0xac(%rbp), %eax
imulq $0x3a, %rax, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movswl 0x20(%rax), %edx
movl $0x1d, %eax
movl $0x1b, %ecx
cmpl $0x38, %edx
cmovel %ecx, %eax
movslq %eax, %rdx
movq -0x10(%rbp), %r8
addq $0x10, %r8
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x3080
movw -0xac(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xac(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x1036640, -0xb8(%rbp) # imm = 0x1036640
leaq -0xc0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3100
jmp 0xe932
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x3510
nopw %cs:(%rax,%rax)