nus-yam/ex-repair huggingface dataset:
Program: 133125
Project: 133125
Buggy source:
/** 
 * Start code that will execute asynchronously
 * @param procName the name of the wait block (useful so generatedtcl code can have a nice name for the block)
 * @param waitVars
 * @param usedVars any variables which are read or written inside block
 * @param keepOpenVars any vars that need to be kept open for wait
 * @param mode what guarantees wait statement should provide
 * @param recursive if true, wait until all contents of arrays/structs(recursively) are closed
 * @param target controls where asynchronous execution occurs
 */
public abstract void startWaitStatement(String procName,List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars,WaitMode mode,boolean recursive,TaskMode target);

Fixed version (ground truth):
/** 
 * Start code that will execute asynchronously
 * @param procName the name of the wait block (useful so generatedtcl code can have a nice name for the block)
 * @param waitVars
 * @param usedVars any variables which are read or written inside block
 * @param keepOpenVars any vars that need to be kept open for wait
 * @param mode what guarantees wait statement should provide
 * @param recursive if true, wait until all contents of arrays/structs(recursively) are closed
 * @param target controls where asynchronous execution occurs
 */
public abstract void startWaitStatement(String procName,List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars,Arg priority,WaitMode mode,boolean recursive,TaskMode target);
Program: 133127
Project: 133127
Buggy source:
private void waitStmt(Context context,SwiftAST tree) throws UserException {
  Wait wait=Wait.fromAST(context,tree);
  ArrayList<Var> waitEvaled=new ArrayList<Var>();
  for (  SwiftAST expr : wait.getWaitExprs()) {
    Var res=exprWalker.eval(context,expr,TypeChecker.findSingleExprType(context,expr),false,null);
    waitEvaled.add(res);
  }
  ArrayList<Var> usedVars=new ArrayList<Var>();
  ArrayList<Var> keepOpenVars=new ArrayList<Var>();
  summariseBranchVariableUsage(context,Arrays.asList(wait.getBlock().getVariableUsage()),usedVars,keepOpenVars);
  HashSet<String> waitVarSet=new HashSet<String>(Var.nameList(waitEvaled));
  waitVarSet.retainAll(Var.nameList(keepOpenVars));
  if (waitVarSet.size() > 0) {
    throw new UserException(context,"String_Node_Str" + "String_Node_Str" + waitVarSet.toString());
  }
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitEvaled,usedVars,keepOpenVars,WaitMode.EXPLICIT,false,TaskMode.LOCAL_CONTROL);
  block(new LocalContext(context),wait.getBlock());
  backend.endWaitStatement(usedVars,keepOpenVars);
}

Fixed version (ground truth):
private void waitStmt(Context context,SwiftAST tree) throws UserException {
  Wait wait=Wait.fromAST(context,tree);
  ArrayList<Var> waitEvaled=new ArrayList<Var>();
  for (  SwiftAST expr : wait.getWaitExprs()) {
    Var res=exprWalker.eval(context,expr,TypeChecker.findSingleExprType(context,expr),false,null);
    waitEvaled.add(res);
  }
  ArrayList<Var> usedVars=new ArrayList<Var>();
  ArrayList<Var> keepOpenVars=new ArrayList<Var>();
  summariseBranchVariableUsage(context,Arrays.asList(wait.getBlock().getVariableUsage()),usedVars,keepOpenVars);
  HashSet<String> waitVarSet=new HashSet<String>(Var.nameList(waitEvaled));
  waitVarSet.retainAll(Var.nameList(keepOpenVars));
  if (waitVarSet.size() > 0) {
    throw new UserException(context,"String_Node_Str" + "String_Node_Str" + waitVarSet.toString());
  }
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitEvaled,usedVars,keepOpenVars,null,WaitMode.EXPLICIT,false,TaskMode.LOCAL_CONTROL);
  block(new LocalContext(context),wait.getBlock());
  backend.endWaitStatement(usedVars,keepOpenVars);
}
Program: 133129
Project: 133129
Buggy source:
private void switchStatement(Context context,SwiftAST tree) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  Switch sw=Switch.fromAST(context,tree);
  sw.typeCheck(context);
  Var switchVar=exprWalker.eval(context,sw.getSwitchExpr(),Types.F_INT,true,null);
  List<Var> usedVariables=new ArrayList<Var>();
  List<Var> keepOpenVars=new ArrayList<Var>();
  List<VariableUsageInfo> branchVUs=new ArrayList<VariableUsageInfo>();
  for (  SwiftAST b : sw.getCaseBodies()) {
    branchVUs.add(b.checkedGetVariableUsage());
  }
  checkConditionalDeadlock(context,switchVar,branchVUs);
  summariseBranchVariableUsage(context,branchVUs,usedVariables,keepOpenVars);
  if (!usedVariables.contains(switchVar))   usedVariables.add(switchVar);
  FunctionContext fc=context.getFunctionContext();
  backend.startWaitStatement(fc.constructName("String_Node_Str"),Arrays.asList(switchVar),usedVariables,keepOpenVars,WaitMode.DATA_ONLY,false,TaskMode.LOCAL_CONTROL);
  Context waitContext=new LocalContext(context);
  Var switchVal=varCreator.createValueOfVar(waitContext,switchVar);
  backend.retrieveInt(switchVal,switchVar);
  LogHelper.trace(context,"String_Node_Str" + sw.getCaseBodies().size() + "String_Node_Str");
  backend.startSwitch(Arg.createVar(switchVal),sw.getCaseLabels(),sw.hasDefault());
  for (  SwiftAST caseBody : sw.getCaseBodies()) {
    block(new LocalContext(waitContext),caseBody);
    backend.endCase();
  }
  backend.endSwitch();
  backend.endWaitStatement(usedVariables,keepOpenVars);
}

