def coerce_to_int(val, default=3735928559):
    """Attempts to cast given value to an integer, return the original value if failed or the default if one provided."""
    try:
        return int(val)
    except (TypeError, ValueError):
        if default != 3735928559:
            return default
        return val
