// File: 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:
subq $0x1c8, %rsp            # imm = 0x1C8
movb %dl, %al
movq %rdi, 0x1c0(%rsp)
movl %esi, 0x1bc(%rsp)
andb $0x1, %al
movb %al, 0x1bb(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x28220
leaq 0x1a8(%rsp), %rdi
callq 0x28240
leaq 0x168(%rsp), %rdi
callq 0x28430
testb $0x1, 0x1bb(%rsp)
je 0x1d1b9
movq 0x50(%rsp), %rdi
addq $0xa18, %rdi            # imm = 0xA18
callq 0x28260
movq %rax, 0x160(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x50(%rsp), %rdi
addq $0xa18, %rdi            # imm = 0xA18
callq 0x282b0
movq %rax, 0x158(%rsp)
leaq 0x1b0(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x28290
testb $0x1, %al
jne 0x1cff3
jmp 0x1d1b4
leaq 0x1b0(%rsp), %rdi
callq 0x282e0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x28300
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x1a8(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x282e0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x28370
movq %rax, 0x148(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x28330
testb $0x1, %al
jne 0x1d063
jmp 0x1d196
leaq 0x1a8(%rsp), %rdi
callq 0x283a0
movl 0x10(%rax), %eax
cmpl 0x1bc(%rsp), %eax
jne 0x1d17a
leaq 0x1a8(%rsp), %rdi
callq 0x283a0
movq %rax, %rsi
leaq 0x108(%rsp), %rdi
callq 0x1aad0
jmp 0x1d09f
leaq 0x168(%rsp), %rdi
movq %rdi, 0x40(%rsp)
leaq 0x108(%rsp), %rsi
movq %rsi, 0x38(%rsp)
callq 0x28460
movq 0x38(%rsp), %rdi
callq 0x28070
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
addq $0x9e8, %rdi            # imm = 0x9E8
callq 0x27f10
movq %rax, 0x48(%rsp)
jmp 0x1d0e5
leaq 0x1a8(%rsp), %rdi
callq 0x284a0
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x28000
jmp 0x1d101
leaq 0x1b0(%rsp), %rdi
callq 0x282e0
addq $0x20, %rax
movq %rax, 0x28(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x28520
movq 0x28(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x284b0
movq %rax, 0x30(%rsp)
jmp 0x1d145
movq 0x30(%rsp), %rax
movq %rax, 0xe8(%rsp)
jmp 0x1d191
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x28070
jmp 0x1d3b4
leaq 0x1a8(%rsp), %rdi
xorl %esi, %esi
callq 0x283b0
movq %rax, 0xe0(%rsp)
jmp 0x1d024
jmp 0x1d198
leaq 0x1b0(%rsp), %rdi
xorl %esi, %esi
callq 0x283f0
movq %rax, 0xd8(%rsp)
jmp 0x1cfbc
jmp 0x1d39f
movq 0x50(%rsp), %rdi
addq $0x9e8, %rdi            # imm = 0x9E8
callq 0x28260
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x50(%rsp), %rdi
addq $0x9e8, %rdi            # imm = 0x9E8
callq 0x282b0
movq %rax, 0xc8(%rsp)
leaq 0x1b0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x28290
testb $0x1, %al
jne 0x1d219
jmp 0x1d39d
leaq 0x1b0(%rsp), %rdi
callq 0x282e0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x28300
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x1a8(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x282e0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x28370
movq %rax, 0xb8(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x28330
testb $0x1, %al
jne 0x1d289
jmp 0x1d382
leaq 0x1a8(%rsp), %rdi
callq 0x283a0
movl 0x10(%rax), %eax
cmpl 0x1bc(%rsp), %eax
jne 0x1d369
leaq 0x1a8(%rsp), %rdi
callq 0x283a0
movq %rax, %rsi
leaq 0x78(%rsp), %rdi
callq 0x1aad0
jmp 0x1d2c2
leaq 0x168(%rsp), %rdi
movq %rdi, 0x18(%rsp)
leaq 0x78(%rsp), %rsi
movq %rsi, 0x10(%rsp)
callq 0x28460
movq 0x10(%rsp), %rdi
callq 0x28070
movq 0x50(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq $0xa18, %rdi            # imm = 0xA18
callq 0x27f10
movq %rax, 0x20(%rsp)
jmp 0x1d305
leaq 0x1a8(%rsp), %rdi
callq 0x284a0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x28000
jmp 0x1d321
leaq 0x1b0(%rsp), %rdi
callq 0x282e0
addq $0x20, %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x28520
movq (%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x284b0
movq %rax, 0x8(%rsp)
jmp 0x1d35d
movq 0x8(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x1d37d
leaq 0x1a8(%rsp), %rdi
xorl %esi, %esi
callq 0x283b0
movq %rax, 0x60(%rsp)
jmp 0x1d24a
jmp 0x1d384
leaq 0x1b0(%rsp), %rdi
xorl %esi, %esi
callq 0x283f0
movq %rax, 0x58(%rsp)
jmp 0x1d1e2
jmp 0x1d39f
leaq 0x168(%rsp), %rdi
callq 0x28070
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x100(%rsp), %rdi
callq 0x8870
nopw %cs:(%rax,%rax)