code: private int guessNextBGZFPos(int p, int end)
  		throws IOException
  	{
  		for (;;) {
  			for (;;) {
  				in.seek(p);
  				in.read(buf.array(), 0, 4);
  				int n = buf.getInt(0);
  
  				if (n == BGZF_MAGIC)
  					break;
  
  				// Skip ahead a bit more than 1 byte if you can.
  				if (n >>> 8 == BGZF_MAGIC << 8 >>> 8)
  					++p;
  				else if (n >>> 16 == BGZF_MAGIC << 16 >>> 16)
  					p += 2;
  				else
  					p += 3;
  
  				if (p >= end)
  					return -1;
  			}
  			// Found what looks like a gzip block header: now get XLEN and
  			// search for the BGZF subfield.
  			final int p0 = p;
  			p += 10;
  			in.seek(p);
  			in.read(buf.array(), 0, 2);
  			p += 2;
  			final int xlen   = getUShort(0);
  			final int subEnd = p + xlen;
  
  			while (p < subEnd) {
  				in.read(buf.array(), 0, 4);
  
  				if (buf.getInt(0) != BGZF_MAGIC_SUB) {
  					p += 4 + getUShort(2);
  					in.seek(p);
  					continue;
  				}
  
  				// Found it: this is close enough to a BGZF block, make it
  				// our guess.
  				return p0;
  			}
  			// No luck: look for the next gzip block header. Start right after
  			// where we last saw the identifiers, although we could probably
  			// safely skip further ahead. (If we find the correct one right
  			// now, the previous block contained 0x1f8b0804 bytes of data: that
  			// seems... unlikely.)
  			p = p0 + 4;
  		}
  	}
docs: Returns a negative number if it doesn't find anything.