Program: 96678
Project: 96678
Buggy source:
private String removeExtraParagraphs(String fullWordMl,String toInsert,ApplicabilityBlock applicabilityBlock){
  int startInsertIndex=applicabilityBlock.getStartInsertIndex();
  if (!applicabilityBlock.isInTable() && (toInsert.isEmpty() || toInsert.startsWith(WordCoreUtil.WHOLE_END_PARAGRAPH))) {
    String findParagraphStart=fullWordMl.substring(0,startInsertIndex);
    int paragraphStartIndex=findParagraphStart.lastIndexOf(WordCoreUtil.START_PARAGRAPH);
    String beginningText=fullWordMl.substring(paragraphStartIndex,startInsertIndex);
    if (toInsert.isEmpty() && paragraphStartIndex >= 0 && !beginningText.matches("String_Node_Str" + WordCoreUtil.BEGINFEATURE + "String_Node_Str"+ WordCoreUtil.BEGINCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDFEATURE+ "String_Node_Str")) {
      int endInsertIndex=applicabilityBlock.getEndInsertIndex();
      String findParagraphEnd=fullWordMl.substring(endInsertIndex);
      int paragraphEndIndex=findParagraphEnd.indexOf(WordCoreUtil.END_PARAGRAPH) + endInsertIndex + 6;
      if (paragraphEndIndex >= 0) {
        String endText=fullWordMl.substring(endInsertIndex,paragraphEndIndex);
        if (paragraphEndIndex >= 0 && WordCoreUtil.textOnly(endText).isEmpty() && !endText.matches("String_Node_Str" + WordCoreUtil.BEGINFEATURE + "String_Node_Str"+ WordCoreUtil.BEGINCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDFEATURE+ "String_Node_Str")) {
          applicabilityBlock.setStartInsertIndex(paragraphStartIndex);
          applicabilityBlock.setStartTextIndex(paragraphStartIndex);
          applicabilityBlock.setEndInsertIndex(paragraphEndIndex);
          applicabilityBlock.setEndTextIndex(paragraphEndIndex);
        }
      }
    }
 else {
      String findParagraphEnd=fullWordMl.substring(startInsertIndex);
      int paragraphEndIndex=findParagraphEnd.indexOf(WordCoreUtil.END_PARAGRAPH) + startInsertIndex + 6;
      if (paragraphStartIndex >= 0 && paragraphEndIndex >= 0 && paragraphEndIndex > paragraphStartIndex) {
        String fullParagraph=fullWordMl.substring(paragraphStartIndex,paragraphEndIndex);
        fullParagraph=fullParagraph.replaceFirst("String_Node_Str" + WordCoreUtil.BEGINFEATURE + "String_Node_Str"+ WordCoreUtil.BEGINCONFIG,"String_Node_Str");
        if (WordCoreUtil.textOnly(fullParagraph).isEmpty()) {
          toInsert=toInsert.replaceFirst(WordCoreUtil.WHOLE_END_PARAGRAPH,"String_Node_Str");
          applicabilityBlock.setStartInsertIndex(paragraphStartIndex);
          applicabilityBlock.setStartTextIndex(paragraphEndIndex);
        }
      }
    }
  }
  if (!applicabilityBlock.isInTable() && toInsert.matches("String_Node_Str")) {
    int origLength=toInsert.length();
    int lastParaIndex=toInsert.lastIndexOf(WordCoreUtil.START_PARAGRAPH);
    if (lastParaIndex >= 0) {
      toInsert=toInsert.substring(0,lastParaIndex);
      applicabilityBlock.setEndTextIndex(applicabilityBlock.getEndTextIndex() - (origLength - lastParaIndex));
      applicabilityBlock.setEndInsertIndex(applicabilityBlock.getEndInsertIndex() + WordCoreUtil.WHOLE_END_PARAGRAPH.length());
    }
  }
  return toInsert;
}

