// File: /workspace/github_cpp_makefile_star2_O3/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 0x81fb
leaq 0x38(%rbx), %r14
leaq -0x48(%rbp), %r15
callq 0x30a0
cltd
idivl (%rbx)
movl %edx, -0x48(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3856
callq 0x30a0
cltd
idivl 0x4(%rbx)
movl %edx, -0x48(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3860
movq 0x30(%rbx), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0x3d08
testb %al, %al
jne 0x8162
movq 0x30(%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x81bb
movq %r14, %rsi
callq 0x3d08
testb %al, %al
jne 0x8162
cmpl $0x0, 0xc(%rbx)
jle 0x81fb
movb $0x1, %r12b
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x28(%rbx), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x3b1a
xorb $0x1, %al
andb %al, %r12b
incq %r15
movslq 0xc(%rbx), %rax
addq $0x18, %r13
cmpq %rax, %r15
jl 0x81ca
testb %r12b, %r12b
leaq -0x48(%rbp), %r15
je 0x8162
cmpl $0x3, 0x14(%rbx)
jne 0x82c8
movq 0x48(%rbx), %rdi
leaq 0x38(%rbx), %r14
cmpb $0x1, 0x18(%rbx)
jne 0x8287
leaq -0x48(%rbp), %rdx
movl $0x8, (%rdx)
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
testb %al, %al
jne 0x82c8
movl $0x20, %edi
callq 0x3160
movq %rax, %rbx
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1191(%rip), %rsi      # 0x93db
leaq 0x11a6(%rip), %rdx      # 0x93f7
leaq -0x48(%rbp), %rdi
callq 0x376e
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x35f8
xorl %r12d, %r12d
leaq 0x4b05(%rip), %rsi      # 0xcd78
leaq 0x18e(%rip), %rdx       # 0x8408
movq %rbx, %rdi
callq 0x33f0
jmp 0x83cd
leaq -0x48(%rbp), %rdx
movl $0x8, (%rdx)
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x8379
movq %r14, %rdi
callq 0x382c
movl %eax, %r15d
movq %r14, %rdi
callq 0x3834
testl %r15d, %r15d
js 0x8323
testl %eax, %eax
js 0x8323
cmpl (%rbx), %r15d
jg 0x8323
cmpl 0x4(%rbx), %eax
jg 0x8323
movq 0x4d01(%rip), %r12      # 0xcfd0
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
callq 0x32a0
leaq 0x38(%rbx), %r14
movq %r14, %rdi
callq 0x382c
movl %eax, %r15d
movq %r14, %rdi
callq 0x3834
movl %r15d, %edi
movl %eax, %esi
callq 0x31c0
movq (%r12), %rdi
movb 0x40(%rbx), %al
addb $0x30, %al
movsbl %al, %esi
callq 0x30c0
callq 0x33e0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3160
movq %rax, %rbx
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x109c(%rip), %rsi      # 0x93db
leaq 0x10b1(%rip), %rdx      # 0x93f7
leaq -0x48(%rbp), %rdi
callq 0x376e
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x35f8
xorl %r12d, %r12d
leaq 0x4a10(%rip), %rsi      # 0xcd78
leaq 0x99(%rip), %rdx        # 0x8408
movq %rbx, %rdi
callq 0x33f0
jmp 0x83cd
movl $0x20, %edi
callq 0x3160
movq %rax, %rbx
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1046(%rip), %rsi      # 0x93db
leaq 0x105b(%rip), %rdx      # 0x93f7
leaq -0x48(%rbp), %rdi
callq 0x376e
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x35f8
xorl %r12d, %r12d
leaq 0x49ba(%rip), %rsi      # 0xcd78
leaq 0x43(%rip), %rdx        # 0x8408
movq %rbx, %rdi
callq 0x33f0
jmp 0x83d5
jmp 0x83f4
jmp 0x83d5
jmp 0x83f4
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x83ed
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3280
testb %r12b, %r12b
jne 0x83f7
jmp 0x83ff
movq %rax, %r14
movq %rbx, %rdi
callq 0x31e0
movq %r14, %rdi
callq 0x3400
nop