OPENQASM 3.1; include "stdgates.inc"; // Subroutines inlined: qubits by reference, classical arguments by value, // values returned. qubit[3] q; def layer(qubit a, qubit b, float[64] t) { h a; cx a, b; rz(t) b; } def half(float[64] x) -> float[64] { return x / 2; } def twice(int[32] k) -> int[32] { return 2 * k; } layer(q[0], q[1], half(pi / 2)); layer(q[1], q[2], pi / twice(4));