Program: 32738
Project: 32738
Buggy source:
/** 
 * Sorts the blocks of the specified list of changes. This ensures that the user iterating the list of change blocks can view changes in increasing order. This ensures that indicies will not be shifted. <p>This performs a bubble sort, swapping adjacent change blocks if they should be swapped. The bubble sort is used instead of a more efficient sort because it is necessary to adjust offsets when swapping and therefore it is preferred to only swap adjacent elements. Bubble sort is a sort that only swaps adjacent elements.
 * @param allowContradictingEvents whether a pair of contradicting events shallbe allowed. This would typically be an insert that is wiped away with a delete, an update that is wiped away with a delete, or an insert that is later updated.
 */
static void sortListEventBlocks(List changes,boolean allowContradictingEvents){
  while (true) {
    int swapCount=0;
    int j=0;
    while (j < changes.size() - 1) {
      ListEventBlock first=(ListEventBlock)changes.get(j);
      ListEventBlock second=(ListEventBlock)changes.get(j + 1);
      if (requiresSplit(first,second)) {
        ListEventBlock third=split(first,second);
        changes.add(j + 2,third);
      }
 else       if (canBeCombined(first,second)) {
        combine(first,second);
        changes.remove(j + 1);
        if (j > 0)         j--;
      }
 else       if (requiresSwap(first,second)) {
        swapCount++;
        shift(first,second);
        changes.set(j,second);
        changes.set(j + 1,first);
        j++;
      }
 else {
        j++;
      }
    }
    if (swapCount == 0)     break;
  }
}

Fixed version (ground truth):
/** 
 * Sorts the blocks of the specified list of changes. This ensures that the user iterating the list of change blocks can view changes in increasing order. This ensures that indicies will not be shifted. <p>This performs a bubble sort, swapping adjacent change blocks if they should be swapped. The bubble sort is used instead of a more efficient sort because it is necessary to adjust offsets when swapping and therefore it is preferred to only swap adjacent elements. Bubble sort is a sort that only swaps adjacent elements.
 * @param allowContradictingEvents whether a pair of contradicting events shallbe allowed. This would typically be an insert that is wiped away with a delete, an update that is wiped away with a delete, or an insert that is later updated.
 */
static void sortListEventBlocks(List changes,boolean allowContradictingEvents){
  while (true) {
    int swapCount=0;
    int j=0;
    while (j < changes.size() - 1) {
      ListEventBlock first=(ListEventBlock)changes.get(j);
      ListEventBlock second=(ListEventBlock)changes.get(j + 1);
      if (blocksContradict(first,second)) {
        if (!allowContradictingEvents)         throw new IllegalStateException("String_Node_Str" + first + "String_Node_Str"+ second+ "String_Node_Str");
        simplifyContradiction(changes.subList(j,j + 2));
      }
 else       if (requiresSplit(first,second)) {
        ListEventBlock third=split(first,second);
        changes.add(j + 2,third);
      }
 else       if (canBeCombined(first,second)) {
        combine(first,second);
        changes.remove(j + 1);
        if (j > 0)         j--;
      }
 else       if (requiresSwap(first,second)) {
        swapCount++;
        shift(first,second);
        changes.set(j,second);
        changes.set(j + 1,first);
        j++;
      }
 else {
        j++;
      }
    }
    if (swapCount == 0)     break;
  }
}