Program: 132769
Project: 132769
Buggy source:
@Override public Pair<List<VarCount>,List<VarCount>> inRefCounts(Map<String,Function> functions){
switch (op) {
case STORE_REF:
    return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
case ARRAY_BUILD:
{
    List<VarCount> readIncr=new ArrayList<VarCount>();
    for (int i=0; i < getInputs().size() / 2; i++) {
      Arg elem=getInput(i * 2 + 1);
      if (elem.isVar() && RefCounting.trackReadRefCount(elem.getVar())) {
        readIncr.add(VarCount.one(elem.getVar()));
      }
    }
    Var arr=getOutput(0);
    return Pair.create(readIncr,VarCount.one(arr).asList());
  }
case ASYNC_COPY:
case SYNC_COPY:
{
  List<VarCount> writeRefs;
  if (RefCounting.trackWriteRefCount(getOutput(0))) {
    writeRefs=VarCount.one(getOutput(0)).asList();
  }
 else {
    writeRefs=VarCount.NONE;
  }
  return Pair.create(VarCount.one(getInput(0).getVar()).asList(),writeRefs);
}
case STORE_BAG:
case STORE_ARRAY:
case STORE_STRUCT:
case STORE_RECURSIVE:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.one(getOutput(0)).asList());
}
case DEREF_SCALAR:
case DEREF_FILE:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case AREF_COPY_OUT_FUTURE:
case ARR_COPY_OUT_FUTURE:
{
return Pair.create(Arrays.asList(VarCount.one(getInput(0).getVar()),VarCount.one(getInput(1).getVar())),VarCount.NONE);
}
case AREF_COPY_OUT_IMM:
case ARR_COPY_OUT_IMM:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case ARR_CONTAINS:
case CONTAINER_SIZE:
{
return Pair.create(VarCount.NONE,VarCount.NONE);
}
case ARR_RETRIEVE:
{
VarCount readDecr=new VarCount(getInput(0).getVar(),getInput(2).getIntLit());
return Pair.create(readDecr.asList(),VarCount.NONE);
}
case ARR_STORE:
{
Arg mem=getInput(1);
List<VarCount> readIncr;
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readIncr=VarCount.one(mem.getVar()).asList();
}
 else {
readIncr=VarCount.NONE;
}
return Pair.create(readIncr,VarCount.NONE);
}
case ARR_COPY_IN_IMM:
{
Var mem=getInput(1).getVar();
return Pair.create(VarCount.one(mem).asList(),VarCount.one(getOutput(0)).asList());
}
case ARR_STORE_FUTURE:
case ARR_COPY_IN_FUTURE:
{
Var arr=getInput(0).getVar();
Arg mem=getInput(1);
List<VarCount> readIncr;
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readIncr=Arrays.asList(VarCount.one(arr),VarCount.one(mem.getVar()));
}
 else {
readIncr=VarCount.one(arr).asList();
}
return Pair.create(readIncr,VarCount.one((getOutput(0))).asList());
}
case AREF_STORE_IMM:
case AREF_COPY_IN_IMM:
case AREF_STORE_FUTURE:
case AREF_COPY_IN_FUTURE:
{
Arg ix=getInput(0);
Arg mem=getInput(1);
Var arrayRef=getOutput(0);
List<VarCount> readers=new ArrayList<VarCount>(3);
readers.add(VarCount.one(arrayRef));
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readers.add(VarCount.one(mem.getVar()));
}
if (op == Opcode.AREF_STORE_FUTURE || op == Opcode.AREF_COPY_IN_FUTURE) {
readers.add(VarCount.one(ix.getVar()));
}
 else {
assert(op == Opcode.AREF_STORE_IMM || op == Opcode.AREF_COPY_IN_IMM);
}
return Pair.create(readers,VarCount.NONE);
}
case ARR_CREATE_NESTED_IMM:
{
long readDecr=getInput(2).getIntLit();
long writeDecr=getInput(4).getIntLit();
Var resultArr=getOutput(0);
return Pair.create(new VarCount(resultArr,readDecr).asList(),new VarCount(resultArr,writeDecr).asList());
}
case ARR_CREATE_NESTED_FUTURE:
{
Var srcArray=getOutput(1);
Var ix=getInput(0).getVar();
return Pair.create(VarCount.one(ix).asList(),VarCount.one(srcArray).asList());
}
case AREF_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
{
Var arr=getOutput(1);
Arg ixArg=getInput(0);
List<VarCount> readVars;
if (op == Opcode.AREF_CREATE_NESTED_IMM) {
readVars=VarCount.one(arr).asList();
}
 else {
assert(op == Opcode.AREF_CREATE_NESTED_FUTURE);
readVars=Arrays.asList(VarCount.one(arr),VarCount.one(ixArg.getVar()));
}
return Pair.create(readVars,VarCount.NONE);
}
case BAG_INSERT:
{
Arg mem=getInput(0);
List<VarCount> readers=VarCount.NONE;
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readers=VarCount.one(mem.getVar()).asList();
}
return Pair.create(readers,VarCount.NONE);
}
case STRUCT_INIT_FIELDS:
{
Out<List<Arg>> fieldVals=new Out<List<Arg>>();
unpackStructInitArgs(null,null,fieldVals);
List<VarCount> readIncr=new ArrayList<VarCount>();
List<VarCount> writeIncr=new ArrayList<VarCount>();
for (Arg fieldVal : fieldVals.val) {
if (fieldVal.isVar()) {
Var fieldVar=fieldVal.getVar();
if (RefCounting.trackReadRefCount(fieldVar)) {
readIncr.add(VarCount.one(fieldVar));
}
if (RefCounting.trackWriteRefCount(fieldVar)) {
writeIncr.add(VarCount.one(fieldVar));
}
}
}
return Pair.create(readIncr,writeIncr);
}
case STRUCTREF_COPY_OUT:
case STRUCT_COPY_OUT:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case STRUCT_STORE_SUB:
case STRUCT_COPY_IN:
case STRUCTREF_STORE_SUB:
case STRUCTREF_COPY_IN:
return Pair.create(VarCount.NONE,VarCount.NONE);
case COPY_REF:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.one(getInput(0).getVar()).asList());
}
case COPY_IN_FILENAME:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case UPDATE_INCR:
case UPDATE_MIN:
case UPDATE_SCALE:
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.one(getOutput(0)).asList());
default :
return Pair.create(VarCount.NONE,VarCount.NONE);
}
}

