// File: /workspace/github_cpp_makefile_star2_O1/matallui[P]nibble-curses/src/CMultPC.cpp
// Function: CMultPC::Collision(CObstacle*, int const&, CSnake*)
bool CMultPC::Collision ( CObstacle * const obstacles, int const & num_obstacles, CSnake * sfriend )
{
  if ( !m_lives ) return false;
  
  // collision with obstacles
  for ( int i = 0; i < num_obstacles; i++ )
    if ( obstacles[i].Intersection ( m_body[m_head] ) )
    {
      Die ( dynamic_cast <CMultPC*> (sfriend) );
      m_score -= 1000;
      return true;
    }
  
  // collision with itself
  int i = m_tail;
  for ( int k = 0; k < m_size-3; k++ )
  {
    if ( m_body[m_head] == m_body[i] )
    {
      Die ( dynamic_cast <CMultPC*> (sfriend) );
      m_score -= 1000;
      return true;
    }
    i = (i + 1) % m_max_size;
  }
  
  // collision with friend
  if ( sfriend ) 
    if ( sfriend->hasPoint ( m_body[m_head] ) )
    {
      Die ( dynamic_cast <CMultPC*> (sfriend) );
      m_score -= 1000;
      return true;
    }
  
  return false;
}

// Assembly:
cmpl $0x0, 0x24(%rdi)
je 0x4568
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r13
movq %rdi, %rbx
movq %rcx, -0x38(%rbp)
cmpl $0x0, (%rdx)
setg %al
jle 0x4592
movq %rsi, %r12
movb %al, -0x29(%rbp)
movslq 0x18(%rbx), %rsi
shlq $0x3, %rsi
addq 0x8(%rbx), %rsi
movq %r12, %rdi
callq 0x3b12
testb %al, %al
jne 0x4548
addq $0x18, %r12
xorl %r14d, %r14d
incq %r14
movslq (%r13), %rax
cmpq %rax, %r14
setl %al
jge 0x4592
movb %al, -0x29(%rbp)
leaq 0x18(%r12), %r15
movslq 0x18(%rbx), %rsi
shlq $0x3, %rsi
addq 0x8(%rbx), %rsi
movq %r12, %rdi
callq 0x3b12
movq %r15, %r12
testb %al, %al
je 0x4516
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x456b
leaq 0x85f0(%rip), %rsi      # 0xcb48
leaq 0x86a1(%rip), %rdx      # 0xcc00
xorl %ecx, %ecx
callq 0x32c0
jmp 0x456d
xorl %eax, %eax
retq
xorl %eax, %eax
movl 0x24(%rbx), %ecx
testl %ecx, %ecx
jle 0x457f
decl %ecx
movl %ecx, 0x24(%rbx)
jne 0x457f
movb $0x0, 0x3c(%rax)
addl $0xfffffc18, 0x20(%rbx) # imm = 0xFFFFFC18
movb $0x1, %al
cmpb $0x0, -0x29(%rbp)
jne 0x4664
cmpl $0x4, 0x14(%rbx)
movq -0x38(%rbp), %r14
jl 0x45da
movl 0x1c(%rbx), %r15d
xorl %r12d, %r12d
movq 0x8(%rbx), %rax
movslq 0x18(%rbx), %rcx
leaq (%rax,%rcx,8), %rdi
movslq %r15d, %rcx
leaq (%rax,%rcx,8), %rsi
callq 0x38a0
testb %al, %al
jne 0x4628
incl %r15d
movl %r15d, %eax
cltd
idivl 0x10(%rbx)
incl %r12d
movl 0x14(%rbx), %eax
addl $-0x3, %eax
movl %edx, %r15d
cmpl %eax, %r12d
jl 0x45a3
testq %r14, %r14
je 0x4624
movslq 0x18(%rbx), %rsi
shlq $0x3, %rsi
addq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x3d00
testb %al, %al
je 0x4624
movl 0x24(%rbx), %r14d
testl %r14d, %r14d
jle 0x465b
leaq 0x8541(%rip), %rsi      # 0xcb48
leaq 0x85f2(%rip), %rdx      # 0xcc00
movq -0x38(%rbp), %rdi
xorl %ecx, %ecx
callq 0x32c0
decl %r14d
movl %r14d, 0x24(%rbx)
jne 0x465b
jmp 0x4657
xorl %eax, %eax
jmp 0x4664
testq %r14, %r14
je 0x4647
leaq 0x8514(%rip), %rsi      # 0xcb48
leaq 0x85c5(%rip), %rdx      # 0xcc00
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x32c0
jmp 0x4649
xorl %eax, %eax
movl 0x24(%rbx), %ecx
testl %ecx, %ecx
jle 0x465b
decl %ecx
movl %ecx, 0x24(%rbx)
jne 0x465b
movb $0x0, 0x3c(%rax)
addl $0xfffffc18, 0x20(%rbx) # imm = 0xFFFFFC18
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop