// File: /workspace/github_cpp_makefile_star2_O3/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 0xf30d
movq 0xa30(%r14), %r12
leaq 0xa20(%r14), %rax
movq %rax, (%rsp)
cmpq %rax, %r12
je 0xf445
addq $0x9e8, %r14            # imm = 0x9E8
leaq 0x8(%rsp), %rbp
leaq 0x48(%rsp), %r13
movq 0x40(%r12), %r15
movq 0x48(%r12), %rdx
cmpq %rdx, %r15
je 0xf2f3
cmpl %ebx, 0x10(%r15)
jne 0xf2b3
movq %rbp, %rdi
movq %r15, %rsi
callq 0xddc0
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 0xf25a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xf276
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
movq %r14, %rdi
movq %r13, %rsi
callq 0x16748
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xf2bc
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 0xf2c7
addq $0x38, %r15
jmp 0xf206
movq %rax, %rdi
movq %r15, %rdx
callq 0x17f32
leaq 0x38(%r15), %rsi
movq 0x48(%r12), %rdx
cmpq %rdx, %rsi
je 0xf2e5
subq %rsi, %rdx
movq %r15, %rdi
callq 0x64e0
movq 0x48(%r12), %rdx
addq $-0x38, %rdx
movq %rdx, 0x48(%r12)
jmp 0xf206
movq %r12, %rdi
callq 0x6250
movq %rax, %r12
cmpq (%rsp), %rax
jne 0xf1fc
jmp 0xf445
movq 0xa00(%r14), %r12
leaq 0x9f0(%r14), %rax
movq %rax, (%rsp)
cmpq %rax, %r12
je 0xf445
addq $0xa18, %r14            # imm = 0xA18
leaq 0x8(%rsp), %rbp
leaq 0x48(%rsp), %r13
movq 0x40(%r12), %r15
movq 0x48(%r12), %rdx
cmpq %rdx, %r15
je 0xf430
cmpl %ebx, 0x10(%r15)
jne 0xf3f0
movq %rbp, %rdi
movq %r15, %rsi
callq 0xddc0
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 0xf397
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xf3b3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
movq %r14, %rdi
movq %r13, %rsi
callq 0x16748
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xf3f9
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 0xf404
addq $0x38, %r15
jmp 0xf343
movq %rax, %rdi
movq %r15, %rdx
callq 0x17f32
leaq 0x38(%r15), %rsi
movq 0x48(%r12), %rdx
cmpq %rdx, %rsi
je 0xf422
subq %rsi, %rdx
movq %r15, %rdi
callq 0x64e0
movq 0x48(%r12), %rdx
addq $-0x38, %rdx
movq %rdx, 0x48(%r12)
jmp 0xf343
movq %r12, %rdi
callq 0x6250
movq %rax, %r12
cmpq (%rsp), %rax
jne 0xf339
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xf461
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xf47d
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 0xf495
jmp 0xf495
jmp 0xf495
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x167c4
movq %rbx, %rdi
callq 0x65b0