`atoi` and `LocaleIndependentAtoi` return 0 if the number couldn't be parsed. This is very unintuitive and potentially dangerous, a script like `11111111111111111111 OP_GREATERTHAN` would be identical to `0 OP_GREATERTHAN`.
Therefore, use `ToIntegral`, which returns an std::optional, which we can check for, or otherwise throw a runtime error.
Backport from core#23227.
Depends on D18472.