def mul(x, y):
    """Multiplication modulo 65537."""
    x = x - 1 & 65535
    t16 = y - 1 & 65535
    t32 = x * t16 + x + t16
    x = t32 & 65535
    t16 = t32 >> 16
    x = x - t16 + int(x < t16) + 1
    return x
