nus-yam/ex-repair huggingface dataset:
Program: 133076
Project: 133076
Buggy source:
private void elimRefCountsCont(Logger logger,Function f,Continuation cont,Set<Var> parentAssignedAliasVars){
  for (  Block block : cont.getBlocks()) {
    Counters<Var> readIncrements=new Counters<Var>();
    Counters<Var> writeIncrements=new Counters<Var>();
    if (cont.isAsync() && cont.getType() == ContinuationType.WAIT_STATEMENT) {
      for (      Var keepOpen : cont.getKeepOpenVars()) {
        if (RefCounting.hasWriteRefCount(keepOpen)) {
          writeIncrements.decrement(keepOpen);
        }
      }
      for (      Var passedIn : cont.getPassedInVars()) {
        if (RefCounting.hasReadRefCount(passedIn)) {
          readIncrements.decrement(passedIn);
        }
      }
    }
    elimRefCountsRec(logger,f,block,readIncrements,writeIncrements,parentAssignedAliasVars);
  }
}

Fixed version (ground truth):
private void elimRefCountsCont(Logger logger,Function f,Continuation cont,HierarchicalSet<Var> parentAssignedAliasVars){
  for (  Block block : cont.getBlocks()) {
    Counters<Var> readIncrements=new Counters<Var>();
    Counters<Var> writeIncrements=new Counters<Var>();
    if (isSingleSpawnCont(cont)) {
      for (      Var keepOpen : cont.getKeepOpenVars()) {
        if (RefCounting.hasWriteRefCount(keepOpen)) {
          writeIncrements.decrement(keepOpen);
        }
      }
      for (      Var passedIn : cont.getPassedInVars()) {
        if (RefCounting.hasReadRefCount(passedIn)) {
          readIncrements.decrement(passedIn);
        }
      }
    }
    HierarchicalSet<Var> contAssignedAliasVars=parentAssignedAliasVars.makeChild();
    for (    Var v : cont.constructDefinedVars()) {
      contAssignedAliasVars.add(v);
    }
    elimRefCountsRec(logger,f,block,readIncrements,writeIncrements,contAssignedAliasVars);
  }
}
Program: 133077
Project: 133077
Buggy source:
/** 
 * Update variable passing for nested continuation
 * @param logger
 * @param function
 * @param continuation
 * @param visible
 * @param referencedGlobals
 * @param outerBlockVars
 * @param neededVars
 */
private static void fixupContinuationRec(Logger logger,Function function,Continuation continuation,HierarchicalMap<String,Var> visible,Set<String> referencedGlobals,Set<String> outerBlockVars,Set<String> neededVars){
  List<Var> constructVars=continuation.constructDefinedVars();
  List<String> constructVarNames=null;
  if (constructVars != null) {
    constructVarNames=Var.nameList(constructVars);
  }
  for (  Block innerBlock : continuation.getBlocks()) {
    HierarchicalMap<String,Var> childVisible=visible.makeChildMap();
    if (constructVars != null) {
      for (      Var v : constructVars) {
        childVisible.put(v.name(),v);
      }
    }
    HashSet<String> innerNeededVars=fixupBlockRec(logger,function,innerBlock,childVisible,referencedGlobals);
    if (constructVarNames != null) {
      innerNeededVars.removeAll(constructVarNames);
    }
    if (continuation.inheritsParentVars()) {
      innerNeededVars.removeAll(outerBlockVars);
      neededVars.addAll(innerNeededVars);
    }
 else {
      rebuildContinuationPassedVars(function,continuation,visible,outerBlockVars,neededVars,innerNeededVars);
    }
  }
}

Fixed version (ground truth):
/** 
 * Update variable passing for nested continuation
 * @param logger
 * @param function
 * @param continuation
 * @param visible
 * @param referencedGlobals
 * @param outerBlockVars
 * @param neededVars
 */
private static void fixupContinuationRec(Logger logger,Function function,Continuation continuation,HierarchicalMap<String,Var> visible,Set<String> referencedGlobals,Set<String> outerBlockVars,Set<String> neededVars){
  List<Var> constructVars=continuation.constructDefinedVars();
  List<String> constructVarNames=Var.nameList(constructVars);
  for (  Block innerBlock : continuation.getBlocks()) {
    HierarchicalMap<String,Var> childVisible=visible.makeChildMap();
    for (    Var v : constructVars) {
      childVisible.put(v.name(),v);
    }
    HashSet<String> innerNeededVars=fixupBlockRec(logger,function,innerBlock,childVisible,referencedGlobals);
    if (!constructVarNames.isEmpty()) {
      innerNeededVars.removeAll(constructVarNames);
    }
    if (continuation.inheritsParentVars()) {
      innerNeededVars.removeAll(outerBlockVars);
      neededVars.addAll(innerNeededVars);
    }
 else {
      rebuildContinuationPassedVars(function,continuation,visible,outerBlockVars,neededVars,innerNeededVars);
    }
  }
}
Program: 133078
Project: 133078
Buggy source:
/** 
 * Set up renames for local variables in inline block
 * @param prog program
 * @param targetFunction function block being inlined into
 * @param inlineBlock block to be inlined
 * @param replacements updated with new renames
 */
