There're a couple of intrinsic instructions with a special meaning, one of them
are: phi and to_phi. The best way to describe how it works would an IL
example:

block B1 -> B2, B3

a = literal %0

b = literal %1

branch a, b

block B2

to_phi out, a

block B3

to_phi out, b

block B4

out = phi

ret out

Basically, since IR and IL is in SSA form, variables that have their value
depend on the branching or loop iterations, should be assigned to the final
value using to_phi instruction: second argument - intermediate value, first -
final phi value, that must be declared with <id> = phi in a successor block.

You could notice that gap instruction has appeared in output, but wasn't
present in the input. It is an another intrinsic instruction.

Basically, it contains all moves between registers/stack slots that must happen
at the time when gap instruction is reached. Note that moves may have two
types: move and swap. In case of move the value should be simply moved
from one location to another, and in case of swap values should be swapped
between each other.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.