nus-yam/ex-repair huggingface dataset:
Program: 35236
Project: 35236
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit<V> cb,long[] minOrig,long[] maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  int intArrayLen=(DEPTH + 63) >>> 6;
  this.valIntTemplate=new long[intArrayLen];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.rootKey != null) {
    checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  if (cb.root == null) {
    return;
  }
  Node<V> n=cb.root;
  readInfix(n,valIntTemplate);
  if (!checkMatch(valIntTemplate,n.posDiff)) {
    return;
  }
  stack[++stackTop]=cb.root;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") QueryIterator(CritBit<V> cb,long[] minOrig,long[] maxOrig,int DEPTH){
  this.cb=cb;
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  int intArrayLen=(DEPTH + 63) >>> 6;
  this.valIntTemplate=new long[intArrayLen];
  this.loEnclosed=new boolean[intArrayLen];
  this.hiEnclosed=new boolean[intArrayLen];
  reset(minOrig,maxOrig);
}
Program: 35237
Project: 35237
Buggy source:
private boolean checkMatch(long keyTemplate,int currentDepth){
  int toIgnore=64 - currentDepth;
  long mask=(-1L) << toIgnore;
  long myKey=keyTemplate & mask;
  if ((myKey | (minOrig & mask)) != myKey) {
    return false;
  }
  if ((myKey & (maxOrig & mask)) != myKey) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
private boolean checkMatch(long keyTemplate,int currentDepth){
  int toIgnore=63 - currentDepth;
  return (((keyTemplate | minOrig) & maxOrig) ^ keyTemplate) >>> toIgnore == 0;
}
Program: 35238
Project: 35238
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    hasNext=checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff)) {
    hasNext=false;
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    hasNext=checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff - 1)) {
    hasNext=false;
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}
Program: 35239
Project: 35239
Buggy source:
/** 
 * Full comparison on the parameter. Assigns the parameter to 'nextVal' if comparison fits.
 * @param keyTemplate
 * @return Whether we have a match or not
 */
private boolean checkMatchFullIntoNextVal(long keyTemplate,V value){
  if ((keyTemplate | minOrig) != keyTemplate) {
    return false;
  }
  if ((keyTemplate & maxOrig) != keyTemplate) {
    return false;
  }
  nextValue=value;
  nextKey=keyTemplate;
  return true;
}

Fixed version (ground truth):
/** 
 * Full comparison on the parameter. Assigns the parameter to 'nextVal' if comparison fits.
 * @param keyTemplate
 * @return Whether we have a match or not
 */
private boolean checkMatchFullIntoNextVal(long keyTemplate,V value){
  if (((keyTemplate | minOrig) & maxOrig) != keyTemplate) {
    return false;
  }
  nextValue=value;
  nextKey=keyTemplate;
  return true;
}
Program: 35240
Project: 35240
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    hasNext=checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff)) {
    hasNext=false;
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    hasNext=checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff - 1)) {
    hasNext=false;
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}
Program: 35241
Project: 35241
Buggy source:
private boolean checkMatch(long keyTemplate,int currentDepth){
  int toIgnore=64 - currentDepth;
  long mask=(-1L) << toIgnore;
  long myKey=keyTemplate & mask;
  if ((myKey | (minOrig & mask)) != myKey) {
    return false;
  }
  if ((myKey & (maxOrig & mask)) != myKey) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
private boolean checkMatch(long keyTemplate,int currentDepth){
  int toIgnore=63 - currentDepth;
  return (((keyTemplate | minOrig) & maxOrig) ^ keyTemplate) >>> toIgnore == 0;
}
Program: 35242
Project: 35242
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    hasNext=checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    hasNext=checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff - 1)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}
Program: 35243
Project: 35243
Buggy source:
/** 
 * Full comparison on the parameter. Assigns the parameter to 'nextVal' if comparison fits.
 * @param keyTemplate
 * @return Whether we have a match or not
 */
private boolean checkMatchFullIntoNextVal(long keyTemplate,V value){
  if ((keyTemplate | minOrig) != keyTemplate) {
    return false;
  }
  if ((keyTemplate & maxOrig) != keyTemplate) {
    return false;
  }
  nextValue=value;
  nextKey=keyTemplate;
  return true;
}

Fixed version (ground truth):
/** 
 * Full comparison on the parameter. Assigns the parameter to 'nextVal' if comparison fits.
 * @param keyTemplate
 * @return Whether we have a match or not
 */
private boolean checkMatchFullIntoNextVal(long keyTemplate,V value){
  if (((keyTemplate | minOrig) & maxOrig) != keyTemplate) {
    return false;
  }
  nextValue=value;
  nextKey=keyTemplate;
  return true;
}
Program: 35244
Project: 35244
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    hasNext=checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    hasNext=checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff - 1)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}
Program: 35245
Project: 35245
Buggy source:
private CritBit64<Integer> newCritBit(){
  return CritBit64.create();
}

Fixed version (ground truth):
private <T>CritBit64<T> newCritBit(){
  return CritBit64.create();
}
Program: 35246
Project: 35246
Buggy source:
@Override public boolean hasNext(){
  return nextValue != null;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return nextKey != null;
}
Program: 35247
Project: 35247
Buggy source:
/** 
 * @param n
 * @param infixStart The bit-position of the first infix bits relative to the whole value
 * @param currentPrefix
 */
private static <T>void readInfix(Node<T> n,long[] currentPrefix){
  if (n.infix == null) {
    return;
  }
  int dst=n.posFirstBit >>> 6;
  System.arraycopy(n.infix,0,currentPrefix,dst,n.infix.length);
}

