def pyquil_to_circuit(program: pyquil.Program) -> Circuit:
    """Convert a protoquil pyQuil program to a QuantumFlow Circuit"""

    circ = Circuit()
    for inst in program.instructions:
        # print(type(inst))
        if isinstance(inst, pyquil.Declare):            # Ignore
            continue
        if isinstance(inst, pyquil.Halt):               # Ignore
            continue
        if isinstance(inst, pyquil.Pragma):             # TODO Barrier?
            continue
        elif isinstance(inst, pyquil.Measurement):
            circ += Measure(inst.qubit.index)
        # elif isinstance(inst, pyquil.ResetQubit):     # TODO
        #     continue
        elif isinstance(inst, pyquil.Gate):
            defgate = STDGATES[inst.name]
            gate = defgate(*inst.params)
            qubits = [q.index for q in inst.qubits]
            gate = gate.relabel(qubits)
            circ += gate
        else:
            raise ValueError('PyQuil program is not protoquil')

    return circ
Convert a protoquil pyQuil program to a QuantumFlow Circuit