Program: 133141
Project: 133141
Buggy source:
/** 
 * Convert dataflow f() to local f_l() with wait around it
 * @param logger
 * @param block
 * @return
 */
private static boolean explodeFuncCalls(Logger logger,Function fn,ExecContext execCx,Block block){
  boolean changed=false;
  Set<String> empty=Collections.emptySet();
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction i=it.next();
    MakeImmRequest req=i.canMakeImmediate(empty,true);
    if (req != null && req.in.size() > 0) {
      List<Var> waitVars=ICUtil.filterBlockingOnly(req.in);
      WaitMode waitMode;
      if (req.mode == TaskMode.SYNC || req.mode == TaskMode.LOCAL || (req.mode == TaskMode.LOCAL_CONTROL && execCx == ExecContext.CONTROL)) {
        waitMode=WaitMode.DATA_ONLY;
      }
 else {
        waitMode=WaitMode.TASK_DISPATCH;
      }
      List<Var> outWriteRefcounted=RefCounting.filterWriteRefcount(req.out == null ? Collections.<Var>emptyList() : req.out);
      WaitStatement wait=new WaitStatement(fn.getName() + "String_Node_Str" + i.shortOpName(),waitVars,req.in,outWriteRefcounted,waitMode,true,req.mode);
      block.addContinuation(wait);
      List<Instruction> instBuffer=new ArrayList<Instruction>();
      List<Arg> inVals=OptUtil.fetchValuesOf(wait.getBlock(),instBuffer,req.in);
      List<Var> localOutputs=OptUtil.declareLocalOpOutputVars(wait.getBlock(),req.out);
      MakeImmChange change=i.makeImmediate(localOutputs,inVals);
      OptUtil.fixupImmChange(wait.getBlock(),change,instBuffer,localOutputs,req.out);
      it.remove();
      wait.getBlock().addInstructions(instBuffer);
      changed=true;
    }
  }
  return changed;
}

Fixed version (ground truth):
/** 
 * Convert dataflow f() to local f_l() with wait around it
 * @param logger
 * @param block
 * @return
 */
private static boolean explodeFuncCalls(Logger logger,Function fn,ExecContext execCx,Block block){
  boolean changed=false;
  Set<String> empty=Collections.emptySet();
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction i=it.next();
    MakeImmRequest req=i.canMakeImmediate(empty,true);
    if (req != null && req.in.size() > 0) {
      List<Var> waitVars=ICUtil.filterBlockingOnly(req.in);
      WaitMode waitMode;
      if (req.mode == TaskMode.SYNC || req.mode == TaskMode.LOCAL || (req.mode == TaskMode.LOCAL_CONTROL && execCx == ExecContext.CONTROL)) {
        waitMode=WaitMode.DATA_ONLY;
      }
 else {
        waitMode=WaitMode.TASK_DISPATCH;
      }
      List<Var> outWriteRefcounted=RefCounting.filterWriteRefcount(req.out == null ? Collections.<Var>emptyList() : req.out);
      WaitStatement wait=new WaitStatement(fn.getName() + "String_Node_Str" + i.shortOpName(),waitVars,req.in,outWriteRefcounted,i.getPriority(),waitMode,true,req.mode);
      block.addContinuation(wait);
      List<Instruction> instBuffer=new ArrayList<Instruction>();
      List<Arg> inVals=OptUtil.fetchValuesOf(wait.getBlock(),instBuffer,req.in);
      List<Var> localOutputs=OptUtil.declareLocalOpOutputVars(wait.getBlock(),req.out);
      MakeImmChange change=i.makeImmediate(localOutputs,inVals);
      OptUtil.fixupImmChange(wait.getBlock(),change,instBuffer,localOutputs,req.out);
      it.remove();
      wait.getBlock().addInstructions(instBuffer);
      changed=true;
    }
  }
  return changed;
}