% Figure: speedup decomposition — three panels (one per algorithm), log y-axis.
% Data: paper/figures/data/decomp_{mlkem512,768,1024}.csv
\begin{tikzpicture}
\begin{groupplot}[
  group style={group size=3 by 1, horizontal sep=1.6cm, ylabels at=edge left},
  pqc bar,
  ybar, ymode=log, ymin=1, ymax=500,
  ytick={1,2,5,10,20,50,100,200},
  yticklabels={$1\times$,$2\times$,$5\times$,$10\times$,$20\times$,$50\times$,$100\times$,$200\times$},
  yminorticks=true,
  width=5.2cm, height=6.5cm,
  symbolic x coords={INVNTT,basemul,frommsg,NTT,iDec,iEnc,iKeypair,gena,noise},
  xticklabels={INVNTT,basemul,frommsg,NTT,iDec,iEnc,iKeypair,gen\_a,noise},
  ylabel={Speedup over \texttt{-O0} ($\times$)},
]

%% ML-KEM-512
\nextgroupplot[title={\mlkemk{512}}, bar width=3.5pt]

\addplot+[fill=colRefnv, draw=colRefnv!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=refnv_sp, y error plus=refnv_ehi, y error minus=refnv_elo,
        col sep=comma]{figures/data/decomp_mlkem512.csv};

\addplot+[fill=colRef, draw=colRef!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=ref_sp, y error plus=ref_ehi, y error minus=ref_elo,
        col sep=comma]{figures/data/decomp_mlkem512.csv};

\addplot+[fill=colAvx, draw=colAvx!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=avx2_sp, y error plus=avx2_ehi, y error minus=avx2_elo,
        col sep=comma]{figures/data/decomp_mlkem512.csv};

%% ML-KEM-768
\nextgroupplot[title={\mlkemk{768}}, ylabel={}, bar width=3.5pt]

\addplot+[fill=colRefnv, draw=colRefnv!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=refnv_sp, y error plus=refnv_ehi, y error minus=refnv_elo,
        col sep=comma]{figures/data/decomp_mlkem768.csv};

\addplot+[fill=colRef, draw=colRef!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=ref_sp, y error plus=ref_ehi, y error minus=ref_elo,
        col sep=comma]{figures/data/decomp_mlkem768.csv};

\addplot+[fill=colAvx, draw=colAvx!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=avx2_sp, y error plus=avx2_ehi, y error minus=avx2_elo,
        col sep=comma]{figures/data/decomp_mlkem768.csv};

%% ML-KEM-1024
\nextgroupplot[title={\mlkemk{1024}}, ylabel={}, bar width=3.5pt,
  legend style={at={(1.0,0.99)}, anchor=north east, font=\scriptsize},
  legend entries={O3 (no auto-vec), O3 + auto-vec, O3 + hand SIMD}]

\addplot+[fill=colRefnv, draw=colRefnv!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=refnv_sp, y error plus=refnv_ehi, y error minus=refnv_elo,
        col sep=comma]{figures/data/decomp_mlkem1024.csv};

\addplot+[fill=colRef, draw=colRef!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=ref_sp, y error plus=ref_ehi, y error minus=ref_elo,
        col sep=comma]{figures/data/decomp_mlkem1024.csv};

\addplot+[fill=colAvx, draw=colAvx!70!black, opacity=0.85,
          error bars/.cd, y dir=both, y explicit]
  table[x=op, y=avx2_sp, y error plus=avx2_ehi, y error minus=avx2_elo,
        col sep=comma]{figures/data/decomp_mlkem1024.csv};

\end{groupplot}
\end{tikzpicture}
