nus-yam/ex-repair huggingface dataset:
Program: 5462
Project: 5462
Buggy source:
/** 
 * Insert a node's reading from it's capabilities and make the appropriate relations such as Node-Reading , Capability-reading
 * @param nodeId       , a node's id.
 * @param capabilityId , a capability's id.
 * @param readingValue , the readings value.
 * @param timestamp    , a timestamp for the time the reading took place
 * @throws UnknownNodeIdException       , exception when an unknown node id occurs.
 * @throws UnknownCapabilityIdException ,  exception when an unknown capability id occurs.
 */
public void insertReading(final String nodeId,final String capabilityId,final double readingValue,final Date timestamp) throws UnknownNodeIdException, UnknownCapabilityIdException {
  Node node=NodeController.getInstance().getByID(nodeId);
  if (node == null)   throw new UnknownNodeIdException(nodeId);
  Capability capability=CapabilityController.getInstance().getByID(capabilityId);
  if (capability == null)   throw new UnknownCapabilityIdException(capabilityId);
  NodeReading reading=new NodeReading();
  reading.setNode(node);
  reading.setCapability(capability);
  reading.setReading(readingValue);
  reading.setTimestamp(timestamp);
  if (node.getReadings() == null) {
    node.setReadings(new HashSet<NodeReading>());
  }
  node.getReadings().add(reading);
  if (capability.getNodeReadings() == null) {
    capability.setNodeReadings(new HashSet<NodeReading>());
  }
  capability.getNodeReadings().add(reading);
  NodeReadingController.getInstance().add(reading);
}

Fixed version (ground truth):
/** 
 * Insert a node's reading from it's capabilities and make the appropriate relations such as Node-Reading , Capability-reading
 * @param nodeId       , a node's id.
 * @param capabilityId , a capability's id.
 * @param readingValue , the readings value.
 * @param timestamp    , a timestamp for the time the reading took place
 * @throws UnknownNodeIdException       , exception when an unknown node id occurs.
 * @throws UnknownCapabilityIdException ,  exception when an unknown capability id occurs.
 */
public void insertReading(final String nodeId,final String capabilityId,final double readingValue,final Date timestamp) throws UnknownNodeIdException, UnknownCapabilityIdException {
  Node node=NodeController.getInstance().getByID(nodeId);
  if (node == null)   throw new UnknownNodeIdException(nodeId);
  Capability capability=CapabilityController.getInstance().getByID(capabilityId);
  if (capability == null)   throw new UnknownCapabilityIdException(capabilityId);
  NodeReading reading=new NodeReading();
  reading.setNode(node);
  reading.setCapability(capability);
  reading.setReading(readingValue);
  reading.setTimestamp(timestamp);
  if (node.getReadings() == null) {
    node.setReadings(new HashSet<NodeReading>());
  }
  node.getReadings().add(reading);
  if (capability.getNodeReadings() == null) {
    capability.setNodeReadings(new HashSet<NodeReading>());
  }
  capability.getNodeReadings().add(reading);
  add(reading);
}
Program: 5463
Project: 5463
Buggy source:
/** 
 * Convert the WiseML setup entries collection to a WiseDB setup records.
 * @param collection , collection of setup entries.
 */
