
void check_inout(void)
{
	char temp11[20];
if(strcmp(temp,"input")==0)
{
fprintf(fd,"\ninput");
fscanf(fs,"%s",temp11);
//fgets(temp11,sizeof(temp11),fs);

if(temp11[0]=='[')
{
	strcpy(in.size[in.count],temp11);
	fscanf(fs,"%s",temp11);
	fprintf(fd," %s",in.size[in.count]);
	strcpy(in.var[in.count],temp11);
	fprintf(fd,"  %s",in.var[in.count]);
}
else
{
	strcpy(in.var[in.count],temp11);
	strcpy(in.size[in.count],"0");
	fprintf(fd,"  %s",in.var[in.count]);
}

in.count++;
}

if(strcmp(temp,"output")==0)
{
fprintf(fd,"\noutput");
fscanf(fs,"%s",temp11);
if(temp11[0]=='[')
{
	strcpy(out.size[out.count],temp11);
	fscanf(fs,"%s",temp11);
	fprintf(fd," %s",out.size[out.count]);
	strcpy(out.var[out.count],temp11);
	fprintf(fd,"  %s",out.var[out.count]);
}
else
{
	strcpy(out.var[out.count],temp11);
	strcpy(out.size[out.count],"0");
	fprintf(fd,"  %s",out.var[out.count]);
}

out.count++;
}
}

void check_assign(void)
{
	int k1,k2,k3,ttt; char ch;
	char temp12[40],out1[40];
fscanf(fs,"%s",assign.as[assign.count]);
strcpy(assign1,assign.as[assign.count]);


	l=0;l2=0;l3=0;
	while(assign1[l]!='=')
	{
		l++;
	}
	printf("\n%d\n",l);
	i=l;
	while(1)
	{
	if(assign1[i]=='&') break;
	i++;
	}
	l1=i;
	/*while(1)
	{
	if(assign1[i+1]==';') break;  printf("\n%d",i);scanf("%d",&ttt);
	i++;
	}
	l2=i;
	for(i=l;i<l1;i++)
	{ var2[i]=assign1[i];} var2[i+1]='\0';
	for(i=l1;l<l2;i++)
	{ var3[i]=assign1[i];} var3[i+1]='\0';  */
	printf("\ni=%d  l1=%d,  l2=%d,  var2=%s,  var3=%s,\n",i,l1,l2,var2,var3);
scanf("%d",&ttt);
for(i=0;i<=out.count;i++)
{
	strcpy(temp12,out.var[i]);
	if(temp12[0]==assign1[0])
	{ strcpy(out1,out.size[i]);j=digit(out1[1]);break;}
}
  k2=0;k3=0;
for(k1=0;assign1[k1]!='\0';k1++)
{
  if(assign1[k1]=='&' || assign1[k1]=='|' || assign1[k1]=='^' || assign1[k1]=='~')
  {
  if(k2!=1)
   { ch=assign1[k1];k2=1;  }
    if(ch!=assign1[k1]){ k3=1;}
  }
}
  if(k3==1)

  and_or();

else and_or0();
}

void and_or0(void)
{

if(assign1[2+l]==';')
{
for(m=0;m<l;m++)
	var1[m]=assign1[m];
var1[m]='\0';
	for(i=0;i<=j;i++)
	{
fprintf(fd,"BUF BUF_%d",buf.count);
if(j!=0)
fprintf(fd,"(%s[%d],%c[%d]);\n",var1,(j-i),assign1[1+l],(j-i));
else
fprintf(fd,"(%s,%c);\n",var1,assign1[1+l]);
buf.count++;
	}
}

else if(assign1[1+l]=='~')
{
for(m=0;m<l;m++)
	var1[m]=assign1[m];
var1[m]='\0';

	{
fprintf(fd,"INRBH INRBH_%d",not.count);
if(j!=0)
fprintf(fd,"(%s[%d],%c[%d]);\n",var1,(j-i),assign1[2+l],(j-i));
else
fprintf(fd,"(%s,%c);\n",var1,assign1[2+l]);
not.count++;
	}
}
else if(assign1[2+l+l1-1]=='&')
{
for(m=0;m<l;m++)
	var1[m]=assign1[m];
var1[m]='\0';
for(i=0;i<=j;i++)
	{
fprintf(fd,"AND2 AND_%d ",and.count);
if(j!=0)
fprintf(fd,"(%s[%d],%s[%d],%s[%d]);\n",var1,(j-i),var2,(j-i),var3,(j-i));
else
fprintf(fd,"(%s,%s,%s);\n",var1,var2,var3);
and.count++;
	}
}

else if(assign1[2+l]=='|')
{
for(m=0;m<l;m++)
	var1[m]=assign1[m];
var1[m]='\0';
	for(i=0;i<=j;i++)
	{
fprintf(fd,"OR2 OR_%d ",or.count);
if(j!=0)
fprintf(fd,"(%s[%d],%c[%d],%c[%d]);\n",var1,(j-i),assign1[1+l],(j-i),assign1[3+l],(j-i));
else
fprintf(fd,"(%s,%c,%c);\n",var1,assign1[1+l],assign1[3+l]);
or.count++;
	}
}


else if(assign1[2+l]=='^')
{
for(m=0;m<l;m++)
	var1[m]=assign1[m];
var1[m]='\0';
	for(i=0;i<=j;i++)
	{
fprintf(fd,"XOR2 XOR_%d ",xor.count);
if(j!=0)
fprintf(fd,"(%s[%d],%c[%d],%c[%d]);\n",var1,(j-i),assign1[1+l],(j-i),assign1[3+l],(j-i));
else
fprintf(fd,"(%s,%c,%c);\n",var1,assign1[1+l],assign1[3+l]);
xor.count++;

	}
}
assign.count++;
}

void initialise(void)
{
and.count=1;
or.count=1;
xor.count=1;
not.count=1;
nand.count=1;
xnor.count=1;
nor.count=1;
nand3.count=1;
nor3.count=1;
buf.count=1;
or4.count=1;
nand4.count=1;
nor4.count=1;
assign.count=1;
}


int digit(char c)
{
	if(c=='1') return(1);
	else if(c=='2') return(2);
	else if(c=='3') return(3);
	else if(c=='4') return(4);
	else if(c=='5') return(5);
	else if(c=='6') return(6);
	else if(c=='7') return(7);
	else if(c=='8') return(8);
	else if(c=='9') return(9);
	else
		return(0);
}


