Find instruction that matches the mnemonic.

    :param mnemonic: Mnemonic to match
    :return: :class:`Instruction` that matches or None
186703
def reverse_lookup(mnemonic: str):
    
    for i in get_insns():
        if "_mnemonic" in i.__dict__ and i._mnemonic == mnemonic:
            return i

    return None
201085
def get_remembered_identity(self, subject_context):
        
        rmm = self.remember_me_manager
        if rmm is not None:
            try:
                return rmm.get_remembered_identifiers(subject_context)
            except Exception as ex:
                msg = ("Delegate RememberMeManager instance of type [" +
                       rmm.__class__.__name__ + "] raised an exception during "
                       "get_remembered_identifiers().")
                logger.warning(msg, exc_info=True)
        return None
652934
def count_mnemonic(self, mnemonic, uwis=uwis, alias=None):
        
        all_mnemonics = self.get_mnemonics([mnemonic], uwis=uwis, alias=alias)
        return len(list(filter(None, utils.flatten_list(all_mnemonics))))
774501
def to_string(mnemonic):
        
        strings = {
            # Arithmetic Instructions
            ReilMnemonic.ADD: "add",
            ReilMnemonic.SUB: "sub",
            ReilMnemonic.MUL: "mul",
            ReilMnemonic.DIV: "div",
            ReilMnemonic.MOD: "mod",
            ReilMnemonic.BSH: "bsh",

            # Bitwise Instructions
            ReilMnemonic.AND: "and",
            ReilMnemonic.OR:  "or",
            ReilMnemonic.XOR: "xor",

            # Data Transfer Instructions
            ReilMnemonic.LDM: "ldm",
            ReilMnemonic.STM: "stm",
            ReilMnemonic.STR: "str",

            # Conditional Instructions
            ReilMnemonic.BISZ: "bisz",
            ReilMnemonic.JCC:  "jcc",

            # Other Instructions
            ReilMnemonic.UNKN:  "unkn",
            ReilMnemonic.UNDEF: "undef",
            ReilMnemonic.NOP:   "nop",

            # Extensions
            ReilMnemonic.SEXT: "sext",
            ReilMnemonic.SDIV: "sdiv",
            ReilMnemonic.SMOD: "smod",
            ReilMnemonic.SMUL: "smul",
        }

        return strings[mnemonic]
903268
def to_mnemonic(entropy)
      raise ArgumentError, 'entropy is empty.' if entropy.nil? || entropy.empty?
      e = entropy.htb.unpack('B*').first
      seed = e + checksum(e)
      mnemonic_index = seed.chars.each_slice(11).map{|i|i.join.to_i(2)}
      word_master = load_words
      mnemonic_index.map{|i|word_master[i]}
    end
976335
def count(self, *args, **kw):
        
        obj = args[0]
        try:
            memo_dict = obj._memo[self.method_name]
        except KeyError:
            self.miss = self.miss + 1
        else:
            key = self.keymaker(*args, **kw)
            if key in memo_dict:
                self.hit = self.hit + 1
            else:
                self.miss = self.miss + 1
189794
def parse_instruction(string, location, tokens):
    
    prefix_str = tokens.get("prefix", None)
    mnemonic_str = tokens.get("mnemonic")
    operands = [op for op in tokens.get("operands", [])]

    infer_operands_size(operands)

    # Quick hack: Capstone returns rep instead of repe for cmps and scas
    # instructions.
    if prefix_str == "rep" and (mnemonic_str.startswith("cmps") or mnemonic_str.startswith("scas")):
        prefix_str = "repe"

    instr = X86Instruction(
        prefix_str,
        mnemonic_str,
        operands,
        arch_info.architecture_mode
    )

    return instr
978315
def getInstructions(self):
        '''
        
        '''

        self._instructions = self._client.getInstructions(self.setID)
        return self._instructions
232330
def _classify_no_operation(self, regs_init, regs_fini, mem_fini, written_regs, read_regs):
        
        # TODO: Flags should be taken into account

        matches = []

        # Check that registers didn't change their value.
        regs_changed = any(regs_init[r] != regs_fini[r] for r in regs_init)

        # Check that flags didn't change their value.
        flags_changed = False

        # Check that memory didn't change.
        mem_changed = mem_fini.get_write_count() != 0

        if not regs_changed and not flags_changed and not mem_changed:
            matches.append({
                "op": "nop",
            })

        return matches
805480
def matches_pattern(self, other):
        
        properties = self._message_properties()
        ismatch = False
        if isinstance(other, Message) and self.code == other.code:
            for prop in properties:
                for key, prop_val in prop.items():
                    if hasattr(other, key):
                        key_val = getattr(other, key)
                        ismatch = self._test_match(prop_val, key_val)
                    else:
                        ismatch = False
                    if not ismatch:
                        break
                if not ismatch:
                    break
        return ismatch