Fixed version (ground truth):
private String removeExtraParagraphs(String fullWordMl,String toInsert,ApplicabilityBlock applicabilityBlock){
  int startInsertIndex=applicabilityBlock.getStartInsertIndex();
  if (!applicabilityBlock.isInTable() && (toInsert.isEmpty() || toInsert.startsWith(WordCoreUtil.WHOLE_END_PARAGRAPH))) {
    String findParagraphStart=fullWordMl.substring(0,startInsertIndex);
    int paragraphStartIndex=findParagraphStart.lastIndexOf(WordCoreUtil.START_PARAGRAPH);
    String beginningText=fullWordMl.substring(paragraphStartIndex,startInsertIndex);
    if (toInsert.isEmpty() && paragraphStartIndex > 0 && !beginningText.matches("String_Node_Str" + WordCoreUtil.BEGINFEATURE + "String_Node_Str"+ WordCoreUtil.BEGINCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDFEATURE+ "String_Node_Str")) {
      int endInsertIndex=applicabilityBlock.getEndInsertIndex();
      String findParagraphEnd=fullWordMl.substring(endInsertIndex);
      int paragraphEndIndex=findParagraphEnd.indexOf(WordCoreUtil.END_PARAGRAPH) + endInsertIndex + 6;
      if (paragraphEndIndex >= 0) {
        String endText=fullWordMl.substring(endInsertIndex,paragraphEndIndex);
        if (paragraphEndIndex >= 0 && WordCoreUtil.textOnly(endText).isEmpty() && !endText.matches("String_Node_Str" + WordCoreUtil.BEGINFEATURE + "String_Node_Str"+ WordCoreUtil.BEGINCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDCONFIG+ "String_Node_Str"+ WordCoreUtil.ENDFEATURE+ "String_Node_Str")) {
          applicabilityBlock.setStartInsertIndex(paragraphStartIndex);
          applicabilityBlock.setStartTextIndex(paragraphStartIndex);
          applicabilityBlock.setEndInsertIndex(paragraphEndIndex);
          applicabilityBlock.setEndTextIndex(paragraphEndIndex);
        }
      }
    }
 else {
      String findParagraphEnd=fullWordMl.substring(startInsertIndex);
      int paragraphEndIndex=findParagraphEnd.indexOf(WordCoreUtil.END_PARAGRAPH) + startInsertIndex + 6;
      if (paragraphStartIndex >= 0 && paragraphEndIndex >= 0 && paragraphEndIndex > paragraphStartIndex) {
        String fullParagraph=fullWordMl.substring(paragraphStartIndex,paragraphEndIndex);
        fullParagraph=fullParagraph.replaceFirst("String_Node_Str" + WordCoreUtil.BEGINFEATURE + "String_Node_Str"+ WordCoreUtil.BEGINCONFIG,"String_Node_Str");
        if (WordCoreUtil.textOnly(fullParagraph).isEmpty()) {
          toInsert=toInsert.replaceFirst(WordCoreUtil.WHOLE_END_PARAGRAPH,"String_Node_Str");
          applicabilityBlock.setStartInsertIndex(paragraphStartIndex);
          applicabilityBlock.setStartTextIndex(paragraphEndIndex);
        }
      }
    }
  }
  if (!applicabilityBlock.isInTable() && toInsert.matches("String_Node_Str")) {
    int origLength=toInsert.length();
    int lastParaIndex=toInsert.lastIndexOf(WordCoreUtil.START_PARAGRAPH);
    if (lastParaIndex >= 0) {
      toInsert=toInsert.substring(0,lastParaIndex);
      applicabilityBlock.setEndTextIndex(applicabilityBlock.getEndTextIndex() - (origLength - lastParaIndex));
      applicabilityBlock.setEndInsertIndex(applicabilityBlock.getEndInsertIndex() + WordCoreUtil.WHOLE_END_PARAGRAPH.length());
    }
  }
  return toInsert;
}