// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rsi, %rbx
movq %rdi, 0x58(%rsp)
movl 0xc(%rsi), %r15d
subl 0x8(%rsi), %r15d
movl %r15d, %ebp
incl %ebp
jne 0xff2a
testb %dl, %dl
je 0x1014d
xorl %ebp, %ebp
jmp 0x10138
leaq 0x20(%rbx), %r14
movl %r15d, %eax
movq %rax, 0x60(%rsp)
xorl %r12d, %r12d
leaq 0x8(%rsp), %r13
movl %edx, 0x50(%rsp)
movq %r14, 0x48(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x915c
movq %r14, %rdi
movq %rax, %rsi
callq 0x901a
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x1, %edx
movq %r12, %rdi
callq 0x915c
movq %r14, %rdi
movq %rax, %rsi
callq 0x901a
movsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x2, %edx
movq %r12, %rdi
callq 0x915c
movq %r14, %rdi
movq %rax, %rsi
callq 0x901a
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
addl %r12d, %esi
callq 0xc0ae
movq %rax, %rdi
callq 0xae12
movsd %xmm0, 0x28(%rsp)
movq (%rbx), %rsi
movq %r13, %rdi
callq 0xb208
movq 0x8(%rsp), %r14
movq %r13, %rdi
movq %rbx, %rsi
callq 0xcdcc
cmpq 0x8(%rsp), %r14
je 0x10076
movq %r14, %rdi
callq 0xae00
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
callq 0xae06
movsd %xmm0, 0x18(%rsp)
movq %r14, %rdi
callq 0xae0c
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0xae12
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 0x7300
testb %al, %al
jne 0x10135
addq $0x60, %r14
jmp 0xffee
movq %r13, %rdi
movq %rbx, %rsi
callq 0xce3e
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0x10303
addq $0x60, %r14
movq (%rbx), %rsi
movq %r13, %rdi
callq 0xb214
cmpq 0x8(%rsp), %r14
je 0x10114
movq %r14, %rdi
callq 0xae00
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
callq 0xae06
movsd %xmm0, 0x18(%rsp)
movq %r14, %rdi
callq 0xae0c
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0xae12
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 0x7300
addq $0x60, %r14
testb %al, %al
je 0x10093
jmp 0x10135
leaq 0x1(%r12), %rax
cmpq 0x60(%rsp), %r12
movq %rax, %r12
movl 0x50(%rsp), %edx
movq 0x48(%rsp), %r14
jne 0xff47
jmp 0xff1b
movb $0x1, %bpl
andb $0x1, %bpl
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
setne %bpl
je 0x10138
leaq 0x20(%rbx), %r14
movl %r15d, %eax
movq %rax, 0x48(%rsp)
xorl %r12d, %r12d
leaq 0x8(%rsp), %r13
movq %r14, 0x50(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x915c
movq %r14, %rdi
movq %rax, %rsi
callq 0x901a
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x1, %edx
movq %r12, %rdi
callq 0x915c
movq %r14, %rdi
movq %rax, %rsi
callq 0x901a
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
movl $0x2, %edx
movq %r12, %rdi
callq 0x915c
movq %r14, %rdi
movq %rax, %rsi
callq 0x901a
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
addl %r12d, %esi
callq 0xc0ae
movq %rax, %rdi
callq 0xae12
movsd %xmm0, 0x10(%rsp)
movq 0x58(%rsp), %rax
movq 0xa78(%rax), %r15
cmpq 0xa80(%rax), %r15
je 0x102e2
movq (%rbx), %rsi
movq %r15, %rdi
callq 0xc0a4
testb %al, %al
je 0x102d1
movq %r13, %rdi
movq %r15, %rsi
callq 0xb208
movq 0x8(%rsp), %r14
movq %r13, %rdi
movq %r15, %rsi
callq 0xb214
cmpq 0x8(%rsp), %r14
je 0x102d1
movq %r14, %rdi
callq 0xae00
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
callq 0xae06
movsd %xmm0, 0x38(%rsp)
movq %r14, %rdi
callq 0xae0c
movsd %xmm0, 0x30(%rsp)
movq %r14, %rdi
callq 0xae12
movapd %xmm0, %xmm6
addsd 0x1a05f(%rip), %xmm6    # 0x2a2f0
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
movsd 0x18(%rsp), %xmm5
movsd 0x10(%rsp), %xmm7
callq 0x7300
testb %al, %al
jne 0x10138
addq $0x60, %r14
jmp 0x10241
addq $0x75330, %r15          # imm = 0x75330
movq 0x58(%rsp), %rax
jmp 0x10211
leaq 0x1(%r12), %rax
cmpq 0x48(%rsp), %r12
setne %bpl
movq %rax, %r12
movq 0x50(%rsp), %r14
jne 0x1016e
jmp 0x10138
leaq 0x19dcc(%rip), %rdi     # 0x2a0d6
leaq 0x194fa(%rip), %rsi     # 0x2980b
leaq 0x19dce(%rip), %rcx     # 0x2a0e6
movl $0xab, %edx
callq 0x6210