def _annotate_fn_args(stack, fn_opname, nargs, nkw=-1, consume_fn_name=True):
  kwarg_names = []
  if nkw == -1:
    if sys.version_info[0] < 3:
      nargs, nkw = (nargs % 256, 2 * nargs // 256)
    else:
      if fn_opname == 'CALL_FUNCTION_KW':
        if qj._DEBUG_QJ:
          assert len(stack) and stack[-1].opname == 'LOAD_CONST'
        if not len(stack) or stack[-1].opname != 'LOAD_CONST':
          return
        se = stack.pop()
        kwarg_names = se.oparg_repr[::-1]
        se.oparg_repr = ['']
        nkw = len(kwarg_names)
        nargs -= nkw
        if qj._DEBUG_QJ:
          assert nargs >= 0 and nkw > 0
      else:
        nkw = 0
  for i in range(nkw):
    se = stack.pop()
    if se.stack_depth == 0 and (len(se.oparg_repr) == 0 or se.oparg_repr[0] == ''):
      continue
    if i % 2 == 1 and sys.version_info[0] < 3:
      if qj._DEBUG_QJ:
        assert se.opname == 'LOAD_CONST'
      if se.opname == 'LOAD_CONST':
        se.oparg_repr += ['=']
    else:
      pops = []
      if se.opname.startswith('CALL_FUNCTION'):
        _annotate_fn_args(stack[:], se.opname, se.oparg, -1, True)
      pops = _collect_pops(stack, se.stack_depth - 1 if se.opname.startswith('CALL_FUNCTION') else 0, [], False)
      if i > 1 and len(pops):
        pops[-1].oparg_repr += [',']
      if sys.version_info[0] >= 3:
        target_se = pops[-1] if len(pops) else se
        target_se.oparg_repr = [kwarg_names[i], '='] + target_se.oparg_repr
  for i in range(nargs):
    se = stack.pop()
    if se.opname.startswith('CALL_FUNCTION'):
      _annotate_fn_args(stack, se.opname, se.oparg, -1, True)
    elif len(se.oparg_repr) and se.oparg_repr[0] in {']', '}', ')'}:
      if (i > 0 or nkw > 0):
        se.oparg_repr += [',']
    else:
      pops = _collect_pops(stack, se.stack_depth, [], False)
      if (i > 0 or nkw > 0) and len(pops):
        pops[-1].oparg_repr += [',']
  if consume_fn_name:
    _collect_pops(stack, -1, [], False)