[core refactor] Simplify integer div and mod implementation