nus-yam/ex-repair huggingface dataset:
Program: 90251
Project: 90251
Buggy source:
@Setup public void setup() throws Exception {
  ZipRealDataRetriever dataRetriever=new ZipRealDataRetriever(dataset);
  System.out.println();
  System.out.println("String_Node_Str" + dataRetriever.getName());
  ArrayList<MutableRoaringBitmap> tmpac=new ArrayList<MutableRoaringBitmap>();
  ArrayList<MutableRoaringBitmap> tmprc=new ArrayList<MutableRoaringBitmap>();
  ArrayList<ConciseSet> tmpcc=new ArrayList<ConciseSet>();
  ArrayList<EWAHCompressedBitmap> tmpewah=new ArrayList<EWAHCompressedBitmap>();
  ArrayList<EWAHCompressedBitmap32> tmpewah32=new ArrayList<EWAHCompressedBitmap32>();
  for (  int[] data : dataRetriever.fetchBitPositions()) {
    MutableRoaringBitmap mbasic=MutableRoaringBitmap.bitmapOf(data);
    MutableRoaringBitmap mopti=mbasic.clone();
    mopti.runOptimize();
    ConciseSet concise=toConcise(data);
    tmpac.add(mbasic);
    tmprc.add(mopti);
    tmpcc.add(concise);
    tmpewah.add(EWAHCompressedBitmap.bitmapOf(data));
    tmpewah32.add(EWAHCompressedBitmap32.bitmapOf(data));
  }
  mrc=convertToImmutableRoaring(tmprc);
  mac=convertToImmutableRoaring(tmpac);
  cc=convertToImmutableConcise(tmpcc);
  if ((mrc.size() != mac.size()) || (mac.size() != cc.size()))   throw new RuntimeException("String_Node_Str");
  expectedvalue=0;
  for (int k=0; k < mrc.size(); ++k) {
    ImmutableRoaringBitmap rb=mrc.get(k);
    org.roaringbitmap.IntIterator i=rb.getIntIterator();
    while (i.hasNext())     expectedvalue+=i.next();
  }
}

Fixed version (ground truth):
@Setup public void setup() throws Exception {
  ZipRealDataRetriever dataRetriever=new ZipRealDataRetriever(dataset);
  System.out.println();
  System.out.println("String_Node_Str" + dataRetriever.getName());
  ArrayList<MutableRoaringBitmap> tmpac=new ArrayList<MutableRoaringBitmap>();
  ArrayList<MutableRoaringBitmap> tmprc=new ArrayList<MutableRoaringBitmap>();
  ArrayList<ConciseSet> tmpcc=new ArrayList<ConciseSet>();
  ArrayList<EWAHCompressedBitmap> tmpewah=new ArrayList<EWAHCompressedBitmap>();
  ArrayList<EWAHCompressedBitmap32> tmpewah32=new ArrayList<EWAHCompressedBitmap32>();
  for (  int[] data : dataRetriever.fetchBitPositions()) {
    MutableRoaringBitmap mbasic=MutableRoaringBitmap.bitmapOf(data);
    MutableRoaringBitmap mopti=mbasic.clone();
    mopti.runOptimize();
    ConciseSet concise=toConcise(data);
    tmpac.add(mbasic);
    tmprc.add(mopti);
    tmpcc.add(concise);
    tmpewah.add(EWAHCompressedBitmap.bitmapOf(data));
    tmpewah32.add(EWAHCompressedBitmap32.bitmapOf(data));
  }
  mrc=convertToImmutableRoaring(tmprc);
  mac=convertToImmutableRoaring(tmpac);
  cc=convertToImmutableConcise(tmpcc);
  ewah=convertToImmutableEWAH(tmpewah);
  ewah32=convertToImmutableEWAH32(tmpewah32);
  if ((mrc.size() != mac.size()) || (mac.size() != cc.size()))   throw new RuntimeException("String_Node_Str");
  expectedvalue=0;
  for (int k=0; k < mrc.size(); ++k) {
    ImmutableRoaringBitmap rb=mrc.get(k);
    org.roaringbitmap.IntIterator i=rb.getIntIterator();
    while (i.hasNext())     expectedvalue+=i.next();
  }
}
Program: 90252
Project: 90252
Buggy source:
@Benchmark public int pairwiseOr_EWAH(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah.size(); ++k)   total+=benchmarkState.ewah.get(k).or(benchmarkState.ewah.get(k + 1)).cardinality();
  return total;
}

Fixed version (ground truth):
@Benchmark public int pairwiseOr_EWAH(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah.size(); ++k)   total+=benchmarkState.ewah.get(k).or(benchmarkState.ewah.get(k + 1)).cardinality();
  if (total != benchmarkState.expectedvalue)   throw new RuntimeException("String_Node_Str");
  return total;
}
Program: 90253
Project: 90253
Buggy source:
@Benchmark public int pairwiseOr_EWAH32(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah32.size(); ++k)   total+=benchmarkState.ewah32.get(k).or(benchmarkState.ewah32.get(k + 1)).cardinality();
  return total;
}

Fixed version (ground truth):
@Benchmark public int pairwiseOr_EWAH32(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah32.size(); ++k)   total+=benchmarkState.ewah32.get(k).or(benchmarkState.ewah32.get(k + 1)).cardinality();
  if (total != benchmarkState.expectedvalue)   throw new RuntimeException("String_Node_Str");
  return total;
}
Program: 90254
Project: 90254
Buggy source:
@Benchmark public int pairwiseAnd_EWAH(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah.size(); ++k)   total+=EWAHCompressedBitmap.and(benchmarkState.ewah.get(k),benchmarkState.ewah.get(k + 1)).cardinality();
  if (total != benchmarkState.totaland)   throw new RuntimeException("String_Node_Str");
  return total;
}

Fixed version (ground truth):
@Benchmark public int pairwiseAnd_EWAH(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah.size(); ++k)   total+=benchmarkState.ewah.get(k).and(benchmarkState.ewah.get(k + 1)).cardinality();
  if (total != benchmarkState.totaland)   throw new RuntimeException("String_Node_Str");
  return total;
}
Program: 90255
Project: 90255
Buggy source:
@Benchmark public int pairwiseAnd_EWAH32(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah32.size(); ++k)   total+=EWAHCompressedBitmap32.and(benchmarkState.ewah32.get(k),benchmarkState.ewah32.get(k + 1)).cardinality();
  if (total != benchmarkState.totaland)   throw new RuntimeException("String_Node_Str");
  return total;
}

