Align the pointer index on a byte index of _a_, where a
 must be 1, 2, 4 or 8.
554724
def align(a)
      case a
      when 1
        nil
      when 2, 4, 8
        bits = a - 1
        @idx = @idx + bits & ~bits
        raise IncompleteBufferException if @idx > @buffy.bytesize
      else
        raise "Unsupported alignment #{a}"
      end
    end
229830
private static int indexMiddle(
		BinaryString pattern, MemorySegment[] segments, int start, int len) {
		return SegmentsUtil.find(
				segments, start, len,
				pattern.getSegments(), pattern.getOffset(), pattern.getSizeInBytes());
	}
28843
public static final Mem word_ptr_abs(long target, Register index, int shift, long disp, SEGMENT segmentPrefix) {
        return _ptr_build_abs(target, index, shift, disp, segmentPrefix, SIZE_WORD);
    }
882591
int writePageIndex(byte []buffer,
                     int head,
                     int type,
                     int pid,
                     int nextPid,
                     int entryOffset, 
                     int entryLength)
  {
    int sublen = 1 + 4 * 4;
    
    if (BLOCK_SIZE - 8 < head + sublen) {
      return -1;
    }
    
    buffer[head] = (byte) type;
    head++;
    
    BitsUtil.writeInt(buffer, head, pid);
    head += 4;
    
    BitsUtil.writeInt(buffer, head, nextPid);
    head += 4;
    
    BitsUtil.writeInt(buffer, head, entryOffset);
    head += 4;
    
    BitsUtil.writeInt(buffer, head, entryLength);
    head += 4;
    
    return head;
  }
363436
def index(a, x, atol=None):
    """"""
    i = bs.bisect_left(a, x)
    if i != len(a):
        if atol is None:
            if a[i] == x: return i
        else:
            if abs(a[i] - x) < atol: return i
    raise ValueError
1353161
def build_byte_align_buff(bits):
    
    bitmod = len(bits)%8
    if bitmod == 0:
        rdiff = bitarray()
    else:
        #KEEP bitarray
        rdiff = bitarray(8-bitmod)
        rdiff.setall(False)
    return rdiff+bits
1086071
def byte2int(s, index=0):
    
    if six.PY2:
        return ord(s[index])
    return s[index]
788374
def i8(self, name, value=None, align=None):
        """"""
        self.int(1, name, value, align)
624346
public void align(final long alignByteNumber) throws IOException {
    if (this.bitBufferCount > 0) {
      this.writeBits(0, JBBPBitNumber.decode(8 - this.bitBufferCount));
    }

    if (alignByteNumber > 0) {
      long padding = (alignByteNumber - (this.byteCounter % alignByteNumber)) % alignByteNumber;
      while (padding > 0) {
        this.out.write(0);
        this.byteCounter++;
        padding--;
      }
    }
  }
576750
def p_array_index(self, p):
        ''''''
        if len(p) == 3:
            p[0] = slice(0, -1, -1)
        elif len(p) == 1 or p[1] == ':':
            p[0] = slice(0, -1, 1)
        else:
            p[0] = slice(0, int(p[1]), 1)
999467
def get_byte(self, index):
        
        pos = self.size() // 8 - 1 - index
        return self[pos * 8 + 7 : pos * 8]
990018
public static final Mem byte_ptr_abs(long target, Register index, int shift, long disp, SEGMENT segmentPrefix) {
        return _ptr_build_abs(target, index, shift, disp, segmentPrefix, SIZE_BYTE);
    }
904352
public static final Mem qword_ptr_abs(long target, Register index, int shift, long disp, SEGMENT segmentPrefix) {
        return _ptr_build_abs(target, index, shift, disp, segmentPrefix, SIZE_QWORD);
    }
