// File: WolfgangLechner[P]StructureAnalysis/molecular_system.cpp
// Function: CMolecularSystem::get_distancePosition(int, double, double, double, double&, double&, double&)
void CMolecularSystem::get_distancePosition(int ti ,double posx, double posy,double posz ,double &diffx,double &diffy,double &diffz)
{
  diffx = posx - this->molecules[ti].posx;
  diffy = posy - this->molecules[ti].posy;
  diffz = posz - this->molecules[ti].posz;

  //nearest image
  if (diffx >  this->parameter->boxx/2.0) {diffx = diffx - this->parameter->boxx;};
  if (diffx < -this->parameter->boxx/2.0) {diffx = diffx + this->parameter->boxx;};
  if (diffy >  this->parameter->boxy/2.0) {diffy = diffy - this->parameter->boxy;};
  if (diffy < -this->parameter->boxy/2.0) {diffy = diffy + this->parameter->boxy;};
  if (diffz >  this->parameter->boxz/2.0) {diffz = diffz - this->parameter->boxz;};
  if (diffz < -this->parameter->boxz/2.0) {diffz = diffz + this->parameter->boxz;};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movsd %xmm2, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0xc(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
subsd 0x8(%rcx), %xmm0
movq -0x30(%rbp), %rcx
movsd %xmm0, (%rcx)
movsd -0x20(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0xc(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
subsd 0x10(%rcx), %xmm0
movq -0x38(%rbp), %rcx
movsd %xmm0, (%rcx)
movsd -0x28(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0xc(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
subsd 0x18(%rcx), %xmm0
movq -0x40(%rbp), %rcx
movsd %xmm0, (%rcx)
movq -0x30(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
movsd 0x3218(%rax), %xmm1
movsd 0x27e6(%rip), %xmm2     # 0xc158
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x999f
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
subsd 0x3218(%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd (%rcx), %xmm1
movq 0xb4e8c0(%rax), %rax
movsd 0x3218(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x277f(%rip), %xmm2     # 0xc158
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9a06
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
addsd 0x3218(%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
movsd 0x3220(%rax), %xmm1
movsd 0x272f(%rip), %xmm2     # 0xc158
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x9a56
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
subsd 0x3220(%rax), %xmm0
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd (%rcx), %xmm1
movq 0xb4e8c0(%rax), %rax
movsd 0x3220(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x26c8(%rip), %xmm2     # 0xc158
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9abd
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
addsd 0x3220(%rax), %xmm0
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
movsd 0x3228(%rax), %xmm1
movsd 0x2678(%rip), %xmm2     # 0xc158
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x9b0d
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
subsd 0x3228(%rax), %xmm0
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd (%rcx), %xmm1
movq 0xb4e8c0(%rax), %rax
movsd 0x3228(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x2611(%rip), %xmm2     # 0xc158
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9b74
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd (%rcx), %xmm0
movq 0xb4e8c0(%rax), %rax
addsd 0x3228(%rax), %xmm0
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)