Program: 136124
Project: 136124
Buggy source:
private final TLCState getNextStatesAppl(OpApplNode pred,ActionItemList acts,Context c,TLCState s0,TLCState s1,StateVec nss){
  ExprOrOpArgNode[] args=pred.getArgs();
  int alen=args.length;
  SymbolNode opNode=pred.getOperator();
  int opcode=BuiltInOPs.getOpCode(opNode.getName());
  if (opcode == 0) {
    Object val=this.lookup(opNode,c,s0,false);
    if (val instanceof OpDefNode) {
      OpDefNode opDef=(OpDefNode)val;
      opcode=BuiltInOPs.getOpCode(opDef.getName());
      if (opcode == 0) {
        Context c1=this.getOpContext(opDef,args,c,true);
        return this.getNextStates(opDef.getBody(),acts,c1,s0,s1,nss);
      }
    }
    if (val instanceof LazyValue) {
      LazyValue lv=(LazyValue)val;
      if (lv.val == null || lv.val == ValUndef) {
        return this.getNextStates(lv.expr,acts,lv.con,s0,s1,nss);
      }
      val=lv.val;
    }
    Object bval=val;
    if (alen == 0) {
      if (val instanceof MethodValue) {
        bval=((MethodValue)val).apply(EmptyArgs,EvalControl.Clear);
      }
    }
 else {
      if (val instanceof OpValue) {
        Applicable opVal=(Applicable)val;
        Value[] argVals=new Value[alen];
        for (int i=0; i < alen; i++) {
          argVals[i]=this.eval(args[i],c,s0,s1,EvalControl.Clear);
        }
        bval=opVal.apply(argVals,EvalControl.Clear);
      }
    }
    if (opcode == 0) {
      if (!(bval instanceof BoolValue)) {
        Assert.fail("String_Node_Str" + "String_Node_Str" + bval + "String_Node_Str"+ pred);
      }
      if (((BoolValue)bval).val) {
        return this.getNextStates(acts,s0,s1,nss);
      }
      return s1;
    }
  }
  TLCState resState=s1;
switch (opcode) {
case OPCODE_cl:
case OPCODE_land:
{
      ActionItemList acts1=acts;
      for (int i=alen - 1; i > 0; i--) {
        acts1=acts1.cons(args[i],c,i);
      }
      if (this.callStack != null)       this.callStack.push(args[0]);
      resState=this.getNextStates(args[0],acts1,c,s0,s1,nss);
      if (this.callStack != null)       this.callStack.pop();
      return resState;
    }
case OPCODE_dl:
case OPCODE_lor:
{
    for (int i=0; i < alen; i++) {
      if (this.callStack != null)       this.callStack.push(args[i]);
      resState=this.getNextStates(args[i],acts,c,s0,resState,nss);
      if (this.callStack != null)       this.callStack.pop();
    }
    return resState;
  }
case OPCODE_be:
{
  SemanticNode body=args[0];
  ContextEnumerator Enum=this.contexts(pred,c,s0,s1,EvalControl.Clear);
  Context c1;
  while ((c1=Enum.nextElement()) != null) {
    resState=this.getNextStates(body,acts,c1,s0,resState,nss);
  }
  return resState;
}
case OPCODE_bf:
{
SemanticNode body=args[0];
ContextEnumerator Enum=this.contexts(pred,c,s0,s1,EvalControl.Clear);
Context c1=Enum.nextElement();
if (c1 == null) {
  resState=this.getNextStates(acts,s0,s1,nss);
}
 else {
  ActionItemList acts1=acts;
  Context c2;
  while ((c2=Enum.nextElement()) != null) {
    acts1=acts1.cons(body,c2,-1);
  }
  resState=this.getNextStates(body,acts1,c1,s0,s1,nss);
}
return resState;
}
case OPCODE_fa:
{
Value fval=this.eval(args[0],c,s0,s1,EvalControl.KeepLazy);
if (fval instanceof FcnLambdaValue) {
FcnLambdaValue fcn=(FcnLambdaValue)fval;
if (fcn.fcnRcd == null) {
  Context c1=this.getFcnContext(fcn,args,c,s0,s1,EvalControl.Clear);
  return this.getNextStates(fcn.body,acts,c1,s0,s1,nss);
}
fval=fcn.fcnRcd;
}
if (!(fval instanceof Applicable)) {
Assert.fail("String_Node_Str" + fval.getKindString() + "String_Node_Str"+ pred);
}
Applicable fcn=(Applicable)fval;
Value argVal=this.eval(args[1],c,s0,s1,EvalControl.Clear);
Value bval=fcn.apply(argVal,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + pred);
}
if (((BoolValue)bval).val) {
return this.getNextStates(acts,s0,s1,nss);
}
return resState;
}
case OPCODE_aa:
{
ActionItemList acts1=acts.cons(args[1],c,-3);
return this.getNextStates(args[0],acts1,c,s0,s1,nss);
}
case OPCODE_sa:
{
this.getNextStates(args[0],acts,c,s0,s1,nss);
return this.processUnchanged(args[1],acts,c,s0,s1,nss);
}
case OPCODE_ite:
{
Value guard=this.eval(args[0],c,s0,s1,EvalControl.Clear);
if (!(guard instanceof BoolValue)) {
Assert.fail("String_Node_Str" + guard.getKindString() + "String_Node_Str"+ "String_Node_Str"+ pred);
}
if (((BoolValue)guard).val) {
return this.getNextStates(args[1],acts,c,s0,s1,nss);
}
 else {
return this.getNextStates(args[2],acts,c,s0,s1,nss);
}
}
case OPCODE_case:
{
SemanticNode other=null;
for (int i=0; i < alen; i++) {
OpApplNode pair=(OpApplNode)args[i];
ExprOrOpArgNode[] pairArgs=pair.getArgs();
if (pairArgs[0] == null) {
other=pairArgs[1];
}
 else {
Value bval=this.eval(pairArgs[0],c,s0,s1,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + bval.getKindString() + "String_Node_Str"+ "String_Node_Str"+ pairArgs[1]);
}
if (((BoolValue)bval).val) {
return this.getNextStates(pairArgs[1],acts,c,s0,s1,nss);
}
}
}
if (other == null) {
Assert.fail("String_Node_Str" + "String_Node_Str" + pred);
}
return this.getNextStates(other,acts,c,s0,s1,nss);
}
case OPCODE_eq:
{
SymbolNode var=this.getPrimedVar(args[0],c,false);
if (var == null) {
Value bval=this.eval(pred,c,s0,s1,EvalControl.Clear);
if (!((BoolValue)bval).val) {
return resState;
}
}
 else {
UniqueString varName=var.getName();
Value lval=s1.lookup(varName);
Value rval=this.eval(args[1],c,s0,s1,EvalControl.Clear);
if (lval == null) {
resState.bind(varName,rval,pred);
resState=this.getNextStates(acts,s0,resState,nss);
resState.unbind(varName);
return resState;
}
 else if (!lval.equals(rval)) {
return resState;
}
}
return this.getNextStates(acts,s0,s1,nss);
}
case OPCODE_in:
{
SymbolNode var=this.getPrimedVar(args[0],c,false);
if (var == null) {
Value bval=this.eval(pred,c,s0,s1,EvalControl.Clear);
if (!((BoolValue)bval).val) {
return resState;
}
}
 else {
UniqueString varName=var.getName();
Value lval=s1.lookup(varName);
Value rval=this.eval(args[1],c,s0,s1,EvalControl.Clear);
if (lval == null) {
if (!(rval instanceof Enumerable)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + pred);
}
ValueEnumeration Enum=((Enumerable)rval).elements();
Value elem;
while ((elem=Enum.nextElement()) != null) {
resState.bind(varName,elem,pred);
resState=this.getNextStates(acts,s0,resState,nss);
resState.unbind(varName);
}
return resState;
}
 else if (!rval.member(lval)) {
return resState;
}
}
return this.getNextStates(acts,s0,s1,nss);
}
case OPCODE_implies:
{
Value bval=this.eval(args[0],c,s0,s1,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + bval.getKindString() + "String_Node_Str"+ pred);
}
if (((BoolValue)bval).val) {
return this.getNextStates(args[1],acts,c,s0,s1,nss);
}
 else {
return this.getNextStates(acts,s0,s1,nss);
}
}
case OPCODE_unchanged:
{
return this.processUnchanged(args[0],acts,c,s0,s1,nss);
}
case OPCODE_cdot:
{
Assert.fail("String_Node_Str");
return s1;
}
default :
{
Value bval=this.eval(pred,c,s0,s1,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + bval + "String_Node_Str"+ pred);
}
if (((BoolValue)bval).val) {
resState=this.getNextStates(acts,s0,s1,nss);
}
return resState;
}
}
}

