def METHOD_NAME(args):
    remaining_args = []
    peers = []
    libs = []
    peers_flag = '--whole-archive-peers'
    libs_flag = '--whole-archive-libs'
    next_is_peer = False
    next_is_lib = False
    for arg in args:
        if arg == peers_flag:
            next_is_peer = True
        elif arg == libs_flag:
            next_is_lib = True
        elif next_is_peer:
            peers.append(arg)
            next_is_peer = False
        elif next_is_lib:
            libs.append(arg)
            next_is_lib = False
        else:
            remaining_args.append(arg)
    return remaining_args, peers, libs