-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathex.cpp
103 lines (87 loc) · 1.81 KB
/
ex.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// Jonathan Salwan - 2013-08-24
//
// http://shell-storm.org
// http://twitter.com/JonathanSalwan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
#include <iostream>
#include "z3++.h"
//class SolveEq
//{
// private:
// z3::context *c;
// z3::solver *s;
// z3::expr *eq;
// z3::model *m;
// z3::expr *x;
//
// public:
// SolveEq();
// ~SolveEq();
//};
//
//SolveEq::SolveEq()
//{
// this->c = new z3::context;
// this->x = new z3::expr(c->bv_const("x", 32));
// this->s = new z3::solver(*(this->c));
// this->eq = new z3::expr(*(this->x));
//};
//
//SolveEq::~SolveEq()
//{
// delete this->c;
// delete this->x;
// delete this->s;
// delete this->eq;
//}
//
//SolveEq::setExpr(z3::expr &expr)
//{
// *(this->eq) = expr;
//}
int main(int ac, const char *av[])
{
z3::context *c;
z3::expr *x;
z3::solver *s;
z3::expr *eq;
z3::model *m;
c = new z3::context;
x = new z3::expr(c->bv_const("x", 32));
s = new z3::solver(*c);
eq = new z3::expr(*x);
*eq = (*x ^ 0x55);
*eq = (*eq == 0x30);
s->add(*eq);
std::cout << s->check() << "\n";
m = new z3::model(s->get_model());
std::cout << *m << "\n";
delete m;
delete eq;
delete x;
delete s;
delete c;
// ----------------------------
c = new z3::context;
x = new z3::expr(c->bv_const("x", 32));
s = new z3::solver(*c);
eq = new z3::expr(*x);
*eq = (*x ^ 0x55);
*eq = (*eq == 0x39);
s->add(*eq);
std::cout << s->check() << "\n";
m = new z3::model(s->get_model());
std::cout << *m << "\n";
delete m;
delete eq;
delete x;
delete s;
delete c;
return 0;
}