Program: 132891
Project: 132891
Buggy source:
@Override public List<ValLoc> getResults(ValueState existing){
switch (op) {
case LOAD_BOOL:
case LOAD_FLOAT:
case LOAD_INT:
case LOAD_REF:
case LOAD_STRING:
case LOAD_BLOB:
case LOAD_VOID:
case LOAD_FILE:
{
      Arg src=getInput(0);
      Var dst=getOutput(0);
      if (Types.isPrimUpdateable(src.getVar().type())) {
        return null;
      }
      Closed outIsClosed;
      if (op == Opcode.LOAD_REF) {
        outIsClosed=Closed.MAYBE_NOT;
      }
 else {
        outIsClosed=Closed.YES_NOT_RECURSIVE;
      }
      List<ValLoc> result=new ArrayList<ValLoc>();
      ValLoc retrieve;
      if (op == Opcode.LOAD_REF) {
        retrieve=ValLoc.derefCompVal(src.getVar(),dst,IsValCopy.NO);
      }
 else {
        retrieve=vanillaResult(outIsClosed);
      }
      result.add(retrieve);
      Opcode cvop=Opcode.assignOpcode(src.futureType());
      if (cvop == null) {
        throw new STCRuntimeError("String_Node_Str" + src.getVar());
      }
      ValLoc assign=ValLoc.buildResult(cvop,Arrays.asList(dst.asArg()),src,outIsClosed);
      result.add(assign);
      Opcode derefOp=Opcode.derefOpCode(src.futureType());
      if (derefOp != null) {
        ValLoc deref=ValLoc.buildResult(derefOp,Arrays.asList(src),dst.asArg(),Closed.MAYBE_NOT);
        result.add(deref);
        for (        RecCV val : existing.findCongruent(src.getVar().asArg(),CongruenceType.VALUE)) {
          if (val.isCV()) {
            result.addAll(ValLoc.createLoadRefCVs(val.cv(),dst));
          }
        }
      }
      return result;
    }
case STORE_REF:
case STORE_BOOL:
case STORE_FLOAT:
case STORE_INT:
case STORE_STRING:
case STORE_BLOB:
case STORE_VOID:
case STORE_FILE:
{
    ValLoc assign=vanillaResult(Closed.YES_NOT_RECURSIVE);
    Arg dst=getOutput(0).asArg();
    Arg src=getInput(0);
    ValLoc retrieve;
    if (op == Opcode.STORE_REF) {
      retrieve=ValLoc.derefCompVal(src.getVar(),dst.getVar(),IsValCopy.NO);
    }
 else {
      retrieve=ValLoc.buildResult(Opcode.retrieveOpcode(dst.futureType()),Arrays.asList(dst),src,Closed.MAYBE_NOT);
    }
    return Arrays.asList(retrieve,assign);
  }
case IS_MAPPED:
{
  ValLoc vanilla=vanillaResult(Closed.YES_NOT_RECURSIVE);
  assert(vanilla != null);
  Var fileVar=getInput(0).getVar();
  if (fileVar.isMapped() == Ternary.MAYBE) {
    return vanilla.asList();
  }
 else {
    Arg result=Arg.createBoolLit(fileVar.isMapped() == Ternary.TRUE);
    return Arrays.asList(vanilla,ValLoc.makeCopy(getOutput(0),result));
  }
}
case GET_FILENAME:
{
List<ValLoc> res=new ArrayList<ValLoc>();
Arg filename=getOutput(0).asArg();
Arg file=getInput(0);
res.add(ValLoc.makeFilename(filename,file.getVar()));
ArgCV filenameCV=ValLoc.makeFilenameVal(file,null).value();
Arg filenameVal=existing.findCanonical(filenameCV,CongruenceType.VALUE);
if (filenameVal != null) {
  res.add(ValLoc.buildResult(Opcode.LOAD_STRING,filename,filenameVal,Closed.YES_NOT_RECURSIVE));
}
return res;
}
case GET_LOCAL_FILENAME:
{
return ValLoc.makeFilenameLocal(getOutput(0).asArg(),getInput(0).getVar()).asList();
}
case SET_FILENAME_VAL:
{
Arg file=getOutput(0).asArg();
Arg val=getInput(0);
return ValLoc.makeFilenameVal(file,val).asList();
}
case DEREF_BLOB:
case DEREF_BOOL:
case DEREF_FLOAT:
case DEREF_INT:
case DEREF_STRING:
{
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES).asList();
}
case DEREF_FILE:
{
if (getOutput(0).isMapped() == Ternary.FALSE) {
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES).asList();
}
 else {
return null;
}
}
case STRUCT_INIT_FIELD:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getInput(1).getVar(),getOutput(0),getInput(0).getStringLit());
return lookup.asList();
}
case STRUCT_LOOKUP:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getOutput(0),getInput(0).getVar(),getInput(1).getStringLit());
return lookup.asList();
}
case ARRAY_INSERT_IMM:
case ARRAY_DEREF_INSERT_IMM:
case ARRAY_INSERT_FUTURE:
case ARRAY_DEREF_INSERT_FUTURE:
case ARRAYREF_INSERT_IMM:
case ARRAYREF_DEREF_INSERT_IMM:
case ARRAYREF_INSERT_FUTURE:
case ARRAYREF_DEREF_INSERT_FUTURE:
{
Var arr;
if (op == Opcode.ARRAYREF_INSERT_FUTURE || op == Opcode.ARRAYREF_INSERT_IMM || op == Opcode.ARRAYREF_DEREF_INSERT_FUTURE || op == Opcode.ARRAYREF_DEREF_INSERT_IMM) {
arr=getOutput(1);
}
 else {
arr=getOutput(0);
}
Arg ix=getInput(0);
Var member=getInput(1).getVar();
boolean insertingRef=(op == Opcode.ARRAYREF_DEREF_INSERT_FUTURE || op == Opcode.ARRAYREF_DEREF_INSERT_IMM || op == Opcode.ARRAY_DEREF_INSERT_FUTURE || op == Opcode.ARRAY_DEREF_INSERT_IMM);
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,member,insertingRef));
}
case ARRAY_BUILD:
{
Var arr=getOutput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.buildResult(op,getInputs(),arr.asArg(),Closed.YES_NOT_RECURSIVE));
assert(getInputs().size() % 2 == 0);
int elemCount=getInputs().size() / 2;
for (int i=0; i < elemCount; i++) {
Arg key=getInput(2 * i);
Var val=getInput(2 * i + 1).getVar();
res.add(ValLoc.makeArrayResult(arr,key,val,false));
}
res.add(CommonFunctionCall.makeArraySizeCV(arr,Arg.createIntLit(elemCount),false));
return res;
}
case ARRAY_LOOKUP_IMM:
case ARRAY_LOOKUP_REF_IMM:
case ARRAY_LOOKUP_FUTURE:
case ARRAYREF_LOOKUP_FUTURE:
case ARRAYREF_LOOKUP_IMM:
{
Var arr=getInput(0).getVar();
Arg ix=getInput(1);
Var contents=getOutput(0);
if (op == Opcode.ARRAY_LOOKUP_IMM) {
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,contents,false));
}
 else {
assert(Types.isMemberReference(contents,arr));
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.makeArrayResult(arr,ix,contents,true));
addDerefMemberVals(existing,arr,contents,ix,res);
return res;
}
}
case ARRAY_CREATE_NESTED_FUTURE:
case ARRAY_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
case ARRAYREF_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nestedArr=getOutput(0);
Var arr;
if (op == Opcode.ARRAYREF_CREATE_NESTED_FUTURE || op == Opcode.ARRAYREF_CREATE_NESTED_IMM) {
arr=getOutput(2);
}
 else {
arr=getOutput(1);
}
Arg ix=getInput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
boolean returnsRef=op != Opcode.ARRAY_CREATE_NESTED_IMM && op != Opcode.ARRAY_CREATE_BAG;
res.add(ValLoc.makeArrayResult(arr,ix,nestedArr,returnsRef));
res.add(ValLoc.makeCreateNestedResult(arr,ix,nestedArr,returnsRef));
if (op == Opcode.ARRAY_CREATE_NESTED_IMM || op == Opcode.ARRAY_CREATE_BAG) {
}
 else {
addDerefMemberVals(existing,arr,nestedArr,ix,res);
}
return res;
}
case COPY_REF:
{
List<ValLoc> res=new ArrayList<ValLoc>();
Var srcRef=getInput(0).getVar();
res.add(ValLoc.makeAlias(getOutput(0),srcRef));
return res;
}
default :
return null;
}
}

