  Given a function $f:\mathbb R\to\mathbb R$, call a decreasing sequence
$x_1>x_2>x_3>\cdots$ $f$-bad if $f(x_1)>f(x_2)>f(x_3)>\cdots$, and call the
function $f$ "ordinal decreasing" if there exist no infinite $f$-bad sequences.
We prove the following result, which generalizes results of Erickson et al.
(2022) and Bufetov et al. (2024): Given ordinal decreasing functions
$f,g_1,\ldots,g_k,s$ that are everywhere larger than $0$, define the recursive
algorithm "$M(x)$: if $x<0$ return $f(x)$, else return
$g_1(-M(x-g_2(-M(x-\cdots-g_k(-M(x-s(x)))\cdots))))$". Then $M(x)$ halts and is
ordinal decreasing for all $x \in \mathbb{R}$.
  More specifically, given an ordinal decreasing function $f$, denote by $o(f)$
the ordinal height of the root of the tree of $f$-bad sequences. Then we prove
that, for $k\ge 2$, the function $M(x)$ defined by the above algorithm
satisfies $o(M)\le\varphi_{k-1}(\gamma+o(s)+1)$, where $\gamma$ is the smallest
ordinal such that $\max{\{o(s),o(f),o(g_1), \ldots,
o(g_k)\}}<\varphi_{k-1}(\gamma)$.
