// File: WolfgangLechner[P]StructureAnalysis/molecular_system.cpp
// Function: CMolecularSystem::get_AllNeighbors()
void CMolecularSystem::get_AllNeighbors()
{
  double nd,d;
  nd = this->parameter->neighbordistance;
  int c,nop;
  nop = this->parameter->nop;

  for (int ti = 0;ti<nop;ti++)
  {
    for (int tn = 0;tn<MAXNUMBEROFNEIGHBORS;tn++)
    {
      this->molecules[ti].neighbors[tn] = nilvalue;
      this->molecules[ti].neighbordist[tn] = -1.0;
    }
  }


  for (int ti = 0;ti<nop;ti++)
  {
    c = 0;
	  for (int tj = 0;tj<nop;tj++)
	  {

          if (tj != ti) { 
            d = get_absDistance(ti,tj); 
            if (d < nd) {
              this->molecules[ti].neighbors[c] = tj; 
              this->molecules[ti].neighbordist[c]=d; 
              c += 1;   
            }
         }
	  }
    this->molecules[ti].n_neighbors = c;
    cout << ti << " " << c << "\n";
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0xb4e8c0(%rax), %rcx
movsd 0x3250(%rcx), %xmm0
movsd %xmm0, -0x10(%rbp)
movq 0xb4e8c0(%rax), %rax
movl 0x3208(%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x666e
movl $0x0, -0x28(%rbp)
cmpl $0x64, -0x28(%rbp)
jge 0x6661
movq -0x38(%rbp), %rax
movq 0xb4e8b8(%rax), %rcx
movslq -0x24(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movslq -0x28(%rbp), %rdx
movl $0x1fca055, 0xa0(%rcx,%rdx,4) # imm = 0x1FCA055
movq 0xb4e8b8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x870, %rcx, %rcx      # imm = 0x870
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
movsd 0x5b1b(%rip), %xmm0     # 0xc168
movsd %xmm0, 0x230(%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x65fe
jmp 0x6663
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x65ef
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x6798
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x6730
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0x6720
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
callq 0x67a0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x671e
movq -0x38(%rbp), %rax
movl -0x30(%rbp), %esi
movq 0xb4e8b8(%rax), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movslq -0x1c(%rbp), %rdx
movl %esi, 0xa0(%rcx,%rdx,4)
movsd -0x18(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x870, %rcx, %rcx      # imm = 0x870
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x230(%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6720
jmp 0x6722
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x668f
movq -0x38(%rbp), %rax
movl -0x1c(%rbp), %ecx
movq 0xb4e8b8(%rax), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rax
movl %ecx, 0x550(%rax)
movl -0x2c(%rbp), %esi
movq 0x8874(%rip), %rdi      # 0xefd0
callq 0x3410
movq %rax, %rdi
leaq 0x5b0c(%rip), %rsi      # 0xc277
callq 0x3200
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x3410
movq %rax, %rdi
leaq 0x5d05(%rip), %rsi      # 0xc48a
callq 0x3200
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6675
addq $0x40, %rsp
popq %rbp
retq
nop