The IBM OpenQASM program below clones a state selected from an orthogonal pair. It seems to work but there is a mystery. I declare the classical register as an array c[1] but when I try to test its contents, the assembler will not allow me to index it. That is, it rejects "c[0]". I get similar results if there is an array of two registers; I always have to use the array name rather than a reference to an array element. My question is, how do you reference one classical register within an array, for example in an "if" statement.
There is a second question, less pressing but important. I don't know who to make a block of code that is executed when the "if" test passes. I am forced to repeat the test for each line in the block. How do you declare a block of code or, equivalently, use a branch statement to skip a block?
cloner1 = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[1];
x q[2];
x q[4];
x q[0]; //Set up input
measure q[0] -> c[0];
if (c==1) CX q[1],q[2];
if (c==1) CX q[2],q[1];
if (c==1) CX q[1],q[2];
if (c==1) CX q[3],q[4];
if (c==1) CX q[4],q[3];
if (c==1) CX q[3],q[4];
measure q[1]->c[0];
measure q[3]->c[0];
"""
```