public void convertCollection(final Collection<Setup> collection){
  if (collection == null) {
    LOGGER.fatal("String_Node_Str");
    System.exit(-1);
  }
  setEntities(collection);
  for (  Setup setup : getEntities()) {
    SetupImporter.setNodeLinkSetup(setup);
    testbed.setSetup(setup);
    setup.setTestbed(testbed);
    TestbedController.getInstance().update(testbed);
    SetupController.getInstance().add(setup);
    LOGGER.debug("String_Node_Str");
  }
  LOGGER.debug("String_Node_Str" + collection.size() + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Convert the WiseML setup entries collection to a WiseDB setup records.
 * @param collection , collection of setup entries.
 */
public void convertCollection(final Collection<Setup> collection){
  if (collection == null) {
    LOGGER.fatal("String_Node_Str");
    System.exit(-1);
  }
  setEntities(collection);
  for (  Setup setup : getEntities()) {
    SetupImporter.setNodeLinkSetup(setup);
    testbed.setSetup(setup);
    setup.setTestbed(testbed);
    TestbedController.getInstance().update(testbed);
    LOGGER.debug("String_Node_Str");
    SetupController.getInstance().add(setup);
    LOGGER.debug("String_Node_Str");
  }
}
Program: 5466
Project: 5466
Buggy source:
public void setWisemlfilename(String wisemlfilename){
  this.wisemlfilename=wisemlfilename;
}

Fixed version (ground truth):
public void setWisemlfilename(String wisemlFilename){
  this.wisemlFilename=wisemlFilename;
}
Program: 5467
Project: 5467
Buggy source:
public String getWisemlfilename(){
  return wisemlfilename;
}

Fixed version (ground truth):
public String getWisemlfilename(){
  return wisemlFilename;
}
Program: 5468
Project: 5468
Buggy source:
public void addNodename(Nodename nodename){
  this.names.add(nodename);
}

Fixed version (ground truth):
public void addNodename(Nodename nodename){
  if (this.names == null) {
    this.names=new ArrayList<Nodename>();
  }
  this.names.add(nodename);
}
Program: 5469
Project: 5469
Buggy source:
public void addApplication(Application app){
  this.applications.add(app);
}

Fixed version (ground truth):
public void addApplication(Application app){
  if (this.applications == null) {
    this.applications=new ArrayList<Application>();
  }
  this.applications.add(app);
}
Program: 5470
Project: 5470
Buggy source:
public void addServerConnection(ServerConnection con){
  this.serverConnections.add(con);
}

Fixed version (ground truth):
public void addServerConnection(ServerConnection con){
  if (this.serverConnections == null) {
    this.serverConnections=new ArrayList<ServerConnection>();
  }
  this.serverConnections.add(con);
}
Program: 5471
Project: 5471
Buggy source:
/** 
 * this method add a node in the configuration
 * @param nd of the testbed configuration
 */
public void addNodes(Nodes nd){
  this.nodes.add(nd);
}

Fixed version (ground truth):
/** 
 * this method add a node in the configuration
 * @param nd of the testbed configuration
 */
public void addNodes(Nodes nd){
  if (this.nodes == null) {
    this.nodes=new ArrayList<Nodes>();
  }
  this.nodes.add(nd);
}
Program: 5473
Project: 5473
Buggy source:
/** 
 * Handle the message via   {@link #innerHandle(AjahMessage)} and then callhandle on child handlers.
 * @see com.ajah.rfcmail.fetch.MessageHandler#handle(AjahMessage)
 */
@Override public final MessageHandlerResponse handle(AjahMessage message) throws MessagingException {
  AjahUtils.requireParam(message,"String_Node_Str");
  AjahUtils.requireParam(message.getId(),"String_Node_Str");
  MessageHandlerResponse response=innerHandle(message);
  for (  MessageHandler messageHandler : this.messageHandlers.getList(response.getResult())) {
    messageHandler.handle(message);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Handle the message via   {@link #innerHandle(AjahMessage)} and then callhandle on child handlers.
 * @see com.ajah.rfcmail.fetch.MessageHandler#handle(AjahMimeMessage)
 */
@Override public final MessageHandlerResponse handle(AjahMimeMessage message) throws MessagingException {
  AjahUtils.requireParam(message,"String_Node_Str");
  AjahUtils.requireParam(message.getId(),"String_Node_Str");
  MessageHandlerResponse response=innerHandle(message);
  for (  MessageHandler messageHandler : this.messageHandlers.getList(response.getResult())) {
    messageHandler.handle(message);
  }
  return null;
}
Program: 5474
Project: 5474
Buggy source:
private void processFolder(final IMAPFolder folder) throws MessagingException, IOException {
  log.fine("String_Node_Str" + folder.getFullName());
  final long start=System.currentTimeMillis();
  if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
    folder.open(Folder.READ_ONLY);
    final Message[] messages=folder.getMessages();
    log.fine(messages.length + "String_Node_Str");
    final FetchProfile fp=new FetchProfile();
    fp.add("String_Node_Str");
    folder.fetch(messages,fp);
    long messageCount=0;
    for (    final Message message : messages) {
      messageCount++;
      try {
        for (        MessageHandler messageHandler : getMessageHandlers()) {
          log.finest(messageHandler.getClass().getSimpleName() + "String_Node_Str" + ((MimeMessage)message).getMessageID());
          messageHandler.handle(new AjahMessage(message));
          return;
        }
      }
 catch (      final MessagingException e) {
        log.log(Level.SEVERE,e.getMessage(),e);
      }
    }
    log.finest(messageCount + "String_Node_Str");
  }
  final long end=System.currentTimeMillis();
  log.finest("String_Node_Str" + folder.getFullName() + "String_Node_Str"+ (end - start)+ "String_Node_Str");
  if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
    final Folder[] children=folder.list();
    if (children != null) {
      for (      final Folder child : children) {
        processFolder((IMAPFolder)child);
      }
    }
  }
}

Fixed version (ground truth):
private void processFolder(final IMAPFolder folder) throws MessagingException, IOException {
  log.fine("String_Node_Str" + folder.getFullName());
  final long start=System.currentTimeMillis();
  if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
    folder.open(Folder.READ_ONLY);
    final Message[] messages=folder.getMessages();
    log.fine(messages.length + "String_Node_Str");
    final FetchProfile fp=new FetchProfile();
    fp.add("String_Node_Str");
    folder.fetch(messages,fp);
    long messageCount=0;
    for (    final Message message : messages) {
      messageCount++;
      try {
        for (        MessageHandler messageHandler : getMessageHandlers()) {
          log.finest(messageHandler.getClass().getSimpleName() + "String_Node_Str" + ((MimeMessage)message).getMessageID());
          messageHandler.handle(new AjahMimeMessage(message.getInputStream()));
          return;
        }
      }
 catch (      final MessagingException e) {
        log.log(Level.SEVERE,e.getMessage(),e);
      }
    }
    log.finest(messageCount + "String_Node_Str");
  }
  final long end=System.currentTimeMillis();
  log.finest("String_Node_Str" + folder.getFullName() + "String_Node_Str"+ (end - start)+ "String_Node_Str");
  if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
    final Folder[] children=folder.list();
    if (children != null) {
      for (      final Folder child : children) {
        processFolder((IMAPFolder)child);
      }
    }
  }
}
Program: 5475
Project: 5475
Buggy source:
/** 
 * Process a message.
 * @param message The message to process.
 * @return The result of the message processing, will not be null.
 * @throws MessagingException
 */
MessageHandlerResponse handle(AjahMessage message) throws MessagingException ;

Fixed version (ground truth):
/** 
 * Process a message.
 * @param message The message to process.
 * @return The result of the message processing, will not be null.
 * @throws MessagingException
 */
MessageHandlerResponse handle(AjahMimeMessage message) throws MessagingException ;
Program: 5476
Project: 5476
Buggy source:
/** 
 * Gets the content of a message as text and removes extra whitespace.
 * @see #getContentAsText(AjahMessage)
 * @param message
 * @return The content of a message as text with extra whitespace removed.
 * @throws IOException
 * @throws MessagingException
 */
public static String getContentAsCleanText(AjahMessage message) throws MessagingException, IOException {
  return removeExtraWhitespace(getContentAsText(message));
}

Fixed version (ground truth):
/** 
 * Gets the content of a message as text and removes extra whitespace.
 * @see #getContentAsText(AjahMimeMessage)
 * @param message
 * @return The content of a message as text with extra whitespace removed.
 * @throws IOException
 * @throws MessagingException
 */
public static String getContentAsCleanText(AjahMimeMessage message) throws MessagingException, IOException {
  return removeExtraWhitespace(getContentAsText(message));
}
Program: 5477
Project: 5477
Buggy source:
/** 
 * Returns a random element from a list.
 * @param < T > Type of element.
 * @param list The list to find a random element in.
 * @return A random element from the list, or null if the list is null orempty.
 */
public static <T>T getRandomElement(final List<T> list){
  if (CollectionUtils.isEmpty(list)) {
    return null;
  }
  return list.get(getRandomNumber(0,list.size()));
}

Fixed version (ground truth):
/** 
 * Returns a random element from a list.
 * @param < T > Type of element.
 * @param list The list to find a random element in.
 * @return A random element from the list, or null if the list is null orempty.
 */
public static <T>T getRandomElement(final List<T> list){
  if (CollectionUtils.isEmpty(list)) {
    return null;
  }
  return list.get(getRandomNumber(0,list.size() - 1));
}
Program: 5479
Project: 5479
Buggy source:
private void writePort(PortReg function,int data,long cycles){
switch (function) {
case OUT:
{
      out=data;
      PortListener listener=portListener;
      if (listener != null) {
        listener.portWrite(this,out | (~dir) & 0xff);
      }
      break;
    }
case IN:
  logw(WarningType.ILLEGAL_IO_WRITE,"String_Node_Str" + getID() + "String_Node_Str");
throw new EmulationException("String_Node_Str" + getID() + "String_Node_Str");
case DIR:
{
dir=data;
PortListener listener=portListener;
if (listener != null) {
  listener.portWrite(this,out | (~dir) & 0xff);
}
break;
}
case REN:
ren=data;
break;
case IFG:
if (DEBUG) {
log("String_Node_Str" + data);
}
ifg&=data;
updateIV();
break;
case IE:
ie=data;
if (DEBUG) {
log("String_Node_Str" + data);
}
cpu.flagInterrupt(interrupt,this,(ifg & ie) > 0);
break;
case IES:
ies=data;
break;
case SEL:
sel=data;
break;
case SEL2:
sel2=data;
break;
case DS:
ds=data;
break;
case IV_L:
if (iv != 0) {
if (iv > 1 && iv < 17) {
ifg&=~(1 << ((iv - 2) / 2));
}
updateIV();
}
break;
case IV_H:
break;
}
}

Fixed version (ground truth):
private void writePort(PortReg function,int data,long cycles){
switch (function) {
case OUT:
{
      out=data;
      PortListener listener=portListener;
      if (listener != null) {
        listener.portWrite(this,out | (~dir) & 0xff);
      }
      break;
    }
case IN:
  logw(WarningType.ILLEGAL_IO_WRITE,"String_Node_Str" + getID() + "String_Node_Str");
throw new EmulationException("String_Node_Str" + getID() + "String_Node_Str");
case DIR:
{
dir=data;
PortListener listener=portListener;
if (listener != null) {
  listener.portWrite(this,out | (~dir) & 0xff);
}
break;
}
case REN:
ren=data;
break;
case IFG:
if (DEBUG) {
log("String_Node_Str" + data);
}
ifg=data;
updateIV();
break;
case IE:
ie=data;
if (DEBUG) {
log("String_Node_Str" + data);
}
cpu.flagInterrupt(interrupt,this,(ifg & ie) > 0);
break;
case IES:
ies=data;
break;
case SEL:
sel=data;
break;
case SEL2:
sel2=data;
break;
case DS:
ds=data;
break;
case IV_L:
if (iv != 0) {
if (iv > 1 && iv < 17) {
ifg&=~(1 << ((iv - 2) / 2));
}
updateIV();
}
break;
case IV_H:
break;
}
}
Program: 5481
Project: 5481
Buggy source:
public void setLogLevel(int l){
  logLevel=l;
}

Fixed version (ground truth):
public void setLogLevel(int l){
  logLevel=l;
  DEBUG=logLevel == Loggable.DEBUG;
}
Program: 5482
Project: 5482
Buggy source:
public void updateIV(){
  int bitval=0x01;
  iv=0;
  int ie_ifg=ifg & ie;
  for (int i=0; i < 8; i++) {
    if ((bitval & ie_ifg) > 0) {
      iv=2 + i * 2;
      break;
    }
    bitval=bitval << 1;
  }
}

Fixed version (ground truth):
private void updateIV(){
  int bitval=0x01;
  iv=0;
  int ie_ifg=ifg & ie;
  for (int i=0; i < 8; i++) {
    if ((bitval & ie_ifg) > 0) {
      iv=2 + i * 2;
      break;
    }
    bitval=bitval << 1;
  }
  cpu.flagInterrupt(interrupt,this,(ifg & ie) > 0);
}
Program: 5483
Project: 5483
Buggy source:
public int read(int address,boolean word,long cycles){
  PortReg reg=portMap[address - offset];
  if (word && reg == PortReg.IV_L) {
    return read_port(reg,cycles) | (read_port(PortReg.IV_H,cycles) << 8);
  }
 else   if (word && ioPair != null) {
    return read_port(reg,cycles) | (ioPair.read_port(reg,cycles) << 8);
  }
  return read_port(reg,cycles);
}

Fixed version (ground truth):
public int read(int address,boolean word,long cycles){
  PortReg reg=portMap[address - offset];
  if (word && reg == PortReg.IV_L) {
    return (readPort(PortReg.IV_H,cycles) << 8) | readPort(reg,cycles);
  }
 else   if (word && ioPair != null) {
    return readPort(reg,cycles) | (ioPair.readPort(reg,cycles) << 8);
  }
  return readPort(reg,cycles);
}
Program: 5484
Project: 5484
Buggy source:
public void write(int address,int data,boolean word,long cycles){
  int iAddress=address - offset;
  if (iAddress < 0 || iAddress >= portMap.length) {
    throw new EmulationException("String_Node_Str" + getID() + "String_Node_Str"+ Utils.hex(address,4));
  }
  PortReg fun=portMap[iAddress];
  if (DEBUG) {
    log("String_Node_Str" + getID() + fun+ "String_Node_Str"+ Utils.hex(address,2)+ "String_Node_Str"+ Utils.hex(data,2)+ "String_Node_Str"+ Utils.binary8(data)+ (word ? "String_Node_Str" : "String_Node_Str"));
  }
  if (word && ioPair != null) {
    write_port(fun,data & 0xff,cycles);
    ioPair.write_port(fun,data >> 8,cycles);
  }
 else {
    write_port(fun,data,cycles);
  }
}

Fixed version (ground truth):
public void write(int address,int data,boolean word,long cycles){
  int iAddress=address - offset;
  if (iAddress < 0 || iAddress >= portMap.length) {
    throw new EmulationException("String_Node_Str" + getID() + "String_Node_Str"+ Utils.hex(address,4));
  }
  PortReg fun=portMap[iAddress];
  if (DEBUG) {
    log("String_Node_Str" + getID() + fun+ "String_Node_Str"+ Utils.hex(address,2)+ "String_Node_Str"+ Utils.hex(data,2)+ "String_Node_Str"+ Utils.binary8(data)+ (word ? "String_Node_Str" : "String_Node_Str"));
  }
  if (word && ioPair != null) {
    writePort(fun,data & 0xff,cycles);
    ioPair.writePort(fun,data >> 8,cycles);
  }
 else {
    writePort(fun,data,cycles);
  }
}
Program: 5485
Project: 5485
Buggy source:
public void setPinState(int pin,PinState state){
  if (pinState[pin] != state) {
    pinState[pin]=state;
    int bit=1 << pin;
    if (state == PinState.HI) {
      in|=bit;
    }
 else {
      in&=~bit;
    }
    if (interrupt > 0) {
      if ((ies & bit) == 0) {
        if (state == PinState.HI) {
          ifg|=bit;
          updateIV();
          if (DEBUG) {
            log("String_Node_Str" + bit);
          }
        }
      }
 else {
        if (state == PinState.LOW) {
          ifg|=bit;
          updateIV();
          if (DEBUG) {
            log("String_Node_Str" + bit);
          }
        }
      }
      cpu.flagInterrupt(interrupt,this,(ifg & ie) > 0);
    }
    if (timerCapture[pin] != null) {
      timerCapture[pin].capture(pin,0,state);
    }
  }
}

Fixed version (ground truth):
public void setPinState(int pin,PinState state){
  if (pinState[pin] != state) {
    pinState[pin]=state;
    int bit=1 << pin;
    if (state == PinState.HI) {
      in|=bit;
    }
 else {
      in&=~bit;
    }
    if (interrupt > 0) {
      if ((ies & bit) == 0) {
        if (state == PinState.HI) {
          ifg|=bit;
          if (DEBUG) {
            log("String_Node_Str" + bit);
          }
          updateIV();
        }
      }
 else {
        if (state == PinState.LOW) {
          ifg|=bit;
          if (DEBUG) {
            log("String_Node_Str" + bit);
          }
          updateIV();
        }
      }
    }
    if (timerCapture[pin] != null) {
      timerCapture[pin].capture(pin,0,state);
    }
  }
}
Program: 5487
Project: 5487
Buggy source:
private static String dumpMem(int pc,int size,int[] memory){
  String output="String_Node_Str";
  for (int i=0, n=4; i < n; i++) {
    if (size > i) {
      output+=Utils.hex8(memory[pc + i]) + "String_Node_Str";
    }
 else {
      output+="String_Node_Str";
    }
  }
  return output;
}

Fixed version (ground truth):
private static String dumpMem(int pc,int size,int[] memory){
  String output="String_Node_Str";
  for (int i=0, n=size; i < n; i++) {
    if (size > i) {
      output+=Utils.hex8(memory[pc + i]) + "String_Node_Str";
    }
 else {
      output+="String_Node_Str";
    }
  }
  return output;
}
Program: 5488
Project: 5488
Buggy source:
public synchronized void removeChart(Chart chart){
  charts=(Chart[])ArrayUtils.remove(charts,chart);
}

Fixed version (ground truth):
public synchronized void removeChart(Chart chart){
  charts=ArrayUtils.remove(charts,chart);
}
Program: 5489
Project: 5489
Buggy source:
public synchronized void addChart(Chart chart){
  charts=(Chart[])ArrayUtils.add(Chart.class,charts,chart);
}

Fixed version (ground truth):
public synchronized void addChart(Chart chart){
  charts=ArrayUtils.add(Chart.class,charts,chart);
}
Program: 5490
Project: 5490
Buggy source:
public StackUI(MSP430 cpu,int updateCyclePeriod){
  super(new BorderLayout());
  this.updateCyclePeriod=updateCyclePeriod;
  this.cpu=cpu;
  if (cpu.getDisAsm() != null) {
    MapTable mapTable=cpu.getDisAsm().getMap();
    if (mapTable != null) {
      this.heapStartAddress=mapTable.heapStartAddress;
      this.stackStartAddress=mapTable.stackStartAddress;
    }
  }
}

Fixed version (ground truth):
public StackUI(MSP430 cpu,int updateCyclePeriod){
  super(new BorderLayout());
  this.updateCyclePeriod=updateCyclePeriod;
  this.cpu=cpu;
}
Program: 5491
Project: 5491
Buggy source:
@Override public void notifyWriteBefore(int type,int adr,int data){
  int size=((stackStartAddress - data) + 0xffff) % 0xffff;
  if (minData[pos] > size) {
    minData[pos]=size;
  }
  if (maxData[pos] < size) {
    maxData[pos]=size;
  }
  if (cpu.cpuCycles - lastCycles > updateCyclePeriod) {
    lastCycles=cpu.cpuCycles;
    pos=(pos + 1) % minData.length;
    minData[pos]=Integer.MAX_VALUE;
    maxData[pos]=0;
    update=true;
    repaint();
  }
}

Fixed version (ground truth):
@Override public void notifyWriteBefore(int register,int data,int mode){
  int size=stackStartAddress - data;
  if (minData[pos] > size) {
    minData[pos]=size;
  }
  if (maxData[pos] < size) {
    maxData[pos]=size;
  }
  if (cpu.cpuCycles - lastCycles > updateCyclePeriod) {
    lastCycles=cpu.cpuCycles;
    pos=(pos + 1) % minData.length;
    minData[pos]=Integer.MAX_VALUE;
    maxData[pos]=0;
    update=true;
    repaint();
  }
}
Program: 5494
Project: 5494
Buggy source:
@Override public int get(int address,AccessMode mode){
  if (address >= MAX_MEM) {
    throw new EmulationException("String_Node_Str" + MSP430Core.this.config.getAddressAsString(address));
  }
  return memorySegments[address >> 8].get(address,mode);
}

Fixed version (ground truth):
@Override public int get(int address,AccessMode mode){
  if (address >= MAX_MEM) {
    throw new EmulationException("String_Node_Str" + Utils.hex(address,4));
  }
  return memorySegments[address >> 8].get(address,mode);
}
Program: 5495
Project: 5495
Buggy source:
@Override public void set(int address,int data,AccessMode mode){
  if (address >= MAX_MEM) {
    throw new EmulationException("String_Node_Str" + MSP430Core.this.config.getAddressAsString(address));
  }
  memorySegments[address >> 8].set(address,data,mode);
}

Fixed version (ground truth):
@Override public void set(int address,int data,AccessMode mode){
  if (address >= MAX_MEM) {
    throw new EmulationException("String_Node_Str" + Utils.hex(address,4));
  }
  memorySegments[address >> 8].set(address,data,mode);
}
Program: 5499
Project: 5499
Buggy source:
private void run() throws EmulationException {
  while (!isStopping) {
    if (cycles > nextOut && !debug) {
      printCPUSpeed(reg[PC]);
      nextOut=cycles + 20000007;
    }
    int pc=emulateOP(-1);
    if (pc >= 0) {
      if (execCounter != null) {
        execCounter[pc]++;
      }
      if (trace != null) {
        trace[tracePos++]=pc;
        if (tracePos >= trace.length)         tracePos=0;
      }
      if (debug) {
        if (servicedInterrupt >= 0) {
          disAsm.disassemble(pc,memory,reg,servicedInterrupt);
        }
 else {
          disAsm.disassemble(pc,memory,reg);
        }
      }
    }
    if (cycles > nextSleep) {
      try {
        Thread.sleep(10);
      }
 catch (      Exception e) {
      }
      nextSleep=cycles + sleepRate;
    }
  }
  isStopping=isBreaking=false;
}

Fixed version (ground truth):
private void run() throws EmulationException {
  while (!isStopping) {
    if (cycles > nextOut && !debug) {
      printCPUSpeed(reg[PC]);
      nextOut=cycles + 20000007;
    }
    int pc=emulateOP(-1);
    if (pc >= 0) {
      if (execCounter != null) {
        execCounter[pc]++;
      }
      if (trace != null) {
        trace[tracePos++]=pc;
        if (tracePos >= trace.length)         tracePos=0;
      }
      if (debug) {
        if (servicedInterrupt >= 0) {
          disAsm.disassemble(pc,memory,reg,servicedInterrupt);
        }
 else {
          disAsm.disassemble(pc,memory,reg);
        }
      }
    }
    if (cycles > nextSleep) {
      try {
        Thread.sleep(100);
      }
 catch (      Exception e) {
      }
      nextSleep=cycles + (long)(rate * dcoFrq / 10);
    }
  }
  isStopping=isBreaking=false;
}
Program: 5500
Project: 5500
Buggy source:
public int setup(MSP430Core cpu,ArrayList<IOUnit> ioUnits){
  Multiplier32 mp=new Multiplier32(cpu,cpu.memory,0x4c0);
  for (int i=0x4c0, n=0x4c0 + 30; i < n; i++) {
    cpu.memOut[i]=mp;
    cpu.memIn[i]=mp;
  }
  for (int i=0, n=uartConfig.length; i < n; i++) {
    GenericUSCI usci=new GenericUSCI(cpu,i,cpu.memory,this);
    for (int a=0; a < 0x20; a++) {
      cpu.setIO(a + uartConfig[i].offset,usci,false);
    }
    System.out.println("String_Node_Str" + usci.getName());
    ioUnits.add(usci);
  }
  ioUnits.add(IOPort.parseIOPort(cpu,47,portConfig[0]));
  ioUnits.add(IOPort.parseIOPort(cpu,42,portConfig[1]));
  for (int i=2; i < portConfig.length; i++) {
    ioUnits.add(IOPort.parseIOPort(cpu,0,portConfig[i]));
  }
  return portConfig.length + uartConfig.length;
}

Fixed version (ground truth):
public int setup(MSP430Core cpu,ArrayList<IOUnit> ioUnits){
  Multiplier32 mp=new Multiplier32(cpu,cpu.memory,0x4c0);
  for (int i=0x4c0, n=0x4c0 + 0x30; i < n; i++) {
    cpu.memOut[i]=mp;
    cpu.memIn[i]=mp;
  }
  for (int i=0, n=uartConfig.length; i < n; i++) {
    GenericUSCI usci=new GenericUSCI(cpu,i,cpu.memory,this);
    for (int a=0; a < 0x20; a++) {
      cpu.setIO(a + uartConfig[i].offset,usci,false);
    }
    System.out.println("String_Node_Str" + usci.getName());
    ioUnits.add(usci);
  }
  ioUnits.add(IOPort.parseIOPort(cpu,47,portConfig[0]));
  ioUnits.add(IOPort.parseIOPort(cpu,42,portConfig[1]));
  for (int i=2; i < portConfig.length; i++) {
    ioUnits.add(IOPort.parseIOPort(cpu,0,portConfig[i]));
  }
  return portConfig.length + uartConfig.length;
}
Program: 5502
Project: 5502
Buggy source:
private void resetTIV(long cycles){
  if (lastTIV == timerOverflow) {
    interruptPending=false;
    if (DEBUG) {
      log("String_Node_Str");
    }
  }
 else   if (lastTIV / 2 < noCompare) {
    if (DEBUG) {
      log(cpu.cycles + "String_Node_Str" + (lastTIV / 2));
    }
    ccr[lastTIV / 2].tcctl&=~CC_IFG;
  }
  cpu.flagInterrupt(ccr1Vector,this,false);
  lastTIV=0;
  for (int i=1; i < noCompare; i++) {
    ccr[i].triggerInterrupt(cycles);
  }
  if (lastTIV == 0 && interruptEnable & interruptPending) {
    cpu.flagInterrupt(ccr1Vector,this,true);
  }
}

Fixed version (ground truth):
private void resetTIV(long cycles){
  if (lastTIV == timerOverflow) {
    interruptPending=false;
    if (DEBUG) {
      log("String_Node_Str");
    }
  }
 else   if (lastTIV / 2 < noCompare) {
    if (DEBUG) {
      log(cpu.cycles + "String_Node_Str" + (lastTIV / 2));
    }
    ccr[lastTIV / 2].tcctl&=~CC_IFG;
  }
  cpu.flagInterrupt(ccr1Vector,this,false);
  lastTIV=0;
  for (int i=1; i < noCompare; i++) {
    ccr[i].triggerInterrupt(cycles);
  }
  if (lastTIV == 0 && interruptEnable & interruptPending) {
    lastTIV=timerOverflow;
    cpu.flagInterrupt(ccr1Vector,this,true);
  }
}
Program: 5503
Project: 5503
Buggy source:
@Override public int getSPIlen(){
  return 0;
}

Fixed version (ground truth):
@Override public int getSPIlen(){
  return spiLen;
}
Program: 5504
Project: 5504
Buggy source:
public int getOutputPowerIndicator(){
  return (registers[REG_TXPOWER] & 0x1f);
}

Fixed version (ground truth):
public int getOutputPowerIndicator(){
  return (memory[REG_TXPOWER] & 0x1f);
}
Program: 5505
Project: 5505
Buggy source:
/** 
 * External APIs for simulators simulating Radio medium, etc.
 */
public void updateActiveFrequency(){
  activeFrequency=registers[REG_FSCTRL] - 357 + 2405 - 0x4000;
  activeChannel=(registers[REG_FSCTRL] - 357 - 0x4000) / 5 + 11;
}

Fixed version (ground truth):
/** 
 * External APIs for simulators simulating Radio medium, etc.
 */
public void updateActiveFrequency(){
  activeFrequency=memory[REG_FSCTRL] - 357 + 2405 - 0x4000;
  activeChannel=(memory[REG_FSCTRL] - 357 - 0x4000) / 5 + 11;
}
Program: 5506
Project: 5506
Buggy source:
@Override public String info(){
  updateActiveFrequency();
  return "String_Node_Str" + isRadioOn + "String_Node_Str"+ chipSelect+ "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str"+ ((registers[REG_GPIOPOLARITY] & FIFOP_POLARITY) == FIFOP_POLARITY)+ "String_Node_Str"+ currentFIFOP+ "String_Node_Str"+ currentFIFO+ "String_Node_Str"+ currentSFD+ "String_Node_Str"+ rxFIFO.stateToString()+ "String_Node_Str"+ rxlen+ "String_Node_Str"+ stateMachine+ "String_Node_Str"+ command+ "String_Node_Str"+ autoAck+ "String_Node_Str"+ addressDecode+ "String_Node_Str"+ autoCRC+ "String_Node_Str"+ Utils.hex8(memory[RAM_PANID + 1])+ Utils.hex8(memory[RAM_PANID])+ "String_Node_Str"+ Utils.hex8(memory[RAM_SHORTADDR + 1])+ Utils.hex8(memory[RAM_SHORTADDR])+ "String_Node_Str"+ getLongAddress()+ "String_Node_Str"+ activeChannel+ "String_Node_Str"+ fifopThr+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String info(){
  updateActiveFrequency();
  return "String_Node_Str" + isRadioOn + "String_Node_Str"+ chipSelect+ "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str"+ ((memory[REG_GPIOPOLARITY] & FIFOP_POLARITY) == FIFOP_POLARITY)+ "String_Node_Str"+ currentFIFOP+ "String_Node_Str"+ currentFIFO+ "String_Node_Str"+ currentSFD+ "String_Node_Str"+ rxFIFO.stateToString()+ "String_Node_Str"+ rxlen+ "String_Node_Str"+ stateMachine+ "String_Node_Str"+ command+ "String_Node_Str"+ autoAck+ "String_Node_Str"+ addressDecode+ "String_Node_Str"+ autoCRC+ "String_Node_Str"+ Utils.hex8(memory[RAM_PANID + 1])+ Utils.hex8(memory[RAM_PANID])+ "String_Node_Str"+ Utils.hex8(memory[RAM_SHORTADDR + 1])+ Utils.hex8(memory[RAM_SHORTADDR])+ "String_Node_Str"+ getLongAddress()+ "String_Node_Str"+ activeChannel+ "String_Node_Str"+ fifopThr+ "String_Node_Str";
}
Program: 5507
Project: 5507
Buggy source:
public int getRegister(int register){
  return registers[register];
}

Fixed version (ground truth):
public int getRegister(int register){
  return memory[register];
}
Program: 5509
Project: 5509
Buggy source:
private void reset(){
  registers[REG_RSSISTAT]=0;
  fifoGPIO=gpio[1];
  fifopGPIO=gpio[2];
  ccaGPIO=gpio[3];
  sfdGPIO=gpio[4];
  for (int i=0; i < gpio.length; i++) {
    gpio[i].setPolarity(true);
  }
}

Fixed version (ground truth):
private void reset(){
  memory[REG_RSSISTAT]=0;
  fifoGPIO=gpio[1];
  fifopGPIO=gpio[2];
  ccaGPIO=gpio[3];
  sfdGPIO=gpio[4];
  for (int i=0; i < gpio.length; i++) {
    gpio[i].setPolarity(true);
  }
}
Program: 5510
Project: 5510
Buggy source:
public void setRegister(int register,int data){
  registers[register]=data;
}

Fixed version (ground truth):
public void setRegister(int register,int data){
  memory[register]=data;
}
Program: 5512
Project: 5512
Buggy source:
@Override public int getConfiguration(int parameter){
  return registers[parameter];
}

Fixed version (ground truth):
@Override public int getConfiguration(int parameter){
  return memory[parameter];
}
Program: 5513
Project: 5513
Buggy source:
void writeMemory(int address,int data){
}

Fixed version (ground truth):
void writeMemory(int address,int data){
  System.out.printf("String_Node_Str",address,data);
  int oldValue=memory[address];
  memory[address]=data;
switch (address) {
case REG_FIFOPCTRL:
    fifopThr=data & FIFOP_THR;
  if (DEBUG)   log("String_Node_Str" + Utils.hex16(oldValue) + "String_Node_Str"+ Utils.hex16(data));
break;
case REG_GPIOPOLARITY:
if (DEBUG) log("String_Node_Str" + Utils.hex16(oldValue) + "String_Node_Str"+ Utils.hex16(data));
if (oldValue != data) {
setFIFOP(currentFIFOP);
setFIFO(currentFIFO);
setSFD(currentSFD);
setCCA(currentCCA);
}
break;
case REG_MDMCTRL0:
addressDecode=(data & ADR_DECODE) != 0;
autoCRC=(data & ADR_AUTOCRC) != 0;
autoAck=(data & AUTOACK) != 0;
break;
case REG_FSCTRL:
{
ChannelListener listener=this.channelListener;
if (listener != null) {
int oldChannel=activeChannel;
updateActiveFrequency();
if (oldChannel != activeChannel) {
listener.channelChanged(activeChannel);
}
}
break;
}
}
configurationChanged(address,oldValue,data);
}
Program: 5514
Project: 5514
Buggy source:
public void setRSSI(int power){
  final int minp=-128 + RSSI_OFFSET;
  final int maxp=128 + RSSI_OFFSET;
  if (power < minp) {
    power=-minp;
  }
  if (power > maxp) {
    power=maxp;
  }
  if (DEBUG)   log("String_Node_Str" + power);
  rssi=power;
  registers[REG_RSSI]=power - RSSI_OFFSET;
  updateCCA();
}

Fixed version (ground truth):
public void setRSSI(int power){
  final int minp=-128 + RSSI_OFFSET;
  final int maxp=128 + RSSI_OFFSET;
  if (power < minp) {
    power=-minp;
  }
  if (power > maxp) {
    power=maxp;
  }
  if (DEBUG)   log("String_Node_Str" + power);
  rssi=power;
  memory[REG_RSSI]=power - RSSI_OFFSET;
  updateCCA();
}
Program: 5515
Project: 5515
Buggy source:
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect) {
    instruction=-1;
    spiLen=0;
    command=null;
  }
  if (DEBUG) {
    log("String_Node_Str" + chipSelect);
  }
}

