Program: 32627
Project: 32627
Buggy source:
/** 
 * @param parent the subtree to insert into, must not be null.
 * @param color a bitmask value such as 1, 2, 4, 8, 16, 32, 64 or 128.
 * @param value the object to hold in the inserted node.
 * @param size the size of the inserted node, with respect to indices.
 * @return the inserted node, or the modified node if this insert simplyincreased the size of an existing node.
 */
private FourColorNode<V> insertIntoSubtreeInSortedOrder(FourColorNode<V> parent,byte color,V value,int size){
  while (true) {
    assert(parent != null);
    int sortSide;
    for (FourColorNode<V> currentFollower=parent; true; currentFollower=next(currentFollower)) {
      if (currentFollower == null) {
        sortSide=-1;
        break;
      }
 else       if (currentFollower.sorted) {
        sortSide=comparator.compare(value,currentFollower.value);
        break;
      }
    }
    if (sortSide == 0 && color == parent.color && value == parent.value && value != null) {
      parent.size+=size;
      fixCountsThruRoot(parent,color,size);
      return parent;
    }
    boolean insertOnLeft=false;
    insertOnLeft=insertOnLeft || sortSide < 0;
    insertOnLeft=insertOnLeft || sortSide == 0 && parent.left == null;
    insertOnLeft=insertOnLeft || sortSide == 0 && parent.right != null && parent.left.height < parent.right.height;
    if (insertOnLeft) {
      FourColorNode<V> parentLeft=parent.left;
      if (parentLeft == null) {
        FourColorNode<V> inserted=new FourColorNode<V>(color,size,value,parent);
        parent.left=inserted;
        fixCountsThruRoot(parent,color,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentLeft;
        continue;
      }
    }
 else {
      FourColorNode<V> parentRight=parent.right;
      if (parentRight == null) {
        FourColorNode<V> inserted=new FourColorNode<V>(color,size,value,parent);
        parent.right=inserted;
        fixCountsThruRoot(parent,color,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentRight;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param parent the subtree to insert into, must not be null.
 * @param color a bitmask value such as 1, 2, 4, 8, 16, 32, 64 or 128.
 * @param value the object to hold in the inserted node.
 * @param size the size of the inserted node, with respect to indices.
 * @return the inserted node, or the modified node if this insert simplyincreased the size of an existing node.
 */
private FourColorNode<V> insertIntoSubtreeInSortedOrder(FourColorNode<V> parent,byte color,V value,int size){
  while (true) {
    assert(parent != null);
    int sortSide;
    for (FourColorNode<V> currentFollower=parent; true; currentFollower=next(currentFollower)) {
      if (currentFollower == null) {
        sortSide=-1;
        break;
      }
 else       if (currentFollower.sorted == Element.SORTED) {
        sortSide=comparator.compare(value,currentFollower.value);
        break;
      }
    }
    if (sortSide == 0 && color == parent.color && value == parent.value && value != null) {
      parent.size+=size;
      fixCountsThruRoot(parent,color,size);
      return parent;
    }
    boolean insertOnLeft=false;
    insertOnLeft=insertOnLeft || sortSide < 0;
    insertOnLeft=insertOnLeft || sortSide == 0 && parent.left == null;
    insertOnLeft=insertOnLeft || sortSide == 0 && parent.right != null && parent.left.height < parent.right.height;
    if (insertOnLeft) {
      FourColorNode<V> parentLeft=parent.left;
      if (parentLeft == null) {
        FourColorNode<V> inserted=new FourColorNode<V>(color,size,value,parent);
        parent.left=inserted;
        fixCountsThruRoot(parent,color,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentLeft;
        continue;
      }
    }
 else {
      FourColorNode<V> parentRight=parent.right;
      if (parentRight == null) {
        FourColorNode<V> inserted=new FourColorNode<V>(color,size,value,parent);
        parent.right=inserted;
        fixCountsThruRoot(parent,color,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentRight;
      }
    }
  }
}