:param function:    A normalized Function object.
        :returns:           A dictionary of basic block addresses and their distance to the exit of the function.
427003
def _distances_from_function_exit(function):
        
        reverse_graph = function.graph.reverse()
        # we aren't guaranteed to have an exit from the function so explicitly add the node
        reverse_graph.add_node("start")
        found_exits = False
        for n in function.graph.nodes():
            if len(list(function.graph.successors(n))) == 0:
                reverse_graph.add_edge("start", n)
                found_exits = True

        # if there were no exits (a function with a while 1) let's consider the block with the highest address to
        # be the exit. This isn't the most scientific way, but since this case is pretty rare it should be okay
        if not found_exits:
            last = max(function.graph.nodes(), key=lambda x:x.addr)
            reverse_graph.add_edge("start", last)

        dists = networkx.single_source_shortest_path_length(reverse_graph, "start")

        # remove temp node
        del dists["start"]

        # correct for the added node
        for n in dists:
            dists[n] -= 1

        return dists
456216
def map(self, function):
        
        if isinstance(self.slice, slice):
            for i in range(*self.slice.indices(len(self.layout.fields))):
                function(self.layout.fields[i])

        elif isinstance(self.slice, list):
            # A list of pointers  Ex: [[[0, 0], 'div'], [[0, 2, 3], 'field_name']]
            for pointer in self.slice:
                position = pointer[0]

                layout_object = self.layout.fields[position[0]]
                for i in position[1:]:
                    previous_layout_object = layout_object
                    layout_object = layout_object.fields[i]

                # If update_attrs is applied to a string, we call to its wrapping layout object
                if (
                    function.__name__ == 'update_attrs'
                    and isinstance(layout_object, string_types)
                ):
                    function(previous_layout_object)
                else:
                    function(layout_object)
392611
def module_functions(modulestr):
    

    funcs = dict(inspect.getmembers(import_module(modulestr),
                 inspect.isfunction))

    return OrderedDict(sorted(funcs.items(), key=lambda f: f[0]))
1044072
def p_function_def(p):
    
    p[0] = make_func_declaration(p[3], p.lineno(3))
    SYMBOL_TABLE.enter_scope(p[3])
    FUNCTION_LEVEL.append(SYMBOL_TABLE.get_entry(p[3]))
    FUNCTION_LEVEL[-1].convention = p[2]

    if p[0] is not None:
        kind = KIND.sub if p[1] == 'SUB' else KIND.function  # Must be 'function' or 'sub'
        FUNCTION_LEVEL[-1].set_kind(kind, p.lineno(1))
1344695
def standard_parsing_functions(Block, Tx):
    
    def stream_block(f, block):
        assert isinstance(block, Block)
        block.stream(f)

    def stream_blockheader(f, blockheader):
        assert isinstance(blockheader, Block)
        blockheader.stream_header(f)

    def stream_tx(f, tx):
        assert isinstance(tx, Tx)
        tx.stream(f)

    def parse_int_6(f):
        b = f.read(6) + b'\0\0'
        return struct.unpack(b, "<L")[0]

    def stream_int_6(f, v):
        f.write(struct.pack(v, "<L")[:6])

    more_parsing = [
        ("A", (PeerAddress.parse, lambda f, peer_addr: peer_addr.stream(f))),
        ("v", (InvItem.parse, lambda f, inv_item: inv_item.stream(f))),
        ("T", (Tx.parse, stream_tx)),
        ("B", (Block.parse, stream_block)),
        ("z", (Block.parse_as_header, stream_blockheader)),
        ("1", (lambda f: struct.unpack("B", f.read(1))[0], lambda f, v: f.write(struct.pack("B", v)))),
        ("6", (parse_int_6, stream_int_6)),
        ("O", (lambda f: True if f.read(1) else False,
               lambda f, v: f.write(b'' if v is None else struct.pack("B", v)))),
    ]
    all_items = list(STREAMER_FUNCTIONS.items())
    all_items.extend(more_parsing)
    return all_items
560971
def get_extra_functions(self) -> Dict[str, Callable]:
        
        methods = {}
        for mName in dir(self):
            m = getattr(self, mName)
            if callable(m) and getattr(m, "extra_fn", False):
                methods[mName] = m
        return methods
1028973
def differing_functions(self):
        
        different_funcs = []
        for (func_a, func_b) in self.function_matches:
            if not self.functions_probably_identical(func_a, func_b):
                different_funcs.append((func_a, func_b))
        return different_funcs
1156187
def memoize(fn):
    ''''''

    cache = {}

    @wraps(fn)
    def wrapped_function(*args):
        if args in cache:
            return cache[args]

        else:
            result = fn(*args)
            cache[args] = result
            return result

    return wrapped_function
