FSMs with finite memory
Let your original state machine $M(k)$ have $n$ states and transition relation $t(s,s&#39;)$, where each transition $t(s,s&#39;)$ updates the global variables $x_1,...,x_k$ by applying function 
$(x&#39;_1,...,x&#39;_k) = f_{t(s,s&#39;)} (x_1,...,x_k)$. 
Then $M(k)$ is equivalent to a standard FSM with $n(2r+1)^k$ states, where each state encodes a tuple $(s,x_1,...,x_k)$ with each $x_i$ encoding one fixed value in $[-r,r]$, and new transition relation $t&#39;$

$t&#39;( (s,x_1,...,x_k), (s&#39;,x&#39;_1,...,x&#39;_k)) \Leftrightarrow t(s,s&#39;) \wedge [(x&#39;_1,...,x&#39;_k) = f_{t(s,s&#39;)} (x_1,...,x_k)]$.