module M:
  input I, R;
  output O;

  loop
    do
      loop
        do
          halt
        watching I;
        do
          halt
        watching I;
        emit O
      end
    watching R
  end
.