Hi guys,
Im trying to run klee on some programs but facing a lot of problems. Could
someone guide me as to what will be the most optimal way to run klee on the
attached program.
NOTE: Wherever i make the variable symbolic, they were scanf statements in
the original program meant to take input from STDIN or files.
Anyhelp would be much appreciated havent been able to figure things out
from online resources related to klee.
Regards
Udayan Tandon
#include<stdio.h>
#include<stdlib.h>
#include<klee/klee.h>
struct node
{
int dest;
struct node *next;
};
struct AdjList
{
struct node *head;
};
struct graph
{
int v;
struct AdjList *arr;
};
struct graph *p;
int visited[100005],bi_index[100005];
struct queue
{
int info;
struct queue *next;
};
struct queue *front=NULL,*rear=NULL;
int isEmpty()
{
if(front==NULL)
return 1;
return 0;
}
void enqueue(int x)
{
struct queue *q;
q=(struct queue*)malloc(sizeof(struct queue));
q->info=x;
q->next=NULL;
if(isEmpty())
{
front=q;
rear=q;
}
else
{
rear->next=q;
rear=q;
}
}
int dequeue()
{
if(isEmpty())
return -1;
int x=front->info;
struct queue*temp=front;
front=front->next;
free(temp);
return x;
}
struct node *newNode(int dest)
{
struct node *temp=(struct node*)malloc(sizeof(struct node));
temp->dest=dest;
temp->next=NULL;
return temp;
}
struct graph *create(int n)
{
p=(struct graph*)malloc(sizeof(struct graph));
p->v=n;
p->arr=(struct AdjList*)malloc(n*sizeof(struct node));
int i;
for(i=0;i<n;i++)
p->arr[i].head=NULL;
return p;
}
/*
void display(int n)
{
int i;
for(i=0;i<n;i++)
{
struct node *temp=p->arr[i].head;
printf("%dth list is:\nhead",i);
while(temp!=NULL)
{
printf("->%d",temp->dest);
temp=temp->next;
}
printf("\n");
}
}
*/
void add_edge(int i,int j)
{
// add(i,j)
struct node *new_node=newNode(i);
new_node->next=p->arr[j].head;
p->arr[j].head=new_node;
// add(j,i)
struct node *new_node2=newNode(j);
new_node2->next=p->arr[i].head;
p->arr[i].head=new_node2;
}
int bi_partite(int k)
{
front=NULL;
rear=NULL;
enqueue(k);
visited[k]=1;
// level[k]=1;
bi_index[k]=0;
while(!isEmpty())
{
k=dequeue();
// printf("%d %d\n",k,level[k]);
struct node *temp=p->arr[k].head;
while(temp!=NULL)
{
int t=temp->dest;
if(visited[t]==0)
{
enqueue(t);
visited[t]=1;
// level[t]=level[k]+1;
bi_index[t]=(bi_index[k]+1)%2;
}
else
{
if(bi_index[t]==bi_index[k])
return 0;
}
temp=temp->next;
}
}
return 1;
// printf("\n");
}
int main()
{
int t;
klee_make_symbolic(&t, sizeof(t), "t");
while(t>0)
{
int v,e,i,start,end;
klee_make_symbolic(&v, sizeof(v), "v");
klee_make_symbolic(&e, sizeof(e), "e");
p=create(v);
for(i=0;i<e;i++)
{
klee_make_symbolic(&start, sizeof(start), "start");
klee_make_symbolic(&end, sizeof(end), "end");
if(start<1 || end<1 || start>v || end>v);
else
add_edge(start-1,end-1);
}
for(i=0;i<v;i++)
visited[i]=0;
int x=1;
// display(v);
for(i=0;i<v;i++)
{
if(visited[i]==0)
{
x=bi_partite(i);
// printf("%d\n",x);
if(x==0)
break;
}
}
if(x==1)
printf("YES\n");
else
printf("NO\n");
free(p);
p=NULL;
t--;
}
return 0;
}
_______________________________________________
klee-dev mailing list
[email protected]
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev