def bytes_startswith_range(x: bytes, prefix: bytes, start: int, end: int) -> bool:
    """Does specified slice of given bytes object start with the subsequence prefix?

    Compiling bytes.startswith with range arguments compiles this function.
    This function is only intended to be executed in this compiled form.

    Args:
        x: The bytes object to examine.
        prefix: The subsequence to look for.
        start: Beginning of slice of x.  Interpreted as slice notation.
        end: End of slice of x.  Interpreted as slice notation.

    Returns:
        Result of check.
    """
    if start < 0:
        start += len(x)
        if start < 0:
            start = 0
    if end < 0:
        end += len(x)
        if end < 0:
            end = 0
    elif end > len(x):
        end = len(x)

    if end - start < len(prefix):
        return False
    index = start
    for i in prefix:
        if x[index] != i:
            return False
        index += 1
    return True