def _cond_swap_values(swap, u, v):
    """
    Conditionally swap u and v if swap=1 and otherwise left unchanged if
    swap=0. The value of swap must be 0 or 1 exclusively.
    """
    swap_diff = -swap & (u ^ v)
    return u ^ swap_diff, v ^ swap_diff
