Program: 9292
Project: 9292
Buggy source:
void extractInstructionsInto(LazyMethodGen freshMethod,IntMap remap,boolean addReturn){
  LazyMethodGen.assertGoodBody(getBody(),toString());
  freshMethod.assertGoodBody();
  InstructionList freshBody=freshMethod.getBody();
  for (InstructionHandle oldIh=start.getNext(); oldIh != end; oldIh=oldIh.getNext()) {
    Instruction oldI=oldIh.getInstruction();
    Instruction freshI=(oldI == RANGEINSTRUCTION) ? oldI : Utility.copyInstruction(oldI);
    InstructionHandle freshIh;
    if (freshI instanceof BranchInstruction) {
      BranchInstruction oldBranch=(BranchInstruction)oldI;
      BranchInstruction freshBranch=(BranchInstruction)freshI;
      InstructionHandle oldTarget=oldBranch.getTarget();
      oldTarget.removeTargeter(oldBranch);
      oldTarget.addTargeter(freshBranch);
      if (freshBranch instanceof Select) {
        Select oldSelect=(Select)oldI;
        Select freshSelect=(Select)freshI;
        InstructionHandle[] oldTargets=freshSelect.getTargets();
        for (int k=oldTargets.length - 1; k >= 0; k--) {
          oldTargets[k].removeTargeter(oldSelect);
          oldTargets[k].addTargeter(freshSelect);
        }
      }
      freshIh=freshBody.append(freshBranch);
    }
 else {
      freshIh=freshBody.append(freshI);
    }
    InstructionTargeter[] sources=oldIh.getTargeters();
    if (sources != null) {
      for (int j=sources.length - 1; j >= 0; j--) {
        InstructionTargeter source=sources[j];
        if (source instanceof LocalVariableTag) {
          Shadow.Kind kind=getKind();
          if (kind == Shadow.AdviceExecution || kind == Shadow.ConstructorExecution || kind == Shadow.MethodExecution || kind == Shadow.PreInitialization || kind == Shadow.Initialization || kind == Shadow.StaticInitialization) {
            source.updateTarget(oldIh,freshIh);
          }
 else {
            source.updateTarget(oldIh,null);
          }
        }
 else         if (source instanceof Range) {
          ((Range)source).updateTarget(oldIh,freshIh,freshBody);
        }
 else {
          source.updateTarget(oldIh,freshIh);
        }
      }
    }
    if (freshI instanceof LocalVariableInstruction || freshI instanceof RET) {
      IndexedInstruction indexedI=(IndexedInstruction)freshI;
      int oldIndex=indexedI.getIndex();
      int freshIndex;
      if (!remap.hasKey(oldIndex)) {
        freshIndex=freshMethod.allocateLocal(2);
        remap.put(oldIndex,freshIndex);
      }
 else {
        freshIndex=remap.get(oldIndex);
      }
      indexedI.setIndex(freshIndex);
    }
  }
  try {
    for (InstructionHandle oldIh=start.getNext(); oldIh != end; ) {
      InstructionHandle next=oldIh.getNext();
      body.delete(oldIh);
      oldIh=next;
    }
  }
 catch (  TargetLostException e) {
    throw new BCException("String_Node_Str");
  }
  InstructionHandle ret=null;
  if (addReturn) {
    ret=freshBody.append(InstructionFactory.createReturn(freshMethod.getReturnType()));
  }
  InstructionTargeter[] ts=end.getTargeters();
  if (ts != null) {
    for (int j=ts.length - 1; j >= 0; j--) {
      InstructionTargeter t=ts[j];
      if (t == this)       continue;
      if (!addReturn) {
        throw new BCException("String_Node_Str");
      }
 else {
        t.updateTarget(end,ret);
      }
    }
  }
  LazyMethodGen.assertGoodBody(getBody(),toString());
  freshMethod.assertGoodBody();
}

