private static int search(int[] I, byte[] oldBuf, byte[] newBuf, int newBufOffset, int start, int end, IntByRef pos) {
    if (end - start < 2) {
      int x = matchLen(oldBuf, I[start], newBuf, newBufOffset);
      int y = matchLen(oldBuf, I[end], newBuf, newBufOffset);
      if (x > y) {
        pos.value = I[start];
        return x;
      }
      else {
        pos.value = I[end];
        return y;
      }
    }

    int middle = start + (end - start) / 2;
    if (memCmp(oldBuf, I[middle], newBuf, newBufOffset) < 0) {
      return search(I, oldBuf, newBuf, newBufOffset, middle, end, pos);
    }
    else {
      return search(I, oldBuf, newBuf, newBufOffset, start, middle, pos);
    }
  }
private static int search(int[] I, byte[] oldBuf, byte[] newBuf, int newBufOffset, int start, int end, IntByRef pos)