def _apply_controlled_rotations(quantum_circuit, controls, angle, n_qubits,
    with_barriers=False):
    """
    This procedure applies controlled rotations using a tuple
    with the states of the qubits (eg.: controls = (x, y, z),
    where each x,y and z can be either 0 or 1).
    A not gate is applied to a control qubit everytime it's in the state |0> ,
    given the controlled rotations are activated when the control qubit is set to |1>.

    :param quantum_circuit: Quantum circuit object from qiskit library
    :param controls: A tuple with one possibility of states of qubits, example: (0,1,0)
    :param angle: Angle to be used in the multi controlled rotation
    :param n_qubits: (int) Number of qubits in the quantum circtuin
    :param with_barriers: Boolean, add the barriers in the quantum circuit for better visualisation
                          when printing the circuit
    :return: Updated quantum circuit with the controlled rotations applied
    """
    n_controls = len(controls)
    control_qubit_indexes = list(range(n_controls))
    for i, ctrl in enumerate(controls):
        if ctrl == 0:
            quantum_circuit.x(n_qubits - i - 1)
    if with_barriers:
        quantum_circuit.barrier()
    control_qubit_objects_list = []
    reg = quantum_circuit.qregs[0]
    for c_idx in control_qubit_indexes:
        control_qubit_objects_list.append(reg[n_qubits - c_idx - 1])
    target = reg[n_qubits - n_controls - 1]
    quantum_circuit.mcry(angle, control_qubit_objects_list, target, None,
        mode='noancilla')
    if with_barriers:
        quantum_circuit.barrier()
    for i, ctrl in enumerate(controls):
        if ctrl == 0:
            quantum_circuit.x(n_qubits - i - 1)
    return quantum_circuit
