findIndexSS = (structs, clock) => {
  let left = 0;
  let right = structs.length - 1;
  let mid = structs[right];
  let midclock = mid.id.clock;

  if (midclock === clock) {
    return right;
  } // @todo does it even make sense to pivot the search?
  // If a good split misses, it might actually increase the time to find the correct item.
  // Currently, the only advantage is that search with pivoting might find the item on the first try.


  let midindex = math.floor(clock / (midclock + mid.length - 1) * right); // pivoting the search

  while (left <= right) {
    mid = structs[midindex];
    midclock = mid.id.clock;

    if (midclock <= clock) {
      if (clock < midclock + mid.length) {
        return midindex;
      }

      left = midindex + 1;
    } else {
      right = midindex - 1;
    }

    midindex = math.floor((left + right) / 2);
  } // Always check state before looking for a struct in StructStore
  // Therefore the case of not finding a struct is unexpected


  throw error.unexpectedCase();
}
Perform a binary search on a sorted array
@param {Array<Item|GC>} structs
@param {number} clock
@return {number}

@private
@function