1139838
def get_function_pars(fn):
    

    pars = []
    par_names = pyLike.StringVector()
    fn.getParamNames(par_names)

    for pname in par_names:

        par = fn.getParam(pname)
        bounds = par.getBounds()
        perr = par.error() if par.isFree() else np.nan
        pars += [dict(name=pname,
                      value=par.getValue(),
                      error=perr,
                      min=bounds[0],
                      max=bounds[1],
                      free=par.isFree(),
                      scale=par.getScale())]

    return pars
672628
def fitted_function(self):
        
        function = self.function
        fitted_parameters = self.fitted_parameters
        return lambda x: function(x, *fitted_parameters)
606403
def _scan_block(self, cfg_job):
        

        addr = cfg_job.addr
        current_func_addr = cfg_job.func_addr

        # Fix the function address
        # This is for rare cases where we cannot successfully determine the end boundary of a previous function, and
        # as a consequence, our analysis mistakenly thinks the previous function goes all the way across the boundary,
        # resulting the missing of the second function in function manager.
        if addr in self._function_addresses_from_symbols:
            current_func_addr = addr

        if self._addr_hooked_or_syscall(addr):
            entries = self._scan_procedure(cfg_job, current_func_addr)

        else:
            entries = self._scan_irsb(cfg_job, current_func_addr)

        return entries
170339
def function_doc(function_index=1, function_name=None):
    
    frm = func_frame(function_index + 1, function_name)
    try:
        func = getattr(frm.f_locals['self'], frm.f_code.co_name)
    except:
        func = frm.f_globals[frm.f_code.co_name]
    return func.__doc__
1009060
def _function(self, x, a, b, c, d):
        
        return c/((a**2-x**2)**2 + (b*x)**2)+d
519537
def p_function_body(p):
    ''''''
    assert p[1].kind == 'compound'

    p[0] = p[1]
    if len(p) == 3:
        p[0].redirects.extend(p[2])
        assert p[0].pos[0] < p[0].redirects[-1].pos[1]
        p[0].pos = (p[0].pos[0], p[0].redirects[-1].pos[1])
935491
def create_function_f_i(self):
        """"""
        return ca.Function(
            'f_i',
            [self.t, self.x, self.y, self.m, self.p, self.c, self.pre_c, self.ng, self.nu],
            [self.f_i],
            ['t', 'x', 'y', 'm', 'p', 'c', 'pre_c', 'ng', 'nu'], ['x_n'], self.func_opt)
1020928
def function_parameters(function):
    
    if not callable(function):
        raise TypeError(
            'function_parameters(function=%s) you must pass a function' % (
                function
            )
        )
    def wrapper(*args, **kwargs):
        if function.__doc__ is not None:
            if len(function.__doc__) > 3 and len(
                    args) + len(kwargs) + len(
                        function.__defaults__ if function.__defaults__ else ''
                        ) >= len(getParaList(function)):
                paras_index = [p for p in getParaList(
                    function) if p not in kwargs.keys()]
                for content in [i.split('))')[0
                ] for i in function.__doc__.replace(
                    ' ', '').split('((') if ':' in i and i.split(
                        ':')[0] in paras_index or i.split(':'
                        )[0] in kwargs.keys()]:
                    con = content.split(':')
                    if con[0] in kwargs.keys() or len(args) > paras_index.index(con[0]):
                        # To avoid default parameters
                        try:
                            if not isinstance(eval(con[1]), type):
                                raise TypeError()
                        except Exception:
                            raise TypeError(
                                "function_parameters(%s(%s=%s)) " % (
                                    getsourcefile(function) + 
                                    ' ' + function.__name__,
                                    con[0], con[1]
                                ) + "wrong type given in __doc__" 
                            )
                        received_arg = kwargs.get(con[0])
                        if not received_arg and con[0] in paras_index:
                            # to avoid kwarg when it's arg
                            received_arg = args[paras_index.index(con[0])]
                        if type(received_arg) != eval(con[1]):
                            raise TypeError(
                                "%s(%s=%s) requires type %s" % (
                                    getsourcefile(function) + 
                                    ' ' + function.__name__,
                                    con[0], type(received_arg),
                                    eval(con[1])
                                )
                            )
        return function(*args, **kwargs)
    return wrapper
1154070
def function_info(self, functionKey):
        """"""
        node_type = 'function'
        filename, line_number, function_name = functionKey
        if function_name == '<module>':
            modulePath, moduleName = osp.split(filename)
            node_type = 'module'
            if moduleName == '__init__.py':
                modulePath, moduleName = osp.split(modulePath)
            function_name = '<' + moduleName + '>'
        if not filename or filename == '~':
            file_and_line = '(built-in)'
            node_type = 'builtin'
        else:
            if function_name == '__init__':
                node_type = 'constructor'                
            file_and_line = '%s : %d' % (filename, line_number)
        return filename, line_number, function_name, file_and_line, node_type