Program: 32629
Project: 32629
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 SimpleNode<V> insertIntoSubtreeInSortedOrder(SimpleNode<V> parent,V value,int size){
  while (true) {
    assert(parent != null);
    int sortSide;
    for (SimpleNode<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 (false && sortSide == 0 && value == parent.value && value != null) {
      fixCountsThruRoot(parent,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) {
      SimpleNode<V> parentLeft=parent.left;
      if (parentLeft == null) {
        SimpleNode<V> inserted=new SimpleNode<V>(size,value,parent);
        parent.left=inserted;
        fixCountsThruRoot(parent,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentLeft;
        continue;
      }
    }
 else {
      SimpleNode<V> parentRight=parent.right;
      if (parentRight == null) {
        SimpleNode<V> inserted=new SimpleNode<V>(size,value,parent);
        parent.right=inserted;
        fixCountsThruRoot(parent,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 SimpleNode<V> insertIntoSubtreeInSortedOrder(SimpleNode<V> parent,V value,int size){
  while (true) {
    assert(parent != null);
    int sortSide;
    for (SimpleNode<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 (false && sortSide == 0 && value == parent.value && value != null) {
      fixCountsThruRoot(parent,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) {
      SimpleNode<V> parentLeft=parent.left;
      if (parentLeft == null) {
        SimpleNode<V> inserted=new SimpleNode<V>(size,value,parent);
        parent.left=inserted;
        fixCountsThruRoot(parent,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentLeft;
        continue;
      }
    }
 else {
      SimpleNode<V> parentRight=parent.right;
      if (parentRight == null) {
        SimpleNode<V> inserted=new SimpleNode<V>(size,value,parent);
        parent.right=inserted;
        fixCountsThruRoot(parent,size);
        fixHeightPostChange(parent,false);
        return inserted;
      }
 else {
        parent=parentRight;
      }
    }
  }
}