\documentclass[preview,convert={indir={aux/}, outdir={aux/}, outputdir={aux/}},border=40px]{standalone}
\usepackage{quantikz}

\begin{document}
\begin{quantikz}
\lstick{$\ket{0}$} & \gate{H} & \ctrl{1} & \qw{}    & \ctrl{2} & \rstick[3]{$\ket{\varphi'}$} & \qw & \meter{}\\
\lstick{$\ket{0}$} & \qw{}    & \targ{}  & \qw{}    & \ctrl{1} & \\
\lstick{$\ket{0}$} & \qw{}    & \qw{}    & \gate{X} & \targ{}  &
\end{quantikz}
\hspace{1cm}
\end{document}
