#include #include "config.c" // unwind must be >LEN // cbmc --trace --function check 1.c --unwind 11 --unwinding-assertions -DCBMC -DLEN=4 int naive(char* s) { // skip spaces while (*s==' ') s++; char *tmp=s; // read option (a-z) for (;;) { if ((*s>='a') && (*s<='z')) { s++; continue; } else break; }; // skip spaces while (*s==' ') s++; // match '=' if (*s!='=') return -1; s++; // skip spaces while (*s==' ') s++; tmp=s; // read option (0-9) for (;;) { if ((*s>='0') && (*s<='9')) { s++; continue; } else break; }; // skip spaces while (*s==' ') s++; // all done! return 1; }; #ifdef CBMC void check() { char s[LEN+1]; s[LEN]=0; __CPROVER_assert (naive(s)==fsm_main(s), "assert"); }; #endif int main() { //#define S " = " #define S "b=" printf ("%d\n", naive(S)); printf ("%d\n", fsm_main(S)); };