// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movl 0xc(%rsi), %eax
subl 0x8(%rsi), %eax
cmpl $-0x1, %eax
je 0x10072
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, 0x50(%rsp)
leaq 0x20(%rsi), %r15
movl %eax, %eax
movq %rax, 0x40(%rsp)
xorl %r12d, %r12d
movq %rsp, %r13
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x9124
movq %r15, %rdi
movq %rax, %rsi
callq 0x8fe2
movsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x1, %edx
movq %r12, %rdi
callq 0x9124
movq %r15, %rdi
movq %rax, %rsi
callq 0x8fe2
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x2, %edx
movq %r12, %rdi
callq 0x9124
movq %r15, %rdi
movq %rax, %rsi
callq 0x8fe2
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
addl %r12d, %esi
callq 0xc00a
movq %rax, %rdi
callq 0xad7e
movsd %xmm0, 0x20(%rsp)
movq (%rbx), %rsi
movq %r13, %rdi
callq 0xb164
movq (%rsp), %r14
movq %r13, %rdi
movq %rbx, %rsi
callq 0xcd48
cmpq (%rsp), %r14
je 0xffbb
movq %r14, %rdi
callq 0xad6c
movsd %xmm0, 0x18(%rsp)
movq %r14, %rdi
callq 0xad72
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0xad78
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0xad7e
movapd %xmm0, %xmm6
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
movsd 0x30(%rsp), %xmm4
movsd 0x28(%rsp), %xmm5
movsd 0x20(%rsp), %xmm7
callq 0x7320
testb %al, %al
jne 0x10205
addq $0x60, %r14
jmp 0xff34
movq %r13, %rdi
movq %rbx, %rsi
callq 0xcdba
movq (%rsp), %r14
testq %r14, %r14
je 0x10216
addq $0x60, %r14
movq (%rbx), %rsi
movq %r13, %rdi
callq 0xb170
cmpq (%rsp), %r14
je 0x1005a
movq %r14, %rdi
callq 0xad6c
movsd %xmm0, 0x18(%rsp)
movq %r14, %rdi
callq 0xad72
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0xad78
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0xad7e
movapd %xmm0, %xmm6
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
movsd 0x30(%rsp), %xmm4
movsd 0x28(%rsp), %xmm5
movsd 0x20(%rsp), %xmm7
callq 0x7320
addq $0x60, %r14
testb %al, %al
je 0xffd7
jmp 0x10205
leaq 0x1(%r12), %rax
cmpq 0x40(%rsp), %r12
movq %rax, %r12
jne 0xfe8e
testb %bpl, %bpl
je 0x10079
xorl %eax, %eax
jmp 0x10207
xorl %r12d, %r12d
movq %rsp, %r13
movq 0x50(%rsp), %r14
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x9124
movq %r15, %rdi
movq %rax, %rsi
callq 0x8fe2
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x1, %edx
movq %r12, %rdi
callq 0x9124
movq %r15, %rdi
movq %rax, %rsi
callq 0x8fe2
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x2, %edx
movq %r12, %rdi
callq 0x9124
movq %r15, %rdi
movq %rax, %rsi
callq 0x8fe2
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
movq %r12, 0x48(%rsp)
addl %r12d, %esi
callq 0xc00a
movq %rax, %rdi
callq 0xad7e
movsd %xmm0, 0x8(%rsp)
movq 0xa78(%r14), %rbp
cmpq 0xa80(%r14), %rbp
je 0x101ed
movq (%rbx), %rsi
movq %rbp, %rdi
callq 0xc000
testb %al, %al
je 0x101e1
movq %r13, %rdi
movq %rbp, %rsi
callq 0xb164
movq (%rsp), %r12
movq %r13, %rdi
movq %rbp, %rsi
callq 0xb170
cmpq (%rsp), %r12
je 0x101e1
movq %r12, %rdi
callq 0xad6c
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
callq 0xad72
movsd %xmm0, 0x30(%rsp)
movq %r12, %rdi
callq 0xad78
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
callq 0xad7e
movapd %xmm0, %xmm6
addsd 0x1a14b(%rip), %xmm6    # 0x2a2f0
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movsd 0x10(%rsp), %xmm5
movsd 0x8(%rsp), %xmm7
callq 0x7320
testb %al, %al
jne 0x10205
addq $0x60, %r12
jmp 0x10156
addq $0x75330, %rbp          # imm = 0x75330
jmp 0x10127
movq 0x48(%rsp), %rdx
leaq 0x1(%rdx), %r12
xorl %eax, %eax
cmpq 0x40(%rsp), %rdx
jne 0x10084
jmp 0x10207
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19eb9(%rip), %rdi     # 0x2a0d6
leaq 0x195e7(%rip), %rsi     # 0x2980b
leaq 0x19ebb(%rip), %rcx     # 0x2a0e6
movl $0xab, %edx
callq 0x6210
nop