Fixed version (ground truth):
@Override public Pair<List<VarCount>,List<VarCount>> inRefCounts(Map<String,Function> functions){
switch (op) {
case STORE_REF:
    return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
case ARRAY_BUILD:
{
    List<VarCount> readIncr=new ArrayList<VarCount>();
    for (int i=0; i < getInputs().size() / 2; i++) {
      Arg elem=getInput(i * 2 + 1);
      if (elem.isVar() && RefCounting.trackReadRefCount(elem.getVar())) {
        readIncr.add(VarCount.one(elem.getVar()));
      }
    }
    Var arr=getOutput(0);
    return Pair.create(readIncr,VarCount.one(arr).asList());
  }
case ASYNC_COPY:
case SYNC_COPY:
{
  List<VarCount> writeRefs;
  if (RefCounting.trackWriteRefCount(getOutput(0))) {
    writeRefs=VarCount.one(getOutput(0)).asList();
  }
 else {
    writeRefs=VarCount.NONE;
  }
  return Pair.create(VarCount.one(getInput(0).getVar()).asList(),writeRefs);
}
case STORE_BAG:
case STORE_ARRAY:
case STORE_STRUCT:
case STORE_RECURSIVE:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.one(getOutput(0)).asList());
}
case DEREF_SCALAR:
case DEREF_FILE:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case AREF_COPY_OUT_FUTURE:
case ARR_COPY_OUT_FUTURE:
{
return Pair.create(Arrays.asList(VarCount.one(getInput(0).getVar()),VarCount.one(getInput(1).getVar())),VarCount.NONE);
}
case AREF_COPY_OUT_IMM:
case ARR_COPY_OUT_IMM:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case ARR_CONTAINS:
case CONTAINER_SIZE:
{
return Pair.create(VarCount.NONE,VarCount.NONE);
}
case ARR_RETRIEVE:
{
VarCount readDecr=new VarCount(getInput(0).getVar(),getInput(2).getIntLit());
return Pair.create(readDecr.asList(),VarCount.NONE);
}
case ARR_STORE:
{
Arg mem=getInput(1);
List<VarCount> readIncr;
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readIncr=VarCount.one(mem.getVar()).asList();
}
 else {
readIncr=VarCount.NONE;
}
return Pair.create(readIncr,VarCount.NONE);
}
case ARR_COPY_IN_IMM:
{
Var mem=getInput(1).getVar();
return Pair.create(VarCount.one(mem).asList(),VarCount.one(getOutput(0)).asList());
}
case ARR_STORE_FUTURE:
case ARR_COPY_IN_FUTURE:
{
Var arr=getInput(0).getVar();
Arg mem=getInput(1);
List<VarCount> readIncr;
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readIncr=Arrays.asList(VarCount.one(arr),VarCount.one(mem.getVar()));
}
 else {
readIncr=VarCount.one(arr).asList();
}
return Pair.create(readIncr,VarCount.one((getOutput(0))).asList());
}
case AREF_STORE_IMM:
case AREF_COPY_IN_IMM:
case AREF_STORE_FUTURE:
case AREF_COPY_IN_FUTURE:
{
Arg ix=getInput(0);
Arg mem=getInput(1);
Var arrayRef=getOutput(0);
List<VarCount> readers=new ArrayList<VarCount>(3);
readers.add(VarCount.one(arrayRef));
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readers.add(VarCount.one(mem.getVar()));
}
if (op == Opcode.AREF_STORE_FUTURE || op == Opcode.AREF_COPY_IN_FUTURE) {
readers.add(VarCount.one(ix.getVar()));
}
 else {
assert(op == Opcode.AREF_STORE_IMM || op == Opcode.AREF_COPY_IN_IMM);
}
return Pair.create(readers,VarCount.NONE);
}
case ARR_CREATE_NESTED_IMM:
{
long readDecr=getInput(3).getIntLit();
long writeDecr=getInput(4).getIntLit();
Var arr=getOutput(1);
return Pair.create(new VarCount(arr,readDecr).asList(),new VarCount(arr,writeDecr).asList());
}
case ARR_CREATE_NESTED_FUTURE:
{
Var srcArray=getOutput(1);
Var ix=getInput(0).getVar();
return Pair.create(VarCount.one(ix).asList(),VarCount.one(srcArray).asList());
}
case AREF_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
{
Var arr=getOutput(1);
Arg ixArg=getInput(0);
List<VarCount> readVars;
if (op == Opcode.AREF_CREATE_NESTED_IMM) {
readVars=VarCount.one(arr).asList();
}
 else {
assert(op == Opcode.AREF_CREATE_NESTED_FUTURE);
readVars=Arrays.asList(VarCount.one(arr),VarCount.one(ixArg.getVar()));
}
return Pair.create(readVars,VarCount.NONE);
}
case BAG_INSERT:
{
Arg mem=getInput(0);
List<VarCount> readers=VarCount.NONE;
if (mem.isVar() && RefCounting.trackReadRefCount(mem.getVar())) {
readers=VarCount.one(mem.getVar()).asList();
}
return Pair.create(readers,VarCount.NONE);
}
case STRUCT_INIT_FIELDS:
{
Out<List<Arg>> fieldVals=new Out<List<Arg>>();
unpackStructInitArgs(null,null,fieldVals);
List<VarCount> readIncr=new ArrayList<VarCount>();
List<VarCount> writeIncr=new ArrayList<VarCount>();
for (Arg fieldVal : fieldVals.val) {
if (fieldVal.isVar()) {
Var fieldVar=fieldVal.getVar();
if (RefCounting.trackReadRefCount(fieldVar)) {
readIncr.add(VarCount.one(fieldVar));
}
if (RefCounting.trackWriteRefCount(fieldVar)) {
writeIncr.add(VarCount.one(fieldVar));
}
}
}
return Pair.create(readIncr,writeIncr);
}
case STRUCTREF_COPY_OUT:
case STRUCT_COPY_OUT:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case STRUCT_STORE_SUB:
case STRUCT_COPY_IN:
case STRUCTREF_STORE_SUB:
case STRUCTREF_COPY_IN:
return Pair.create(VarCount.NONE,VarCount.NONE);
case COPY_REF:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.one(getInput(0).getVar()).asList());
}
case COPY_IN_FILENAME:
{
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.NONE);
}
case UPDATE_INCR:
case UPDATE_MIN:
case UPDATE_SCALE:
return Pair.create(VarCount.one(getInput(0).getVar()).asList(),VarCount.one(getOutput(0)).asList());
default :
return Pair.create(VarCount.NONE,VarCount.NONE);
}
}