Fixed version (ground truth):
private void switchStatement(Context context,SwiftAST tree) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  Switch sw=Switch.fromAST(context,tree);
  sw.typeCheck(context);
  Var switchVar=exprWalker.eval(context,sw.getSwitchExpr(),Types.F_INT,true,null);
  List<Var> usedVariables=new ArrayList<Var>();
  List<Var> keepOpenVars=new ArrayList<Var>();
  List<VariableUsageInfo> branchVUs=new ArrayList<VariableUsageInfo>();
  for (  SwiftAST b : sw.getCaseBodies()) {
    branchVUs.add(b.checkedGetVariableUsage());
  }
  checkConditionalDeadlock(context,switchVar,branchVUs);
  summariseBranchVariableUsage(context,branchVUs,usedVariables,keepOpenVars);
  if (!usedVariables.contains(switchVar))   usedVariables.add(switchVar);
  FunctionContext fc=context.getFunctionContext();
  backend.startWaitStatement(fc.constructName("String_Node_Str"),Arrays.asList(switchVar),usedVariables,keepOpenVars,null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL_CONTROL);
  Context waitContext=new LocalContext(context);
  Var switchVal=varCreator.createValueOfVar(waitContext,switchVar);
  backend.retrieveInt(switchVal,switchVar);
  LogHelper.trace(context,"String_Node_Str" + sw.getCaseBodies().size() + "String_Node_Str");
  backend.startSwitch(Arg.createVar(switchVal),sw.getCaseLabels(),sw.hasDefault());
  for (  SwiftAST caseBody : sw.getCaseBodies()) {
    block(new LocalContext(waitContext),caseBody);
    backend.endCase();
  }
  backend.endSwitch();
  backend.endWaitStatement(usedVariables,keepOpenVars);
}
Program: 133134
Project: 133134
Buggy source:
private void copyArrayByValue(Context context,Var dst,Var src) throws UserException {
  assert(dst.type().equals(src.type()));
  assert(Types.isArray(src.type()));
  LocalContext copyContext=new LocalContext(context);
  Type t=src.type();
  Type memType=Types.getArrayMemberType(t);
  Var member=copyContext.createAliasVariable(memType);
  Var ix=copyContext.createLocalValueVariable(Types.V_INT);
  List<Var> keepOpen=Arrays.asList(dst);
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,keepOpen,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  backend.startForeachLoop(context.getFunctionContext().constructName("String_Node_Str"),src,member,ix,-1,true,usedVars,keepOpen);
  backend.arrayInsertImm(member,dst,Arg.createVar(ix));
  backend.endForeachLoop(-1,true,usedVars,keepOpen);
  backend.endWaitStatement(usedVars,keepOpen);
}

