In the OpenQasm language, the if statement is typically used for conditional quantum operations, not for controlling classical operations like measurements. The if statement in OpenQasm allows you to conditionally apply quantum gates or operations based on the state of classical registers (cregs).
The correct usage of the if statement in OpenQasm 2.0 is as follows:
if(c_reg == int) QuantumOperation qreg;
Here, c_reg is the classical register you're checking, int is the integer value you're comparing it to, and QuantumOperation is the quantum operation you want to conditionally apply to qreg based on the condition.
However, you cannot use the if statement to conditionally execute classical operations like measurements (measure qreg -> creg). The if statement in OpenQasm is designed to conditionally apply quantum operations, not classical operations.
If you're experiencing an issue where the measurement statement is executing regardless of the if statement, there might be some other factors at play, such as the actual values of your classical registers, how they are being manipulated, or how the circuit is being executed. Without seeing your actual code and circuit, it's hard to pinpoint the exact issue.
To troubleshoot this, you might want to check the values stored in your classical registers (c_reg) and ensure that they match the conditions you are checking in your if statement. Additionally, you could try simplifying your code to a minimal example that still reproduces the issue and share that with the community or support forums for more specific assistance.