Program: 132517
Project: 132517
Buggy source:
/** 
 * After this function is called, in the TCL context at the top of the stack will be available the bottom, top (inclusive) and increment of the split in tcl values: TCLTMP_RANGE_LO TCLTMP_RANGE_HI and TCLTMP_RANGE_INC
 * @param loopName
 * @param splitDegree
 * @param leafDegree
 * @param startE start of range (inclusive)
 * @param endE end of range (inclusive)
 * @param incrE
 * @param usedVariables
 */
private void startRangeSplit(String loopName,List<PassedVar> passedVars,List<RefCount> perIterIncrs,int splitDegree,int leafDegree,Expression startE,Expression endE,Expression incrE){
  List<String> commonFormalArgs=new ArrayList<String>();
  for (  PassedVar pv : passedVars) {
    commonFormalArgs.add(prefixVar(pv.var.name()));
  }
  Value loVal=Value.numericValue(TCLTMP_RANGE_LO);
  Value hiVal=Value.numericValue(TCLTMP_RANGE_HI);
  Value incVal=Value.numericValue(TCLTMP_RANGE_INC);
  commonFormalArgs.add(loVal.variable());
  commonFormalArgs.add(hiVal.variable());
  commonFormalArgs.add(incVal.variable());
  List<String> outerFormalArgs=new ArrayList<String>(commonFormalArgs);
  List<Expression> commonArgs=new ArrayList<Expression>();
  for (  PassedVar pv : passedVars) {
    commonArgs.add(varToExpr(pv.var));
  }
  List<Expression> outerCallArgs=new ArrayList<Expression>(commonArgs);
  outerCallArgs.add(startE);
  outerCallArgs.add(endE);
  outerCallArgs.add(incrE);
  List<Expression> innerCallArgs=new ArrayList<Expression>(commonArgs);
  innerCallArgs.add(loVal);
  innerCallArgs.add(hiVal);
  innerCallArgs.add(incVal);
  Sequence outer=new Sequence();
  String outerProcName=uniqueTCLFunctionName(loopName + "String_Node_Str");
  tree.add(new Proc(outerProcName,usedTclFunctionNames,outerFormalArgs,outer));
  Sequence inner=new Sequence();
  String innerProcName=uniqueTCLFunctionName(loopName + "String_Node_Str");
  tree.add(new Proc(innerProcName,usedTclFunctionNames,commonFormalArgs,inner));
  pointAdd(new Command(outerProcName,outerCallArgs));
  Expression done=new TclExpr(loVal,TclExpr.GT,hiVal);
  If finishedIf=new If(done,false);
  finishedIf.thenBlock().add(Command.returnCommand());
  outer.add(finishedIf);
  WhileLoop iter=new WhileLoop(LiteralInt.ONE);
  outer.add(iter);
  Value itersLeft=Value.numericValue(TCLTMP_ITERSLEFT);
  iter.loopBody().add(new SetVariable(itersLeft.variable(),rangeItersLeft(loVal,hiVal,incVal)));
  Expression doneSplitting=new TclExpr(itersLeft,TclExpr.LTE,new LiteralInt(leafDegree));
  If splitIf=new If(doneSplitting,true);
  iter.loopBody().add(splitIf);
  splitIf.thenBlock().add(new Command(innerProcName,innerCallArgs));
  splitIf.thenBlock().add(Command.returnCommand());
  splitIf.elseBlock().append(rangeDoSplit(splitDegree,leafDegree,loVal,hiVal,incVal,outerProcName,commonArgs,itersLeft));
  pointPush(inner);
}

Fixed version (ground truth):
/** 
 * After this function is called, in the TCL context at the top of the stack will be available the bottom, top (inclusive) and increment of the split in tcl values: TCLTMP_RANGE_LO TCLTMP_RANGE_HI and TCLTMP_RANGE_INC
 * @param loopName
 * @param splitDegree
 * @param leafDegree
 * @param startE start of range (inclusive)
 * @param endE end of range (inclusive)
 * @param incrE
 * @param perIterDecrs
 * @param usedVariables
 */
private void startRangeSplit(String loopName,List<PassedVar> passedVars,List<RefCount> perIterIncrs,int splitDegree,int leafDegree,Expression startE,Expression endE,Expression incrE,List<RefCount> perIterDecrs){
  List<Var> mustPass=RefCount.extractVars(perIterDecrs);
  List<String> commonFormalArgs=new ArrayList<String>();
  for (  PassedVar pv : passedVars) {
    commonFormalArgs.add(prefixVar(pv.var));
    mustPass.remove(pv.var);
  }
  for (  Var var : mustPass) {
    commonFormalArgs.add(prefixVar(var));
  }
  Value loVal=Value.numericValue(TCLTMP_RANGE_LO);
  Value hiVal=Value.numericValue(TCLTMP_RANGE_HI);
  Value incVal=Value.numericValue(TCLTMP_RANGE_INC);
  commonFormalArgs.add(loVal.variable());
  commonFormalArgs.add(hiVal.variable());
  commonFormalArgs.add(incVal.variable());
  List<String> outerFormalArgs=new ArrayList<String>(commonFormalArgs);
  List<Expression> commonArgs=new ArrayList<Expression>();
  for (  PassedVar pv : passedVars) {
    commonArgs.add(varToExpr(pv.var));
  }
  for (  Var var : mustPass) {
    commonArgs.add(varToExpr(var));
  }
  List<Expression> outerCallArgs=new ArrayList<Expression>(commonArgs);
  outerCallArgs.add(startE);
  outerCallArgs.add(endE);
  outerCallArgs.add(incrE);
  List<Expression> innerCallArgs=new ArrayList<Expression>(commonArgs);
  innerCallArgs.add(loVal);
  innerCallArgs.add(hiVal);
  innerCallArgs.add(incVal);
  Sequence outer=new Sequence();
  String outerProcName=uniqueTCLFunctionName(loopName + "String_Node_Str");
  tree.add(new Proc(outerProcName,usedTclFunctionNames,outerFormalArgs,outer));
  Sequence inner=new Sequence();
  String innerProcName=uniqueTCLFunctionName(loopName + "String_Node_Str");
  tree.add(new Proc(innerProcName,usedTclFunctionNames,commonFormalArgs,inner));
  pointAdd(new Command(outerProcName,outerCallArgs));
  Expression done=new TclExpr(loVal,TclExpr.GT,hiVal);
  If finishedIf=new If(done,false);
  finishedIf.thenBlock().add(Command.returnCommand());
  outer.add(finishedIf);
  WhileLoop iter=new WhileLoop(LiteralInt.ONE);
  outer.add(iter);
  Value itersLeft=Value.numericValue(TCLTMP_ITERSLEFT);
  iter.loopBody().add(new SetVariable(itersLeft.variable(),rangeItersLeft(loVal,hiVal,incVal)));
  Expression doneSplitting=new TclExpr(itersLeft,TclExpr.LTE,new LiteralInt(leafDegree));
  If splitIf=new If(doneSplitting,true);
  iter.loopBody().add(splitIf);
  splitIf.thenBlock().add(new Command(innerProcName,innerCallArgs));
  splitIf.thenBlock().add(Command.returnCommand());
  splitIf.elseBlock().append(rangeDoSplit(splitDegree,leafDegree,loVal,hiVal,incVal,outerProcName,commonArgs,itersLeft));
  pointPush(inner);
}