@Override
	public void transform(@Nonnull JvmTransformerContext context, @Nonnull Workspace workspace,
	                      @Nonnull WorkspaceResource resource, @Nonnull JvmClassBundle bundle,
	                      @Nonnull JvmClassInfo initialClassState) throws TransformationException {
		boolean dirty = false;
		String className = initialClassState.getName();
		ClassNode node = context.getNode(bundle, initialClassState);
		for (MethodNode method : node.methods) {
			// Skip if abstract.
			InsnList instructions = method.instructions;
			if (instructions == null)
				continue;

			for (int i = instructions.size() - 2; i >= 0; i--) {
				AbstractInsnNode insn = instructions.get(i);

				// TODO: Make this not shit, just getting this to work for the demo cases in the transformer tests.
				//  - A more proper implementation will have the same behavior, but with more proper edge case handling
				if (isSupportedValueProducer(insn) && insn.getNext().getOpcode() == POP) {
					instructions.remove(insn.getNext());
					instructions.remove(insn);
					dirty = true;
				}
			}
		}
		if (dirty)
			context.setNode(bundle, initialClassState, node);
	}
A transformer that folds redundant stack operations.

@author Matt Coley
recaf-core/src/main/java/software/coley/recaf/services/deobfuscation/transform/generic/StackOperationFoldingTransformer.java