557658
def learn(self, matches, recall):
        '''
        
        '''
        compound_length = 2

        dupe_cover = Cover(self.blocker.predicates, matches)
        dupe_cover.dominators(cost=self.total_cover)
        dupe_cover.compound(compound_length)

        comparison_count = self.comparisons(dupe_cover, compound_length)

        dupe_cover.dominators(cost=comparison_count, comparison=True)

        coverable_dupes = set.union(*viewvalues(dupe_cover))
        uncoverable_dupes = [pair for i, pair in enumerate(matches)
                             if i not in coverable_dupes]

        epsilon = int((1.0 - recall) * len(matches))

        if len(uncoverable_dupes) > epsilon:
            logger.warning(OUT_OF_PREDICATES_WARNING)
            logger.debug(uncoverable_dupes)
            epsilon = 0
        else:
            epsilon -= len(uncoverable_dupes)

        for pred in dupe_cover:
            pred.count = comparison_count[pred]

        searcher = BranchBound(len(coverable_dupes) - epsilon, 2500)
        final_predicates = searcher.search(dupe_cover)

        logger.info('Final predicate set:')
        for predicate in final_predicates:
            logger.info(predicate)

        return final_predicates
550000
def _delete_instructions(self, instruction, value=None):
        
        if instruction == 'LABEL' and value:
            self._modify_instruction_label(value, None)
            return
        if instruction == 'ENV' and value:
            self._modify_instruction_env(value, None)
            return

        lines = self.lines
        deleted = False
        for insn in reversed(self.structure):
            if insn['instruction'] == instruction:
                if value and insn['value'] != value:
                    continue
                deleted = True
                del lines[insn['startline']:insn['endline'] + 1]
        if deleted:
            self.lines = lines
1127280
public int getMnemonic() {
        int mnemonic = KeyEvent.VK_UNDEFINED;
        if (!MAC_OS_X) {
            int index = getMnemonicIndex();
            if ((index >= 0) && ((index + 1) < myAnnotatedString.length())) {
                mnemonic = Character.toUpperCase(myAnnotatedString.charAt(index + 1));
            }
        }
        return mnemonic;
    }
409537
def _get_match(self, prefix):
        
        # (hard coded) If we match a CPR response, return Keys.CPRResponse.
        # (This one doesn't fit in the ANSI_SEQUENCES, because it contains
        # integer variables.)
        if _cpr_response_re.match(prefix):
            return Keys.CPRResponse

        elif _mouse_event_re.match(prefix):
            return Keys.Vt100MouseEvent

        # Otherwise, use the mappings.
        try:
            return ANSI_SEQUENCES[prefix]
        except KeyError:
            return None
1018166
def _any(self, memory, addr, **kwargs):
        
        return memory.state.solver.eval(addr, exact=kwargs.pop('exact', self._exact), **kwargs)
391884
def read_instruction(fio, start_pos):
    
    op = fio.read(1)

    if not op:
        return None

    op = ord(op)

    ins = opcode_table[op]
    operands = ins['operands']
    name = ins['mnemonic']

    final_operands = []
    # Most opcodes have simple operands.
    if operands:
        for fmt, type_ in operands:
            final_operands.append(
                Operand(
                    type_,
                    fmt.value.unpack(fio.read(fmt.value.size))[0]
                )
            )
    # Special case for lookupswitch.
    elif op == 0xAB:
        # Get rid of the alignment padding.
        padding = 4 - (start_pos + 1) % 4
        padding = padding if padding != 4 else 0
        fio.read(padding)

        # Default branch address and branch count.
        default, npairs = unpack('>ii', fio.read(8))

        pairs = {}
        for _ in repeat(None, npairs):
            match, offset = unpack('>ii', fio.read(8))
            pairs[match] = offset

        final_operands.append(pairs)
        final_operands.append(Operand(OperandTypes.BRANCH, default))
    # Special case for tableswitch
    elif op == 0xAA:
        # Get rid of the alignment padding.
        padding = 4 - (start_pos + 1) % 4
        padding = padding if padding != 4 else 0
        fio.read(padding)

        default, low, high = unpack('>iii', fio.read(12))
        final_operands.append(Operand(OperandTypes.BRANCH, default))
        final_operands.append(Operand(OperandTypes.LITERAL, low))
        final_operands.append(Operand(OperandTypes.LITERAL, high))

        for _ in repeat(None, high - low + 1):
            offset = unpack('>i', fio.read(4))[0]
            final_operands.append(Operand(OperandTypes.BRANCH, offset))
    # Special case for the wide prefix
    elif op == 0xC4:
        real_op = unpack('>B', fio.read(1))[0]
        ins = opcode_table[real_op]
        name = ins['mnemonic']

        final_operands.append(Operand(
            OperandTypes.LOCAL_INDEX,
            unpack('>H', fio.read(2))[0]
        ))
        # Further special case for iinc.
        if real_op == 0x84:
            final_operands.append(Operand(
                OperandTypes.LITERAL,
                unpack('>H', fio.read(2))[0]
            ))

    return Instruction(name, op, final_operands, start_pos)
461178
def matches(self, other):
        
        if not isinstance(other, Failure):
            return False
        if self.exc_info is None or other.exc_info is None:
            return self._matches(other)
        else:
            return self == other