nus-yam/ex-repair huggingface dataset:
Program: 133003
Project: 133003
Buggy source:
private static boolean relocateContinuation(Deque<Continuation> ancestors,Block currBlock,ExecContext currContext,Set<Continuation> movedC,Continuation cont){
  boolean canRelocate=true;
  for (  Continuation ancestor : ancestors) {
    if (cont == ancestor) {
      canRelocate=false;
      break;
    }
  }
  if (currContext == ExecContext.WORKER) {
    if (cont.getType() != ContinuationType.WAIT_STATEMENT) {
      canRelocate=false;
    }
 else {
      WaitStatement w=(WaitStatement)cont;
      if (w.getTarget() == TaskMode.CONTROL || w.getTarget() == TaskMode.WORKER || w.getTarget() == TaskMode.LOCAL) {
        canRelocate=true;
      }
 else       if (w.getTarget() == TaskMode.LOCAL_CONTROL) {
        w.setMode(WaitMode.TASK_DISPATCH);
        w.setTarget(TaskMode.CONTROL);
      }
 else {
        canRelocate=false;
      }
    }
  }
  if (canRelocate) {
    currBlock.addContinuation(cont);
    movedC.add(cont);
    assert(cont.isAsync());
  }
  return canRelocate;
}

Fixed version (ground truth):
private boolean relocateContinuation(Deque<Continuation> ancestors,Block currBlock,ExecContext currContext,Set<Continuation> movedC,Continuation cont){
  boolean canRelocate=true;
  for (  Continuation ancestor : ancestors) {
    if (cont == ancestor) {
      canRelocate=false;
      break;
    }
  }
  if (currContext == ExecContext.WORKER) {
    if (cont.getType() != ContinuationType.WAIT_STATEMENT) {
      canRelocate=false;
    }
 else {
      WaitStatement w=(WaitStatement)cont;
      if (w.getTarget() == TaskMode.CONTROL || w.getTarget() == TaskMode.WORKER || w.getTarget() == TaskMode.LOCAL) {
        canRelocate=true;
      }
 else       if (w.getTarget() == TaskMode.LOCAL_CONTROL) {
        if (w.getMode() == WaitMode.EXPLICIT && retainExplicit) {
          canRelocate=false;
        }
 else {
          w.setMode(WaitMode.TASK_DISPATCH);
          w.setTarget(TaskMode.CONTROL);
        }
      }
 else {
        canRelocate=false;
      }
    }
  }
  if (canRelocate) {
    currBlock.addContinuation(cont);
    movedC.add(cont);
    assert(cont.isAsync());
  }
  return canRelocate;
}
Program: 133004
Project: 133004
Buggy source:
private static boolean pushDownWaits(Logger logger,Function fn,Block block,ExecContext currContext){
  MultiMap<Var,InstOrCont> waitMap=buildWaiterMap(block);
  if (waitMap.isDefinitelyEmpty()) {
    return false;
  }
  boolean changed=false;
  HashSet<Continuation> allPushedDown=new HashSet<Continuation>();
  ArrayList<Continuation> contCopy=new ArrayList<Continuation>(block.getContinuations());
  for (  Continuation c : contCopy) {
    if (allPushedDown.contains(c)) {
      continue;
    }
    ExecContext newContext=canPushDownInto(c,currContext);
    if (newContext != null) {
      for (      Block innerBlock : c.getBlocks()) {
        ArrayDeque<Continuation> ancestors=new ArrayDeque<Continuation>();
        ancestors.push(c);
        PushDownResult pdRes=pushDownWaitsRec(logger,fn,block,currContext,ancestors,innerBlock,newContext,waitMap);
        changed=changed || pdRes.anyChanges;
        allPushedDown.addAll(pdRes.relocated);
      }
    }
  }
  return changed;
}

Fixed version (ground truth):
private boolean pushDownWaits(Logger logger,Function fn,Block block,ExecContext currContext){
  MultiMap<Var,InstOrCont> waitMap=buildWaiterMap(block);
  if (waitMap.isDefinitelyEmpty()) {
    return false;
  }
  boolean changed=false;
  HashSet<Continuation> allPushedDown=new HashSet<Continuation>();
  ArrayList<Continuation> contCopy=new ArrayList<Continuation>(block.getContinuations());
  for (  Continuation c : contCopy) {
    if (allPushedDown.contains(c)) {
      continue;
    }
    ExecContext newContext=canPushDownInto(c,currContext);
    if (newContext != null) {
      for (      Block innerBlock : c.getBlocks()) {
        ArrayDeque<Continuation> ancestors=new ArrayDeque<Continuation>();
        ancestors.push(c);
        PushDownResult pdRes=pushDownWaitsRec(logger,fn,block,currContext,ancestors,innerBlock,newContext,waitMap);
        changed=changed || pdRes.anyChanges;
        allPushedDown.addAll(pdRes.relocated);
      }
    }
  }
  return changed;
}
Program: 133006
Project: 133006
Buggy source:
private static String printDepGraph(MultiMap<Var,Var> dependencyGraph){
  List<Var> keys=new ArrayList<Var>(dependencyGraph.keySet());
  Collections.sort(keys);
  StringBuilder sb=new StringBuilder();
  for (  Var key : keys) {
    sb.append(key.name() + "String_Node_Str");
    ICUtil.prettyPrintVarList(sb,dependencyGraph.get(key));
    sb.append("String_Node_Str");
  }
  return sb.toString();
}

Fixed version (ground truth):
private static String printDepGraph(MultiMap<Var,Var> dependencyGraph,int indent){
  List<Var> keys=new ArrayList<Var>(dependencyGraph.keySet());
  Collections.sort(keys);
  StringBuilder sb=new StringBuilder();
  for (  Var key : keys) {
    for (int i=0; i < indent; i++) {
      sb.append(' ');
    }
    sb.append(key.name() + "String_Node_Str");
    ICUtil.prettyPrintVarList(sb,dependencyGraph.get(key));
    sb.append("String_Node_Str");
  }
  return sb.toString();
}
Program: 133007
Project: 133007
Buggy source:
/** 
 * @param logger
 * @param f
 * @return true if changes made
 */
