Program: 132959
Project: 132959
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.isScalarFuture(input.var.type())) {
      Type valueT=Types.derefResultType(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(),VarStorage.STACK,DefType.LOCAL_USER);
    newBlock.renameVars(Collections.singletonMap(fv.val1,tmpfuture.asArg()),RenameMode.REPLACE_VAR,true);
    newBlock.addVariable(tmpfuture);
    Instruction store=ICInstructions.futureSet(fv.val1,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.isScalarFuture(input.var.type())) {
      Type valueT=Types.derefResultType(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(),VarStorage.STACK,DefType.LOCAL_USER);
    newBlock.renameVars(Collections.singletonMap(fv.val1,tmpfuture.asArg()),RenameMode.REPLACE_VAR,true);
    newBlock.addVariable(tmpfuture);
    Instruction store=ICInstructions.futureSet(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);
}