nus-yam/ex-repair huggingface dataset:
Program: 12772
Project: 12772
Buggy source:
@Override public void onLivingUpdate(){
  if (!this.worldObj.isRemote) {
    if (boss == null) {
      if (bossId != null) {
        lookForBoss();
      }
      if (boss == null) {
        lookForBossTimer++;
      }
      if (lookForBossTimer > MAX_SEARCH_TIME) {
        this.attackEntityFrom(DamageSource.generic,5);
      }
    }
 else     if (!boss.isEntityAlive()) {
      boss=null;
      bossId=null;
    }
 else     if (boss.getDistanceSquared(this) > 1000) {
      if (this.rand.nextInt(80) == 0) {
        this.attackEntityFrom(DamageSource.generic,3);
      }
    }
  }
  super.onLivingUpdate();
}

Fixed version (ground truth):
@Override public void onLivingUpdate(){
  if (!this.worldObj.isRemote) {
    if (boss == null) {
      if (bossId != null) {
        lookForBoss();
      }
      if (boss == null) {
        lookForBossTimer++;
      }
      if (lookForBossTimer > MAX_SEARCH_TIME) {
        this.attackEntityFrom(DamageSource.generic,5);
      }
    }
 else     if (!boss.isTheEntityAlive()) {
      boss=null;
      bossId=null;
    }
 else     if (boss.getTheDistanceSquared(this) > 1000) {
      if (this.rand.nextInt(80) == 0) {
        this.attackEntityFrom(DamageSource.generic,3);
      }
    }
  }
  super.onLivingUpdate();
}
Program: 12773
Project: 12773
Buggy source:
@Override public void setLord(IMinionLord b){
  if (!b.equals(boss)) {
    this.setBossId(b.getPersistentID());
    boss=b;
  }
}

Fixed version (ground truth):
@Override public void setLord(IMinionLord b){
  if (!b.equals(boss)) {
    this.setBossId(b.getThePersistentID());
    boss=b;
  }
}
Program: 12774
Project: 12774
Buggy source:
@Override public void loadPartialUpdate(NBTTagCompound nbt){
  if (nbt.hasKey("String_Node_Str")) {
    Entity e=worldObj.getEntityByID(nbt.getInteger("String_Node_Str"));
    if (e instanceof EntityPlayer) {
      this.boss=VampirePlayer.get((EntityPlayer)e);
    }
 else     if (e instanceof IMinionLord) {
      this.boss=(IMinionLord)e;
    }
 else {
      Logger.w("String_Node_Str","String_Node_Str" + nbt.getInteger("String_Node_Str") + "String_Node_Str"+ e+ "String_Node_Str");
      return;
    }
    this.bossId=this.boss.getPersistentID();
  }
}

Fixed version (ground truth):
@Override public void loadPartialUpdate(NBTTagCompound nbt){
  if (nbt.hasKey("String_Node_Str")) {
    Entity e=worldObj.getEntityByID(nbt.getInteger("String_Node_Str"));
    if (e instanceof EntityPlayer) {
      this.boss=VampirePlayer.get((EntityPlayer)e);
    }
 else     if (e instanceof IMinionLord) {
      this.boss=(IMinionLord)e;
    }
 else {
      Logger.w("String_Node_Str","String_Node_Str" + nbt.getInteger("String_Node_Str") + "String_Node_Str"+ e+ "String_Node_Str");
      return;
    }
    this.bossId=this.boss.getThePersistentID();
  }
}
Program: 12775
Project: 12775
Buggy source:
/** 
 * Returns whether the EntityAIBase should begin execution.
 */
@Override public boolean shouldExecute(){
  boss=((IMinion)entity).getLord();
  if (boss == null) {
    return false;
  }
 else {
    double d0=this.boss.getDistanceSquared(entity);
    return d0 >= MINDIST && d0 <= MAXDIST;
  }
}

Fixed version (ground truth):
/** 
 * Returns whether the EntityAIBase should begin execution.
 */
@Override public boolean shouldExecute(){
  boss=((IMinion)entity).getLord();
  if (boss == null) {
    return false;
  }
 else {
    double d0=this.boss.getTheDistanceSquared(entity);
    return d0 >= MINDIST && d0 <= MAXDIST;
  }
}
Program: 12776
Project: 12776
Buggy source:
/** 
 * Returns whether an in-progress EntityAIBase should continue executing
 */
@Override public boolean continueExecuting(){
  if (!this.boss.isEntityAlive()) {
    boss=null;
    return false;
  }
 else {
    double d0=this.boss.getDistanceSquared(entity);
    return d0 >= MINDIST && d0 <= MAXDIST;
  }
}

Fixed version (ground truth):
/** 
 * Returns whether an in-progress EntityAIBase should continue executing
 */