1112314
@Override public long indexOf(byte b, long fromIndex) {
    if (fromIndex < 0) throw new IllegalArgumentException("fromIndex < 0");

    Segment s = head;
    if (s == null) return -1L;
    long offset = 0L;
    do {
      int segmentByteCount = s.limit - s.pos;
      if (fromIndex >= segmentByteCount) {
        fromIndex -= segmentByteCount;
      } else {
        byte[] data = s.data;
        for (int pos = (int) (s.pos + fromIndex), limit = s.limit; pos < limit; pos++) {
          if (data[pos] == b) return offset + pos - s.pos;
        }
        fromIndex = 0;
      }
      offset += segmentByteCount;
      s = s.next;
    } while (s != head);
    return -1L;
  }
617138
def store(self, value, ptr, align=None):
        
        if not isinstance(ptr.type, types.PointerType):
            raise TypeError("cannot store to value of type %s (%r): not a pointer"
                            % (ptr.type, str(ptr)))
        if ptr.type.pointee != value.type:
            raise TypeError("cannot store %s to %s: mismatching types"
                            % (value.type, ptr.type))
        st = instructions.StoreInstr(self.block, value, ptr)
        st.align = align
        self._insert(st)
        return st
766950
def _astore8(ins):
    ''' 
    '''
    output = _addr(ins.quad[1])
    op = ins.quad[2]

    indirect = op[0] == '*'
    if indirect:
        op = op[1:]

    immediate = op[0] == '#'
    if immediate:
        op = op[1:]

    if is_int(op):
        if indirect:
            if immediate:
                op = str(int(op) & 0xFFFF)  # Truncate to 16bit pointer
                output.append('ld a, (%s)' % op)
            else:
                output.append('ld de, (%s)' % op)
                output.append('ld a, (de)')
        else:
            op = str(int(op) & 0xFF)  # Truncate to byte
            output.append('ld (hl), %s' % op)
            return output

    elif op[0] == '_':
        if indirect:
            if immediate:
                output.append('ld a, (%s)' % op)  # Redundant: *#_id == _id
            else:
                output.append('ld de, (%s)' % op)  # *_id
                output.append('ld a, (de)')
        else:
            if immediate:
                output.append('ld a, %s' % op)  # #_id
            else:
                output.append('ld a, (%s)' % op)  # _id
    else:
        output.append('pop af')  # tn

    output.append('ld (hl), a')

    return output
796288
protected byte[] AssembleIndex(int[] NewOffsets,byte[] NewObjects)
	{
		// Calc the index' count field
		char Count = (char)(NewOffsets.length-1);
		// Calc the size of the object array
		int Size = NewOffsets[NewOffsets.length-1];
		// Calc the Offsize
		byte Offsize;
        if (Size <= 0xff) Offsize = 1;
        else if (Size <= 0xffff) Offsize = 2;
        else if (Size <= 0xffffff) Offsize = 3;
        else Offsize = 4;
        // The byte array for the new index. The size is calc by
        // Count=2, Offsize=1, OffsetArray = Offsize*(Count+1), The object array
        byte[] NewIndex = new byte[2+1+Offsize*(Count+1)+NewObjects.length];
        // The counter for writing
        int Place = 0;
        // Write the count field
        NewIndex[Place++] = (byte) ((Count >>> 8) & 0xff);
        NewIndex[Place++] = (byte) ((Count >>> 0) & 0xff);
        // Write the offsize field
        NewIndex[Place++] = Offsize;
        // Write the offset array according to the offsize
        for (int i=0;i<NewOffsets.length;i++)
        {
        	// The value to be written
        	int Num = NewOffsets[i]-NewOffsets[0]+1;
        	// Write in bytes according to the offsize
        	switch (Offsize) {
                case 4:
                	NewIndex[Place++] = (byte) ((Num >>> 24) & 0xff);
                case 3:
                	NewIndex[Place++] = (byte) ((Num >>> 16) & 0xff);
                case 2:
                	NewIndex[Place++] = (byte) ((Num >>>  8) & 0xff);
                case 1:
                	NewIndex[Place++] = (byte) ((Num >>>  0) & 0xff);
        	}                	
        }
        // Write the new object array one by one
        for (int i=0;i<NewObjects.length;i++)
        {
        	NewIndex[Place++] = NewObjects[i];
        }
        // Return the new index
        return NewIndex;
	}