Program: 133185
Project: 133185
Buggy source:
/** 
 * Do the inlining
 * @param logger
 * @param block
 * @param it iterator positioned at function call instruction
 * @param fnCall
 * @param toInline
 */
private void inlineCall(Logger logger,Program prog,Function contextFunction,Block block,ListIterator<Instruction> it,FunctionCall fnCall,Function toInline){
  it.remove();
  Block inlineBlock=toInline.getMainblock().clone(BlockType.NESTED_BLOCK,null,null);
  Map<String,Arg> renames=new HashMap<String,Arg>();
  List<Var> passIn=new ArrayList<Var>();
  List<Var> outArrays=new ArrayList<Var>();
  assert(fnCall.getOutputs().size() == toInline.getOutputList().size());
  assert(fnCall.getInputs().size() == toInline.getInputList().size());
  for (int i=0; i < fnCall.getInputs().size(); i++) {
    Arg inputVal=fnCall.getInput(i);
    Var inArg=toInline.getInputList().get(i);
    renames.put(inArg.name(),inputVal);
    if (inputVal.isVar()) {
      passIn.add(inputVal.getVar());
    }
    inlineBlock.removeCleanups(inArg);
  }
  for (int i=0; i < fnCall.getOutputs().size(); i++) {
    Var outVar=fnCall.getOutput(i);
    Var outArg=toInline.getOutputList().get(i);
    renames.put(outArg.name(),Arg.createVar(outVar));
    passIn.add(outVar);
    if (Types.isArray(outVar.type())) {
      outArrays.add(outVar);
    }
    inlineBlock.removeCleanups(outArg);
  }
  Block insertBlock;
  ListIterator<Instruction> insertPos;
  chooseUniqueNames(prog,contextFunction,inlineBlock,renames);
  inlineBlock.renameVars(renames,false);
  if (fnCall.getMode() == TaskMode.SYNC) {
    insertBlock=block;
    insertPos=it;
  }
 else {
    WaitMode waitMode=WaitMode.TASK_DISPATCH;
    WaitStatement wait=new WaitStatement(contextFunction.getName() + "String_Node_Str" + toInline.getName()+ "String_Node_Str",toInline.getBlockingInputs(),passIn,outArrays,waitMode,false,fnCall.getMode());
    block.addContinuation(wait);
    insertBlock=wait.getBlock();
    insertPos=insertBlock.instructionIterator();
  }
  insertBlock.insertInline(inlineBlock,insertPos);
  logger.debug("String_Node_Str" + fnCall.getFunctionName() + "String_Node_Str"+ contextFunction.getName());
  new Exception().printStackTrace();
}

Fixed version (ground truth):
/** 
 * Do the inlining
 * @param logger
 * @param block
 * @param it iterator positioned at function call instruction
 * @param fnCall
 * @param toInline
 */
private void inlineCall(Logger logger,Program prog,Function contextFunction,Block block,ListIterator<Instruction> it,FunctionCall fnCall,Function toInline){
  it.remove();
  Block inlineBlock=toInline.getMainblock().clone(BlockType.NESTED_BLOCK,null,null);
  Map<String,Arg> renames=new HashMap<String,Arg>();
  List<Var> passIn=new ArrayList<Var>();
  List<Var> outArrays=new ArrayList<Var>();
  assert(fnCall.getOutputs().size() == toInline.getOutputList().size());
  assert(fnCall.getInputs().size() == toInline.getInputList().size());
  for (int i=0; i < fnCall.getInputs().size(); i++) {
    Arg inputVal=fnCall.getInput(i);
    Var inArg=toInline.getInputList().get(i);
    renames.put(inArg.name(),inputVal);
    if (inputVal.isVar()) {
      passIn.add(inputVal.getVar());
    }
    inlineBlock.removeCleanups(inArg);
  }
  for (int i=0; i < fnCall.getOutputs().size(); i++) {
    Var outVar=fnCall.getOutput(i);
    Var outArg=toInline.getOutputList().get(i);
    renames.put(outArg.name(),Arg.createVar(outVar));
    passIn.add(outVar);
    if (Types.isArray(outVar.type())) {
      outArrays.add(outVar);
    }
    inlineBlock.removeCleanups(outArg);
  }
  Block insertBlock;
  ListIterator<Instruction> insertPos;
  chooseUniqueNames(prog,contextFunction,inlineBlock,renames);
  inlineBlock.renameVars(renames,false);
  if (fnCall.getMode() == TaskMode.SYNC) {
    insertBlock=block;
    insertPos=it;
  }
 else {
    WaitMode waitMode=WaitMode.TASK_DISPATCH;
    WaitStatement wait=new WaitStatement(contextFunction.getName() + "String_Node_Str" + toInline.getName()+ "String_Node_Str",toInline.getBlockingInputs(),passIn,outArrays,waitMode,false,fnCall.getMode());
    block.addContinuation(wait);
    insertBlock=wait.getBlock();
    insertPos=insertBlock.instructionIterator();
  }
  insertBlock.insertInline(inlineBlock,insertPos);
  logger.debug("String_Node_Str" + fnCall.getFunctionName() + "String_Node_Str"+ contextFunction.getName());
  blacklist.add(Pair.create(contextFunction.getName(),fnCall.getFunctionName()));
}