private void chooseUniqueNames(Logger logger,Program prog,Function targetFunction,Block inlineBlock,Map<String,Arg> replacements){
  Set<String> excludedNames=new HashSet<String>();
  excludedNames.addAll(prog.getGlobalConsts().keySet());
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(inlineBlock);
  while (!blocks.isEmpty()) {
    Block block=blocks.pop();
    for (    Var v : block.getVariables()) {
      if (v.defType() != DefType.GLOBAL_CONST) {
        updateName(logger,block,targetFunction,replacements,excludedNames,v);
      }
    }
    for (    Continuation c : block.getContinuations()) {
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null) {
        for (        Var cv : constructVars) {
          updateName(logger,block,targetFunction,replacements,excludedNames,cv);
        }
      }
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Set up renames for local variables in inline block
 * @param prog program
 * @param targetFunction function block being inlined into
 * @param inlineBlock block to be inlined
 * @param replacements updated with new renames
 */
private void chooseUniqueNames(Logger logger,Program prog,Function targetFunction,Block inlineBlock,Map<String,Arg> replacements){
  Set<String> excludedNames=new HashSet<String>();
  excludedNames.addAll(prog.getGlobalConsts().keySet());
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(inlineBlock);
  while (!blocks.isEmpty()) {
    Block block=blocks.pop();
    for (    Var v : block.getVariables()) {
      if (v.defType() != DefType.GLOBAL_CONST) {
        updateName(logger,block,targetFunction,replacements,excludedNames,v);
      }
    }
    for (    Continuation c : block.getContinuations()) {
      for (      Var cv : c.constructDefinedVars()) {
        updateName(logger,block,targetFunction,replacements,excludedNames,cv);
      }
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
}
Program: 133080
Project: 133080
Buggy source:
private void checkCleanups(Function fn,Block block){
  Set<String> blockVarNames=Var.nameSet(block.getVariables());
  if (block.getType() == BlockType.MAIN_BLOCK) {
    blockVarNames.addAll(Var.nameList(fn.getInputList()));
    blockVarNames.addAll(Var.nameList(fn.getOutputList()));
  }
 else {
    List<Var> constructVars=block.getParentCont().constructDefinedVars();
    if (constructVars != null) {
      blockVarNames.addAll(Var.nameList(constructVars));
    }
  }
  for (  CleanupAction ca : block.getCleanups()) {
    if (!blockVarNames.contains(ca.var().name())) {
      if (ca.action().op != Opcode.DECR_WRITERS) {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + ca.var() + "String_Node_Str"+ fn.getName()+ "String_Node_Str"+ "String_Node_Str"+ blockVarNames);
      }
    }
  }
}

Fixed version (ground truth):
private void checkCleanups(Function fn,Block block){
  Set<String> blockVarNames=Var.nameSet(block.getVariables());
  if (block.getType() == BlockType.MAIN_BLOCK) {
    blockVarNames.addAll(Var.nameList(fn.getInputList()));
    blockVarNames.addAll(Var.nameList(fn.getOutputList()));
  }
 else {
    List<Var> constructVars=block.getParentCont().constructDefinedVars();
    blockVarNames.addAll(Var.nameList(constructVars));
  }
  for (  CleanupAction ca : block.getCleanups()) {
    if (!blockVarNames.contains(ca.var().name())) {
      if (ca.action().op != Opcode.DECR_WRITERS) {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + ca.var() + "String_Node_Str"+ fn.getName()+ "String_Node_Str"+ "String_Node_Str"+ blockVarNames);
      }
    }
  }
}
Program: 133081
Project: 133081
Buggy source:
private void checkUniqueVarNames(Logger logger,Program program,Function fn,Block block,Set<String> usedNames){
  for (  Var v : block.getVariables()) {
    checkVarUnique(logger,program,fn,usedNames,v);
  }
  if (checkCleanups)   checkCleanups(fn,block);
  for (  Continuation c : block.getContinuations()) {
    List<Var> constructDefined=c.constructDefinedVars();
    if (constructDefined != null) {
      for (      Var v : constructDefined) {
        checkVarUnique(logger,program,fn,usedNames,v);
      }
    }
    for (    Block inner : c.getBlocks()) {
      checkUniqueVarNames(logger,program,fn,inner,usedNames);
    }
  }
}

Fixed version (ground truth):
private void checkUniqueVarNames(Logger logger,Program program,Function fn,Block block,Set<String> usedNames){
  for (  Var v : block.getVariables()) {
    checkVarUnique(logger,program,fn,usedNames,v);
  }
  if (checkCleanups)   checkCleanups(fn,block);
  for (  Continuation c : block.getContinuations()) {
    for (    Var v : c.constructDefinedVars()) {
      checkVarUnique(logger,program,fn,usedNames,v);
    }
    for (    Block inner : c.getBlocks()) {
      checkUniqueVarNames(logger,program,fn,inner,usedNames);
    }
  }
}
Program: 133082
Project: 133082
Buggy source:
@Override public List<Var> constructDefinedVars(){
  return null;
}

Fixed version (ground truth):
@Override public List<Var> constructDefinedVars(){
  return Collections.emptyList();
}
Program: 133083
Project: 133083
Buggy source:
public boolean varNameUsed(String name){
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(this.mainBlock);
  while (!blocks.isEmpty()) {
    Block curr=blocks.pop();
    for (    Var v : curr.variables) {
      if (v.name().equals(name))       return true;
    }
    for (    Continuation c : curr.getContinuations()) {
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null)       for (      Var cv : constructVars)       if (cv.name().equals(name))       return true;
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean varNameUsed(String name){
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(this.mainBlock);
  while (!blocks.isEmpty()) {
    Block curr=blocks.pop();
    for (    Var v : curr.variables) {
      if (v.name().equals(name))       return true;
    }
    for (    Continuation c : curr.getContinuations()) {
      for (      Var cv : c.constructDefinedVars())       if (cv.name().equals(name))       return true;
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
  return false;
}
Program: 133084
Project: 133084
Buggy source:
private void elimRefCountsCont(Logger logger,Function f,Continuation cont){
  Counters<Var> readIncrements=new Counters<Var>();
  Counters<Var> writeIncrements=new Counters<Var>();
  if (cont.isAsync() && cont.getType() == ContinuationType.WAIT_STATEMENT) {
    for (    Var keepOpen : cont.getKeepOpenVars()) {
      if (RefCounting.hasWriteRefCount(keepOpen)) {
        writeIncrements.decrement(keepOpen);
      }
    }
    for (    Var passedIn : cont.getPassedInVars()) {
      if (RefCounting.hasReadRefCount(passedIn)) {
        readIncrements.decrement(passedIn);
      }
    }
  }
  for (  Block block : cont.getBlocks()) {
    elimRefCountsRec(logger,f,block,readIncrements,writeIncrements);
  }
}

Fixed version (ground truth):
private void elimRefCountsCont(Logger logger,Function f,Continuation cont){
  for (  Block block : cont.getBlocks()) {
    Counters<Var> readIncrements=new Counters<Var>();
    Counters<Var> writeIncrements=new Counters<Var>();
    if (cont.isAsync() && cont.getType() == ContinuationType.WAIT_STATEMENT) {
      for (      Var keepOpen : cont.getKeepOpenVars()) {
        if (RefCounting.hasWriteRefCount(keepOpen)) {
          writeIncrements.decrement(keepOpen);
        }
      }
      for (      Var passedIn : cont.getPassedInVars()) {
        if (RefCounting.hasReadRefCount(passedIn)) {
          readIncrements.decrement(passedIn);
        }
      }
    }
    elimRefCountsRec(logger,f,block,readIncrements,writeIncrements);
  }
}
Program: 133085
Project: 133085
Buggy source:
private void checkVarReference(Map<String,Var> declared,Var referencedVar){
  assert(declared.containsKey(referencedVar.name()));
  assert(referencedVar.identical(declared.get(referencedVar.name())));
}

Fixed version (ground truth):
private void checkVarReference(Map<String,Var> declared,Var referencedVar){
}
Program: 133086
Project: 133086
Buggy source:
/** 
 * Rename variables in block (and nested blocks) according to map. If the map doesn't have an entry, we don't rename anything
 * @param inputsOnly  if true, only change references which are readingthe var.  if false, completely remove the old variable and replace  with new
 * @param renames OldName -> NewName
 */
public void renameVars(Map<Var,Arg> renames,boolean inputsOnly){
  if (!inputsOnly) {
    renameVarsInBlockVarsList(renames);
  }
  for (  Instruction i : instructions) {
    if (inputsOnly) {
      i.renameInputs(renames);
    }
 else {
      i.renameVars(renames);
    }
  }
  for (  Continuation c : continuations) {
    c.replaceVars(renames,inputsOnly,true);
  }
  renameCleanupActions(renames,inputsOnly);
}

Fixed version (ground truth):
/** 
 * Rename variables in block (and nested blocks) according to map. If the map doesn't have an entry, we don't rename anything
 * @param inputsOnly  if true, only change references which are readingthe var.  if false, completely remove the old variable and replace  with new
 * @param renames OldName -> NewName
 */
public void renameVars(Map<Var,Arg> renames,boolean inputsOnly){
  renameInDefs(renames,inputsOnly);
  renameInCode(renames,inputsOnly);
}
Program: 133087
Project: 133087
Buggy source:
public static Var declareLocalOutputVar(Block block,Var var,String valName){
  Var valOut=block.declareVariable(Types.derefResultType(var.type()),valName,VarStorage.LOCAL,DefType.LOCAL_COMPILER,null);
  if (valOut.type().equals(Types.V_BLOB)) {
    block.addCleanup(valOut,TurbineOp.freeBlob(valOut));
  }
  return valOut;
}

Fixed version (ground truth):
public static Var declareLocalOutputVar(Block block,Var var,String valName){
  Var valOut=block.declareVariable(Types.derefResultType(var.type()),valName,VarStorage.LOCAL,DefType.LOCAL_COMPILER,null);
  if (valOut.type().equals(Types.V_BLOB)) {
    block.addCleanup(valOut,TurbineOp.freeBlob(valOut));
  }
 else   if (valOut.type().equals(Types.V_FILE)) {
    block.addCleanup(valOut,TurbineOp.decrLocalFileRef(valOut));
  }
  return valOut;
}
Program: 133089
Project: 133089
Buggy source:
public static Instruction futureSet(Var dst,Arg src){
  assert(Types.isScalarFuture(dst.type()));
switch (dst.type().primType()) {
case BOOL:
    assert(src.isImmediateBool());
  return TurbineOp.assignBool(dst,src);
case INT:
assert(src.isImmediateInt());
return TurbineOp.assignInt(dst,src);
case FLOAT:
assert(src.isImmediateFloat());
return TurbineOp.assignFloat(dst,src);
case STRING:
assert(src.isImmediateString());
return TurbineOp.assignString(dst,src);
case BLOB:
assert(src.isImmediateBlob());
return TurbineOp.assignBlob(dst,src);
case VOID:
assert(src.isVar() && src.getVar().type().equals(Types.V_VOID));
return TurbineOp.assignVoid(dst,src);
default :
throw new STCRuntimeError("String_Node_Str" + dst.type().typeName() + "String_Node_Str");
}
}

Fixed version (ground truth):
public static Instruction futureSet(Var dst,Arg src){
  assert(Types.isScalarFuture(dst.type()));
switch (dst.type().primType()) {
case BOOL:
    assert(src.isImmediateBool());
  return TurbineOp.assignBool(dst,src);
case INT:
assert(src.isImmediateInt());
return TurbineOp.assignInt(dst,src);
case FLOAT:
assert(src.isImmediateFloat());
return TurbineOp.assignFloat(dst,src);
case STRING:
assert(src.isImmediateString());
return TurbineOp.assignString(dst,src);
case BLOB:
assert(src.isImmediateBlob());
return TurbineOp.assignBlob(dst,src);
case VOID:
assert(src.isVar() && src.getVar().type().equals(Types.V_VOID));
return TurbineOp.assignVoid(dst,src);
case FILE:
assert(src.isVar() && src.getVar().type().equals(Types.V_FILE));
return TurbineOp.assignFile(dst,src);
default :
throw new STCRuntimeError("String_Node_Str" + dst.type().typeName() + "String_Node_Str");
}
}
Program: 133090
Project: 133090
Buggy source:
public static Instruction arrayCreateNestedImm(Var arrayResult,Var arrayVar,Arg arrIx){
  return new TurbineOp(Opcode.ARRAY_CREATE_NESTED_IMM,Arg.createVar(arrayResult),Arg.createVar(arrayVar),arrIx);
}

Fixed version (ground truth):
public static Instruction arrayCreateNestedImm(Var arrayResult,Var arrayVar,Arg arrIx){
  assert(arrIx.isImmediateInt());
  return new TurbineOp(Opcode.ARRAY_CREATE_NESTED_IMM,Arg.createVar(arrayResult),Arg.createVar(arrayVar),arrIx);
}
Program: 133091
Project: 133091
Buggy source:
public static Instruction arrayRefCreateNestedImmIx(Var arrayResult,Var arrayVar,Arg arrIx){
  return new TurbineOp(Opcode.ARRAY_REF_CREATE_NESTED_IMM,Arg.createVar(arrayResult),Arg.createVar(arrayVar),arrIx);
}

Fixed version (ground truth):
public static Instruction arrayRefCreateNestedImmIx(Var arrayResult,Var arrayVar,Arg arrIx){
  assert(arrIx.isImmediateInt());
  return new TurbineOp(Opcode.ARRAY_REF_CREATE_NESTED_IMM,Arg.createVar(arrayResult),Arg.createVar(arrayVar),arrIx);
}
Program: 133092
Project: 133092
Buggy source:
/** 
 * Try and merge if1 into one of statements in mergeCands If successful, call it.remove()
 * @param it
 * @param mergeCands
 * @param loop1
 */
private static void fuseForeachLoop(ListIterator<Continuation> it,LinkedList<Continuation> mergeCands,ForeachLoop loop1){
  for (  Continuation c2 : mergeCands) {
    if (c2.getType() == ContinuationType.FOREACH_LOOP) {
      ForeachLoop loop2=(ForeachLoop)c2;
      if (loop2.fuseable(loop1)) {
        loop2.fuseInto(loop1,true);
        it.remove();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Try and merge if1 into one of statements in mergeCands If successful, call it.remove()
 * @param it
 * @param mergeCands
 * @param loop1
 */
private static void fuseForeachLoop(ListIterator<Continuation> it,LinkedList<Continuation> mergeCands,ForeachLoop loop1){
  for (  Continuation c2 : mergeCands) {
    if (c2.getType() == ContinuationType.FOREACH_LOOP) {
      ForeachLoop loop2=(ForeachLoop)c2;
      if (loop2.fuseable(loop1)) {
        loop2.fuseInto(loop1,true);
        it.remove();
        return;
      }
    }
  }
}
Program: 133093
Project: 133093
Buggy source:
/** 
 * Try and merge if1 into one of statements in mergeCands If successful, call it.remove()
 * @param it
 * @param mergeCands
 * @param loop1
 */
private static void fuseRangeLoop(ListIterator<Continuation> it,LinkedList<Continuation> mergeCands,RangeLoop loop1){
  for (  Continuation c2 : mergeCands) {
    if (c2.getType() == ContinuationType.RANGE_LOOP) {
      RangeLoop loop2=(RangeLoop)c2;
      if (loop2.fuseable(loop1)) {
        loop2.fuseInto(loop1,true);
        it.remove();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Try and merge if1 into one of statements in mergeCands If successful, call it.remove()
 * @param it
 * @param mergeCands
 * @param loop1
 */
private static void fuseRangeLoop(ListIterator<Continuation> it,LinkedList<Continuation> mergeCands,RangeLoop loop1){
  for (  Continuation c2 : mergeCands) {
    if (c2.getType() == ContinuationType.RANGE_LOOP) {
      RangeLoop loop2=(RangeLoop)c2;
      if (loop2.fuseable(loop1)) {
        assert(loop2 != loop1);
        loop2.fuseInto(loop1,true);
        it.remove();
        return;
      }
    }
  }
}
Program: 133094
Project: 133094
Buggy source:
/** 
 * Try and merge if1 into one of statements in mergeCands If successful, call it.remove()
 * @param it
 * @param mergeCands
 * @param if1
 */
private static void fuseIfStatement(ListIterator<Continuation> it,LinkedList<Continuation> mergeCands,IfStatement if1){
  for (  Continuation c2 : mergeCands) {
    if (c2.getType() == ContinuationType.IF_STATEMENT) {
      IfStatement if2=(IfStatement)c2;
      if (if1.fuseable(if2)) {
        if2.fuse(if1,true);
        it.remove();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Try and merge if1 into one of statements in mergeCands If successful, call it.remove()
 * @param it
 * @param mergeCands
 * @param if1
 */
private static void fuseIfStatement(ListIterator<Continuation> it,LinkedList<Continuation> mergeCands,IfStatement if1){
  for (  Continuation c2 : mergeCands) {
    if (c2.getType() == ContinuationType.IF_STATEMENT) {
      IfStatement if2=(IfStatement)c2;
      if (if1.fuseable(if2)) {
        if2.fuse(if1,true);
        it.remove();
        return;
      }
    }
  }
}
Program: 133095
Project: 133095
Buggy source:
private static void pushdownDeclarations(Block block,Map<String,Pair<Continuation,Block>> candidates){
  if (candidates.size() > 0) {
    ListIterator<Var> varIt=block.variableIterator();
    while (varIt.hasNext()) {
      Var var=varIt.next();
      Pair<Continuation,Block> newHome=candidates.get(var.name());
      if (newHome != null) {
        varIt.remove();
        newHome.val1.removePassedInVar(var);
        newHome.val2.addVariable(var);
        block.moveCleanups(var,newHome.val2);
      }
    }
  }
}

Fixed version (ground truth):
private static void pushdownDeclarations(Block block,Map<String,Pair<Continuation,Block>> candidates){
  if (candidates.size() > 0) {
    ListIterator<Var> varIt=block.variableIterator();
    while (varIt.hasNext()) {
      Var var=varIt.next();
      Pair<Continuation,Block> newHome=candidates.get(var.name());
      if (newHome != null) {
        varIt.remove();
        Continuation cont=newHome.val1;
        if (cont.isAsync()) {
          cont.removePassedInVar(var);
        }
        newHome.val2.addVariable(var);
        block.moveCleanups(var,newHome.val2);
      }
    }
  }
}
Program: 133096
Project: 133096
Buggy source:
/** 
 * @param newCV
 * @param replace for debugging purposes, set to true if we intend to replace
 */
public void addComputedValue(ComputedValue newCV,boolean replace){
  boolean outClosed=newCV.isOutClosed();
  if (isAvailable(newCV)) {
    if (!replace) {
      throw new STCRuntimeError("String_Node_Str" + getLocation(newCV) + "String_Node_Str"+ newCV);
    }
  }
 else   if (replace) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + newCV + "String_Node_Str");
  }
  Arg valLoc=newCV.getValLocation();
  Opcode op=newCV.getOp();
  availableVals.put(newCV,valLoc);
  if (valLoc.isVar() && outClosed) {
    System.err.println(valLoc + "String_Node_Str");
    this.closed.add(valLoc.getVar().name());
  }
  if (op == Opcode.LOAD_BOOL || op == Opcode.LOAD_FLOAT || op == Opcode.LOAD_INT || op == Opcode.LOAD_STRING || op == Opcode.LOAD_VOID || op == Opcode.LOAD_FILE) {
    System.err.println(valLoc + "String_Node_Str");
    this.closed.add(newCV.getInput(0).getVar().name());
  }
}

Fixed version (ground truth):
/** 
 * @param newCV
 * @param replace for debugging purposes, set to true if we intend to replace
 */
public void addComputedValue(ComputedValue newCV,boolean replace){
  boolean outClosed=newCV.isOutClosed();
  if (isAvailable(newCV)) {
    if (!replace) {
      throw new STCRuntimeError("String_Node_Str" + getLocation(newCV) + "String_Node_Str"+ newCV);
    }
  }
 else   if (replace) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + newCV + "String_Node_Str");
  }
  Arg valLoc=newCV.getValLocation();
  Opcode op=newCV.getOp();
  availableVals.put(newCV,valLoc);
  if (valLoc.isVar() && outClosed) {
    this.closed.add(valLoc.getVar().name());
  }
  if (op == Opcode.LOAD_BOOL || op == Opcode.LOAD_FLOAT || op == Opcode.LOAD_INT || op == Opcode.LOAD_STRING || op == Opcode.LOAD_VOID || op == Opcode.LOAD_FILE) {
    this.closed.add(newCV.getInput(0).getVar().name());
  }
}
Program: 133098
Project: 133098
Buggy source:
/** 
 * Choose which inputs/outputs to an app invocation should be blocked upon.  This is somewhat complex since we sometimes need to block on filenames/file statuses/etc  
 * @param context
 * @param redirFutures 
 * @param inputs
 * @param outputs
 * @return
 * @throws UserException
 * @throws UndefinedTypeException
 */
private Pair<Map<String,Var>,List<Var>> selectAppWaitVars(Context context,List<Var> args,Redirects<Var> redirFutures) throws UserException, UndefinedTypeException {
  List<Var> allArgs=new ArrayList<Var>();
  allArgs.addAll(args);
  allArgs.addAll(redirFutures.redirections(true,true));
  Map<String,Var> fileNames=new HashMap<String,Var>();
  List<Var> waitVars=new ArrayList<Var>();
  for (  Var arg : allArgs) {
    if (Types.isFile(arg.type())) {
      if (fileNames.containsKey(arg.name())) {
        continue;
      }
      Var filenameFuture=varCreator.createFilenameAlias(context,arg);
      if (arg.defType() == DefType.OUTARG) {
        backend.getFileName(filenameFuture,arg,true);
      }
 else {
        backend.getFileName(filenameFuture,arg,false);
      }
      waitVars.add(filenameFuture);
      fileNames.put(arg.name(),filenameFuture);
      if (arg.defType() != DefType.OUTARG) {
        waitVars.add(arg);
      }
    }
 else {
      waitVars.add(arg);
    }
  }
  return Pair.create(fileNames,waitVars);
}

Fixed version (ground truth):
/** 
 * Choose which inputs/outputs to an app invocation should be blocked upon.  This is somewhat complex since we sometimes need to block on filenames/file statuses/etc  
 * @param context
 * @param redirFutures 
 * @param inputs
 * @param outputs
 * @return
 * @throws UserException
 * @throws UndefinedTypeException
 */
private Pair<Map<String,Var>,List<Var>> selectAppWaitVars(Context context,List<Var> args,List<Var> outArgs,Redirects<Var> redirFutures) throws UserException, UndefinedTypeException {
  List<Var> allArgs=new ArrayList<Var>();
  allArgs.addAll(args);
  allArgs.addAll(redirFutures.redirections(true,true));
  Map<String,Var> fileNames=new HashMap<String,Var>();
  List<Var> waitVars=new ArrayList<Var>();
  for (  Var arg : allArgs) {
    if (Types.isFile(arg.type())) {
      if (fileNames.containsKey(arg.name())) {
        continue;
      }
      loadAppFilename(context,fileNames,waitVars,arg);
    }
 else {
      waitVars.add(arg);
    }
  }
  for (  Var outArg : outArgs) {
    if (Types.isFile(outArg.type()) && !fileNames.containsKey(outArg.name())) {
      loadAppFilename(context,fileNames,waitVars,outArg);
    }
  }
  return Pair.create(fileNames,waitVars);
}
Program: 133099
Project: 133099
Buggy source:
/** 
 * @param newCV
 * @param replace for debugging purposes, set to true if we intend to replace
 */
public void addComputedValue(ComputedValue newCV,boolean replace){
  boolean outClosed=newCV.isOutClosed();
  if (isAvailable(newCV)) {
    if (!replace) {
      throw new STCRuntimeError("String_Node_Str" + getLocation(newCV) + "String_Node_Str"+ newCV);
    }
  }
 else   if (replace) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + newCV + "String_Node_Str");
  }
  Arg valLoc=newCV.getValLocation();
  Opcode op=newCV.getOp();
  availableVals.put(newCV,valLoc);
  if (valLoc.isVar() && outClosed) {
    this.closed.add(valLoc.getVar().name());
  }
  if (op == Opcode.LOAD_BOOL || op == Opcode.LOAD_FLOAT || op == Opcode.LOAD_INT || op == Opcode.LOAD_REF || op == Opcode.LOAD_STRING || op == Opcode.LOAD_VOID || op == Opcode.LOAD_FILE) {
    this.closed.add(newCV.getInput(0).getVar().name());
  }
}

Fixed version (ground truth):
/** 
 * @param newCV
 * @param replace for debugging purposes, set to true if we intend to replace
 */
public void addComputedValue(ComputedValue newCV,boolean replace){
  boolean outClosed=newCV.isOutClosed();
  if (isAvailable(newCV)) {
    if (!replace) {
      throw new STCRuntimeError("String_Node_Str" + getLocation(newCV) + "String_Node_Str"+ newCV);
    }
  }
 else   if (replace) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + newCV + "String_Node_Str");
  }
  Arg valLoc=newCV.getValLocation();
  Opcode op=newCV.getOp();
  availableVals.put(newCV,valLoc);
  if (valLoc.isVar() && outClosed) {
    System.err.println(valLoc + "String_Node_Str");
    this.closed.add(valLoc.getVar().name());
  }
  if (op == Opcode.LOAD_BOOL || op == Opcode.LOAD_FLOAT || op == Opcode.LOAD_INT || op == Opcode.LOAD_STRING || op == Opcode.LOAD_VOID || op == Opcode.LOAD_FILE) {
    System.err.println(valLoc + "String_Node_Str");
    this.closed.add(newCV.getInput(0).getVar().name());
  }
}
Program: 133100
Project: 133100
Buggy source:
private static void updateMapWithWrites(Block curr,HierarchicalMap<String,Block> writeMap){
  for (  Instruction inst : curr.getInstructions()) {
    for (    Var out : inst.getOutputs()) {
      if (trackWrites(out)) {
        writeMap.put(out.name(),curr);
      }
    }
  }
  for (  Var declared : curr.getVariables()) {
    if (Types.isArray(declared.type())) {
      writeMap.put(declared.name(),curr);
    }
  }
}

Fixed version (ground truth):
private static void updateMapWithWrites(Block curr,HierarchicalMap<String,Block> writeMap){
  for (  Instruction inst : curr.getInstructions()) {
    for (    Var out : inst.getOutputs()) {
      if (trackWrites(out)) {
        Logging.getSTCLogger().trace("String_Node_Str" + inst + "String_Node_Str"+ out);
        writeMap.put(out.name(),curr);
      }
 else {
        Logging.getSTCLogger().trace("String_Node_Str" + inst + "String_Node_Str"+ out);
      }
    }
  }
  for (  Var declared : curr.getVariables()) {
    if (Types.isArray(declared.type()) && declared.storage() != VarStorage.ALIAS) {
      writeMap.put(declared.name(),curr);
    }
  }
}
Program: 133101
Project: 133101
Buggy source:
public static List<String> varNameList(List<Arg> inputs){
  ArrayList<String> result=new ArrayList<String>();
  collectVarNames(result,inputs);
  return result;
}

Fixed version (ground truth):
public static List<String> varNameList(List<Arg> inputs,boolean nullsOk){
  ArrayList<String> result=new ArrayList<String>();
  collectVarNames(result,inputs,false);
  return result;
}
Program: 133102
Project: 133102
Buggy source:
/** 
 * Put all variable names in a collection of opargs into addTo
 */
public static void collectVarNames(Collection<String> addTo,Collection<Arg> args){
  for (  Arg o : args) {
    if (o.kind == ArgKind.VAR) {
      addTo.add(o.getVar().name());
    }
  }
}

Fixed version (ground truth):
public static void collectVarNames(Collection<String> addTo,Collection<Arg> args){
  collectVarNames(addTo,args,false);
}
Program: 133103
Project: 133103
Buggy source:
/** 
 * print a comma separated list of var names to sb
 * @param sb
 * @param args
 */
public static void prettyPrintArgList(StringBuilder sb,Collection<Arg> args){
  boolean first=true;
  for (  Arg a : args) {
    if (first) {
      first=false;
    }
 else {
      sb.append("String_Node_Str");
    }
    sb.append(a.toString());
  }
}

Fixed version (ground truth):
/** 
 * print a comma separated list of var names to sb
 * @param sb
 * @param args
 */
public static void prettyPrintArgList(StringBuilder sb,Collection<Arg> args){
  boolean first=true;
  for (  Arg a : args) {
    if (first) {
      first=false;
    }
 else {
      sb.append("String_Node_Str");
    }
    sb.append(a);
  }
}
Program: 133104
Project: 133104
Buggy source:
public static void replaceOpargsInList(Map<String,Arg> renames,List<Arg> args){
  if (renames.isEmpty()) {
    return;
  }
  for (int i=0; i < args.size(); i++) {
    Arg oa=args.get(i);
    if (oa.isVar()) {
      String oldName=oa.getVar().name();
      Arg val=renames.get(oldName);
      if (val != null) {
        args.set(i,val);
      }
    }
  }
}

Fixed version (ground truth):
public static void replaceOpargsInList(Map<String,Arg> renames,List<Arg> args,boolean nullsOk){
  if (renames.isEmpty()) {
    return;
  }
  for (int i=0; i < args.size(); i++) {
    Arg oa=args.get(i);
    if (oa == null) {
      if (nullsOk) {
        continue;
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + args);
      }
    }
    if (oa.isVar()) {
      String oldName=oa.getVar().name();
      Arg val=renames.get(oldName);
      if (val != null) {
        args.set(i,val);
      }
    }
  }
}
Program: 133106
Project: 133106
Buggy source:
private static void pushdownDeclarations(Block block,Map<String,Block> candidates){
  if (candidates.size() > 0) {
    ListIterator<Var> varIt=block.variableIterator();
    while (varIt.hasNext()) {
      Var var=varIt.next();
      Block newHome=candidates.get(var.name());
      if (newHome != null) {
        varIt.remove();
        newHome.addVariable(var);
        block.moveCleanups(var,newHome);
      }
    }
  }
}

Fixed version (ground truth):
private static void pushdownDeclarations(Block block,Map<String,Pair<Continuation,Block>> candidates){
  if (candidates.size() > 0) {
    ListIterator<Var> varIt=block.variableIterator();
    while (varIt.hasNext()) {
      Var var=varIt.next();
      Pair<Continuation,Block> newHome=candidates.get(var.name());
      if (newHome != null) {
        varIt.remove();
        newHome.val1.removePassedInVar(var);
        newHome.val2.addVariable(var);
        block.moveCleanups(var,newHome.val2);
      }
    }
  }
}
Program: 133108
Project: 133108
Buggy source:
public static void fixupImmChange(Block block,MakeImmChange change,List<Instruction> instBuffer,List<Var> newOutVars,List<Var> oldOutVars){
  for (  Instruction newInst : change.newInsts) {
    instBuffer.add(newInst);
  }
  if (!change.isOutVarSame()) {
    Var newOut=change.newOut;
    Var oldOut=change.oldOut;
    OptUtil.replaceInstructionOutputVar(block,instBuffer,newOut,oldOut);
  }
  if (newOutVars != null) {
    for (int i=0; i < newOutVars.size(); i++) {
      Var oldOut=oldOutVars.get(i);
      Var newOut=newOutVars.get(i);
      instBuffer.add(ICInstructions.futureSet(oldOut,Arg.createVar(newOut)));
    }
  }
}

Fixed version (ground truth):
public static void fixupImmChange(Block srcBlock,Block targetBlock,MakeImmChange change,List<Instruction> instBuffer,List<Var> newOutVars,List<Var> oldOutVars){
  for (  Instruction newInst : change.newInsts) {
    instBuffer.add(newInst);
  }
  if (!change.isOutVarSame()) {
    Var newOut=change.newOut;
    Var oldOut=change.oldOut;
    OptUtil.replaceInstructionOutputVar(srcBlock,instBuffer,newOut,oldOut);
  }
  if (newOutVars != null) {
    for (int i=0; i < newOutVars.size(); i++) {
      Var oldOut=oldOutVars.get(i);
      Var newOut=newOutVars.get(i);
      instBuffer.add(ICInstructions.futureSet(oldOut,Arg.createVar(newOut)));
    }
  }
}
Program: 133110
Project: 133110
Buggy source:
public static void fixupVariablePassing(Logger logger,Program prog,Function fn,Set<String> referencedGlobals){
  HierarchicalMap<String,Var> fnargs=new HierarchicalMap<String,Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Entry<String,Arg> e : prog.getGlobalConsts().entrySet()) {
    Arg a=e.getValue();
    Var v=new Var(a.getType(),e.getKey(),VarStorage.GLOBAL_CONST,DefType.GLOBAL_CONST,null);
    fnargs.put(e.getKey(),v);
  }
  HashSet<String> neededVars=fixupVariablePassing(logger,fn.getMainblock(),fnargs,referencedGlobals);
  neededVars.removeAll(Var.nameList(fn.getInputList()));
  neededVars.removeAll(Var.nameList(fn.getOutputList()));
  if (neededVars.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ neededVars.toString());
  }
}

Fixed version (ground truth):
public static void fixupVariablePassing(Logger logger,Program prog,Function fn,Set<String> referencedGlobals){
  HierarchicalMap<String,Var> fnargs=new HierarchicalMap<String,Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Entry<String,Arg> e : prog.getGlobalConsts().entrySet()) {
    Arg a=e.getValue();
    Var v=new Var(a.getType(),e.getKey(),VarStorage.GLOBAL_CONST,DefType.GLOBAL_CONST,null);
    fnargs.put(e.getKey(),v);
  }
  HashSet<String> neededVars=fixupVariablePassing(logger,fn,fn.getMainblock(),fnargs,referencedGlobals);
  neededVars.removeAll(Var.nameList(fn.getInputList()));
  neededVars.removeAll(Var.nameList(fn.getOutputList()));
  if (neededVars.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ neededVars.toString());
  }
}
Program: 133111
Project: 133111
Buggy source:
private void updateName(Logger logger,Block block,Function targetFunction,Map<String,Arg> replacements,Set<String> excludedNames,Var var){
  String newName=targetFunction.getMainblock().uniqueVarName(var.name(),excludedNames);
  Var newVar=new Var(var.type(),newName,var.storage(),var.defType(),var.mapping());
  replacements.put(var.name(),Arg.createVar(newVar));
  excludedNames.add(newName);
  UniqueVarNames.replaceCleanup(block,var,newVar);
  logger.trace("String_Node_Str" + var + "String_Node_Str"+ newVar+ "String_Node_Str"+ targetFunction.getName());
}

Fixed version (ground truth):
private void updateName(Logger logger,Block block,Function targetFunction,Map<String,Arg> replacements,Set<String> excludedNames,Var var){
  String newName=targetFunction.getMainblock().uniqueVarName(var.name(),excludedNames);
  Var newVar=new Var(var.type(),newName,var.storage(),var.defType(),var.mapping());
  assert(!replacements.containsKey(newName));
  replacements.put(var.name(),Arg.createVar(newVar));
  excludedNames.add(newName);
  UniqueVarNames.replaceCleanup(block,var,newVar);
  logger.trace("String_Node_Str" + var + "String_Node_Str"+ newVar+ "String_Node_Str"+ targetFunction.getName());
}
Program: 133112
Project: 133112
Buggy source:
public static void fixupVariablePassing(Logger logger,Program prog,Function fn,Set<String> referencedGlobals){
  HierarchicalMap<String,Var> fnargs=new HierarchicalMap<String,Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Entry<String,Arg> e : prog.getGlobalConsts().entrySet()) {
    Arg a=e.getValue();
    Var v=new Var(a.getType(),e.getKey(),VarStorage.GLOBAL_CONST,DefType.GLOBAL_CONST,null);
    fnargs.put(e.getKey(),v);
  }
  HashSet<String> neededVars=fixupVariablePassing(logger,fn.getMainblock(),fnargs);
  neededVars.removeAll(Var.nameList(fn.getInputList()));
  neededVars.removeAll(Var.nameList(fn.getOutputList()));
  if (neededVars.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ neededVars.toString());
  }
}

Fixed version (ground truth):
public static void fixupVariablePassing(Logger logger,Program prog,Function fn,Set<String> referencedGlobals){
  HierarchicalMap<String,Var> fnargs=new HierarchicalMap<String,Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.put(v.name(),v);
  }
  for (  Entry<String,Arg> e : prog.getGlobalConsts().entrySet()) {
    Arg a=e.getValue();
    Var v=new Var(a.getType(),e.getKey(),VarStorage.GLOBAL_CONST,DefType.GLOBAL_CONST,null);
    fnargs.put(e.getKey(),v);
  }
  HashSet<String> neededVars=fixupVariablePassing(logger,fn.getMainblock(),fnargs,referencedGlobals);
  neededVars.removeAll(Var.nameList(fn.getInputList()));
  neededVars.removeAll(Var.nameList(fn.getOutputList()));
  if (neededVars.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ neededVars.toString());
  }
}
Program: 133113
Project: 133113
Buggy source:
protected void fuseIntoAbstract(AbstractLoop o,boolean insertAtTop){
  this.loopBody.insertInline(o.loopBody,insertAtTop);
  this.addKeepOpenVars(o.keepOpenVars);
  ICUtil.removeDuplicates(this.keepOpenVars);
  this.addPassedInVars(o.passedInVars);
  ICUtil.removeDuplicates(this.passedInVars);
}

Fixed version (ground truth):
protected void fuseIntoAbstract(AbstractLoop o,boolean insertAtTop){
  this.loopBody.insertInline(o.loopBody,insertAtTop);
  this.addKeepOpenVars(o.keepOpenVars);
  ICUtil.removeDuplicates(this.keepOpenVars);
  this.addPassedInVars(o.passedInVars);
}
Program: 133114
Project: 133114
Buggy source:
public AbstractLoop(Block block,List<Var> usedVars,List<Var> keepOpenVars){
  super(usedVars,keepOpenVars);
  this.loopBody=block;
  this.loopBody.setParent(this);
}

Fixed version (ground truth):
public AbstractLoop(Block loopBody,List<Var> usedVars,List<Var> keepOpenVars){
  super(usedVars,keepOpenVars);
  this.loopBody=loopBody;
  this.loopBody.setParent(this);
}
Program: 133115
Project: 133115
Buggy source:
@Override public void addPassedInVars(Collection<Var> vars){
  super.addPassedInVars(vars);
  this.loopContinue.removeUsedVars(vars);
  this.loopBreak.removeUsedVars(vars);
}

Fixed version (ground truth):
@Override public void addPassedInVars(Collection<Var> vars){
  super.addPassedInVars(vars);
  this.loopContinue.addUsedVars(vars);
  this.loopBreak.addUsedVars(vars);
}
Program: 133116
Project: 133116
Buggy source:
private Pair<LoopBreak,LoopContinue> findInstructions(Block body){
}

Fixed version (ground truth):
private Pair<LoopBreak,LoopContinue> findInstructions(){
}
Program: 133117
Project: 133117
Buggy source:
public void addUsedVar(Var variable){
  this.loopUsedVars.add(variable);
}

Fixed version (ground truth):
public void addUsedVar(Var variable){
  this.loopUsedVars.add(variable);
  ICUtil.removeDuplicates(this.loopUsedVars);
}
Program: 133118
Project: 133118
Buggy source:
private void decrementAllRefs(List<Var> usedVars,List<Var> keepOpenVars,Expression refDecrAmount){
  List<Var> readOnlyUsedVars=Var.varListDiff(usedVars,keepOpenVars);
  pointStack.peek().append(decrementReaders(readOnlyUsedVars,refDecrAmount));
  pointStack.peek().append(decrementWriters(keepOpenVars,refDecrAmount));
}

Fixed version (ground truth):
private void decrementAllRefs(List<Var> usedVars,List<Var> keepOpenVars,Expression refDecrAmount){
  keepOpenVars=RefCounting.filterWriteRefcount(keepOpenVars);
  List<Var> readOnlyUsedVars=Var.varListDiff(usedVars,keepOpenVars);
  pointStack.peek().append(decrementReaders(readOnlyUsedVars,refDecrAmount));
  pointStack.peek().append(decrementWriters(keepOpenVars,refDecrAmount));
}
Program: 133119
Project: 133119
Buggy source:
private void incrementAllRefs(List<Var> usedVars,List<Var> keepOpenVars,Expression refIncrAmount){
  List<Var> readOnlyUsedVars=Var.varListDiff(usedVars,keepOpenVars);
  pointStack.peek().append(incrementReaders(readOnlyUsedVars,refIncrAmount));
  pointStack.peek().append(incrementWriters(keepOpenVars,refIncrAmount));
}

Fixed version (ground truth):
/** 
 * Increment reference counts upon calling something asynchronously. It is valid to call this function with usedVars = <all variables from outer scope that are used in new scope> keepOpenVars = <all variables written in new scope>
 * @param usedVars any variables used in the new scope.  If thereis overlap with keepOpenVars, only the write refcount is used
 * @param keepOpenVars any written variables for which write refcount mayneed to be maintained.  Any variables without write refcount are filtered out, so it is valid to just pass a list of all variables written in new scope. 
 */
private void incrementAllRefs(List<Var> usedVars,List<Var> keepOpenVars,Expression refIncrAmount){
  keepOpenVars=RefCounting.filterWriteRefcount(keepOpenVars);
  List<Var> readOnlyUsedVars=Var.varListDiff(usedVars,keepOpenVars);
  pointStack.peek().append(incrementReaders(readOnlyUsedVars,refIncrAmount));
  pointStack.peek().append(incrementWriters(keepOpenVars,refIncrAmount));
}
Program: 133121
Project: 133121
Buggy source:
public void addVariable(Var variable){
  this.variables.add(variable);
}

Fixed version (ground truth):
public void addVariable(Var variable,boolean atTop){
  if (atTop) {
    this.variables.add(0,variable);
  }
 else {
    this.variables.add(variable);
  }
}
Program: 133122
Project: 133122
Buggy source:
private void findEssentialVars(Set<String> stillNeeded,List<List<Var>> interdependencies){
  for (  Var v : variables) {
    if (v.isMapped()) {
      stillNeeded.add(v.name());
      stillNeeded.add(v.mapping().name());
    }
  }
  for (  Instruction i : instructions) {
    for (    Arg oa : i.getInputs()) {
      if (oa.isVar()) {
        stillNeeded.add(oa.getVar().name());
      }
    }
    if (i.hasSideEffects()) {
      for (      Var out : i.getOutputs()) {
        stillNeeded.add(out.name());
      }
    }
 else {
      interdependencies.add(i.getOutputs());
    }
  }
  for (  Continuation c : continuations) {
    for (    Var v : c.requiredVars()) {
      stillNeeded.add(v.name());
    }
    for (    Block b : c.getBlocks()) {
      b.findEssentialVars(stillNeeded,interdependencies);
    }
  }
  for (  CleanupAction a : cleanupActions) {
    if (a.action.writesAliasVar()) {
      stillNeeded.add(a.var.name());
    }
    for (    Arg out : a.action.getInputs()) {
      if (out.isVar()) {
        stillNeeded.add(out.getVar().name());
      }
    }
  }
}

Fixed version (ground truth):
private void findEssentialVars(Set<String> stillNeeded,List<List<Var>> interdependencies){
  for (  Var v : variables) {
    if (v.isMapped()) {
      stillNeeded.add(v.name());
      stillNeeded.add(v.mapping().name());
    }
  }
  for (  Instruction i : instructions) {
    updateEssentialVars(i,stillNeeded,interdependencies,i.hasSideEffects());
  }
  for (  Continuation c : continuations) {
    for (    Var v : c.requiredVars()) {
      stillNeeded.add(v.name());
    }
    for (    Block b : c.getBlocks()) {
      b.findEssentialVars(stillNeeded,interdependencies);
    }
  }
  for (  CleanupAction a : cleanupActions) {
    boolean actionHasSideEffects=a.hasSideEffect();
    updateEssentialVars(a.action(),stillNeeded,interdependencies,actionHasSideEffects);
    if (actionHasSideEffects) {
      stillNeeded.add(a.var().name());
    }
  }
}
Program: 133123
Project: 133123
Buggy source:
public void renameCleanupActions(Map<String,Arg> renames,boolean inputsOnly){
  ListIterator<CleanupAction> it=cleanupActions.listIterator();
  while (it.hasNext()) {
    CleanupAction a=it.next();
    if (inputsOnly) {
      a.action.renameInputs(renames);
    }
 else {
      a.action.renameVars(renames);
    }
    if (!inputsOnly && renames.containsKey(a.var.name())) {
      Arg replacement=renames.get(a.var.name());
      if (replacement.isVar()) {
      }
 else {
      }
    }
  }
}

Fixed version (ground truth):
public void renameCleanupActions(Map<String,Arg> renames,boolean inputsOnly){
  for (  CleanupAction a : cleanupActions) {
    a.renameVars(renames,inputsOnly);
  }
}
Program: 133124
Project: 133124
Buggy source:
/** 
 * List of variables needed by async
 * @param usedVars
 * @param waitVars
 * @return
 */
private List<Var> asyncUsedVars(List<Var> usedVars,List<Var> waitVars){
  List<Var> neededVars=new ArrayList<Var>(usedVars);
  Set<String> existingNames=Var.nameSet(usedVars);
  for (  Var wv : waitVars) {
    if (existingNames.contains(wv)) {
      neededVars.add(wv);
    }
  }
  return neededVars;
}

Fixed version (ground truth):
/** 
 * List of variables needed by async
 * @param usedVars
 * @param waitVars
 * @return
 */
private List<Var> asyncUsedVars(List<Var> usedVars,List<Var> waitVars){
  List<Var> neededVars=new ArrayList<Var>(usedVars);
  Set<String> existingNames=Var.nameSet(usedVars);
  for (  Var wv : waitVars) {
    if (!existingNames.contains(wv.name())) {
      neededVars.add(wv);
    }
  }
  return neededVars;
}