Program: 133154
Project: 133154
Buggy source:
/** 
 * @param context local context for app function
 * @param cmd AST for app function command
 * @param outputs output arguments for app
 * @param hasSideEffects
 * @param deterministic
 * @throws UserException
 */
private void genAppFunctionBody(Context context,SwiftAST appBody,List<Var> outputs,boolean hasSideEffects,boolean deterministic) throws UserException {
  assert(appBody.getType() == ExMParser.APP_BODY);
  assert(appBody.getChildCount() >= 1);
  SwiftAST cmd=appBody.child(0);
  assert(cmd.getType() == ExMParser.COMMAND);
  assert(cmd.getChildCount() >= 1);
  SwiftAST appNameT=cmd.child(0);
  assert(appNameT.getType() == ExMParser.STRING);
  String appName=Literals.extractLiteralString(context,appNameT);
  List<Var> args=evalAppCmdArgs(context,cmd);
  Redirects<Var> redirFutures=processAppRedirects(context,appBody.children(1));
  checkAppOutputs(context,appName,outputs,args,redirFutures);
  Pair<Map<String,Var>,List<Var>> wait=selectAppWaitVars(context,args,redirFutures);
  Map<String,Var> fileNames=wait.val1;
  List<Var> waitVars=wait.val2;
  List<Var> passIn=new ArrayList<Var>();
  passIn.addAll(fileNames.values());
  passIn.addAll(args);
  String waitName=context.getFunctionContext().constructName("String_Node_Str");
  backend.startWaitStatement(waitName,waitVars,passIn,Collections.<Var>emptyList(),null,WaitMode.TASK_DISPATCH,true,TaskMode.LEAF);
  Pair<List<Arg>,Redirects<Arg>> retrieved=retrieveAppArgs(context,args,redirFutures,fileNames);
  List<Arg> localArgs=retrieved.val1;
  Redirects<Arg> localRedirects=retrieved.val2;
  backend.runExternal(appName,localArgs,outputs,localRedirects,hasSideEffects,deterministic);
  backend.endWaitStatement(passIn,Arrays.<Var>asList());
}

Fixed version (ground truth):
/** 
 * @param context local context for app function
 * @param cmd AST for app function command
 * @param outputs output arguments for app
 * @param hasSideEffects
 * @param deterministic
 * @throws UserException
 */
private void genAppFunctionBody(Context context,SwiftAST appBody,List<Var> outputs,boolean hasSideEffects,boolean deterministic) throws UserException {
  assert(appBody.getType() == ExMParser.APP_BODY);
  assert(appBody.getChildCount() >= 1);
  SwiftAST cmd=appBody.child(0);
  assert(cmd.getType() == ExMParser.COMMAND);
  assert(cmd.getChildCount() >= 1);
  SwiftAST appNameT=cmd.child(0);
  assert(appNameT.getType() == ExMParser.STRING);
  String appName=Literals.extractLiteralString(context,appNameT);
  List<Var> args=evalAppCmdArgs(context,cmd);
  Redirects<Var> redirFutures=processAppRedirects(context,appBody.children(1));
  checkAppOutputs(context,appName,outputs,args,redirFutures);
  Pair<Map<String,Var>,List<Var>> wait=selectAppWaitVars(context,args,redirFutures);
  Map<String,Var> fileNames=wait.val1;
  List<Var> waitVars=wait.val2;
  List<Var> passIn=new ArrayList<Var>();
  passIn.addAll(fileNames.values());
  passIn.addAll(args);
  String waitName=context.getFunctionContext().constructName("String_Node_Str");
  backend.startWaitStatement(waitName,waitVars,passIn,Collections.<Var>emptyList(),null,WaitMode.TASK_DISPATCH,true,TaskMode.LEAF);
  Pair<List<Arg>,Redirects<Arg>> retrieved=retrieveAppArgs(context,args,redirFutures,fileNames);
  List<Arg> localArgs=retrieved.val1;
  Redirects<Arg> localRedirects=retrieved.val2;
  backend.runExternal(appName,localArgs,outputs,localRedirects,hasSideEffects,deterministic);
  backend.endWaitStatement(waitVars,passIn,Arrays.<Var>asList());
}