Program: 132764
Project: 132764
Buggy source:
private static void pipelineTasks(Logger logger,Function f,Block curr,ExecContext cx){
  for (  Continuation cont : curr.allComplexStatements()) {
    ExecContext childCx=cont.childContext(cx);
    for (    Block childBlock : cont.getBlocks()) {
      pipelineTasks(logger,f,childBlock,childCx);
    }
  }
  List<WaitStatement> candidates=new ArrayList<WaitStatement>();
  for (  Continuation cont : curr.getContinuations()) {
    if (cont.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement w=(WaitStatement)cont;
      boolean compatible=true;
      if (!w.getWaitVars().isEmpty()) {
        compatible=false;
      }
 else       if (!Settings.NO_TURBINE_ENGINE && w.childContext(cx) != cx) {
        compatible=false;
      }
 else       if (w.isParallel()) {
        compatible=false;
      }
      if (compatible) {
        candidates.add(w);
      }
    }
  }
  if (candidates.isEmpty()) {
    return;
  }
  logger.trace("String_Node_Str" + candidates.size() + "String_Node_Str"+ "String_Node_Str");
  WaitStatement bestCand=candidates.get(0);
  if (candidates.size() > 1) {
    int bestCost=heuristicCost(logger,f,curr,bestCand);
    for (int i=1; i < candidates.size(); i++) {
      WaitStatement cand=candidates.get(i);
      int cost=heuristicCost(logger,f,curr,cand);
      if (cost < bestCost) {
        bestCost=cost;
        bestCand=cand;
      }
    }
  }
  if (candidates.size() == 1) {
    bestCand.inlineInto(curr);
  }
 else {
    NestedBlock nested=new NestedBlock();
    bestCand.inlineInto(nested.getBlock());
    nested.setRunLast(true);
    curr.addContinuation(nested);
  }
}

Fixed version (ground truth):
private static void pipelineTasks(Logger logger,Function f,Block curr,ExecContext cx){
  for (  Continuation cont : curr.allComplexStatements()) {
    ExecContext childCx=cont.childContext(cx);
    for (    Block childBlock : cont.getBlocks()) {
      pipelineTasks(logger,f,childBlock,childCx);
    }
  }
  List<WaitStatement> candidates=new ArrayList<WaitStatement>();
  for (  Continuation cont : curr.getContinuations()) {
    if (cont.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement w=(WaitStatement)cont;
      boolean compatible=true;
      if (!w.getWaitVars().isEmpty()) {
        compatible=false;
      }
 else       if (!Settings.NO_TURBINE_ENGINE && w.childContext(cx) != cx) {
        compatible=false;
      }
 else       if (w.isParallel()) {
        compatible=false;
      }
 else       if (w.targetLocation() != null && !w.targetLocation().equals(Location.ANY_LOCATION)) {
        compatible=false;
      }
      if (compatible) {
        candidates.add(w);
      }
    }
  }
  if (candidates.isEmpty()) {
    return;
  }
  logger.trace("String_Node_Str" + candidates.size() + "String_Node_Str"+ "String_Node_Str");
  WaitStatement bestCand=candidates.get(0);
  if (candidates.size() > 1) {
    int bestCost=heuristicCost(logger,f,curr,bestCand);
    for (int i=1; i < candidates.size(); i++) {
      WaitStatement cand=candidates.get(i);
      int cost=heuristicCost(logger,f,curr,cand);
      if (cost < bestCost) {
        bestCost=cost;
        bestCand=cand;
      }
    }
  }
  if (candidates.size() == 1) {
    bestCand.inlineInto(curr);
  }
 else {
    NestedBlock nested=new NestedBlock();
    bestCand.inlineInto(nested.getBlock());
    nested.setRunLast(true);
    curr.addContinuation(nested);
  }
}