#-------------------------------------------
# Conditionals - If/Elif/Else Conditional
# Ported by: Noah Gergel
# Last updated: May 6 2020
#-------------------------------------------

.text

# A function with an if/elif/else condition in it.
f3:
    # Function code leading up to the conditional.
    # ...

    # Handle the different cases.
    li    t1, 1
    beq   t0, t1, _f3Body1

    li    t1, 10
    ble   t0, t1, _f3Body2

    # We're done all of our conditions. If we get here then we know that none of
    # the if conditions were met. If there's an else block then we must execute it
    # by unconditionally jumping to it. If there is no else block (i.e. if/elif
    # without else) then we unconditionally jump to the join block.

    # We have an else block, so jump to it.
    j     _f3Else

    # Or if there was no else block: j _f3Join

_f3Body1:
    # We passed if condition one, do if then block.
    # ...

    # We don't want to execute any of the other blocks, so jump to the join point.
    j     _f3Join

_f3Body2:
    # We failed condition one but passed condition two, do the elif then block.
    # ...

    # We don't want to execute any of the other blocks, so jump to the join point.
    j     _f3Join

_f3Else:
    # We didn't pass any conditions so do the else block.
    # ...

    # There's nothing between us and the join block so we can just fall through.

_f3Join:
    # Code after the conditional.
    # ...

    jalr  zero, ra, 0