2019-06-13 14:43:11 +00:00
|
|
|
from z3 import *
|
|
|
|
|
|
|
|
def ADD(x, y):
|
|
|
|
return x + y
|
|
|
|
|
|
|
|
def MUL(x, y):
|
|
|
|
return x * y
|
|
|
|
|
|
|
|
def SUB(x, y):
|
|
|
|
return x - y
|
|
|
|
|
|
|
|
def DIV(x, y):
|
|
|
|
return If(y == 0, 0, UDiv(x, y))
|
|
|
|
|
|
|
|
def SDIV(x, y):
|
|
|
|
return If(y == 0, 0, x / y)
|
|
|
|
|
|
|
|
def MOD(x, y):
|
|
|
|
return If(y == 0, 0, URem(x, y))
|
|
|
|
|
|
|
|
def SMOD(x, y):
|
|
|
|
return If(y == 0, 0, x % y)
|
|
|
|
|
|
|
|
def LT(x, y):
|
2019-06-14 14:57:57 +00:00
|
|
|
return If(ULT(x, y), BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
2019-06-13 14:43:11 +00:00
|
|
|
|
|
|
|
def GT(x, y):
|
2019-06-14 14:57:57 +00:00
|
|
|
return If(UGT(x, y), BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
2019-06-13 14:43:11 +00:00
|
|
|
|
|
|
|
def SLT(x, y):
|
2019-06-14 14:57:57 +00:00
|
|
|
return If(x < y, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
2019-06-13 14:43:11 +00:00
|
|
|
|
|
|
|
def SGT(x, y):
|
2019-06-14 14:57:57 +00:00
|
|
|
return If(x > y, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
|
|
|
|
2019-06-14 15:47:54 +00:00
|
|
|
def EQ(x, y):
|
|
|
|
return If(x == y, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
|
|
|
|
2019-06-14 14:57:57 +00:00
|
|
|
def ISZERO(x):
|
|
|
|
return If(x == 0, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
2019-06-13 14:43:11 +00:00
|
|
|
|
|
|
|
def AND(x, y):
|
|
|
|
return x & y
|
|
|
|
|
2020-04-20 14:14:22 +00:00
|
|
|
def OR(x, y):
|
|
|
|
return x | y
|
|
|
|
|
2019-06-13 14:43:11 +00:00
|
|
|
def SHL(x, y):
|
|
|
|
return y << x
|
|
|
|
|
|
|
|
def SHR(x, y):
|
|
|
|
return LShR(y, x)
|
|
|
|
|
|
|
|
def SAR(x, y):
|
|
|
|
return y >> x
|