Program: 101077
Project: 101077
Buggy source:
public int select0(int offset,int count){
  if (count == 1)   return 1;
  if (count == 2)   return node2pos;
  int start=indexCache[count / CACHE_WIDTH] / CACHE_WIDTH;
  int end=countCache.length;
  int ici=count / CACHE_WIDTH + 1;
  if (indexCache.length > ici) {
    end=(indexCache[ici]) / CACHE_WIDTH + 1;
  }
  int m=0;
  int d=0;
  while (start != end) {
    m=(start + end) / 2;
    d=count - (CACHE_WIDTH * (m + 1) - countCache[m]);
    if (m == (countCache.length - 1)) {
      d+=CACHE_WIDTH - (size % CACHE_WIDTH);
    }
    if (d < 0) {
      end=m;
      continue;
    }
 else     if (d > 0) {
      if (start != m)       start=m;
 else       break;
    }
 else {
      break;
    }
  }
  if (d > 0) {
    count=d;
    for (int i=(m + 1) * CACHE_WIDTH / 8; i < vector.length; i++) {
      if (i * 8 >= size)       return -1;
      int c=8 - BITCOUNTS[vector[i] & 0xff];
      if (count <= c) {
        int v=vector[i] & 0xff;
        for (int j=0; j < 8; j++) {
          if (i * 8 + j >= size)           return -1;
          if ((v & 0x80) == 0) {
            count--;
            if (count == 0) {
              return i * 8 + j;
            }
          }
          v<<=1;
        }
      }
      count-=c;
    }
  }
 else {
    count=d - 1;
    int i=Math.min(((m + 1) * CACHE_WIDTH) - 1,size - 1);
    int v=vector[i / 8] & 0xff;
    v>>=8 - (i % 8) - 1;
    while (i >= 0) {
      if ((v & 0x01) == 0) {
        count++;
        if (count == 0) {
          return i;
        }
      }
      if (i % 8 == 0) {
        v=vector[(i - 1) / 8] & 0xff;
      }
 else {
        v>>=1;
      }
      i--;
    }
  }
  return -1;
}

Fixed version (ground truth):
public int select0(int offset,int count){
  if (count == 1)   return node1pos;
  if (count == 2)   return node2pos;
  int start=indexCache[count / CACHE_WIDTH] / CACHE_WIDTH;
  int end=countCache.length;
  int ici=count / CACHE_WIDTH + 1;
  if (indexCache.length > ici) {
    end=(indexCache[ici]) / CACHE_WIDTH + 1;
  }
  int m=0;
  int d=0;
  while (start != end) {
    m=(start + end) / 2;
    d=count - (CACHE_WIDTH * (m + 1) - countCache[m]);
    if (m == (countCache.length - 1)) {
      d+=CACHE_WIDTH - (size % CACHE_WIDTH);
    }
    if (d < 0) {
      end=m;
      continue;
    }
 else     if (d > 0) {
      if (start != m)       start=m;
 else       break;
    }
 else {
      break;
    }
  }
  if (d > 0) {
    count=d;
    for (int i=(m + 1) * CACHE_WIDTH / 8; i < vector.length; i++) {
      if (i * 8 >= size)       return -1;
      int c=8 - BITCOUNTS[vector[i] & 0xff];
      if (count <= c) {
        int v=vector[i] & 0xff;
        for (int j=0; j < 8; j++) {
          if (i * 8 + j >= size)           return -1;
          if ((v & 0x80) == 0) {
            count--;
            if (count == 0) {
              return i * 8 + j;
            }
          }
          v<<=1;
        }
      }
      count-=c;
    }
  }
 else {
    count=d - 1;
    int i=Math.min(((m + 1) * CACHE_WIDTH) - 1,size - 1);
    int v=vector[i / 8] & 0xff;
    v>>=8 - (i % 8) - 1;
    while (i >= 0) {
      if ((v & 0x01) == 0) {
        count++;
        if (count == 0) {
          return i;
        }
      }
      if (i % 8 == 0) {
        v=vector[(i - 1) / 8] & 0xff;
      }
 else {
        v>>=1;
      }
      i--;
    }
  }
  return -1;
}