code: public static InsnList cloneInsnList(InsnList insnList, Set<LabelNode> globalLabels) {
          Validate.notNull(insnList);
  
          // remap all labelnodes
          Map<LabelNode, LabelNode> labelNodeMapping = new HashMap<>();
          ListIterator<AbstractInsnNode> it = insnList.iterator();
          while (it.hasNext()) {
              AbstractInsnNode abstractInsnNode = it.next();
              if (abstractInsnNode instanceof LabelNode) {
                  LabelNode existingLabelNode = (LabelNode) abstractInsnNode;
                  labelNodeMapping.put(existingLabelNode, new LabelNode());
              }
          }
          
          // override remapping such that global labels stay the same
          for (LabelNode globalLabel : globalLabels) {
              labelNodeMapping.put(globalLabel, globalLabel);
          }
          
          // clone
          InsnList ret = new InsnList();
          it = insnList.iterator();
          while (it.hasNext()) {
              AbstractInsnNode abstractInsnNode = it.next();
              ret.add(abstractInsnNode.clone(labelNodeMapping));
          }
  
          return ret;
      }
docs: Clones an instruction list. All labels are remapped unless otherwise specified in {@code globalLabels}.
  @param insnList instruction list to clone
  @param globalLabels set of labels that should not be remapped
  @throws NullPointerException if any argument is {@code null}
  @return instruction list with cloned instructions