Fixed version (ground truth):
/** 
 * @param n
 * @param infixStart The bit-position of the first infix bits relative to the whole value
 * @param currentPrefix
 */
protected static <T>void readInfix(Node<T> n,long[] currentPrefix){
  if (n.infix == null) {
    return;
  }
  int dst=n.posFirstBit >>> 6;
  System.arraycopy(n.infix,0,currentPrefix,dst,n.infix.length);
}
Program: 35248
Project: 35248
Buggy source:
/** 
 * Full comparison on the parameter. Assigns the parameter to 'nextVal' if comparison fits.
 * @param keyTemplate
 * @return Whether we have a match or not
 */
private boolean checkMatchFullIntoNextVal(long[] keyTemplate,V value){
  boolean loMatch=false;
  boolean hiMatch=false;
  for (int i=0; i < keyTemplate.length; i++) {
    if ((!loMatch && minOrig[i] > keyTemplate[i]) || (!hiMatch && keyTemplate[i] > maxOrig[i])) {
      return false;
    }
    if (minOrig[i] < keyTemplate[i]) {
      loMatch=true;
      if (loMatch && hiMatch) {
        break;
      }
    }
    if (keyTemplate[i] < maxOrig[i]) {
      hiMatch=true;
      if (loMatch && hiMatch) {
        break;
      }
    }
  }
  nextValue=value;
  nextKey=CritBit.clone(keyTemplate);
  return true;
}

Fixed version (ground truth):
/** 
 * Full comparison on the parameter. Assigns the parameter to 'nextVal' if comparison fits.
 * @param keyTemplate
 * @return Whether we have a match or not
 */