Fixed version (ground truth):
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect) {
    instruction=-1;
    spiLen=0;
    if (command != null)     command.executeSPICommand();
    command=null;
  }
  if (DEBUG) {
    log("String_Node_Str" + chipSelect);
  }
}
Program: 5519
Project: 5519
Buggy source:
SPICommand(String pattern){
  String[] subs=pattern.split("String_Node_Str");
  name=subs[0];
  System.out.println("String_Node_Str" + subs[0]);
  value=0;
  mask=0;
  int c=0;
  int start=0;
  String currentName="String_Node_Str";
  bitCount=0;
  for (int i=1; i < subs.length; i++) {
    if (subs[i].equals("String_Node_Str")) {
      value=(value << 1) + 1;
      mask=(mask << 1) | 1;
      bitCount++;
    }
 else     if (subs[i].equals("String_Node_Str")) {
      value=(value << 1);
      mask=(mask << 1) | 1;
      bitCount++;
    }
 else     if (subs[i].equals(currentName)) {
    }
 else {
      if (start != 0) {
        System.out.println("String_Node_Str" + currentName + "String_Node_Str"+ start+ "String_Node_Str"+ (c - 1)+ "String_Node_Str");
        if (bitFields == null)         bitFields=new ArrayList<SPICommand.BitField>();
        bitFields.add(new BitField(currentName,start,c - 1));
      }
 else {
        System.out.println("String_Node_Str" + c);
        if (c < 8) {
          value=value << (8 - c);
          mask=mask << (8 - c);
        }
      }
      currentName=subs[i];
      start=c;
    }
    c++;
  }
  if (start != 0) {
    System.out.println("String_Node_Str" + currentName + "String_Node_Str"+ start+ "String_Node_Str"+ (c - 1)+ "String_Node_Str");
  }
  System.out.printf("String_Node_Str",value);
  System.out.printf("String_Node_Str",value);
}

