# Path: utils.py
# def set_union(*sets):
#     # Python's set.union is unfortunately not a class method,
#     # but a normal method, [and if used as unbound method],
#     # requires at least one argument (set).
#     if sets:
#         return set.union(*sets)
#     return set()


import logging
import arch
import progdb
import copy
                import progdb
import dataflow
from collections import defaultdict
from core import *
from cfgutils import *
from dce import *
from xform_expr import *
from xform_inst import *
from xform_bblock import *
from utils import set_union
                        if is_value(a) and pred(a.val):
                            #refs.append(a)
                            refs.append(mem)
                            break

        inst.foreach_subexpr(collect_mmio)

    foreach_inst(cfg, collect)
    if refs:
        #cfg.props[prop_name] = refs
        cfg.props[prop_name] = sorted(list(set(refs)))


def local_defines(cfg):
    """Locations defined by function's own instructions, disregarding
    calls to other functions. This may be useful e.g. to assess
    preserveds."""

    defs = set()

    def func(inst):
        if inst.op != "call":
            defs.update(inst.defs())

    foreach_inst(cfg, func)
    cfg.props["local_defines"] = defs
    return defs


def collect_reach_exit(cfg):

# Path: utils.py
# def set_union(*sets):
#     # Python's set.union is unfortunately not a class method,
#     # but a normal method, [and if used as unbound method],
#     # requires at least one argument (set).
#     if sets:
#         return set.union(*sets)
#     return set()


# Path: xform_cfg.py
import logging
import arch
import progdb
import copy
                import progdb
import dataflow
from collections import defaultdict
from core import *
from cfgutils import *
from dce import *
from xform_expr import *
from xform_inst import *
from xform_bblock import *
from utils import set_union

                        if is_value(a) and pred(a.val):
                            #refs.append(a)
                            refs.append(mem)
                            break

        inst.foreach_subexpr(collect_mmio)

    foreach_inst(cfg, collect)
    if refs:
        #cfg.props[prop_name] = refs
        cfg.props[prop_name] = sorted(list(set(refs)))


def local_defines(cfg):
    """Locations defined by function's own instructions, disregarding
    calls to other functions. This may be useful e.g. to assess
    preserveds."""

    defs = set()

    def func(inst):
        if inst.op != "call":
            defs.update(inst.defs())

    foreach_inst(cfg, func)
    cfg.props["local_defines"] = defs
    return defs


def collect_reach_exit(cfg):

    all_defs = foreach_bblock(cfg, lambda b: b.defs(True), set_union)