```\nfunction mul(int256 a, int256 b) internal pure returns (int256) {\n    int256 c = a * b;\n\n    // Detect overflow when multiplying MIN_INT256 with -1\n    require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));\n    require((b == 0) || (c / b == a));\n    return c;\n}\n```\n