def _pull_out_perm_lhs(lhs, rest, out_port, in_port):
    """Pull out a permutation from the Feedback of a SeriesProduct with itself.

    Args:
        lhs (CPermutation): The permutation circuit
        rest (tuple): The other SeriesProduct operands
        out_port (int): The feedback output port index
        in_port (int): The feedback input port index

    Returns:
        Circuit: The simplified circuit
    """
    out_inv, lhs_red = lhs._factor_lhs(out_port)
    return lhs_red << Feedback.create(SeriesProduct.create(*rest),
                                      out_port=out_inv, in_port=in_port)