int main() { struct TreeNode { struct TreeNode* left; struct TreeNode* right; }; struct TreeNode* root = malloc(sizeof(*root)), *n; root->left = NULL; root->right = NULL; while (__nondet()) { n = root; while (n->left && n->right) { if (__nondet()) n = n->left; else n = n->right; } if (!n->left && __nondet()) { n->left = malloc(sizeof(*n)); n->left->left = NULL; n->left->right = NULL; } if (!n->right && __nondet()) { n->right = malloc(sizeof(*n)); n->right->left = NULL; n->right->right = NULL; } } n = NULL; struct TreeNode* pred; while (root) { pred = NULL; n = root; while (n->left || n->right) { pred = n; if (n->left) n = n->left; else n = n->right; } if (pred) { if (n == pred->left) pred->left = NULL; else pred->right = NULL; } else root = NULL; free(n); } return 0; }
int main() { struct T { struct T* next; struct T* prev; }; struct T* x = NULL; struct T* y = NULL; while (__nondet()) { y = malloc(sizeof(struct T)); if (!y) abort(); y->next = x; y->prev = NULL; if (x) x->prev = y; x = y; } struct T* sorted = NULL; struct T* pred = NULL; struct T* z = NULL; while (x) { y = x; x = x->next; z = sorted; pred = NULL; __VERIFIER_plot(NULL); while (z && __nondet()) { pred = z; z = z->next; } y->next = z; if (z) z->prev = y; y->prev = pred; if (pred) pred->next = y; else sorted = y; } while (sorted != NULL) { y = sorted; sorted = sorted->next; free(y); } return 0; }
int main() { struct T { struct T* next; }; struct T* x = NULL; struct T* y = NULL; while (__nondet()) { y = malloc(sizeof(*y)); if (!y) abort(); y->next = x; x = y; } struct T* sorted = NULL; struct T* pred = NULL; struct T* z = NULL; while (x) { y = x; x = x->next; pred = NULL; z = sorted; while (z && __nondet()) { pred = z; z = z->next; } ___sl_plot(NULL); y->next = z; if (pred) pred->next = y; else sorted = y; } while (sorted != NULL) { x = sorted; sorted = sorted->next; free(x); } return 0; }
int main() { struct T* head = malloc(sizeof(struct T)); head->next = NULL; head->head = head; struct T* x = head; while (__nondet()) { x->next = malloc(sizeof(struct T)); x->next->next = NULL; x->next->head = head; x = x->next; } x = head; while (x != NULL) x = x->next; x = head; while (x != NULL) { struct T* y = x; x = x->next; free(y); } return 0; }
int main() { for (;;) { if (__nondet()) push(); else pop(); } }
int main() { struct T { struct T* next; }; struct T* x = NULL; struct T* y = NULL; while (__nondet()) { y = malloc(sizeof(*y)); if (!y) abort(); y->next = x; x = y; } struct T* z = NULL; while (x != NULL) { if (__nondet()) { if (z) z->next = x->next; else y = y->next; __VERIFIER_plot(NULL); free(x); break; } z = x; x = x->next; } while (y != NULL) { x = y; y = y->next; free(x); } return 0; }
int main() { struct T { struct T* next; struct T* prev; int data; }; struct T* x = NULL; struct T* y = NULL; x = malloc(sizeof(struct T)); if (!x) abort(); x->next = x; x->prev = x; x->data = 0; while (__nondet()) { y = malloc(sizeof(struct T)); if (!y) abort(); y->next = x->next; y->next->prev = y; y->prev = x; y->data = 0; x->next = y; y = NULL; } y = x->next; __VERIFIER_plot(NULL); while (y != x) { struct T* z = y; y = y->next; free(z); } free(x); return 0; }
int main() { struct master_item *sll = NULL; struct master_item* pm; struct list_head* lh, * lh2, *lh3; struct my_item *now, *next; create_sll_item(sll); create_sll_item(sll); while (__nondet()) create_sll_item(sll); while (sll) destroy_sll_item(sll); return 0; }
int main() { struct cell* S = NULL; int pc1 = 1; struct cell* t1 = NULL; struct cell* x1 = NULL; int pc4 = 1; struct cell* t4 = NULL; struct cell* x4 = NULL; struct cell* garbage = NULL; while(1) if (__nondet()) // ------------------- Push 1 ------------------- switch (pc1) { case 1: x1 = malloc(sizeof(*x1)); pc1 = 2; continue; case 2: t1 = S; pc1 = 3; continue; case 3: x1->next = t1; pc1 = 4; continue; case 4: // ___sl_plot("problema"); if (S == t1) { S = x1; pc1 = 1; x1 = NULL; t1 = NULL; } else { pc1 = 2; t1 = NULL; } continue; } else // ------------------- Pop 4 ------------------- switch (pc4) { case 1: t4 = S; pc4 = 2; continue; case 2: if (t4 == NULL) pc4 = 1; else pc4 = 3; continue; case 3: x4 = t4->next; pc4 = 4; continue; case 4: if (S == t4) { S = x4; t4->next = garbage; garbage = t4; pc4 = 1; x4 = NULL; t4 = NULL; } else { pc4 = 1; x4 = NULL; t4 = NULL; } continue; } return 0; }
int main() { struct T { struct T* next; struct T* prev; int data; }; struct T* x = NULL; struct T* y = NULL; x = malloc(sizeof(struct T)); x->next = NULL; x->prev = NULL; // first DLL while (__nondet()) { y = malloc(sizeof(struct T)); y->next = x; x->prev = y; y->prev = NULL; x = y; } struct T* z = NULL; y = malloc(sizeof(struct T)); y->next = NULL; y->prev = NULL; // pointer to the end of y struct T* yLast = y; // second DLL while (__nondet()) { z = malloc(sizeof(struct T)); z->next = y; y->prev = z; z->prev = NULL; y = z; } // concat 'x' and 'y' yLast->next = x; x->prev = yLast; y = NULL; z = NULL; __VERIFIER_plot("dll-concat-lists-0001"); y = x; while (y) { y = y->next; } __VERIFIER_plot("dll-concat-lists-0002"); // delete while (x->next) { y = x->next; x->next = x->next->next; free(y); } while (x->prev) { y = x->prev; x->prev = x->prev->prev; free(y); } free(x); return 0; }
int main() { struct TreeNode { struct TreeNode* left; struct TreeNode* right; struct TreeNode* parent; }; struct StackItem { struct StackItem* next; struct TreeNode* node; }; struct TreeNode* root = malloc(sizeof(*root)), *n; root->left = NULL; root->right = NULL; root->parent = NULL; while (__nondet()) { n = root; while (n->left && n->right) { if (__nondet()) n = n->left; else n = n->right; } if (!n->left && __nondet()) { n->left = malloc(sizeof(*n)); n->left->left = NULL; n->left->right = NULL; n->left->parent = n; } if (!n->right && __nondet()) { n->right = malloc(sizeof(*n)); n->right->left = NULL; n->right->right = NULL; n->right->parent = n; } } n = NULL; /* struct TreeNode* parent = root, * right = NULL, * curr; while (parent != NULL) { curr = parent->left; if (curr != NULL) { while (curr != right && curr->right != NULL) curr = curr->right; if (curr != right) { curr->right = parent; parent = parent->left; continue; } else curr->right = NULL; } else right = parent; parent = parent->right; } */ /* if (!root) return; struct TreeNode* current = root, * from = NULL; while (current != root || from == NULL) { while (current->left) current = current->left; if (current->right) { current = current->right; continue; } from = current; current = current->parent; if (from == current->left) { current = current->right; } else { while (from != current->left && current != root) { from = current; current = current->parent; } if (current == root && from == current->left && current->right) current = current->right; } } */ // struct TreeNode* pred; /* while (root) { // pred = NULL; n = root; while (n->left || n->right) { // pred = n; if (n->left) n = n->left; else n = n->right; } if (n->parent) { if (n == n->parent->left) n->parent->left = NULL; else n->parent->right = NULL; } else root = NULL; free(n); } */ struct StackItem* s = malloc(sizeof(*s)), *st; s->next = NULL; s->node = root; while (s != NULL) { st = s; s = s->next; n = st->node; free(st); if (n->left) { st = malloc(sizeof(*st)); st->next = s; st->node = n->left; s = st; } if (n->right) { st = malloc(sizeof(*st)); st->next = s; st->node = n->right; s = st; } free(n); } return 0; }
int main() { struct T { struct T* next; struct T* prev; int data; }; struct T2 { struct T head; struct T2* next; struct T2* prev; }; struct T2* first = NULL; struct T2* last = NULL; while (__nondet()) { struct T2* x = malloc(sizeof(struct T2)); x->next = NULL; x->prev = NULL; x->head.next = &x->head; x->head.prev = &x->head; x->head.data = 0; struct T* y = NULL; while (__nondet()) { y = malloc(sizeof(struct T)); y->next = x->head.next; y->next->prev = y; y->prev = &x->head; y->data = 0; x->head.next = y; y = NULL; } if (!first) { first = x; last = x; } else { last->next = x; x->prev = last; last = x; } } while (first) { struct T2* x = first; first = first->next; struct T* y = x->head.next; while (y != &x->head) { struct T* z = y; y = y->next; free(z); } free(x); } return 0; }
int main() { struct T { struct T* next; int data; }; struct T2 { struct T head; struct T2* next; }; struct T2* first = NULL; struct T2* last = NULL; while (__nondet()) { struct T2* x = malloc(sizeof(struct T2)); if (!x) abort(); x->next = NULL; x->head.next = &x->head; x->head.data = 0; struct T* y = NULL; while (__nondet()) { y = malloc(sizeof(struct T)); if (!y) abort(); y->next = x->head.next; y->data = 0; x->head.next = y; y = NULL; } if (!first) { first = x; last = x; } else { last->next = x; last = x; } } ___sl_plot(NULL); while (first) { struct T2* x = first; first = first->next; struct T* y = x->head.next; while (y != &x->head) { struct T* z = y; y = y->next; free(z); } free(x); } return 0; }