:return: an initial state with a symbolic stack and good options for rop
346926
def make_initial_state(project, stack_length):
        
        initial_state = project.factory.blank_state(
            add_options={options.AVOID_MULTIVALUED_READS, options.AVOID_MULTIVALUED_WRITES,
                         options.NO_SYMBOLIC_JUMP_RESOLUTION, options.CGC_NO_SYMBOLIC_RECEIVE_LENGTH,
                         options.NO_SYMBOLIC_SYSCALL_RESOLUTION, options.TRACK_ACTION_HISTORY},
            remove_options=options.resilience | options.simplification)
        initial_state.options.discard(options.CGC_ZERO_FILL_UNCONSTRAINED_MEMORY)
        initial_state.options.update({options.TRACK_REGISTER_ACTIONS, options.TRACK_MEMORY_ACTIONS,
                                      options.TRACK_JMP_ACTIONS, options.TRACK_CONSTRAINT_ACTIONS})
        symbolic_stack = initial_state.solver.BVS("symbolic_stack", project.arch.bits * stack_length)
        initial_state.memory.store(initial_state.regs.sp, symbolic_stack)
        if initial_state.arch.bp_offset != initial_state.arch.sp_offset:
            initial_state.regs.bp = initial_state.regs.sp + 20 * initial_state.arch.bytes
        initial_state.solver._solver.timeout = 500  # only solve for half a second at most
        return initial_state
130020
def concatenate(*fsms):
		'''
			
		'''
		alphabet = set().union(*[fsm.alphabet for fsm in fsms])

		def connect_all(i, substate):
			'''
				Take a state in the numbered FSM and return a set containing it, plus
				(if it's final) the first state from the next FSM, plus (if that's
				final) the first state from the next but one FSM, plus...
			'''
			result = {(i, substate)}
			while i < len(fsms) - 1 and substate in fsms[i].finals:
				i += 1
				substate = fsms[i].initial
				result.add((i, substate))
			return result

		# Use a superset containing states from all FSMs at once.
		# We start at the start of the first FSM. If this state is final in the
		# first FSM, then we are also at the start of the second FSM. And so on.
		initial = set()
		if len(fsms) > 0:
			initial.update(connect_all(0, fsms[0].initial))
		initial = frozenset(initial)

		def final(state):
			'''If you're in a final state of the final FSM, it's final'''
			for (i, substate) in state:
				if i == len(fsms) - 1 and substate in fsms[i].finals:
					return True
			return False

		def follow(current, symbol):
			'''
				Follow the collection of states through all FSMs at once, jumping to the
				next FSM if we reach the end of the current one
				TODO: improve all follow() implementations to allow for dead metastates?
			'''
			next = set()
			for (i, substate) in current:
				fsm = fsms[i]
				if substate in fsm.map and symbol in fsm.map[substate]:
					next.update(connect_all(i, fsm.map[substate][symbol]))
			if len(next) == 0:
				raise OblivionError
			return frozenset(next)

		return crawl(alphabet, initial, final, follow).reduce()
327227
def checkInitialState(self,initialState):
        
        assert initialState is not None, "Initial state has not been specified."
        assert isinstance(initialState,(int,list,tuple,np.ndarray,set)), "initialState %r is not an int, tuple, list, set or numpy array" % initialState

         
        if isinstance(initialState,list): 
            #Check whether all entries of the list are ints. Return an int if the len ==1, otherwise a tuple.
            assert all(isinstance(i, int) for i in initialState), "initialState %r is not integer" % initialState 
            initialState = int(initialState) if len(initialState)==1 else tuple(initialState)          

        elif isinstance(initialState,tuple): 
            #Check whether all entries are ints. Return an int if the len ==1, otherwise a tuple.
            assert all(isinstance(i, int) for i in initialState), "initialState %r is not integer" % initialState
            if len(initialState)==1:
                initialState = int(initialState)     
        
        elif isinstance(initialState,np.ndarray):
            #Check whether the state is a 1d numpy array. Return an int if it has length 1.
            assert issubclass(initialState.dtype.type, np.integer) and initialState.ndim==1, "initialState %r is not a one-dimensional integer numpy array" % initialState 
            initialState = int(initialState) if len(initialState)==1 else tuple(initialState)
            
        elif isinstance(initialState,set):
            #If we have a set, then check whether all elements are ints or tuples.
            for state in initialState:                
                assert isinstance(state,(tuple,int)), "the set initialState %r should contain tuples or ints" % initialState 
                if isinstance(state,tuple):
                    assert all(isinstance(i,int) for i in state), "the state %r should be integer" % initialState 
                
        return initialState
236326
def init_state(self, x):
    
    optim_state = {}
    optim_state["t"] = 0.
    optim_state["m"] = [tf.zeros_like(v) for v in x]
    optim_state["u"] = [tf.zeros_like(v) for v in x]
    return optim_state
913094
def initialize_state?(object)
      value = read(object, :state)
      (value.nil? || value.respond_to?(:empty?) && value.empty?) && !states[value, :value]
    end
1194700
def _initialize_parameters(state_machine, n_features):
        
        return np.zeros((state_machine.n_states 
                         + state_machine.n_transitions,
                         n_features))
