class StaticInitMerger extends ClassVisitor {

  private String name;

  private MethodVisitor clinit;

  private final String prefix;

  private int counter;

  public StaticInitMerger(final String prefix, final ClassVisitor cv) {
    this(Opcodes.ASM4, prefix, cv);
  }

  protected StaticInitMerger(final int api, final String prefix, final ClassVisitor cv) {
    super(api, cv);
    this.prefix = prefix;
  }

  @Override
  public void visit(final int version, final int access, final String name, final String signature,
      final String superName, final String[] interfaces) {
    cv.visit(version, access, name, signature, superName, interfaces);
    this.name = name;
  }

  @Override
  public MethodVisitor visitMethod(final int access, final String name, final String desc,
      final String signature, final String[] exceptions) {<FILL_FUNCTION_BODY>}

  @Override
  public void visitEnd() {
    if (clinit != null) {
      clinit.visitInsn(Opcodes.RETURN);
      clinit.visitMaxs(0, 0);
    }
    cv.visitEnd();
  }
}

    MethodVisitor mv;
    if ("<clinit>".equals(name)) {
      int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC;
      String n = prefix + counter++;
      mv = cv.visitMethod(a, n, desc, signature, exceptions);

      if (clinit == null) {
        clinit = cv.visitMethod(a, name, desc, null, null);
      }
      clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc);
    } else {
      mv = cv.visitMethod(access, name, desc, signature, exceptions);
    }
    return mv;
  
<methods>public void <init>(int) ,public void <init>(int, com.googlecode.aviator.asm.ClassVisitor) ,public void visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) ,public com.googlecode.aviator.asm.AnnotationVisitor visitAnnotation(java.lang.String, boolean) ,public void visitAttribute(com.googlecode.aviator.asm.Attribute) ,public void visitEnd() ,public com.googlecode.aviator.asm.FieldVisitor visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) ,public void visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int) ,public com.googlecode.aviator.asm.MethodVisitor visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) ,public void visitOuterClass(java.lang.String, java.lang.String, java.lang.String) ,public void visitSource(java.lang.String, java.lang.String) <variables>protected final non-sealed int api,protected com.googlecode.aviator.asm.ClassVisitor cv