Program: 58405
Project: 58405
Buggy source:
private static byte[] writeWorld(String name,String transformedName,byte[] bytes,ClassReader cr){
  String[] names;
  if (LoadingPlugin.runtimeDeobfEnabled) {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
 else {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
  name=name.replace('.','/');
  ClassNode cn=new ClassNode(ASM5);
  cr.accept(cn,ClassReader.EXPAND_FRAMES);
  final String sig="String_Node_Str";
  MethodNode addTileEntity=null, addTileEntities=null, setTileEntity=null, updateEntities=null, unloadTile=null;
  boolean found=false;
  for (  MethodNode m : cn.methods) {
    if ("String_Node_Str".equals(m.name)) {
      if (sig.equals(m.desc))       found=true;
      LabelNode a=new LabelNode(new Label());
      AbstractInsnNode n=m.instructions.getFirst();
      while (n.getOpcode() != INVOKESPECIAL || !((MethodInsnNode)n).name.equals("String_Node_Str"))       n=n.getNext();
      m.instructions.insert(n,n=a);
      m.instructions.insert(n,n=new LineNumberNode(-15000,a));
      m.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
      m.instructions.insert(n,n=new TypeInsnNode(NEW,"String_Node_Str"));
      m.instructions.insert(n,n=new InsnNode(DUP));
      m.instructions.insert(n,n=new MethodInsnNode(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
      m.instructions.insert(n,n=new FieldInsnNode(PUTFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(m.name) && "String_Node_Str".equals(m.desc)) {
      addTileEntity=m;
    }
 else     if (names[4].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      addTileEntities=m;
    }
 else     if (names[5].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      setTileEntity=m;
    }
 else     if (names[6].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      updateEntities=m;
    }
 else     if (names[9].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      unloadTile=m;
    }
  }
  cn.fields.add(new FieldNode(ACC_PRIVATE | ACC_SYNTHETIC,"String_Node_Str","String_Node_Str",null,null));
  if (unloadTile != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n;
    unloadTile.instructions.insert(n=a);
    unloadTile.instructions.insert(n,n=new LineNumberNode(-15005,a));
    unloadTile.instructions.insert(n,n=new VarInsnNode(ALOAD,1));
    unloadTile.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
  }
  if (addTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n;
    addTileEntity.instructions.insert(n=a);
    addTileEntity.instructions.insert(n,n=new LineNumberNode(-15001,a));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,1));
    addTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (setTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=setTileEntity.instructions.getLast();
    while (n.getOpcode() != RETURN)     n=n.getPrevious();
    n=n.getPrevious();
    setTileEntity.instructions.insert(n=a);
    setTileEntity.instructions.insert(n,n=new LineNumberNode(-15002,a));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    setTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,4));
    setTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    setTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (addTileEntities != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=addTileEntities.instructions.getFirst();
    for (; ; ) {
      while (n.getOpcode() != CHECKCAST)       n=n.getNext();
      if ((((TypeInsnNode)n).desc).equals("String_Node_Str"))       break;
    }
    addTileEntities.instructions.insert(n,n=a);
    addTileEntities.instructions.insert(n,n=new LineNumberNode(-15003,a));
    addTileEntities.instructions.insert(n,n=new InsnNode(DUP));
    addTileEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntities.instructions.insert(n,n=new InsnNode(SWAP));
    addTileEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntities.instructions.insert(n,n=new InsnNode(POP));
  }
  if (updateEntities != null) {
    AbstractInsnNode n=updateEntities.instructions.getFirst();
    while (n.getOpcode() != INVOKEVIRTUAL || !"String_Node_Str".equals(((MethodInsnNode)n).name) || !"String_Node_Str".equals(((MethodInsnNode)n).desc))     n=n.getNext();
    while (n.getOpcode() != PUTFIELD || !names[8].equals(((FieldInsnNode)n).name))     n=n.getPrevious();
    n=n.getNext();
    LabelNode lStart=new LabelNode(new Label());
    LabelNode lCond=new LabelNode(new Label());
    LabelNode lGuard=new LabelNode(new Label());
    LabelNode a=new LabelNode(new Label());
    updateEntities.instructions.insertBefore(n,n=a);
    updateEntities.instructions.insert(n,n=new LineNumberNode(-15004,a));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(GOTO,lCond));
    updateEntities.instructions.insert(n,n=lStart);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new TypeInsnNode(CHECKCAST,"String_Node_Str"));
    updateEntities.instructions.insert(n,n=new InsnNode(DUP));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNULL,lGuard));
    updateEntities.instructions.insert(n,n=new InsnNode(DUP));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str",names[7],"String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFEQ,lGuard));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new InsnNode(ACONST_NULL));
    updateEntities.instructions.insert(n,n=lGuard);
    updateEntities.instructions.insert(n,n=new InsnNode(POP));
    updateEntities.instructions.insert(n,n=lCond);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNE,lStart));
  }
  ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cn.accept(cw);
  if (!found) {
    cw.newMethod(name,"String_Node_Str",sig,true);
    MethodVisitor mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str",sig,null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,0);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitVarInsn(ALOAD,1);
    mv.visitFieldInsn(PUTFIELD,name,names[0],"String_Node_Str");
    mv.visitTypeInsn(NEW,"String_Node_Str");
    mv.visitInsn(DUP);
    mv.visitVarInsn(ALOAD,4);
    mv.visitVarInsn(ALOAD,2);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitFieldInsn(PUTFIELD,name,names[1],"String_Node_Str");
    mv.visitVarInsn(ALOAD,3);
    mv.visitFieldInsn(PUTFIELD,name,names[2],"String_Node_Str");
    mv.visitVarInsn(ALOAD,5);
    mv.visitFieldInsn(PUTFIELD,name,names[3],"String_Node_Str");
    mv.visitInsn(RETURN);
    mv.visitMaxs(11,10);
    mv.visitEnd();
    cw.visitEnd();
  }
  bytes=cw.toByteArray();
  return bytes;
}