82420
def init(celf, *, loop = None, unregister = None, message = None) :
        ""
        return \
            celf \
              (
                loop = loop,
                unregister = unregister,
                message = message,
              )
775140
def _lazily_initialize(self):
    """"""
    # TODO(nickfelt): remove on-demand imports once dep situation is fixed.
    import tensorflow.compat.v1 as tf
    with self._initialization_lock:
      if self._session:
        return
      graph = tf.Graph()
      with graph.as_default():
        self.initialize_graph()
      # Don't reserve GPU because libpng can't run on GPU.
      config = tf.ConfigProto(device_count={'GPU': 0})
      self._session = tf.Session(graph=graph, config=config)
421358
def opt(self, x_init, f_fp=None, f=None, fp=None):
        
        rcstrings = ['','Maximum number of iterations exceeded', 'Gradient and/or function calls not changing']

        opt_dict = {}
        if self.xtol is not None:
            print("WARNING: bfgs doesn't have an xtol arg, so I'm going to ignore it")
        if self.ftol is not None:
            print("WARNING: bfgs doesn't have an ftol arg, so I'm going to ignore it")
        if self.gtol is not None:
            opt_dict['gtol'] = self.gtol

        opt_result = optimize.fmin_bfgs(f, x_init, fp, disp=self.messages,
                                            maxiter=self.max_iters, full_output=True, **opt_dict)
        self.x_opt = opt_result[0]
        self.f_opt = f_fp(self.x_opt)[0]
        self.funct_eval = opt_result[4]
        self.status = rcstrings[opt_result[6]]
1118711
def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
                    trainable_initializers=None, trainable_regularizers=None,
                    name=None):
    """"""
    core_initial_state = self._core.initial_state(
        batch_size, dtype=dtype, trainable=trainable,
        trainable_initializers=trainable_initializers,
        trainable_regularizers=trainable_regularizers, name=name)

    dropout_masks = [None] * len(self._dropout_state_size)
    def set_dropout_mask(index, state, keep_prob):
      if index is not None:
        ones = tf.ones_like(state, dtype=dtype)
        dropout_masks[index] = tf.nn.dropout(ones, keep_prob=keep_prob)
    tf.contrib.framework.nest.map_structure(
        set_dropout_mask,
        self._dropout_indexes, core_initial_state, self._keep_probs)

    return core_initial_state, dropout_masks
1306217
def _get_initial_returning(self):
        

        hooker = None
        if self.is_syscall:
            hooker = self.project.simos.syscall_from_addr(self.addr)
        elif self.is_simprocedure:
            hooker = self.project.hooked_by(self.addr)
        if hooker and hasattr(hooker, 'NO_RET'):
            return not hooker.NO_RET

        # Cannot determine
        return None
1219146
def _init_lsr(n_items, alpha, initial_params):
    """"""
    if initial_params is None:
        weights = np.ones(n_items)
    else:
        weights = exp_transform(initial_params)
    chain = alpha * np.ones((n_items, n_items), dtype=float)
    return weights, chain
486393
def _init(self):
        
        assert self._name
        assert self._group

        # self.n = 0
        self.u = []
        self.name = []
        self.idx = []
        self.uid = {}

        if not self._unamey:
            self._unamey = self._algebs
        else:
            assert len(self._unamey) == len(self._algebs)

        if not self._unamex:
            self._unamex = self._states
        else:
            assert len(self._unamex) == len(self._states)

        for item in self._data.keys():
            self.__dict__[item] = []

        for bus in self._ac.keys():
            for var in self._ac[bus]:
                self.__dict__[var] = []
        for node in self._dc.keys():
            for var in self._dc[node]:
                self.__dict__[var] = []

        for var in self._states + self._algebs + self._service:
            self.__dict__[var] = []

        self._flags['sysbase'] = False
        self._flags['allocate'] = False
        self._flags['address'] = False
745077
def create_initialize(repo, atts)
      @repo = repo
      atts.each do |k, v|
        instance_variable_set("@#{k}".to_sym, v)
      end
      self
    end
699323
def initializerepo(self):
        

        try:
            os.mkdir(self.repopath)
        except OSError:
            pass

        cmd = self.repo.init(bare=self.bare, shared=self.shared)

        if not self.bare:
            self.write_testing_data([], [])
            self.write_training_data([], [])
            self.write_classifier(None)

            cmd = self.repo.add('training.pkl')
            cmd = self.repo.add('testing.pkl')
            cmd = self.repo.add('classifier.pkl')

            cmd = self.repo.commit(m='initial commit')
            cmd = self.repo.tag('initial')
            cmd = self.set_version('initial')
844485
def initial_global_state(self) -> GlobalState:
        """"""
        environment = Environment(
            self.callee_account,
            self.caller,
            self.call_data,
            self.gas_price,
            self.call_value,
            self.origin,
            code=self.code or self.callee_account.code,
        )
        return super().initial_global_state_from_environment(
            environment, active_function="fallback"
        )
404466
def inits_t(wrap):
    
    return Transformation(
        'inits',
        lambda sequence: [wrap(sequence[:i]) for i in reversed(range(len(sequence) + 1))],
        {ExecutionStrategies.PRE_COMPUTE}
    )