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

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();
  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);
    renames.put(toInline.getInputList().get(i).name(),inputVal);
    if (inputVal.isVar()) {
      passIn.add(inputVal.getVar());
    }
  }
  for (int i=0; i < fnCall.getOutputs().size(); i++) {
    Var outVar=fnCall.getOutput(i);
    renames.put(toInline.getOutputList().get(i).name(),Arg.createVar(outVar));
    passIn.add(outVar);
    if (Types.isArray(outVar.type())) {
      outArrays.add(outVar);
    }
  }
  Block insertBlock;
  ListIterator<Instruction> insertPos;
  Block inlineBlock=toInline.getMainblock().clone(BlockType.NESTED_BLOCK,null,null);
  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 + "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"+ toInline.getName());
}