# How to see the QASM code corresponding to compiled Q# function?

I'm learning Q#. Is there any way to see the QASM code of a Q# function I write, the same way I can see the disassembly of a C# function?

## 1 Answer

Q# is not compiled into QASM, so that would be tricky. Q# compilation and execution process is approximately as follows:

• Q# code is parsed into an internal data structure representing an abstract syntax tree. This data structure undergoes some transformations (for example, to generate adjoint and controlled versions of operations used in the code). I don't know a way to see this representation directly.
• Next, to execute the code on a simulator this data structure is used to generate C# code. This code doesn't look particularly assembly-like, since it maintains a lot of high-level language constructs. If your Q# code was stored in file MyCode.qs in folder A, the C# result of code generation will be found in A\obj\qsharp\src\MyCode.g.cs.
• C# compiler compiles this generated code into a classical executable and runs it.

Having said that, it is possible to write a separate tool that will convert a subset of Q# operations into OpenQasm; this example by Rolf Huisman shows a way to do that.

• thanks, I'll send MS a suggestion to add QASM, I think you should too. – GideonMax Jun 5 at 12:00