'Search for a gadget which matches the specified criteria.
Arguments:
move(int): Minimum number of bytes by which the stack
pointer is adjusted.
regs(list): Minimum list of registers which are popped off the
stack.
order(str): Either the string \'size\' or \'regs\'. Decides how to
order multiple gadgets the fulfill the requirements.
The search will try to minimize the number of bytes popped more than
requested, the number of registers touched besides the requested and
the address.
If ``order == \'size\'``, then gadgets are compared lexicographically
by ``(total_moves, total_regs, addr)``, otherwise by ``(total_regs, total_moves, addr)``.
Returns:
A :class:`.Gadget` object'

def search(self, move=0, regs=None, order='size'):

    matches = self.search_iter(move, regs)
    if (matches is None):
        return None
    key = {'size': (lambda g: (g.move, len(g.regs), g.address)), 'regs': (lambda g: (len(g.regs), g.move, g.address))}[order]
    try:
        result = min(matches, key=key)
    except ValueError:
        return None
    if (move and (result.move == 9999999999)):
        return None
    return result
