%% LaTeX2e file `tmp-gen-recursive-with-bug.tex'
%% generated by the `filecontents' environment
%% from source `codeanatomy.lstlisting' on 2025/10/19.
%%
\tikzstyle{token} = [code part, fill=yellow]
\tikzstyle{bug} = [code part, fill=red!50]
\begin{lrbox}{\mycodebox}
\lstset{
  escapeinside={!}{!}
  ,basicstyle=\linespread{1.8}
}
\begin{lstlisting}[basicstyle=\small\ttfamily]
function !\cPart[token]{fnName}{gcd}! (p,q) {
    if (q === 0) {
        return !\cPart[bug]{bug}{q}!;
    } else {
        let r = p % q;
        return !\cPart[token]{recursive}{gcd}!(q, r);
    }
}
\end{lstlisting}
\end{lrbox}

\begin{tikzpicture}[remember picture]
\node(code) [anatomy] at (0,0) {\usebox\mycodebox};

\codeAnnotation{recursiveText}    (-1,2) {Function can\\call itself.}
\codeAnnotation{bugText}         ( 5,2.25) {This is\\the bug.}

\draw[->, annotation] (recursiveText) to[out=50, in=190]  (fnName);
\draw[->, annotation] (recursiveText) to[out=-20, in=175] (recursive.north west);
\draw[->, annotation] (bugText)       to[out=190,in=-20]  (bug.south east);
\end{tikzpicture}
