// File: /workspace/github_cpp_makefile_star2_O1/matallui[P]nibble-curses/src/CSingle.cpp
// Function: CSingle::Move()
bool CSingle::Move ( void )
{
  if ( !m_lives ) return true;
  
  int next_head = (m_head + 1) % m_max_size;
  
  int key = getch();
  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;
  }
  
  // snake has to increase
  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;
  }
  
  // update new head coordinates
  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 0x428d
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 0x8ebd(%rip), %r12      # 0xcfd0
movq (%r12), %rdi
callq 0x3110
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
cmpl $0x3, %eax
ja 0x4164
leaq 0x4f43(%rip), %rcx      # 0x9070
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x55, 0x28(%rbx)
je 0x4164
movb $0x44, 0x28(%rbx)
jmp 0x4164
cmpb $0x52, 0x28(%rbx)
je 0x4164
movb $0x4c, 0x28(%rbx)
jmp 0x4164
cmpb $0x4c, 0x28(%rbx)
je 0x4164
movb $0x52, 0x28(%rbx)
jmp 0x4164
cmpb $0x44, 0x28(%rbx)
je 0x4164
movb $0x55, 0x28(%rbx)
movl 0x2c(%rbx), %eax
testl %eax, %eax
jle 0x4175
decl %eax
movl %eax, 0x2c(%rbx)
incl 0x14(%rbx)
jmp 0x41ab
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 0x41f6
cmpl $0x44, %eax
je 0x421c
cmpl $0x4c, %eax
jne 0x4252
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x3884
jmp 0x4252
cmpl $0x52, %eax
je 0x4238
cmpl $0x55, %eax
jne 0x4252
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x387a
jmp 0x4252
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x3864
jmp 0x4252
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