// File: /workspace/github_cpp_makefile_star2_O2/Chrom3D[P]Chrom3D/src/Model.cpp
// Function: Model::isClashing(Move&, bool)
bool Model::isClashing(Move &mov, bool onlyIntra /*=false*/) { //

  vector<Chromosome>::iterator chriter;  
  boost::container::static_vector<Bead,MAXSIZE>::iterator beaditer;

  uint movSize = (mov.stop-mov.start)+1;
  for(uint i=0; i!=movSize; i++) {
    double moveX=mov.mat(i,0);
    double moveY=mov.mat(i,1);
    double moveZ=mov.mat(i,2);
    double moveRadius=mov.chr[mov.start+i].getRadius();

    // INTRACHROMOSOMAL
    // "left" part:
    for(beaditer = mov.chr.begin(); beaditer != mov.begin(); beaditer++) {
      if(util::coordClash(beaditer->getX(),beaditer->getY(), beaditer->getZ(), moveX, moveY, moveZ, beaditer->getRadius(), moveRadius)) {
        return true;
      }
    }
    // "Right" part:
    for(beaditer = mov.end()+1; beaditer != mov.chr.end(); beaditer++) {
      if(util::coordClash(beaditer->getX(),beaditer->getY(), beaditer->getZ(), moveX, moveY, moveZ, beaditer->getRadius(), moveRadius)) {
        return true;
      }
    }
  }
    
  if(onlyIntra) {
    return false;
  }

  // INTERCHROMOSOMAL
  for(uint i=0; i!=movSize; i++) {
    double moveX=mov.mat(i,0);
    double moveY=mov.mat(i,1);
    double moveZ=mov.mat(i,2);
    double moveRadius=mov.chr[mov.start+i].getRadius();
    for(chriter = chromosomes.begin(); chriter != chromosomes.end(); chriter++) {
      if(*chriter != mov.chr) { 
        for(beaditer = chriter->begin(); beaditer != chriter->end(); beaditer++) {
          if(util::coordClash(beaditer->getX(),beaditer->getY(), beaditer->getZ(), moveX, moveY, moveZ, beaditer->getRadius()-0.00000001, moveRadius)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, 0x54(%rsp)
movq %rsp, %r12
andq $0x0, (%r12)
movq %rsi, %rbx
movl 0xc(%rsi), %r14d
subl 0x8(%rsi), %r14d
movq %rdi, 0x58(%rsp)
incl %r14d
leaq 0x10(%rsi), %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %rbp
cmpq %r14, %r13
je 0xe6ac
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x8614
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r15, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x8614
movsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %r15, %rdi
movq %r13, %rsi
pushq $0x2
popq %rdx
callq 0x8614
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
addl %r13d, %esi
callq 0xb174
movq %rax, %rdi
callq 0xa3e8
movsd %xmm0, 0x28(%rsp)
movq (%rbx), %rsi
movq %rbp, %rdi
callq 0xa778
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xbcf8
movq (%rsp), %rdi
cmpq 0x8(%rsp), %rdi
je 0xe5d2
callq 0xa3d6
movsd %xmm0, 0x20(%rsp)
movq (%rsp), %rdi
callq 0xa3dc
movsd %xmm0, 0x18(%rsp)
movq (%rsp), %rdi
callq 0xa3e2
movsd %xmm0, 0x10(%rsp)
movq (%rsp), %rdi
callq 0xa3e8
movapd %xmm0, %xmm6
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
movsd 0x30(%rsp), %xmm5
movsd 0x28(%rsp), %xmm7
callq 0x6ee6
testb %al, %al
jne 0xe82d
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xb1ee
jmp 0xe53d
movq %r13, 0x48(%rsp)
movq %r14, %r13
movq %r15, %r14
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xbd32
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %r15
movq %r13, %r14
movq 0x48(%rsp), %r13
pushq $0x1
popq %rdx
callq 0xb224
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq (%rbx), %rsi
movq %rbp, %rdi
callq 0xa784
movq (%rsp), %rdi
cmpq 0x8(%rsp), %rdi
je 0xe6a4
callq 0xa3d6
movsd %xmm0, 0x20(%rsp)
movq (%rsp), %rdi
callq 0xa3dc
movsd %xmm0, 0x18(%rsp)
movq (%rsp), %rdi
callq 0xa3e2
movsd %xmm0, 0x10(%rsp)
movq (%rsp), %rdi
callq 0xa3e8
movapd %xmm0, %xmm6
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
movsd 0x30(%rsp), %xmm5
movsd 0x28(%rsp), %xmm7
callq 0x6ee6
testb %al, %al
jne 0xe82d
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xb1ee
jmp 0xe60f
incq %r13
jmp 0xe4bd
cmpb $0x0, 0x54(%rsp)
je 0xe6ba
xorl %eax, %eax
jmp 0xe82f
xorl %r13d, %r13d
leaq 0x8(%rsp), %rbp
movq %rsp, %r12
cmpq %r14, %r13
je 0xe6b3
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x8614
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r15, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x8614
movsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %r15, %rdi
movq %r13, %rsi
pushq $0x2
popq %rdx
callq 0x8614
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
movq %r13, 0x48(%rsp)
addl %r13d, %esi
callq 0xb174
movq %rax, %rdi
callq 0xa3e8
movsd %xmm0, 0x28(%rsp)
movq 0x58(%rsp), %rax
movq 0xa78(%rax), %r13
movq 0x58(%rsp), %rax
cmpq 0xa80(%rax), %r13
je 0xe820
movq (%rbx), %rsi
movq %r13, %rdi
callq 0xb162
testb %al, %al
je 0xe814
movq %rbp, %rdi
movq %r13, %rsi
callq 0xa778
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0xa784
movq (%rsp), %rdi
cmpq 0x8(%rsp), %rdi
je 0xe814
callq 0xa3d6
movsd %xmm0, 0x20(%rsp)
movq (%rsp), %rdi
callq 0xa3dc
movsd %xmm0, 0x18(%rsp)
movq (%rsp), %rdi
callq 0xa3e2
movsd %xmm0, 0x10(%rsp)
movq (%rsp), %rdi
callq 0xa3e8
movapd %xmm0, %xmm6
addsd 0x12c59(%rip), %xmm6    # 0x21428
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
movsd 0x30(%rsp), %xmm5
movsd 0x28(%rsp), %xmm7
callq 0x6ee6
testb %al, %al
jne 0xe82d
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xb1ee
jmp 0xe777
addq $0x75330, %r13          # imm = 0x75330
jmp 0xe73e
movq 0x48(%rsp), %r13
incq %r13
jmp 0xe6c5
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq