1*48123Sbostic /*-
2*48123Sbostic  * %sccs.include.proprietary.c%
3*48123Sbostic  */
4*48123Sbostic 
510968Srrh #ifndef lint
6*48123Sbostic static char sccsid[] = "@(#)3.branch.c	4.2 (Berkeley) 04/16/91";
7*48123Sbostic #endif /* not lint */
810968Srrh 
910968Srrh #include <stdio.h>
1010968Srrh #include "def.h"
1110968Srrh #include "3.def.h"
1210968Srrh 
1310968Srrh 
1410968Srrh getbranch(head)
1510968Srrh VERT *head;
1610968Srrh 	{
1710968Srrh 	VERT v;
1810968Srrh 	for (v = 0; v < nodenum; ++v)
1910968Srrh 		LABEL(v) = FALSE;
2010968Srrh 	for (v = START; DEFINED(v); v = RSIB(v))
2110968Srrh 		chkbranch(v,head);
2210968Srrh 	addlab(START);
2310968Srrh 	}
2410968Srrh 
2510968Srrh 
2610968Srrh 
2710968Srrh chkbranch(v,head)
2810968Srrh VERT v,*head;
2910968Srrh 	{
3010968Srrh 	VERT  w;
3110968Srrh 	int i;
3210968Srrh 	switch(NTYPE(v))
3310968Srrh 		{
3410968Srrh 		case GOVX:
3510968Srrh 				for (i = 1, w = head[v]; DEFINED(w); w = head[w], ++i)
3610968Srrh 					{
3710968Srrh 					if (i > 1 && !levnxt && !levbrk) break;
3810968Srrh 					if (ARC(v,0) == BRK(w) && (levbrk || i == 1))
3910968Srrh 						{
4010968Srrh 						NTYPE(v) = BRKVX;
4110968Srrh 						LEVEL(v) = i;
4210968Srrh 						break;
4310968Srrh 						}
4410968Srrh 					else if (ARC(v,0) == NXT(w) && (levnxt || i == 1))
4510968Srrh 						{
4610968Srrh 						NTYPE(v) = NXTVX;
4710968Srrh 						LEVEL(v) = i;
4810968Srrh 						break;
4910968Srrh 						}
5010968Srrh 					}
5110968Srrh 			if (NTYPE(v) == GOVX)
5210968Srrh 				{
5310968Srrh 				if (ARC(v,0) == stopvert)
5410968Srrh 					NTYPE(v) = STOPVX;
5510968Srrh 				else if (ARC(v,0) == retvert)
5610968Srrh 					NTYPE(v) = RETVX;
5710968Srrh 				else LABEL(ARC(v,0)) = TRUE;
5810968Srrh 				}
5910968Srrh 			break;
6010968Srrh 		case COMPVX:
6110968Srrh 		case ASGOVX:
6210968Srrh 			for (i = 0; i < ARCNUM(v); ++i)
6310968Srrh 				LABEL(ARC(v,i)) = TRUE;
6410968Srrh 			break;
6510968Srrh 		case IOVX:
6610968Srrh 				if (DEFINED(ARC(v,ENDEQ)))
6710968Srrh 					LABEL(ARC(v,ENDEQ)) = TRUE;
6810968Srrh 				if (DEFINED(ARC(v,ERREQ)))
6910968Srrh 					LABEL(ARC(v,ERREQ)) = TRUE;
7010968Srrh 				if (DEFINED(FMTREF(v)))
7110968Srrh 					LABEL(FMTREF(v)) = TRUE;
7210968Srrh 				break;
7310968Srrh 		}
7410968Srrh 	for (i = 0; i < CHILDNUM(v); ++i)
7510968Srrh 		for (w = LCHILD(v,i); DEFINED(w); w = RSIB(w))
7610968Srrh 			chkbranch(w,head);
7710968Srrh 	}
7810968Srrh 
7910968Srrh 
8010968Srrh addlab(v)		/* add labels */
8110968Srrh VERT v;
8210968Srrh 	{
8310968Srrh 	int recvar;
8410968Srrh 	if (NTYPE(v) != ITERVX && LABEL(v) )
8510968Srrh 		LABEL(v) = nxtlab();
8610968Srrh 	RECURSE(addlab,v,recvar);
8710968Srrh 	if (NTYPE(v) == ITERVX && LABEL(NXT(v)))
8810968Srrh 		LABEL(NXT(v)) = nxtlab();
8910968Srrh 	}
9010968Srrh 
9110968Srrh 
9210968Srrh nxtlab()
9310968Srrh 	{
9410968Srrh 	static count;
9510968Srrh 	return(labinit + (count++) * labinc);
9610968Srrh 	}
97