// File: /workspace/github_cpp_makefile_star2_O1/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:
cmpl $0x0, 0x24(%rdi)
je 0x486c
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl 0x18(%rdi), %eax
incl %eax
cltd
idivl 0x10(%rdi)
movl %edx, %r14d
movq 0x8915(%rip), %r12      # 0xcfd0
movq (%r12), %rdi
callq 0x3110
cmpl $0x1, 0x38(%rbx)
jne 0x46fc
leal -0x41(%rax), %ecx
cmpl $0x36, %ecx
ja 0x46e2
movabsq $0x44000900440009, %rdx # imm = 0x44000900440009
btq %rcx, %rdx
jb 0x4736
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
cmpl $0x3, %eax
ja 0x4743
leaq 0x49c1(%rip), %rcx      # 0x90b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x72, %eax
jg 0x4727
cmpl $0x56, %eax
jg 0x486f
cmpl $0x41, %eax
je 0x4895
cmpl $0x44, %eax
je 0x4882
cmpl $0x53, %eax
je 0x48c9
jmp 0x4743
leal -0x102(%rax), %ecx
cmpl $0x4, %ecx
jae 0x48a8
cmpb $0x1, 0x3c(%rbx)
jne 0x4743
movl %eax, %edi
callq 0x3350
movl 0x2c(%rbx), %eax
testl %eax, %eax
jle 0x4754
decl %eax
movl %eax, 0x2c(%rbx)
incl 0x14(%rbx)
jmp 0x478a
movq (%r12), %rdi
movl 0x34(%rbx), %eax
shll $0x8, %eax
movzwl %ax, %esi
callq 0x32a0
movslq 0x1c(%rbx), %rdi
shlq $0x3, %rdi
addq 0x8(%rbx), %rdi
leaq -0x24(%rbp), %rsi
movb $0x20, (%rsi)
callq 0x38b6
movl 0x1c(%rbx), %eax
incl %eax
cltd
idivl 0x10(%rbx)
movl %edx, 0x1c(%rbx)
movq 0x8(%rbx), %rax
movslq 0x18(%rbx), %rcx
leaq (%rax,%rcx,8), %rsi
movslq %r14d, %r15
leaq (%rax,%r15,8), %rdi
callq 0x3836
movl %r14d, 0x18(%rbx)
movzbl 0x28(%rbx), %eax
cmpl $0x51, %eax
jg 0x47d5
cmpl $0x44, %eax
je 0x47fb
cmpl $0x4c, %eax
jne 0x4831
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x3884
jmp 0x4831
cmpl $0x52, %eax
je 0x4817
cmpl $0x55, %eax
jne 0x4831
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x387a
jmp 0x4831
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x3864
jmp 0x4831
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x386e
movq (%r12), %rdi
movl 0x30(%rbx), %eax
shll $0x8, %eax
movzwl %ax, %esi
callq 0x32a0
movslq 0x18(%rbx), %rdi
shlq $0x3, %rdi
addq 0x8(%rbx), %rdi
leaq -0x24(%rbp), %rsi
movb $0x40, (%rsi)
callq 0x38b6
callq 0x33e0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
movb $0x1, %al
retq
cmpl $0x57, %eax
je 0x48b6
cmpl $0x61, %eax
je 0x4895
cmpl $0x64, %eax
jne 0x4743
cmpb $0x4c, 0x28(%rbx)
je 0x4743
movb $0x52, 0x28(%rbx)
jmp 0x4743
cmpb $0x52, 0x28(%rbx)
je 0x4743
movb $0x4c, 0x28(%rbx)
jmp 0x4743
cmpl $0x73, %eax
je 0x48c9
cmpl $0x77, %eax
jne 0x4743
cmpb $0x44, 0x28(%rbx)
je 0x4743
movb $0x55, 0x28(%rbx)
jmp 0x4743
cmpb $0x55, 0x28(%rbx)
je 0x4743
movb $0x44, 0x28(%rbx)
jmp 0x4743