private boolean checkMatchFullIntoNextVal(long[] keyTemplate,V value){
  boolean loMatch=false;
  boolean hiMatch=false;
  for (int i=0; i < keyTemplate.length; i++) {
    if ((!loMatch && minOrig[i] > keyTemplate[i]) || (!hiMatch && keyTemplate[i] > maxOrig[i])) {
      return false;
    }
    if (i >= minOrig.length || i >= keyTemplate.length) {
      System.out.print("String_Node_Str");
    }
    if (minOrig[i] < keyTemplate[i]) {
      loMatch=true;
      if (loMatch && hiMatch) {
        break;
      }
    }
    if (keyTemplate[i] < maxOrig[i]) {
      hiMatch=true;
      if (loMatch && hiMatch) {
        break;
      }
    }
  }
  nextValue=value;
  nextKey=CritBit.clone(keyTemplate);
  return true;
}
Program: 35249
Project: 35249
Buggy source:
private void findNext(){
  while (stackTop >= 0) {
    Node<V> n=stack[stackTop];
    if (readHigherNext[stackTop] == READ_LOWER) {
      readHigherNext[stackTop]=READ_UPPER;
      long valTemp=BitTools.set0(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.lo == null) {
          if (checkMatchFullIntoNextVal(n.loPost,n.loVal)) {
            return;
          }
        }
 else {
          stack[++stackTop]=n.lo;
          prefixes[stackTop]=n.loPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    if (readHigherNext[stackTop] == READ_UPPER) {
      readHigherNext[stackTop]=RETURN_TO_PARENT;
      long valTemp=BitTools.set1(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.hi == null) {
          if (checkMatchFullIntoNextVal(n.hiPost,n.hiVal)) {
            --stackTop;
            return;
          }
        }
 else {
          stack[++stackTop]=n.hi;
          prefixes[stackTop]=n.hiPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    --stackTop;
  }
  nextValue=null;
  nextKey=0;
}

Fixed version (ground truth):
private void findNext(){
  while (stackTop >= 0) {
    Node<V> n=stack[stackTop];
    if (readHigherNext[stackTop] == READ_LOWER) {
      readHigherNext[stackTop]=READ_UPPER;
      long valTemp=BitTools.set0(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.lo == null) {
          if (checkMatchFullIntoNextVal(n.loPost,n.loVal)) {
            return;
          }
        }
 else {
          stack[++stackTop]=n.lo;
          prefixes[stackTop]=n.loPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    if (readHigherNext[stackTop] == READ_UPPER) {
      readHigherNext[stackTop]=RETURN_TO_PARENT;
      long valTemp=BitTools.set1(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.hi == null) {
          if (checkMatchFullIntoNextVal(n.hiPost,n.hiVal)) {
            --stackTop;
            return;
          }
        }
 else {
          stack[++stackTop]=n.hi;
          prefixes[stackTop]=n.hiPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    --stackTop;
  }
  nextValue=null;
  nextKey=0;
  hasNext=false;
}
Program: 35250
Project: 35250
Buggy source:
@SuppressWarnings("String_Node_Str") public CBIterator(CritBit64<V> cb,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  if (cb.size == 0) {
    return;
  }
  if (cb.size == 1) {
    nextValue=cb.rootVal;
    nextKey=cb.rootKey;
    return;
  }
  stack[++stackTop]=cb.root;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public CBIterator(CritBit64<V> cb,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    nextValue=cb.rootVal;
    nextKey=cb.rootKey;
    return;
  }
  stack[++stackTop]=cb.root;
  findNext();
}
Program: 35251
Project: 35251
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    return;
  }
  if (cb.size == 1) {
    checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    hasNext=checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff)) {
    hasNext=false;
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}
Program: 35252
Project: 35252
Buggy source:
@Override public boolean hasNext(){
  return nextValue != null;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return hasNext;
}
Program: 35253
Project: 35253
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    return;
  }
  if (cb.size == 1) {
    checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  if (cb.size == 0) {
    hasNext=false;
    return;
  }
  if (cb.size == 1) {
    hasNext=checkMatchFullIntoNextVal(cb.rootKey,cb.rootVal);
    return;
  }
  Node<V> n=cb.root;
  if (!checkMatch(cb.rootKey,n.posDiff)) {
    hasNext=false;
    return;
  }
  stack[++stackTop]=cb.root;
  prefixes[stackTop]=cb.rootKey;
  findNext();
}
Program: 35254
Project: 35254
Buggy source:
private void findNext(){
  while (stackTop >= 0) {
    Node<V> n=stack[stackTop];
    if (readHigherNext[stackTop] == READ_LOWER) {
      readHigherNext[stackTop]=READ_UPPER;
      long valTemp=BitTools.set0(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.lo == null) {
          if (checkMatchFullIntoNextVal(n.loPost,n.loVal)) {
            return;
          }
        }
 else {
          stack[++stackTop]=n.lo;
          prefixes[stackTop]=n.loPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    if (readHigherNext[stackTop] == READ_UPPER) {
      readHigherNext[stackTop]=RETURN_TO_PARENT;
      long valTemp=BitTools.set1(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.hi == null) {
          if (checkMatchFullIntoNextVal(n.hiPost,n.hiVal)) {
            --stackTop;
            return;
          }
        }
 else {
          stack[++stackTop]=n.hi;
          prefixes[stackTop]=n.hiPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    --stackTop;
  }
  nextValue=null;
  nextKey=0;
}

Fixed version (ground truth):
private void findNext(){
  while (stackTop >= 0) {
    Node<V> n=stack[stackTop];
    if (readHigherNext[stackTop] == READ_LOWER) {
      readHigherNext[stackTop]=READ_UPPER;
      long valTemp=BitTools.set0(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.lo == null) {
          if (checkMatchFullIntoNextVal(n.loPost,n.loVal)) {
            return;
          }
        }
 else {
          stack[++stackTop]=n.lo;
          prefixes[stackTop]=n.loPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    if (readHigherNext[stackTop] == READ_UPPER) {
      readHigherNext[stackTop]=RETURN_TO_PARENT;
      long valTemp=BitTools.set1(prefixes[stackTop],n.posDiff);
      if (checkMatch(valTemp,n.posDiff)) {
        if (n.hi == null) {
          if (checkMatchFullIntoNextVal(n.hiPost,n.hiVal)) {
            --stackTop;
            return;
          }
        }
 else {
          stack[++stackTop]=n.hi;
          prefixes[stackTop]=n.hiPost;
          readHigherNext[stackTop]=READ_LOWER;
          continue;
        }
      }
    }
    --stackTop;
  }
  nextValue=null;
  nextKey=0;
  hasNext=false;
}
Program: 35255
Project: 35255
Buggy source:
@SuppressWarnings("String_Node_Str") public CBIterator(CritBit64COW<V> cb,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    return;
  }
  if (info.size == 1) {
    nextValue=info.rootVal;
    nextKey=info.rootKey;
    return;
  }
  stack[++stackTop]=info.root;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public CBIterator(CritBit64COW<V> cb,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    nextValue=info.rootVal;
    nextKey=info.rootKey;
    return;
  }
  stack[++stackTop]=info.root;
  findNext();
}
Program: 35256
Project: 35256
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    return;
  }
  if (info.size == 1) {
    checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIteratorMask(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    hasNext=checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}
Program: 35257
Project: 35257
Buggy source:
@Override public boolean hasNext(){
  return nextValue != null;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return hasNext;
}
Program: 35258
Project: 35258
Buggy source:
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    return;
  }
  if (info.size == 1) {
    checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public QueryIterator(CritBit64COW<V> cb,long minOrig,long maxOrig,int DEPTH){
  this.stack=new Node[DEPTH];
  this.readHigherNext=new byte[DEPTH];
  this.prefixes=new long[DEPTH];
  this.minOrig=minOrig;
  this.maxOrig=maxOrig;
  AtomicInfo<V> info=cb.info;
  if (info.size == 0) {
    hasNext=false;
    return;
  }
  if (info.size == 1) {
    hasNext=checkMatchFullIntoNextVal(info.rootKey,info.rootVal);
    return;
  }
  Node<V> n=info.root;
  if (!checkMatch(info.rootKey,n.posDiff)) {
    return;
  }
  stack[++stackTop]=info.root;
  prefixes[stackTop]=info.rootKey;
  findNext();
}
Program: 35259
Project: 35259
Buggy source:
/** 
 * Compares two values.
 * @param v1
 * @param v2
 * @return Position of the differing bit, or -1 if both values are equal
 */
private int compare(long[] v1,long[] v2){
  int pos=0;
  for (int i=0; i < v1.length; i++) {
    if (v1[i] != v2[i]) {
      long x=v1[i] ^ v2[i];
      pos+=Long.numberOfLeadingZeros(x);
      return pos;
    }
    pos+=64;
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Compares two values.
 * @param v1
 * @param v2
 * @return Position of the differing bit, or -1 if both values are equal
 */
private static int compare(long[] v1,long[] v2){
  int pos=0;
  for (int i=0; i < v1.length; i++) {
    if (v1[i] != v2[i]) {
      long x=v1[i] ^ v2[i];
      pos+=Long.numberOfLeadingZeros(x);
      return pos;
    }
    pos+=64;
  }
  return -1;
}
Program: 35260
Project: 35260
Buggy source:
/** 
 * @param v
 * @param startPos
 * @return True if the infix matches the value or if no infix is defined
 */
private boolean doesInfixMatch(Node<V> n,long[] v){
  if (n.infix == null) {
    return true;
  }
  int startPos=n.posFirstBit;
  int endPos=n.posDiff - 1;
  int start=startPos >>> 6;
  int end=((endPos + 63) >>> 6) - 1;
  for (int i=start; i <= end; i++) {
    if (v[i] != n.infix[i - start] && i == end) {
      long mask=(-1L) << (63 - endPos);
      if ((v[i] & mask) != (n.infix[i - start] & mask)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * @param v
 * @param startPos
 * @return True if the infix matches the value or if no infix is defined
 */
private boolean doesInfixMatch(Node<V> n,long[] v){
  if (n.infix == null) {
    return true;
  }
  int startPos=n.posFirstBit;
  int endPos=n.posDiff - 1;
  int start=startPos >>> 6;
  int end=((endPos + 63) >>> 6) - 1;
  for (int i=start; i <= end; i++) {
    if (v[i] != n.infix[i - start] && i == end) {
      long mask=(-1L) << (63 - endPos);
      if ((v[i] & mask) != (n.infix[i - start] & mask)) {
        return false;
      }
      return true;
    }
  }
  return true;
}
Program: 35261
Project: 35261
Buggy source:
@Test public void test64Bug2(){
  Random R=new Random(1);
  int N=7;
  long[] a=new long[N];
  CritBit<Integer> cb=newCritBit(64);
  for (int i=0; i < N; i++) {
    a[i]=R.nextLong();
    System.out.println("String_Node_Str" + a[i] + "String_Node_Str"+ BitTools.toBinary(a[i],64));
    if (cb.contains(new long[]{a[i]})) {
      for (int j=0; j < i; j++) {
        if (a[j] == a[i]) {
          i--;
          continue;
        }
      }
      fail("String_Node_Str" + i);
    }
    assertNull(cb.insert(new long[]{a[i]},i));
    assertEquals(i + 1,cb.size());
    assertTrue(cb.checkTree());
  }
  assertEquals(N,cb.size());
  for (int i=0; i < N; i++) {
    assertTrue("String_Node_Str" + i,cb.checkTree());
    assertTrue("String_Node_Str" + i,cb.contains(new long[]{a[i]}));
    assertEquals(i,(int)cb.remove(new long[]{a[i]}));
    assertNull(cb.remove(new long[]{a[i]}));
    assertFalse(cb.contains(new long[]{a[i]}));
    assertEquals(N - i - 1,cb.size());
  }
  assertEquals(0,cb.size());
}

Fixed version (ground truth):
@Test public void test64Bug2(){
  Random R=new Random(1);
  int N=7;
  long[] a=new long[N];
  CritBit<Integer> cb=newCritBit(64);
  for (int i=0; i < N; i++) {
    a[i]=R.nextLong();
    if (cb.contains(new long[]{a[i]})) {
      for (int j=0; j < i; j++) {
        if (a[j] == a[i]) {
          i--;
          continue;
        }
      }
      fail("String_Node_Str" + i);
    }
    assertNull(cb.insert(new long[]{a[i]},i));
    assertEquals(i + 1,cb.size());
    assertTrue(cb.checkTree());
  }
  assertEquals(N,cb.size());
  for (int i=0; i < N; i++) {
    assertTrue("String_Node_Str" + i,cb.checkTree());
    assertTrue("String_Node_Str" + i,cb.contains(new long[]{a[i]}));
    assertEquals(i,(int)cb.remove(new long[]{a[i]}));
    assertNull(cb.remove(new long[]{a[i]}));
    assertFalse(cb.contains(new long[]{a[i]}));
    assertEquals(N - i - 1,cb.size());
  }
  assertEquals(0,cb.size());
}
Program: 35262
Project: 35262
Buggy source:
private void randomInsertCheck(final int N,final int SEED,int DEPTH){
  Random R=new Random(SEED);
  long[] a=new long[N];
  CritBit<Integer> cb=newCritBit(DEPTH);
  for (int i=0; i < N; i++) {
    iFail=i;
    a[i]=((long)R.nextInt()) << (64 - DEPTH);
    if (cb.contains(new long[]{a[i]})) {
      boolean isDuplicate=false;
      for (int j=0; j < i; j++) {
        if (a[j] == a[i]) {
          isDuplicate=true;
          break;
        }
      }
      if (isDuplicate) {
        assertNotNull(cb.insert(new long[]{a[i]},i));
        i--;
        continue;
      }
      fail("String_Node_Str" + i);
    }
    assertNull("String_Node_Str" + i + "String_Node_Str"+ a[i],cb.insert(new long[]{a[i]},12345 + i));
    assertEquals("String_Node_Str" + i,12345 + i,(int)cb.insert(new long[]{a[i]},i));
    assertEquals(i + 1,cb.size());
    assertTrue(cb.contains(new long[]{a[i]}));
  }
  assertEquals(N,cb.size());
  for (int i=0; i < N; i++) {
    assertTrue(cb.contains(new long[]{a[i]}));
  }
  for (int i=0; i < N; i++) {
    assertTrue(cb.contains(new long[]{a[i]}));
    assertEquals(i,(int)cb.remove(new long[]{a[i]}));
    assertEquals(null,cb.remove(new long[]{a[i]}));
    assertFalse(cb.contains(new long[]{a[i]}));
    assertEquals(N - i - 1,cb.size());
  }
  assertEquals(0,cb.size());
}

Fixed version (ground truth):
private void randomInsertCheck(final int N,final int SEED,int DEPTH){
  Random R=new Random(SEED);
  long[] a=new long[N];
  CritBit<Integer> cb=newCritBit(DEPTH);
  for (int i=0; i < N; i++) {
    iFail=i;
    a[i]=((long)R.nextInt()) << (64 - DEPTH);
    if (cb.contains(new long[]{a[i]})) {
      boolean isDuplicate=false;
      for (int j=0; j < i; j++) {
        if (a[j] == a[i]) {
          isDuplicate=true;
          break;
        }
      }
      if (isDuplicate) {
        i--;
        continue;
      }
      fail("String_Node_Str" + i);
    }
    assertNull("String_Node_Str" + i + "String_Node_Str"+ a[i],cb.insert(new long[]{a[i]},12345 + i));
    assertEquals("String_Node_Str" + i,12345 + i,(int)cb.insert(new long[]{a[i]},i));
    assertEquals(i + 1,cb.size());
    assertTrue(cb.contains(new long[]{a[i]}));
    assertEquals("String_Node_Str" + i,i,(int)cb.get(new long[]{a[i]}));
  }
  assertEquals(N,cb.size());
  for (int i=0; i < N; i++) {
    assertTrue(cb.contains(new long[]{a[i]}));
    if (i != (int)cb.get(new long[]{a[i]})) {
      cb.printTree();
    }
    assertEquals("String_Node_Str" + i,i,(int)cb.get(new long[]{a[i]}));
  }
  for (int i=0; i < N; i++) {
    assertTrue(cb.contains(new long[]{a[i]}));
    assertEquals(i,(int)cb.remove(new long[]{a[i]}));
    assertEquals(null,cb.remove(new long[]{a[i]}));
    assertFalse(cb.contains(new long[]{a[i]}));
    assertEquals(N - i - 1,cb.size());
  }
  assertEquals(0,cb.size());
}
Program: 35264
Project: 35264
Buggy source:
/** 
 * @param v
 * @param startPos first bit of infix, counting starts with 0 for 1st bit 
 * @param endPos last bit of infix
 * @return The infix PLUS leading bits before the infix that belong in the same 'long'.
 */
private long[] extractInfix(long[] v,int startPos,int endPos){
  if (endPos < startPos) {
    return null;
  }
  int start=startPos >>> 6;
  int end=endPos >>> 6;
  long[] inf=new long[end - start + 1];
  System.arraycopy(v,start,inf,0,inf.length);
  inf[inf.length - 1]&=~((-1L) >>> (1 + (endPos & 0x3F)));
  return inf;
}

Fixed version (ground truth):
/** 
 * @param v
 * @param startPos first bit of infix, counting starts with 0 for 1st bit 
 * @param endPos last bit of infix
 * @return The infix PLUS leading bits before the infix that belong in the same 'long'.
 */
private long[] extractInfix(long[] v,int startPos,int endPos){
  if (endPos < startPos) {
    return null;
  }
  int start=startPos >>> 6;
  int end=endPos >>> 6;
  long[] inf=new long[end - start + 1];
  System.arraycopy(v,start,inf,0,inf.length);
  if ((endPos & 0x3F) < 63) {
    inf[inf.length - 1]&=~((-1L) >>> (1 + (endPos & 0x3F)));
  }
  return inf;
}
Program: 35265
Project: 35265
Buggy source:
@Test public void testDelete64K(){
  final int K=3;
  for (int r=0; r < 100; r++) {
    Random R=new Random(r);
    int N=10000;
    long[][] aa=new long[N][];
    CritBit cb=newCritBit(64,K);
    for (int i=0; i < N; i++) {
      long[] a=new long[K];
      for (int k=0; k < K; k++) {
        a[k]=BitTools.toSortableLong(R.nextDouble());
      }
      aa[i]=a;
      if (cb.containsKD(a)) {
        for (int j=0; j < i; j++) {
          boolean match=true;
          for (int k=0; k < K; k++) {
            if (aa[j][k] != a[k]) {
              match=false;
              break;
            }
          }
          if (match) {
            i--;
            continue;
          }
        }
        fail("String_Node_Str" + r + "String_Node_Str"+ i);
      }
      assertTrue(cb.insertKD(a));
      assertEquals(i + 1,cb.size());
    }
    assertEquals(N,cb.size());
    for (int i=0; i < N >> 1; i++) {
      long[] a=aa[i];
      if (!cb.containsKD(a)) {
        System.out.println("String_Node_Str" + BitTools.toBinary(a,64));
        System.out.println("String_Node_Str" + BitTools.toBinary(BitTools.mergeLong(64,a),64));
      }
      cb.removeKD(a);
      a=aa[N - i - 1];
      if (!cb.containsKD(a)) {
        System.out.println("String_Node_Str" + BitTools.toBinary(a,64));
        System.out.println("String_Node_Str" + BitTools.toBinary(BitTools.mergeLong(64,a),64));
      }
      cb.removeKD(a);
    }
    cb.printTree();
    assertEquals(0,cb.size());
  }
}

Fixed version (ground truth):
@Test public void testDelete64K(){
  final int K=3;
  for (int r=0; r < 100; r++) {
    Random R=new Random(r);
    int N=10000;
    long[][] aa=new long[N][];
    CritBit cb=newCritBit(64,K);
    for (int i=0; i < N; i++) {
      long[] a=new long[K];
      for (int k=0; k < K; k++) {
        a[k]=BitTools.toSortableLong(R.nextDouble());
      }
      aa[i]=a;
      if (cb.containsKD(a)) {
        for (int j=0; j < i; j++) {
          boolean match=true;
          for (int k=0; k < K; k++) {
            if (aa[j][k] != a[k]) {
              match=false;
              break;
            }
          }
          if (match) {
            i--;
            continue;
          }
        }
        fail("String_Node_Str" + r + "String_Node_Str"+ i);
      }
      assertTrue(cb.insertKD(a));
      assertEquals(i + 1,cb.size());
    }
    assertEquals(N,cb.size());
    for (int i=0; i < N >> 1; i++) {
      long[] a=aa[i];
      assertTrue(cb.removeKD(a));
      cb.removeKD(a);
      a=aa[N - i - 1];
      assertTrue(cb.removeKD(a));
    }
    assertEquals(0,cb.size());
  }
}
Program: 35266
Project: 35266
Buggy source:
Node(int localDepth,int DEPTH,long[] loVal,long[] hiVal,long[] infix,int posDiff){
  this.loVal=loVal;
  this.hiVal=hiVal;
  this.infix=infix;
  this.posDiff=posDiff;
}

Fixed version (ground truth):
Node(int posFirstBit,long[] loVal,long[] hiVal,long[] infix,int posDiff){
  this.loVal=loVal;
  this.hiVal=hiVal;
  this.infix=infix;
  this.posFirstBit=posFirstBit;
  this.posDiff=posDiff;
}
Program: 35267
Project: 35267
Buggy source:
private Node createNode(long[] v1,long[] v2,int currentDepth){
  int posDiff=compare(v1,v2);
  if (posDiff == -1) {
    return null;
  }
  long[] infix=extractInfix(v1,currentDepth,posDiff - 1);
  long[] p1=createPostFix(v1,posDiff);
  long[] p2=createPostFix(v2,posDiff);
  if (BitTools.getBit(v2,posDiff)) {
    return new Node(0,DEPTH,p1,p2,infix,posDiff);
  }
 else {
    return new Node(0,DEPTH,p2,p1,infix,posDiff);
  }
}

Fixed version (ground truth):
private Node createNode(long[] v1,long[] v2,int currentDepth){
  int posDiff=compare(v1,v2);
  if (posDiff == -1) {
    return null;
  }
  long[] infix=extractInfix(v1,currentDepth,posDiff - 1);
  long[] p1=createPostFix(v1,posDiff);
  long[] p2=createPostFix(v2,posDiff);
  if (BitTools.getBit(v2,posDiff)) {
    return new Node(currentDepth,p1,p2,infix,posDiff);
  }
 else {
    return new Node(currentDepth,p2,p1,infix,posDiff);
  }
}
Program: 35269
Project: 35269
Buggy source:
private void updateParentAfterRemove(Node parent,long[] newPost,Node newSub,boolean isParentHigh,long[] currentPrefix,Node n){
  if (parent == null) {
    rootVal=newPost;
    root=newSub;
  }
 else   if (isParentHigh) {
    parent.hiVal=createPostFix(currentPrefix,parent.posDiff);
    parent.hi=newSub;
  }
 else {
    parent.loVal=createPostFix(currentPrefix,parent.posDiff);
    parent.lo=newSub;
  }
  if (parent != null) {
    int start=((n.posDiff - 1) & 0x3F) + 1 - (n.infix != null ? n.infix.length : 0);
    start<<=6;
    parent.infix=extractInfix(currentPrefix,start,n.posDiff - 1);
  }
  size--;
}

Fixed version (ground truth):
private void updateParentAfterRemove(Node parent,long[] newPost,Node newSub,boolean isParentHigh,long[] currentPrefix,Node n){
  if (newSub != null) {
    readInfix(newSub,newSub.posFirstBit,currentPrefix);
  }
  if (parent == null) {
    rootVal=newPost;
    root=newSub;
  }
 else   if (isParentHigh) {
    parent.hiVal=newSub != null ? null : createPostFix(currentPrefix,parent.posDiff);
    parent.hi=newSub;
  }
 else {
    parent.loVal=newSub != null ? null : createPostFix(currentPrefix,parent.posDiff);
    parent.lo=newSub;
  }
  if (newSub != null) {
    newSub.posFirstBit=n.posFirstBit;
    newSub.infix=extractInfix(currentPrefix,newSub.posFirstBit,newSub.posDiff - 1);
  }
  size--;
}
Program: 35270
Project: 35270
Buggy source:
/** 
 * Performs a k-dimensional query.
 * @param min
 * @param max
 * @return
 */
public Iterator<long[]> queryKD(long[] min,long[] max){
  checkDIM(min);
  checkDIM(max);
  return new QueryIteratorKD(this,min,max,DIM,DEPTH);
}

Fixed version (ground truth):
/** 
 * Performs a k-dimensional query.
 * @param min
 * @param max
 * @return Result iterator
 */
public Iterator<long[]> queryKD(long[] min,long[] max){
  checkDIM(min);
  checkDIM(max);
  return new QueryIteratorKD(this,min,max,DIM,DEPTH);
}
Program: 35273
Project: 35273
Buggy source:
@Test public void testInsert64KBug2(){
  final int K=3;
  CritBit cb=newCritBit(64,K);
  long[] A=new long[]{4603080768121727233L,4602303061770585570L,4604809596301821093L};
  long[] B=new long[]{4603082763292946186L,4602305978608368320L,4604812210005530572L};
  cb.insertKD(A);
  assertTrue(cb.containsKD(A));
  cb.insertKD(B);
  assertTrue(cb.containsKD(A));
  assertTrue(cb.containsKD(B));
  cb.printTree();
  cb.removeKD(B);
  cb.printTree();
  assertTrue(cb.containsKD(A));
}

Fixed version (ground truth):
@Test public void testInsert64KBug2(){
  final int K=3;
  CritBit cb=newCritBit(64,K);
  long[] A=new long[]{4603080768121727233L,4602303061770585570L,4604809596301821093L};
  long[] B=new long[]{4603082763292946186L,4602305978608368320L,4604812210005530572L};
  cb.insertKD(A);
  assertTrue(cb.containsKD(A));
  cb.insertKD(B);
  assertTrue(cb.containsKD(A));
  assertTrue(cb.containsKD(B));
  cb.removeKD(B);
  assertTrue(cb.containsKD(A));
}
Program: 35275
Project: 35275
Buggy source:
private boolean checkMatch(long[] valTemplate,int currentDepth){
  int i;
  for (i=0; (i + 1) * DEPTH <= currentDepth; i++) {
    if (minOrig[i] > valTemplate[i] || valTemplate[i] > maxOrig[i]) {
      return false;
    }
  }
  if ((i + 1) * DEPTH != currentDepth + 1) {
    int toIgnore=((i + 1) * DEPTH) - currentDepth;
    if (minOrig[i] >>> toIgnore > valTemplate[i] >>> toIgnore || valTemplate[i] >>> toIgnore > maxOrig[i] >>> toIgnore) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean checkMatch(long[] valTemplate,int currentDepth){
  int i;
  for (i=0; (i + 1) * DEPTH <= currentDepth; i++) {
    if (minOrig[i] > valTemplate[i] || valTemplate[i] > maxOrig[i]) {
      return false;
    }
  }
  if ((i + 1) * DEPTH != currentDepth + 1) {
    int toIgnore=((i + 1) * DEPTH) - currentDepth;
    long mask=(-1L) << toIgnore;
    if ((minOrig[i] & mask) > (valTemplate[i] & mask) || (valTemplate[i] & mask) > (maxOrig[i] & mask)) {
      return false;
    }
  }
  return true;
}
Program: 35276
Project: 35276
Buggy source:
@Test public void test64Bug1(){
  Random R=new Random(0);
  int N=6;
  long[] a=new long[N];
  CritBit<Integer> cb=newCritBit(64);
  for (int i=0; i < N; i++) {
    a[i]=R.nextLong();
    System.out.println("String_Node_Str" + a[i] + "String_Node_Str"+ BitTools.toBinary(a[i],64));
    if (cb.contains(new long[]{a[i]})) {
      for (int j=0; j < i; j++) {
        if (a[j] == a[i]) {
          i--;
          continue;
        }
      }
      fail("String_Node_Str" + i);
    }
    assertNull(cb.insert(new long[]{a[i]},i));
  }
  assertEquals(N,cb.size());
  for (int i=0; i < N; i++) {
    assertEquals(i,(int)cb.remove(new long[]{a[i]}));
    assertTrue("String_Node_Str" + i,cb.checkTree());
    assertNull(cb.remove(new long[]{a[i]}));
    assertTrue("String_Node_Str" + i,cb.checkTree());
  }
  assertEquals(0,cb.size());
}

Fixed version (ground truth):
@Test public void test64Bug1(){
  Random R=new Random(0);
  int N=6;
  long[] a=new long[N];
  CritBit<Integer> cb=newCritBit(64);
  for (int i=0; i < N; i++) {
    a[i]=R.nextLong();
    if (cb.contains(new long[]{a[i]})) {
      for (int j=0; j < i; j++) {
        if (a[j] == a[i]) {
          i--;
          continue;
        }
      }
      fail("String_Node_Str" + i);
    }
    assertNull(cb.insert(new long[]{a[i]},i));
  }
  assertEquals(N,cb.size());
  for (int i=0; i < N; i++) {
    assertEquals(i,(int)cb.remove(new long[]{a[i]}));
    assertTrue("String_Node_Str" + i,cb.checkTree());
    assertNull(cb.remove(new long[]{a[i]}));
    assertTrue("String_Node_Str" + i,cb.checkTree());
  }
  assertEquals(0,cb.size());
}
Program: 35278
Project: 35278
Buggy source:
@Override public void userEventTriggered(ChannelHandlerContext ctx,Object evt) throws Exception {
  if (evt instanceof DataFrameSentEvent) {
    DataFrameSentEvent dfse=(DataFrameSentEvent)evt;
    logger.trace("String_Node_Str",dfse.getDataFrame());
    if (!hasCurrentTransaction()) {
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      currentDataFrameTransaction=dfse.getDataFrame().createWrapperTransaction(zctx,dfse.isListeningNode());
      if (currentDataFrameTransaction != null) {
        logger.trace("String_Node_Str",dfse.getDataFrame(),currentDataFrameTransaction.getId());
        if (currentDataFrameTransaction.getTimeout() > 0 && handlerContext != null && handlerContext.executor() != null) {
          timeoutFuture=handlerContext.executor().schedule(new TransactionTimeoutHandler(currentDataFrameTransaction.getId(),handlerContext,this),currentDataFrameTransaction.getTimeout(),TimeUnit.MILLISECONDS);
        }
 else {
          logger.warn("String_Node_Str");
        }
        zctx.process(ctx);
      }
    }
 else {
      logger.trace("String_Node_Str",dfse.getDataFrame());
    }
  }
 else   if (evt instanceof TransactionTimeoutEvent) {
    TransactionTimeoutEvent tte=(TransactionTimeoutEvent)evt;
    if (tte.getId().equals(currentDataFrameTransaction.getId())) {
      logger.trace("String_Node_Str");
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      currentDataFrameTransaction.timeout(zctx);
      zctx.process(ctx);
    }
 else {
      logger.error("String_Node_Str",tte.getId());
    }
  }
 else {
    ctx.fireUserEventTriggered(evt);
  }
}

Fixed version (ground truth):
@Override public void userEventTriggered(ChannelHandlerContext ctx,Object evt) throws Exception {
  if (evt instanceof DataFrameSentEvent) {
    DataFrameSentEvent dfse=(DataFrameSentEvent)evt;
    logger.trace("String_Node_Str",dfse.getDataFrame());
    if (!hasCurrentTransaction()) {
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      currentDataFrameTransaction=dfse.getDataFrame().createWrapperTransaction(zctx,dfse.isListeningNode());
      if (currentDataFrameTransaction != null) {
        logger.trace("String_Node_Str",dfse.getDataFrame(),currentDataFrameTransaction.getId());
        startTimeoutCallback();
        zctx.process(ctx);
      }
    }
 else     if (currentDataFrameTransaction != null && currentDataFrameTransaction.getStartFrame() == dfse.getDataFrame()) {
      logger.trace("String_Node_Str");
      startTimeoutCallback();
    }
 else {
      logger.trace("String_Node_Str",dfse.getDataFrame());
    }
  }
 else   if (evt instanceof TransactionTimeoutEvent) {
    TransactionTimeoutEvent tte=(TransactionTimeoutEvent)evt;
    if (tte.getId().equals(currentDataFrameTransaction.getId())) {
      logger.trace("String_Node_Str");
      timeoutFuture=null;
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      currentDataFrameTransaction.timeout(zctx);
      zctx.process(ctx);
    }
 else {
      logger.error("String_Node_Str",tte.getId());
    }
  }
 else {
    ctx.fireUserEventTriggered(evt);
  }
}
Program: 35279
Project: 35279
Buggy source:
/** 
 * Called when data is read from the Z-Wave network.
 * @param ctx the handler context
 * @param msg the message that was read
 */
@Override public void channelRead(ChannelHandlerContext ctx,Object msg){
  if (msg instanceof Frame) {
    Frame frame=(Frame)msg;
    if (hasCurrentTransaction()) {
      String tid=currentDataFrameTransaction.getId();
      logger.trace("String_Node_Str",tid,frame);
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      if (currentDataFrameTransaction.addFrame(zctx,frame)) {
        if (currentDataFrameTransaction.isComplete()) {
          logger.trace("String_Node_Str",tid);
          logger.trace("String_Node_Str");
          if (timeoutFuture != null) {
            timeoutFuture.cancel(true);
            timeoutFuture=null;
          }
        }
        zctx.process(ctx);
      }
 else {
        logger.trace("String_Node_Str");
        ctx.fireChannelRead(msg);
      }
    }
 else     if (msg instanceof AddNodeToNetwork) {
      logger.trace("String_Node_Str");
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      currentDataFrameTransaction=new NodeInclusionTransaction(zctx,(DataFrame)msg);
      zctx.process(ctx);
    }
 else {
      logger.trace("String_Node_Str",frame);
      ctx.fireChannelRead(msg);
    }
  }
}

Fixed version (ground truth):
/** 
 * Called when data is read from the Z-Wave network.
 * @param ctx the handler context
 * @param msg the message that was read
 */
@Override public void channelRead(ChannelHandlerContext ctx,Object msg){
  if (msg instanceof Frame) {
    Frame frame=(Frame)msg;
    if (hasCurrentTransaction()) {
      String tid=currentDataFrameTransaction.getId();
      logger.trace("String_Node_Str",tid,frame);
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      if (currentDataFrameTransaction.addFrame(zctx,frame)) {
        if (currentDataFrameTransaction.isComplete()) {
          logger.trace("String_Node_Str",tid);
          logger.trace("String_Node_Str");
          cancelTimeoutCallback();
        }
        zctx.process(ctx);
      }
 else {
        logger.trace("String_Node_Str");
        ctx.fireChannelRead(msg);
      }
    }
 else     if (msg instanceof AddNodeToNetwork) {
      logger.trace("String_Node_Str");
      NettyZWaveChannelContext zctx=new NettyZWaveChannelContext();
      currentDataFrameTransaction=new NodeInclusionTransaction(zctx,(DataFrame)msg);
      zctx.process(ctx);
    }
 else {
      logger.trace("String_Node_Str",frame);
      ctx.fireChannelRead(msg);
    }
  }
}
Program: 35282
Project: 35282
Buggy source:
/** 
 * Create a MULTI_INSTANCE_GET command.
 * @param nodeId the target node ID
 * @param commandClass the command class being requested
 * @return a DataFrame instance
 */
public DataFrame createMultiInstanceGet(byte nodeId,byte commandClass){
  if (getVersion() > 1) {
    throw new RuntimeException("String_Node_Str");
  }
  return createSendDataFrame("String_Node_Str",nodeId,new byte[]{MultiInstanceCommandClass.ID,MULTI_INSTANCE_GET,commandClass},true);
}

Fixed version (ground truth):
/** 
 * Create a MULTI_INSTANCE_GET command.
 * @param nodeId the target node ID
 * @param commandClass the command class being requested
 * @return a DataFrame instance
 */
public DataFrame createMultiInstanceGet(byte nodeId,byte commandClass){
  if (getVersion() > 1) {
    throw new ZWaveRuntimeException("String_Node_Str");
  }
  return createSendDataFrame("String_Node_Str",nodeId,new byte[]{MultiInstanceCommandClass.ID,MULTI_INSTANCE_GET,commandClass},true);
}