<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def coerce_to_int(val, default=0xDEADBEEF):
 """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 != 0xDEADBEEF:
            return default
        return val