// File: /workspace/github_cpp_makefile_star2_O1/Chrom3D[P]Chrom3D/src/Model.cpp
// Function: Model::switchConstraints(ConstraintType, bool)
void Model::switchConstraints(ConstraintType ct, bool switchOn) {
  
  map<string,vector<Constraint> >::iterator cm_it;
  vector<Constraint>::iterator c_it; 
  pair<string, string> beadIds;
  
  if(switchOn){

    for(cm_it = constraintsOFF.begin(); cm_it != constraintsOFF.end(); cm_it++) {

      for(c_it = cm_it->second.begin(); c_it != cm_it->second.end();) {

        if(c_it->constType == ct) {
          beadIds = c_it->getBeadIDs();
          // First, copy all constraint pointers to the "ON" map (NOTE! We should check whether the constraint is already in the list) 
          constraints[beadIds.first].push_back(*c_it);
          // Erase the constraint from the "OFF" map vector for that bead
          cm_it->second.erase(c_it);
        }
        else {
          c_it++;
        }
      }
    }
  }
  else {

    for(cm_it = constraints.begin(); cm_it != constraints.end(); cm_it++) {

      for(c_it = cm_it->second.begin(); c_it != cm_it->second.end();) {

        if(c_it->constType == ct) {
          beadIds = c_it->getBeadIDs();
          // First, copy all constraint pointers to the "OFF" map (NOTE! We should check whether the constraint is already in the list) 
          constraintsOFF[beadIds.first].push_back(*c_it);
          // Erase the constraint from the "OFF" map vector for that bead
          cm_it->second.erase(c_it);
        }
        else {
          c_it++;
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x58(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x78(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
testl %edx, %edx
je 0xf372
movq 0xa30(%r14), %r12
leaq 0xa20(%r14), %rax
movq %rax, (%rsp)
cmpq %rax, %r12
je 0xf49f
addq $0x9e8, %r14            # imm = 0x9E8
leaq 0x8(%rsp), %rbp
leaq 0x48(%rsp), %r13
movq 0x40(%r12), %r15
cmpq 0x48(%r12), %r15
je 0xf358
cmpl %ebx, 0x10(%r15)
jne 0xf320
movq %rbp, %rdi
movq %r15, %rsi
callq 0xde3c
movq %r13, %rdi
movq %rbp, %rsi
callq 0x63b0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x63b0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xf2c7
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xf2e3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
movq %r14, %rdi
movq %r13, %rsi
callq 0x16ac4
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xf329
movq 0x30(%r15), %rcx
movq %rcx, 0x30(%rsi)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsi)
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x38, 0x8(%rax)
jmp 0xf334
addq $0x38, %r15
jmp 0xf271
movq %rax, %rdi
movq %r15, %rdx
callq 0x18280
leaq 0x38(%r15), %rsi
movq 0x48(%r12), %rdx
cmpq %rdx, %rsi
je 0xf34d
subq %rsi, %rdx
movq %r15, %rdi
callq 0x64e0
addq $-0x38, 0x48(%r12)
jmp 0xf271
movq %r12, %rdi
callq 0x6250
movq %rax, %r12
cmpq (%rsp), %rax
jne 0xf26c
jmp 0xf49f
movq 0xa00(%r14), %r12
leaq 0x9f0(%r14), %rax
movq %rax, (%rsp)
cmpq %rax, %r12
je 0xf49f
addq $0xa18, %r14            # imm = 0xA18
leaq 0x8(%rsp), %rbp
leaq 0x48(%rsp), %r13
movq 0x40(%r12), %r15
cmpq 0x48(%r12), %r15
je 0xf48a
cmpl %ebx, 0x10(%r15)
jne 0xf452
movq %rbp, %rdi
movq %r15, %rsi
callq 0xde3c
movq %r13, %rdi
movq %rbp, %rsi
callq 0x63b0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x63b0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xf3f9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xf415
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
movq %r14, %rdi
movq %r13, %rsi
callq 0x16ac4
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xf45b
movq 0x30(%r15), %rcx
movq %rcx, 0x30(%rsi)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsi)
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x38, 0x8(%rax)
jmp 0xf466
addq $0x38, %r15
jmp 0xf3a3
movq %rax, %rdi
movq %r15, %rdx
callq 0x18280
leaq 0x38(%r15), %rsi
movq 0x48(%r12), %rdx
cmpq %rdx, %rsi
je 0xf47f
subq %rsi, %rdx
movq %r15, %rdi
callq 0x64e0
addq $-0x38, 0x48(%r12)
jmp 0xf3a3
movq %r12, %rdi
callq 0x6250
movq %rax, %r12
cmpq (%rsp), %rax
jne 0xf39e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xf4bb
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xf4d7
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6310
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf4ef
jmp 0xf4ef
jmp 0xf4ef
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x16b40
movq %rbx, %rdi
callq 0x65b0