Program: 132717
Project: 132717
Buggy source:
private Function switchToValuePassing(Logger logger,Function fn,Set<String> usedFunctionNames){
  if (fn.blockingInputs().isEmpty())   return null;
  List<Var> switchVars=new ArrayList<Var>();
  for (  WaitVar input : fn.blockingInputs()) {
    if (Types.isPrimFuture(input.var.type())) {
      Type valueT=Types.retrievedType(input.var.type());
      if (Semantics.canPassToChildTask(valueT)) {
        switchVars.add(input.var);
      }
    }
  }
  if (switchVars.isEmpty())   return null;
  List<Pair<Var,Var>> futValPairs=createValueVars(fn,switchVars);
  Map<Var,Var> switched=new HashMap<Var,Var>();
  for (  Pair<Var,Var> fv : futValPairs) {
    switched.put(fv.val1,fv.val2);
    assert(fv.val2 != null);
  }
  List<Var> newIList=buildNewInputList(fn,switched);
  String newName=selectUniqueName(fn.getName(),usedFunctionNames);
  Block callNewFunction=callNewFunctionCode(fn,newName,switchVars);
  Block newBlock=fn.swapBlock(callNewFunction);
  for (  Pair<Var,Var> fv : futValPairs) {
    Var tmpfuture=new Var(fv.val1.type(),fv.val1.name(),Alloc.STACK,DefType.LOCAL_USER,VarProvenance.renamed(fv.val1));
    newBlock.renameVars(Collections.singletonMap(fv.val1,tmpfuture.asArg()),RenameMode.REPLACE_VAR,true);
    newBlock.addVariable(tmpfuture);
    Instruction store=TurbineOp.storePrim(tmpfuture,fv.val2.asArg());
    newBlock.addInstructionFront(store);
  }
  List<WaitVar> newBlocking=new ArrayList<WaitVar>();
  for (  WaitVar wv : fn.blockingInputs()) {
    if (!switchVars.contains(wv.var)) {
      newBlocking.add(wv);
    }
  }
  return new Function(newName,newIList,newBlocking,fn.getOutputList(),fn.mode(),newBlock);
}

Fixed version (ground truth):
private Function switchToValuePassing(Logger logger,Function fn,Set<String> usedFunctionNames){
  if (fn.blockingInputs().isEmpty())   return null;
  List<Var> switchVars=new ArrayList<Var>();
  for (  WaitVar input : fn.blockingInputs()) {
    if (Types.isPrimFuture(input.var.type())) {
      Type valueT=Types.retrievedType(input.var.type());
      if (Semantics.canPassToChildTask(valueT)) {
        switchVars.add(input.var);
      }
    }
  }
  if (switchVars.isEmpty())   return null;
  List<Pair<Var,Var>> futValPairs=createValueVars(fn,switchVars);
  Map<Var,Var> switched=new HashMap<Var,Var>();
  for (  Pair<Var,Var> fv : futValPairs) {
    switched.put(fv.val1,fv.val2);
    assert(fv.val2 != null);
  }
  List<Var> newIList=buildNewInputList(fn,switched);
  String newName=selectUniqueName(fn.getName(),usedFunctionNames);
  Block callNewFunction=callNewFunctionCode(fn,newName,switchVars);
  Block newBlock=fn.swapBlock(callNewFunction);
  for (  Pair<Var,Var> fv : futValPairs) {
    Var tmpfuture=new Var(fv.val1.type(),fv.val1.name(),Alloc.STACK,DefType.LOCAL_USER,VarProvenance.renamed(fv.val1));
    newBlock.renameVars(fn.getName(),Collections.singletonMap(fv.val1,tmpfuture.asArg()),RenameMode.REPLACE_VAR,true);
    newBlock.addVariable(tmpfuture);
    Instruction store=TurbineOp.storePrim(tmpfuture,fv.val2.asArg());
    newBlock.addInstructionFront(store);
  }
  List<WaitVar> newBlocking=new ArrayList<WaitVar>();
  for (  WaitVar wv : fn.blockingInputs()) {
    if (!switchVars.contains(wv.var)) {
      newBlocking.add(wv);
    }
  }
  return new Function(newName,newIList,newBlocking,fn.getOutputList(),fn.mode(),newBlock);
}