Fixed version (ground truth):
private static byte[] writeWorld(String name,String transformedName,byte[] bytes,ClassReader cr){
  String[] names;
  if (LoadingPlugin.runtimeDeobfEnabled) {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
 else {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
  name=transformedName.replace('.','/');
  ClassNode cn=new ClassNode(ASM5);
  cr.accept(cn,ClassReader.EXPAND_FRAMES);
  final String sig="String_Node_Str";
  MethodNode addTileEntity=null, addTileEntities=null, setTileEntity=null, updateEntities=null, unloadTile=null;
  boolean found=false;
  for (  MethodNode m : cn.methods) {
    if ("String_Node_Str".equals(m.name)) {
      if (sig.equals(m.desc))       found=true;
      LabelNode a=new LabelNode(new Label());
      AbstractInsnNode n=m.instructions.getFirst();
      while (n.getOpcode() != INVOKESPECIAL || !((MethodInsnNode)n).name.equals("String_Node_Str"))       n=n.getNext();
      m.instructions.insert(n,n=a);
      m.instructions.insert(n,n=new LineNumberNode(-15000,a));
      m.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
      m.instructions.insert(n,n=new TypeInsnNode(NEW,"String_Node_Str"));
      m.instructions.insert(n,n=new InsnNode(DUP));
      m.instructions.insert(n,n=new MethodInsnNode(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
      m.instructions.insert(n,n=new FieldInsnNode(PUTFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(m.name) && "String_Node_Str".equals(m.desc)) {
      addTileEntity=m;
    }
 else     if (names[4].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      addTileEntities=m;
    }
 else     if (names[5].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      setTileEntity=m;
    }
 else     if (names[6].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      updateEntities=m;
    }
 else     if (names[9].equals(m.name) && "String_Node_Str".equals(m.desc)) {
      unloadTile=m;
    }
  }
  cn.fields.add(new FieldNode(ACC_PRIVATE | ACC_SYNTHETIC,"String_Node_Str","String_Node_Str",null,null));
  if (unloadTile != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n;
    unloadTile.instructions.insert(n=a);
    unloadTile.instructions.insert(n,n=new LineNumberNode(-15005,a));
    unloadTile.instructions.insert(n,n=new VarInsnNode(ALOAD,1));
    unloadTile.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
  }
  if (addTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n;
    addTileEntity.instructions.insert(n=a);
    addTileEntity.instructions.insert(n,n=new LineNumberNode(-15001,a));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,1));
    addTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (setTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=setTileEntity.instructions.getLast();
    while (n.getOpcode() != RETURN)     n=n.getPrevious();
    n=n.getPrevious();
    setTileEntity.instructions.insert(n=a);
    setTileEntity.instructions.insert(n,n=new LineNumberNode(-15002,a));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    setTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,4));
    setTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    setTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (addTileEntities != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=addTileEntities.instructions.getFirst();
    for (; ; ) {
      while (n.getOpcode() != CHECKCAST)       n=n.getNext();
      if ((((TypeInsnNode)n).desc).equals("String_Node_Str"))       break;
    }
    addTileEntities.instructions.insert(n,n=a);
    addTileEntities.instructions.insert(n,n=new LineNumberNode(-15003,a));
    addTileEntities.instructions.insert(n,n=new InsnNode(DUP));
    addTileEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntities.instructions.insert(n,n=new InsnNode(SWAP));
    addTileEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntities.instructions.insert(n,n=new InsnNode(POP));
  }
  if (updateEntities != null) {
    AbstractInsnNode n=updateEntities.instructions.getFirst();
    while (n.getOpcode() != INVOKEVIRTUAL || !"String_Node_Str".equals(((MethodInsnNode)n).name) || !"String_Node_Str".equals(((MethodInsnNode)n).desc))     n=n.getNext();
    while (n.getOpcode() != PUTFIELD || !names[8].equals(((FieldInsnNode)n).name))     n=n.getPrevious();
    n=n.getNext();
    LabelNode lStart=new LabelNode(new Label());
    LabelNode lCond=new LabelNode(new Label());
    LabelNode lGuard=new LabelNode(new Label());
    LabelNode a=new LabelNode(new Label());
    updateEntities.instructions.insertBefore(n,n=a);
    updateEntities.instructions.insert(n,n=new LineNumberNode(-15004,a));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(GOTO,lCond));
    updateEntities.instructions.insert(n,n=lStart);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new TypeInsnNode(CHECKCAST,"String_Node_Str"));
    updateEntities.instructions.insert(n,n=new InsnNode(DUP));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNULL,lGuard));
    updateEntities.instructions.insert(n,n=new InsnNode(DUP));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str",names[7],"String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFEQ,lGuard));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new InsnNode(ACONST_NULL));
    updateEntities.instructions.insert(n,n=lGuard);
    updateEntities.instructions.insert(n,n=new InsnNode(POP));
    updateEntities.instructions.insert(n,n=lCond);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNE,lStart));
  }
  ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cn.accept(cw);
  if (!found) {
    cw.newMethod(name,"String_Node_Str",sig,true);
    MethodVisitor mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str",sig,null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,0);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitVarInsn(ALOAD,1);
    mv.visitFieldInsn(PUTFIELD,name,names[0],"String_Node_Str");
    mv.visitTypeInsn(NEW,"String_Node_Str");
    mv.visitInsn(DUP);
    mv.visitVarInsn(ALOAD,4);
    mv.visitVarInsn(ALOAD,2);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitFieldInsn(PUTFIELD,name,names[1],"String_Node_Str");
    mv.visitVarInsn(ALOAD,3);
    mv.visitFieldInsn(PUTFIELD,name,names[2],"String_Node_Str");
    mv.visitVarInsn(ALOAD,5);
    mv.visitFieldInsn(PUTFIELD,name,names[3],"String_Node_Str");
    mv.visitInsn(RETURN);
    mv.visitMaxs(11,10);
    mv.visitEnd();
    cw.visitEnd();
  }
  bytes=cw.toByteArray();
  return bytes;
}