Program: 133079
Project: 133079
Buggy source:
/** 
 * @param logger
 * @param curr current block
 * @param ancestors ancestors of current block
 * @param maxHoist maximum number of blocks can lift out
 * @param maxLoopHoist max number of block can lift out withoutgoing through loop
 * @param writeMap map for current block filled in with anything defined by construct or outer blocks
 * @return true if change made
 */
private static boolean hoistRec(Logger logger,Block curr,List<Block> ancestors,int maxHoist,int maxLoopHoist,HierarchicalMap<String,Block> writeMap){
  boolean changed=false;
  updateMapWithWrites(curr,writeMap);
  if (maxHoist > 0) {
    changed=tryHoist(logger,curr,ancestors,maxHoist,maxLoopHoist,writeMap);
  }
  ancestors.add(curr);
  for (  Continuation c : curr.getContinuations()) {
    int childHoist=canHoistThrough(c) ? maxHoist + 1 : 0;
    int childLoopHoist=c.isLoop() ? 0 : maxLoopHoist + 1;
    for (    Block b : c.getBlocks()) {
      HierarchicalMap<String,Block> childWriteMap=writeMap.makeChildMap();
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null) {
        for (        Var v : constructVars) {
          if (trackWrites(v)) {
            childWriteMap.put(v.name(),b);
          }
        }
      }
      if (c.getType() == ContinuationType.WAIT_STATEMENT) {
        for (        Var waitVar : ((WaitStatement)c).getWaitVars()) {
          if (trackWrites(waitVar)) {
            childWriteMap.put(waitVar.name(),b);
          }
        }
      }
      if (hoistRec(logger,b,ancestors,childHoist,childLoopHoist,childWriteMap)) {
        changed=true;
      }
    }
  }
  ancestors.remove(ancestors.size() - 1);
  return changed;
}

Fixed version (ground truth):
/** 
 * @param logger
 * @param curr current block
 * @param ancestors ancestors of current block
 * @param maxHoist maximum number of blocks can lift out
 * @param maxLoopHoist max number of block can lift out withoutgoing through loop
 * @param writeMap map for current block filled in with anything defined by construct or outer blocks
 * @return true if change made
 */
private static boolean hoistRec(Logger logger,Block curr,List<Block> ancestors,int maxHoist,int maxLoopHoist,HierarchicalMap<String,Block> writeMap){
  boolean changed=false;
  updateMapWithWrites(curr,writeMap);
  if (maxHoist > 0) {
    changed=tryHoist(logger,curr,ancestors,maxHoist,maxLoopHoist,writeMap);
  }
  ancestors.add(curr);
  for (  Continuation c : curr.getContinuations()) {
    int childHoist=canHoistThrough(c) ? maxHoist + 1 : 0;
    int childLoopHoist=c.isLoop() ? 0 : maxLoopHoist + 1;
    for (    Block b : c.getBlocks()) {
      HierarchicalMap<String,Block> childWriteMap=writeMap.makeChildMap();
      for (      Var v : c.constructDefinedVars()) {
        if (trackWrites(v)) {
          childWriteMap.put(v.name(),b);
        }
      }
      if (c.getType() == ContinuationType.WAIT_STATEMENT) {
        for (        Var waitVar : ((WaitStatement)c).getWaitVars()) {
          if (trackWrites(waitVar)) {
            childWriteMap.put(waitVar.name(),b);
          }
        }
      }
      if (hoistRec(logger,b,ancestors,childHoist,childLoopHoist,childWriteMap)) {
        changed=true;
      }
    }
  }
  ancestors.remove(ancestors.size() - 1);
  return changed;
}