private static boolean eliminateIter(Logger logger,Function f){
  HashSet<Var> removeCandidates=new HashSet<Var>();
  HashSet<Var> needed=new HashSet<Var>();
  MultiMap<Var,Var> dependencyGraph=new MultiMap<Var,Var>();
  walkFunction(logger,f,removeCandidates,needed,dependencyGraph);
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + f.getName() + "String_Node_Str"+ "String_Node_Str"+ removeCandidates+ "String_Node_Str"+ "String_Node_Str"+ needed+ "String_Node_Str"+ "String_Node_Str"+ printDepGraph(dependencyGraph));
  }
  ArrayDeque<Var> workStack=new ArrayDeque<Var>();
  workStack.addAll(needed);
  while (!workStack.isEmpty()) {
    Var neededVar=workStack.pop();
    List<Var> deps=dependencyGraph.remove(neededVar);
    if (deps != null) {
      needed.addAll(deps);
      workStack.addAll(deps);
    }
  }
  removeCandidates.removeAll(needed);
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + removeCandidates);
  }
  if (removeCandidates.isEmpty()) {
    return false;
  }
 else {
    f.getMainblock().removeVars(removeCandidates);
    return true;
  }
}

Fixed version (ground truth):
/** 
 * @param logger
 * @param f
 * @return true if changes made
 */
private static boolean eliminateIter(Logger logger,Function f){
  HashSet<Var> removeCandidates=new HashSet<Var>();
  HashSet<Var> needed=new HashSet<Var>();
  MultiMap<Var,Var> dependencyGraph=new MultiMap<Var,Var>();
  Map<Var,Var> componentOf=new HashMap<Var,Var>();
  walkFunction(logger,f,removeCandidates,needed,dependencyGraph,componentOf);
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + f.getName() + "String_Node_Str"+ "String_Node_Str"+ removeCandidates+ "String_Node_Str"+ "String_Node_Str"+ needed+ "String_Node_Str"+ "String_Node_Str"+ printDepGraph(dependencyGraph,4)+ "String_Node_Str"+ ICUtil.prettyPrintMap(componentOf,4));
  }
  ArrayDeque<Var> workStack=new ArrayDeque<Var>();
  workStack.addAll(needed);
  while (!workStack.isEmpty()) {
    Var neededVar=workStack.pop();
    List<Var> deps=dependencyGraph.remove(neededVar);
    if (deps != null) {
      needed.addAll(deps);
      workStack.addAll(deps);
    }
  }
  removeCandidates.removeAll(needed);
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + removeCandidates);
  }
  if (removeCandidates.isEmpty()) {
    return false;
  }
 else {
    f.getMainblock().removeVars(removeCandidates);
    return true;
  }
}
Program: 133008
Project: 133008
Buggy source:
/** 
 * Collect information for dead code elimination
 * @param logger
 * @param f
 * @param removeCandidates list of vars declared in function thatcould be removed
 * @param needed
 * @param dependencyGraph
 */