Fixed version (ground truth):
private void copyArrayByValue(Context context,Var dst,Var src) throws UserException {
  assert(dst.type().equals(src.type()));
  assert(Types.isArray(src.type()));
  LocalContext copyContext=new LocalContext(context);
  Type t=src.type();
  Type memType=Types.getArrayMemberType(t);
  Var member=copyContext.createAliasVariable(memType);
  Var ix=copyContext.createLocalValueVariable(Types.V_INT);
  List<Var> keepOpen=Arrays.asList(dst);
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,keepOpen,null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  backend.startForeachLoop(context.getFunctionContext().constructName("String_Node_Str"),src,member,ix,-1,true,usedVars,keepOpen);
  backend.arrayInsertImm(member,dst,Arg.createVar(ix));
  backend.endForeachLoop(-1,true,usedVars,keepOpen);
  backend.endWaitStatement(usedVars,keepOpen);
}
Program: 133135
Project: 133135
Buggy source:
/** 
 * Copy a struct reference to a struct.  We need to do this in the compiler front-end because we want to generate specialized code to walk the structure and copy all struct members
 * @param context
 * @param dst
 * @param src
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void dereferenceStruct(Context context,Var dst,Var src) throws UserException, UndefinedTypeException {
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,new ArrayList<Var>(),WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  Var rValDerefed=varCreator.createTmp(context,src.type().memberType(),false,true);
  backend.retrieveRef(rValDerefed,src);
  copyByValue(context,rValDerefed,dst,dst.type());
  backend.endWaitStatement(usedVars,new ArrayList<Var>());
}

Fixed version (ground truth):
/** 
 * Copy a struct reference to a struct.  We need to do this in the compiler front-end because we want to generate specialized code to walk the structure and copy all struct members
 * @param context
 * @param dst
 * @param src
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void dereferenceStruct(Context context,Var dst,Var src) throws UserException, UndefinedTypeException {
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,new ArrayList<Var>(),null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  Var rValDerefed=varCreator.createTmp(context,src.type().memberType(),false,true);
  backend.retrieveRef(rValDerefed,src);
  copyByValue(context,rValDerefed,dst,dst.type());
  backend.endWaitStatement(usedVars,new ArrayList<Var>());
}
Program: 133137
Project: 133137
Buggy source:
@Override public void generateWrappedBuiltin(String function,FunctionType ft,List<Var> outArgs,List<Var> inArgs,TaskMode mode) throws UserException {
  Function fn=new Function(function,inArgs,outArgs,TaskMode.SYNC);
  this.program.addFunction(fn);
  List<Var> used=new ArrayList<Var>();
  used.addAll(inArgs);
  used.addAll(outArgs);
  WaitMode waitMode;
  if (mode == TaskMode.LOCAL || mode == TaskMode.SYNC) {
    waitMode=WaitMode.DATA_ONLY;
  }
 else {
    waitMode=WaitMode.TASK_DISPATCH;
  }
  WaitStatement wait=new WaitStatement(function + "String_Node_Str",inArgs,used,Collections.<Var>emptyList(),waitMode,true,mode);
  fn.getMainblock().addContinuation(wait);
  Block block=wait.getBlock();
  List<Instruction> instBuffer=new ArrayList<Instruction>();
  List<Arg> inVals=new ArrayList<Arg>();
  for (  Var inArg : inArgs) {
    inVals.add(Arg.createVar(WrapUtil.fetchValueOf(block,instBuffer,inArg,Var.LOCAL_VALUE_VAR_PREFIX + inArg.name())));
  }
  List<Var> outVals=new ArrayList<Var>();
  for (  Var outArg : outArgs) {
    outVals.add(WrapUtil.declareLocalOutputVar(block,outArg,Var.LOCAL_VALUE_VAR_PREFIX + outArg.name()));
  }
  instBuffer.add(new LocalFunctionCall(function,inVals,outVals));
  for (int i=0; i < outVals.size(); i++) {
    Var outArg=outArgs.get(i);
    Var outVal=outVals.get(i);
    instBuffer.add(ICInstructions.futureSet(outArg,Arg.createVar(outVal)));
  }
  block.addInstructions(instBuffer);
}

Fixed version (ground truth):
@Override public void generateWrappedBuiltin(String function,FunctionType ft,List<Var> outArgs,List<Var> inArgs,TaskMode mode) throws UserException {
  Function fn=new Function(function,inArgs,outArgs,TaskMode.SYNC);
  this.program.addFunction(fn);
  List<Var> used=new ArrayList<Var>();
  used.addAll(inArgs);
  used.addAll(outArgs);
  WaitMode waitMode;
  if (mode == TaskMode.LOCAL || mode == TaskMode.SYNC) {
    waitMode=WaitMode.DATA_ONLY;
  }
 else {
    waitMode=WaitMode.TASK_DISPATCH;
  }
  WaitStatement wait=new WaitStatement(function + "String_Node_Str",inArgs,used,Collections.<Var>emptyList(),null,waitMode,true,mode);
  fn.getMainblock().addContinuation(wait);
  Block block=wait.getBlock();
  List<Instruction> instBuffer=new ArrayList<Instruction>();
  List<Arg> inVals=new ArrayList<Arg>();
  for (  Var inArg : inArgs) {
    inVals.add(Arg.createVar(WrapUtil.fetchValueOf(block,instBuffer,inArg,Var.LOCAL_VALUE_VAR_PREFIX + inArg.name())));
  }
  List<Var> outVals=new ArrayList<Var>();
  for (  Var outArg : outArgs) {
    outVals.add(WrapUtil.declareLocalOutputVar(block,outArg,Var.LOCAL_VALUE_VAR_PREFIX + outArg.name()));
  }
  instBuffer.add(new LocalFunctionCall(function,inVals,outVals));
  for (int i=0; i < outVals.size(); i++) {
    Var outArg=outArgs.get(i);
    Var outVal=outVals.get(i);
    instBuffer.add(ICInstructions.futureSet(outArg,Arg.createVar(outVal)));
  }
  block.addInstructions(instBuffer);
}
Program: 133138
Project: 133138
Buggy source:
@Override public void startWaitStatement(String procName,List<Var> waitVars,List<Var> usedVariables,List<Var> keepOpenVars,WaitMode mode,boolean recursive,TaskMode target){
  assert(currFunction != null);
  WaitStatement wait=new WaitStatement(procName,waitVars,usedVariables,keepOpenVars,mode,recursive,target);
  currBlock().addContinuation(wait);
  blockStack.push(wait.getBlock());
}

Fixed version (ground truth):
@Override public void startWaitStatement(String procName,List<Var> waitVars,List<Var> usedVariables,List<Var> keepOpenVars,Arg priority,WaitMode mode,boolean recursive,TaskMode target){
  assert(currFunction != null);
  assert(priority == null || priority.isImmediateInt());
  WaitStatement wait=new WaitStatement(procName,waitVars,usedVariables,keepOpenVars,priority,mode,recursive,target);
  currBlock().addContinuation(wait);
  blockStack.push(wait.getBlock());
}
Program: 133140
Project: 133140
Buggy source:
private void doInlining(Logger logger,Program prog,Function contextFunction,Block block,MultiMap<String,String> inlineLocations,Map<String,Function> toInline){
  for (  Continuation c : block.getContinuations()) {
    for (    Block cb : c.getBlocks()) {
      doInlining(logger,prog,contextFunction,cb,inlineLocations,toInline);
    }
  }
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction inst=it.next();
    if (isFunctionCall(inst)) {
      FunctionCall fcall=(FunctionCall)inst;
      if (toInline.containsKey(fcall.getFunctionName())) {
        if (fcall.getPriority() != null)         continue;
        List<String> inlineCallers=inlineLocations.get(fcall.getFunctionName());
        if (inlineCallers.contains(contextFunction.getName())) {
          inlineCall(logger,prog,contextFunction,block,it,fcall,toInline.get(fcall.getFunctionName()));
        }
      }
    }
  }
}

Fixed version (ground truth):
private void doInlining(Logger logger,Program prog,Function contextFunction,Block block,MultiMap<String,String> inlineLocations,Map<String,Function> toInline){
  for (  Continuation c : block.getContinuations()) {
    for (    Block cb : c.getBlocks()) {
      doInlining(logger,prog,contextFunction,cb,inlineLocations,toInline);
    }
  }
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction inst=it.next();
    if (isFunctionCall(inst)) {
      FunctionCall fcall=(FunctionCall)inst;
      if (toInline.containsKey(fcall.getFunctionName())) {
        List<String> inlineCallers=inlineLocations.get(fcall.getFunctionName());
        if (inlineCallers.contains(contextFunction.getName())) {
          inlineCall(logger,prog,contextFunction,block,it,fcall,toInline.get(fcall.getFunctionName()));
        }
      }
    }
  }
}
Program: 133143
Project: 133143
Buggy source:
@Override public Collection<Var> requiredVars(){
  ArrayList<Var> res=new ArrayList<Var>();
  if (mode == WaitMode.EXPLICIT || mode == WaitMode.TASK_DISPATCH) {
    for (    Var v : waitVars) {
      res.add(v);
    }
  }
  return res;
}

Fixed version (ground truth):
@Override public Collection<Var> requiredVars(){
  ArrayList<Var> res=new ArrayList<Var>();
  if (mode == WaitMode.EXPLICIT || mode == WaitMode.TASK_DISPATCH) {
    for (    Var v : waitVars) {
      res.add(v);
    }
  }
  if (priority != null && priority.isVar()) {
    res.add(priority.getVar());
  }
  return res;
}
Program: 133144
Project: 133144
Buggy source:
@Override public void generate(Logger logger,CompilerBackend gen,GenInfo info) throws UndefinedTypeException {
  gen.startWaitStatement(procName,waitVars,passedInVars,keepOpenVars,mode,recursive,target);
  this.block.generate(logger,gen,info);
  gen.endWaitStatement(passedInVars,keepOpenVars);
}

Fixed version (ground truth):
@Override public void generate(Logger logger,CompilerBackend gen,GenInfo info) throws UndefinedTypeException {
  gen.startWaitStatement(procName,waitVars,passedInVars,keepOpenVars,priority,mode,recursive,target);
  this.block.generate(logger,gen,info);
  gen.endWaitStatement(passedInVars,keepOpenVars);
}
Program: 133145
Project: 133145
Buggy source:
@Override public void replaceConstructVars_(Map<String,Arg> renames,boolean inputsOnly){
  ICUtil.replaceVarsInList(renames,waitVars,true);
}

Fixed version (ground truth):
@Override public void replaceConstructVars_(Map<String,Arg> renames,boolean inputsOnly){
  ICUtil.replaceVarsInList(renames,waitVars,true);
  priority=ICUtil.replaceOparg(renames,priority,true);
}
Program: 133146
Project: 133146
Buggy source:
private WaitStatement(String procName,Block block,List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars,WaitMode mode,boolean recursive,TaskMode target){
  super(usedVars,keepOpenVars);
  assert(waitVars != null);
  assert(usedVars != null);
  assert(keepOpenVars != null);
  assert(target != null);
  assert(mode != null);
  this.procName=procName;
  this.block=block;
  this.block.setParent(this);
  this.waitVars=new ArrayList<Var>(waitVars);
  ICUtil.removeDuplicates(this.waitVars);
  this.mode=mode;
  this.recursive=recursive;
  this.target=target;
}

Fixed version (ground truth):
private WaitStatement(String procName,Block block,List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars,Arg priority,WaitMode mode,boolean recursive,TaskMode target){
  super(usedVars,keepOpenVars);
  assert(waitVars != null);
  assert(usedVars != null);
  assert(keepOpenVars != null);
  assert(target != null);
  assert(mode != null);
  this.procName=procName;
  this.block=block;
  this.block.setParent(this);
  this.waitVars=new ArrayList<Var>(waitVars);
  ICUtil.removeDuplicates(this.waitVars);
  this.priority=priority;
  this.mode=mode;
  this.recursive=recursive;
  this.target=target;
}
Program: 133147
Project: 133147
Buggy source:
@Override public void prettyPrint(StringBuilder sb,String currentIndent){
  String newIndent=currentIndent + indent;
  sb.append(currentIndent + "String_Node_Str");
  ICUtil.prettyPrintVarList(sb,waitVars);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str" + procName + "String_Node_Str");
  ICUtil.prettyPrintVarInfo(sb,passedInVars,keepOpenVars);
  sb.append("String_Node_Str" + mode + "String_Node_Str"+ target+ "String_Node_Str"+ (recursive ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
  sb.append("String_Node_Str");
  block.prettyPrint(sb,newIndent);
  sb.append(currentIndent + "String_Node_Str");
}

Fixed version (ground truth):
@Override public void prettyPrint(StringBuilder sb,String currentIndent){
  String newIndent=currentIndent + indent;
  sb.append(currentIndent + "String_Node_Str");
  ICUtil.prettyPrintVarList(sb,waitVars);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str" + procName + "String_Node_Str");
  ICUtil.prettyPrintVarInfo(sb,passedInVars,keepOpenVars);
  sb.append("String_Node_Str" + mode + "String_Node_Str"+ target+ "String_Node_Str"+ (recursive ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
  if (priority != null) {
    sb.append("String_Node_Str" + priority);
  }
  sb.append("String_Node_Str");
  block.prettyPrint(sb,newIndent);
  sb.append(currentIndent + "String_Node_Str");
}
Program: 133148
Project: 133148
Buggy source:
@Override public WaitStatement clone(){
  return new WaitStatement(procName,this.block.clone(),waitVars,passedInVars,keepOpenVars,mode,recursive,target);
}

Fixed version (ground truth):
@Override public WaitStatement clone(){
  return new WaitStatement(procName,this.block.clone(),waitVars,passedInVars,keepOpenVars,priority,mode,recursive,target);
}
Program: 133149
Project: 133149
Buggy source:
public Arg getPriority(){
  return priority;
}

Fixed version (ground truth):
@Override public Arg getPriority(){
  return priority;
}
Program: 133150
Project: 133150
Buggy source:
@Override public void startWaitStatement(String procName,List<Var> waitVars,List<Var> usedVariables,List<Var> keepOpenVars,WaitMode mode,boolean recursive,TaskMode target){
  logger.trace("String_Node_Str");
  startAsync(procName,waitVars,usedVariables,keepOpenVars,false);
}

Fixed version (ground truth):
@Override public void startWaitStatement(String procName,List<Var> waitVars,List<Var> usedVariables,List<Var> keepOpenVars,Arg priority,WaitMode mode,boolean recursive,TaskMode target){
  logger.trace("String_Node_Str");
  startAsync(procName,waitVars,usedVariables,keepOpenVars,false);
}
Program: 133151
Project: 133151
Buggy source:
public abstract void endWaitStatement(List<Var> usedVars,List<Var> keepOpenVars);

Fixed version (ground truth):
public abstract void endWaitStatement(List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars);
Program: 133153
Project: 133153
Buggy source:
private void waitStmt(Context context,SwiftAST tree) throws UserException {
  Wait wait=Wait.fromAST(context,tree);
  ArrayList<Var> waitEvaled=new ArrayList<Var>();
  for (  SwiftAST expr : wait.getWaitExprs()) {
    Var res=exprWalker.eval(context,expr,TypeChecker.findSingleExprType(context,expr),false,null);
    waitEvaled.add(res);
  }
  ArrayList<Var> usedVars=new ArrayList<Var>();
  ArrayList<Var> keepOpenVars=new ArrayList<Var>();
  summariseBranchVariableUsage(context,Arrays.asList(wait.getBlock().getVariableUsage()),usedVars,keepOpenVars);
  HashSet<String> waitVarSet=new HashSet<String>(Var.nameList(waitEvaled));
  waitVarSet.retainAll(Var.nameList(keepOpenVars));
  if (waitVarSet.size() > 0) {
    throw new UserException(context,"String_Node_Str" + "String_Node_Str" + waitVarSet.toString());
  }
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitEvaled,usedVars,keepOpenVars,null,WaitMode.EXPLICIT,false,TaskMode.LOCAL_CONTROL);
  block(new LocalContext(context),wait.getBlock());
  backend.endWaitStatement(usedVars,keepOpenVars);
}

Fixed version (ground truth):
private void waitStmt(Context context,SwiftAST tree) throws UserException {
  Wait wait=Wait.fromAST(context,tree);
  ArrayList<Var> waitEvaled=new ArrayList<Var>();
  for (  SwiftAST expr : wait.getWaitExprs()) {
    Var res=exprWalker.eval(context,expr,TypeChecker.findSingleExprType(context,expr),false,null);
    waitEvaled.add(res);
  }
  ArrayList<Var> usedVars=new ArrayList<Var>();
  ArrayList<Var> keepOpenVars=new ArrayList<Var>();
  summariseBranchVariableUsage(context,Arrays.asList(wait.getBlock().getVariableUsage()),usedVars,keepOpenVars);
  HashSet<String> waitVarSet=new HashSet<String>(Var.nameList(waitEvaled));
  waitVarSet.retainAll(Var.nameList(keepOpenVars));
  if (waitVarSet.size() > 0) {
    throw new UserException(context,"String_Node_Str" + "String_Node_Str" + waitVarSet.toString());
  }
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitEvaled,usedVars,keepOpenVars,null,WaitMode.EXPLICIT,false,TaskMode.LOCAL_CONTROL);
  block(new LocalContext(context),wait.getBlock());
  backend.endWaitStatement(waitEvaled,usedVars,keepOpenVars);
}
Program: 133155
Project: 133155
Buggy source:
private void switchStatement(Context context,SwiftAST tree) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  Switch sw=Switch.fromAST(context,tree);
  sw.typeCheck(context);
  Var switchVar=exprWalker.eval(context,sw.getSwitchExpr(),Types.F_INT,true,null);
  List<Var> usedVariables=new ArrayList<Var>();
  List<Var> keepOpenVars=new ArrayList<Var>();
  List<VariableUsageInfo> branchVUs=new ArrayList<VariableUsageInfo>();
  for (  SwiftAST b : sw.getCaseBodies()) {
    branchVUs.add(b.checkedGetVariableUsage());
  }
  checkConditionalDeadlock(context,switchVar,branchVUs);
  summariseBranchVariableUsage(context,branchVUs,usedVariables,keepOpenVars);
  if (!usedVariables.contains(switchVar))   usedVariables.add(switchVar);
  FunctionContext fc=context.getFunctionContext();
  backend.startWaitStatement(fc.constructName("String_Node_Str"),Arrays.asList(switchVar),usedVariables,keepOpenVars,null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL_CONTROL);
  Context waitContext=new LocalContext(context);
  Var switchVal=varCreator.createValueOfVar(waitContext,switchVar);
  backend.retrieveInt(switchVal,switchVar);
  LogHelper.trace(context,"String_Node_Str" + sw.getCaseBodies().size() + "String_Node_Str");
  backend.startSwitch(Arg.createVar(switchVal),sw.getCaseLabels(),sw.hasDefault());
  for (  SwiftAST caseBody : sw.getCaseBodies()) {
    block(new LocalContext(waitContext),caseBody);
    backend.endCase();
  }
  backend.endSwitch();
  backend.endWaitStatement(usedVariables,keepOpenVars);
}

Fixed version (ground truth):
private void switchStatement(Context context,SwiftAST tree) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  Switch sw=Switch.fromAST(context,tree);
  sw.typeCheck(context);
  Var switchVar=exprWalker.eval(context,sw.getSwitchExpr(),Types.F_INT,true,null);
  List<Var> usedVariables=new ArrayList<Var>();
  List<Var> keepOpenVars=new ArrayList<Var>();
  List<VariableUsageInfo> branchVUs=new ArrayList<VariableUsageInfo>();
  for (  SwiftAST b : sw.getCaseBodies()) {
    branchVUs.add(b.checkedGetVariableUsage());
  }
  checkConditionalDeadlock(context,switchVar,branchVUs);
  summariseBranchVariableUsage(context,branchVUs,usedVariables,keepOpenVars);
  if (!usedVariables.contains(switchVar))   usedVariables.add(switchVar);
  FunctionContext fc=context.getFunctionContext();
  backend.startWaitStatement(fc.constructName("String_Node_Str"),Arrays.asList(switchVar),usedVariables,keepOpenVars,null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL_CONTROL);
  Context waitContext=new LocalContext(context);
  Var switchVal=varCreator.createValueOfVar(waitContext,switchVar);
  backend.retrieveInt(switchVal,switchVar);
  LogHelper.trace(context,"String_Node_Str" + sw.getCaseBodies().size() + "String_Node_Str");
  backend.startSwitch(Arg.createVar(switchVal),sw.getCaseLabels(),sw.hasDefault());
  for (  SwiftAST caseBody : sw.getCaseBodies()) {
    block(new LocalContext(waitContext),caseBody);
    backend.endCase();
  }
  backend.endSwitch();
  backend.endWaitStatement(Arrays.asList(switchVar),usedVariables,keepOpenVars);
}
Program: 133160
Project: 133160
Buggy source:
private void copyArrayByValue(Context context,Var dst,Var src) throws UserException {
  assert(dst.type().equals(src.type()));
  assert(Types.isArray(src.type()));
  LocalContext copyContext=new LocalContext(context);
  Type t=src.type();
  Type memType=Types.getArrayMemberType(t);
  Var member=copyContext.createAliasVariable(memType);
  Var ix=copyContext.createLocalValueVariable(Types.V_INT);
  List<Var> keepOpen=Arrays.asList(dst);
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,keepOpen,null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  backend.startForeachLoop(context.getFunctionContext().constructName("String_Node_Str"),src,member,ix,-1,true,usedVars,keepOpen);
  backend.arrayInsertImm(member,dst,Arg.createVar(ix));
  backend.endForeachLoop(-1,true,usedVars,keepOpen);
  backend.endWaitStatement(usedVars,keepOpen);
}

Fixed version (ground truth):
private void copyArrayByValue(Context context,Var dst,Var src) throws UserException {
  assert(dst.type().equals(src.type()));
  assert(Types.isArray(src.type()));
  LocalContext copyContext=new LocalContext(context);
  Type t=src.type();
  Type memType=Types.getArrayMemberType(t);
  Var member=copyContext.createAliasVariable(memType);
  Var ix=copyContext.createLocalValueVariable(Types.V_INT);
  List<Var> keepOpen=Arrays.asList(dst);
  List<Var> usedVars=Arrays.asList(src,dst);
  List<Var> waitVars=Arrays.asList(src);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitVars,usedVars,keepOpen,null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  backend.startForeachLoop(context.getFunctionContext().constructName("String_Node_Str"),src,member,ix,-1,true,usedVars,keepOpen);
  backend.arrayInsertImm(member,dst,Arg.createVar(ix));
  backend.endForeachLoop(-1,true,usedVars,keepOpen);
  backend.endWaitStatement(waitVars,usedVars,keepOpen);
}
Program: 133161
Project: 133161
Buggy source:
/** 
 * Copy a struct reference to a struct.  We need to do this in the compiler front-end because we want to generate specialized code to walk the structure and copy all struct members
 * @param context
 * @param dst
 * @param src
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void dereferenceStruct(Context context,Var dst,Var src) throws UserException, UndefinedTypeException {
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,new ArrayList<Var>(),null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  Var rValDerefed=varCreator.createTmp(context,src.type().memberType(),false,true);
  backend.retrieveRef(rValDerefed,src);
  copyByValue(context,rValDerefed,dst,dst.type());
  backend.endWaitStatement(usedVars,new ArrayList<Var>());
}

Fixed version (ground truth):
/** 
 * Copy a struct reference to a struct.  We need to do this in the compiler front-end because we want to generate specialized code to walk the structure and copy all struct members
 * @param context
 * @param dst
 * @param src
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void dereferenceStruct(Context context,Var dst,Var src) throws UserException, UndefinedTypeException {
  List<Var> usedVars=Arrays.asList(src,dst);
  List<Var> waitVars=Arrays.asList(src);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitVars,usedVars,new ArrayList<Var>(),null,WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
  Var rValDerefed=varCreator.createTmp(context,src.type().memberType(),false,true);
  backend.retrieveRef(rValDerefed,src);
  copyByValue(context,rValDerefed,dst,dst.type());
  backend.endWaitStatement(waitVars,usedVars,new ArrayList<Var>());
}
Program: 133163
Project: 133163
Buggy source:
@Override public void endWaitStatement(List<Var> usedVars,List<Var> keepOpenVars){
  assert(currBlock().getType() == BlockType.WAIT_BLOCK);
  blockStack.pop();
}

Fixed version (ground truth):
@Override public void endWaitStatement(List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars){
  assert(currBlock().getType() == BlockType.WAIT_BLOCK);
  blockStack.pop();
}
Program: 133164
Project: 133164
Buggy source:
@Override public void generate(Logger logger,CompilerBackend gen,GenInfo info) throws UndefinedTypeException {
  gen.startWaitStatement(procName,waitVars,passedInVars,keepOpenVars,priority,mode,recursive,target);
  this.block.generate(logger,gen,info);
  gen.endWaitStatement(passedInVars,keepOpenVars);
}

Fixed version (ground truth):
@Override public void generate(Logger logger,CompilerBackend gen,GenInfo info) throws UndefinedTypeException {
  gen.startWaitStatement(procName,waitVars,passedInVars,keepOpenVars,priority,mode,recursive,target);
  this.block.generate(logger,gen,info);
  gen.endWaitStatement(waitVars,passedInVars,keepOpenVars);
}
Program: 133165
Project: 133165
Buggy source:
@Override public void endWaitStatement(List<Var> usedVars,List<Var> keepOpenVars){
  logger.trace("String_Node_Str");
  endAsync(keepOpenVars);
}

Fixed version (ground truth):
@Override public void endWaitStatement(List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars){
  logger.trace("String_Node_Str");
  endAsync(keepOpenVars);
}
Program: 133166
Project: 133166
Buggy source:
private void endAsync(List<Var> usedVars,List<Var> keepOpenVars){
  decrementAllRefs(usedVars,keepOpenVars);
  execContextStack.pop();
  pointStack.pop();
}

Fixed version (ground truth):
private void endAsync(List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars){
  List<Var> allUsedVars=asyncUsedVars(usedVars,waitVars);
  decrementAllRefs(allUsedVars,keepOpenVars);
  execContextStack.pop();
  pointStack.pop();
}
Program: 133168
Project: 133168
Buggy source:
@Override public void endWaitStatement(List<Var> usedVars,List<Var> keepOpenVars){
  logger.trace("String_Node_Str");
  endAsync(usedVars,keepOpenVars);
}

Fixed version (ground truth):
@Override public void endWaitStatement(List<Var> waitVars,List<Var> usedVars,List<Var> keepOpenVars){
  logger.trace("String_Node_Str");
  endAsync(waitVars,usedVars,keepOpenVars);
}
Program: 133169
Project: 133169
Buggy source:
private static void doHoist(Logger logger,List<Block> ancestors,Block curr,Instruction inst,ListIterator<Instruction> currInstIt,int hoistDepth,HierarchicalMap<String,Block> writeMap){
  assert(hoistDepth > 0);
  assert(hoistDepth <= ancestors.size());
  Block target=ancestors.get(ancestors.size() - hoistDepth);
  logger.trace("String_Node_Str" + hoistDepth + "String_Node_Str"+ inst.toString());
  assert(target != null);
  currInstIt.remove();
  target.addInstruction(inst);
  relocateVarDefs(curr,target,ancestors,inst,hoistDepth);
  for (  Var out : inst.getOutputs()) {
    writeMap.remove(out.name(),false);
    writeMap.put(out.name(),target,hoistDepth);
  }
}

Fixed version (ground truth):
private static void doHoist(Logger logger,List<Block> ancestors,Block curr,Instruction inst,ListIterator<Instruction> currInstIt,int hoistDepth,HierarchicalMap<String,Block> writeMap){
  assert(hoistDepth > 0);
  assert(hoistDepth <= ancestors.size());
  Block target=ancestors.get(ancestors.size() - hoistDepth);
  logger.trace("String_Node_Str" + hoistDepth + "String_Node_Str"+ inst.toString());
  assert(target != null);
  currInstIt.remove();
  target.addInstruction(inst);
  relocateVarDefs(curr,target,ancestors,inst,hoistDepth);
  for (  Var out : inst.getOutputs()) {
    writeMap.remove(out.name(),false);
    if (trackWrites(out)) {
      writeMap.put(out.name(),target,hoistDepth);
    }
  }
}
Program: 133170
Project: 133170
Buggy source:
/** 
 * True if the variable is one we should track
 * @param in
 * @return
 */
