Program: 178534
Project: 178534
Buggy source:
public TreeOperation handleTreeMergeParagraph(TreeMergeParagraph op1){
  if (sp == op1.getPosition()) {
    if (ep == sp - 1) {
      return new TreeCompositeOperation(this,op1);
    }
    if (ep > sp) {
      return new TreeCompositeOperation(new TreeMoveParagraph(siteId,sp - 1,ep - 1),new TreeMergeParagraph(ep - 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
 else {
      return new TreeCompositeOperation(this,new TreeMergeParagraph(ep + 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
  }
  if (sp == op1.getPosition() - 1) {
    if (ep == sp + 2) {
      return new TreeCompositeOperation(this,op1);
    }
    if (ep > sp) {
      return new TreeCompositeOperation(this,new TreeMergeParagraph(ep,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
 else {
      return new TreeCompositeOperation(new TreeMoveParagraph(siteId,sp + 1,ep + 1),new TreeMergeParagraph(ep + 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
  }
  if (op1.getPosition() < sp) {
    if (op1.getPosition() == ep) {
      return new TreeCompositeOperation(new TreeMoveParagraph(siteId,ep,ep + 2),op1);
    }
    if (op1.getPosition() < ep) {
      return op1;
    }
    return new TreeMergeParagraph(op1.getPosition() + 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr);
  }
  if (op1.getPosition() == ep) {
    return new TreeCompositeOperation(new TreeMoveParagraph(siteId,ep - 1,ep + 1),new TreeMergeParagraph(op1.getPosition() - 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
  }
  if (op1.getPosition() < ep) {
    return new TreeMergeParagraph(op1.getPosition() - 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr);
  }
  return op1;
}

Fixed version (ground truth):
public TreeOperation handleTreeMergeParagraph(TreeMergeParagraph op1){
  if (sp == op1.getPosition()) {
    if (ep == sp - 1) {
      return new TreeCompositeOperation(this,op1);
    }
    if (ep > sp) {
      return new TreeCompositeOperation(new TreeMoveParagraph(siteId,sp - 1,ep - 1),new TreeMergeParagraph(op1.getSiteId(),ep - 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
 else {
      return new TreeCompositeOperation(this,new TreeMergeParagraph(op1.getSiteId(),ep + 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
  }
  if (sp == op1.getPosition() - 1) {
    if (ep == sp + 2) {
      return new TreeCompositeOperation(this,op1);
    }
    if (ep > sp) {
      return new TreeCompositeOperation(this,new TreeMergeParagraph(op1.getSiteId(),ep,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
 else {
      return new TreeCompositeOperation(new TreeMoveParagraph(siteId,sp + 1,ep + 1),new TreeMergeParagraph(op1.getSiteId(),ep + 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
    }
  }
  if (op1.getPosition() < sp) {
    if (op1.getPosition() == ep) {
      return new TreeCompositeOperation(new TreeMoveParagraph(siteId,ep,ep + 2),op1);
    }
    if (op1.getPosition() < ep) {
      return op1;
    }
    return new TreeMergeParagraph(op1.getSiteId(),op1.getPosition() + 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr);
  }
  if (op1.getPosition() == ep) {
    return new TreeCompositeOperation(new TreeMoveParagraph(siteId,ep - 1,ep + 1),new TreeMergeParagraph(op1.getSiteId(),op1.getPosition() - 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr));
  }
  if (op1.getPosition() < ep) {
    return new TreeMergeParagraph(op1.getSiteId(),op1.getPosition() - 1,op1.leftSiblingChildrenNr,op1.rightSiblingChildrenNr);
  }
  return op1;
}