Program: 132706
Project: 132706
Buggy source:
/** 
 * @param logger
 * @param f
 * @param curr
 * @param cx current exec context
 * @param maybeInLoop if there's maybe a loop between the currentcontext and the root of the task we're in
 */
private static void pipelineTasks(Logger logger,Function f,Block curr,ExecContext cx,boolean maybeInLoop){
  for (  Continuation cont : curr.allComplexStatements()) {
    boolean contInLoop;
    if (cont.isAsync()) {
      contInLoop=false;
    }
 else     if (cont.isLoop()) {
      contInLoop=true;
    }
 else {
      contInLoop=maybeInLoop;
    }
    ExecContext childCx=cont.childContext(cx);
    for (    Block childBlock : cont.getBlocks()) {
      pipelineTasks(logger,f,childBlock,childCx,contInLoop);
    }
  }
  if (maybeInLoop) {
    return;
  }
  List<WaitStatement> candidates=new ArrayList<WaitStatement>();
  for (  Continuation cont : curr.getContinuations()) {
    if (cont.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement w=(WaitStatement)cont;
      ExecContext waitChildContext=w.childContext(cx);
      boolean compatible=true;
      if (!w.getWaitVars().isEmpty()) {
        compatible=false;
      }
 else       if (!waitChildContext.equals(cx) && !waitChildContext.isWildcardContext()) {
        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);
  }
}

Fixed version (ground truth):
/** 
 * @param logger
 * @param f
 * @param curr
 * @param cx current exec context
 * @param maybeInLoop if there's maybe a loop between the currentcontext and the root of the task we're in
 */
private static void pipelineTasks(Logger logger,Function f,Block curr,ExecContext cx,boolean maybeInLoop){
  for (  Continuation cont : curr.allComplexStatements()) {
    boolean contInLoop;
    if (cont.isAsync()) {
      contInLoop=false;
    }
 else     if (cont.isLoop()) {
      contInLoop=true;
    }
 else {
      contInLoop=maybeInLoop;
    }
    ExecContext childCx=cont.childContext(cx);
    for (    Block childBlock : cont.getBlocks()) {
      pipelineTasks(logger,f,childBlock,childCx,contInLoop);
    }
  }
  if (maybeInLoop) {
    return;
  }
  List<WaitStatement> candidates=new ArrayList<WaitStatement>();
  for (  Continuation cont : curr.getContinuations()) {
    if (cont.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement w=(WaitStatement)cont;
      ExecContext waitChildContext=w.childContext(cx);
      boolean compatible=true;
      if (!w.getWaitVars().isEmpty()) {
        compatible=false;
      }
 else       if (!waitChildContext.equals(cx) && !waitChildContext.isWildcardContext()) {
        compatible=false;
      }
 else       if (w.isParallel()) {
        compatible=false;
      }
 else       if (!Location.isAnyLocation(w.targetLocation(),true)) {
        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);
  }
}