private static boolean trackWrites(Var in){
  Type t=in.type();
  if (Types.isScalarFuture(t) || Types.isScalarValue(t)) {
    return true;
  }
 else   if (Types.isRef(t) && Types.isScalarFuture(t.memberType())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * True if the variable is one we should track
 * @param in
 * @return
 */
private static boolean trackWrites(Var in){
  Type t=in.type();
  if (Types.isScalarFuture(t) || Types.isScalarValue(t)) {
    return true;
  }
 else   if (Types.isRef(t)) {
    return true;
  }
  return false;
}
Program: 133171
Project: 133171
Buggy source:
private static void updateName(Set<String> usedNames,HashMap<String,Arg> renames,Var var){
  if (usedNames.contains(var.name())) {
    System.err.println(var.name() + "String_Node_Str");
    String newName=chooseNewName(usedNames,var);
    renames.put(var.name(),Arg.createVar(new Var(var.type(),newName,var.storage(),var.defType(),var.mapping())));
    usedNames.add(newName);
  }
 else {
    usedNames.add(var.name());
  }
}

Fixed version (ground truth):
private static void updateName(Set<String> usedNames,HashMap<String,Arg> renames,Var var){
  if (usedNames.contains(var.name())) {
    String newName=chooseNewName(usedNames,var);
    renames.put(var.name(),Arg.createVar(new Var(var.type(),newName,var.storage(),var.defType(),var.mapping())));
    usedNames.add(newName);
  }
 else {
    usedNames.add(var.name());
  }
}
Program: 133172
Project: 133172
Buggy source:
private void updateName(Block block,Function f,Map<String,Arg> replacements,Set<String> excludedNames,Var var){
  String newName=f.getMainblock().uniqueVarName(var.name(),excludedNames);
  Var newVar=new Var(var.type(),newName,var.storage(),var.defType(),var.mapping());
  replacements.put(var.name(),Arg.createVar(newVar));
  excludedNames.add(newName);
  UniqueVarNames.replaceCleanup(block,var,newVar);
}

Fixed version (ground truth):
private void updateName(Logger logger,Block block,Function targetFunction,Map<String,Arg> replacements,Set<String> excludedNames,Var var){
  String newName=targetFunction.getMainblock().uniqueVarName(var.name(),excludedNames);
  Var newVar=new Var(var.type(),newName,var.storage(),var.defType(),var.mapping());
  replacements.put(var.name(),Arg.createVar(newVar));
  excludedNames.add(newName);
  UniqueVarNames.replaceCleanup(block,var,newVar);
  logger.trace("String_Node_Str" + var + "String_Node_Str"+ newVar+ "String_Node_Str"+ targetFunction.getName());
}
Program: 133173
Project: 133173
Buggy source:
/** 
 * Set up renames for local variables in inline block
 * @param prog program
 * @param targetFunction function block being inlined into
 * @param inlineBlock block to be inlined
 * @param replacements updated with new renames
 */
private void chooseUniqueNames(Program prog,Function targetFunction,Block inlineBlock,Map<String,Arg> replacements){
  Set<String> excludedNames=new HashSet<String>();
  excludedNames.addAll(prog.getGlobalConsts().keySet());
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(inlineBlock);
  while (!blocks.isEmpty()) {
    Block block=blocks.pop();
    for (    Var v : block.getVariables()) {
      if (v.defType() != DefType.GLOBAL_CONST) {
        updateName(block,targetFunction,replacements,excludedNames,v);
      }
    }
    for (    Continuation c : block.getContinuations()) {
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null) {
        for (        Var cv : constructVars) {
          updateName(block,targetFunction,replacements,excludedNames,cv);
        }
      }
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Set up renames for local variables in inline block
 * @param prog program
 * @param targetFunction function block being inlined into
 * @param inlineBlock block to be inlined
 * @param replacements updated with new renames
 */
private void chooseUniqueNames(Logger logger,Program prog,Function targetFunction,Block inlineBlock,Map<String,Arg> replacements){
  Set<String> excludedNames=new HashSet<String>();
  excludedNames.addAll(prog.getGlobalConsts().keySet());
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(inlineBlock);
  while (!blocks.isEmpty()) {
    Block block=blocks.pop();
    for (    Var v : block.getVariables()) {
      if (v.defType() != DefType.GLOBAL_CONST) {
        updateName(logger,block,targetFunction,replacements,excludedNames,v);
      }
    }
    for (    Continuation c : block.getContinuations()) {
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null) {
        for (        Var cv : constructVars) {
          updateName(logger,block,targetFunction,replacements,excludedNames,cv);
        }
      }
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
}
Program: 133174
Project: 133174
Buggy source:
/** 
 * Do one iteration of the iterative optimizer passes
 * @param icOutput
 * @param logger
 * @param prog
 * @param iteration
 * @param nIterations
 * @throws Exception
 */
private static void iterate(PrintStream icOutput,Logger logger,Program prog,long nIterations) throws UserException {
  FunctionInline inliner=new FunctionInline();
  for (long iteration=0; iteration < nIterations; iteration++) {
    OptimizerPipeline pipe=new OptimizerPipeline(icOutput);
    pipe.addPass(inliner);
    pipe.addPass(new Validate());
    pipe.addPass(new ConstantFold());
    if (iteration == 0) {
      pipe.addPass(new LoopUnroller());
    }
    pipe.addPass(new HoistLoops());
    pipe.addPass(new ForwardDataflow());
    pipe.addPass(new ContinuationFusion());
    if (iteration == nIterations - 2) {
      pipe.addPass(new Pipeline());
      pipe.addPass(new Validate());
    }
    boolean doWaitMerges=(iteration == nIterations - 1);
    pipe.addPass(new WaitCoalescer(doWaitMerges));
    pipe.addPass(new Validate());
    pipe.runPipeline(logger,prog,iteration);
  }
}

Fixed version (ground truth):
/** 
 * Do one iteration of the iterative optimizer passes
 * @param icOutput
 * @param logger
 * @param prog
 * @param iteration
 * @param nIterations
 * @throws Exception
 */
private static void iterate(PrintStream icOutput,Logger logger,Program prog,long nIterations) throws UserException {
  FunctionInline inliner=new FunctionInline();
  for (long iteration=0; iteration < nIterations; iteration++) {
    OptimizerPipeline pipe=new OptimizerPipeline(icOutput);
    pipe.addPass(inliner);
    pipe.addPass(new FixupVariables());
    pipe.addPass(new Validate());
    pipe.addPass(new ConstantFold());
    if (iteration == 0) {
      pipe.addPass(new LoopUnroller());
    }
    pipe.addPass(new HoistLoops());
    pipe.addPass(new ForwardDataflow());
    pipe.addPass(new ContinuationFusion());
    if (iteration == nIterations - 2) {
      pipe.addPass(new Pipeline());
      pipe.addPass(new Validate());
    }
    boolean doWaitMerges=(iteration == nIterations - 1);
    pipe.addPass(new WaitCoalescer(doWaitMerges));
    pipe.addPass(new Validate());
    pipe.runPipeline(logger,prog,iteration);
  }
}
Program: 133175
Project: 133175
Buggy source:
public void prettyPrint(StringBuilder sb,String indent){
  for (  Var v : variables) {
    sb.append(indent);
    sb.append("String_Node_Str" + v.type().typeName() + "String_Node_Str"+ v.name()+ "String_Node_Str"+ v.storage().toString().toLowerCase()+ "String_Node_Str");
    if (v.isMapped()) {
      sb.append("String_Node_Str" + v.mapping().name());
    }
    sb.append("String_Node_Str");
  }
  for (  Instruction i : instructions) {
    sb.append(indent);
    sb.append(i.toString());
    sb.append("String_Node_Str");
  }
  for (  boolean runLast : new boolean[]{false,true}) {
    for (    Continuation c : continuations) {
      if (c.runLast() == runLast) {
        c.prettyPrint(sb,indent);
      }
    }
  }
  for (  CleanupAction a : cleanupActions) {
    sb.append(indent);
    sb.append(a.action().toString());
    sb.append("String_Node_Str" + a.var.name());
    sb.append("String_Node_Str");
  }
}

Fixed version (ground truth):
public void prettyPrint(StringBuilder sb,String indent){
  for (  Var v : variables) {
    sb.append(indent);
    sb.append("String_Node_Str" + v.type().typeName() + "String_Node_Str"+ v.name()+ "String_Node_Str"+ v.storage().toString().toLowerCase()+ "String_Node_Str");
    if (v.isMapped()) {
      sb.append("String_Node_Str" + v.mapping().name());
    }
    sb.append("String_Node_Str");
  }
  for (  Instruction i : instructions) {
    sb.append(indent);
    sb.append(i.toString());
    sb.append("String_Node_Str");
  }
  for (  boolean runLast : new boolean[]{false,true}) {
    for (    Continuation c : continuations) {
      if (c.runLast() == runLast) {
        c.prettyPrint(sb,indent);
      }
    }
  }
  for (  CleanupAction a : cleanupActions) {
    sb.append(indent);
    sb.append(a.toString());
    sb.append("String_Node_Str");
  }
}
Program: 133176
Project: 133176
Buggy source:
public Block clone(BlockType newType,Continuation parentCont,Function parentFunction){
  Block cloned=new Block(newType,parentCont,parentFunction,ICUtil.cloneInstructions(this.instructions),new ArrayList<Var>(this.variables),new ArrayList<Continuation>(),new ArrayList<CleanupAction>(this.cleanupActions));
  for (  Continuation c : this.continuations) {
    cloned.addContinuation(c.clone());
  }
  return cloned;
}

Fixed version (ground truth):
public Block clone(BlockType newType,Continuation parentCont,Function parentFunction){
  Block cloned=new Block(newType,parentCont,parentFunction,ICUtil.cloneInstructions(this.instructions),new ArrayList<Var>(this.variables),new ArrayList<Continuation>(),ICUtil.cloneCleanups(this.cleanupActions));
  for (  Continuation c : this.continuations) {
    cloned.addContinuation(c.clone());
  }
  return cloned;
}
Program: 133177
Project: 133177
Buggy source:
private void doInlining(Logger logger,Program prog,Function contextFunction,Block block,MultiMap<String,String> inlineLocations,Map<String,Function> toInline){
  for (  Continuation c : block.getContinuations()) {
    for (    Block cb : c.getBlocks()) {
      doInlining(logger,prog,contextFunction,cb,inlineLocations,toInline);
    }
  }
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction inst=it.next();
    if (isFunctionCall(inst)) {
      FunctionCall fcall=(FunctionCall)inst;
      if (toInline.containsKey(fcall.getFunctionName())) {
        List<String> inlineCallers=inlineLocations.get(fcall.getFunctionName());
        if (inlineCallers.contains(contextFunction.getName())) {
          inlineCall(logger,prog,contextFunction,block,it,fcall,toInline.get(fcall.getFunctionName()));
        }
      }
    }
  }
}

Fixed version (ground truth):
private void doInlining(Logger logger,Program prog,Function contextFunction,Block block,MultiMap<String,String> inlineLocations,Map<String,Function> toInline){
  for (  Continuation c : block.getContinuations()) {
    for (    Block cb : c.getBlocks()) {
      doInlining(logger,prog,contextFunction,cb,inlineLocations,toInline);
    }
  }
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction inst=it.next();
    if (isFunctionCall(inst)) {
      FunctionCall fcall=(FunctionCall)inst;
      if (toInline.containsKey(fcall.getFunctionName())) {
        if (fcall.getPriority() != null)         continue;
        List<String> inlineCallers=inlineLocations.get(fcall.getFunctionName());
        if (inlineCallers.contains(contextFunction.getName())) {
          inlineCall(logger,prog,contextFunction,block,it,fcall,toInline.get(fcall.getFunctionName()));
        }
      }
    }
  }
}