(self, function)
:param angr.knowledge.Function function:
        :return:
def _optimize_function(self, function):
        """

        :param angr.knowledge.Function function:
        :return:
        """

        #if function.addr != 0x8048250:
        #    return

        func_kb = KnowledgeBase(self.project)

        # switch to non-optimized IR, since optimized IR will optimize away register reads/writes
        # for example,
        # .text:08048285 add     eax, [ebp+var_8]
        # .text:08048288 mov     [ebp+var_C], eax
        # becomes
        #    06 | ------ IMark(0x8048285, 3, 0) ------
        #    07 | t25 = Add32(t24,0xfffffff8)
        #    08 | t5 = LDle:I32(t25)
        #    09 | t4 = Add32(t2,t5)
        #    10 | PUT(eip) = 0x08048288
        #    11 | ------ IMark(0x8048288, 3, 0) ------
        #    12 | t27 = Add32(t24,0xfffffff4)
        #    13 | STle(t27) = t4
        #    14 | PUT(eip) = 0x0804828b
        # there is no write to or read from eax

        cfg = self.project.analyses.CFGEmulated(kb=func_kb,
                                                call_depth=1,
                                                base_graph=function.graph,
                                                keep_state=True,
                                                starts=(function.addr,),
                                                iropt_level=0,
                                                )

        ddg = self.project.analyses.DDG(kb=func_kb,
                                        cfg=cfg
                                        )

        if 'constant_propagation' in self._techniques:
            self._constant_propagation(function, ddg.simplified_data_graph)
        if 'redundant_stack_variable_removal' in self._techniques:
            self._redundant_stack_variable_removal(function, ddg.simplified_data_graph)
        if 'register_reallocation' in self._techniques:
            self._register_reallocation(function, ddg.simplified_data_graph)
        if 'dead_assignment_elimination' in self._techniques:
            self._dead_assignment_elimination(function, ddg.simplified_data_graph)
def _optimize_function ( self , function ) : #if function.addr != 0x8048250: #    return func_kb = KnowledgeBase ( self . project ) # switch to non-optimized IR, since optimized IR will optimize away register reads/writes # for example, # .text:08048285 add     eax, [ebp+var_8] # .text:08048288 mov     [ebp+var_C], eax # becomes #    06 | ------ IMark(0x8048285, 3, 0) ------ #    07 | t25 = Add32(t24,0xfffffff8) #    08 | t5 = LDle:I32(t25) #    09 | t4 = Add32(t2,t5) #    10 | PUT(eip) = 0x08048288 #    11 | ------ IMark(0x8048288, 3, 0) ------ #    12 | t27 = Add32(t24,0xfffffff4) #    13 | STle(t27) = t4 #    14 | PUT(eip) = 0x0804828b # there is no write to or read from eax cfg = self . project . analyses . CFGEmulated ( kb = func_kb , call_depth = 1 , base_graph = function . graph , keep_state = True , starts = ( function . addr , ) , iropt_level = 0 , ) ddg = self . project . analyses . DDG ( kb = func_kb , cfg = cfg ) if 'constant_propagation' in self . _techniques : self . _constant_propagation ( function , ddg . simplified_data_graph ) if 'redundant_stack_variable_removal' in self . _techniques : self . _redundant_stack_variable_removal ( function , ddg . simplified_data_graph ) if 'register_reallocation' in self . _techniques : self . _register_reallocation ( function , ddg . simplified_data_graph ) if 'dead_assignment_elimination' in self . _techniques : self . _dead_assignment_elimination ( function , ddg . simplified_data_graph )