Program: 141639
Project: 141639
Buggy source:
public void compareAddressBooks(boolean initMode){
  for (  String currentUID : listSyncContacts) {
    if (davContacts.get(currentUID) == null) {
      if (outlookContacts.get(currentUID) != null) {
        outlookContacts.get(currentUID).setStatus(Contact.Status.DELETE);
      }
    }
    if (outlookContacts.get(currentUID) == null) {
      if (davContacts.get(currentUID) != null) {
        davContacts.get(currentUID).setStatus(Contact.Status.DELETE);
      }
    }
  }
  List<Contact> newOutlookContacts=new ArrayList();
  List<Contact> newDAVContacts=new ArrayList();
  List<Contact> replacedOutlookContacts=new ArrayList();
  List<Contact> replacedlDAVContacts=new ArrayList();
  for (  Entry<String,Contact> outlookEntry : outlookContacts.entrySet()) {
    Contact outlookContact=outlookEntry.getValue();
    String outlookKey=outlookEntry.getKey();
    if (outlookContact.getStatus() != Contact.Status.READIN && outlookContact.getStatus() != Contact.Status.UIDADDED) {
      continue;
    }
    Contact davContact=davContacts.get(outlookKey);
    if ((outlookContact.getStatus() == Contact.Status.UIDADDED) != (davContact == null)) {
      Status.print("String_Node_Str");
      continue;
    }
    if (davContact == null) {
      if (initMode) {
        Contact equalDavContact=null;
        for (        Contact initDavContact : davContacts.values()) {
          if (outlookContact.equalTo(initDavContact) && initDavContact.getStatus() == Contact.Status.READIN) {
            equalDavContact=initDavContact;
            break;
          }
        }
        if (equalDavContact != null) {
          Contact newContact=new Contact(outlookContact,Contact.Status.UIDADDED,equalDavContact.getUid());
          newOutlookContacts.add(newContact);
          replacedOutlookContacts.add(outlookContact);
          equalDavContact.setStatus(Contact.Status.UNCHANGED);
          continue;
        }
      }
      Contact newContact=new Contact(outlookContact,Contact.Status.NEW);
      newDAVContacts.add(newContact);
      continue;
    }
    if (outlookContact.equalTo(davContact)) {
      outlookContact.setStatus(Contact.Status.UNCHANGED);
      davContact.setStatus(Contact.Status.UNCHANGED);
      continue;
    }
    if (outlookContact.getLastModificationTime().getTime() > davContact.getLastModificationTime().getTime()) {
      replacedlDAVContacts.add(davContact);
      Contact newContact=new Contact(outlookContact,Contact.Status.CHANGED);
      newDAVContacts.add(newContact);
      outlookContact.setStatus(Contact.Status.UNCHANGED);
      davContact.setStatus(Contact.Status.DELETE);
    }
 else {
      replacedOutlookContacts.add(outlookContact);
      Contact newContact=new Contact(davContact,Contact.Status.CHANGED);
      newContact.setEntryID(outlookContact.getEntryID());
      newOutlookContacts.add(newContact);
      davContact.setStatus(Contact.Status.UNCHANGED);
      outlookContact.setStatus(Contact.Status.DELETE);
    }
  }
  for (  Contact contact : replacedOutlookContacts) {
    this.removeContact(Addressbook.OUTLOOKADDRESSBOOK,contact.getUid());
  }
  for (  Contact contact : replacedlDAVContacts) {
    this.removeContact(Addressbook.WEBDAVADDRESSBOOK,contact.getUid());
  }
  for (  Contact contact : newDAVContacts) {
    this.addContact(Contacts.Addressbook.WEBDAVADDRESSBOOK,contact);
  }
  for (  Entry<String,Contact> davEntry : davContacts.entrySet()) {
    Contact davContact=davEntry.getValue();
    String davKey=davEntry.getKey();
    if (davContact.getStatus() != Contact.Status.READIN && (davContact.getStatus() != Contact.Status.UIDADDED)) {
      continue;
    }
    Contact outlookContact=outlookContacts.get(davKey);
    if (outlookContact == null) {
      Contact newContact=new Contact(davContact,Contact.Status.NEW);
      newOutlookContacts.add(newContact);
    }
  }
  for (  Contact contact : newOutlookContacts) {
    this.addContact(Contacts.Addressbook.OUTLOOKADDRESSBOOK,contact);
  }
}

