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