private static void walkFunction(Logger logger,Function f,HashSet<Var> removeCandidates,HashSet<Var> needed,MultiMap<Var,Var> dependencyGraph){
  Map<Var,Var> componentOf=new HashMap<Var,Var>();
  ArrayDeque<Block> workStack=new ArrayDeque<Block>();
  workStack.push(f.getMainblock());
  needed.addAll(f.getOutputList());
  while (!workStack.isEmpty()) {
    Block block=workStack.pop();
    walkBlockVars(block,removeCandidates,dependencyGraph);
    walkInstructions(logger,block,needed,dependencyGraph,componentOf);
    ListIterator<Continuation> it=block.continuationIterator();
    while (it.hasNext()) {
      Continuation c=it.next();
      if (c.isNoop()) {
        it.remove();
      }
 else {
        needed.addAll(c.requiredVars(true));
        for (        Block inner : c.getBlocks()) {
          workStack.push(inner);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Collect information for dead code elimination
 * @param logger
 * @param f
 * @param removeCandidates list of vars declared in function thatcould be removed
 * @param needed
 * @param dependencyGraph
 * @param componentOf
 */
private static void walkFunction(Logger logger,Function f,HashSet<Var> removeCandidates,HashSet<Var> needed,MultiMap<Var,Var> dependencyGraph,Map<Var,Var> componentOf){
  ArrayDeque<Block> workStack=new ArrayDeque<Block>();
  workStack.push(f.getMainblock());
  needed.addAll(f.getOutputList());
  while (!workStack.isEmpty()) {
    Block block=workStack.pop();
    walkBlockVars(block,removeCandidates,dependencyGraph);
    walkInstructions(logger,block,needed,dependencyGraph,componentOf);
    ListIterator<Continuation> it=block.continuationIterator();
    while (it.hasNext()) {
      Continuation c=it.next();
      if (c.isNoop()) {
        it.remove();
      }
 else {
        needed.addAll(c.requiredVars(true));
        for (        Block inner : c.getBlocks()) {
          workStack.push(inner);
        }
      }
    }
  }
}
Program: 133009
Project: 133009
Buggy source:
public Pair<Var,Var> getComponentAlias(){
switch (op) {
case ARRAY_CREATE_NESTED_IMM:
case ARRAY_CREATE_NESTED_FUTURE:
    return Pair.create(getOutput(0),getOutput(1));
case ARRAYREF_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
  return Pair.create(getOutput(0),getOutput(2));
case LOAD_REF:
return Pair.create(getOutput(0),getInput(0).getVar());
case STRUCT_LOOKUP:
case STRUCTREF_LOOKUP:
return Pair.create(getOutput(0),getInput(0).getVar());
default :
return null;
}
}

Fixed version (ground truth):
public Pair<Var,Var> getComponentAlias(){
switch (op) {
case ARRAY_CREATE_NESTED_IMM:
case ARRAY_CREATE_NESTED_FUTURE:
    return Pair.create(getOutput(0),getOutput(1));
case ARRAYREF_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
  return Pair.create(getOutput(0),getOutput(2));
case LOAD_REF:
return Pair.create(getOutput(0),getInput(0).getVar());
case ADDRESS_OF:
return Pair.create(getOutput(0),getInput(0).getVar());
case STRUCT_LOOKUP:
case STRUCTREF_LOOKUP:
return Pair.create(getOutput(0),getInput(0).getVar());
default :
return null;
}
}
Program: 133010
Project: 133010
Buggy source:
/** 
 * Check function argument type Returns which formal argument type is selected. Only handles case where formalArgT has a type variable
 * @param context
 * @param func
 * @param arg
 * @param formalArgT
 * @param argExprT
 * @param tvConstraints fill in constraints for type variables
 * @return
 * @throws TypeMismatchException
 */
private static Type checkFunArgTV(Context context,String func,int arg,Type formalArgT,Type argExprT,MultiMap<String,Type> tvConstraints) throws TypeMismatchException {
  if (Types.isUnion(formalArgT)) {
    throw new STCRuntimeError("String_Node_Str");
  }
  if (Types.isRef(formalArgT)) {
    argExprT=argExprT.memberType();
  }
  if (Types.isUnion(argExprT)) {
    List<Map<String,Type>> possible=new ArrayList<Map<String,Type>>();
    for (    Type alt : UnionType.getAlternatives(argExprT)) {
      possible.add(formalArgT.matchTypeVars(alt));
    }
    for (    Map<String,Type> m : possible) {
      assert(m.keySet().equals(possible.get(0).keySet()));
    }
    for (    String boundVar : possible.get(0).keySet()) {
      List<Type> choices=new ArrayList<Type>();
      for (      Map<String,Type> m : possible) {
        Type t=m.get(boundVar);
        assert(!Types.isUnion(t));
        choices.add(t);
      }
      tvConstraints.put(boundVar,UnionType.makeUnion(choices));
    }
  }
 else {
    tvConstraints.putAll(formalArgT.matchTypeVars(argExprT));
  }
  return formalArgT;
}

Fixed version (ground truth):
/** 
 * Check function argument type Returns which formal argument type is selected. Only handles case where formalArgT has a type variable
 * @param context
 * @param func
 * @param arg
 * @param formalArgT
 * @param argExprT
 * @param tvConstraints fill in constraints for type variables
 * @return
 * @throws TypeMismatchException
 */
private static Type checkFunArgTV(Context context,String func,int arg,Type formalArgT,Type argExprT,MultiMap<String,Type> tvConstraints) throws TypeMismatchException {
  if (Types.isUnion(formalArgT)) {
    throw new STCRuntimeError("String_Node_Str");
  }
  if (Types.isRef(formalArgT)) {
    argExprT=argExprT.memberType();
  }
  if (Types.isUnion(argExprT)) {
    List<Map<String,Type>> possible=new ArrayList<Map<String,Type>>();
    for (    Type alt : UnionType.getAlternatives(argExprT)) {
      possible.add(formalArgT.matchTypeVars(alt));
    }
    for (    Map<String,Type> m : possible) {
      assert(m.keySet().equals(possible.get(0).keySet()));
    }
    for (    String boundVar : possible.get(0).keySet()) {
      List<Type> choices=new ArrayList<Type>();
      for (      Map<String,Type> m : possible) {
        Type t=m.get(boundVar);
        assert(!Types.isUnion(t));
        choices.add(t);
      }
      tvConstraints.put(boundVar,UnionType.makeUnion(choices));
    }
  }
 else {
    Map<String,Type> matchedTypeVars=formalArgT.matchTypeVars(argExprT);
    if (matchedTypeVars == null) {
      throw new TypeMismatchException(context,"String_Node_Str" + "String_Node_Str" + formalArgT + "String_Node_Str"+ "String_Node_Str"+ argExprT);
    }
    tvConstraints.putAll(matchedTypeVars);
  }
  return formalArgT;
}
Program: 133012
Project: 133012
Buggy source:
/** 
 * Try to squash together waits, e.g. wait (x) { < do some minor work that doesn't help with progress > wait (y) { < do some real work > } } gets changed to wait (x, y) { ... }
 * @param logger
 * @param fn
 * @param block
 */
private boolean squashWaits(Logger logger,Function fn,WaitStatement wait,ExecContext waitContext){
  Block block=wait.getBlock();
  WaitStatement innerWait=null;
  for (  Continuation c : block.getContinuations()) {
    if (c.isAsync()) {
      if (c.getType() == ContinuationType.WAIT_STATEMENT) {
        if (innerWait != null) {
          return false;
        }
 else {
          innerWait=(WaitStatement)c;
        }
      }
 else {
        return false;
      }
    }
  }
  if (innerWait == null)   return false;
  ExecContext innerContext=innerWait.childContext(waitContext);
  if (innerContext != waitContext)   return false;
  for (  Var waitVar : innerWait.getWaitVars()) {
    if (block.getVariables().contains(waitVar)) {
      return false;
    }
  }
  if (!ProgressOpcodes.isNonProgress(block)) {
    return false;
  }
  if (logger.isTraceEnabled())   logger.trace("String_Node_Str" + innerWait.getWaitVars() + "String_Node_Str"+ "String_Node_Str"+ wait.getWaitVars()+ "String_Node_Str");
  wait.addWaitVars(innerWait.getWaitVars());
  innerWait.inlineInto(block);
  return true;
}

Fixed version (ground truth):
/** 
 * Try to squash together waits, e.g. wait (x) { < do some minor work that doesn't help with progress > wait (y) { < do some real work > } } gets changed to wait (x, y) { ... }
 * @param logger
 * @param fn
 * @param block
 */
private boolean squashWaits(Logger logger,Function fn,WaitStatement wait,ExecContext waitContext){
  Block block=wait.getBlock();
  WaitStatement innerWait=null;
  for (  Continuation c : block.getContinuations()) {
    if (c.isAsync()) {
      if (c.getType() == ContinuationType.WAIT_STATEMENT) {
        if (innerWait != null) {
          return false;
        }
 else {
          innerWait=(WaitStatement)c;
        }
      }
 else {
        return false;
      }
    }
  }
  if (innerWait == null)   return false;
  ExecContext innerContext=innerWait.childContext(waitContext);
  if (innerContext != waitContext)   return false;
  if (retainExplicit && innerWait.getMode() == WaitMode.EXPLICIT && wait.getMode() != WaitMode.EXPLICIT)   return false;
  for (  Var waitVar : innerWait.getWaitVars()) {
    if (block.getVariables().contains(waitVar)) {
      return false;
    }
  }
  if (!ProgressOpcodes.isNonProgress(block)) {
    return false;
  }
  if (logger.isTraceEnabled())   logger.trace("String_Node_Str" + innerWait.getWaitVars() + "String_Node_Str"+ "String_Node_Str"+ wait.getWaitVars()+ "String_Node_Str");
  wait.addWaitVars(innerWait.getWaitVars());
  innerWait.inlineInto(block);
  return true;
}
Program: 133013
Project: 133013
Buggy source:
public WaitCoalescer(boolean doMerges){
  this.doMerges=doMerges;
}

Fixed version (ground truth):
public WaitCoalescer(boolean doMerges,boolean retainExplicit){
  this.doMerges=doMerges;
  this.retainExplicit=retainExplicit;
}
Program: 133015
Project: 133015
Buggy source:
@Override public Block tryInline(Set<Var> closedVars,Set<Var> recClosedVars){
  boolean varsLeft=false;
  ListIterator<Var> it=waitVars.listIterator();
  while (it.hasNext()) {
    Var wv=it.next();
    if ((closedVars.contains(wv) && !recursionRequired(wv)) || recClosedVars.contains(wv)) {
      it.remove();
    }
 else {
      varsLeft=true;
    }
  }
  if (varsLeft || mode == WaitMode.TASK_DISPATCH) {
    return null;
  }
 else {
    return block;
  }
}

Fixed version (ground truth):
@Override public Block tryInline(Set<Var> closedVars,Set<Var> recClosedVars,boolean keepExplicitDependencies){
  if (keepExplicitDependencies && mode == WaitMode.EXPLICIT)   return null;
  boolean varsLeft=false;
  ListIterator<Var> it=waitVars.listIterator();
  while (it.hasNext()) {
    Var wv=it.next();
    if ((closedVars.contains(wv) && !recursionRequired(wv)) || recClosedVars.contains(wv)) {
      it.remove();
    }
 else {
      varsLeft=true;
    }
  }
  if (varsLeft || mode == WaitMode.TASK_DISPATCH) {
    return null;
  }
 else {
    return block;
  }
}
Program: 133016
Project: 133016
Buggy source:
@Override public Block branchPredict(Map<Var,Arg> knownConstants){
  return tryInline(Collections.<Var>emptySet(),knownConstants.keySet());
}

Fixed version (ground truth):
@Override public Block branchPredict(Map<Var,Arg> knownConstants){
  return null;
}
Program: 133017
Project: 133017
Buggy source:
/** 
 * @param logger
 * @param block 
 * @param visible allvariables logically visible in this block. will be modified in fn
 * @param referencedGlobals updated with names of any globals used
 * @param updateLists 
 * @return
 */
private static Pair<Set<Var>,Set<Var>> fixupBlockRec(Logger logger,Function function,Block block,HierarchicalSet<Var> visible,Set<Var> referencedGlobals,boolean updateLists){
  if (updateLists)   removeGlobalImports(block);
  Set<Var> blockVars=new HashSet<Var>();
  for (  Var v : block.getVariables()) {
    blockVars.add(v);
    visible.add(v);
  }
  Set<Var> read=new HashSet<Var>();
  Set<Var> written=new HashSet<Var>();
  findBlockNeeded(block,read,written);
  for (  Continuation c : block.getContinuations()) {
    fixupContinuationRec(logger,function,c,visible,referencedGlobals,blockVars,read,written,updateLists);
  }
  read.removeAll(blockVars);
  written.removeAll(blockVars);
  Set<Var> globals=addGlobalImports(block,visible,updateLists,Arrays.asList(read,written));
  referencedGlobals.addAll(globals);
  read.removeAll(globals);
  written.removeAll(globals);
  return Pair.create(read,written);
}

Fixed version (ground truth):
/** 
 * @param logger
 * @param block 
 * @param visible allvariables logically visible in this block. will be modified in fn
 * @param referencedGlobals updated with names of any globals used
 * @param updateLists 
 * @return
 */
private static Pair<Set<Var>,Set<Var>> fixupBlockRec(Logger logger,Function function,Block block,ExecContext execCx,HierarchicalSet<Var> visible,Set<Var> referencedGlobals,boolean updateLists){
  if (updateLists)   removeGlobalImports(block);
  Set<Var> blockVars=new HashSet<Var>();
  for (  Var v : block.getVariables()) {
    blockVars.add(v);
    visible.add(v);
  }
  Set<Var> read=new HashSet<Var>();
  Set<Var> written=new HashSet<Var>();
  findBlockNeeded(block,read,written);
  for (  Continuation c : block.getContinuations()) {
    fixupContinuationRec(logger,function,execCx,c,visible,referencedGlobals,blockVars,read,written,updateLists);
  }
  read.removeAll(blockVars);
  written.removeAll(blockVars);
  if (execCx == ExecContext.CONTROL) {
    Set<Var> globals=addGlobalImports(block,visible,updateLists,Arrays.asList(read,written));
    referencedGlobals.addAll(globals);
    read.removeAll(globals);
    written.removeAll(globals);
  }
  return Pair.create(read,written);
}
Program: 133019
Project: 133019
Buggy source:
/** 
 * Find all referenced vars in scope
 * @param block
 * @param written accumulate output vars
 * @param read accumulate all input vars from this block
 */
private static void findBlockNeeded(Block block,Set<Var> read,Set<Var> written){
  for (  Var v : block.getVariables()) {
    if (v.isMapped()) {
      read.add(v.mapping());
    }
  }
  for (  Instruction i : block.getInstructions()) {
    for (    Arg in : i.getInputs()) {
      if (in.isVar()) {
        read.add(in.getVar());
      }
    }
    written.addAll(i.getOutputs());
  }
  for (  Continuation cont : block.getContinuations()) {
    read.addAll(cont.requiredVars());
  }
  for (  CleanupAction cleanup : block.getCleanups()) {
    for (    Arg in : cleanup.action().getInputs()) {
      if (in.isVar()) {
        read.add(in.getVar());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Find all referenced vars in scope
 * @param block
 * @param written accumulate output vars
 * @param read accumulate all input vars from this block
 */
private static void findBlockNeeded(Block block,Set<Var> read,Set<Var> written){
  for (  Var v : block.getVariables()) {
    if (v.isMapped()) {
      read.add(v.mapping());
    }
  }
  for (  Instruction i : block.getInstructions()) {
    for (    Arg in : i.getInputs()) {
      if (in.isVar()) {
        read.add(in.getVar());
      }
    }
    written.addAll(i.getOutputs());
  }
  for (  Continuation cont : block.getContinuations()) {
    read.addAll(cont.requiredVars(false));
  }
  for (  CleanupAction cleanup : block.getCleanups()) {
    for (    Arg in : cleanup.action().getInputs()) {
      if (in.isVar()) {
        read.add(in.getVar());
      }
    }
  }
}
Program: 133020
Project: 133020
Buggy source:
public static void fixupFunction(Logger logger,Program prog,Function fn,Set<Var> referencedGlobals,boolean updateLists){
  HierarchicalSet<Var> fnargs=new HierarchicalSet<Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.add(v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.add(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.add(v);
  }
  Pair<Set<Var>,Set<Var>> res=fixupBlockRec(logger,fn,fn.getMainblock(),fnargs,referencedGlobals,updateLists);
  Set<Var> read=res.val1;
  Set<Var> written=res.val2;
  if (updateLists) {
    for (int i=0; i < fn.getOutputList().size(); i++) {
      Var output=fn.getOutput(i);
      if (!read.contains(output)) {
        fn.makeOutputWriteOnly(i);
      }
    }
  }
  read.removeAll(fn.getInputList());
  read.removeAll(fn.getOutputList());
  if (read.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ read.toString());
  }
  written.removeAll(fn.getOutputList());
  if (written.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ written.toString());
  }
}

Fixed version (ground truth):
public static void fixupFunction(Logger logger,Program prog,Function fn,Set<Var> referencedGlobals,boolean updateLists){
  HierarchicalSet<Var> fnargs=new HierarchicalSet<Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.add(v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.add(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.add(v);
  }
  Pair<Set<Var>,Set<Var>> res=fixupBlockRec(logger,fn,fn.getMainblock(),ExecContext.CONTROL,fnargs,referencedGlobals,updateLists);
  Set<Var> read=res.val1;
  Set<Var> written=res.val2;
  if (updateLists) {
    for (int i=0; i < fn.getOutputList().size(); i++) {
      Var output=fn.getOutput(i);
      if (!read.contains(output)) {
        fn.makeOutputWriteOnly(i);
      }
    }
  }
  read.removeAll(fn.getInputList());
  read.removeAll(fn.getOutputList());
  if (read.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ read.toString());
  }
  written.removeAll(fn.getOutputList());
  if (written.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ written.toString());
  }
}
Program: 133021
Project: 133021
Buggy source:
private static void rebuildContinuationPassedVars(Function function,Continuation continuation,HierarchicalSet<Var> visibleVars,Set<Var> outerBlockVars,Set<Var> outerRead,Set<Var> innerRead,Set<Var> outerWritten,Set<Var> innerWritten){
  Set<Var> innerAllNeeded=new HashSet<Var>();
  innerAllNeeded.addAll(innerRead);
  innerAllNeeded.addAll(innerWritten);
  List<PassedVar> passedIn=new ArrayList<PassedVar>();
  for (  Var needed : innerAllNeeded) {
    assert(needed.storage() != VarStorage.GLOBAL_CONST);
    boolean read=innerRead.contains(needed);
    boolean written=innerWritten.contains(needed);
    if (!outerBlockVars.contains(needed)) {
      if (read)       outerRead.add(needed);
      if (written)       outerWritten.add(needed);
    }
    if (!visibleVars.contains(needed)) {
      throw new STCRuntimeError("String_Node_Str" + needed + "String_Node_Str"+ "String_Node_Str"+ function.getName());
    }
    assert(read || written);
    boolean writeOnly=!read;
    passedIn.add(new PassedVar(needed,writeOnly));
  }
  continuation.setPassedVars(passedIn);
}

Fixed version (ground truth):
private static void rebuildContinuationPassedVars(Function function,Continuation continuation,HierarchicalSet<Var> visibleVars,Set<Var> outerBlockVars,Set<Var> outerRead,Set<Var> innerRead,Set<Var> outerWritten,Set<Var> innerWritten){
  Set<Var> innerAllNeeded=new HashSet<Var>();
  innerAllNeeded.addAll(innerRead);
  innerAllNeeded.addAll(innerWritten);
  List<PassedVar> passedIn=new ArrayList<PassedVar>();
  for (  Var needed : innerAllNeeded) {
    boolean read=innerRead.contains(needed);
    boolean written=innerWritten.contains(needed);
    if (!outerBlockVars.contains(needed)) {
      if (read)       outerRead.add(needed);
      if (written)       outerWritten.add(needed);
    }
    if (!visibleVars.contains(needed)) {
      throw new STCRuntimeError("String_Node_Str" + needed + "String_Node_Str"+ "String_Node_Str"+ function.getName());
    }
    assert(read || written);
    boolean writeOnly=!read;
    passedIn.add(new PassedVar(needed,writeOnly));
  }
  continuation.setPassedVars(passedIn);
}
Program: 133022
Project: 133022
Buggy source:
private boolean rearrangeWaitsRec(Logger logger,Function fn,Block block,ExecContext currContext){
  List<WaitStatement> toInline=new ArrayList<WaitStatement>();
  boolean changed=false;
  for (  Continuation c : block.getContinuations()) {
    ExecContext newContext=c.childContext(currContext);
    for (    Block childB : c.getBlocks()) {
      if (rearrangeWaits(logger,fn,childB,newContext)) {
        changed=true;
      }
    }
    if (c.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement wait=(WaitStatement)c;
      if (tryReduce(logger,fn,currContext,newContext,wait)) {
        toInline.add(wait);
      }
      if (squashWaits(logger,fn,wait,newContext)) {
        changed=true;
      }
    }
  }
  for (  WaitStatement w : toInline) {
    w.inlineInto(block);
    changed=true;
  }
  return changed;
}

Fixed version (ground truth):
private boolean rearrangeWaitsRec(Logger logger,Function fn,Block block,ExecContext currContext){
  List<WaitStatement> toInline=new ArrayList<WaitStatement>();
  boolean changed=false;
  for (  Continuation c : block.getContinuations()) {
    ExecContext newContext=c.childContext(currContext);
    for (    Block childB : c.getBlocks()) {
      if (rearrangeWaits(logger,fn,childB,newContext)) {
        changed=true;
      }
    }
    if (c.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement wait=(WaitStatement)c;
      if (tryReduce(logger,fn,currContext,newContext,wait)) {
        toInline.add(wait);
      }
 else       if (squashWaits(logger,fn,wait,newContext)) {
        changed=true;
      }
    }
  }
  for (  WaitStatement w : toInline) {
    w.inlineInto(block);
    changed=true;
  }
  return changed;
}
Program: 133023
Project: 133023
Buggy source:
/** 
 * Remove from candidates any variables that can't have the refcount decremented before this continuation starts execution
 * @param inst
 * @param type
 * @param candidates
 */
private void removeDecrCandidates(Continuation cont,RefCountType type,Set<Var> candidates){
  if (type == RefCountType.READERS) {
    for (    Var v : cont.requiredVars()) {
      candidates.remove(v);
    }
  }
  if (isForeachLoop(cont)) {
    AbstractForeachLoop loop=(AbstractForeachLoop)cont;
    for (    RefCount rc : loop.getStartIncrements()) {
      if (rc.type == type) {
        candidates.remove(rc.var);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove from candidates any variables that can't have the refcount decremented before this continuation starts execution
 * @param inst
 * @param type
 * @param candidates
 */
private void removeDecrCandidates(Continuation cont,RefCountType type,Set<Var> candidates){
  if (type == RefCountType.READERS) {
    for (    Var v : cont.requiredVars(false)) {
      candidates.remove(v);
    }
  }
  if (isForeachLoop(cont)) {
    AbstractForeachLoop loop=(AbstractForeachLoop)cont;
    for (    RefCount rc : loop.getStartIncrements()) {
      if (rc.type == type) {
        candidates.remove(rc.var);
      }
    }
  }
}
Program: 133024
Project: 133024
Buggy source:
/** 
 * try to reduce to a simpler form of wait
 * @param currContext
 * @param toInline
 * @param newContext
 * @param wait
 */
private boolean tryReduce(ExecContext currContext,ExecContext newContext,WaitStatement wait){
  if ((currContext == newContext && ProgressOpcodes.isCheap(wait.getBlock())) || (currContext == ExecContext.WORKER && newContext == ExecContext.CONTROL && ProgressOpcodes.isCheapWorker(wait.getBlock()))) {
    if (wait.getWaitVars().isEmpty()) {
      return true;
    }
 else {
      if (wait.getTarget() == TaskMode.CONTROL) {
        if (currContext == ExecContext.CONTROL) {
          wait.setTarget(TaskMode.LOCAL_CONTROL);
        }
 else {
          wait.setTarget(TaskMode.LOCAL);
        }
      }
      if (wait.getMode() == WaitMode.TASK_DISPATCH) {
        wait.setMode(WaitMode.DATA_ONLY);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * try to reduce to a simpler form of wait
 * @param currContext
 * @param toInline
 * @param newContext
 * @param wait
 */
private boolean tryReduce(Logger logger,Function fn,ExecContext currContext,ExecContext newContext,WaitStatement wait){
  if ((currContext == newContext && ProgressOpcodes.isCheap(wait.getBlock())) || (currContext == ExecContext.WORKER && newContext == ExecContext.CONTROL && canSwitchControlToWorker(logger,fn,wait))) {
    if (wait.getWaitVars().isEmpty()) {
      return true;
    }
 else {
      if (wait.getTarget() == TaskMode.CONTROL) {
        if (currContext == ExecContext.CONTROL) {
          wait.setTarget(TaskMode.LOCAL_CONTROL);
        }
 else {
          wait.setTarget(TaskMode.LOCAL);
        }
      }
      if (wait.getMode() == WaitMode.TASK_DISPATCH) {
        wait.setMode(WaitMode.DATA_ONLY);
      }
    }
  }
  return false;
}
Program: 133025
Project: 133025
Buggy source:
private boolean rearrangeWaitsRec(Logger logger,Function fn,Block block,ExecContext currContext){
  List<WaitStatement> toInline=new ArrayList<WaitStatement>();
  boolean changed=false;
  for (  Continuation c : block.getContinuations()) {
    ExecContext newContext=c.childContext(currContext);
    for (    Block childB : c.getBlocks()) {
      if (rearrangeWaits(logger,fn,childB,newContext)) {
        changed=true;
      }
    }
    if (c.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement wait=(WaitStatement)c;
      if (tryReduce(currContext,newContext,wait)) {
        toInline.add(wait);
      }
      if (squashWaits(logger,fn,wait,newContext)) {
        changed=true;
      }
    }
  }
  for (  WaitStatement w : toInline) {
    w.inlineInto(block);
    changed=true;
  }
  return changed;
}

Fixed version (ground truth):
private boolean rearrangeWaitsRec(Logger logger,Function fn,Block block,ExecContext currContext){
  List<WaitStatement> toInline=new ArrayList<WaitStatement>();
  boolean changed=false;
  for (  Continuation c : block.getContinuations()) {
    ExecContext newContext=c.childContext(currContext);
    for (    Block childB : c.getBlocks()) {
      if (rearrangeWaits(logger,fn,childB,newContext)) {
        changed=true;
      }
    }
    if (c.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement wait=(WaitStatement)c;
      if (tryReduce(logger,fn,currContext,newContext,wait)) {
        toInline.add(wait);
      }
      if (squashWaits(logger,fn,wait,newContext)) {
        changed=true;
      }
    }
  }
  for (  WaitStatement w : toInline) {
    w.inlineInto(block);
    changed=true;
  }
  return changed;
}
Program: 133026
Project: 133026
Buggy source:
@Override public Collection<Var> requiredVars(){
  ArrayList<Var> res=new ArrayList<Var>();
  if (mode == WaitMode.EXPLICIT || mode == WaitMode.TASK_DISPATCH) {
    for (    Var v : waitVars) {
      res.add(v);
    }
  }
  if (priority != null && priority.isVar()) {
    res.add(priority.getVar());
  }
  return res;
}

Fixed version (ground truth):
@Override public Collection<Var> requiredVars(boolean forDeadCodeElim){
  ArrayList<Var> res=new ArrayList<Var>();
  if (!forDeadCodeElim || mode == WaitMode.EXPLICIT || mode == WaitMode.TASK_DISPATCH) {
    for (    Var v : waitVars) {
      res.add(v);
    }
  }
  if (priority != null && priority.isVar()) {
    res.add(priority.getVar());
  }
  return res;
}
Program: 133027
Project: 133027
Buggy source:
@Override public void startForeachLoop(String loopName,Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<RefCount> perIterIncrs){
  assert(Types.isArray(arrayVar.type()));
  assert(loopCountVar == null || loopCountVar.type().equals(Types.V_INT));
  if (!arrayClosed) {
    throw new STCRuntimeError("String_Node_Str");
  }
  boolean haveKeys=loopCountVar != null;
  String contentsVar=TCLTMP_ARRAY_CONTENTS;
  if (splitDegree <= 0) {
    pointStack.peek().add(Turbine.containerContents(contentsVar,varToExpr(arrayVar),haveKeys));
    if (!perIterIncrs.isEmpty()) {
      pointStack.peek().add(new SetVariable(TCLTMP_ITERS,Square.fnCall("String_Node_Str",new Token("String_Node_Str"),new Value(contentsVar))));
      handleRefcounts(perIterIncrs,new Value(TCLTMP_ITERS),false);
    }
  }
 else {
    startForeachSplit(loopName,arrayVar,contentsVar,splitDegree,leafDegree,haveKeys,passedVars,perIterIncrs);
  }
  startForeachInner(new Value(contentsVar),memberVar,loopCountVar);
}

Fixed version (ground truth):
@Override public void startForeachLoop(String loopName,Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<RefCount> perIterIncrs){
  assert(Types.isArray(arrayVar.type()));
  assert(loopCountVar == null || loopCountVar.type().equals(Types.V_INT));
  if (!arrayClosed) {
    throw new STCRuntimeError("String_Node_Str");
  }
  boolean haveKeys=loopCountVar != null;
  String contentsVar=TCLTMP_ARRAY_CONTENTS;
  if (splitDegree <= 0) {
    pointStack.peek().add(Turbine.containerContents(contentsVar,varToExpr(arrayVar),haveKeys));
    Value tclDict=new Value(contentsVar);
    Expression containerSize=Turbine.dictSize(tclDict);
    handleForeachContainerRefcounts(perIterIncrs,containerSize);
  }
 else {
    startForeachSplit(loopName,arrayVar,contentsVar,splitDegree,leafDegree,haveKeys,passedVars,perIterIncrs);
  }
  startForeachInner(new Value(contentsVar),memberVar,loopCountVar);
}
Program: 133028
Project: 133028
Buggy source:
private void startForeachSplit(String procName,Var arrayVar,String contentsVar,int splitDegree,int leafDegree,boolean haveKeys,List<PassedVar> usedVars,List<RefCount> perIterIncrs){
  pointStack.peek().add(Turbine.containerSize(TCLTMP_CONTAINER_SIZE,varToExpr(arrayVar)));
  Expression lastIndex=Square.arithExpr(new Value(TCLTMP_CONTAINER_SIZE),new Token("String_Node_Str"),new LiteralInt(1));
  ArrayList<PassedVar> splitUsedVars=new ArrayList<PassedVar>(usedVars);
  splitUsedVars.add(new PassedVar(arrayVar,false));
  startRangeSplit(procName,splitUsedVars,perIterIncrs,splitDegree,leafDegree,LiteralInt.ZERO,lastIndex,LiteralInt.ONE);
  pointStack.peek().add(new SetVariable(TCLTMP_SPLITLEN,Square.arithExpr(new Token(String.format("String_Node_Str",TCLTMP_RANGE_HI,TCLTMP_RANGE_LO)))));
  pointStack.peek().add(Turbine.containerContents(contentsVar,varToExpr(arrayVar),haveKeys,new Value(TCLTMP_SPLITLEN),TCLTMP_RANGE_LO_V));
}

Fixed version (ground truth):
private void startForeachSplit(String procName,Var arrayVar,String contentsVar,int splitDegree,int leafDegree,boolean haveKeys,List<PassedVar> usedVars,List<RefCount> perIterIncrs){
  pointStack.peek().add(Turbine.containerSize(TCLTMP_CONTAINER_SIZE,varToExpr(arrayVar)));
  Value containerSize=new Value(TCLTMP_CONTAINER_SIZE);
  Expression lastIndex=Square.arithExpr(containerSize,new Token("String_Node_Str"),new LiteralInt(1));
  handleForeachContainerRefcounts(perIterIncrs,containerSize);
  ArrayList<PassedVar> splitUsedVars=new ArrayList<PassedVar>(usedVars);
  splitUsedVars.add(new PassedVar(arrayVar,false));
  startRangeSplit(procName,splitUsedVars,perIterIncrs,splitDegree,leafDegree,LiteralInt.ZERO,lastIndex,LiteralInt.ONE);
  pointStack.peek().add(new SetVariable(TCLTMP_SPLITLEN,Square.arithExpr(new Token(String.format("String_Node_Str",TCLTMP_RANGE_HI,TCLTMP_RANGE_LO)))));
  pointStack.peek().add(Turbine.containerContents(contentsVar,varToExpr(arrayVar),haveKeys,new Value(TCLTMP_SPLITLEN),TCLTMP_RANGE_LO_V));
}
Program: 133029
Project: 133029
Buggy source:
/** 
 * Do the manipulation necessary to allow an old instruction output variable to be replaced with a new one. Assume that newOut is a value type of oldOut
 * @param instBuffer append any fixup instructions here
 * @param newOut
 * @param oldOut
 */
public static void replaceInstructionOutputVar(Block block,List<Instruction> instBuffer,Var newOut,Var oldOut){
  block.declareVariable(newOut);
  if (Types.isRefTo(oldOut.type(),newOut.type())) {
    Var refVar;
    if (oldOut.storage() == VarStorage.ALIAS) {
      refVar=new Var(oldOut.type(),oldOut.name(),VarStorage.TEMP,oldOut.defType(),oldOut.mapping());
      block.replaceVarDeclaration(oldOut,refVar);
      Map<Var,Arg> renames=Collections.singletonMap(oldOut,Arg.createVar(refVar));
      for (      Instruction inst : instBuffer) {
        inst.renameVars(renames);
      }
    }
 else {
      refVar=oldOut;
    }
    instBuffer.add(TurbineOp.addressOf(refVar,newOut));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + oldOut + "String_Node_Str"+ newOut+ "String_Node_Str"+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Do the manipulation necessary to allow an old instruction output variable to be replaced with a new one. Assume that newOut is a value type of oldOut
 * @param targetBlock 
 * @param instBuffer append any fixup instructions here
 * @param newOut
 * @param oldOut
 */
public static void replaceInstructionOutputVar(Block block,Block targetBlock,List<Instruction> instBuffer,Var newOut,Var oldOut){
  replaceInstOutput(block,targetBlock,instBuffer,newOut,oldOut);
}
Program: 133030
Project: 133030
Buggy source:
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 && change.storeOutputVals) {
    for (int i=0; i < newOutVars.size(); i++) {
      Var oldOut=oldOutVars.get(i);
      Var newOut=newOutVars.get(i);
      if (oldOut != newOut)       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;
    replaceInstOutput(srcBlock,targetBlock,instBuffer,newOut,oldOut);
  }
  if (newOutVars != null && change.storeOutputVals) {
    for (int i=0; i < newOutVars.size(); i++) {
      Var oldOut=oldOutVars.get(i);
      Var newOut=newOutVars.get(i);
      if (oldOut != newOut)       instBuffer.add(ICInstructions.futureSet(oldOut,Arg.createVar(newOut)));
    }
  }
}
Program: 133031
Project: 133031
Buggy source:
public void replaceVarDeclaration(Var oldV,Var newV){
  if (!this.variables.contains(oldV)) {
    throw new STCRuntimeError("String_Node_Str" + oldV.toString() + "String_Node_Str");
  }
  Map<Var,Arg> replacement=Collections.singletonMap(oldV,Arg.createVar(newV));
  this.renameVars(replacement,false,true);
}

Fixed version (ground truth):
public boolean replaceVarDeclaration(Var oldV,Var newV){
  if (!this.variables.contains(oldV)) {
    return false;
  }
  Map<Var,Arg> replacement=Collections.singletonMap(oldV,Arg.createVar(newV));
  this.renameVars(replacement,false,true);
  return true;
}
Program: 133033
Project: 133033
Buggy source:
/** 
 * Fuse the other loop into this loop
 */
public void fuseInto(RangeLoop o,boolean insertAtTop){
  Map<Var,Arg> renames=new HashMap<Var,Arg>();
  renames.put(o.loopVar,Arg.createVar(this.loopVar));
  if (countVar != null)   renames.put(o.countVar,Arg.createVar(this.countVar));
  o.replaceVars(renames,false,true);
  this.fuseIntoAbstract(o,insertAtTop);
}

Fixed version (ground truth):
/** 
 * Fuse the other loop into this loop
 */
public void fuseInto(RangeLoop o,boolean insertAtTop){
  Map<Var,Arg> renames=new HashMap<Var,Arg>();
  renames.put(o.loopVar,Arg.createVar(this.loopVar));
  if (loopCounterVar != null)   renames.put(o.loopCounterVar,Arg.createVar(this.loopCounterVar));
  o.replaceVars(renames,false,true);
  this.fuseIntoAbstract(o,insertAtTop);
}
Program: 133034
Project: 133034
Buggy source:
private RangeLoop(String loopName,Block block,Var loopVar,Var countVar,Arg start,Arg end,Arg increment,List<PassedVar> passedVars,List<Var> keepOpenVars,int desiredUnroll,boolean unrolled,int splitDegree,int leafDegree,List<RefCount> startIncrements,List<RefCount> endDecrements){
  super(block,passedVars,keepOpenVars,startIncrements,endDecrements);
  assert(start.isImmediateInt());
  assert(end.isImmediateInt());
  assert(increment.isImmediateInt());
  assert(loopVar.type().equals(Types.V_INT));
  this.loopName=loopName;
  this.loopVar=loopVar;
  this.countVar=countVar;
  this.start=start;
  this.end=end;
  this.increment=increment;
  this.desiredUnroll=desiredUnroll;
  this.unrolled=unrolled;
  this.splitDegree=splitDegree;
  this.leafDegree=leafDegree;
}

Fixed version (ground truth):
private RangeLoop(Block block,String loopName,Var loopVar,Var loopCounterVar,Arg start,Arg end,Arg increment,List<PassedVar> passedVars,List<Var> keepOpenVars,int desiredUnroll,boolean unrolled,int splitDegree,int leafDegree,List<RefCount> startIncrements,List<RefCount> endDecrements){
  super(block,loopName,loopVar,loopCounterVar,splitDegree,leafDegree,desiredUnroll,unrolled,passedVars,keepOpenVars,startIncrements,endDecrements);
  assert(loopVar.type().equals(Types.V_INT));
  assert(start.isImmediateInt());
  assert(end.isImmediateInt());
  assert(increment.isImmediateInt());
  this.start=start;
  this.end=end;
  this.increment=increment;
}
Program: 133035
Project: 133035
Buggy source:
public AbstractForeachLoop(Block loopBody,List<PassedVar> passedVars,List<Var> keepOpenVars,List<RefCount> startIncrements,List<RefCount> endDecrements){
  super(loopBody,passedVars,keepOpenVars);
  this.startIncrements=new ArrayList<RefCount>(startIncrements);
  this.endDecrements=new ArrayList<RefCount>(endDecrements);
}

Fixed version (ground truth):
public AbstractForeachLoop(Block loopBody,String loopName,Var loopVar,Var loopCounterVar,int splitDegree,int leafDegree,int desiredUnroll,boolean unrolled,List<PassedVar> passedVars,List<Var> keepOpenVars,List<RefCount> startIncrements,List<RefCount> endDecrements){
  super(loopBody,passedVars,keepOpenVars);
  assert(loopCounterVar == null || loopCounterVar.type().equals(Types.V_INT));
  this.loopName=loopName;
  this.loopVar=loopVar;
  this.loopCounterVar=loopCounterVar;
  this.splitDegree=splitDegree;
  this.leafDegree=leafDegree;
  this.desiredUnroll=desiredUnroll;
  this.unrolled=unrolled;
  this.startIncrements=new ArrayList<RefCount>(startIncrements);
  this.endDecrements=new ArrayList<RefCount>(endDecrements);
}
Program: 133036
Project: 133036
Buggy source:
public boolean fuseable(RangeLoop o){
  return this.start.equals(o.start) && this.increment.equals(o.increment) && this.end.equals(o.end)&& this.desiredUnroll == o.desiredUnroll && this.splitDegree == o.splitDegree && (this.countVar == null) == (o.countVar == null);
}

Fixed version (ground truth):
public boolean fuseable(RangeLoop o){
  return this.start.equals(o.start) && this.increment.equals(o.increment) && this.end.equals(o.end)&& this.desiredUnroll == o.desiredUnroll && this.splitDegree == o.splitDegree && (this.loopCounterVar == null) == (o.loopCounterVar == null);
}
Program: 133037
Project: 133037
Buggy source:
public ForeachLoop(String loopName,Var arrayVar,Var loopVar,Var loopCounterVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<Var> keepOpenVars,List<RefCount> startIncrements,List<RefCount> endDecrements){
  this(loopName,new Block(BlockType.FOREACH_BODY,null),arrayVar,loopVar,loopCounterVar,splitDegree,leafDegree,arrayClosed,passedVars,keepOpenVars,startIncrements,endDecrements);
}

Fixed version (ground truth):
public ForeachLoop(String loopName,Var arrayVar,Var loopVar,Var loopCounterVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<Var> keepOpenVars,List<RefCount> startIncrements,List<RefCount> endDecrements){
  this(new Block(BlockType.FOREACH_BODY,null),loopName,arrayVar,loopVar,loopCounterVar,splitDegree,leafDegree,arrayClosed,passedVars,keepOpenVars,startIncrements,endDecrements);
}