import re


def apply_functions_exclude(elf_config, functions):
    """
    Remove excluded functions from the list of functions

    :param elf_config: Config for elf binary file
    :param functions: Array of functions in the binary elf file
    :return: Tuple with included and excluded functions
    """
    if 'exclude_functions' not in elf_config:
        return functions, []
    incl = {}
    excl = {}
    for fname in functions:
        exclude = False
        for rex in elf_config['exclude_functions']:
            if re.match(rex, fname):
                exclude = True
                excl[fname] = functions[fname]
                break
        if not exclude:
            incl[fname] = functions[fname]
    return incl, excl