Skip to content

Instantly share code, notes, and snippets.

@moyix
Created July 27, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyix/e75d21ddea480d3e2ac72baf3dc1facf to your computer and use it in GitHub Desktop.
Save moyix/e75d21ddea480d3e2ac72baf3dc1facf to your computer and use it in GitHub Desktop.
// gcc z3ex.c -o z3ex -l z3
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "z3.h"
int main(void) {
Z3_config cfg;
Z3_context ctx;
cfg = Z3_mk_config();
ctx = Z3_mk_context(cfg);
Z3_sort I = Z3_mk_bv_sort(ctx, 64);
Z3_ast x = Z3_mk_int64(ctx, -5, I); // works if you change this to 5
Z3_string s = Z3_ast_to_string(ctx, x);
printf("%s\n", s);
int64_t x_val = 0;
if (Z3_get_numeral_int64(ctx, x, &x_val)) {
printf("Success: x = %" PRId64 "\n", x_val);
}
else {
printf("Failed.\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment