// File: 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
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
testb $0x1, 0x18(%rax)
je 0xb87d
movb $0x0, -0x9(%rbp)
movb -0x9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xb766
jmp 0xb87b
movq -0xc0(%rbp), %rax
addq $0x38, %rax
movq %rax, -0xd0(%rbp)
callq 0x30c0
movq -0xd0(%rbp), %rdi
movq -0xc0(%rbp), %rcx
cltd
idivl (%rcx)
movl %edx, -0x10(%rbp)
leaq -0x10(%rbp), %rsi
callq 0x3ce0
movq -0xc0(%rbp), %rax
addq $0x38, %rax
movq %rax, -0xc8(%rbp)
callq 0x30c0
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rcx
cltd
idivl 0x4(%rcx)
movl %edx, -0x14(%rbp)
leaq -0x14(%rbp), %rsi
callq 0x3d00
movq -0xc0(%rbp), %rsi
movq 0x30(%rsi), %rax
movq (%rax), %rdi
addq $0x38, %rsi
callq 0x4470
testb $0x1, %al
jne 0xb7ec
jmp 0xb7f1
jmp 0xb758
movq -0xc0(%rbp), %rax
movq 0x30(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0xb826
movq -0xc0(%rbp), %rsi
movq 0x30(%rsi), %rax
movq 0x8(%rax), %rdi
addq $0x38, %rsi
callq 0x4470
testb $0x1, %al
jne 0xb821
jmp 0xb826
jmp 0xb758
movb $0x1, -0x9(%rbp)
movl $0x0, -0x18(%rbp)
movq -0xc0(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0xb876
movq -0xc0(%rbp), %rsi
movq 0x28(%rsi), %rdi
movslq -0x18(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x38, %rsi
callq 0x4150
testb $0x1, %al
jne 0xb865
jmp 0xb869
movb $0x0, -0x9(%rbp)
jmp 0xb86b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xb831
jmp 0xb758
jmp 0xb87d
movq -0xc0(%rbp), %rax
cmpl $0x3, 0x14(%rax)
jne 0xbbaf
movq -0xc0(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0xb987
movq -0xc0(%rbp), %rsi
movq 0x48(%rsi), %rdi
addq $0x38, %rsi
movl $0x8, -0x1c(%rbp)
movq (%rdi), %rax
leaq -0x1c(%rbp), %rdx
callq *0x20(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0xb8ca
jmp 0xb982
movb $0x1, -0x55(%rbp)
movl $0x20, %edi
callq 0x31a0
movq %rax, -0xe0(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x34f0
movq -0xd8(%rbp), %rdx
leaq 0xc1e(%rip), %rsi       # 0xc51b
leaq -0x40(%rbp), %rdi
callq 0x3880
jmp 0xb908
movq -0xe0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3770
jmp 0xb91a
movq -0xe0(%rbp), %rdi
movb $0x0, -0x55(%rbp)
leaq 0x4444(%rip), %rsi      # 0xfd70
leaq 0x2fd(%rip), %rdx       # 0xbc30
callq 0x34d0
jmp 0xbc2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb960
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x31d0
leaq -0x41(%rbp), %rdi
callq 0x3340
testb $0x1, -0x55(%rbp)
jne 0xb971
jmp 0xb97d
movq -0xe0(%rbp), %rdi
callq 0x3220
jmp 0xbc23
jmp 0xbbad
movq -0xc0(%rbp), %rsi
movq 0x48(%rsi), %rdi
addq $0x38, %rsi
movl $0x8, -0x5c(%rbp)
movq (%rdi), %rax
leaq -0x5c(%rbp), %rdx
callq *0x28(%rax)
xorb $-0x1, %al
testb $0x1, %al
jne 0xb9b2
jmp 0xba79
movb $0x1, -0x82(%rbp)
movl $0x20, %edi
callq 0x31a0
movq %rax, -0xf0(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x34f0
movq -0xe8(%rbp), %rdx
leaq 0xb30(%rip), %rsi       # 0xc51b
leaq -0x80(%rbp), %rdi
callq 0x3880
jmp 0xb9f6
movq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3770
jmp 0xba08
movq -0xf0(%rbp), %rdi
movb $0x0, -0x82(%rbp)
leaq 0x4353(%rip), %rsi      # 0xfd70
leaq 0x20c(%rip), %rdx       # 0xbc30
callq 0x34d0
jmp 0xbc2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xba51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31d0
leaq -0x81(%rbp), %rdi
callq 0x3340
testb $0x1, -0x82(%rbp)
jne 0xba68
jmp 0xba74
movq -0xf0(%rbp), %rdi
callq 0x3220
jmp 0xbc23
movq -0xc0(%rbp), %rdi
addq $0x38, %rdi
callq 0x3c50
movq -0xc0(%rbp), %rdi
movl %eax, -0x88(%rbp)
addq $0x38, %rdi
callq 0x3c60
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x88(%rbp)
jl 0xbade
movq -0xc0(%rbp), %rcx
movl -0x88(%rbp), %eax
cmpl (%rcx), %eax
jg 0xbade
cmpl $0x0, -0x8c(%rbp)
jl 0xbade
movq -0xc0(%rbp), %rcx
movl -0x8c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jle 0xbbab
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x31a0
movq %rax, -0x100(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x34f0
movq -0xf8(%rbp), %rdx
leaq 0xa04(%rip), %rsi       # 0xc51b
leaq -0xb0(%rbp), %rdi
callq 0x3880
jmp 0xbb25
movq -0x100(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3770
jmp 0xbb3a
movq -0x100(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x4221(%rip), %rsi      # 0xfd70
leaq 0xda(%rip), %rdx        # 0xbc30
callq 0x34d0
jmp 0xbc2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbb86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x31d0
leaq -0xb1(%rbp), %rdi
callq 0x3340
testb $0x1, -0xb2(%rbp)
jne 0xbb9d
jmp 0xbba9
movq -0x100(%rbp), %rdi
callq 0x3220
jmp 0xbc23
jmp 0xbbad
jmp 0xbbaf
movq 0x441a(%rip), %rax      # 0xffd0
movq (%rax), %rdi
movl $0x300, %esi            # imm = 0x300
callq 0x3330
movq -0xc0(%rbp), %rdi
addq $0x38, %rdi
callq 0x3c50
movq -0xc0(%rbp), %rdi
movl %eax, -0x104(%rbp)
addq $0x38, %rdi
callq 0x3c60
movl -0x104(%rbp), %edi
movl %eax, %esi
callq 0x3200
movq -0xc0(%rbp), %rax
movq 0x43cc(%rip), %rcx      # 0xffd0
movq (%rcx), %rdi
movl 0x40(%rax), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x30e0
callq 0x34c0
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x34e0
nopl (%rax)