Fixed version (ground truth):
@Override public List<ValLoc> getResults(ValueState existing){
switch (op) {
case LOAD_BOOL:
case LOAD_FLOAT:
case LOAD_INT:
case LOAD_REF:
case LOAD_STRING:
case LOAD_BLOB:
case LOAD_VOID:
case LOAD_FILE:
{
      Arg src=getInput(0);
      Var dst=getOutput(0);
      if (Types.isPrimUpdateable(src.getVar().type())) {
        return null;
      }
      Closed outIsClosed;
      if (op == Opcode.LOAD_REF) {
        outIsClosed=Closed.MAYBE_NOT;
      }
 else {
        outIsClosed=Closed.YES_NOT_RECURSIVE;
      }
      List<ValLoc> result=new ArrayList<ValLoc>();
      ValLoc retrieve;
      if (op == Opcode.LOAD_REF) {
        retrieve=ValLoc.derefCompVal(dst,src.getVar(),IsValCopy.NO);
      }
 else {
        retrieve=vanillaResult(outIsClosed);
      }
      result.add(retrieve);
      Opcode cvop=Opcode.assignOpcode(src.futureType());
      if (cvop == null) {
        throw new STCRuntimeError("String_Node_Str" + src.getVar());
      }
      ValLoc assign=ValLoc.buildResult(cvop,Arrays.asList(dst.asArg()),src,outIsClosed);
      result.add(assign);
      return result;
    }
case STORE_REF:
case STORE_BOOL:
case STORE_FLOAT:
case STORE_INT:
case STORE_STRING:
case STORE_BLOB:
case STORE_VOID:
case STORE_FILE:
{
    ValLoc assign=vanillaResult(Closed.YES_NOT_RECURSIVE);
    Arg dst=getOutput(0).asArg();
    Arg src=getInput(0);
    ValLoc retrieve;
    if (op == Opcode.STORE_REF) {
      retrieve=ValLoc.derefCompVal(src.getVar(),dst.getVar(),IsValCopy.NO);
    }
 else {
      retrieve=ValLoc.buildResult(Opcode.retrieveOpcode(dst.futureType()),Arrays.asList(dst),src,Closed.MAYBE_NOT);
    }
    return Arrays.asList(retrieve,assign);
  }
case IS_MAPPED:
{
  ValLoc vanilla=vanillaResult(Closed.YES_NOT_RECURSIVE);
  assert(vanilla != null);
  Var fileVar=getInput(0).getVar();
  if (fileVar.isMapped() == Ternary.MAYBE) {
    return vanilla.asList();
  }
 else {
    Arg result=Arg.createBoolLit(fileVar.isMapped() == Ternary.TRUE);
    return Arrays.asList(vanilla,ValLoc.makeCopy(getOutput(0),result));
  }
}
case GET_FILENAME:
{
List<ValLoc> res=new ArrayList<ValLoc>();
Arg filename=getOutput(0).asArg();
Arg file=getInput(0);
res.add(ValLoc.makeFilename(filename,file.getVar()));
ArgCV filenameCV=ValLoc.makeFilenameVal(file,null).value();
Arg filenameVal=existing.findCanonical(filenameCV,CongruenceType.VALUE);
if (filenameVal != null) {
  res.add(ValLoc.buildResult(Opcode.LOAD_STRING,filename,filenameVal,Closed.YES_NOT_RECURSIVE));
}
return res;
}
case GET_LOCAL_FILENAME:
{
return ValLoc.makeFilenameLocal(getOutput(0).asArg(),getInput(0).getVar()).asList();
}
case SET_FILENAME_VAL:
{
Arg file=getOutput(0).asArg();
Arg val=getInput(0);
return ValLoc.makeFilenameVal(file,val).asList();
}
case DEREF_BLOB:
case DEREF_BOOL:
case DEREF_FLOAT:
case DEREF_INT:
case DEREF_STRING:
{
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES).asList();
}
case DEREF_FILE:
{
if (getOutput(0).isMapped() == Ternary.FALSE) {
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES).asList();
}
 else {
return null;
}
}
case STRUCT_INIT_FIELD:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getInput(1).getVar(),getOutput(0),getInput(0).getStringLit());
return lookup.asList();
}
case STRUCT_LOOKUP:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getOutput(0),getInput(0).getVar(),getInput(1).getStringLit());
return lookup.asList();
}
case ARRAY_INSERT_IMM:
case ARRAY_DEREF_INSERT_IMM:
case ARRAY_INSERT_FUTURE:
case ARRAY_DEREF_INSERT_FUTURE:
case ARRAYREF_INSERT_IMM:
case ARRAYREF_DEREF_INSERT_IMM:
case ARRAYREF_INSERT_FUTURE:
case ARRAYREF_DEREF_INSERT_FUTURE:
{
Var arr;
if (op == Opcode.ARRAYREF_INSERT_FUTURE || op == Opcode.ARRAYREF_INSERT_IMM || op == Opcode.ARRAYREF_DEREF_INSERT_FUTURE || op == Opcode.ARRAYREF_DEREF_INSERT_IMM) {
arr=getOutput(1);
}
 else {
arr=getOutput(0);
}
Arg ix=getInput(0);
Var member=getInput(1).getVar();
boolean insertingRef=(op == Opcode.ARRAYREF_DEREF_INSERT_FUTURE || op == Opcode.ARRAYREF_DEREF_INSERT_IMM || op == Opcode.ARRAY_DEREF_INSERT_FUTURE || op == Opcode.ARRAY_DEREF_INSERT_IMM);
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,member,insertingRef));
}
case ARRAY_BUILD:
{
Var arr=getOutput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.buildResult(op,getInputs(),arr.asArg(),Closed.YES_NOT_RECURSIVE));
assert(getInputs().size() % 2 == 0);
int elemCount=getInputs().size() / 2;
for (int i=0; i < elemCount; i++) {
Arg key=getInput(2 * i);
Var val=getInput(2 * i + 1).getVar();
res.add(ValLoc.makeArrayResult(arr,key,val,false));
}
res.add(CommonFunctionCall.makeArraySizeCV(arr,Arg.createIntLit(elemCount),false));
return res;
}
case ARRAY_LOOKUP_IMM:
case ARRAY_LOOKUP_REF_IMM:
case ARRAY_LOOKUP_FUTURE:
case ARRAYREF_LOOKUP_FUTURE:
case ARRAYREF_LOOKUP_IMM:
{
Var arr=getInput(0).getVar();
Arg ix=getInput(1);
Var contents=getOutput(0);
if (op == Opcode.ARRAY_LOOKUP_IMM) {
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,contents,false));
}
 else {
assert(Types.isMemberReference(contents,arr));
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.makeArrayResult(arr,ix,contents,true));
addDerefMemberVals(existing,arr,contents,ix,res);
return res;
}
}
case ARRAY_CREATE_NESTED_FUTURE:
case ARRAY_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
case ARRAYREF_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nestedArr=getOutput(0);
Var arr;
if (op == Opcode.ARRAYREF_CREATE_NESTED_FUTURE || op == Opcode.ARRAYREF_CREATE_NESTED_IMM) {
arr=getOutput(2);
}
 else {
arr=getOutput(1);
}
Arg ix=getInput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
boolean returnsRef=op != Opcode.ARRAY_CREATE_NESTED_IMM && op != Opcode.ARRAY_CREATE_BAG;
res.add(ValLoc.makeArrayResult(arr,ix,nestedArr,returnsRef));
res.add(ValLoc.makeCreateNestedResult(arr,ix,nestedArr,returnsRef));
if (op == Opcode.ARRAY_CREATE_NESTED_IMM || op == Opcode.ARRAY_CREATE_BAG) {
}
 else {
addDerefMemberVals(existing,arr,nestedArr,ix,res);
}
return res;
}
case COPY_REF:
{
List<ValLoc> res=new ArrayList<ValLoc>();
Var srcRef=getInput(0).getVar();
res.add(ValLoc.makeAlias(getOutput(0),srcRef));
return res;
}
default :
return null;
}
}