# Buggy code
def parse_yul_identifier(
    root: YulScope, node: YulNode, ast: Dict
) -> Optional[Expression]:
    name = ast["name"]

    if name in builtins:
        return Identifier(YulBuiltin(name))

    # check function-scoped variables
    if root.parent_func:
        variable = root.parent_func.get_local_variable_from_name(name)
        if variable:
            return Identifier(variable)

    # check yul-scoped variable
    variable = root.get_yul_local_variable_from_name(name)
    if variable:
        return Identifier(variable.underlying)

    # check yul-scoped function

    func = root.get_yul_local_function_from_name(name)
    if func:
        return Identifier(func.underlying)

    # check for magic suffixes
    if name.endswith("_slot"):
        potential_name = name[:-5]
        var = root.function.contract.get_state_variable_from_name(potential_name)
        if var:
            return Identifier(SolidityVariable(name))
    if name.endswith("_offset"):
        potential_name = name[:-7]
        var = root.function.contract.get_state_variable_from_name(potential_name)
        if var:
            return Identifier(SolidityVariable(name))

    raise SlitherException(f"unresolved reference to identifier {name}")


# Traceback (slither.exceptions.SlitherException)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/__main__.py", line 612, in main_impl
printer_classes)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/slither.py", line 86, in __init__
self._parser.analyze_contracts()
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/slitherSolc.py", line 341, in analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/slitherSolc.py", line 438, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/slitherSolc.py", line 478, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/declarations/contract.py", line 356, in analyze_content_functions
function_parser.analyze_content()
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/declarations/function.py", line 303, in analyze_content
node_parser.analyze_expressions()
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 254, in analyze_expressions
node.analyze_expressions()
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 42, in analyze_expressions
expression = parse_yul(self._scope, self, self._unparsed_expression)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 663, in parse_yul
op = parsers.get(ast['nodeType'], parse_yul_unsupported)(root, node, ast)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 570, in parse_yul_assignment
return _parse_yul_assignment_common(root, node, ast, 'variableNames')
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 552, in _parse_yul_assignment_common
rhs = parse_yul(root, node, ast['value'])
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 663, in parse_yul
op = parsers.get(ast['nodeType'], parse_yul_unsupported)(root, node, ast)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 574, in parse_yul_function_call
args = [parse_yul(root, node, arg) for arg in ast['arguments']]
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 574, in <listcomp>
args = [parse_yul(root, node, arg) for arg in ast['arguments']]
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 663, in parse_yul
op = parsers.get(ast['nodeType'], parse_yul_unsupported)(root, node, ast)
File "/usr/local/lib/python3.6/dist-packages/slither_analyzer-0.6.12-py3.6.egg/slither/solc_parsing/yul/parse_yul.py", line 637, in parse_yul_identifier
raise SlitherException(f"unresolved reference to identifier {name}")
slither.exceptions.SlitherException: unresolved reference to identifier PUBLIC_KEY_OFFSET
ERROR:root:Error:
ERROR:root:unresolved reference to identifier PUBLIC_KEY_OFFSET
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues

# Fixed code
def parse_yul_identifier(
    root: YulScope, node: YulNode, ast: Dict
) -> Optional[Expression]:
    name = ast["name"]

    if name in builtins:
        return Identifier(YulBuiltin(name))

    # check function-scoped variables
    if root.parent_func:
        variable = root.parent_func.get_local_variable_from_name(name)
        if variable:
            return Identifier(variable)

        variable = root.parent_func.contract.get_state_variable_from_name(name)
        if variable:
            return Identifier(variable)

    # check yul-scoped variable
    variable = root.get_yul_local_variable_from_name(name)
    if variable:
        return Identifier(variable.underlying)

    # check yul-scoped function

    func = root.get_yul_local_function_from_name(name)
    if func:
        return Identifier(func.underlying)

    # check for magic suffixes
    if name.endswith("_slot"):
        potential_name = name[:-5]
        var = root.function.contract.get_state_variable_from_name(potential_name)
        if var:
            return Identifier(SolidityVariable(name))
    if name.endswith("_offset"):
        potential_name = name[:-7]
        var = root.function.contract.get_state_variable_from_name(potential_name)
        if var:
            return Identifier(SolidityVariable(name))

    raise SlitherException(f"unresolved reference to identifier {name}")