def METHOD_NAME(profile):
    """Returns the most common opcodes in order of descending frequency.
    The result is a list of tuples of the form
      (opcode, opname, # of occurrences)
    """
    if has_pairs(profile) and profile:
        inst_list = profile[-1]
    else:
        inst_list = profile
    result = [(op, opcode.opname[op], count)
              for op, count in enumerate(inst_list)
              if count > 0]
    result.sort(key=operator.itemgetter(2), reverse=True)
    return result