Fixed version (ground truth):
private final TLCState getNextStatesAppl(OpApplNode pred,ActionItemList acts,Context c,TLCState s0,TLCState s1,StateVec nss){
  ExprOrOpArgNode[] args=pred.getArgs();
  int alen=args.length;
  SymbolNode opNode=pred.getOperator();
  int opcode=BuiltInOPs.getOpCode(opNode.getName());
  if (opcode == 0) {
    Object val=this.lookup(opNode,c,s0,false);
    if (val instanceof OpDefNode) {
      OpDefNode opDef=(OpDefNode)val;
      opcode=BuiltInOPs.getOpCode(opDef.getName());
      if (opcode == 0) {
        Context c1=this.getOpContext(opDef,args,c,true);
        return this.getNextStates(opDef.getBody(),acts,c1,s0,s1,nss);
      }
    }
    if (val instanceof LazyValue) {
      LazyValue lv=(LazyValue)val;
      if (lv.val == null || lv.val == ValUndef) {
        return this.getNextStates(lv.expr,acts,lv.con,s0,s1,nss);
      }
      val=lv.val;
    }
    Object bval=val;
    if (alen == 0) {
      if (val instanceof MethodValue) {
        bval=((MethodValue)val).apply(EmptyArgs,EvalControl.Clear);
      }
    }
 else {
      if (val instanceof OpValue) {
        Applicable opVal=(Applicable)val;
        Value[] argVals=new Value[alen];
        for (int i=0; i < alen; i++) {
          argVals[i]=this.eval(args[i],c,s0,s1,EvalControl.Clear);
        }
        bval=opVal.apply(argVals,EvalControl.Clear);
      }
    }
    if (opcode == 0) {
      if (!(bval instanceof BoolValue)) {
        Assert.fail("String_Node_Str" + "String_Node_Str" + bval + "String_Node_Str"+ pred);
      }
      if (((BoolValue)bval).val) {
        return this.getNextStates(acts,s0,s1,nss);
      }
      return s1;
    }
  }
  TLCState resState=s1;
switch (opcode) {
case OPCODE_cl:
case OPCODE_land:
{
      ActionItemList acts1=acts;
      for (int i=alen - 1; i > 0; i--) {
        acts1=acts1.cons(args[i],c,i);
      }
      if (this.callStack != null)       this.callStack.push(args[0]);
      resState=this.getNextStates(args[0],acts1,c,s0,s1,nss);
      if (this.callStack != null)       this.callStack.pop();
      return resState;
    }
case OPCODE_dl:
case OPCODE_lor:
{
    for (int i=0; i < alen; i++) {
      if (this.callStack != null)       this.callStack.push(args[i]);
      resState=this.getNextStates(args[i],acts,c,s0,resState,nss);
      if (this.callStack != null)       this.callStack.pop();
    }
    return resState;
  }
case OPCODE_be:
{
  SemanticNode body=args[0];
  ContextEnumerator Enum=this.contexts(pred,c,s0,s1,EvalControl.Clear);
  Context c1;
  while ((c1=Enum.nextElement()) != null) {
    resState=this.getNextStates(body,acts,c1,s0,resState,nss);
  }
  return resState;
}
case OPCODE_bf:
{
SemanticNode body=args[0];
ContextEnumerator Enum=this.contexts(pred,c,s0,s1,EvalControl.Clear);
Context c1=Enum.nextElement();
if (c1 == null) {
  resState=this.getNextStates(acts,s0,s1,nss);
}
 else {
  ActionItemList acts1=acts;
  Context c2;
  while ((c2=Enum.nextElement()) != null) {
    acts1=acts1.cons(body,c2,-1);
  }
  resState=this.getNextStates(body,acts1,c1,s0,s1,nss);
}
return resState;
}
case OPCODE_fa:
{
Value fval=this.eval(args[0],c,s0,s1,EvalControl.KeepLazy);
if (fval instanceof FcnLambdaValue) {
FcnLambdaValue fcn=(FcnLambdaValue)fval;
if (fcn.fcnRcd == null) {
  Context c1=this.getFcnContext(fcn,args,c,s0,s1,EvalControl.Clear);
  return this.getNextStates(fcn.body,acts,c1,s0,s1,nss);
}
fval=fcn.fcnRcd;
}
if (!(fval instanceof Applicable)) {
Assert.fail("String_Node_Str" + fval.getKindString() + "String_Node_Str"+ pred);
}
Applicable fcn=(Applicable)fval;
Value argVal=this.eval(args[1],c,s0,s1,EvalControl.Clear);
Value bval=fcn.apply(argVal,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + pred);
}
if (((BoolValue)bval).val) {
return this.getNextStates(acts,s0,s1,nss);
}
return resState;
}
case OPCODE_aa:
{
ActionItemList acts1=acts.cons(args[1],c,-3);
return this.getNextStates(args[0],acts1,c,s0,s1,nss);
}
case OPCODE_sa:
{
resState=this.getNextStates(args[0],acts,c,s0,resState,nss);
return this.processUnchanged(args[1],acts,c,s0,resState,nss);
}
case OPCODE_ite:
{
Value guard=this.eval(args[0],c,s0,s1,EvalControl.Clear);
if (!(guard instanceof BoolValue)) {
Assert.fail("String_Node_Str" + guard.getKindString() + "String_Node_Str"+ "String_Node_Str"+ pred);
}
if (((BoolValue)guard).val) {
return this.getNextStates(args[1],acts,c,s0,s1,nss);
}
 else {
return this.getNextStates(args[2],acts,c,s0,s1,nss);
}
}
case OPCODE_case:
{
SemanticNode other=null;
for (int i=0; i < alen; i++) {
OpApplNode pair=(OpApplNode)args[i];
ExprOrOpArgNode[] pairArgs=pair.getArgs();
if (pairArgs[0] == null) {
other=pairArgs[1];
}
 else {
Value bval=this.eval(pairArgs[0],c,s0,s1,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + bval.getKindString() + "String_Node_Str"+ "String_Node_Str"+ pairArgs[1]);
}
if (((BoolValue)bval).val) {
return this.getNextStates(pairArgs[1],acts,c,s0,s1,nss);
}
}
}
if (other == null) {
Assert.fail("String_Node_Str" + "String_Node_Str" + pred);
}
return this.getNextStates(other,acts,c,s0,s1,nss);
}
case OPCODE_eq:
{
SymbolNode var=this.getPrimedVar(args[0],c,false);
if (var == null) {
Value bval=this.eval(pred,c,s0,s1,EvalControl.Clear);
if (!((BoolValue)bval).val) {
return resState;
}
}
 else {
UniqueString varName=var.getName();
Value lval=s1.lookup(varName);
Value rval=this.eval(args[1],c,s0,s1,EvalControl.Clear);
if (lval == null) {
resState.bind(varName,rval,pred);
resState=this.getNextStates(acts,s0,resState,nss);
resState.unbind(varName);
return resState;
}
 else if (!lval.equals(rval)) {
return resState;
}
}
return this.getNextStates(acts,s0,s1,nss);
}
case OPCODE_in:
{
SymbolNode var=this.getPrimedVar(args[0],c,false);
if (var == null) {
Value bval=this.eval(pred,c,s0,s1,EvalControl.Clear);
if (!((BoolValue)bval).val) {
return resState;
}
}
 else {
UniqueString varName=var.getName();
Value lval=s1.lookup(varName);
Value rval=this.eval(args[1],c,s0,s1,EvalControl.Clear);
if (lval == null) {
if (!(rval instanceof Enumerable)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + pred);
}
ValueEnumeration Enum=((Enumerable)rval).elements();
Value elem;
while ((elem=Enum.nextElement()) != null) {
resState.bind(varName,elem,pred);
resState=this.getNextStates(acts,s0,resState,nss);
resState.unbind(varName);
}
return resState;
}
 else if (!rval.member(lval)) {
return resState;
}
}
return this.getNextStates(acts,s0,s1,nss);
}
case OPCODE_implies:
{
Value bval=this.eval(args[0],c,s0,s1,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + bval.getKindString() + "String_Node_Str"+ pred);
}
if (((BoolValue)bval).val) {
return this.getNextStates(args[1],acts,c,s0,s1,nss);
}
 else {
return this.getNextStates(acts,s0,s1,nss);
}
}
case OPCODE_unchanged:
{
return this.processUnchanged(args[0],acts,c,s0,s1,nss);
}
case OPCODE_cdot:
{
Assert.fail("String_Node_Str");
return s1;
}
default :
{
Value bval=this.eval(pred,c,s0,s1,EvalControl.Clear);
if (!(bval instanceof BoolValue)) {
Assert.fail("String_Node_Str" + "String_Node_Str" + bval + "String_Node_Str"+ pred);
}
if (((BoolValue)bval).val) {
resState=this.getNextStates(acts,s0,s1,nss);
}
return resState;
}
}
}