// File: /workspace/github_cpp_makefile_star2_O2/matallui[P]nibble-curses/src/CNibbles.cpp
// Function: CNibbles::PutFood()
void CNibbles::PutFood ( void )
{
  if ( m_master )
  {
    bool free = false;
    
    while ( !free )
    {
      m_xyfood.setX ( rand() % m_maxLines );
      m_xyfood.setY ( rand() % m_maxCols );
      
      if ( m_snakes[0]->hasPoint ( m_xyfood ) ) continue;
      if ( m_snakes[1] && m_snakes[1]->hasPoint ( m_xyfood ) ) continue;
      
      free = true;
      for ( int i = 0; i < m_num_obstacles; i++ )
	if ( m_obstacles[i].Intersection ( m_xyfood ) ) free = false;	
    }
  }
  
  if ( m_mode == 3 )
  {
    if ( m_master )
    {
      if ( ! m_socket->Send ( (char*) &m_xyfood, sizeof(m_xyfood) ) )
	throw CException( "Problems with communication." );
    }
    else
    {
      if ( ! m_socket->Recv ( (char*) &m_xyfood, sizeof(m_xyfood) ) )
	throw CException( "Problems with communication." );
      int x, y;
      x = m_xyfood.getX();
      y = m_xyfood.getY();
      if ( x < 0 || x > m_maxLines || y < 0 || y > m_maxCols )
	throw CException( "Problems with communication." );
    }
  }
  
  attrset ( COLOR_PAIR(3) );
  move ( m_xyfood.getX(), m_xyfood.getY() );
  addch ( (char) (m_nfood+48) );
  refresh();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x18(%rdi)
jne 0x7b74
leaq 0x38(%rbx), %r14
leaq -0x50(%rbp), %r15
callq 0x3090
cltd
idivl (%rbx)
movl %edx, -0x50(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x37c2
callq 0x3090
cltd
idivl 0x4(%rbx)
movl %edx, -0x50(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x37cc
movq 0x30(%rbx), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0x3c40
testb %al, %al
jne 0x7ade
movq 0x30(%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x7b37
movq %r14, %rsi
callq 0x3c40
testb %al, %al
jne 0x7ade
movb $0x1, %r12b
xorl %r13d, %r13d
xorl %r15d, %r15d
movslq 0xc(%rbx), %rax
cmpq %rax, %r15
jge 0x7b66
movq 0x28(%rbx), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x3a68
xorb $0x1, %al
andb %al, %r12b
incq %r15
addq $0x18, %r13
jmp 0x7b40
testb $0x1, %r12b
leaq -0x50(%rbp), %r15
je 0x7ade
cmpl $0x3, 0x14(%rbx)
jne 0x7c34
movq 0x48(%rbx), %rdi
leaq 0x38(%rbx), %r14
cmpb $0x1, 0x18(%rbx)
jne 0x7bf3
leaq -0x50(%rbp), %rdx
movl $0x8, (%rdx)
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
testb %al, %al
jne 0x7c34
pushq $0x20
popq %rdi
callq 0x3180
movq %rax, %rbx
leaq 0x822(%rip), %rsi       # 0x83db
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x369c
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x361a
xorl %r15d, %r15d
leaq 0x4199(%rip), %rsi      # 0xbd78
leaq 0x168(%rip), %rdx       # 0x7d4e
movq %rbx, %rdi
callq 0x3410
jmp 0x7d1f
leaq -0x50(%rbp), %rdx
movl $0x8, (%rdx)
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x7cd8
movq %r14, %rdi
callq 0x3798
movl %eax, %r15d
movq %r14, %rdi
callq 0x37a0
testl %r15d, %r15d
js 0x7c8f
testl %eax, %eax
js 0x7c8f
cmpl (%rbx), %r15d
jg 0x7c8f
cmpl 0x4(%rbx), %eax
jg 0x7c8f
movq 0x4395(%rip), %r12      # 0xbfd0
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
callq 0x32c0
leaq 0x38(%rbx), %r14
movq %r14, %rdi
callq 0x3798
movl %eax, %r15d
movq %r14, %rdi
callq 0x37a0
movl %r15d, %edi
movl %eax, %esi
callq 0x31d0
movq (%r12), %rdi
movb 0x40(%rbx), %al
addb $0x30, %al
movsbl %al, %esi
callq 0x30b0
callq 0x3400
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x3180
movq %rax, %rbx
leaq 0x73a(%rip), %rsi       # 0x83db
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x369c
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x361a
xorl %r15d, %r15d
leaq 0x40b1(%rip), %rsi      # 0xbd78
leaq 0x80(%rip), %rdx        # 0x7d4e
movq %rbx, %rdi
callq 0x3410
jmp 0x7d1f
pushq $0x20
popq %rdi
callq 0x3180
movq %rax, %rbx
leaq 0x6f1(%rip), %rsi       # 0x83db
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x369c
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x361a
xorl %r15d, %r15d
leaq 0x4068(%rip), %rsi      # 0xbd78
leaq 0x37(%rip), %rdx        # 0x7d4e
movq %rbx, %rdi
callq 0x3410
jmp 0x7d27
jmp 0x7d27
jmp 0x7d3a
jmp 0x7d3a
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x3150
testb %r15b, %r15b
jne 0x7d3d
jmp 0x7d45
movq %rax, %r14
movq %rbx, %rdi
callq 0x31f0
movq %r14, %rdi
callq 0x3420
nop