Fixed version (ground truth):
SPICommand(String pattern){
  String[] subs=pattern.split("String_Node_Str");
  name=subs[0];
  System.out.println("String_Node_Str" + subs[0]);
  value=0;
  mask=0;
  int c=0;
  int start=0;
  String currentName="String_Node_Str";
  bitCount=0;
  for (int i=1; i < subs.length; i++) {
    if (subs[i].equals("String_Node_Str")) {
      if (c < 8) {
        value=(value << 1) + 1;
        mask=(mask << 1) | 1;
        bitCount++;
      }
    }
 else     if (subs[i].equals("String_Node_Str")) {
      if (c < 8) {
        value=(value << 1);
        mask=(mask << 1) | 1;
        bitCount++;
      }
    }
 else     if (subs[i].equals(currentName)) {
    }
 else {
      if (start != 0) {
        System.out.println("String_Node_Str" + currentName + "String_Node_Str"+ start+ "String_Node_Str"+ (c - 1)+ "String_Node_Str");
        if (bitFields == null)         bitFields=new ArrayList<SPICommand.BitField>();
        bitFields.add(new BitField(currentName,start,c - 1));
      }
 else {
        System.out.printf("String_Node_Str",c,value,mask);
        if (c < 8) {
          value=value << (8 - c);
          mask=mask << (8 - c);
        }
      }
      currentName=subs[i];
      start=c;
    }
    c++;
  }
  if (start != 0) {
    System.out.println("String_Node_Str" + currentName + "String_Node_Str"+ start+ "String_Node_Str"+ (c - 1)+ "String_Node_Str");
  }
  System.out.printf("String_Node_Str",value);
  System.out.printf("String_Node_Str",mask);
}
Program: 5521
Project: 5521
Buggy source:
public DebugInfo getDebugInfo(int address){
  for (int i=0; i < lineInfo.size(); i++) {
    LineData data=lineInfo.get(i);
    int start=data.lineEntries[0].address;
    int end=data.lineEntries[data.lineEntries.length - 1].address;
    if (address <= end && address >= start) {
      for (int j=0; j < data.lineEntries.length; j++) {
        if (data.lineEntries[j].address >= address) {
          return new DebugInfo(data.lineEntries[j].line,null,data.sourceFiles[0],"String_Node_Str");
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public DebugInfo getDebugInfo(int address){
  for (int i=0; i < lineInfo.size(); i++) {
    LineData data=lineInfo.get(i);
    int start=data.lineEntries[0].address;
    int end=data.lineEntries[data.lineEntries.length - 1].address;
    if (start == 0)     continue;
    if (address <= end && address >= start) {
      for (int j=0; j < data.lineEntries.length; j++) {
        LineEntry lineEntry=data.lineEntries[j];
        int startEntry=lineEntry.address;
        int endEntry;
        if (j + 1 < data.lineEntries.length) {
          endEntry=data.lineEntries[j + 1].address - 1;
        }
 else {
          continue;
        }
        if (address >= startEntry && address <= endEntry) {
          return new DebugInfo(lineEntry.line,null,data.sourceFiles[lineEntry.file - 1],"String_Node_Str");
        }
      }
    }
  }
  return null;
}
Program: 5522
Project: 5522
Buggy source:
LineEntry(int line,int adr){
  this.line=line;
  address=adr;
}

Fixed version (ground truth):
LineEntry(int line,int adr,int file){
  this.line=line;
  this.address=adr;
  this.file=file;
}
Program: 5524
Project: 5524
Buggy source:
public long stepInstructions(int count) throws EmulationException {
  if (isRunning()) {
    throw new IllegalStateException("String_Node_Str");
  }
  setRunning(true);
  while (count-- > 0 && isRunning()) {
    int pc=emulateOP(-1);
    if (pc >= 0) {
      if (execCounter != null) {
        execCounter[pc]++;
      }
      if (trace != null) {
        trace[tracePos++]=pc;
        if (tracePos > trace.length)         tracePos=0;
      }
    }
    if (debug) {
      if (servicedInterrupt >= 0) {
        disAsm.disassemble(reg[PC],memory,reg,servicedInterrupt);
      }
 else {
        disAsm.disassemble(reg[PC],memory,reg);
      }
    }
  }
  setRunning(false);
  return cycles;
}

Fixed version (ground truth):
public long stepInstructions(int count) throws EmulationException {
  if (isRunning()) {
    throw new IllegalStateException("String_Node_Str");
  }
  setRunning(true);
  while (count-- > 0 && isRunning()) {
    int pc=emulateOP(-1);
    if (pc >= 0) {
      if (execCounter != null) {
        execCounter[pc]++;
      }
      if (trace != null) {
        trace[tracePos++]=pc;
        if (tracePos >= trace.length)         tracePos=0;
      }
    }
    if (debug) {
      if (servicedInterrupt >= 0) {
        disAsm.disassemble(reg[PC],memory,reg,servicedInterrupt);
      }
 else {
        disAsm.disassemble(reg[PC],memory,reg);
      }
    }
  }
  setRunning(false);
  return cycles;
}
Program: 5528
Project: 5528
Buggy source:
private void setFIFOP(boolean fifop){
  fifoP=fifop;
  if (DEBUG)   log("String_Node_Str" + fifop);
  if ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) {
    fifopPort.setPinState(fifopPin,fifop ? 0 : 1);
  }
 else {
    fifopPort.setPinState(fifopPin,fifop ? 1 : 0);
  }
}

Fixed version (ground truth):
private void setFIFOP(boolean fifop){
  currentFIFOP=fifop;
  if (DEBUG)   log("String_Node_Str" + fifop);
  if ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) {
    fifopPort.setPinState(fifopPin,fifop ? 0 : 1);
  }
 else {
    fifopPort.setPinState(fifopPin,fifop ? 1 : 0);
  }
}
Program: 5529
Project: 5529
Buggy source:
public String info(){
  updateActiveFrequency();
  return "String_Node_Str" + on + "String_Node_Str"+ chipSelect+ "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str"+ ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY)+ "String_Node_Str"+ fifoP+ "String_Node_Str"+ currentFIFO+ "String_Node_Str"+ currentSFD+ "String_Node_Str"+ rxFIFO.stateToString()+ "String_Node_Str"+ rxlen+ "String_Node_Str"+ stateMachine+ "String_Node_Str"+ state+ "String_Node_Str"+ autoAck+ "String_Node_Str"+ addressDecode+ "String_Node_Str"+ autoCRC+ "String_Node_Str"+ Utils.hex8(memory[RAM_PANID + 1])+ Utils.hex8(memory[RAM_PANID])+ "String_Node_Str"+ Utils.hex8(memory[RAM_SHORTADDR + 1])+ Utils.hex8(memory[RAM_SHORTADDR])+ "String_Node_Str"+ getLongAddress()+ "String_Node_Str"+ activeChannel+ "String_Node_Str"+ fifopThr+ "String_Node_Str";
}

Fixed version (ground truth):
public String info(){
  updateActiveFrequency();
  return "String_Node_Str" + on + "String_Node_Str"+ chipSelect+ "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str"+ ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY)+ "String_Node_Str"+ currentFIFOP+ "String_Node_Str"+ currentFIFO+ "String_Node_Str"+ currentSFD+ "String_Node_Str"+ rxFIFO.stateToString()+ "String_Node_Str"+ rxlen+ "String_Node_Str"+ stateMachine+ "String_Node_Str"+ state+ "String_Node_Str"+ autoAck+ "String_Node_Str"+ addressDecode+ "String_Node_Str"+ autoCRC+ "String_Node_Str"+ Utils.hex8(memory[RAM_PANID + 1])+ Utils.hex8(memory[RAM_PANID])+ "String_Node_Str"+ Utils.hex8(memory[RAM_SHORTADDR + 1])+ Utils.hex8(memory[RAM_SHORTADDR])+ "String_Node_Str"+ getLongAddress()+ "String_Node_Str"+ activeChannel+ "String_Node_Str"+ fifopThr+ "String_Node_Str";
}
Program: 5530
Project: 5530
Buggy source:
private void setSFD(boolean sfd){
  if ((registers[REG_IOCFG0] & SFD_POLARITY) == SFD_POLARITY)   sfdPort.setPinState(sfdPin,sfd ? 0 : 1);
 else   sfdPort.setPinState(sfdPin,sfd ? 1 : 0);
  currentSFD=sfd;
  if (DEBUG)   log("String_Node_Str" + sfd + "String_Node_Str"+ cpu.cycles);
}

Fixed version (ground truth):
private void setSFD(boolean sfd){
  currentSFD=sfd;
  if ((registers[REG_IOCFG0] & SFD_POLARITY) == SFD_POLARITY)   sfdPort.setPinState(sfdPin,sfd ? 0 : 1);
 else   sfdPort.setPinState(sfdPin,sfd ? 1 : 0);
  if (DEBUG)   log("String_Node_Str" + sfd + "String_Node_Str"+ cpu.cycles);
}
Program: 5533
Project: 5533
Buggy source:
private void setReg(int address,int data){
  int oldValue=registers[address];
  registers[address]=data;
switch (address) {
case REG_IOCFG0:
    fifopThr=data & FIFOP_THR;
  if (DEBUG)   log("String_Node_Str" + registers[address]);
break;
case REG_IOCFG1:
if (DEBUG) log("String_Node_Str" + ((registers[address] & SFDMUX) >> SFDMUX) + "String_Node_Str"+ (registers[address] & CCAMUX));
updateCCA();
break;
case REG_MDMCTRL0:
addressDecode=(data & ADR_DECODE) != 0;
autoCRC=(data & ADR_AUTOCRC) != 0;
autoAck=(data & AUTOACK) != 0;
break;
case REG_FSCTRL:
if (cl != null) {
updateActiveFrequency();
cl.changedChannel(activeChannel);
}
break;
}
configurationChanged(address,oldValue,data);
}

Fixed version (ground truth):
private void setReg(int address,int data){
  int oldValue=registers[address];
  registers[address]=data;
switch (address) {
case REG_IOCFG0:
    fifopThr=data & FIFOP_THR;
  if (DEBUG)   log("String_Node_Str" + Utils.hex16(oldValue) + "String_Node_Str"+ Utils.hex16(data));
if ((oldValue & POLARITY_MASK) != (data & POLARITY_MASK)) {
  setFIFOP(currentFIFOP);
  setFIFO(currentFIFO);
  setSFD(currentSFD);
  setCCA(currentCCA);
}
break;
case REG_IOCFG1:
if (DEBUG) log("String_Node_Str" + ((registers[address] & SFDMUX) >> SFDMUX) + "String_Node_Str"+ (registers[address] & CCAMUX));
updateCCA();
break;
case REG_MDMCTRL0:
addressDecode=(data & ADR_DECODE) != 0;
autoCRC=(data & ADR_AUTOCRC) != 0;
autoAck=(data & AUTOACK) != 0;
break;
case REG_FSCTRL:
if (cl != null) {
updateActiveFrequency();
cl.changedChannel(activeChannel);
}
break;
}
configurationChanged(address,oldValue,data);
}
Program: 5534
Project: 5534
Buggy source:
private void setFIFO(boolean fifo){
  if (DEBUG)   log("String_Node_Str" + fifo);
  currentFIFO=fifo;
  fifoPort.setPinState(fifoPin,fifo ? 1 : 0);
}

Fixed version (ground truth):
private void setFIFO(boolean fifo){
  currentFIFO=fifo;
  if (DEBUG)   log("String_Node_Str" + fifo);
  if ((registers[REG_IOCFG0] & FIFO_POLARITY) == FIFO_POLARITY) {
    fifoPort.setPinState(fifoPin,fifo ? 0 : 1);
  }
 else {
    fifoPort.setPinState(fifoPin,fifo ? 1 : 0);
  }
}
Program: 5535
Project: 5535
Buggy source:
private void setInternalCCA(boolean clear){
  setCCAPin(clear);
  if (DEBUG)   log("String_Node_Str" + clear);
}

Fixed version (ground truth):
private void setInternalCCA(boolean clear){
  setCCA(clear);
  if (DEBUG)   log("String_Node_Str" + clear);
}
Program: 5536
Project: 5536
Buggy source:
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect) {
    state=SpiState.WAITING;
  }
  if (DEBUG) {
    log("String_Node_Str" + chipSelect);
  }
}

