function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) {
	const fromSegments = CodePathSegment.flattenUnusedSegments(
		unflattenedFromSegments,
	);
	const toSegments = CodePathSegment.flattenUnusedSegments(
		unflattenedToSegments,
	);
	const end = Math.min(fromSegments.length, toSegments.length);

	/*
	 * This loop effectively updates a doubly-linked list between two collections
	 * of segments making sure that segments in the same array indices are
	 * combined to create a path.
	 */
	for (let i = 0; i < end; ++i) {
		// get the segments in matching array indices
		const fromSegment = fromSegments[i];
		const toSegment = toSegments[i];

		/*
		 * If the destination segment is reachable, then create a path from the
		 * source segment to the destination segment.
		 */
		if (toSegment.reachable) {
			fromSegment.nextSegments.push(toSegment);
		}

		/*
		 * If the source segment is reachable, then create a path from the
		 * destination segment back to the source segment.
		 */
		if (fromSegment.reachable) {
			toSegment.prevSegments.push(fromSegment);
		}

		/*
		 * Also update the arrays that don't care if the segments are reachable
		 * or not. This should always happen regardless of anything else.
		 */
		fromSegment.allNextSegments.push(toSegment);
		toSegment.allPrevSegments.push(fromSegment);

		/*
		 * If the destination segment has at least two previous segments in its
		 * path then that means there was one previous segment before this iteration
		 * of the loop was executed. So, we need to mark the source segment as
		 * looped.
		 */
		if (toSegment.allPrevSegments.length >= 2) {
			CodePathSegment.markPrevSegmentAsLooped(toSegment, fromSegment);
		}

		// let the code path analyzer know that there's been a loop created
		state.notifyLooped(fromSegment, toSegment);
	}
}
Creates looping path between two arrays of segments, ensuring that there are
paths going between matching segments in the arrays.
@param {CodePathState} state The state to operate on.
@param {CodePathSegment[]} unflattenedFromSegments Segments which are source.
@param {CodePathSegment[]} unflattenedToSegments Segments which are destination.
@returns {void}