// File: /workspace/github_cpp_makefile_star2_O2/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 0x4160
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 0x7fe5(%rip), %r12      # 0xbfd0
movq (%r12), %rdi
callq 0x3100
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
cmpl $0x3, %eax
ja 0x403c
leaq 0x406b(%rip), %rcx      # 0x8070
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x55, 0x28(%rbx)
je 0x403c
movb $0x44, 0x28(%rbx)
jmp 0x403c
cmpb $0x52, 0x28(%rbx)
je 0x403c
movb $0x4c, 0x28(%rbx)
jmp 0x403c
cmpb $0x4c, 0x28(%rbx)
je 0x403c
movb $0x52, 0x28(%rbx)
jmp 0x403c
cmpb $0x44, 0x28(%rbx)
je 0x403c
movb $0x55, 0x28(%rbx)
movl 0x2c(%rbx), %eax
testl %eax, %eax
jle 0x404d
decl %eax
movl %eax, 0x2c(%rbx)
incl 0x14(%rbx)
jmp 0x4083
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 0x410b
cmpl $0x4c, %eax
je 0x40d3
cmpl $0x52, %eax
je 0x40ef
cmpl $0x55, %eax
jne 0x4125
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37ee
jmp 0x4125
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37f8
jmp 0x4125
shlq $0x3, %r15
addq 0x8(%rbx), %r15
leaq -0x24(%rbp), %rsi
movl $0x1, (%rsi)
movq %r15, %rdi
callq 0x37e2
jmp 0x4125
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