Program: 133253
Project: 133253
Buggy source:
private void callFunction(Context context,String function,List<Variable> oList,List<Variable> iList,Variable priorityVal) throws UndefinedTypeException, UserException {
  List<SwiftType> expectedTypes=TypeChecker.checkFunctionCall(context,function,oList,iList);
  ArrayList<Variable> realIList=new ArrayList<Variable>(iList.size());
  ArrayList<Variable> derefVars=new ArrayList<Variable>();
  ArrayList<Variable> waitVars=new ArrayList<Variable>();
  Context waitContext=null;
  assert(expectedTypes.size() == iList.size());
  for (int i=0; i < iList.size(); i++) {
    Variable input=iList.get(i);
    SwiftType inputType=input.getType();
    SwiftType expType=expectedTypes.get(i);
    if (inputType.equals(expType)) {
      realIList.add(input);
    }
 else     if (Types.isReferenceTo(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Variable derefed;
      derefed=waitContext.createAliasVariable(expType);
      waitVars.add(input);
      derefVars.add(derefed);
      realIList.add(derefed);
    }
 else     if (Types.isUpdateableEquiv(inputType,expType)) {
      Variable copy=varCreator.createTmp(waitContext,ScalarUpdateableType.asScalarFuture(inputType));
      assignVariable(waitContext,copy,input);
      realIList.add(copy);
    }
 else {
      throw new STCRuntimeError(context.getFileLine() + "String_Node_Str" + "String_Node_Str"+ inputType.toString()+ "String_Node_Str"+ expType.toString());
    }
  }
  if (waitContext != null) {
    FunctionContext fc=context.getFunctionContext();
    ArrayList<Variable> usedVars=new ArrayList<Variable>();
    usedVars.addAll(iList);
    usedVars.addAll(oList);
    backend.startWaitStatement(fc.constructName("String_Node_Str" + function),waitVars,usedVars,new ArrayList<Variable>(),false);
    assert(waitVars.size() == derefVars.size());
    for (int i=0; i < waitVars.size(); i++) {
      Variable derefVar=derefVars.get(i);
      varCreator.declare(derefVar);
      if (Types.isArrayRef(waitVars.get(i).getType())) {
        backend.retrieveRef(derefVar,waitVars.get(i));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + derefVar);
      }
    }
  }
  Arg priority=priorityVal != null ? Arg.createVar(priorityVal) : null;
  if (context.isBuiltinFunction(function)) {
    if (FunctionSemantics.hasLocalEquiv(function)) {
      assert(oList.size() <= 1);
      Variable out=oList.size() == 0 ? null : oList.get(0);
      backend.asyncOp(FunctionSemantics.getLocalEquiv(function),out,Arg.fromVarList(realIList),priority);
    }
 else {
      backend.builtinFunctionCall(function,realIList,oList,priority);
    }
  }
 else   if (context.isCompositeFunction(function))   backend.compositeFunctionCall(function,realIList,oList,null,!context.isSyncComposite(function),priority);
 else   throw UndefinedFunctionException.unknownFunction(context,function);
  if (waitContext != null) {
    backend.endWaitStatement(new ArrayList<Variable>());
  }
}

Fixed version (ground truth):
private void callFunction(Context context,String function,List<Variable> oList,List<Variable> iList,Variable priorityVal) throws UndefinedTypeException, UserException {
  List<SwiftType> expectedTypes=TypeChecker.checkFunctionCall(context,function,oList,iList);
  ArrayList<Variable> realIList=new ArrayList<Variable>(iList.size());
  ArrayList<Variable> derefVars=new ArrayList<Variable>();
  ArrayList<Variable> waitVars=new ArrayList<Variable>();
  Context waitContext=null;
  assert(expectedTypes.size() == iList.size());
  for (int i=0; i < iList.size(); i++) {
    Variable input=iList.get(i);
    SwiftType inputType=input.getType();
    SwiftType expType=expectedTypes.get(i);
    if (inputType.equals(expType)) {
      realIList.add(input);
    }
 else     if (Types.isReferenceTo(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Variable derefed;
      derefed=waitContext.createAliasVariable(expType);
      waitVars.add(input);
      derefVars.add(derefed);
      realIList.add(derefed);
    }
 else     if (Types.isUpdateableEquiv(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Variable copy=varCreator.createTmp(waitContext,ScalarUpdateableType.asScalarFuture(inputType));
      assignVariable(waitContext,copy,input);
      realIList.add(copy);
    }
 else {
      throw new STCRuntimeError(context.getFileLine() + "String_Node_Str" + "String_Node_Str"+ inputType.toString()+ "String_Node_Str"+ expType.toString());
    }
  }
  if (waitContext != null) {
    FunctionContext fc=context.getFunctionContext();
    ArrayList<Variable> usedVars=new ArrayList<Variable>();
    usedVars.addAll(iList);
    usedVars.addAll(oList);
    backend.startWaitStatement(fc.constructName("String_Node_Str" + function),waitVars,usedVars,new ArrayList<Variable>(),false);
    assert(waitVars.size() == derefVars.size());
    for (int i=0; i < waitVars.size(); i++) {
      Variable derefVar=derefVars.get(i);
      varCreator.declare(derefVar);
      if (Types.isArrayRef(waitVars.get(i).getType())) {
        backend.retrieveRef(derefVar,waitVars.get(i));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + derefVar);
      }
    }
  }
  Arg priority=priorityVal != null ? Arg.createVar(priorityVal) : null;
  if (context.isBuiltinFunction(function)) {
    if (FunctionSemantics.hasLocalEquiv(function)) {
      assert(oList.size() <= 1);
      Variable out=oList.size() == 0 ? null : oList.get(0);
      backend.asyncOp(FunctionSemantics.getLocalEquiv(function),out,Arg.fromVarList(realIList),priority);
    }
 else {
      backend.builtinFunctionCall(function,realIList,oList,priority);
    }
  }
 else   if (context.isCompositeFunction(function))   backend.compositeFunctionCall(function,realIList,oList,null,!context.isSyncComposite(function),priority);
 else   throw UndefinedFunctionException.unknownFunction(context,function);
  if (waitContext != null) {
    backend.endWaitStatement(new ArrayList<Variable>());
  }
}