def METHOD_NAME(sql: str) -> str:
    comments: list[str] = []
    hints: list[str] = []
    index_hints: list[tuple[str, str, str, str]] = []
    for match in query_rewrite_re.findall(sql):
        if match in SELECT_HINT_TOKENS:
            hints.append(match)
        elif match.startswith("label="):
            comments.append(match[6:])
        elif match.startswith("index="):
            # Extra parsing
            index_match = index_rule_re.match(match)
            if index_match:
                index_hints.append(
                    (
                        index_match.group("table_name"),
                        index_match.group("rule"),
                        index_match.group("index_names"),
                        index_match.group("for_what"),
                    )
                )
        # Silently fail on unrecognized rewrite requests
    # Delete all rewrite comments
    sql = query_rewrite_re.sub("", sql)
    if comments or hints or index_hints:  # If nothing to do, don't bother
        sql = modify_sql(sql, comments, hints, index_hints)
    return sql