Fixed version (ground truth):
void extractInstructionsInto(LazyMethodGen freshMethod,IntMap remap,boolean addReturn){
  LazyMethodGen.assertGoodBody(getBody(),toString());
  freshMethod.assertGoodBody();
  InstructionList freshBody=freshMethod.getBody();
  for (InstructionHandle oldIh=start.getNext(); oldIh != end; oldIh=oldIh.getNext()) {
    Instruction oldI=oldIh.getInstruction();
    Instruction freshI=(oldI == RANGEINSTRUCTION) ? oldI : Utility.copyInstruction(oldI);
    InstructionHandle freshIh;
    if (freshI instanceof BranchInstruction) {
      BranchInstruction oldBranch=(BranchInstruction)oldI;
      BranchInstruction freshBranch=(BranchInstruction)freshI;
      InstructionHandle oldTarget=oldBranch.getTarget();
      oldTarget.removeTargeter(oldBranch);
      oldTarget.addTargeter(freshBranch);
      if (freshBranch instanceof Select) {
        Select oldSelect=(Select)oldI;
        Select freshSelect=(Select)freshI;
        InstructionHandle[] oldTargets=freshSelect.getTargets();
        for (int k=oldTargets.length - 1; k >= 0; k--) {
          oldTargets[k].removeTargeter(oldSelect);
          oldTargets[k].addTargeter(freshSelect);
        }
      }
      freshIh=freshBody.append(freshBranch);
    }
 else {
      freshIh=freshBody.append(freshI);
    }
    InstructionTargeter[] sources=oldIh.getTargeters();
    if (sources != null) {
      for (int j=sources.length - 1; j >= 0; j--) {
        InstructionTargeter source=sources[j];
        if (source instanceof LocalVariableTag) {
          Shadow.Kind kind=getKind();
          if (kind == Shadow.AdviceExecution || kind == Shadow.ConstructorExecution || kind == Shadow.MethodExecution || kind == Shadow.PreInitialization || kind == Shadow.Initialization || kind == Shadow.StaticInitialization) {
            source.updateTarget(oldIh,freshIh);
          }
 else {
            source.updateTarget(oldIh,null);
          }
        }
 else         if (source instanceof Range) {
          ((Range)source).updateTarget(oldIh,freshIh,freshBody);
        }
 else {
          source.updateTarget(oldIh,freshIh);
        }
      }
    }
    if (freshI instanceof LocalVariableInstruction || freshI instanceof RET) {
      IndexedInstruction indexedI=(IndexedInstruction)freshI;
      int oldIndex=indexedI.getIndex();
      int freshIndex;
      if (!remap.hasKey(oldIndex)) {
        freshIndex=freshMethod.allocateLocal(2);
        remap.put(oldIndex,freshIndex);
      }
 else {
        freshIndex=remap.get(oldIndex);
      }
      indexedI.setIndex(freshIndex);
    }
  }
  for (InstructionHandle newIh=freshBody.getStart(); newIh != freshBody.getEnd(); newIh=newIh.getNext()) {
    InstructionTargeter[] sources=newIh.getTargeters();
    if (sources != null) {
      for (int i=sources.length - 1; i >= 0; i--) {
        if (sources[i] instanceof LocalVariableTag) {
          LocalVariableTag lvt=(LocalVariableTag)sources[i];
          if (!lvt.isRemapped() && remap.hasKey(lvt.getSlot())) {
            lvt.updateSlot(remap.get(lvt.getSlot()));
          }
        }
      }
    }
  }
  try {
    for (InstructionHandle oldIh=start.getNext(); oldIh != end; ) {
      InstructionHandle next=oldIh.getNext();
      body.delete(oldIh);
      oldIh=next;
    }
  }
 catch (  TargetLostException e) {
    throw new BCException("String_Node_Str");
  }
  InstructionHandle ret=null;
  if (addReturn) {
    ret=freshBody.append(InstructionFactory.createReturn(freshMethod.getReturnType()));
  }
  InstructionTargeter[] ts=end.getTargeters();
  if (ts != null) {
    for (int j=ts.length - 1; j >= 0; j--) {
      InstructionTargeter t=ts[j];
      if (t == this)       continue;
      if (!addReturn) {
        throw new BCException("String_Node_Str");
      }
 else {
        t.updateTarget(end,ret);
      }
    }
  }
  LazyMethodGen.assertGoodBody(getBody(),toString());
  freshMethod.assertGoodBody();
}