// File: /workspace/github_cpp_makefile_star2_O2/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 0x46ce
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 0x7adb(%rip), %r12      # 0xbfd0
movq (%r12), %rdi
callq 0x3100
cmpl $0x1, 0x38(%rbx)
jne 0x453a
leal -0x41(%rax), %ecx
cmpl $0x36, %ecx
ja 0x451c
movabsq $0x44000900440009, %rdx # imm = 0x44000900440009
btq %rcx, %rdx
jb 0x4579
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
cmpl $0x3, %eax
ja 0x45aa
leaq 0x3b83(%rip), %rcx      # 0x80b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leal -0x102(%rax), %ecx
cmpl $0x4, %ecx
jb 0x4579
cmpl $0x41, %eax
je 0x4588
cmpl $0x44, %eax
je 0x45a0
cmpl $0x53, %eax
je 0x4594
cmpl $0x77, %eax
je 0x456d
cmpl $0x61, %eax
je 0x4588
cmpl $0x64, %eax
je 0x45a0
cmpl $0x73, %eax
je 0x4594
cmpl $0x57, %eax
jne 0x45aa
cmpb $0x44, 0x28(%rbx)
je 0x45aa
movb $0x55, 0x28(%rbx)
jmp 0x45aa
cmpb $0x1, 0x3c(%rbx)
jne 0x45aa
movl %eax, %edi
callq 0x3360
jmp 0x45aa
cmpb $0x52, 0x28(%rbx)
je 0x45aa
movb $0x4c, 0x28(%rbx)
jmp 0x45aa
cmpb $0x55, 0x28(%rbx)
je 0x45aa
movb $0x44, 0x28(%rbx)
jmp 0x45aa
cmpb $0x4c, 0x28(%rbx)
je 0x45aa
movb $0x52, 0x28(%rbx)
movl 0x2c(%rbx), %eax
testl %eax, %eax
jle 0x45bb
decl %eax
movl %eax, 0x2c(%rbx)
incl 0x14(%rbx)
jmp 0x45f1
movq (%r12), %rdi
movl 0x34(%rbx), %eax
shll $0x8, %eax
movzwl %ax, %esi
callq 0x32c0
movslq 0x1c(%rbx), %rdi
shlq $0x3, %rdi
addq 0x8(%rbx), %rdi
leaq -0x24(%rbp), %rsi
movb $0x20, (%rsi)
callq 0x382a
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 0x37aa
movl %r14d, 0x18(%rbx)
movzbl 0x28(%rbx), %eax
cmpl $0x44, %eax
je 0x4679
cmpl $0x4c, %eax
je 0x4641
cmpl $0x52, %eax
je 0x465d
cmpl $0x55, %eax
jne 0x4693
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37ee
jmp 0x4693
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37f8
jmp 0x4693
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37e2
jmp 0x4693
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37d8
movq (%r12), %rdi
movl 0x30(%rbx), %eax
shll $0x8, %eax
movzwl %ax, %esi
callq 0x32c0
movslq 0x18(%rbx), %rdi
shlq $0x3, %rdi
addq 0x8(%rbx), %rdi
leaq -0x24(%rbp), %rsi
movb $0x40, (%rsi)
callq 0x382a
callq 0x3400
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
movb $0x1, %al
retq
nop