{
    "Function": "_hem",
    "File": "contracts/lib/solady/test/utils/TestPlus.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [
        "require(bool,string)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _hem(uint256 x, uint256 min, uint256 max)\n        internal\n        pure\n        virtual\n        returns (uint256 result)\n    {\n        require(min <= max, \"Max is less than min.\");\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // prettier-ignore\n            for {} 1 {} {\n                // If `x` is between `min` and `max`, return `x` directly.\n                // This is to ensure that dictionary values\n                // do not get shifted if the min is nonzero.\n                // More info: https://github.com/foundry-rs/forge-std/issues/188\n                if iszero(or(lt(x, min), gt(x, max))) {\n                    result := x\n                    break\n                }\n\n                let size := add(sub(max, min), 1)\n                if and(iszero(gt(x, 3)), gt(size, x)) {\n                    result := add(min, x)\n                    break\n                }\n\n                let w := not(0)\n                if and(iszero(lt(x, sub(0, 4))), gt(size, sub(w, x))) {\n                    result := sub(max, sub(w, x))\n                    break\n                }\n\n                // Otherwise, wrap x into the range [min, max],\n                // i.e. the range is inclusive.\n                if iszero(lt(x, max)) {\n                    let d := sub(x, max)\n                    let r := mod(d, size)\n                    if iszero(r) {\n                        result := max\n                        break\n                    }\n                    result := add(add(min, r), w)\n                    break\n                }\n                let d := sub(min, x)\n                let r := mod(d, size)\n                if iszero(r) {\n                    result := min\n                    break\n                }\n                result := add(sub(max, r), 1)\n                break\n            }\n        }\n    }"
}