Fixed version (ground truth):
@Benchmark public int pairwiseAnd_EWAH32(BenchmarkState benchmarkState){
  int total=0;
  for (int k=0; k + 1 < benchmarkState.ewah32.size(); ++k)   total+=benchmarkState.ewah32.get(k).and(benchmarkState.ewah32.get(k + 1)).cardinality();
  if (total != benchmarkState.totaland)   throw new RuntimeException("String_Node_Str");
  return total;
}
Program: 90257
Project: 90257
Buggy source:
@Benchmark public int horizontalOr_EWAH32(BenchmarkState benchmarkState){
  EWAHCompressedBitmap32 bitmapor=benchmarkState.ewah32.get(0);
  for (int j=1; j < benchmarkState.ewah32.size(); ++j) {
    bitmapor=bitmapor.or(benchmarkState.ewah32.get(j));
  }
  int answer=bitmapor.cardinality();
  if (answer != benchmarkState.horizontalor)   throw new RuntimeException("String_Node_Str");
  return answer;
}

Fixed version (ground truth):
@Benchmark public int horizontalOr_EWAH32(BenchmarkState benchmarkState){
  EWAHCompressedBitmap32[] a=new EWAHCompressedBitmap32[benchmarkState.ewah32.size()];
  EWAHCompressedBitmap32 bitmapor=EWAHCompressedBitmap32.or(benchmarkState.ewah32.toArray(a));
  int answer=bitmapor.cardinality();
  if (answer != benchmarkState.horizontalor)   throw new RuntimeException("String_Node_Str");
  return answer;
}
Program: 90258
Project: 90258
Buggy source:
private void smartAppendExclusive(short start,short length){
  int oldend;
  if ((nbrruns == 0) || (Util.toIntUnsigned(start) > (oldend=Util.toIntUnsigned(getValue(nbrruns - 1)) + Util.toIntUnsigned(getLength(nbrruns - 1)) + 1))) {
    valueslength[2 * nbrruns]=start;
    valueslength[2 * nbrruns + 1]=length;
    nbrruns++;
    return;
  }
  int newend=Util.toIntUnsigned(start) + Util.toIntUnsigned(length) + 1;
  if (Util.toIntUnsigned(start) == Util.toIntUnsigned(getValue(nbrruns - 1))) {
    if (newend != oldend) {
      int m=Math.min(newend,oldend);
      int M=Math.max(newend,oldend);
      setValue(nbrruns - 1,(short)m);
      setLength(nbrruns - 1,(short)(M - m - 1));
      return;
    }
 else {
      nbrruns--;
      return;
    }
  }
  setLength(nbrruns - 1,(short)(start - Util.toIntUnsigned(getValue(nbrruns - 1)) - 1));
  if (newend != oldend) {
    int m=Math.min(newend,oldend);
    int M=Math.max(newend,oldend);
    setValue(nbrruns,(short)m);
    setLength(nbrruns,(short)(M - m - 1));
    nbrruns++;
  }
}

Fixed version (ground truth):
private void smartAppendExclusive(short start,short length){
  int oldend;
  if ((nbrruns == 0) || (Util.toIntUnsigned(start) > (oldend=Util.toIntUnsigned(getValue(nbrruns - 1)) + Util.toIntUnsigned(getLength(nbrruns - 1)) + 1))) {
    valueslength[2 * nbrruns]=start;
    valueslength[2 * nbrruns + 1]=length;
    nbrruns++;
    return;
  }
  if (oldend == Util.toIntUnsigned(start)) {
    valueslength[2 * (nbrruns - 1) + 1]+=length + 1;
    return;
  }
  int newend=Util.toIntUnsigned(start) + Util.toIntUnsigned(length) + 1;
  if (Util.toIntUnsigned(start) == Util.toIntUnsigned(getValue(nbrruns - 1))) {
    if (newend != oldend) {
      int m=Math.min(newend,oldend);
      int M=Math.max(newend,oldend);
      setValue(nbrruns - 1,(short)m);
      setLength(nbrruns - 1,(short)(M - m - 1));
      return;
    }
 else {
      nbrruns--;
      return;
    }
  }
  setLength(nbrruns - 1,(short)(start - Util.toIntUnsigned(getValue(nbrruns - 1)) - 1));
  if (newend != oldend) {
    int m=Math.min(newend,oldend);
    int M=Math.max(newend,oldend);
    setValue(nbrruns,(short)m);
    setLength(nbrruns,(short)(M - m - 1));
    nbrruns++;
  }
}
Program: 90259
Project: 90259
Buggy source:
private void smartAppendExclusive(short[] vl,short val){
  int oldend;
  if ((nbrruns == 0) || (BufferUtil.toIntUnsigned(val) > (oldend=BufferUtil.toIntUnsigned(getValue(nbrruns - 1)) + BufferUtil.toIntUnsigned(getLength(nbrruns - 1)) + 1))) {
    vl[2 * nbrruns]=val;
    vl[2 * nbrruns + 1]=0;
    nbrruns++;
    return;
  }
  int newend=BufferUtil.toIntUnsigned(val) + 1;
  if (BufferUtil.toIntUnsigned(val) == BufferUtil.toIntUnsigned(getValue(nbrruns - 1))) {
    if (newend != oldend) {
      setValue(nbrruns - 1,(short)newend);
      setLength(nbrruns - 1,(short)(oldend - newend - 1));
      return;
    }
 else {
      nbrruns--;
      return;
    }
  }
  setLength(nbrruns - 1,(short)(val - BufferUtil.toIntUnsigned(getValue(nbrruns - 1)) - 1));
  if (newend != oldend) {
    setValue(nbrruns,(short)newend);
    setLength(nbrruns,(short)(oldend - newend - 1));
    nbrruns++;
  }
}

