private Kind isPowerOfTwoOperation(Variable v, Expr expr)
        {
            if (!(
                    v.TypedIdent.Type.Equals(verifier.IntRep.GetIntType(8)) ||
                    v.TypedIdent.Type.Equals(verifier.IntRep.GetIntType(16)) ||
                    v.TypedIdent.Type.Equals(verifier.IntRep.GetIntType(32))
                    ))
            {
                return(Kind.No);
            }

            Expr lhs, rhs;

            if (IntegerRepresentationHelper.IsFun(expr, "MUL", out lhs, out rhs))
            {
                if ((IsVariable(lhs, v) || IsVariable(rhs, v)) && (IsConstant(lhs, 2) || IsConstant(rhs, 2)))
                {
                    return(Kind.Inc);
                }
            }

            if (IntegerRepresentationHelper.IsFun(expr, "DIV", out lhs, out rhs) ||
                IntegerRepresentationHelper.IsFun(expr, "SDIV", out lhs, out rhs))
            {
                if (IsVariable(lhs, v) && IsConstant(rhs, 2))
                {
                    return(Kind.Dec);
                }
            }

            if (IntegerRepresentationHelper.IsFun(expr, "SHL", out lhs, out rhs))
            {
                if (IsVariable(lhs, v) && IsConstant(rhs, 1))
                {
                    return(Kind.Inc);
                }
            }

            if (IntegerRepresentationHelper.IsFun(expr, "ASHR", out lhs, out rhs))
            {
                if (IsVariable(lhs, v) && IsConstant(rhs, 1))
                {
                    return(Kind.Dec);
                }
            }

            if (IntegerRepresentationHelper.IsFun(expr, "LSHR", out lhs, out rhs))
            {
                if (IsVariable(lhs, v) && IsConstant(rhs, 1))
                {
                    return(Kind.Dec);
                }
            }

            return(Kind.No);
        }
        private Variable GetPowerOfTwoRhsVariable(Expr expr)
        {
            Expr lhs, rhs;

            if (IntegerRepresentationHelper.IsFun(expr, "MUL", out lhs, out rhs))
            {
                if (IsVariable(lhs) && IsConstant(rhs, 2))
                {
                    return(GetVariable(lhs));
                }
                else if (IsConstant(lhs, 2) && IsVariable(rhs))
                {
                    return(GetVariable(rhs));
                }
                else
                {
                    return(null);
                }
            }

            if (IntegerRepresentationHelper.IsFun(expr, "DIV", out lhs, out rhs) ||
                IntegerRepresentationHelper.IsFun(expr, "SDIV", out lhs, out rhs))
            {
                if (IsVariable(lhs) && IsConstant(rhs, 2))
                {
                    return(GetVariable(lhs));
                }
                else
                {
                    return(null);
                }
            }

            if (IntegerRepresentationHelper.IsFun(expr, "SHL", out lhs, out rhs) ||
                IntegerRepresentationHelper.IsFun(expr, "ASHR", out lhs, out rhs) ||
                IntegerRepresentationHelper.IsFun(expr, "LSHR", out lhs, out rhs))
            {
                if (IsVariable(lhs) && IsConstant(rhs))
                {
                    return(GetVariable(lhs));
                }
                else
                {
                    return(null);
                }
            }

            return(null);
        }
 public bool IsSext(Expr e, out Expr subExpr)
 {
     return(IntegerRepresentationHelper.IsFun(e, "SEXT[0-9]+", out subExpr));
 }
 public bool IsMul(Expr e, out Expr lhs, out Expr rhs)
 {
     return(IntegerRepresentationHelper.IsFun(e, "MUL", out lhs, out rhs));
 }