///|
/// Folds a little-endian word using four consecutive slices of the CRC table.
#cfg(target="native")
#inline
fn fold_word(word : UInt32, base : Int32) -> UInt32 {
  // base is one of 0, 1024, 2048, or 3072. Each byte adds at most 255.
  slicing_table.unsafe_get(base + 3 * 256 + (word & 0xFF).reinterpret_as_int()) ^
  slicing_table.unsafe_get(
    base + 2 * 256 + ((word >> 8) & 0xFF).reinterpret_as_int(),
  ) ^
  slicing_table.unsafe_get(
    base + 256 + ((word >> 16) & 0xFF).reinterpret_as_int(),
  ) ^
  slicing_table.unsafe_get(base + (word >> 24).reinterpret_as_int())
}

///|
/// Extends a finalized checksum with sixteen-byte scalar groups on native.
#cfg(target="native")
fn update_scalar_wide(initial : UInt32, data : BytesView) -> UInt32 {
  let bytes = data.data()
  let start = data.start_offset()
  let length = data.length()
  let limit = length - length % 16
  for offset = 0, crc = initial ^ xor_mask; offset < limit; {
    // The rounded limit bounds all four loads by the view, including offset views.
    let index = start + offset
    let first = bytes.unsafe_read_uint32_le(index)
    let second = bytes.unsafe_read_uint32_le(index + 4)
    let third = bytes.unsafe_read_uint32_le(index + 8)
    let fourth = bytes.unsafe_read_uint32_le(index + 12)
    continue offset + 16,
      fold_word(first ^ crc, 12 * 256) ^
      fold_word(second, 8 * 256) ^
      fold_word(third, 4 * 256) ^
      fold_word(fourth, 0)
  } nobreak {
    update_scalar(crc ^ xor_mask, data[limit:])
  }
}