// File: /workspace/github_cpp_makefile_star2_O1/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 0x832a
leaq 0x38(%rbx), %r14
leaq -0x48(%rbp), %r15
xorl %r13d, %r13d
callq 0x30a0
cltd
idivl (%rbx)
movl %edx, -0x48(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x384e
callq 0x30a0
cltd
idivl 0x4(%rbx)
movl %edx, -0x48(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3858
movq 0x30(%rbx), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0x3d00
testb %al, %al
jne 0x82da
movq 0x30(%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x82e2
movq %r14, %rsi
callq 0x3d00
testb %al, %al
je 0x82e2
testb $0x1, %r13b
je 0x8281
jmp 0x832a
cmpl $0x0, 0xc(%rbx)
jle 0x8325
movb $0x1, %r13b
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x28(%rbx), %rdi
addq %r12, %rdi
movq %r14, %rsi
callq 0x3b12
movzbl %r13b, %r13d
testb %al, %al
movl $0x0, %eax
cmovnel %eax, %r13d
incq %r15
movslq 0xc(%rbx), %rax
addq $0x18, %r12
cmpq %rax, %r15
jl 0x82f1
leaq -0x48(%rbp), %r15
jmp 0x82da
movb $0x1, %r13b
jmp 0x82da
cmpl $0x3, 0x14(%rbx)
jne 0x83f8
movq 0x48(%rbx), %rdi
leaq 0x38(%rbx), %r14
cmpb $0x1, 0x18(%rbx)
jne 0x83b7
leaq -0x48(%rbp), %rdx
movl $0x8, (%rdx)
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
testb %al, %al
jne 0x83f8
movl $0x20, %edi
callq 0x3160
movq %rax, %rbx
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1061(%rip), %rsi      # 0x93db
leaq 0x1076(%rip), %rdx      # 0x93f7
leaq -0x48(%rbp), %rdi
callq 0x376a
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x35f8
xorl %r15d, %r15d
leaq 0x49d5(%rip), %rsi      # 0xcd78
leaq 0x192(%rip), %rdx       # 0x853c
movq %rbx, %rdi
callq 0x33f0
jmp 0x84ff
leaq -0x48(%rbp), %rdx
movl $0x8, (%rdx)
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x84aa
movq %r14, %rdi
callq 0x3824
movl %eax, %r15d
movq %r14, %rdi
callq 0x382c
testl %r15d, %r15d
js 0x8453
testl %eax, %eax
js 0x8453
cmpl (%rbx), %r15d
jg 0x8453
cmpl 0x4(%rbx), %eax
jg 0x8453
movq 0x4bd1(%rip), %r12      # 0xcfd0
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
callq 0x32a0
leaq 0x38(%rbx), %r14
movq %r14, %rdi
callq 0x3824
movl %eax, %r15d
movq %r14, %rdi
callq 0x382c
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), %r12
movq %r12, -0x10(%r12)
leaq 0xf6b(%rip), %rsi       # 0x93db
leaq 0xf80(%rip), %rdx       # 0x93f7
leaq -0x48(%rbp), %rdi
callq 0x376a
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x35f8
xorl %r15d, %r15d
leaq 0x48df(%rip), %rsi      # 0xcd78
leaq 0x9c(%rip), %rdx        # 0x853c
movq %rbx, %rdi
callq 0x33f0
jmp 0x84ff
movl $0x20, %edi
callq 0x3160
movq %rax, %rbx
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xf14(%rip), %rsi       # 0x93db
leaq 0xf29(%rip), %rdx       # 0x93f7
leaq -0x48(%rbp), %rdi
callq 0x376a
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x35f8
xorl %r15d, %r15d
leaq 0x4888(%rip), %rsi      # 0xcd78
leaq 0x45(%rip), %rdx        # 0x853c
movq %rbx, %rdi
callq 0x33f0
jmp 0x8507
jmp 0x8507
jmp 0x8521
jmp 0x8521
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x8527
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3280
jmp 0x8527
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
je 0x8534
movq %rbx, %rdi
callq 0x31e0
movq %r14, %rdi
callq 0x3400