Fixed version (ground truth):
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect) {
    if (state == SpiState.WRITE_REGISTER && usartDataPos == 1) {
      usartDataValue=(registers[usartDataAddress] & 0xff) | (usartDataValue & 0xff00);
      if (DEBUG) {
        log("String_Node_Str" + Utils.hex8(usartDataAddress) + "String_Node_Str"+ usartDataValue);
      }
      setReg(usartDataAddress,usartDataValue);
    }
    state=SpiState.WAITING;
  }
  if (DEBUG) {
    log("String_Node_Str" + chipSelect);
  }
}
Program: 5537
Project: 5537
Buggy source:
public CC2420(MSP430Core cpu){
  super("String_Node_Str","String_Node_Str",cpu);
  rxFIFO=new ArrayFIFO("String_Node_Str",memory,RAM_RXFIFO,128);
  registers[REG_SNOP]=0;
  registers[REG_TXCTRL]=0xa0ff;
  setModeNames(MODE_NAMES);
  setMode(MODE_POWER_OFF);
  fifoP=false;
  rxFIFO.reset();
  overflow=false;
  reset();
}

Fixed version (ground truth):
public CC2420(MSP430Core cpu){
  super("String_Node_Str","String_Node_Str",cpu);
  rxFIFO=new ArrayFIFO("String_Node_Str",memory,RAM_RXFIFO,128);
  registers[REG_SNOP]=0;
  registers[REG_TXCTRL]=0xa0ff;
  setModeNames(MODE_NAMES);
  setMode(MODE_POWER_OFF);
  currentFIFOP=false;
  rxFIFO.reset();
  overflow=false;
  reset();
}