// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/grid.cc
// Function: GaussianCube::calculateDistanceGridWithAccessibilityInfo(ATOM_NETWORK*, ATOM_NETWORK*, bool, double)
void GaussianCube::calculateDistanceGridWithAccessibilityInfo(ATOM_NETWORK *atmnet, ATOM_NETWORK *orgatmnet, bool highAccuracy, double probe_radius){

 AccessibilityClass accessAnalysis;
 if(highAccuracy) accessAnalysis.setupAndFindChannels(atmnet, orgatmnet, highAccuracy, probe_radius, probe_radius);
   else accessAnalysis.setupAndFindChannels(atmnet, atmnet, highAccuracy, probe_radius, probe_radius);

 for(int x=0; x<na; x++)
   for(int y=0; y<nb; y++)
     for(int z=0; z<nc; z++)
       {
       bool overlaps = false;
       bool inside = false;
       Point point(o.x+x*va.x+y*vb.x+z*vc.x,
                 o.y+x*va.y+y*vb.y+z*vc.y,
                 o.z+x*va.z+y*vb.z+z*vc.z);
       double dist_var;
       pair<bool,bool> answer = (accessAnalysis.isVPointInsideAtomAndNotAccessible(point, dist_var));
       inside = answer.first; overlaps = answer.second;

       if(accessAnalysis.needToResample() == true)
          {
          cout << "Need to resample in grid calc. Abort." << "Contact the author" << endl;
          abort();
          };

       double dist;

//       dist = accessAnalysis.lastMinDist();
//       if(inside == false && overlaps == true) dist = dist * -1.0;
  
       if(inside == true)
         {
         dist = 0.0;
         } else
         {
         dist = accessAnalysis.lastMinDist()-probe_radius;
         if(overlaps == true) dist = dist * -1.0;
         };

       cube[x][y][z]=dist;
       };

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa98, %rsp            # imm = 0xA98
movsd %xmm0, 0x20(%rsp)
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x36c02
testl %ebp, %ebp
cmoveq %r15, %r14
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movsd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm1
callq 0x6e3ac
xorl %r13d, %r13d
leaq 0x58(%rsp), %r15
movslq 0x78(%rbx), %rax
cmpq %rax, %r13
jge 0x675a5
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x28(%rsp)
xorl %r14d, %r14d
movslq 0x7c(%rbx), %rax
cmpq %rax, %r14
jge 0x6759d
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r12d, %r12d
movslq 0x80(%rbx), %rax
cmpq %rax, %r12
jge 0x67595
movsd 0x18(%rbx), %xmm0
movsd 0x28(%rsp), %xmm4
mulsd %xmm4, %xmm0
addsd (%rbx), %xmm0
movsd 0x30(%rbx), %xmm1
movsd 0x30(%rsp), %xmm5
mulsd %xmm5, %xmm1
cvtsi2sd %r12d, %xmm2
addsd %xmm0, %xmm1
movsd 0x48(%rbx), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x20(%rbx), %xmm1
mulsd %xmm4, %xmm1
addsd 0x8(%rbx), %xmm1
movsd 0x38(%rbx), %xmm3
mulsd %xmm5, %xmm3
addsd %xmm1, %xmm3
movsd 0x50(%rbx), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm3, %xmm1
movsd 0x28(%rbx), %xmm3
mulsd %xmm4, %xmm3
addsd 0x10(%rbx), %xmm3
movsd 0x40(%rbx), %xmm4
mulsd %xmm5, %xmm4
addsd %xmm3, %xmm4
mulsd 0x58(%rbx), %xmm2
addsd %xmm4, %xmm2
leaq 0x40(%rsp), %rdi
callq 0x63c46
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x6e78c
movl %eax, %ebp
movq %r15, %rdi
callq 0x36d64
testb %al, %al
jne 0x675c1
xorpd %xmm0, %xmm0
testb $0x1, %bpl
jne 0x67578
btl $0x8, %ebp
movsd 0xa50(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
jae 0x67578
xorpd 0x99058(%rip), %xmm0    # 0x1005d0
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
jmp 0x67483
incq %r14
jmp 0x67468
incq %r13
jmp 0x6744d
leaq 0x58(%rsp), %rdi
callq 0x36e9e
addq $0xa98, %rsp            # imm = 0xA98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe89f8(%rip), %rdi     # 0x14ffc0
leaq 0x9d34c(%rip), %rsi     # 0x10491b
callq 0x4480
leaq 0x9d366(%rip), %rsi     # 0x104941
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4230
callq 0x4290
jmp 0x675f6
jmp 0x675f6
jmp 0x675f6
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x36e9e
movq %rbx, %rdi
callq 0x4780