Program: 52143
Project: 52143
Buggy source:
public long sequenceForPosition(StoreRecovery recovery,Wire wire,long position,long timeoutMS) throws EOFException, UnrecoverableTimeoutException, StreamCorruptedException {
  final LongArrayValues index2indexArr=getIndex2index(recovery,wire,timeoutMS);
  long lastKnownAddress=0;
  long lastKnownIndex=0;
  if (((Byteable)index2indexArr).bytesStore() == null)   return linearScanByPosition(wire,position,lastKnownIndex,lastKnownAddress);
  final LongArrayValues indexArr=indexArray.get();
  Bytes<?> bytes=wire.bytes();
  for (int index2=0; index2 < indexCount; index2++) {
    long secondaryAddress=getSecondaryAddress(recovery,wire,timeoutMS,index2indexArr,index2);
    bytes.readLimit(bytes.capacity());
    try (DocumentContext context=wire.readingDocument(secondaryAddress)){
      if (!context.isPresent() || !context.isMetaData())       throw new IllegalStateException("String_Node_Str" + context.isPresent() + "String_Node_Str"+ context.isMetaData());
      @NotNull final LongArrayValues array1=array(wire,indexArr,false);
      long posN=array1.getValueAt(indexCount - 1);
      if (posN > 0 && posN < position) {
        lastKnownAddress=posN;
        lastKnownIndex=((index2 + 1L << indexCountBits) - 1) << indexSpacingBits;
        continue;
      }
      for (int index1=0; index1 < indexCount; index1++) {
        long pos=array1.getValueAt(index1);
        if (pos != 0 && pos <= position) {
          lastKnownAddress=pos;
          lastKnownIndex=((long)index2 << (indexCountBits + indexSpacingBits)) + (index1 << indexSpacingBits);
          continue;
        }
        ScanResult scanResult;
        long nextIndex;
        if (lastKnownIndex < 0) {
          scanResult=firstScan(wire);
          nextIndex=0;
        }
 else {
          nextIndex=lastKnownIndex + indexSpacing;
          scanResult=linearScan(wire,nextIndex,lastKnownIndex,lastKnownAddress);
        }
        if (scanResult == ScanResult.FOUND) {
          long nextPosition=bytes.readPosition();
          array1.setOrderedValueAt(index1,nextPosition);
          array1.setMaxUsed(index1 + 1);
          if (nextPosition == position) {
            nextEntryToIndex.setMaxValue(nextIndex + 1);
            return nextIndex;
          }
        }
        long ret=linearScanByPosition(wire,position,lastKnownIndex,lastKnownAddress);
        nextEntryToIndex.setMaxValue(ret + 1);
        return ret;
      }
    }
   }
  throw new AssertionError();
}

Fixed version (ground truth):
public long sequenceForPosition(StoreRecovery recovery,Wire wire,final long position,long timeoutMS) throws EOFException, UnrecoverableTimeoutException, StreamCorruptedException {
  final LongArrayValues index2indexArr=getIndex2index(recovery,wire,timeoutMS);
  long lastKnownAddress=0;
  long lastKnownIndex=0;
  if (((Byteable)index2indexArr).bytesStore() == null)   return linearScanByPosition(wire,position,lastKnownIndex,lastKnownAddress);
  final LongArrayValues indexArr=indexArray.get();
  Bytes<?> bytes=wire.bytes();
  for (int index2=0; index2 < indexCount; index2++) {
    long secondaryAddress=getSecondaryAddress(recovery,wire,timeoutMS,index2indexArr,index2);
    bytes.readLimit(bytes.capacity());
    try (DocumentContext context=wire.readingDocument(secondaryAddress)){
      if (!context.isPresent() || !context.isMetaData())       throw new IllegalStateException("String_Node_Str" + context.isPresent() + "String_Node_Str"+ context.isMetaData());
      @NotNull final LongArrayValues array1=array(wire,indexArr,false);
      long posN=array1.getValueAt(indexCount - 1);
      if (posN > 0 && posN < position) {
        lastKnownAddress=posN;
        lastKnownIndex=((index2 + 1L << indexCountBits) - 1) << indexSpacingBits;
        continue;
      }
      for (int index1=0; index1 < indexCount; index1++) {
        long pos=array1.getValueAt(index1);
        if (pos != 0 && pos <= position) {
          lastKnownAddress=pos;
          lastKnownIndex=((long)index2 << (indexCountBits + indexSpacingBits)) + (index1 << indexSpacingBits);
          continue;
        }
        ScanResult scanResult;
        long nextIndex;
        if (lastKnownIndex < 0) {
          scanResult=firstScan(wire);
          nextIndex=0;
        }
 else {
          nextIndex=lastKnownIndex + indexSpacing;
          scanResult=linearScan(wire,nextIndex,lastKnownIndex,lastKnownAddress);
        }
        if (scanResult == ScanResult.FOUND) {
          long nextPosition=bytes.readPosition();
          array1.setOrderedValueAt(index1,nextPosition);
          array1.setMaxUsed(index1 + 1);
          if (nextPosition == position) {
            nextEntryToIndex.setMaxValue(nextIndex + 1);
            return nextIndex;
          }
        }
        long ret=linearScanByPosition(wire,position,lastKnownIndex,lastKnownAddress);
        nextEntryToIndex.setMaxValue(ret + 1);
        return ret;
      }
    }
   }
  throw new AssertionError();
}