// SPDX-License-Identifier: MIT // Generated by EML-lang Solidity backend // Source module: clamp_bounded // Source file: /home/monogate/monogate/forge/examples/clamp_bounded.eml // Functions: 1 (1 @verify-annotated) // Constants: 2 pragma solidity ^0.8.20; contract ClampBounded { int256 constant LO = (-1); int256 constant HI = 1; /// @notice Formal proof: clamp_in_unit_interval (MachLib). Compiled from EML-lang. /// @dev Pfaffian profile: chain_order=0, cost_class=p0-d2-w0-c0, drift_risk=LOW. /// @dev Gas estimate: ~269 gas (PRBMath SD59x18 overrides assumed; run forge gas-bench for the canonical signal). /// @param x x (int256) /// @dev ensures: (result >= LO) /// @dev ensures: (result <= HI) function clampUnit(int256 x) external pure returns (int256) { return _clamp(x, LO, HI); } /// @dev clamp helper -- min(max(x, lo), hi). function _clamp(int256 x, int256 lo, int256 hi) internal pure returns (int256) { if (x < lo) return lo; if (x > hi) return hi; return x; } }