void check_inout(int i)
{          int j,k,l=0,s1=0,s2=0;  char siz1[4],siz2[4],nm[30];
    while(temp[i]!=';' && temp[i]!='\0')
    {
	if(isspace(temp[i])==0)
	{
	if (temp[i]=='[')
	{
		i++;
		l=0;
	       while (temp[i]!=':')
			{ siz1[l++]= temp[i++];}
		i++;siz1[l]='\0';l=0;
		while (temp[i]!=']')
			 siz2[l++]= temp[i++];
		siz2[l]='\0';
		l=0;i++;


		s1= atoi(siz1);
		s2= atoi(siz2);


	 }

	 while(temp[i]!=',' && temp[i]!=';')
	 {
	      if (isspace(temp[i])==0)
		nm[l++]=temp[i];
	      i++;
	 }nm[l]='\0';

	 strcpy(varray[varcount].name,nm);
	 varray[varcount].size1=s1;
	 varray[varcount].size2=s2;
	 varcount++;
	 strcpy(nm,"");l=0;
      }

    i++;
   }


   }


void and_or2(int t)
{
int ft=0,l,synt,v1=1,v1_index=0,v2_index=0,a=48,asc;
char conc[4],op[15]="synth_";
strcpy(assign1,temp);t++;
while (assign1[t]!='=')
{

	if (isspace(assign1[t])==0)
		final[ft++]=assign1[t];

	t++;

}final[ft]='\0';
for (l=0; l<varcount; l++)
{
	if(strcmp(final,varray[l].name)==0)
	{j=varray[l].size1; break;}
}
t++;
	strcpy(oper,"");
while(assign1[t]!=';')
{if(isspace(assign1[t])==0)
	{
	asc=assign1[t];

	if(((asc>=65 && asc<=90) || (asc>=97 && asc<=122)) && (v1==1))
		{  variable1[v1_index]=assign1[t];v1_index++; }
	else if((!((asc>=65 && asc<=90) || (asc>=97 && asc<=122))) && (v1==1))
		{oper[0]=assign1[t];oper[1]='\0';asc=assign1[t+1];
			if(!((asc>=65 && asc<=90) || (asc>=97 && asc<=122)) && isspace(asc)==0)
			{
			oper[1]=assign1[++t];oper[2]='\0';
			}
			v1=2;variable1[v1_index]='\0';
		}
	else if((asc>=65 && asc<=90) || (asc>=97 && asc<=122))
		{  variable2[v2_index]=assign1[t];v2_index++; }
	else
		{ conc[0]=a++;conc[1]='\0';
		variable2[v2_index]='\0';
		strcat(op,conc);
		strcpy(outvar,op);
		and1(j,j);
		oper[0]=assign1[t];oper[1]='\0';asc=assign1[t+1];
			if(!((asc>=65 && asc<=90) || (asc>=97 && asc<=122)) && isspace(asc)==0)
			{
			oper[1]=assign1[++t];oper[2]='\0'; 
			}
		v2_index=0;
		}
	}
	t++;

}
variable2[v2_index]='\0';
if(strcmp(oper,"")==0) 
variable1[v1_index]='\0';
strcpy(outvar,final);
and1(j,j);
}



void and1(int s,int index)
{

if(strcmp(oper,"")==0)
{
		if(s==0)
	{
	fprintf(fd,"BUF BUF_%d",buf.count++);

	fprintf(fd,"(%s , %s);\n",outvar,variable1);
	}
	else
	{
	while(index>=0)
	{	fprintf(fd,"BUF BUF_%d(%s[%d] , %s[%d]);\n",buf.count++,outvar,index,variable1,index); 
		index--;
	}
	}
}




else if(strcmp(oper,"~&")==0)
{
		if(s==0)
	{
	fprintf(fd,"NAND2 NAND_%d",nand.count++);

	fprintf(fd,"(%s , %s , %s);\n",outvar,variable1,variable2);
	}
	else
	{
	while(index>=0)
	{	fprintf(fd,"NAND2 NAND_%d(%s[%d] , %s[%d] , %s[%d]);\n",nand.count++,outvar,index,variable1,index,variable2,index); index--;}
	}
}



else if(strcmp(oper,"~|")==0)
{
		if(s==0)
	{
	fprintf(fd,"NOR2 NOR_%d",nor.count++);

	fprintf(fd,"(%s , %s , %s);\n",outvar,variable1,variable2);
	}
	else
	{
	while(index>=0)
	{	fprintf(fd,"NOR2 NOR_%d(%s[%d] , %s[%d] , %s[%d]);\n",nor.count++,outvar,index,variable1,index,variable2,index); index--;}
	}
}

else if(strcmp(oper,"~^")==0 || strcmp(oper,"^~")==0)
{
		if(s==0)
	{
	fprintf(fd,"XNOR2 XNOR_%d",xnor.count++);

	fprintf(fd,"(%s , %s , %s);\n",outvar,variable1,variable2);
	}
	else
	{
	while(index>=0)
	{	fprintf(fd,"XNOR2 XNOR_%d(%s[%d] , %s[%d] , %s[%d]);\n",xnor.count++,outvar,index,variable1,index,variable2,index); index--;}
	}
}



 else if(oper[0]=='&')
{      	if(s==0)
	{
	fprintf(fd,"AND2 AND_%d",and.count++);

	fprintf(fd,"(%s , %s , %s);\n",outvar,variable1,variable2);
	}
	else
	{
	while(index>=0)
	{	fprintf(fd,"AND2 AND_%d(%s[%d] , %s[%d] , %s[%d]);\n",and.count++,outvar,index,variable1,index,variable2,index); index--;}
	}
}
else if(oper[0]=='|')
{       if(s==0)
	{
	fprintf(fd,"OR2 OR_%d",or.count++);

	fprintf(fd,"(%s , %s , %s);\n",outvar,variable1,variable2);
	}
	else
	{
	while(index>=0)
	{  	fprintf(fd,"OR2 OR_%d(%s[%d] , %s[%d] , %s[%d]);\n",or.count++,outvar,index,variable1,index,variable2,index); index--;}
	}
}
else if(oper[0]=='^')
{
if(s==0)
{
fprintf(fd,"XOR2 XOR_%d",xor.count++);
fprintf(fd,"(%s , %s , %s);\n",outvar,variable1,variable2);
}
else
{
   while(index>=0)
  {  fprintf(fd,"XOR2 XOR_%d(%s[%d] , %s[%d] , %s[%d]);\n",xor.count++,outvar,index,variable1,index,variable2,index); index--;}
}
}
else if(oper[0]=='~')
{
if(s==0)
{
fprintf(fd,"NOT NOT_%d",not.count++);

fprintf(fd,"(%s , %s);\n",outvar,variable2);
}
else
{
   while(index>=0)
  {  fprintf(fd,"NOT NOT_%d(%s[%d] ,%s[%d]);\n",not.count++,outvar,index,variable2,index); index--;}
}

}

strcpy(variable1,outvar); strcpy(variable2,"");
}