Fixed version (ground truth):
private void smartAppendExclusive(short[] vl,short val){
  int oldend;
  if ((nbrruns == 0) || (BufferUtil.toIntUnsigned(val) > (oldend=BufferUtil.toIntUnsigned(getValue(nbrruns - 1)) + BufferUtil.toIntUnsigned(getLength(nbrruns - 1)) + 1))) {
    vl[2 * nbrruns]=val;
    vl[2 * nbrruns + 1]=0;
    nbrruns++;
    return;
  }
  if (oldend == BufferUtil.toIntUnsigned(val)) {
    vl[2 * (nbrruns - 1) + 1]++;
    return;
  }
  int newend=BufferUtil.toIntUnsigned(val) + 1;
  if (BufferUtil.toIntUnsigned(val) == BufferUtil.toIntUnsigned(getValue(nbrruns - 1))) {
    if (newend != oldend) {
      setValue(nbrruns - 1,(short)newend);
      setLength(nbrruns - 1,(short)(oldend - newend - 1));
      return;
    }
 else {
      nbrruns--;
      return;
    }
  }
  setLength(nbrruns - 1,(short)(val - BufferUtil.toIntUnsigned(getValue(nbrruns - 1)) - 1));
  if (newend < oldend) {
    setValue(nbrruns,(short)newend);
    setLength(nbrruns,(short)(oldend - newend - 1));
    nbrruns++;
  }
 else   if (oldend < newend) {
    setValue(nbrruns,(short)oldend);
    setLength(nbrruns,(short)(newend - oldend - 1));
    nbrruns++;
  }
}
Program: 90260
Project: 90260
Buggy source:
/** 
 * Sort the bitmap prior to using the and aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static RoaringBitmap and(Iterator<RoaringBitmap> bitmaps){
  if (!bitmaps.hasNext())   return new RoaringBitmap();
  ArrayList<RoaringBitmap> array=new ArrayList<RoaringBitmap>();
  while (bitmaps.hasNext())   array.add(bitmaps.next());
  Collections.sort(array,new Comparator<RoaringBitmap>(){
    @Override public int compare(    RoaringBitmap a,    RoaringBitmap b){
      return a.getSizeInBytes() - b.getSizeInBytes();
    }
  }
);
  RoaringBitmap answer=RoaringBitmap.and(array.get(0),array.get(1));
  for (int k=2; k < array.size(); ++k)   answer.and(array.get(k));
  return answer;
}

Fixed version (ground truth):
/** 
 * Sort the bitmap prior to using the and aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static RoaringBitmap and(Iterator<RoaringBitmap> bitmaps){
  if (!bitmaps.hasNext())   return new RoaringBitmap();
  ArrayList<RoaringBitmap> array=new ArrayList<RoaringBitmap>();
  while (bitmaps.hasNext())   array.add(bitmaps.next());
  if (array.size() == 1)   return array.get(0);
  Collections.sort(array,new Comparator<RoaringBitmap>(){
    @Override public int compare(    RoaringBitmap a,    RoaringBitmap b){
      return a.getSizeInBytes() - b.getSizeInBytes();
    }
  }
);
  RoaringBitmap answer=RoaringBitmap.and(array.get(0),array.get(1));
  for (int k=2; k < array.size(); ++k)   answer.and(array.get(k));
  return answer;
}
Program: 90262
Project: 90262
Buggy source:
/** 
 * Look value value k in array in the range [begin,end). If the value is found, return its index. If not, return -(i+1) where i is the index where the value would be inserted.  The array is assumed to contain sorted values where shorts are interpreted as unsigned integers.
 * @param array array where we search
 * @param begin first index (inclusive)
 * @param end last index (exclusive)
 * @param k value we search for
 * @return
 */
public static int unsignedBinarySearch(final short[] array,final int begin,final int end,final short k){
  int ikey=toIntUnsigned(k);
  if ((end > 0) && (toIntUnsigned(array[end - 1]) < ikey))   return -end - 1;
  int low=begin;
  int high=end - 1;
  while (low <= high) {
    final int middleIndex=(low + high) >>> 1;
    final int middleValue=toIntUnsigned(array[middleIndex]);
    if (middleValue < ikey)     low=middleIndex + 1;
 else     if (middleValue > ikey)     high=middleIndex - 1;
 else     return middleIndex;
  }
  return -(low + 1);
}

Fixed version (ground truth):
/** 
 * Look value value k in array in the range [begin,end). If the value is found, return its index. If not, return -(i+1) where i is the index where the value would be inserted.  The array is assumed to contain sorted values where shorts are interpreted as unsigned integers.
 * @param array array where we search
 * @param begin first index (inclusive)
 * @param end last index (exclusive)
 * @param k value we search for
 * @return count
 */
public static int unsignedBinarySearch(final short[] array,final int begin,final int end,final short k){
  int ikey=toIntUnsigned(k);
  if ((end > 0) && (toIntUnsigned(array[end - 1]) < ikey))   return -end - 1;
  int low=begin;
  int high=end - 1;
  while (low <= high) {
    final int middleIndex=(low + high) >>> 1;
    final int middleValue=toIntUnsigned(array[middleIndex]);
    if (middleValue < ikey)     low=middleIndex + 1;
 else     if (middleValue > ikey)     high=middleIndex - 1;
 else     return middleIndex;
  }
  return -(low + 1);
}
Program: 90264
Project: 90264
Buggy source:
/** 
 * In-place bitwise OR (union) operation. The current bitmap is modified.
 * @param x2 other bitmap
 */