Fixed version (ground truth):
public void compareAddressBooks(boolean initMode){
  for (  String currentUID : listSyncContacts) {
    if (davContacts.get(currentUID) == null) {
      if (outlookContacts.get(currentUID) != null) {
        outlookContacts.get(currentUID).setStatus(Contact.Status.DELETE);
      }
    }
    if (outlookContacts.get(currentUID) == null) {
      if (davContacts.get(currentUID) != null) {
        davContacts.get(currentUID).setStatus(Contact.Status.DELETE);
      }
    }
  }
  List<Contact> newOutlookContacts=new ArrayList();
  List<Contact> newDAVContacts=new ArrayList();
  List<Contact> replacedOutlookContacts=new ArrayList();
  List<Contact> replacedlDAVContacts=new ArrayList();
  for (  Entry<String,Contact> outlookEntry : outlookContacts.entrySet()) {
    Contact outlookContact=outlookEntry.getValue();
    String outlookKey=outlookEntry.getKey();
    if (outlookContact.getStatus() != Contact.Status.READIN && outlookContact.getStatus() != Contact.Status.UIDADDED) {
      continue;
    }
    Contact davContact=davContacts.get(outlookKey);
    if ((outlookContact.getStatus() == Contact.Status.UIDADDED) != (davContact == null)) {
      if (!initMode) {
        Status.print("String_Node_Str");
        continue;
      }
    }
    if (davContact == null) {
      if (initMode) {
        Contact equalDavContact=null;
        for (        Contact initDavContact : davContacts.values()) {
          if (outlookContact.equalTo(initDavContact) && initDavContact.getStatus() == Contact.Status.READIN) {
            equalDavContact=initDavContact;
            break;
          }
        }
        if (equalDavContact != null) {
          Contact newContact=new Contact(outlookContact,Contact.Status.UIDADDED,equalDavContact.getUid());
          newOutlookContacts.add(newContact);
          replacedOutlookContacts.add(outlookContact);
          equalDavContact.setStatus(Contact.Status.UNCHANGED);
          continue;
        }
      }
      Contact newContact=new Contact(outlookContact,Contact.Status.NEW);
      newDAVContacts.add(newContact);
      continue;
    }
    if (outlookContact.equalTo(davContact)) {
      outlookContact.setStatus(Contact.Status.UNCHANGED);
      davContact.setStatus(Contact.Status.UNCHANGED);
      continue;
    }
    if (outlookContact.getLastModificationTime().getTime() > davContact.getLastModificationTime().getTime()) {
      replacedlDAVContacts.add(davContact);
      Contact newContact=new Contact(outlookContact,Contact.Status.CHANGED);
      newDAVContacts.add(newContact);
      outlookContact.setStatus(Contact.Status.UNCHANGED);
      davContact.setStatus(Contact.Status.DELETE);
    }
 else {
      replacedOutlookContacts.add(outlookContact);
      Contact newContact=new Contact(davContact,Contact.Status.CHANGED);
      newContact.setEntryID(outlookContact.getEntryID());
      newOutlookContacts.add(newContact);
      davContact.setStatus(Contact.Status.UNCHANGED);
      outlookContact.setStatus(Contact.Status.DELETE);
    }
  }
  for (  Contact contact : replacedOutlookContacts) {
    this.removeContact(Addressbook.OUTLOOKADDRESSBOOK,contact.getUid());
  }
  for (  Contact contact : replacedlDAVContacts) {
    this.removeContact(Addressbook.WEBDAVADDRESSBOOK,contact.getUid());
  }
  for (  Contact contact : newDAVContacts) {
    this.addContact(Contacts.Addressbook.WEBDAVADDRESSBOOK,contact);
  }
  for (  Entry<String,Contact> davEntry : davContacts.entrySet()) {
    Contact davContact=davEntry.getValue();
    String davKey=davEntry.getKey();
    if (davContact.getStatus() != Contact.Status.READIN && (davContact.getStatus() != Contact.Status.UIDADDED)) {
      continue;
    }
    Contact outlookContact=outlookContacts.get(davKey);
    if (outlookContact == null) {
      Contact newContact=new Contact(davContact,Contact.Status.NEW);
      newOutlookContacts.add(newContact);
    }
  }
  for (  Contact contact : newOutlookContacts) {
    this.addContact(Contacts.Addressbook.OUTLOOKADDRESSBOOK,contact);
  }
}