def METHOD_NAME(mat: np.ndarray):
    """Synthesis of a CZ circuit for linear nearest neighbour (LNN) connectivity,
    based on Maslov and Roetteler.
    Note that this method *reverts* the order of qubits in the circuit,
    and returns a circuit containing CX and phase (S, Sdg or Z) gates.
    Args:
        mat: an upper-diagonal matrix representing the CZ circuit.
            mat[i][j]=1 for i<j represents a CZ(i,j) gate
    Return:
        QuantumCircuit: a circuit implementation of the CZ circuit of depth 2*n+2 for LNN connectivity.
    Reference:
        1. Dmitri Maslov, Martin Roetteler,
           *Shorter stabilizer circuits via Bruhat decomposition and quantum circuit transformations*,
           `arXiv:1705.09176 <https://arxiv.org/abs/1705.09176>`_.
    """
    num_qubits = mat.shape[0]
    pats = _create_patterns(num_qubits)
    patlist = []
    # s_gates[i] = 0, 1, 2 or 3 for a gate id, sdg, z or s on qubit i respectively
    s_gates = np.zeros(num_qubits)
    qc = QuantumCircuit(num_qubits)
    for i in range(num_qubits):
        for j in range(i + 1, num_qubits):
            if mat[i][j]:  # CZ(i,j) gate
                s_gates[i] += 2  # qc.z[i]
                s_gates[j] += 2  # qc.z[j]
                patlist.append((i, j - 1))
                patlist.append((i, j))
                patlist.append((i + 1, j - 1))
                patlist.append((i + 1, j))
    for i in range((num_qubits + 1) // 2):
        for j in range(num_qubits):
            if pats[(i, j)] in patlist:
                patcnt = patlist.count(pats[(i, j)])
                for _ in range(patcnt):
                    s_gates[j] += 1  # qc.sdg[j]
        # Add phase gates: s, sdg or z
        for j in range(num_qubits):
            if s_gates[j] % 4 == 1:
                qc.sdg(j)
            elif s_gates[j] % 4 == 2:
                qc.z(j)
            elif s_gates[j] % 4 == 3:
                qc.s(j)
        qc = _append_cx_stage1(qc, num_qubits)
        qc = _append_cx_stage2(qc, num_qubits)
        s_gates = np.zeros(num_qubits)
    if (num_qubits % 2) == 0:
        i = num_qubits // 2
        for j in range(num_qubits):
            if pats[(i, j)] in patlist and pats[(i, j)][0] != pats[(i, j)][1]:
                patcnt = patlist.count(pats[(i, j)])
                for _ in range(patcnt):
                    s_gates[j] += 1  # qc.sdg[j]
        # Add phase gates: s, sdg or z
        for j in range(num_qubits):
            if s_gates[j] % 4 == 1:
                qc.sdg(j)
            elif s_gates[j] % 4 == 2:
                qc.z(j)
            elif s_gates[j] % 4 == 3:
                qc.s(j)
        qc = _append_cx_stage1(qc, num_qubits)
    return qc