public void or(final ImmutableRoaringBitmap x2){
  int pos1=0, pos2=0;
  int length1=highLowContainer.size();
  final int length2=x2.highLowContainer.size();
  main:   if (pos1 < length1 && pos2 < length2) {
    short s1=highLowContainer.getKeyAtIndex(pos1);
    short s2=x2.highLowContainer.getKeyAtIndex(pos2);
    while (true) {
      if (s1 == s2) {
        getMappeableRoaringArray().setContainerAtIndex(pos1,highLowContainer.getContainerAtIndex(pos1).ior(x2.highLowContainer.getContainerAtIndex(pos2)));
        pos1++;
        pos2++;
        if ((pos1 == length1) || (pos2 == length2)) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
 else       if (Util.compareUnsigned(s1,s2) < 0) {
        pos1++;
        if (pos1 == length1) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
      }
 else {
        getMappeableRoaringArray().insertNewKeyValueAt(pos1,(short)s2,x2.highLowContainer.getContainerAtIndex(pos2));
        pos1++;
        length1++;
        pos2++;
        if (pos2 == length2) {
          break main;
        }
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
    }
  }
  if (pos1 == length1) {
    getMappeableRoaringArray().appendCopy(x2.highLowContainer,pos2,length2);
  }
}

Fixed version (ground truth):
/** 
 * In-place bitwise OR (union) operation. The current bitmap is modified.
 * @param x2 other bitmap
 */
public void or(final ImmutableRoaringBitmap x2){
  int pos1=0, pos2=0;
  int length1=highLowContainer.size();
  final int length2=x2.highLowContainer.size();
  main:   if (pos1 < length1 && pos2 < length2) {
    short s1=highLowContainer.getKeyAtIndex(pos1);
    short s2=x2.highLowContainer.getKeyAtIndex(pos2);
    while (true) {
      if (s1 == s2) {
        getMappeableRoaringArray().setContainerAtIndex(pos1,highLowContainer.getContainerAtIndex(pos1).ior(x2.highLowContainer.getContainerAtIndex(pos2)));
        pos1++;
        pos2++;
        if ((pos1 == length1) || (pos2 == length2)) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
 else       if (Util.compareUnsigned(s1,s2) < 0) {
        pos1++;
        if (pos1 == length1) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
      }
 else {
        getMappeableRoaringArray().insertNewKeyValueAt(pos1,(short)s2,x2.highLowContainer.getContainerAtIndex(pos2).clone());
        pos1++;
        length1++;
        pos2++;
        if (pos2 == length2) {
          break main;
        }
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
    }
  }
  if (pos1 == length1) {
    getMappeableRoaringArray().appendCopy(x2.highLowContainer,pos2,length2);
  }
}
Program: 90266
Project: 90266
Buggy source:
int numberOfRunsAdjustment(){
  int ans=0;
  long nextWord=bitmap[0];
  for (int i=0; i < bitmap.length - 1; i++) {
    final long word=nextWord;
    nextWord=bitmap[i + 1];
    ans+=((word >>> 63) & ~nextWord);
  }
  final long word=nextWord;
  if ((word & 0x8000000000000000L) != 0)   ans++;
  return ans;
}

Fixed version (ground truth):
/** 
 * Computes the number of runs
 * @return the number of runs
 */
public int numberOfRunsAdjustment(){
  int ans=0;
  long nextWord=bitmap[0];
  for (int i=0; i < bitmap.length - 1; i++) {
    final long word=nextWord;
    nextWord=bitmap[i + 1];
    ans+=((word >>> 63) & ~nextWord);
  }
  final long word=nextWord;
  if ((word & 0x8000000000000000L) != 0)   ans++;
  return ans;
}
Program: 90267
Project: 90267
Buggy source:
int numberOfRunsLowerBound(int mustNotExceed){
  int numRuns=0;
  for (int blockOffset=0; blockOffset < bitmap.length; blockOffset+=BLOCKSIZE) {
    for (int i=blockOffset; i < blockOffset + BLOCKSIZE; i++) {
      long word=bitmap[i];
      numRuns+=Long.bitCount((~word) & (word << 1));
    }
    if (numRuns > mustNotExceed)     return numRuns;
  }
  return numRuns;
}

Fixed version (ground truth):
/** 
 * Counts how many runs there is in the bitmap, up to a maximum
 * @param mustNotExceed maximum of runs beyond which counting is pointless
 * @return estimated number of courses
 */
public int numberOfRunsLowerBound(int mustNotExceed){
  int numRuns=0;
  for (int blockOffset=0; blockOffset < bitmap.length; blockOffset+=BLOCKSIZE) {
    for (int i=blockOffset; i < blockOffset + BLOCKSIZE; i++) {
      long word=bitmap[i];
      numRuns+=Long.bitCount((~word) & (word << 1));
    }
    if (numRuns > mustNotExceed)     return numRuns;
  }
  return numRuns;
}
Program: 90270
Project: 90270
Buggy source:
@Override public MappeableContainer add(int begin,int end){
  int indexstart=BufferUtil.unsignedBinarySearch(content,0,cardinality,(short)begin);
  if (indexstart < 0)   indexstart=-indexstart - 1;
  int indexend=BufferUtil.unsignedBinarySearch(content,0,cardinality,(short)(end - 1));
  if (indexend < 0)   indexend=-indexend - 1;
 else   indexend++;
  int rangelength=end - begin;
  int newcardinality=indexstart + (cardinality - indexend) + rangelength;
  if (newcardinality > DEFAULT_MAX_SIZE) {
    MappeableBitmapContainer a=this.toBitmapContainer();
    return a.iadd(begin,end);
  }
  MappeableArrayContainer answer=new MappeableArrayContainer(newcardinality,content);
  BufferUtil.arraycopy(content,indexend,answer.content,indexstart + rangelength,cardinality - indexend);
  short[] answerarray=answer.content.array();
  for (int k=0; k < rangelength; ++k) {
    answerarray[k + indexstart]=(short)(begin + k);
  }
  answer.cardinality=newcardinality;
  return answer;
}

Fixed version (ground truth):
@Override public MappeableContainer add(int begin,int end){
  int indexstart=BufferUtil.unsignedBinarySearch(content,0,cardinality,(short)begin);
  if (indexstart < 0)   indexstart=-indexstart - 1;
  int indexend=BufferUtil.unsignedBinarySearch(content,0,cardinality,(short)(end - 1));
  if (indexend < 0)   indexend=-indexend - 1;
 else   indexend++;
  int rangelength=end - begin;
  int newcardinality=indexstart + (cardinality - indexend) + rangelength;
  if (newcardinality > DEFAULT_MAX_SIZE) {
    MappeableBitmapContainer a=this.toBitmapContainer();
    return a.iadd(begin,end);
  }
  MappeableArrayContainer answer=new MappeableArrayContainer(newcardinality,content);
  if (!BufferUtil.isBackedBySimpleArray(answer.content))   throw new RuntimeException("String_Node_Str");
  BufferUtil.arraycopy(content,indexend,answer.content,indexstart + rangelength,cardinality - indexend);
  short[] answerarray=answer.content.array();
  for (int k=0; k < rangelength; ++k) {
    answerarray[k + indexstart]=(short)(begin + k);
  }
  answer.cardinality=newcardinality;
  return answer;
}
Program: 90271
Project: 90271
Buggy source:
protected void loadData(final MappeableBitmapContainer bitmapContainer){
  this.cardinality=bitmapContainer.cardinality;
  bitmapContainer.fillArray(content.array());
}

Fixed version (ground truth):
protected void loadData(final MappeableBitmapContainer bitmapContainer){
  this.cardinality=bitmapContainer.cardinality;
  if (!BufferUtil.isBackedBySimpleArray(this.content))   throw new RuntimeException("String_Node_Str");
  bitmapContainer.fillArray(content.array());
}
Program: 90274
Project: 90274
Buggy source:
/** 
 * In-place bitwise OR (union) operation. The current bitmap is modified.
 * @param x2 other bitmap
 */
public void or(final ImmutableRoaringBitmap x2){
  int pos1=0, pos2=0;
  int length1=highLowContainer.size();
  final int length2=x2.highLowContainer.size();
  main:   if (pos1 < length1 && pos2 < length2) {
    short s1=highLowContainer.getKeyAtIndex(pos1);
    short s2=x2.highLowContainer.getKeyAtIndex(pos2);
    while (true) {
      if (s1 == s2) {
        getMappeableRoaringArray().setContainerAtIndex(pos1,highLowContainer.getContainerAtIndex(pos1).ior(x2.highLowContainer.getContainerAtIndex(pos2)));
        pos1++;
        pos2++;
        if ((pos1 == length1) || (pos2 == length2)) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
 else       if (Util.compareUnsigned(s1,s2) < 0) {
        pos1++;
        if (pos1 == length1) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
      }
 else {
        getMappeableRoaringArray().insertNewKeyValueAt(pos1,(short)s2,x2.highLowContainer.getContainerAtIndex(pos2));
        pos1++;
        length1++;
        pos2++;
        if (pos2 == length2) {
          break main;
        }
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
    }
  }
  if (pos1 == length1) {
    getMappeableRoaringArray().appendCopy(x2.highLowContainer,pos2,length2);
  }
}

Fixed version (ground truth):
/** 
 * In-place bitwise OR (union) operation. The current bitmap is modified.
 * @param x2 other bitmap
 */
public void or(final ImmutableRoaringBitmap x2){
  int pos1=0, pos2=0;
  int length1=highLowContainer.size();
  final int length2=x2.highLowContainer.size();
  main:   if (pos1 < length1 && pos2 < length2) {
    short s1=highLowContainer.getKeyAtIndex(pos1);
    short s2=x2.highLowContainer.getKeyAtIndex(pos2);
    while (true) {
      if (s1 == s2) {
        getMappeableRoaringArray().setContainerAtIndex(pos1,highLowContainer.getContainerAtIndex(pos1).ior(x2.highLowContainer.getContainerAtIndex(pos2)));
        pos1++;
        pos2++;
        if ((pos1 == length1) || (pos2 == length2)) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
 else       if (Util.compareUnsigned(s1,s2) < 0) {
        pos1++;
        if (pos1 == length1) {
          break main;
        }
        s1=highLowContainer.getKeyAtIndex(pos1);
      }
 else {
        getMappeableRoaringArray().insertNewKeyValueAt(pos1,(short)s2,x2.highLowContainer.getContainerAtIndex(pos2).clone());
        pos1++;
        length1++;
        pos2++;
        if (pos2 == length2) {
          break main;
        }
        s2=x2.highLowContainer.getKeyAtIndex(pos2);
      }
    }
  }
  if (pos1 == length1) {
    getMappeableRoaringArray().appendCopy(x2.highLowContainer,pos2,length2);
  }
}
Program: 90275
Project: 90275
Buggy source:
@Override public boolean equals(Object o){
  if (o instanceof ImmutableRoaringArray) {
    final ImmutableRoaringArray srb=(ImmutableRoaringArray)o;
    return srb.buffer.equals(this.buffer);
  }
  if (o instanceof MutableRoaringArray) {
    final MutableRoaringArray srb=(MutableRoaringArray)o;
    MappeableContainerPointer cp1=srb.getContainerPointer();
    MappeableContainerPointer cp2=srb.getContainerPointer();
    while (cp1.hasContainer()) {
      if (!cp2.hasContainer())       return false;
      if (cp1.key() != cp2.key())       return false;
      if (cp1.getCardinality() != cp2.getCardinality())       return false;
      if (!cp1.getContainer().equals(cp2.getContainer()))       return false;
      cp1.advance();
      cp2.advance();
    }
    if (cp2.hasContainer())     return false;
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (o instanceof ImmutableRoaringArray) {
    final ImmutableRoaringArray srb=(ImmutableRoaringArray)o;
    return srb.buffer.equals(this.buffer);
  }
  if (o instanceof MutableRoaringArray) {
    final MutableRoaringArray srb=(MutableRoaringArray)o;
    MappeableContainerPointer cp1=this.getContainerPointer();
    MappeableContainerPointer cp2=srb.getContainerPointer();
    while (cp1.hasContainer()) {
      if (!cp2.hasContainer())       return false;
      if (cp1.key() != cp2.key())       return false;
      if (cp1.getCardinality() != cp2.getCardinality())       return false;
      if (!cp1.getContainer().equals(cp2.getContainer()))       return false;
      cp1.advance();
      cp2.advance();
    }
    if (cp2.hasContainer())     return false;
    return true;
  }
  return false;
}
Program: 90278
Project: 90278
Buggy source:
/** 
 * Serialize. The current bitmap is not modified.
 * @param out the DataOutput stream
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void serialize(DataOutput out) throws IOException {
  int startOffset=0;
  if (hasRunContainer()) {
    System.out.println("String_Node_Str");
    out.writeInt(Integer.reverseBytes(SERIAL_COOKIE));
    out.writeInt(Integer.reverseBytes(size));
    System.out.println("String_Node_Str" + size);
    int[] bitmapOfRunContainers=new int[(size + 31) / 32];
    for (int i=0; i < size; ++i)     if (this.array[i].value instanceof RunContainer)     bitmapOfRunContainers[i / 32]|=(1 << (i % 32));
    for (int i=0; i < bitmapOfRunContainers.length; ++i)     out.writeInt(Integer.reverseBytes(bitmapOfRunContainers[i]));
    System.out.println("String_Node_Str" + bitmapOfRunContainers.length + "String_Node_Str");
    startOffset=4 + 4 + 4 * this.size + 4 * this.size + 4 * bitmapOfRunContainers.length;
  }
 else {
    System.out.println("String_Node_Str");
    out.writeInt(Integer.reverseBytes(SERIAL_COOKIE_NO_RUNCONTAINER));
    out.writeInt(Integer.reverseBytes(size));
    startOffset=4 + 4 + 4 * this.size + 4 * this.size;
  }
  for (int k=0; k < size; ++k) {
    out.writeShort(Short.reverseBytes(this.array[k].key));
    out.writeShort(Short.reverseBytes((short)((this.array[k].value.getCardinality() - 1))));
  }
  for (int k=0; k < this.size; k++) {
    out.writeInt(Integer.reverseBytes(startOffset));
    startOffset=startOffset + this.array[k].value.getArraySizeInBytes();
  }
  for (int k=0; k < size; ++k) {
    array[k].value.writeArray(out);
  }
}

Fixed version (ground truth):
/** 
 * Serialize. The current bitmap is not modified.
 * @param out the DataOutput stream
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void serialize(DataOutput out) throws IOException {
  int startOffset=0;
  if (hasRunContainer()) {
    out.writeInt(Integer.reverseBytes(SERIAL_COOKIE));
    out.writeInt(Integer.reverseBytes(size));
    int[] bitmapOfRunContainers=new int[(size + 31) / 32];
    for (int i=0; i < size; ++i)     if (this.array[i].value instanceof RunContainer)     bitmapOfRunContainers[i / 32]|=(1 << (i % 32));
    for (int i=0; i < bitmapOfRunContainers.length; ++i)     out.writeInt(Integer.reverseBytes(bitmapOfRunContainers[i]));
    startOffset=4 + 4 + 4 * this.size + 4 * this.size + 4 * bitmapOfRunContainers.length;
  }
 else {
    out.writeInt(Integer.reverseBytes(SERIAL_COOKIE_NO_RUNCONTAINER));
    out.writeInt(Integer.reverseBytes(size));
    startOffset=4 + 4 + 4 * this.size + 4 * this.size;
  }
  for (int k=0; k < size; ++k) {
    out.writeShort(Short.reverseBytes(this.array[k].key));
    out.writeShort(Short.reverseBytes((short)((this.array[k].value.getCardinality() - 1))));
  }
  for (int k=0; k < this.size; k++) {
    out.writeInt(Integer.reverseBytes(startOffset));
    startOffset=startOffset + this.array[k].value.getArraySizeInBytes();
  }
  for (int k=0; k < size; ++k) {
    array[k].value.writeArray(out);
  }
}
Program: 90279
Project: 90279
Buggy source:
public void iaddInvalidRange2(){
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void iaddInvalidRange2(){
  Container rc=new RunContainer();
  rc.iadd(0,1 << 20);
}
Program: 90280
Project: 90280
Buggy source:
/** 
 * Find the smallest integer index larger than pos such that array[index].key&gt;=x. If none can be found, return size. Based on code by O. Kaser.
 * @param x minimal value
 * @param pos index to exceed
 * @return the smallest index greater than pos such that array[index].key is at least as largeas min, or size if it is not possible.
 */
protected int advanceUntil(short x,int pos){
  int lower=pos + 1;
  if (lower >= size || Util.toIntUnsigned(array[lower].key) >= Util.toIntUnsigned(x)) {
    return lower;
  }
  int spansize=1;
  while (lower + spansize < size && Util.toIntUnsigned(array[lower + spansize].key) < Util.toIntUnsigned(x))   spansize*=2;
  int upper=(lower + spansize < size) ? lower + spansize : size - 1;
  if (array[upper].key == x) {
    return upper;
  }
  if (Util.toIntUnsigned(array[upper].key) < Util.toIntUnsigned(x)) {
    return size;
  }
  lower+=(spansize / 2);
  while (lower + 1 != upper) {
    int mid=(lower + upper) / 2;
    if (array[mid].key == x)     return mid;
 else     if (Util.toIntUnsigned(array[mid].key) < Util.toIntUnsigned(x))     lower=mid;
 else     upper=mid;
  }
  return upper;
}

Fixed version (ground truth):
/** 
 * Find the smallest integer index larger than pos such that array[index].key&gt;=x. If none can be found, return size. Based on code by O. Kaser.
 * @param x minimal value
 * @param pos index to exceed
 * @return the smallest index greater than pos such that array[index].key is at least as largeas min, or size if it is not possible.
 */
protected int advanceUntil(int x,int pos){
  int lower=pos + 1;
  if (lower >= size || Util.toIntUnsigned(array[lower].key) >= x) {
    return lower;
  }
  int spansize=1;
  while (lower + spansize < size && Util.toIntUnsigned(array[lower + spansize].key) < x)   spansize*=2;
  int upper=(lower + spansize < size) ? lower + spansize : size - 1;
  if (array[upper].key == x) {
    return upper;
  }
  if (Util.toIntUnsigned(array[upper].key) < x) {
    return size;
  }
  lower+=(spansize / 2);
  while (lower + 1 != upper) {
    int mid=(lower + upper) / 2;
    if (array[mid].key == x)     return mid;
 else     if (Util.toIntUnsigned(array[mid].key) < x)     lower=mid;
 else     upper=mid;
  }
  return upper;
}
Program: 90281
Project: 90281
Buggy source:
/** 
 * Append copies of the values from another array
 * @param sa            other array
 * @param startingIndex starting index in the other array
 * @param end endingIndex (exclusive) in the other array
 */
protected void appendCopy(RoaringArray sa,int startingIndex,int end){
  extendArray(end - startingIndex);
  for (int i=startingIndex; i < end; ++i) {
    this.array[this.size++]=new Element(sa.array[i].key,sa.array[i].value.clone());
  }
}

Fixed version (ground truth):
/** 
 * Append copies of the values from another array
 * @param sa            other array
 * @param startingIndex starting index in the other array
 * @param end endingIndex (exclusive) in the other array
 */
protected void appendCopy(RoaringArray sa,int startingIndex,int end){
  extendArray(end - startingIndex);
  for (int i=startingIndex; i < end; ++i)   this.array[this.size++]=new Element(sa.array[i].key,sa.array[i].value.clone());
}
Program: 90282
Project: 90282
Buggy source:
public int advanceUntil(short x,int pos){
  int lower=pos + 1;
  if (lower >= size || getKey(lower) >= BufferUtil.toIntUnsigned(x)) {
    return lower;
  }
  int spansize=1;
  while (lower + spansize < size && getKey(lower + spansize) < BufferUtil.toIntUnsigned(x))   spansize*=2;
  int upper=(lower + spansize < size) ? lower + spansize : size - 1;
  if (getKey(upper) == x) {
    return upper;
  }
  if (getKey(upper) < BufferUtil.toIntUnsigned(x)) {
    return size;
  }
  lower+=(spansize / 2);
  while (lower + 1 != upper) {
    int mid=(lower + upper) / 2;
    if (getKey(mid) == BufferUtil.toIntUnsigned(x))     return mid;
 else     if (getKey(mid) < BufferUtil.toIntUnsigned(x))     lower=mid;
 else     upper=mid;
  }
  return upper;
}

Fixed version (ground truth):
public int advanceUntil(int x,int pos){
  int lower=pos + 1;
  if (lower >= size || getKey(lower) >= x) {
    return lower;
  }
  int spansize=1;
  while (lower + spansize < size && getKey(lower + spansize) < x)   spansize*=2;
  int upper=(lower + spansize < size) ? lower + spansize : size - 1;
  if (getKey(upper) == x) {
    return upper;
  }
  if (getKey(upper) < x) {
    return size;
  }
  lower+=(spansize / 2);
  while (lower + 1 != upper) {
    int mid=(lower + upper) / 2;
    if (getKey(mid) == x)     return mid;
 else     if (getKey(mid) < x)     lower=mid;
 else     upper=mid;
  }
  return upper;
}
Program: 90283
Project: 90283
Buggy source:
public int advanceUntil(short x,int pos){
  int lower=pos + 1;
  if (lower >= size || BufferUtil.toIntUnsigned(array[lower].key) >= BufferUtil.toIntUnsigned(x)) {
    return lower;
  }
  int spansize=1;
  while (lower + spansize < size && BufferUtil.toIntUnsigned(array[lower + spansize].key) < BufferUtil.toIntUnsigned(x))   spansize*=2;
  int upper=(lower + spansize < size) ? lower + spansize : size - 1;
  if (array[upper].key == x) {
    return upper;
  }
  if (BufferUtil.toIntUnsigned(array[upper].key) < BufferUtil.toIntUnsigned(x)) {
    return size;
  }
  lower+=(spansize / 2);
  while (lower + 1 != upper) {
    int mid=(lower + upper) / 2;
    if (array[mid].key == x)     return mid;
 else     if (BufferUtil.toIntUnsigned(array[mid].key) < BufferUtil.toIntUnsigned(x))     lower=mid;
 else     upper=mid;
  }
  return upper;
}

Fixed version (ground truth):
public int advanceUntil(int x,int pos){
  int lower=pos + 1;
  if (lower >= size || BufferUtil.toIntUnsigned(array[lower].key) >= x) {
    return lower;
  }
  int spansize=1;
  while (lower + spansize < size && BufferUtil.toIntUnsigned(array[lower + spansize].key) < x)   spansize*=2;
  int upper=(lower + spansize < size) ? lower + spansize : size - 1;
  if (array[upper].key == x) {
    return upper;
  }
  if (BufferUtil.toIntUnsigned(array[upper].key) < x) {
    return size;
  }
  lower+=(spansize / 2);
  while (lower + 1 != upper) {
    int mid=(lower + upper) / 2;
    if (array[mid].key == x)     return mid;
 else     if (BufferUtil.toIntUnsigned(array[mid].key) < x)     lower=mid;
 else     upper=mid;
  }
  return upper;
}
Program: 90284
Project: 90284
Buggy source:
/** 
 * Find the smallest integer index larger than pos such that getKeyAtIndex(index)&gt;=x. If none can be found, return size.
 * @param x minimal value
 * @param pos index to exceed
 * @return the smallest index greater than pos such that getKeyAtIndex(index) is at least as largeas min, or size if it is not possible.
 */
int advanceUntil(short x,int pos);

Fixed version (ground truth):
/** 
 * Find the smallest integer index larger than pos such that getKeyAtIndex(index)&gt;=x. If none can be found, return size.
 * @param x minimal value
 * @param pos index to exceed
 * @return the smallest index greater than pos such that getKeyAtIndex(index) is at least as largeas min, or size if it is not possible.
 */
int advanceUntil(int x,int pos);
Program: 90285
Project: 90285
Buggy source:
@Test(expected=IllegalArgumentException.class) public void iremoveInvalidRange2(){
  Container rc=new RunContainer();
  rc.remove(0,1 << 20);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void iremoveInvalidRange2(){
  Container rc=new RunContainer();
  rc.iremove(0,1 << 20);
}
Program: 90286
Project: 90286
Buggy source:
@Test(expected=IllegalArgumentException.class) public void iaddRangeInvalid2(){
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void iaddRangeInvalid2(){
  Container rc=new RunContainer();
  rc.iadd(0,1 << 20);
}
Program: 90287
Project: 90287
Buggy source:
@Override public Container not(final int firstOfRange,final int lastOfRange){
  if (firstOfRange >= lastOfRange) {
    return clone();
  }
  int startIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)firstOfRange);
  if (startIndex < 0)   startIndex=-startIndex - 1;
  int lastIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)(lastOfRange - 1));
  if (lastIndex < 0)   lastIndex=-lastIndex - 2;
  final int currentValuesInRange=lastIndex - startIndex + 1;
  final int spanToBeFlipped=lastOfRange - firstOfRange;
  final int newValuesInRange=spanToBeFlipped - currentValuesInRange;
  final int cardinalityChange=newValuesInRange - currentValuesInRange;
  final int newCardinality=cardinality + cardinalityChange;
  if (newCardinality >= DEFAULT_MAX_SIZE)   return toBitmapContainer().not(firstOfRange,lastOfRange);
  ArrayContainer answer=new ArrayContainer(newCardinality);
  System.arraycopy(content,0,answer.content,0,startIndex);
  int outPos=startIndex;
  int inPos=startIndex;
  int valInRange=firstOfRange;
  for (; valInRange < lastOfRange && inPos <= lastIndex; ++valInRange) {
    if ((short)valInRange != content[inPos]) {
      answer.content[outPos++]=(short)valInRange;
    }
 else {
      ++inPos;
    }
  }
  for (; valInRange < lastOfRange; ++valInRange) {
    answer.content[outPos++]=(short)valInRange;
  }
  for (int i=lastIndex + 1; i < cardinality; ++i)   answer.content[outPos++]=content[i];
  answer.cardinality=newCardinality;
  return answer;
}

Fixed version (ground truth):
@Override public Container not(final int firstOfRange,final int lastOfRange){
  if (firstOfRange >= lastOfRange) {
    return clone();
  }
  int startIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)firstOfRange);
  if (startIndex < 0)   startIndex=-startIndex - 1;
  int lastIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)(lastOfRange - 1));
  if (lastIndex < 0)   lastIndex=-lastIndex - 2;
  final int currentValuesInRange=lastIndex - startIndex + 1;
  final int spanToBeFlipped=lastOfRange - firstOfRange;
  final int newValuesInRange=spanToBeFlipped - currentValuesInRange;
  final int cardinalityChange=newValuesInRange - currentValuesInRange;
  final int newCardinality=cardinality + cardinalityChange;
  if (newCardinality > DEFAULT_MAX_SIZE)   return toBitmapContainer().not(firstOfRange,lastOfRange);
  ArrayContainer answer=new ArrayContainer(newCardinality);
  System.arraycopy(content,0,answer.content,0,startIndex);
  int outPos=startIndex;
  int inPos=startIndex;
  int valInRange=firstOfRange;
  for (; valInRange < lastOfRange && inPos <= lastIndex; ++valInRange) {
    if ((short)valInRange != content[inPos]) {
      answer.content[outPos++]=(short)valInRange;
    }
 else {
      ++inPos;
    }
  }
  for (; valInRange < lastOfRange; ++valInRange) {
    answer.content[outPos++]=(short)valInRange;
  }
  for (int i=lastIndex + 1; i < cardinality; ++i)   answer.content[outPos++]=content[i];
  answer.cardinality=newCardinality;
  return answer;
}
Program: 90288
Project: 90288
Buggy source:
@Override public Container add(int begin,int end){
  int indexstart=Util.unsignedBinarySearch(content,0,cardinality,(short)begin);
  if (indexstart < 0)   indexstart=-indexstart - 1;
  int indexend=Util.unsignedBinarySearch(content,0,cardinality,(short)(end - 1));
  if (indexend < 0)   indexend=-indexend - 1;
 else   indexend++;
  int rangelength=end - begin;
  int newcardinality=indexstart + (cardinality - indexend) + rangelength;
  if (newcardinality >= DEFAULT_MAX_SIZE) {
    BitmapContainer a=this.toBitmapContainer();
    return a.iadd(begin,end);
  }
  ArrayContainer answer=new ArrayContainer(newcardinality,content);
  System.arraycopy(content,indexend,answer.content,indexstart + rangelength,cardinality - indexend);
  for (int k=0; k < rangelength; ++k) {
    answer.content[k + indexstart]=(short)(begin + k);
  }
  answer.cardinality=newcardinality;
  return answer;
}

Fixed version (ground truth):
@Override public Container add(int begin,int end){
  int indexstart=Util.unsignedBinarySearch(content,0,cardinality,(short)begin);
  if (indexstart < 0)   indexstart=-indexstart - 1;
  int indexend=Util.unsignedBinarySearch(content,0,cardinality,(short)(end - 1));
  if (indexend < 0)   indexend=-indexend - 1;
 else   indexend++;
  int rangelength=end - begin;
  int newcardinality=indexstart + (cardinality - indexend) + rangelength;
  if (newcardinality > DEFAULT_MAX_SIZE) {
    BitmapContainer a=this.toBitmapContainer();
    return a.iadd(begin,end);
  }
  ArrayContainer answer=new ArrayContainer(newcardinality,content);
  System.arraycopy(content,indexend,answer.content,indexstart + rangelength,cardinality - indexend);
  for (int k=0; k < rangelength; ++k) {
    answer.content[k + indexstart]=(short)(begin + k);
  }
  answer.cardinality=newcardinality;
  return answer;
}
Program: 90289
Project: 90289
Buggy source:
@Override public Container iadd(int begin,int end){
  int indexstart=Util.unsignedBinarySearch(content,0,cardinality,(short)begin);
  if (indexstart < 0)   indexstart=-indexstart - 1;
  int indexend=Util.unsignedBinarySearch(content,0,cardinality,(short)(end - 1));
  if (indexend < 0)   indexend=-indexend - 1;
 else   indexend++;
  int rangelength=end - begin;
  int newcardinality=indexstart + (cardinality - indexend) + rangelength;
  if (newcardinality >= DEFAULT_MAX_SIZE) {
    BitmapContainer a=this.toBitmapContainer();
    return a.iadd(begin,end);
  }
  if (newcardinality >= this.content.length)   increaseCapacity(newcardinality);
  System.arraycopy(content,indexend,content,indexstart + rangelength,cardinality - indexend);
  for (int k=0; k < rangelength; ++k) {
    content[k + indexstart]=(short)(begin + k);
  }
  cardinality=newcardinality;
  return this;
}

Fixed version (ground truth):
@Override public Container iadd(int begin,int end){
  int indexstart=Util.unsignedBinarySearch(content,0,cardinality,(short)begin);
  if (indexstart < 0)   indexstart=-indexstart - 1;
  int indexend=Util.unsignedBinarySearch(content,0,cardinality,(short)(end - 1));
  if (indexend < 0)   indexend=-indexend - 1;
 else   indexend++;
  int rangelength=end - begin;
  int newcardinality=indexstart + (cardinality - indexend) + rangelength;
  if (newcardinality > DEFAULT_MAX_SIZE) {
    BitmapContainer a=this.toBitmapContainer();
    return a.iadd(begin,end);
  }
  if (newcardinality >= this.content.length)   increaseCapacity(newcardinality);
  System.arraycopy(content,indexend,content,indexstart + rangelength,cardinality - indexend);
  for (int k=0; k < rangelength; ++k) {
    content[k + indexstart]=(short)(begin + k);
  }
  cardinality=newcardinality;
  return this;
}
Program: 90290
Project: 90290
Buggy source:
@Override public Container inot(final int firstOfRange,final int lastOfRange){
  int startIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)firstOfRange);
  if (startIndex < 0)   startIndex=-startIndex - 1;
  int lastIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)(lastOfRange - 1));
  if (lastIndex < 0)   lastIndex=-lastIndex - 1 - 1;
  final int currentValuesInRange=lastIndex - startIndex + 1;
  final int spanToBeFlipped=lastOfRange - firstOfRange;
  final int newValuesInRange=spanToBeFlipped - currentValuesInRange;
  final short[] buffer=new short[newValuesInRange];
  final int cardinalityChange=newValuesInRange - currentValuesInRange;
  final int newCardinality=cardinality + cardinalityChange;
  if (cardinalityChange > 0) {
    if (newCardinality > content.length) {
      if (newCardinality >= DEFAULT_MAX_SIZE)       return toBitmapContainer().inot(firstOfRange,lastOfRange);
      content=Arrays.copyOf(content,newCardinality);
    }
    System.arraycopy(content,lastIndex + 1,content,lastIndex + 1 + cardinalityChange,cardinality - 1 - lastIndex);
    negateRange(buffer,startIndex,lastIndex,firstOfRange,lastOfRange);
  }
 else {
    negateRange(buffer,startIndex,lastIndex,firstOfRange,lastOfRange);
    if (cardinalityChange < 0) {
      System.arraycopy(content,startIndex + newValuesInRange - cardinalityChange,content,startIndex + newValuesInRange,newCardinality - (startIndex + newValuesInRange));
    }
  }
  cardinality=newCardinality;
  return this;
}

