/* Integer modulus; return 'm % n'. (Assume that C '' with negative operands follows C99 behavior. See previous comment about luaV_idiv.)  */
lua_Integer luaV_mod(lua_State *L, lua_Integer m, lua_Integer n)
/* Integer modulus; return 'm % n'. (Assume that C '' with negative operands follows C99 behavior. See previous comment about luaV_idiv.)  */
lua_Integer luaV_mod(lua_State *L, lua_Integer m, lua_Integer n)
{
    if (n == 0)
      luaG_runerror(L, "attempt to perform 'n%%0'");
    return 0;
  }
  else {
    lua_Integer r = m % n;
    if (r != 0 && (r ^ n) < 0)
      r += n;
    return r;
  }
}