% ------------------------------------------------------------------------------
% Copyright (c) 2019, 2026 Contributors to the Eclipse Foundation
%
% See the NOTICE file(s) distributed with this work for additional
% information regarding copyright ownership.
%
% This program and the accompanying materials are made available under the terms
% of the MIT License which is available at https://opensource.org/licenses/MIT
%
% SPDX-License-Identifier: MIT
% ------------------------------------------------------------------------------
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, arrows, automata, positioning, shapes, shapes.misc}
\usepackage[paperwidth=40in, paperheight=20in]{geometry}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[
    auto,
    ->,
    node distance=5cm,
    every state/.style={ellipse, semithick, fill=black!5, minimum size=2cm, font=\Large},
    initial distance=1.2cm,
    every initial by arrow/.style={-{Stealth[scale=1.4]}},
    initial text=,
    transform shape,
    double distance=2pt,
    every loop/.style={min distance=10mm}
]

\node[state, initial, initial text={$\mathtt{count} = 0$}, accepting] (A) {\emph{Off}};
\node[state, right of=A] (B) {\emph{On}};
\node[above left=2.35cm and 2cm of A] (txt) {\textbf{marked} $\mathtt{count} = 0$};

\path[-{Stealth[scale=1.4]}]
    (B) edge[bend left, below] node[align=center] {\texttt{turn\_off}} (A)
    (A) edge[bend left, above] node[align=center] {$\texttt{count}~mod~2 = 0$\\\texttt{turn\_on}} (B)
    (A) edge[loop below] node[align=center] {$\mathtt{count} > 0$\\\texttt{decrement}\\$\mathtt{count} := \mathtt{count} - 1$} (A)
    (A) edge[loop above] node[align=center] {$\mathtt{count} < 4$\\\texttt{increment}\\$\mathtt{count} := \mathtt{count} + 1$} (A)
;

\end{tikzpicture}
\end{document}
