code: private int emitNodes(FSA fsa, OutputStream os, IntArrayList linearized) throws IOException {
      int offset = 0;
  
      // Add epsilon state.
      offset += emitNodeData(os, 0);
      if (fsa.getRootNode() != 0)
        offset += emitArc(os, BIT_LAST_ARC, (byte) '^', offsets.get(fsa.getRootNode()));
      else
        offset += emitArc(os, BIT_LAST_ARC, (byte) '^', 0);
  
      boolean offsetsChanged = false;
      final int max = linearized.size();
      for (IntCursor c : linearized) {
        final int state = c.value;
        final int nextState = c.index + 1 < max ? linearized.get(c.index + 1) : NO_STATE;
  
        if (os == null) {
          offsetsChanged |= (offsets.get(state) != offset);
          offsets.put(state, offset);
        } else {
          assert offsets.get(state) == offset : state + " " + offsets.get(state) + " " + offset;
        }
  
        offset += emitNodeData(os, withNumbers ? numbers.get(state) : 0);
        offset += emitNodeArcs(fsa, os, state, nextState);
      }
  
      return offsetsChanged ? offset : 0;
    }
docs: Update arc offsets assuming the given goto length.