Program: 132745
Project: 132745
Buggy source:
@Override public void startForeachLoop(String loopName,Var container,Var memberVar,Var loopCountVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  boolean haveKeys=loopCountVar != null;
  if (Types.isArray(container) || Types.isArrayLocal(container)) {
    assert(!haveKeys || Types.isArrayKeyVal(container,loopCountVar.asArg()));
  }
 else {
    assert(Types.isBag(container) || Types.isBagLocal(container));
    assert(!haveKeys);
  }
  boolean localContainer=Types.isContainerLocal(container);
  if (localContainer) {
    if (!arrayClosed || splitDegree >= 0) {
      throw new STCRuntimeError("String_Node_Str");
    }
    assert(Types.isElemType(container,memberVar));
  }
 else {
    assert(Types.isElemValType(container,memberVar));
  }
  if (!arrayClosed) {
    throw new STCRuntimeError("String_Node_Str");
  }
  Value tclContainer;
  if (splitDegree <= 0) {
    if (localContainer) {
      tclContainer=varToExpr(container);
    }
 else {
      tclContainer=new Value(TCLTMP_ARRAY_CONTENTS);
      pointAdd(Turbine.enumerateAll(tclContainer.variable(),varToExpr(container),haveKeys));
    }
    Expression containerSize;
    if (haveKeys) {
      containerSize=Turbine.dictSize(tclContainer);
    }
 else {
      containerSize=Turbine.listLength(tclContainer);
    }
    handleForeachContainerRefcounts(perIterIncrs,constIncrs,containerSize);
  }
 else {
    tclContainer=new Value(TCLTMP_ARRAY_CONTENTS);
    startForeachSplit(loopName,container,tclContainer.variable(),splitDegree,leafDegree,haveKeys,passedVars,perIterIncrs,constIncrs);
  }
  startForeachInner(tclContainer,memberVar,loopCountVar);
}

Fixed version (ground truth):
@Override public void startForeachLoop(String loopName,Var container,Var memberVar,Var loopCountVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  boolean haveKeys=loopCountVar != null;
  boolean isKVContainer;
  if (Types.isArray(container) || Types.isArrayLocal(container)) {
    assert(!haveKeys || Types.isArrayKeyVal(container,loopCountVar.asArg()));
    isKVContainer=true;
  }
 else {
    assert(Types.isBag(container) || Types.isBagLocal(container));
    assert(!haveKeys);
    isKVContainer=false;
  }
  boolean localContainer=Types.isContainerLocal(container);
  if (localContainer) {
    if (!arrayClosed || splitDegree >= 0) {
      throw new STCRuntimeError("String_Node_Str");
    }
    assert(Types.isElemType(container,memberVar));
  }
 else {
    assert(Types.isElemValType(container,memberVar));
  }
  if (!arrayClosed) {
    throw new STCRuntimeError("String_Node_Str");
  }
  boolean isDict;
  Value tclContainer;
  if (splitDegree <= 0) {
    if (localContainer) {
      tclContainer=varToExpr(container);
      isDict=isKVContainer;
    }
 else {
      tclContainer=new Value(TCLTMP_ARRAY_CONTENTS);
      pointAdd(Turbine.enumerateAll(tclContainer.variable(),varToExpr(container),haveKeys));
      isDict=haveKeys;
    }
    Expression containerSize;
    if (isDict) {
      containerSize=Turbine.dictSize(tclContainer);
    }
 else {
      containerSize=Turbine.listLength(tclContainer);
    }
    handleForeachContainerRefcounts(perIterIncrs,constIncrs,containerSize);
  }
 else {
    assert(!localContainer);
    tclContainer=new Value(TCLTMP_ARRAY_CONTENTS);
    startForeachSplit(loopName,container,tclContainer.variable(),splitDegree,leafDegree,haveKeys,passedVars,perIterIncrs,constIncrs);
    isDict=haveKeys;
  }
  startForeachInner(tclContainer,memberVar,loopCountVar,isDict);
}