\SetKwFunction{Fmassseg}{mass\_segmentator}
\SetKwFunction{Fdiam}{calc\_mass\_diameter\_cm}
\SetKwFunction{Frisk}{assess\_patient\_liver\_risk}
\SetKwFunction{Ffeatures}{calc\_mass\_imaging\_features}
\SetKwFunction{Fagg}{agg\_recommendations}
\SetKwFunction{Fsusp}{is\_suspicious}

\begin{algorithm2e}[htbp]
\DontPrintSemicolon
\SetAlgoVlined           % optional but helps alignment across pages
\SetAlgoLongEnd          % allows page breaks within blocks
\SetAlgoNoEnd            % optional: suppresses "end" lines
\SetAlgoLongEnd          % allows page breaks within blocks
\caption{Assessment of Liver Lesions}
\label{alg:liver-assessment}


\textit{This illustrative pseudocode shows the structure of a synthesized program
generated by the planner–executor framework for the liver ACR guidelines.}\\[5pt]

\KwIn{$x$: abdominal CT scan}
\KwIn{$b$: patient background / clinical data}
\KwOut{$\mathit{rec}$: patient-level follow-up recommendation}

$\mathcal{M} \gets \Fmassseg{x, \text{organ}=\text{"liver"}}$\;
$R \gets [\ ]$ \tcp*[r]{list of mass-level recommendations}

\ForEach{$m \in \mathcal{M}$}{
    $d \gets \Fdiam{m, x}$ \tcp*[r]{mass diameter in cm}
    $r \gets \Frisk{b}$ \tcp*[r]{patient-level risk (Low / High)}

    \uIf{$d \le 1.0$}{
        \uIf{$r = \text{Low}$}{
            $r_m \gets \text{``Benign; no further follow-up.''}$\;
        }
        \Else{
            $r_m \gets \text{``Liver MRI in 3--6 months.''}$\;
        }
    }
    \uElseIf{$1.0 < d \le 1.5$}{
        $\phi_m \gets \Ffeatures{m, x}$ \tcp*[r]{lesion's imaging features}
        \uIf{$\phi_m = \text{suspicious}$}{
            \textit{Further logic...}\;
        }
        \Else{
            \textit{Further other logic...}\;
        }
    }
    \Else{
        $\text{``Further logic for large lesions...``}$ \tcp*[r]{larger than 1.5 cm}
    }
    append $r_m$ to $R$\;
}

$\mathit{rec} \gets \Fagg{R}$ \tcp*[r]{aggregate into patient-level recommendation}
\KwRet{$\mathit{rec}$}
\end{algorithm2e}