We have the following operation $\text{IF} \ x_i =0 \ \text{THEN} \ P \ \text{END}$. I want to simulate this using a $\text{LOOP}$ program. Here is what I have:
$$\text{IF} \ x_i = 0 \ \text{THEN} \ P \ \text{END} \ ≙ \begin{cases} x_j := 1; \\ \text{LOOP} \ x_i \ \text{DO} \ x_j := 0 \ \text{END}; \\ \text{LOOP} \ x_j \ \text{DO} \ P \ \text{END} \end{cases} $$
The $\text{IF}$ program executes $P$ only when $x_i =0$, otherwise terminating. The $\text{LOOP}$ program takes $x_j$ and assigns it the value $1$. Then loops $x_i$ many times executing the program $x_j := 0$. Since no value has been assigned to $x_i$, this line is looped over $0$ many times. In the final line we loop once and execute the program $P$. Therefore, both the programs are equivalent.
So if we have $x_i = 3$, then we loop $3$ times, and each time we assign $x_j$ the value of $0$. After the third loop, the program terminates and never executes the program $P$. This is the same as the $\text{IF}$ program, which doesn't execute $P$ since $x_i \neq 0$. Is my understanding correct?