Program: 83635
Project: 83635
Buggy source:
@Override public void writeStatement(MethodWriter writer) throws BytecodeException {
  org.objectweb.asm.Label startLabel=this.startLabel.target=new org.objectweb.asm.Label();
  org.objectweb.asm.Label updateLabel=this.updateLabel.target=new org.objectweb.asm.Label();
  org.objectweb.asm.Label endLabel=this.endLabel.target=new org.objectweb.asm.Label();
  Variable var=this.variable;
switch (this.type) {
case DEFAULT:
{
      int locals=writer.localCount();
      if (var != null) {
        var.writeInit(writer,var.value);
      }
      writer.writeTargetLabel(startLabel);
      if (this.condition != null) {
        this.condition.writeInvJump(writer,endLabel);
      }
      if (this.then != null) {
        this.then.writeStatement(writer);
      }
      writer.writeLabel(updateLabel);
      if (this.update != null) {
        this.update.writeStatement(writer);
      }
      writer.writeJumpInsn(Opcodes.GOTO,startLabel);
      writer.resetLocals(locals);
      writer.writeLabel(endLabel);
      if (var != null) {
        var.writeLocal(writer,startLabel,endLabel);
      }
      return;
    }
case ARRAY:
{
    Variable arrayVar=this.var3;
    Variable indexVar=this.var1;
    Variable lengthVar=this.var2;
    org.objectweb.asm.Label scopeLabel=new org.objectweb.asm.Label();
    writer.writeLabel(scopeLabel);
    var.value.writeExpression(writer);
    int locals=writer.localCount();
    writer.writeInsn(Opcodes.DUP);
    arrayVar.writeInit(writer,null);
    writer.writeInsn(Opcodes.ARRAYLENGTH);
    lengthVar.writeInit(writer,null);
    writer.writeLDC(0);
    indexVar.writeInit(writer,null);
    writer.writeJumpInsn(Opcodes.GOTO,updateLabel);
    writer.writeTargetLabel(startLabel);
    arrayVar.writeGet(writer,null);
    indexVar.writeGet(writer,null);
    writer.writeInsn(var.type.getArrayLoadOpcode());
    var.writeInit(writer,null);
    if (this.then != null) {
      this.then.writeStatement(writer);
    }
    writer.writeIINC(indexVar.index,1);
    writer.writeLabel(updateLabel);
    indexVar.writeGet(writer,null);
    lengthVar.writeGet(writer,null);
    writer.writeJumpInsn(Opcodes.IF_ICMPLT,startLabel);
    writer.resetLocals(locals);
    writer.writeLabel(endLabel);
    var.writeLocal(writer,scopeLabel,endLabel);
    indexVar.writeLocal(writer,scopeLabel,endLabel);
    lengthVar.writeLocal(writer,scopeLabel,endLabel);
    arrayVar.writeLocal(writer,scopeLabel,endLabel);
    return;
  }
case STRING:
{
  Variable stringVar=this.var3;
  Variable indexVar=this.var1;
  Variable lengthVar=this.var2;
  org.objectweb.asm.Label scopeLabel=new org.objectweb.asm.Label();
  writer.writeLabel(scopeLabel);
  var.value.writeExpression(writer);
  int locals=writer.localCount();
  writer.writeInsn(Opcodes.DUP);
  stringVar.writeInit(writer,null);
  writer.writeInvokeInsn(Opcodes.INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
  lengthVar.writeInit(writer,null);
  writer.writeLDC(0);
  indexVar.writeInit(writer,null);
  writer.writeJumpInsn(Opcodes.GOTO,updateLabel);
  writer.writeTargetLabel(startLabel);
  stringVar.writeGet(writer,null);
  indexVar.writeGet(writer,null);
  writer.writeInvokeInsn(Opcodes.INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
  var.writeInit(writer,null);
  if (this.then != null) {
    this.then.writeStatement(writer);
  }
  writer.writeIINC(indexVar.index,1);
  writer.writeLabel(updateLabel);
  indexVar.writeGet(writer,null);
  lengthVar.writeGet(writer,null);
  writer.writeJumpInsn(Opcodes.IF_ICMPLT,startLabel);
  writer.resetLocals(locals);
  writer.writeLabel(endLabel);
  var.writeLocal(writer,scopeLabel,endLabel);
  indexVar.writeLocal(writer,scopeLabel,endLabel);
  lengthVar.writeLocal(writer,scopeLabel,endLabel);
  stringVar.writeLocal(writer,scopeLabel,endLabel);
  return;
}
case ITERATOR:
{
Variable iteratorVar=this.var1;
org.objectweb.asm.Label scopeLabel=new org.objectweb.asm.Label();
writer.writeLabel(scopeLabel);
var.value.writeExpression(writer);
writer.writeInvokeInsn(Opcodes.INVOKEINTERFACE,"String_Node_Str","String_Node_Str","String_Node_Str",true);
int locals=writer.localCount();
var.index=locals;
iteratorVar.index=locals + 1;
writer.writeVarInsn(Opcodes.ASTORE,iteratorVar.index);
writer.writeJumpInsn(Opcodes.GOTO,updateLabel);
writer.writeTargetLabel(startLabel);
writer.writeVarInsn(Opcodes.ALOAD,iteratorVar.index);
writer.writeInvokeInsn(Opcodes.INVOKEINTERFACE,"String_Node_Str","String_Node_Str","String_Node_Str",true);
if (!var.type.equals(Types.OBJECT)) {
  writer.writeTypeInsn(Opcodes.CHECKCAST,var.type.getInternalName());
}
writer.writeVarInsn(Opcodes.ASTORE,var.index);
if (this.then != null) {
  this.then.writeStatement(writer);
}
writer.writeLabel(updateLabel);
writer.writeVarInsn(Opcodes.ALOAD,iteratorVar.index);
writer.writeInvokeInsn(Opcodes.INVOKEINTERFACE,"String_Node_Str","String_Node_Str","String_Node_Str",true);
writer.writeJumpInsn(Opcodes.IFNE,startLabel);
writer.resetLocals(locals);
writer.writeLabel(endLabel);
var.writeLocal(writer,scopeLabel,endLabel);
iteratorVar.writeLocal(writer,scopeLabel,endLabel);
}
}
}

Fixed version (ground truth):
@Override public void writeStatement(MethodWriter writer) throws BytecodeException {
  org.objectweb.asm.Label startLabel=this.startLabel.target=new org.objectweb.asm.Label();
  org.objectweb.asm.Label updateLabel=this.updateLabel.target=new org.objectweb.asm.Label();
  org.objectweb.asm.Label endLabel=this.endLabel.target=new org.objectweb.asm.Label();
  Variable var=this.variable;
switch (this.type) {
case DEFAULT:
{
      int locals=writer.localCount();
      if (var != null) {
        var.writeInit(writer,var.value);
      }
      writer.writeTargetLabel(startLabel);
      if (this.condition != null) {
        this.condition.writeInvJump(writer,endLabel);
      }
      if (this.then != null) {
        this.then.writeStatement(writer);
      }
      writer.writeLabel(updateLabel);
      if (this.update != null) {
        this.update.writeStatement(writer);
      }
      writer.writeJumpInsn(Opcodes.GOTO,startLabel);
      writer.resetLocals(locals);
      writer.writeLabel(endLabel);
      if (var != null) {
        var.writeLocal(writer,startLabel,endLabel);
      }
      return;
    }
case ARRAY:
{
    Variable arrayVar=this.var3;
    Variable indexVar=this.var1;
    Variable lengthVar=this.var2;
    org.objectweb.asm.Label scopeLabel=new org.objectweb.asm.Label();
    writer.writeLabel(scopeLabel);
    var.value.writeExpression(writer);
    int locals=writer.localCount();
    writer.writeInsn(Opcodes.DUP);
    arrayVar.writeInit(writer,null);
    writer.writeInsn(Opcodes.ARRAYLENGTH);
    lengthVar.writeInit(writer,null);
    writer.writeLDC(0);
    indexVar.writeInit(writer,null);
    writer.writeJumpInsn(Opcodes.GOTO,updateLabel);
    writer.writeTargetLabel(startLabel);
    arrayVar.writeGet(writer,null);
    indexVar.writeGet(writer,null);
    writer.writeInsn(var.type.getArrayLoadOpcode());
    var.writeInit(writer,null);
    if (this.then != null) {
      this.then.writeStatement(writer);
    }
    writer.writeIINC(indexVar.index,1);
    writer.writeLabel(updateLabel);
    indexVar.writeGet(writer,null);
    lengthVar.writeGet(writer,null);
    writer.writeJumpInsn(Opcodes.IF_ICMPLT,startLabel);
    writer.resetLocals(locals);
    writer.writeLabel(endLabel);
    var.writeLocal(writer,scopeLabel,endLabel);
    indexVar.writeLocal(writer,scopeLabel,endLabel);
    lengthVar.writeLocal(writer,scopeLabel,endLabel);
    arrayVar.writeLocal(writer,scopeLabel,endLabel);
    return;
  }
case STRING:
{
  Variable stringVar=this.var3;
  Variable indexVar=this.var1;
  Variable lengthVar=this.var2;
  org.objectweb.asm.Label scopeLabel=new org.objectweb.asm.Label();
  writer.writeLabel(scopeLabel);
  var.value.writeExpression(writer);
  int locals=writer.localCount();
  writer.writeInsn(Opcodes.DUP);
  stringVar.writeInit(writer,null);
  writer.writeInvokeInsn(Opcodes.INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
  lengthVar.writeInit(writer,null);
  writer.writeLDC(0);
  indexVar.writeInit(writer,null);
  writer.writeJumpInsn(Opcodes.GOTO,updateLabel);
  writer.writeTargetLabel(startLabel);
  stringVar.writeGet(writer,null);
  indexVar.writeGet(writer,null);
  writer.writeInvokeInsn(Opcodes.INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
  var.writeInit(writer,null);
  if (this.then != null) {
    this.then.writeStatement(writer);
  }
  writer.writeIINC(indexVar.index,1);
  writer.writeLabel(updateLabel);
  indexVar.writeGet(writer,null);
  lengthVar.writeGet(writer,null);
  writer.writeJumpInsn(Opcodes.IF_ICMPLT,startLabel);
  writer.resetLocals(locals);
  writer.writeLabel(endLabel);
  var.writeLocal(writer,scopeLabel,endLabel);
  indexVar.writeLocal(writer,scopeLabel,endLabel);
  lengthVar.writeLocal(writer,scopeLabel,endLabel);
  stringVar.writeLocal(writer,scopeLabel,endLabel);
  return;
}
case ITERATOR:
{
Variable iteratorVar=this.var1;
org.objectweb.asm.Label scopeLabel=new org.objectweb.asm.Label();
writer.writeLabel(scopeLabel);
var.value.writeExpression(writer);
writer.writeInvokeInsn(Opcodes.INVOKEINTERFACE,"String_Node_Str","String_Node_Str","String_Node_Str",true);
int locals=writer.localCount();
var.index=locals + 1;
writer.writeVarInsn(Opcodes.ASTORE,iteratorVar.index=locals);
writer.writeJumpInsn(Opcodes.GOTO,updateLabel);
writer.writeTargetLabel(startLabel);
writer.writeVarInsn(Opcodes.ALOAD,iteratorVar.index);
writer.writeInvokeInsn(Opcodes.INVOKEINTERFACE,"String_Node_Str","String_Node_Str","String_Node_Str",true);
if (!var.type.equals(Types.OBJECT)) {
  writer.writeTypeInsn(Opcodes.CHECKCAST,var.type.getInternalName());
}
writer.writeVarInsn(Opcodes.ASTORE,var.index);
if (this.then != null) {
  this.then.writeStatement(writer);
}
writer.writeLabel(updateLabel);
writer.writeVarInsn(Opcodes.ALOAD,iteratorVar.index);
writer.writeInvokeInsn(Opcodes.INVOKEINTERFACE,"String_Node_Str","String_Node_Str","String_Node_Str",true);
writer.writeJumpInsn(Opcodes.IFNE,startLabel);
writer.resetLocals(locals);
writer.writeLabel(endLabel);
var.writeLocal(writer,scopeLabel,endLabel);
iteratorVar.writeLocal(writer,scopeLabel,endLabel);
}
}
}