Solving a system of recurrences
You can prove by induction that it always holds that $z \leq 0$, and so $z \neq 1$ and $z &lt; y$. This allows the following simplification:


Input: $i$
$x,y,z,w \gets 1,1,0,0$
Repeat:

$z \gets z-1$


If $x = y$ then $w \gets w+1$ and $y \gets 1$; Else $y \gets y+1$


$x \gets 8w$

Until $w = i$
Return $z$


The running time is proportional to the number of iterations of the loop (which also happens to be the negation of the output).

In the first iteration we have $x=y$ and so set $w\gets 1$, $x\gets 8$, $y\gets 1$. Eight iterations later, we have $x=y=8$ (at the beginning of the iteration), and so we set $w\gets 2$, $x\gets 16$, $y\gets 1$. Sixteen iterations later, we have $x=y=16$, and so we set $w\gets 3$, $x\gets 24$, $y\gets 1$.

In total, we see that the number of iterations is
$$
1 + 8(1 + \cdots + (i-1)) = 1 + 8\frac{i(i-1)}{2} = 4i(i-1)+1 = (2i-1)^2.
$$
This shows that the output is $-(2i-1)^2$, and that the running time is $\Theta(i^2)$.