Fixed version (ground truth):
@Override public Container inot(final int firstOfRange,final int lastOfRange){
  int startIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)firstOfRange);
  if (startIndex < 0)   startIndex=-startIndex - 1;
  int lastIndex=Util.unsignedBinarySearch(content,0,cardinality,(short)(lastOfRange - 1));
  if (lastIndex < 0)   lastIndex=-lastIndex - 1 - 1;
  final int currentValuesInRange=lastIndex - startIndex + 1;
  final int spanToBeFlipped=lastOfRange - firstOfRange;
  final int newValuesInRange=spanToBeFlipped - currentValuesInRange;
  final short[] buffer=new short[newValuesInRange];
  final int cardinalityChange=newValuesInRange - currentValuesInRange;
  final int newCardinality=cardinality + cardinalityChange;
  if (cardinalityChange > 0) {
    if (newCardinality > content.length) {
      if (newCardinality > DEFAULT_MAX_SIZE)       return toBitmapContainer().inot(firstOfRange,lastOfRange);
      content=Arrays.copyOf(content,newCardinality);
    }
    System.arraycopy(content,lastIndex + 1,content,lastIndex + 1 + cardinalityChange,cardinality - 1 - lastIndex);
    negateRange(buffer,startIndex,lastIndex,firstOfRange,lastOfRange);
  }
 else {
    negateRange(buffer,startIndex,lastIndex,firstOfRange,lastOfRange);
    if (cardinalityChange < 0) {
      System.arraycopy(content,startIndex + newValuesInRange - cardinalityChange,content,startIndex + newValuesInRange,newCardinality - (startIndex + newValuesInRange));
    }
  }
  cardinality=newCardinality;
  return this;
}
Program: 90291
Project: 90291
Buggy source:
@Override public Container iremove(int begin,int end){
  Util.resetBitmapRange(bitmap,begin,end);
  computeCardinality();
  if (getCardinality() < ArrayContainer.DEFAULT_MAX_SIZE)   return toArrayContainer();
  return this;
}

Fixed version (ground truth):
@Override public Container iremove(int begin,int end){
  Util.resetBitmapRange(bitmap,begin,end);
  computeCardinality();
  if (getCardinality() <= ArrayContainer.DEFAULT_MAX_SIZE)   return toArrayContainer();
  return this;
}