+static inline pos_t *
+bt_child(struct bt_matchfinder *mf, pos_t node, int offset)
+{
+ if (MATCHFINDER_MAX_WINDOW_ORDER < sizeof(pos_t) * 8) {
+ /* no cast needed */
+ return &mf->child_tab[(node << 1) + offset];
+ } else {
+ return &mf->child_tab[((size_t)node << 1) + offset];
+ }
+}
+
+static inline pos_t *
+bt_left_child(struct bt_matchfinder *mf, pos_t node)
+{
+ return bt_child(mf, node, 0);
+}
+
+static inline pos_t *
+bt_right_child(struct bt_matchfinder *mf, pos_t node)
+{
+ return bt_child(mf, node, 1);
+}
+
+/*
+ * Retrieve a list of matches with the current position.
+ *
+ * @mf
+ * The matchfinder structure.
+ * @in_begin
+ * Pointer to the beginning of the input buffer.
+ * @in_next
+ * Pointer to the next byte in the input buffer to process. This is the
+ * pointer to the sequence being matched against.
+ * @min_len
+ * Only record matches that are at least this long.
+ * @max_len
+ * The maximum permissible match length at this position.
+ * @nice_len
+ * Stop searching if a match of at least this length is found.
+ * Must be <= @max_len.
+ * @max_search_depth
+ * Limit on the number of potential matches to consider. Must be >= 1.
+ * @next_hash
+ * Pointer to the hash code for the current sequence, which was computed
+ * one position in advance so that the binary tree root could be
+ * prefetched. This is an input/output parameter.
+ * @best_len_ret
+ * The length of the longest match found is written here. (This is
+ * actually redundant with the 'struct lz_match' array, but this is easier
+ * for the compiler to optimize when inlined and the caller immediately
+ * does a check against 'best_len'.)
+ * @lz_matchptr
+ * An array in which this function will record the matches. The recorded
+ * matches will be sorted by strictly increasing length and strictly
+ * increasing offset. The maximum number of matches that may be found is
+ * 'min(nice_len, max_len) - 3 + 1'.
+ *
+ * The return value is a pointer to the next available slot in the @lz_matchptr
+ * array. (If no matches were found, this will be the same as @lz_matchptr.)
+ */
+static inline struct lz_match *