// File: /workspace/github_cpp_makefile_star2_O1/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 0x48f44
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 0x95b90
cmpl $0x0, 0x78(%rbx)
jle 0x8a04e
xorl %r13d, %r13d
leaq 0x58(%rsp), %r15
cmpl $0x0, 0x7c(%rbx)
jle 0x8a03e
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x28(%rsp)
xorl %r14d, %r14d
cmpl $0x0, 0x80(%rbx)
jle 0x8a02e
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r12d, %r12d
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
xorps %xmm2, %xmm2
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 0x85436
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x95fda
movl %eax, %ebp
movq %r15, %rdi
callq 0x490d4
testb %al, %al
jne 0x8a06a
xorpd %xmm0, %xmm0
testb $0x1, %bpl
jne 0x8a006
btl $0x8, %ebp
movsd 0xa50(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
jae 0x8a006
xorpd 0xc95aa(%rip), %xmm0    # 0x1535b0
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movslq 0x80(%rbx), %rax
cmpq %rax, %r12
jl 0x89f1a
incq %r14
movslq 0x7c(%rbx), %rax
cmpq %rax, %r14
jl 0x89efc
incq %r13
movslq 0x78(%rbx), %rax
cmpq %rax, %r13
jl 0x89ee1
leaq 0x58(%rsp), %rdi
callq 0x4925c
addq $0xa98, %rsp            # imm = 0xA98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10cf4f(%rip), %rdi    # 0x196fc0
leaq 0xcd803(%rip), %rsi     # 0x15787b
movl $0x25, %edx
callq 0x44e0
movq 0x10cf37(%rip), %rdi    # 0x196fc0
leaq 0xcd811(%rip), %rsi     # 0x1578a1
movl $0x12, %edx
callq 0x44e0
movq 0x10cf1f(%rip), %rdi    # 0x196fc0
callq 0x41f0
callq 0x4260
jmp 0x8a0b1
jmp 0x8a0b1
jmp 0x8a0b1
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4925c
movq %rbx, %rdi
callq 0x4780