@Override public boolean continueExecuting(){
  if (!this.boss.isTheEntityAlive()) {
    boss=null;
    return false;
  }
 else {
    double d0=this.boss.getTheDistanceSquared(entity);
    return d0 >= MINDIST && d0 <= MAXDIST;
  }
}
Program: 12779
Project: 12779
Buggy source:
public static final void fillMap(){
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public static final void fillMap(){
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
  add("String_Node_Str","String_Node_Str","String_Node_Str");
}
Program: 12780
Project: 12780
Buggy source:
@Override public void render(Entity entity,float f,float f1,float f2,float f3,float f4,float f5){
  super.render(entity,f,f1,f2,f3,f4,f5);
  setRotationAngles(f,f1,f2,f3,f4,f5,entity);
  hatTop.render(f5);
  hatRim.render(f5);
  axeShaft.render(f5);
  axeBlade1.render(f5);
  axeBlade2.render(f5);
  stake.render(f5);
}

Fixed version (ground truth):
@Override public void render(Entity entity,float f,float f1,float f2,float f3,float f4,float f5){
  super.render(entity,f,f1,f2,f3,f4,f5);
  setRotationAngles(f,f1,f2,f3,f4,f5,entity);
  hatTop.render(f5);
  hatRim.render(f5);
  if (renderWeapons) {
    axeShaft.render(f5);
    axeBlade1.render(f5);
    axeBlade2.render(f5);
    stake.render(f5);
  }
}
Program: 12781
Project: 12781
Buggy source:
@Override public IMessage onMessage(UpdateVampirePlayerPacket message,MessageContext ctx){
  VampirePlayer.get(Minecraft.getMinecraft().thePlayer).loadSyncUpdate(message.level,message.timers);
  return null;
}

Fixed version (ground truth):
@Override public IMessage onMessage(UpdateVampirePlayerPacket message,MessageContext ctx){
  VampirePlayer.get(VampirismMod.proxy.getSPPlayer()).loadSyncUpdate(message.level,message.timers);
  return null;
}
Program: 12782
Project: 12782
Buggy source:
/** 
 * Sets the vampire lords level and updates his nametag
 * @param l
 * @param sync whether to sync the level with the client or not
 */
public void setLevel(int l,boolean sync){
  if (l > 0 && l != level) {
    this.level=l;
    this.setCustomNameTag(I18n.format("String_Node_Str" + REFERENCE.ENTITY.VAMPIRE_LORD_NAME + "String_Node_Str",new Object[0]) + "String_Node_Str" + I18n.format("String_Node_Str",new Object[0])+ "String_Node_Str"+ level);
    if (sync && !this.worldObj.isRemote) {
      NBTTagCompound nbt=new NBTTagCompound();
      nbt.setInteger("String_Node_Str",level);
      Helper.sendPacketToPlayersAround(new UpdateEntityPacket(this,nbt),this);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the vampire lords level and updates his nametag
 * @param l
 * @param sync whether to sync the level with the client or not
 */
public void setLevel(int l,boolean sync){
  if (l > 0 && l != level) {
    this.level=l;
    if (sync && !this.worldObj.isRemote) {
      NBTTagCompound nbt=new NBTTagCompound();
      nbt.setInteger("String_Node_Str",level);
      Helper.sendPacketToPlayersAround(new UpdateEntityPacket(this,nbt),this);
    }
  }
}
Program: 12783
Project: 12783
Buggy source:
@Override public void registerSubscriptions(){
}

Fixed version (ground truth):
@Override public void registerSubscriptions(){
  super.registerSubscriptions();
}
Program: 12785
Project: 12785
Buggy source:
private void addAITasks(){
  EntityAITasks tasks=(EntityAITasks)Helper.Reflection.getPrivateFinalField(EntityLiving.class,entity,"String_Node_Str");
  tasks.addTask(1,new EntityAIAttackOnCollide(entity,EntityPlayer.class,1.0D,false));
  tasks.addTask(1,new EntityAIAttackOnCollide(entity,EntityVampireHunter.class,1.0D,true));
  EntityAITasks targetTasks=(EntityAITasks)Helper.Reflection.getPrivateFinalField(EntityLiving.class,entity,"String_Node_Str");
  targetTasks.addTask(3,new EntityAINearestAttackableTarget(entity,EntityPlayer.class,0,true,false,new IEntitySelector(){
    @Override public boolean isEntityApplicable(    Entity entity){
      if (entity instanceof EntityPlayer) {
        return VampirePlayer.get((EntityPlayer)entity).getLevel() <= 0;
      }
      return false;
    }
  }
));
  targetTasks.addTask(3,new EntityAINearestAttackableTarget(entity,EntityVampireHunter.class,0,true));
}

Fixed version (ground truth):
private void addAITasks(){
  EntityAITasks tasks=(EntityAITasks)Helper.Reflection.getPrivateFinalField(EntityLiving.class,(EntityLiving)entity,"String_Node_Str");
  tasks.addTask(1,new EntityAIAttackOnCollide(entity,EntityPlayer.class,1.0D,false));
  tasks.addTask(1,new EntityAIAttackOnCollide(entity,EntityVampireHunter.class,1.0D,true));
  EntityAITasks targetTasks=(EntityAITasks)Helper.Reflection.getPrivateFinalField(EntityLiving.class,entity,"String_Node_Str");
  targetTasks.addTask(3,new EntityAINearestAttackableTarget(entity,EntityPlayer.class,0,true,false,new IEntitySelector(){
    @Override public boolean isEntityApplicable(    Entity entity){
      if (entity instanceof EntityPlayer) {
        return VampirePlayer.get((EntityPlayer)entity).getLevel() <= 0;
      }
      return false;
    }
  }
));
  targetTasks.addTask(3,new EntityAINearestAttackableTarget(entity,EntityVampireHunter.class,0,true));
}
Program: 12786
Project: 12786
Buggy source:
@Override public IMessage onMessage(SpawnParticlePacket message,MessageContext ctx){
  if (message.type.equals("String_Node_Str")) {
    Class[] paramtype=new Class[]{ItemStack.class,Integer.TYPE};
    ItemStack is=new ItemStack(Item.getItemById(260));
    Helper.Reflection.callMethod(EntityPlayer.class,Minecraft.getMinecraft().thePlayer,"String_Node_Str",paramtype,new Object[]{is,message.amount});
    return null;
  }
  WorldClient world=Minecraft.getMinecraft().theWorld;
  world.spawnParticle(message.type,message.x,message.y,message.z,message.velX,message.velY,message.velZ);
  for (int i=1; i < message.amount; i++) {
    Random ran=world.rand;
    double x=message.x + (ran.nextGaussian());
    double y=message.y + (ran.nextGaussian());
    double z=message.z + (ran.nextGaussian());
    world.spawnParticle(message.type,x,y,z,ran.nextDouble(),ran.nextGaussian(),ran.nextGaussian());
  }
  return null;
}

Fixed version (ground truth):
@Override public IMessage onMessage(SpawnParticlePacket message,MessageContext ctx){
  if (message.type.equals("String_Node_Str")) {
    Class[] paramtype=new Class[]{ItemStack.class,Integer.TYPE};
    ItemStack is=new ItemStack(Item.getItemById(260));
    Helper.Reflection.callMethod(EntityPlayer.class,(EntityPlayer)Minecraft.getMinecraft().thePlayer,"String_Node_Str",paramtype,new Object[]{is,message.amount});
    return null;
  }
  WorldClient world=Minecraft.getMinecraft().theWorld;
  world.spawnParticle(message.type,message.x,message.y,message.z,message.velX,message.velY,message.velZ);
  for (int i=1; i < message.amount; i++) {
    Random ran=world.rand;
    double x=message.x + (ran.nextGaussian());
    double y=message.y + (ran.nextGaussian());
    double z=message.z + (ran.nextGaussian());
    world.spawnParticle(message.type,x,y,z,ran.nextDouble(),ran.nextGaussian(),ran.nextGaussian());
  }
  return null;
}
Program: 12787
Project: 12787
Buggy source:
@Override public void processCommand(ICommandSender sender,String[] param){
  if (sender instanceof EntityPlayer) {
    EntityPlayer p=(EntityPlayer)sender;
    if (param.length > 0) {
      try {
        VampirePlayer.get(p).setLevel(Integer.parseInt(param[0]));
      }
 catch (      NumberFormatException e) {
        Logger.e("String_Node_Str",param[0] + "String_Node_Str");
      }
    }
 else {
      VampirePlayer.get(p).levelUp();
    }
    if (VampirePlayer.get(p).getLevel() == 1) {
      sendMessage(sender,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void processCommand(ICommandSender sender,String[] param){
  if (sender instanceof EntityPlayer) {
    EntityPlayer p=(EntityPlayer)sender;
    sendMessage(sender,"String_Node_Str" + p.worldObj.isDaytime());
    if (param.length > 0) {
      try {
        VampirePlayer.get(p).setLevel(Integer.parseInt(param[0]));
      }
 catch (      NumberFormatException e) {
        Logger.e("String_Node_Str",param[0] + "String_Node_Str");
      }
    }
 else {
      VampirePlayer.get(p).levelUp();
    }
    if (VampirePlayer.get(p).getLevel() == 1) {
      sendMessage(sender,"String_Node_Str");
    }
  }
}
Program: 12788
Project: 12788
Buggy source:
/** 
 * Code for the vampirism ritual to start
 * @param player Player who started the ritual and will become a vampire
 * @param itemStack The sword's ItemStack that is going to be consumed
 */
public void startVampirismRitual(EntityPlayer player,ItemStack itemStack){
  Logger.i(TAG,"String_Node_Str");
  player.inventory.consumeInventoryItem(itemStack.getItem());
  setOccupied(true,player);
  List entityList=getWorldObj().loadedEntityList;
  ArrayList<EntityVillager> list=getVillagersInRadius(entityList,DISTANCE_AROUND_ALTAR);
  for (  EntityVillager v : list) {
    for (int i=0; i < LIGHTNINGBOLT_AMOUNT; i++)     getWorldObj().addWeatherEffect(new EntityLightningBolt(getWorldObj(),v.posX,v.posY,v.posZ));
  }
  if (!Minecraft.getMinecraft().theWorld.isDaytime() && ((ItemVampiresFear)itemStack.getItem()).getBlood(itemStack) >= BALANCE.NEEDED_BLOOD && list.size() >= BALANCE.LEVELING.R1_VILLAGERS) {
    VampirePlayer vp=VampirePlayer.get(player);
    if (vp.getLevel() == 0) {
      vp.levelUp();
    }
    Logger.i(TAG,"String_Node_Str");
  }
 else {
    Logger.i(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Code for the vampirism ritual to start
 * @param player Player who started the ritual and will become a vampire
 * @param itemStack The sword's ItemStack that is going to be consumed
 */
public void startVampirismRitual(EntityPlayer player,ItemStack itemStack){
  Logger.i(TAG,"String_Node_Str");
  Logger.i("String_Node_Str",itemStack.toString());
  player.inventory.consumeInventoryItem(itemStack.getItem());
  setOccupied(true,player);
  List entityList=getWorldObj().loadedEntityList;
  ArrayList<EntityVillager> list=getVillagersInRadius(entityList,DISTANCE_AROUND_ALTAR);
  for (  EntityVillager v : list) {
    for (int i=0; i < LIGHTNINGBOLT_AMOUNT; i++)     getWorldObj().addWeatherEffect(new EntityLightningBolt(getWorldObj(),v.posX,v.posY,v.posZ));
  }
  if (!(this.worldObj.isDaytime()) && ItemVampiresFear.getBlood(itemStack) >= BALANCE.NEEDED_BLOOD && list.size() >= BALANCE.LEVELING.R1_VILLAGERS) {
    VampirePlayer vp=VampirePlayer.get(player);
    if (vp.getLevel() == 0) {
      vp.levelUp();
    }
    Logger.i(TAG,"String_Node_Str");
  }
 else {
    itemStack.stackSize=1;
    Logger.i("String_Node_Str",itemStack.toString());
    EntityItem entityitem=new EntityItem(this.worldObj,this.xCoord,this.yCoord + 1,this.zCoord,itemStack);
    entityitem.delayBeforeCanPickup=10;
    Logger.i("String_Node_Str",entityitem.toString());
    this.worldObj.spawnEntityInWorld(entityitem);
    this.setOccupied(false,player);
    Logger.i(TAG,"String_Node_Str" + (!this.worldObj.isDaytime()) + "String_Node_Str"+ ItemVampiresFear.getBlood(itemStack)+ "String_Node_Str"+ list.size());
  }
}
Program: 12789
Project: 12789
Buggy source:
public FlyingBloodParticle(World world,double posX,double posY,double posZ,NBTTagCompound data){
  super(world,posX,posY,posZ,0D,0D,0D);
  Logger.i("String_Node_Str","String_Node_Str" + posX + "String_Node_Str"+ posY+ "String_Node_Str"+ posZ);
  entity=world.getEntityByID(data.getInteger("String_Node_Str"));
  if (entity == null) {
    Logger.e(TAG,"String_Node_Str" + data.getInteger("String_Node_Str") + "String_Node_Str");
    throw new NullPointerException("String_Node_Str");
  }
  this.particleRed=1.0F;
  this.particleBlue=this.particleGreen=0.0F;
  this.noClip=true;
  this.particleMaxAge=MAX_AGE;
  this.setParticleTextureIndex(65);
  this.motionX=(this.worldObj.rand.nextDouble() - 0.5);
  this.motionY=(this.worldObj.rand.nextDouble() + 0.2);
  this.motionZ=(this.worldObj.rand.nextDouble() - 0.5);
  this.onUpdate();
}

Fixed version (ground truth):
public FlyingBloodParticle(double posX,double posY,double posZ,NBTTagCompound data){
  super(Minecraft.getMinecraft().theWorld,posX,posY,posZ,0D,0D,0D);
  Logger.i("String_Node_Str","String_Node_Str" + posX + "String_Node_Str"+ posY+ "String_Node_Str"+ posZ);
  entity=this.worldObj.getEntityByID(data.getInteger("String_Node_Str"));
  if (entity == null) {
    Logger.e(TAG,"String_Node_Str" + data.getInteger("String_Node_Str") + "String_Node_Str");
    throw new NullPointerException("String_Node_Str");
  }
  this.particleRed=1.0F;
  this.particleBlue=this.particleGreen=0.0F;
  this.noClip=true;
  this.particleMaxAge=MAX_AGE;
  this.setParticleTextureIndex(65);
  this.motionX=(this.worldObj.rand.nextDouble() - 0.5);
  this.motionY=(this.worldObj.rand.nextDouble() + 0.2);
  this.motionZ=(this.worldObj.rand.nextDouble() - 0.5);
  this.onUpdate();
}
Program: 12790
Project: 12790
Buggy source:
@Override public IMessage onMessage(SpawnCustomParticlePacket message,MessageContext ctx){
  try {
switch (message.data.getInteger("String_Node_Str")) {
case 0:
      for (int i=0; i < message.amount; i++) {
        EntityFX p=new FlyingBloodParticle(Minecraft.getMinecraft().theWorld,message.posX,message.posY,message.posZ,message.data);
        Minecraft.getMinecraft().effectRenderer.addEffect(p);
      }
    break;
default :
  Logger.w("String_Node_Str","String_Node_Str" + message.data.getInteger("String_Node_Str") + "String_Node_Str");
return null;
}
}
 catch (Exception e) {
Logger.e("String_Node_Str","String_Node_Str",e);
}
return null;
}

Fixed version (ground truth):
@Override public IMessage onMessage(SpawnCustomParticlePacket message,MessageContext ctx){
  try {
switch (message.data.getInteger("String_Node_Str")) {
case 0:
      for (int i=0; i < message.amount; i++) {
        FlyingBloodParticle.addParticle(new FlyingBloodParticle(message.posX,message.posY,message.posZ,message.data));
      }
    break;
default :
  Logger.w("String_Node_Str","String_Node_Str" + message.data.getInteger("String_Node_Str") + "String_Node_Str");
return null;
}
}
 catch (Exception e) {
Logger.e("String_Node_Str","String_Node_Str",e);
}
return null;
}
Program: 12791
Project: 12791
Buggy source:
@Override public void renderTileEntityAt(TileEntity te,double x,double y,double z,float scale){
  TileEntityBloodAltarTier2 te2=(TileEntityBloodAltarTier2)te;
  model.setBloodLevel((int)StrictMath.ceil(te2.getBloodAmount() / te2.getMaxBlood() * 15));
  GL11.glPushMatrix();
  GL11.glTranslatef((float)x + 0.5F,(float)y + 1.5F,(float)z + 0.5F);
  bindTexture(texture);
  GL11.glPushMatrix();
  adjustRotatePivotViaMeta(te.getWorldObj(),te.xCoord,te.yCoord,te.zCoord);
  GL11.glRotatef(180F,0.0F,0.0F,1.0F);
  model.render(null,0.0F,0.0F,-0.1F,0.0F,0.0F,0.0625F);
  GL11.glPopMatrix();
  GL11.glPopMatrix();
}

Fixed version (ground truth):
@Override public void renderTileEntityAt(TileEntity te,double x,double y,double z,float scale){
  TileEntityBloodAltarTier2 te2=(TileEntityBloodAltarTier2)te;
  model.setBloodLevel((int)StrictMath.ceil(((float)te2.getBloodAmount()) / te2.getMaxBlood() * 15));
  GL11.glPushMatrix();
  GL11.glTranslatef((float)x + 0.5F,(float)y + 1.5F,(float)z + 0.5F);
  bindTexture(texture);
  GL11.glPushMatrix();
  adjustRotatePivotViaMeta(te.getWorldObj(),te.xCoord,te.yCoord,te.zCoord);
  GL11.glRotatef(180F,0.0F,0.0F,1.0F);
  model.render(null,0.0F,0.0F,-0.1F,0.0F,0.0F,0.0625F);
  GL11.glPopMatrix();
  GL11.glPopMatrix();
}
Program: 12792
Project: 12792
Buggy source:
public void registerEntitys(){
  int id=0;
  EntityRegistry.registerModEntity(EntityVampireHunter.class,"String_Node_Str",id,VampirismMod.instance,80,1,true);
  EntityRegistry.addSpawn(EntityVampireHunter.class,2,0,1,EnumCreatureType.monster,BiomeGenBase.stoneBeach,BiomeGenBase.desert);
  id++;
  EntityRegistry.registerModEntity(EntityVampire.class,"String_Node_Str",id,VampirismMod.instance,80,1,true);
  EntityRegistry.addSpawn(EntityVampire.class,2,0,1,EnumCreatureType.monster,BiomeGenBase.stoneBeach,BiomeGenBase.desert);
  id++;
}

Fixed version (ground truth):
public void registerEntitys(){
  int id=0;
  BiomeGenBase[] allBiomes=Iterators.toArray(Iterators.filter(Iterators.forArray(BiomeGenBase.getBiomeGenArray()),Predicates.notNull()),BiomeGenBase.class);
  EntityRegistry.registerModEntity(EntityVampireHunter.class,"String_Node_Str",id,VampirismMod.instance,80,1,true);
  EntityRegistry.addSpawn(EntityVampireHunter.class,2,0,1,EnumCreatureType.monster,allBiomes);
  id++;
  EntityRegistry.registerModEntity(EntityVampire.class,"String_Node_Str",id,VampirismMod.instance,80,1,true);
  EntityRegistry.addSpawn(EntityVampire.class,2,0,1,EnumCreatureType.monster,allBiomes);
  id++;
}
Program: 12793
Project: 12793
Buggy source:
public UpdateIssueParams notifiedUserIds(List<Long> notifiedUserIds){
  if (notifiedUserIds == null) {
    parameters.add(new NameValuePair("String_Node_Str","String_Node_Str"));
  }
 else {
    for (    Long notifiedUserId : notifiedUserIds) {
      parameters.add(new NameValuePair("String_Node_Str",notifiedUserId.toString()));
    }
  }
  return this;
}

Fixed version (ground truth):
public UpdateIssueParams notifiedUserIds(List<Long> notifiedUserIds){
  for (  Long notifiedUserId : notifiedUserIds) {
    parameters.add(new NameValuePair("String_Node_Str",notifiedUserId.toString()));
  }
  return this;
}
Program: 12794
Project: 12794
Buggy source:
public UpdateIssueParams attachmentIds(List<Long> attachmentIds){
  if (attachmentIds == null) {
    parameters.add(new NameValuePair("String_Node_Str","String_Node_Str"));
  }
 else {
    for (    Long attachmentId : attachmentIds) {
      parameters.add(new NameValuePair("String_Node_Str",attachmentId.toString()));
    }
  }
  return this;
}

Fixed version (ground truth):
public UpdateIssueParams attachmentIds(List<Long> attachmentIds){
  for (  Long attachmentId : attachmentIds) {
    parameters.add(new NameValuePair("String_Node_Str",attachmentId.toString()));
  }
  return this;
}
Program: 12795
Project: 12795
Buggy source:
@Test public void createParamEmptySetTest() throws UnsupportedEncodingException {
  UpdateIssueParams params=new UpdateIssueParams(1000000001l);
  params.resolution(null).assigneeId(0).dueDate(null).startDate(null).categoryIds(null).versionIds(null).milestoneIds(null).estimatedHours(null).actualHours(null).notifiedUserIds(null).attachmentIds(null);
  List<NameValuePair> parameters=params.getParamList();
  assertEquals(11,parameters.size());
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
@Test public void createParamEmptySetTest() throws UnsupportedEncodingException {
  UpdateIssueParams params=new UpdateIssueParams(1000000001l);
  params.resolution(null).assigneeId(0).dueDate(null).startDate(null).categoryIds(null).versionIds(null).milestoneIds(null).estimatedHours(null).actualHours(null);
  List<NameValuePair> parameters=params.getParamList();
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
  assertEquals(true,existsOneKeyValue(parameters,"String_Node_Str","String_Node_Str"));
}
Program: 12796
Project: 12796
Buggy source:
public UpdateIssueParams resolution(Issue.ResolutionType resolutionType){
  parameters.add(new NameValuePair("String_Node_Str",String.valueOf(resolutionType.getIntValue())));
  return this;
}

Fixed version (ground truth):
public UpdateIssueParams resolution(Issue.ResolutionType resolutionType){
  if (resolutionType == null) {
    parameters.add(new NameValuePair("String_Node_Str","String_Node_Str"));
  }
 else {
    parameters.add(new NameValuePair("String_Node_Str",String.valueOf(resolutionType.getIntValue())));
  }
  return this;
}
Program: 12797
Project: 12797
Buggy source:
private static void initalize(){
  initialized=true;
  font=new int[256][8];
  Thread fontLoader=new Thread(() -> {
    InputStream in=ClassLoader.getSystemResourceAsStream("String_Node_Str");
    Image image=new Image(in);
    PixelReader reader=image.getPixelReader();
    for (int i=0; i < 256; i++) {
      int x=(i >> 4) * 13 + 2;
      int y=(i & 15) * 13 + 4;
      for (int j=0; j < 8; j++) {
        int row=0;
        for (int k=0; k < 7; k++) {
          Color color=reader.getColor((7 - k) + x,j + y);
          boolean on=color.getRed() != 0;
          row=(row << 1) | (on ? 0 : 1);
        }
        font[i][j]=row;
      }
    }
  }
);
  fontLoader.start();
}

Fixed version (ground truth):
private static void initalize(){
  initialized=true;
  font=new int[256][8];
  Thread fontLoader=new Thread(() -> {
    InputStream in=Font.class.getClassLoader().getResourceAsStream("String_Node_Str");
    Image image=new Image(in);
    PixelReader reader=image.getPixelReader();
    for (int i=0; i < 256; i++) {
      int x=(i >> 4) * 13 + 2;
      int y=(i & 15) * 13 + 4;
      for (int j=0; j < 8; j++) {
        int row=0;
        for (int k=0; k < 7; k++) {
          Color color=reader.getColor((7 - k) + x,j + y);
          boolean on=color.getRed() != 0;
          row=(row << 1) | (on ? 0 : 1);
        }
        font[i][j]=row;
      }
    }
  }
);
  fontLoader.start();
}
Program: 12798
Project: 12798
Buggy source:
public void run(){
  RAM memory=Emulator.computer.memory;
  Emulator.computer.pause();
  int pos=memory.readWordRaw(startingAddressPointer);
  for (  Line line : lines) {
    int nextPos=pos + line.getLength() + 1;
    memory.write(pos++,(byte)(nextPos & 0x0ff),false,true);
    memory.write(pos++,(byte)(nextPos >> 8 & 0x0ff),false,true);
    memory.write(pos++,(byte)(line.getNumber() & 0x0ff),false,true);
    memory.write(pos++,(byte)(line.getNumber() >> 8 & 0x0ff),false,true);
    boolean isFirst=true;
    for (    Command command : line.getCommands()) {
      if (!isFirst) {
        memory.write(pos++,(byte)':',false,true);
      }
      isFirst=false;
      for (      Command.ByteOrToken part : command.parts) {
        memory.write(pos++,part.getByte(),false,true);
      }
    }
    memory.write(pos++,(byte)0,false,true);
  }
  memory.write(pos++,(byte)0,false,true);
  memory.write(pos++,(byte)0,false,true);
  memory.write(pos++,(byte)0,false,true);
  memory.write(pos++,(byte)0,false,true);
  Emulator.computer.resume();
}

Fixed version (ground truth):
public void run(){
  RAM memory=Emulator.computer.memory;
  Emulator.computer.pause();
  int pos=memory.readWordRaw(startingAddressPointer);
  for (  Line line : lines) {
    int nextPos=pos + line.getLength() + 1;
    memory.writeWord(pos,nextPos,false,true);
    pos+=2;
    memory.writeWord(pos,line.getNumber(),false,true);
    pos+=2;
    boolean isFirst=true;
    for (    Command command : line.getCommands()) {
      if (!isFirst) {
        memory.write(pos++,(byte)':',false,true);
      }
      isFirst=false;
      for (      Command.ByteOrToken part : command.parts) {
        memory.write(pos++,part.getByte(),false,true);
      }
    }
    memory.write(pos++,(byte)0,false,true);
  }
  memory.write(pos++,(byte)0,false,true);
  memory.write(pos++,(byte)0,false,true);
  memory.write(pos++,(byte)0,false,true);
  memory.write(pos++,(byte)0,false,true);
  clearVariables(pos);
  Emulator.computer.resume();
}
Program: 12799
Project: 12799
Buggy source:
public static ApplesoftProgram fromString(String programSource){
  ApplesoftProgram program=new ApplesoftProgram();
  for (  String line : programSource.split("String_Node_Str")) {
    if (line.trim().isEmpty())     continue;
    program.lines.add(Line.fromString(line));
  }
  for (int i=0; i < program.lines.size(); i++) {
    if (i > 0) {
      program.lines.get(i).setPrevious(program.lines.get(i - 1));
    }
    if (i < program.lines.size() - 1) {
      program.lines.get(i).setNext(program.lines.get(i + 1));
    }
  }
  return program;
}

Fixed version (ground truth):
public static ApplesoftProgram fromString(String programSource){
  ApplesoftProgram program=new ApplesoftProgram();
  for (  String line : programSource.split("String_Node_Str")) {
    if (line.trim().isEmpty()) {
      continue;
    }
    program.lines.add(Line.fromString(line));
  }
  for (int i=0; i < program.lines.size(); i++) {
    if (i > 0) {
      program.lines.get(i).setPrevious(program.lines.get(i - 1));
    }
    if (i < program.lines.size() - 1) {
      program.lines.get(i).setNext(program.lines.get(i + 1));
    }
  }
  return program;
}
Program: 12800
Project: 12800
Buggy source:
private void invokeAcme(File sourceFile,File workingDirectory) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IOException {
  String oldPath=System.getProperty("String_Node_Str");
  redirectSystemOutput();
  try {
    compiledAsset=File.createTempFile(sourceFile.getName(),"String_Node_Str",sourceFile.getParentFile());
    System.setProperty("String_Node_Str",workingDirectory.getAbsolutePath());
    AcmeCrossAssembler acme=new AcmeCrossAssembler();
    String[] params={"String_Node_Str",compiledAsset.getAbsolutePath(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",sourceFile.getAbsolutePath()};
    int status=acme.run("String_Node_Str",params);
    successful=status == 0;
    if (!successful) {
      compiledAsset.delete();
      compiledAsset=null;
    }
  }
  finally {
    restoreSystemOutput();
    System.setProperty("String_Node_Str",oldPath);
  }
  rawOutput.add("String_Node_Str");
  extractOutput(baosErr.toString());
  rawOutput.add("String_Node_Str");
  rawOutput.add("String_Node_Str");
  rawOutput.add("String_Node_Str");
  extractOutput(baosOut.toString());
}

Fixed version (ground truth):
private void invokeAcme(File sourceFile,File workingDirectory) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IOException {
  String oldPath=System.getProperty("String_Node_Str");
  redirectSystemOutput();
  try {
    compiledAsset=File.createTempFile(sourceFile.getName(),"String_Node_Str",sourceFile.getParentFile());
    System.setProperty("String_Node_Str",workingDirectory.getAbsolutePath());
    AcmeCrossAssembler acme=new AcmeCrossAssembler();
    String[] params={"String_Node_Str",normalizeWindowsPath(compiledAsset.getAbsolutePath()),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",normalizeWindowsPath(sourceFile.getAbsolutePath())};
    int status=acme.run("String_Node_Str",params);
    successful=status == 0;
    if (!successful) {
      compiledAsset.delete();
      compiledAsset=null;
    }
  }
  finally {
    restoreSystemOutput();
    System.setProperty("String_Node_Str",oldPath);
  }
  rawOutput.add("String_Node_Str");
  extractOutput(baosErr.toString());
  rawOutput.add("String_Node_Str");
  rawOutput.add("String_Node_Str");
  rawOutput.add("String_Node_Str");
  extractOutput(baosOut.toString());
}
Program: 12801
Project: 12801
Buggy source:
public void execute(){
  lastResult=getHandler().compile(this);
  manageCompileResult(lastResult);
  if (lastResult.isSuccessful()) {
    getHandler().execute(lastResult);
  }
 else {
    getHandler().clean(lastResult);
  }
}

Fixed version (ground truth):
public void execute(){
  lastResult=getHandler().compile(this);
  manageCompileResult(lastResult);
  if (lastResult.isSuccessful()) {
    getHandler().execute(lastResult);
  }
 else {
    lastResult.getOtherMessages().forEach(System.err::println);
    getHandler().clean(lastResult);
  }
}
Program: 12802
Project: 12802
Buggy source:
private boolean isConfigDifferent(){
  boolean changed=false;
  AudioFormat newAf=getAudioFormat();
  changed|=(af == null || !newAf.matches(af));
  if (oldPreferredMixer == null) {
    changed|=preferredMixer.getValue() != null;
  }
 else {
    changed|=!oldPreferredMixer.matches(preferredMixer.getValue());
  }
  oldPreferredMixer=preferredMixer.getValue();
  return changed;
}

Fixed version (ground truth):
private boolean isConfigDifferent(){
  boolean changed=false;
  AudioFormat newAf=getAudioFormat();
  changed|=(af == null || !newAf.matches(af));
  if (oldPreferredMixer == null) {
    changed|=preferredMixer.getValue() != null;
  }
 else {
    changed|=!oldPreferredMixer.matches(Pattern.quote(preferredMixer.getValue()));
  }
  oldPreferredMixer=preferredMixer.getValue();
  return changed;
}
Program: 12803
Project: 12803
Buggy source:
public static void runFile(File binary){
  String fileName=binary.getName().toLowerCase();
  try {
    if (fileName.contains("String_Node_Str")) {
      String addressStr=fileName.substring(fileName.length() - 4);
      int address=Integer.parseInt(addressStr,16);
      brun(binary,address);
    }
 else     if (fileName.contains("String_Node_Str")) {
      gripe("String_Node_Str");
    }
  }
 catch (  NumberFormatException|IOException ex) {
  }
  Emulator.computer.getCpu().resume();
}

Fixed version (ground truth):
@InvokableAction(name="String_Node_Str",category="String_Node_Str",description="String_Node_Str",alternatives="String_Node_Str",defaultKeyMapping="String_Node_Str") public static void runFile(){
  Emulator.computer.pause();
  FileChooser select=new FileChooser();
  File binary=select.showOpenDialog(JaceApplication.getApplication().primaryStage);
  if (binary == null) {
    Emulator.computer.resume();
    return;
  }
  runFileNamed(binary);
}
Program: 12804
Project: 12804
Buggy source:
@Override public void reconfigure(){
  unregisterListeners();
  if (disk1 != null && !disk1.isEmpty()) {
    try {
      MediaEntry entry=MediaCache.getMediaFromFile(new File(disk1));
      drive1.insertMedia(entry,entry.files.get(0));
      disk1=null;
    }
 catch (    IOException ex) {
      Logger.getLogger(CardMassStorage.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
  if (disk2 != null && !disk2.isEmpty()) {
    try {
      MediaEntry entry=MediaCache.getMediaFromFile(new File(disk2));
      drive2.insertMedia(entry,entry.files.get(0));
      disk2=null;
    }
 catch (    IOException ex) {
      Logger.getLogger(CardMassStorage.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
  if (computer.getCpu() != null) {
    int pc=computer.getCpu().getProgramCounter();
    if (drive1.getCurrentDisk() != null && getSlot() == 7 && (pc >= 0x0c65e && pc <= 0x0c66F)) {
      currentDrive=drive1;
      EmulatorUILogic.simulateCtrlAppleReset();
    }
  }
  registerListeners();
}

Fixed version (ground truth):
@Override public void reconfigure(){
  unregisterListeners();
  if (disk1 != null && !disk1.isEmpty()) {
    try {
      MediaEntry entry=MediaCache.getMediaFromFile(new File(disk1));
      disk1=null;
      drive1.insertMedia(entry,entry.files.get(0));
    }
 catch (    IOException ex) {
      Logger.getLogger(CardMassStorage.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
  if (disk2 != null && !disk2.isEmpty()) {
    try {
      MediaEntry entry=MediaCache.getMediaFromFile(new File(disk2));
      disk2=null;
      drive2.insertMedia(entry,entry.files.get(0));
    }
 catch (    IOException ex) {
      Logger.getLogger(CardMassStorage.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
  if (computer.getCpu() != null) {
    int pc=computer.getCpu().getProgramCounter();
    if (drive1.getCurrentDisk() != null && getSlot() == 7 && (pc >= 0x0c65e && pc <= 0x0c66F)) {
      currentDrive=drive1;
      EmulatorUILogic.simulateCtrlAppleReset();
    }
  }
  registerListeners();
}
Program: 12805
Project: 12805
Buggy source:
@Override public void clearState(){
  A=0x0ff;
  X=0x0ff;
  Y=0x0ff;
  C=1;
  interruptSignalled=false;
  Z=true;
  I=true;
  D=true;
  B=true;
  V=true;
  N=true;
  STACK=0xff;
}

Fixed version (ground truth):
@Override public void clearState(){
  A=0x0ff;
  X=0x0ff;
  Y=0x0ff;
  C=1;
  interruptSignalled=false;
  Z=true;
  I=true;
  D=true;
  B=true;
  V=true;
  N=true;
  STACK=0xff;
  setWaitCycles(0);
}
Program: 12806
Project: 12806
Buggy source:
@Test public void testAdditionNonDecimal(){
  cpu.A=0;
  cpu.D=false;
  cpu.C=0;
  assemble("String_Node_Str");
  assertEquals("String_Node_Str",0,cpu.A);
  cpu.tick();
  assertEquals("String_Node_Str",1,cpu.A);
  assertFalse("String_Node_Str",cpu.Z);
}

Fixed version (ground truth):
@Test public void testAdditionNonDecimal(){
  cpu.A=0;
  cpu.D=false;
  cpu.C=0;
  assemble("String_Node_Str");
  assertEquals("String_Node_Str",1,cpu.A);
  assertFalse("String_Node_Str",cpu.Z);
}
Program: 12807
Project: 12807
Buggy source:
@Before public void setup(){
  cpu.suspend();
  for (int i=0; i < 1024; i++) {
    ram.write(i,(byte)0,false,false);
  }
  cpu.setProgramCounter(0);
  cpu.setWaitCycles(0);
  cpu.clearState();
}

Fixed version (ground truth):
@Before public void setup(){
  cpu.suspend();
  cpu.clearState();
}
Program: 12808
Project: 12808
Buggy source:
private void assemble(String code){
  HeadlessProgram program=new HeadlessProgram(Program.DocumentType.assembly);
  program.setValue("String_Node_Str" + code + "String_Node_Str");
  program.execute();
}

Fixed version (ground truth):
private void assemble(String code){
  assembleAt(code,0x0300);
}
Program: 12809
Project: 12809
Buggy source:
@Override public T getValue(){
  if (currentValue != null || allowNull()) {
    return currentValue;
  }
 else {
    Iterator<? extends T> i=getSelections().keySet().iterator();
    return i.next();
  }
}

Fixed version (ground truth):
@Override public T getValue(){
  if (currentValue != null || allowNull()) {
    return currentValue;
  }
 else {
    Iterator<? extends T> i=getSelections().keySet().iterator();
    if (i.hasNext()) {
      return i.next();
    }
 else {
      return null;
    }
  }
}
Program: 12811
Project: 12811
Buggy source:
public int readRegister(int reg){
  Register r=Register.fromInt(reg);
switch (r) {
case ORB:
    if (dataDirectionB == 0x0ff)     break;
  return receiveOutputB() & (dataDirectionB ^ 0x0ff);
case ORA:
case ORAH:
if (dataDirectionA == 0x0ff) break;
return receiveOutputA() & (dataDirectionA ^ 0x0ff);
case DDRB:
return dataDirectionB;
case DDRA:
return dataDirectionA;
case T1CL:
timer1IRQ=false;
timer1counter-=8;
return timer1counter & 0x0ff;
case T1CH:
timer1counter-=8;
return (timer1counter & 0x0ff00) >> 8;
case T1LL:
return timer1latch & 0x0ff;
case T1LH:
return (timer1latch & 0x0ff00) >> 8;
case T2CL:
timer2IRQ=false;
return timer2counter & 0x0ff;
case T2CH:
return (timer2counter & 0x0ff00) >> 8;
case SR:
return 0;
case ACR:
if (timer1freerun) return 64;
return 0;
case PCR:
break;
case IFR:
int val=0;
if (timer1IRQ) val|=64;
if (timer2IRQ) val|=32;
if (val != 0) val|=128;
return val;
case IER:
val=128;
if (timer1interruptEnabled) val|=64;
if (timer2interruptEnabled) val|=32;
return val;
}
return 0;
}

Fixed version (ground truth):
public int readRegister(int reg){
  Register r=Register.fromInt(reg);
switch (r) {
case ORB:
    if (dataDirectionB == 0x0ff) {
      break;
    }
  return receiveOutputB() & (dataDirectionB ^ 0x0ff);
case ORA:
case ORAH:
if (dataDirectionA == 0x0ff) {
  break;
}
return receiveOutputA() & (dataDirectionA ^ 0x0ff);
case DDRB:
return dataDirectionB;
case DDRA:
return dataDirectionA;
case T1CL:
timer1IRQ=false;
return timer1counter & 0x0ff;
case T1CH:
return (timer1counter & 0x0ff00) >> 8;
case T1LL:
return timer1latch & 0x0ff;
case T1LH:
return (timer1latch & 0x0ff00) >> 8;
case T2CL:
timer2IRQ=false;
return timer2counter & 0x0ff;
case T2CH:
return (timer2counter & 0x0ff00) >> 8;
case SR:
return 0;
case ACR:
if (timer1freerun) {
return 64;
}
return 0;
case PCR:
break;
case IFR:
int val=0;
if (timer1IRQ) {
val|=64;
}
if (timer2IRQ) {
val|=32;
}
if (val != 0) {
val|=128;
}
return val;
case IER:
val=128;
if (timer1interruptEnabled) {
val|=64;
}
if (timer2interruptEnabled) {
val|=32;
}
return val;
}
return 0;
}
Program: 12812
Project: 12812
Buggy source:
@Override public void tick(){
  if (timer1running) {
    timer1counter--;
    if (timer1counter < 0) {
      timer1counter=timer1latch;
      if (!timer1freerun)       timer1running=false;
      if (timer1interruptEnabled) {
        timer1IRQ=true;
        computer.getCpu().generateInterrupt();
      }
    }
  }
  if (timer2running) {
    timer2counter--;
    if (timer2counter < 0) {
      timer2running=false;
      timer2counter=timer2latch;
      if (timer2interruptEnabled) {
        timer2IRQ=true;
        computer.getCpu().generateInterrupt();
      }
    }
  }
  if (!timer1running && !timer2running)   setRun(false);
}

Fixed version (ground truth):
@Override public void tick(){
  if (timer1running) {
    timer1counter--;
    if (timer1counter < 0) {
      timer1counter=timer1latch;
      if (!timer1freerun) {
        timer1running=false;
      }
      if (timer1interruptEnabled) {
        timer1IRQ=true;
        computer.getCpu().generateInterrupt();
      }
    }
  }
  if (timer2running) {
    timer2counter--;
    if (timer2counter < 0) {
      timer2running=false;
      timer2counter=timer2latch;
      if (timer2interruptEnabled) {
        timer2IRQ=true;
        computer.getCpu().generateInterrupt();
      }
    }
  }
  if (!timer1running && !timer2running) {
    setRun(false);
  }
}
Program: 12813
Project: 12813
Buggy source:
public void writeRegister(int reg,int value){
  value&=0x0ff;
  Register r=Register.fromInt(reg);
switch (r) {
case ORB:
    if (dataDirectionB == 0)     break;
  value=value & dataDirectionB;
sendOutputB(value);
break;
case ORA:
if (dataDirectionA == 0) break;
value=value & dataDirectionA;
sendOutputA(value);
break;
case DDRB:
dataDirectionB=value;
break;
case DDRA:
dataDirectionA=value;
break;
case T1CL:
case T1LL:
timer1latch=(timer1latch & 0x0ff00) | value;
break;
case T1CH:
timer1latch=(timer1latch & 0x0ff) | (value << 8);
timer1IRQ=false;
timer1counter=timer1latch;
timer1running=true;
setRun(true);
break;
case T1LH:
timer1latch=(timer1latch & 0x0ff) | (value << 8);
timer1IRQ=false;
break;
case T2CL:
timer2latch=(timer2latch & 0x0ff00) | value;
break;
case T2CH:
timer2latch=(timer2latch & 0x0ff) | (value << 8);
timer2IRQ=false;
timer2counter=timer2latch;
timer2running=true;
setRun(true);
break;
case SR:
break;
case ACR:
timer1freerun=(value & 64) != 0;
if (timer1freerun) timer1running=true;
break;
case PCR:
break;
case IFR:
if ((value & 64) != 0) timer1IRQ=false;
if ((value & 32) != 0) timer2IRQ=false;
break;
case IER:
boolean enable=(value & 128) != 0;
if ((value & 64) != 0) timer1interruptEnabled=enable;
if ((value & 32) != 0) timer2interruptEnabled=enable;
break;
default :
}
}

Fixed version (ground truth):
public void writeRegister(int reg,int val){
  int value=val & 0x0ff;
  Register r=Register.fromInt(reg);
switch (r) {
case ORB:
    if (dataDirectionB == 0) {
      break;
    }
  sendOutputB(value & dataDirectionB);
break;
case ORA:
if (dataDirectionA == 0) {
break;
}
sendOutputA(value & dataDirectionA);
break;
case DDRB:
dataDirectionB=value;
break;
case DDRA:
dataDirectionA=value;
break;
case T1CL:
case T1LL:
timer1latch=(timer1latch & 0x0ff00) | value;
break;
case T1CH:
timer1latch=(timer1latch & 0x0ff) | (value << 8);
timer1IRQ=false;
timer1counter=timer1latch;
timer1running=true;
setRun(true);
break;
case T1LH:
timer1latch=(timer1latch & 0x0ff) | (value << 8);
timer1IRQ=false;
break;
case T2CL:
timer2latch=(timer2latch & 0x0ff00) | value;
break;
case T2CH:
timer2latch=(timer2latch & 0x0ff) | (value << 8);
timer2IRQ=false;
timer2counter=timer2latch;
timer2running=true;
setRun(true);
break;
case SR:
break;
case ACR:
timer1freerun=(value & 64) != 0;
if (timer1freerun) {
timer1running=true;
setRun(true);
}
break;
case PCR:
break;
case IFR:
if ((value & 64) != 0) {
timer1IRQ=false;
}
if ((value & 32) != 0) {
timer2IRQ=false;
}
break;
case IER:
boolean enable=(value & 128) != 0;
if ((value & 64) != 0) {
timer1interruptEnabled=enable;
}
if ((value & 32) != 0) {
timer2interruptEnabled=enable;
}
break;
default :
}
}
Program: 12814
Project: 12814
Buggy source:
public R6522(Computer computer){
  super(computer);
}

Fixed version (ground truth):
public R6522(Computer computer){
  super(computer);
  timer1freerun=true;
  timer1running=true;
  timer1latch=0x1fff;
  timer1interruptEnabled=false;
  setRun(true);
}
Program: 12815
Project: 12815
Buggy source:
static public Register fromInt(int i){
  for (  Register r : Register.values()) {
    if (r.val == i)     return r;
  }
  return null;
}

Fixed version (ground truth):
static public Register fromInt(int i){
  for (  Register r : Register.values()) {
    if (r.val == i) {
      return r;
    }
  }
  return null;
}
Program: 12816
Project: 12816
Buggy source:
public void setRate(int clock,int sample_rate){
  sampleRate=sample_rate;
  this.clock=clock;
  cyclesPerSample=clock / sampleRate;
}

Fixed version (ground truth):
public void setRate(int clock,int sample_rate){
  sampleRate=sample_rate == 0 ? 44100 : sample_rate;
  this.clock=clock;
  cyclesPerSample=clock / sampleRate;
}
Program: 12817
Project: 12817
Buggy source:
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  int dataBlocks=(int)((getPhysicalFile().length() + ProdosVirtualDisk.BLOCK_SIZE - 1) / ProdosVirtualDisk.BLOCK_SIZE);
  int treeBlocks=(((dataBlocks * 2) + (ProdosVirtualDisk.BLOCK_SIZE - 2)) / ProdosVirtualDisk.BLOCK_SIZE);
  if (treeBlocks > 1) {
    treeBlocks++;
  }
switch (this.getType()) {
case SEEDLING:
    readFile(buffer,0);
  break;
case SAPLING:
if (block > 0) {
  readFile(buffer,(block - 1));
}
 else {
  generateIndex(buffer,0,dataBlocks);
}
break;
case TREE:
if (block == 0) {
generateIndex(buffer,1,treeBlocks);
}
 else if (block <= treeBlocks) {
int start=treeBlocks + ((block - 1) * 256);
int end=treeBlocks + dataBlocks;
generateIndex(buffer,start,end);
}
 else {
readFile(buffer,(block - treeBlocks - 1));
}
break;
}
}

Fixed version (ground truth):
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  int dataBlocks=(int)((getPhysicalFile().length() + ProdosVirtualDisk.BLOCK_SIZE - 1) / ProdosVirtualDisk.BLOCK_SIZE);
  int treeBlocks=(((dataBlocks * 2) + (ProdosVirtualDisk.BLOCK_SIZE - 2)) / ProdosVirtualDisk.BLOCK_SIZE);
  if (treeBlocks > 1) {
    treeBlocks++;
  }
switch (this.getType()) {
case SEEDLING:
    readFile(buffer,0);
  break;
case SAPLING:
if (block > 0) {
  readFile(buffer,(block - 1));
}
 else {
  generateIndex(buffer,1,treeBlocks + dataBlocks);
}
break;
case TREE:
if (block == 0) {
generateIndex(buffer,1,treeBlocks);
}
 else if (block <= treeBlocks) {
int start=treeBlocks + ((block - 1) * 256);
int end=treeBlocks + dataBlocks;
generateIndex(buffer,start,end);
}
 else {
readFile(buffer,(block - treeBlocks - 1));
}
break;
}
}