// File: matallui[P]nibble-curses/src/CMultPC.cpp
// Function: CMultPC::Move()
bool CMultPC::Move ( void )
{
  if ( !m_lives ) return true;
  
  int next_head = (m_head + 1) % m_max_size;
  int key = getch();
  
  if ( m_playerid == 1 )
  {
    switch ( key )
    {
      case KEY_UP:
	if ( m_direction != 'D' ) m_direction = 'U';
	break;
      case KEY_DOWN:
	if ( m_direction != 'U' ) m_direction = 'D';
	break;
      case KEY_LEFT:
	if ( m_direction != 'R' ) m_direction = 'L';
	break;
      case KEY_RIGHT:
	if ( m_direction != 'L' ) m_direction = 'R';
	break;
      case 'W':
      case 'w':
      case 'S':
      case 's':
      case 'A':
      case 'a':
      case 'D':
      case 'd':
	if ( m_friend_alive )
	  ungetch ( key );
	break;
    }
  }
  else
  {
    switch ( key )
    {
      case 'W':
      case 'w':
	if ( m_direction != 'D' ) m_direction = 'U';
	break;
      case 'S':
      case 's':
	if ( m_direction != 'U' ) m_direction = 'D';
	break;
      case 'A':
      case 'a':
	if ( m_direction != 'R' ) m_direction = 'L';
	break;
      case 'D':
      case 'd':
	if ( m_direction != 'L' ) m_direction = 'R';
	break;
      case KEY_UP:
      case KEY_DOWN:
      case KEY_LEFT:
      case KEY_RIGHT:
	if ( m_friend_alive )
	  ungetch ( key );
	break;
    }
  }
  
  if ( m_delay > 0 )
  {
    m_delay --;
    m_size ++;
  }
  else
  {
    attrset ( COLOR_PAIR(m_cp_erase) );
    m_body[m_tail].Draw( ' ' );
    m_tail = (m_tail + 1) % m_max_size;
  }
  
  m_body[next_head] = m_body[m_head];
  m_head = next_head;
  
  switch ( m_direction )
  {
    case 'U':
      m_body[m_head].decX(1);
      break;
    case 'D':
      m_body[m_head].incX(1);
      break;
    case 'L':
      m_body[m_head].decY(1);
      break;
    case 'R':
      m_body[m_head].incY(1);
      break;
  }
  
  attrset ( COLOR_PAIR(m_cp_draw) );
  m_body[m_head].Draw ( '@' );
  refresh();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x24(%rax)
jne 0x55d3
movb $0x1, -0x1(%rbp)
jmp 0x599b
movq -0x38(%rbp), %rcx
movl 0x18(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x10(%rcx)
movl %edx, -0x14(%rbp)
movq 0xa9e5(%rip), %rax      # 0xffd0
movq (%rax), %rdi
callq 0x3130
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, -0x18(%rbp)
cmpl $0x1, 0x38(%rax)
jne 0x571e
movl -0x18(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $0x41, %eax
je 0x5705
jmp 0x5617
movl -0x3c(%rbp), %eax
subl $0x44, %eax
je 0x5705
jmp 0x5625
movl -0x3c(%rbp), %eax
subl $0x53, %eax
je 0x5705
jmp 0x5633
movl -0x3c(%rbp), %eax
subl $0x57, %eax
je 0x5705
jmp 0x5641
movl -0x3c(%rbp), %eax
subl $0x61, %eax
je 0x5705
jmp 0x564f
movl -0x3c(%rbp), %eax
subl $0x64, %eax
je 0x5705
jmp 0x565d
movl -0x3c(%rbp), %eax
subl $0x73, %eax
je 0x5705
jmp 0x566b
movl -0x3c(%rbp), %eax
subl $0x77, %eax
je 0x5705
jmp 0x5679
movl -0x3c(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x56c0
jmp 0x5685
movl -0x3c(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x56a9
jmp 0x5691
movl -0x3c(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0x56d7
jmp 0x569d
movl -0x3c(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0x56ee
jmp 0x5719
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x44, %eax
je 0x56be
movq -0x38(%rbp), %rax
movb $0x55, 0x28(%rax)
jmp 0x5719
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x55, %eax
je 0x56d5
movq -0x38(%rbp), %rax
movb $0x44, 0x28(%rax)
jmp 0x5719
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x52, %eax
je 0x56ec
movq -0x38(%rbp), %rax
movb $0x4c, 0x28(%rax)
jmp 0x5719
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x4c, %eax
je 0x5703
movq -0x38(%rbp), %rax
movb $0x52, 0x28(%rax)
jmp 0x5719
movq -0x38(%rbp), %rax
testb $0x1, 0x3c(%rax)
je 0x5717
movl -0x18(%rbp), %edi
callq 0x3410
jmp 0x5719
jmp 0x57fa
movl -0x18(%rbp), %eax
movl %eax, -0x40(%rbp)
subl $0x41, %eax
je 0x57b6
jmp 0x572f
movl -0x40(%rbp), %eax
subl $0x44, %eax
je 0x57cd
jmp 0x573d
movl -0x40(%rbp), %eax
subl $0x53, %eax
je 0x579f
jmp 0x5747
movl -0x40(%rbp), %eax
subl $0x57, %eax
je 0x5788
jmp 0x5751
movl -0x40(%rbp), %eax
subl $0x61, %eax
je 0x57b6
jmp 0x575b
movl -0x40(%rbp), %eax
subl $0x64, %eax
je 0x57cd
jmp 0x5765
movl -0x40(%rbp), %eax
subl $0x73, %eax
je 0x579f
jmp 0x576f
movl -0x40(%rbp), %eax
subl $0x77, %eax
je 0x5788
jmp 0x5779
movl -0x40(%rbp), %eax
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
subl $0x4, %eax
jb 0x57e4
jmp 0x57f8
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x44, %eax
je 0x579d
movq -0x38(%rbp), %rax
movb $0x55, 0x28(%rax)
jmp 0x57f8
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x55, %eax
je 0x57b4
movq -0x38(%rbp), %rax
movb $0x44, 0x28(%rax)
jmp 0x57f8
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x52, %eax
je 0x57cb
movq -0x38(%rbp), %rax
movb $0x4c, 0x28(%rax)
jmp 0x57f8
movq -0x38(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x4c, %eax
je 0x57e2
movq -0x38(%rbp), %rax
movb $0x52, 0x28(%rax)
jmp 0x57f8
movq -0x38(%rbp), %rax
testb $0x1, 0x3c(%rax)
je 0x57f6
movl -0x18(%rbp), %edi
callq 0x3410
jmp 0x57f8
jmp 0x57fa
movq -0x38(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jle 0x581c
movq -0x38(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x2c(%rax)
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0x5870
movq -0x38(%rbp), %rax
movq 0xa7a9(%rip), %rcx      # 0xffd0
movq (%rcx), %rdi
movl 0x34(%rax), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
callq 0x3330
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq 0x1c(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movb $0x20, -0x19(%rbp)
leaq -0x19(%rbp), %rsi
callq 0x3e20
movq -0x38(%rbp), %rcx
movl 0x1c(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x10(%rcx)
movq -0x38(%rbp), %rax
movl %edx, 0x1c(%rax)
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
movslq 0x18(%rcx), %rcx
leaq (%rax,%rcx,8), %rsi
movslq -0x14(%rbp), %rcx
leaq (%rax,%rcx,8), %rdi
callq 0x3c80
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, 0x18(%rax)
movsbl 0x28(%rax), %eax
addl $-0x44, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x11, %eax
ja 0x5953
movq -0x48(%rbp), %rax
leaq 0x68cc(%rip), %rcx      # 0xc184
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq 0x18(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl $0x1, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x3d60
jmp 0x5953
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq 0x18(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl $0x1, -0x24(%rbp)
leaq -0x24(%rbp), %rsi
callq 0x3d20
jmp 0x5953
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq 0x18(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl $0x1, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x3d80
jmp 0x5953
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq 0x18(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl $0x1, -0x2c(%rbp)
leaq -0x2c(%rbp), %rsi
callq 0x3d40
movq -0x38(%rbp), %rax
movq 0xa672(%rip), %rcx      # 0xffd0
movq (%rcx), %rdi
movl 0x30(%rax), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
callq 0x3330
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq 0x18(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movb $0x40, -0x2d(%rbp)
leaq -0x2d(%rbp), %rsi
callq 0x3e20
callq 0x34c0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)