"""One step of the 32-bit linear congruential generator (LCG).

Fixed pipeline helper; do not edit. Serves ``guess_label.py``. Exact in double
for 32-bit state and key values. Matches ``matlab/lcgStep.m``.
"""

from __future__ import annotations

import numpy as np


def lcg_step(state: int, value: float, modulus: int) -> int:
    """Fold one value into the generator state (32-bit linear congruential generator, exact in double)."""
    key = int(np.floor(float(value))) if np.isfinite(value) else 0
    return (1664525 * state + 1013904223 + key % modulus) % modulus
