+ occ->prev = t;
+ if (t)
+ t->parent = occ;
+}
+
+/* Sets next field of OCC to P. */
+
+static inline void
+set_next (struct et_occ *occ, struct et_occ *t)
+{
+#ifdef DEBUG_ET
+ gcc_assert (occ != t);
+#endif
+
+ occ->next = t;
+ if (t)
+ t->parent = occ;
+}
+
+/* Recompute minimum for occurrence OCC. */
+
+static inline void
+et_recomp_min (struct et_occ *occ)
+{
+ struct et_occ *mson = occ->prev;
+
+ if (!mson
+ || (occ->next
+ && mson->min > occ->next->min))
+ mson = occ->next;
+
+ if (mson && mson->min < 0)
+ {
+ occ->min = mson->min + occ->depth;
+ occ->min_occ = mson->min_occ;
+ }
+ else
+ {
+ occ->min = occ->depth;
+ occ->min_occ = occ;
+ }
+}
+
+#ifdef DEBUG_ET
+/* Checks whether neighborhood of OCC seems sane. */
+
+static void
+et_check_occ_sanity (struct et_occ *occ)
+{
+ if (!occ)
+ return;
+
+ gcc_assert (occ->parent != occ);
+ gcc_assert (occ->prev != occ);
+ gcc_assert (occ->next != occ);
+ gcc_assert (!occ->next || occ->next != occ->prev);
+
+ if (occ->next)
+ {
+ gcc_assert (occ->next != occ->parent);
+ gcc_assert (occ->next->parent == occ);
+ }
+
+ if (occ->prev)
+ {
+ gcc_assert (occ->prev != occ->parent);
+ gcc_assert (occ->prev->parent == occ);
+ }
+
+ gcc_assert (!occ->parent
+ || occ->parent->prev == occ
+ || occ->parent->next == occ);
+}
+
+/* Checks whether tree rooted at OCC is sane. */
+
+static void
+et_check_sanity (struct et_occ *occ)
+{
+ et_check_occ_sanity (occ);
+ if (occ->prev)
+ et_check_sanity (occ->prev);
+ if (occ->next)
+ et_check_sanity (occ->next);
+}
+
+/* Checks whether tree containing OCC is sane. */
+
+static void
+et_check_tree_sanity (struct et_occ *occ)
+{
+ while (occ->parent)
+ occ = occ->parent;
+
+ et_check_sanity (occ);
+}
+
+/* For recording the paths. */
+
+/* An ad-hoc constant; if the function has more blocks, this won't work,
+ but since it is used for debugging only, it does not matter. */
+#define MAX_NODES 100000