// File: matallui[P]nibble-curses/src/CMultNet.cpp
// Function: CMultNet::Move()
bool CMultNet::Move ( void )
{
  if ( !m_lives ) return true;
  
  char buffer[10];
  bzero ( buffer, 10 );
  
  if ( m_isHost )	// the snake controlled by this computer
  {
    CSingle::Move();
    sprintf ( buffer, "M%c", m_direction );
    if ( ! m_socket->Send ( buffer, 3 ) ) return false;
    bzero ( buffer, 3 );
    if ( ! m_socket->Recv ( buffer, 3 ) ) return false;
    if ( buffer[0] != 'O' || buffer[1] != 'K' ) return false;
  }
  else			// the snake controlled by remote computer
  {
    if ( ! m_socket->Recv ( buffer, 3 ) ) return false;
    if ( buffer[0] != 'M' ) return false;
    m_direction = buffer[1];
    
    switch ( m_direction )
    {
      case 'U':
	ungetch ( KEY_UP );
	break;
      case 'D':
	ungetch ( KEY_DOWN );
	break;
      case 'L':
	ungetch ( KEY_LEFT );
	break;
      case 'R':
	ungetch ( KEY_RIGHT );
	break;
      default:
	return false;
	break;
    }
    CSingle::Move();
    sprintf ( buffer, "OK" );
    if ( ! m_socket->Send ( buffer, 3 ) ) return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x24(%rax)
jne 0x5aa3
movb $0x1, -0x1(%rbp)
jmp 0x5c62
leaq -0x1a(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x31b0
movq -0x38(%rbp), %rax
testb $0x1, 0x3d(%rax)
je 0x5b70
movq -0x38(%rbp), %rdi
callq 0x4ba0
movq -0x38(%rbp), %rax
leaq -0x1a(%rbp), %rdi
movsbl 0x28(%rax), %edx
leaq 0x674d(%rip), %rsi      # 0xc22a
movb $0x0, %al
callq 0x3090
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x1a(%rbp), %rsi
movl $0x3, -0x20(%rbp)
movq (%rdi), %rax
leaq -0x20(%rbp), %rdx
callq *0x20(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0x5b09
jmp 0x5b12
movb $0x0, -0x1(%rbp)
jmp 0x5c62
leaq -0x1a(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x31b0
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x1a(%rbp), %rsi
movl $0x3, -0x24(%rbp)
movq (%rdi), %rax
leaq -0x24(%rbp), %rdx
callq *0x28(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0x5b47
jmp 0x5b50
movb $0x0, -0x1(%rbp)
jmp 0x5c62
movsbl -0x1a(%rbp), %eax
cmpl $0x4f, %eax
jne 0x5b62
movsbl -0x19(%rbp), %eax
cmpl $0x4b, %eax
je 0x5b6b
movb $0x0, -0x1(%rbp)
jmp 0x5c62
jmp 0x5c5e
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x1a(%rbp), %rsi
movl $0x3, -0x28(%rbp)
movq (%rdi), %rax
leaq -0x28(%rbp), %rdx
callq *0x28(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0x5b95
jmp 0x5b9e
movb $0x0, -0x1(%rbp)
jmp 0x5c62
movsbl -0x1a(%rbp), %eax
cmpl $0x4d, %eax
je 0x5bb0
movb $0x0, -0x1(%rbp)
jmp 0x5c62
movq -0x38(%rbp), %rax
movb -0x19(%rbp), %cl
movb %cl, 0x28(%rax)
movsbl 0x28(%rax), %eax
addl $-0x44, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x11, %eax
ja 0x5c10
movq -0x40(%rbp), %rax
leaq 0x6601(%rip), %rcx      # 0xc1d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x103, %edi            # imm = 0x103
callq 0x3410
jmp 0x5c16
movl $0x102, %edi            # imm = 0x102
callq 0x3410
jmp 0x5c16
movl $0x104, %edi            # imm = 0x104
callq 0x3410
jmp 0x5c16
movl $0x105, %edi            # imm = 0x105
callq 0x3410
jmp 0x5c16
movb $0x0, -0x1(%rbp)
jmp 0x5c62
movq -0x38(%rbp), %rdi
callq 0x4ba0
leaq -0x1a(%rbp), %rdi
leaq 0x6604(%rip), %rsi      # 0xc22e
movb $0x0, %al
callq 0x3090
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x1a(%rbp), %rsi
movl $0x3, -0x2c(%rbp)
movq (%rdi), %rax
leaq -0x2c(%rbp), %rdx
callq *0x20(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0x5c56
jmp 0x5c5c
movb $0x0, -0x1(%rbp)
jmp 0x5c62
jmp 0x5c5e
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)