[llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.c 23tree.h Makefile addpins.c analyze.c bellman.c buster.c changraph.c checkpen.c config1.c config2.c config3.c custom.h density.c doborder.c doublecheck.c finalout.c finalpin.c findcheck.c findcost.c findloc.c findnodes.c findside.c fixpenal.c fulllink.c fuloop.c genorient.c gentwf.c geo.h ggenorien.c gglobals.c globals.c gmain.c goverlap.c goverlapf.c goverlapx.c gpass2.c grdcell.c grepair.c hash.c hprobes.c indepmake initbb.c kenk.h lists.h loadbins.c loadpg.c main.c makebins.c makelink.c makesite.c move.c mshortest.c mt.c mt.h neworient.c outbig.c outgeo.c outpin.c output.c outsmall.c parser.c pass2.c perimeter.c placepads.c placepin.c port.h prboard.c prepair.c prestrict.c printgph.c printnets.c procesnet.c readcells.c readgeo.c readgraph.c readnets.c readpar.c readpnode.c rebin.c reduceg.c rglobals.c rmain.c route.h routenet.c savewolf.c scrapnet.c scrappin.c selectpin.c setpwates.c shortpat! h.c test2loop.c testloop.c twstats.c uaspect.c ufixnet.c ufixpin.c uloop.c unbust.c upin.c upinswap.c usite0.c usite1.c usite2.c usiteo1.c usiteo2.c usoftnet.c usoftpin.c utemp.c vprobes.c watesides.c wirecosts.c wireest.c wireratio.c woverlap.c woverlapf.c woverlapx.c xgraph.c ygraph.c

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 5 14:20:07 PDT 2004



Changes in directory llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC:

23tree.c added (r1.1)
23tree.h added (r1.1)
Makefile added (r1.1)
addpins.c added (r1.1)
analyze.c added (r1.1)
bellman.c added (r1.1)
buster.c added (r1.1)
changraph.c added (r1.1)
checkpen.c added (r1.1)
config1.c added (r1.1)
config2.c added (r1.1)
config3.c added (r1.1)
custom.h added (r1.1)
density.c added (r1.1)
doborder.c added (r1.1)
doublecheck.c added (r1.1)
finalout.c added (r1.1)
finalpin.c added (r1.1)
findcheck.c added (r1.1)
findcost.c added (r1.1)
findloc.c added (r1.1)
findnodes.c added (r1.1)
findside.c added (r1.1)
fixpenal.c added (r1.1)
fulllink.c added (r1.1)
fuloop.c added (r1.1)
genorient.c added (r1.1)
gentwf.c added (r1.1)
geo.h added (r1.1)
ggenorien.c added (r1.1)
gglobals.c added (r1.1)
globals.c added (r1.1)
gmain.c added (r1.1)
goverlap.c added (r1.1)
goverlapf.c added (r1.1)
goverlapx.c added (r1.1)
gpass2.c added (r1.1)
grdcell.c added (r1.1)
grepair.c added (r1.1)
hash.c added (r1.1)
hprobes.c added (r1.1)
indepmake added (r1.1)
initbb.c added (r1.1)
kenk.h added (r1.1)
lists.h added (r1.1)
loadbins.c added (r1.1)
loadpg.c added (r1.1)
main.c added (r1.1)
makebins.c added (r1.1)
makelink.c added (r1.1)
makesite.c added (r1.1)
move.c added (r1.1)
mshortest.c added (r1.1)
mt.c added (r1.1)
mt.h added (r1.1)
neworient.c added (r1.1)
outbig.c added (r1.1)
outgeo.c added (r1.1)
outpin.c added (r1.1)
output.c added (r1.1)
outsmall.c added (r1.1)
parser.c added (r1.1)
pass2.c added (r1.1)
perimeter.c added (r1.1)
placepads.c added (r1.1)
placepin.c added (r1.1)
port.h added (r1.1)
prboard.c added (r1.1)
prepair.c added (r1.1)
prestrict.c added (r1.1)
printgph.c added (r1.1)
printnets.c added (r1.1)
procesnet.c added (r1.1)
readcells.c added (r1.1)
readgeo.c added (r1.1)
readgraph.c added (r1.1)
readnets.c added (r1.1)
readpar.c added (r1.1)
readpnode.c added (r1.1)
rebin.c added (r1.1)
reduceg.c added (r1.1)
rglobals.c added (r1.1)
rmain.c added (r1.1)
route.h added (r1.1)
routenet.c added (r1.1)
savewolf.c added (r1.1)
scrapnet.c added (r1.1)
scrappin.c added (r1.1)
selectpin.c added (r1.1)
setpwates.c added (r1.1)
shortpath.c added (r1.1)
test2loop.c added (r1.1)
testloop.c added (r1.1)
twstats.c added (r1.1)
uaspect.c added (r1.1)
ufixnet.c added (r1.1)
ufixpin.c added (r1.1)
uloop.c added (r1.1)
unbust.c added (r1.1)
upin.c added (r1.1)
upinswap.c added (r1.1)
usite0.c added (r1.1)
usite1.c added (r1.1)
usite2.c added (r1.1)
usiteo1.c added (r1.1)
usiteo2.c added (r1.1)
usoftnet.c added (r1.1)
usoftpin.c added (r1.1)
utemp.c added (r1.1)
vprobes.c added (r1.1)
watesides.c added (r1.1)
wirecosts.c added (r1.1)
wireest.c added (r1.1)
wireratio.c added (r1.1)
woverlap.c added (r1.1)
woverlapf.c added (r1.1)
woverlapx.c added (r1.1)
xgraph.c added (r1.1)
ygraph.c added (r1.1)
---
Log message:

New benchmarks (related to 300.twolf?) without an input, of course.


---
Diffs of the changes:  (+25177 -0)

Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.c:1.1
*** /dev/null	Tue Oct  5 16:20:00 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.c	Tue Oct  5 16:19:41 2004
***************
*** 0 ****
--- 1,1034 ----
+ /*
+  *  Some basic 2-3 tree functions:
+  *       1. tinsert( &root , value , property ) ;
+  *          TNODEPTR root ;
+  *          int value , property ;
+  *   
+  *       2. tdelete( &root , value , property ) ;
+  *          TNODEPTR root ;
+  *          int value , property ;
+  *      
+  *       3. tpop( &root , &node , &value , &property ) ;
+  *          TNODEPTR root , node ;
+  *          int value , property ;
+  *      
+  *       4. ttrim( &root , threshold ) ;
+  *          TNODEPTR root ;
+  *          int threshold ;
+  *      
+  *       5. tprint( root ) ;
+  *          TNODEPTR root ;
+  *
+  *       6. tdiscard( root , count )
+  *          TNODEPTR *root ;
+  *          int count ;
+  *
+  *       7. int tprop( r , value )   --- returns FIRST property
+  *          TNODEPTR r ;             associated with: value  of
+  *          int value ;              tree with root: r  ---
+  *
+  *       8. PLISTPTR tplist( r , value )  ---- return ptr to FIRST
+  *          TNODEPTR r ;                       property associated with
+  *          int value ;                        value of tree with root r.
+  *
+  *    To use the 2-3 tree implementation, compile the file: 23tree.c
+  *    with your source files and include the line: #include "23tree.h"
+  *    in any of your source files which use the 2-3 tree functions.
+  *    You may have several 2-3 trees active at once. Each tree must
+  *    given a "root", whose type is necessarily: TNODEPTR.  That is,
+  *    if you want 3 trees to be active, you must declare 3 roots in
+  *    the following fashion:
+  *        TNODEPTR root1 , root2 , root3 ;
+  *    Finally, before you can use any of the functions, you must
+  *    initialize the roots to NULL, as follows:
+  *        root1 = (TNODEPTR) NULL ;
+  *        root2 = (TNODEPTR) NULL ;
+  *        root3 = (TNODEPTR) NULL ;
+  */
+ #include "23tree.h"
+ 
+ void tdump( TNODEPTR node );
+ void tdelete( TNODEPTR *root , int value , int property );
+ void tpatch( TNODEPTR v , int value );
+ void makenode( TNODEPTR *v , int value , int property );
+ void addplist( TNODEPTR v , int property );
+ void tsubson( TNODEPTR *root , TNODEPTR l );
+ 
+ 
+ void tprint( TNODEPTR v )
+ {
+ 
+ int qbot , qtop ;
+ TNODEPTR node , *q , f ;
+ 
+ if( v == (TNODEPTR) NULL ) {
+     return ;
+ }
+ qtop = 0 ;
+ qbot = 0 ;
+ q = (TNODEPTR *) malloc( 10001 * sizeof(TNODEPTR) ) ;
+ q[0] = v ;
+ while( qtop >= qbot ) {
+     tdump( node = q[qbot++] ) ;
+     if( node != v ) {
+ 	f = node->father ;
+ 	if( f->son1 != node && f->son2 != node && f->son3 != node ) {
+ 	    printf("Error Type 1\n");
+ 	}
+ 	if( node->nsons != 0 ) {
+ 	    if( node->son1->father->Lval != node->Lval ) {
+ 		printf("Error Type 2\n");
+ 	    }
+ 	    if( node->son1->father->Mval != node->Mval ) {
+ 		printf("Error Type 3\n");
+ 	    }
+ 	}
+     }
+     if( node->nsons > 0 ) {
+ 	q[++qtop] = node->son1 ;
+ 	q[++qtop] = node->son2 ;
+ 	if( node->son3 != (TNODEPTR) NULL ) {
+ 	    q[++qtop] = node->son3 ;
+ 	}
+     }
+ }
+ free(q) ;
+ /*
+ tmin( v, &node, &value, &property );
+ printf("\n\nMinimum Tree Value: %d\n", value );
+ */
+ return ;
+ }
+ 
+ 
+ void tdump( TNODEPTR node )
+ {
+ 
+ PLISTPTR plptr ;
+ 
+ printf("\n");
+ if( node->nsons == 0 ) {
+     printf("value: %d  ", node->value );
+     plptr = node->plist ;
+     for( ; plptr != (PLISTPTR) NULL; plptr = plptr->pnext ) {
+ 	printf("%d ", plptr->property ) ;
+     }
+     printf("\n");
+ } else{
+     /* printf("Lval: %d   Mval: %d\n", node->Lval , node->Mval );
+     */
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void tmin( TNODEPTR root , TNODEPTR *node , int *value , int *property )
+ {
+ 
+ TNODEPTR v ;
+ 
+ v = root ;
+ if( v == (TNODEPTR) NULL ) {
+     *node = (TNODEPTR) NULL ;
+ } else {
+     while( v->son1 != (TNODEPTR) NULL ) {
+ 	v = v->son1 ;
+     }
+     *node = v ;
+     *value = v->value ;
+     *property = v->plist->property ;
+ }
+ 
+ return;
+ }
+ 
+ 
+ 
+ void tpop( TNODEPTR *root , TNODEPTR *node , int *value , int *property )
+ {
+ 
+ TNODEPTR v ;
+ 
+ v = *root ;
+ if( v == (TNODEPTR) NULL ) {
+     *node = (TNODEPTR) NULL ;
+ } else {
+     while( v->son1 != (TNODEPTR) NULL ) {
+ 	v = v->son1 ;
+     }
+     *node = v ;
+     *value = v->value ;
+     *property = v->plist->property ;
+     tdelete( root , *value , *property ) ;
+ }
+ 
+ return;
+ }
+ 
+ 
+ 
+ void tmax( TNODEPTR *root , TNODEPTR *node , int *value , int *property )
+ {
+ 
+ TNODEPTR v ;
+ 
+ v = *root ;
+ if( v == (TNODEPTR) NULL ) {
+     *node = (TNODEPTR) NULL ;
+ } else {
+     for( ; ; ) {
+ 	if( v->nsons == 3 ) {
+ 	    v = v->son3 ;
+ 	} else if( v->nsons == 2 ) {
+ 	    v = v->son2 ;
+ 	} else {
+ 	    break ;
+ 	}
+     }
+     *node = v ;
+     *value = v->value ;
+     *property = v->plist->property ;
+ }
+ 
+ return;
+ }
+ 
+ 
+ 
+ void ttrim( TNODEPTR *root , int threshold )
+ {
+ 
+ TNODEPTR node ;
+ int property , value ;
+ 
+ for( ; ; ) {
+     tmax( root , &node , &value , &property ) ;
+     if( node == (TNODEPTR) NULL ) {
+ 	break ;
+     } else if( value < threshold ) {
+ 	break ;
+     } else {
+ 	tdelete( root , value , property ) ;
+     }
+ }
+ 
+ return;
+ }
+ 
+ 
+ 
+ 
+ void tdiscard( TNODEPTR *root , int count )
+ {
+ 
+ TNODEPTR node ;
+ int property , value , i ;
+ 
+ for( i = 1 ; i <= count ; i++ ) {
+     tmax( root , &node , &value , &property ) ;
+     if( node == (TNODEPTR) NULL ) {
+ 	break ;
+     } else {
+ 	tdelete( root , value , property ) ;
+     }
+ }
+ return;
+ }
+ 
+ 
+ 
+ 
+ TNODEPTR tsearch( int val , TNODEPTR r )
+ {
+ 
+ if( r->son1->nsons == 0 ) {
+     return( r ) ;
+ } else {
+     if( val <= r->Lval ) {
+ 	return( tsearch( val , r->son1 ) ) ;
+     } else if( r->nsons == 2 || val <= r->Mval ) {
+ 	return( tsearch( val , r->son2 ) ) ;
+     } else {
+ 	return( tsearch( val , r->son3 ) ) ;
+     }
+ }
+ }
+ 
+ 
+ void taddson( TNODEPTR *root , TNODEPTR r )
+ {
+ 
+ TNODEPTR v , nr , f ;
+ 
+ v = (TNODEPTR) malloc( sizeof( TNODE ) ) ;
+ v->son1 = r->son3 ;
+ v->son2 = r->son4 ;
+ v->son3 = (TNODEPTR) NULL ;
+ v->son4 = (TNODEPTR) NULL ;
+ v->father = r->father ;
+ v->nsons = 2 ;
+ r->nsons = 2 ;
+ r->son3 = (TNODEPTR) NULL ;
+ r->son4 = (TNODEPTR) NULL ;
+ v->son1->father = v ;
+ v->son2->father = v ;
+ 
+ f = r->son1 ;
+ while( f->nsons == 3 ) {
+     f = f->son3 ;
+ }
+ if( f->nsons == 0 ) {
+     r->Lval = f->value ;
+ } else {
+     r->Lval = f->Mval ;
+ }
+ f = r->son2 ;
+ while( f->nsons == 3 ) {
+     f = f->son3 ;
+ }
+ if( f->nsons == 0 ) {
+     r->Mval = f->value ;
+ } else {
+     r->Mval = f->Mval ;
+ }
+ f = v->son1 ;
+ while( f->nsons == 3 ) {
+     f = f->son3 ;
+ }
+ if( f->nsons == 0 ) {
+     v->Lval = f->value ;
+ } else {
+     v->Lval = f->Mval ;
+ }
+ f = v->son2 ;
+ while( f->nsons == 3 ) {
+     f = f->son3 ;
+ }
+ if( f->nsons == 0 ) {
+     v->Mval = f->value ;
+ } else {
+     v->Mval = f->Mval ;
+ }
+ 
+ if( r->father == (TNODEPTR) NULL ) {
+     nr = (TNODEPTR) malloc( sizeof( TNODE ) ) ;
+     nr->son1 = r ;
+     nr->son2 = v ;
+     nr->son3 = (TNODEPTR) NULL ;
+     nr->son4 = (TNODEPTR) NULL ;
+     nr->father = (TNODEPTR) NULL ;
+     nr->nsons = 2 ;
+     r->father = nr ;
+     v->father = nr ;
+     nr->Lval = r->Mval ;
+     nr->Mval = v->Mval ;
+     *root = nr ;
+ } else {
+     f = r->father ;
+     if( ++f->nsons == 4 ) {
+ 	if( f->son1 == r ) {
+ 	    f->son4 = f->son3 ;
+ 	    f->son3 = f->son2 ;
+ 	    f->son2 = v ;
+ 	} else if( f->son2 == r ) {
+ 	    f->son4 = f->son3 ;
+ 	    f->son3 = v ;
+ 	} else {
+ 	    f->son4 = v ;
+ 	}
+ 	taddson( root , f ) ;
+     } else {
+ 	if( f->son1 == r ) {
+ 	    f->son3 = f->son2 ;
+ 	    f->son2 = v ;
+ 	    f->Lval = r->Mval ;
+ 	    f->Mval = v->Mval ;
+ 	} else {
+ 	    f->son3 = v ;
+ 	    f->Mval = r->Mval ;
+ 	    tpatch( f , v->Mval ) ;
+ 	}
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ 
+ 
+ void tinsert( TNODEPTR *root , int value , int property )
+ {
+ 
+ TNODEPTR v , nr , f , node ;
+ 
+ if( *root == (TNODEPTR) NULL ) {
+     makenode( &v , value , property ) ;
+     v->father = (TNODEPTR) NULL ;
+     *root = v ;
+ } else if( (*root)->nsons == 0 ) {
+     if( (*root)->value == value ) {
+ 	addplist( *root , property ) ;
+     } else {
+ 	makenode( &v , value , property ) ;
+ 	nr = (TNODEPTR) malloc( sizeof( TNODE ) ) ;
+ 	if( value <= (*root)->value ) {
+ 	    nr->Lval = value ;
+ 	    nr->Mval = (*root)->value ;
+ 	    nr->son1 = v ;
+ 	    nr->son2 = *root ;
+ 	    nr->son3 = (TNODEPTR) NULL ;
+ 	    nr->son4 = (TNODEPTR) NULL ;
+ 	} else {
+ 	    nr->Mval = value ;
+ 	    nr->Lval = (*root)->value ;
+ 	    nr->son1 = *root ;
+ 	    nr->son2 = v ;
+ 	    nr->son3 = (TNODEPTR) NULL ;
+ 	    nr->son4 = (TNODEPTR) NULL ;
+ 	}
+ 	nr->father = (TNODEPTR) NULL ;
+ 	nr->nsons = 2 ;
+ 	(*root)->father = nr ;
+ 	v->father = nr ;
+ 	*root = nr ;
+     }
+ } else {
+     f = tsearch( value , *root ) ;
+     node = tfind( value , f ) ;
+     if( node != (TNODEPTR) NULL ) {
+ 	addplist( node , property ) ;
+     } else {
+ 	makenode( &v , value , property ) ;
+ 	if( f->nsons == 2 ) {
+ 	    if( value <= f->son1->value ) {
+ 		f->son3 = f->son2 ;
+ 		f->son2 = f->son1 ;
+ 		f->son1 = v ;
+ 		f->Mval = f->Lval ;
+ 		f->Lval = value ;
+ 	    } else if( value <= f->son2->value ) {
+ 		f->son3 = f->son2 ;
+ 		f->son2 = v ;
+ 		f->Mval = value ;
+ 	    } else {
+ 		f->son3 = v ;
+ 		tpatch( f , value ) ;
+ 	    }
+ 	    f->nsons = 3 ;
+ 	    v->father = f ;
+ 	} else {
+ 	    if( value <= f->son1->value ) {
+ 		f->son4 = f->son3 ;
+ 		f->son3 = f->son2 ;
+ 		f->son2 = f->son1 ;
+ 		f->son1 = v ;
+ 	    } else if( value <= f->son2->value ) {
+ 		f->son4 = f->son3 ;
+ 		f->son3 = f->son2 ;
+ 		f->son2 = v ;
+ 	    } else if( value <= f->son3->value ) {
+ 		f->son4 = f->son3 ;
+ 		f->son3 = v ;
+ 	    } else {
+ 		f->son4 = v ;
+ 	    }
+ 	    v->father = f ;
+ 	    taddson( root , f ) ;
+ 	}
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void tpatch( TNODEPTR v , int value )
+ {
+ 
+ TNODEPTR f ;
+ 
+ f = v->father ;
+ if( f != (TNODEPTR) NULL ) {
+     if( f->son1 == v ) {
+ 	f->Lval = value ;
+     } else if( f->son2 == v ) {
+ 	f->Mval = value ;
+ 	if( f->son3 == (TNODEPTR) NULL ) {
+ 	    tpatch( f , value ) ;
+ 	}
+     } else {
+ 	tpatch( f , value ) ;
+     }
+ } 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ void tdelete( TNODEPTR *root , int value , int property )
+ {
+ 
+ TNODEPTR f , l , g , s ;
+ PLISTPTR plptr , prevptr ;
+ 
+ if( *root == (TNODEPTR) NULL ) {
+ } else if( (*root)->nsons == 0 ) {
+     plptr = pfind( *root , property , &prevptr ) ;
+     if( plptr != (PLISTPTR) NULL ) {
+ 	if( prevptr != (PLISTPTR) NULL ) {
+ 	    prevptr->pnext = plptr->pnext ;
+ 	    free( plptr ) ;
+ 	} else if( plptr->pnext != (PLISTPTR) NULL ) {
+ 	    (*root)->plist = plptr->pnext ;
+ 	    free( plptr ) ;
+ 	} else {
+ 	    free( plptr ) ;
+ 	    free( *root ) ;
+ 	    *root = (TNODEPTR) NULL ;
+ 	}
+     }
+ } else {
+     l = tdsearch( value , *root ) ;
+     if( l != (TNODEPTR) NULL ) {
+ 	plptr = pfind( l , property , &prevptr ) ;
+ 	if( plptr != (PLISTPTR) NULL ) {
+ 	    if( prevptr != (PLISTPTR) NULL ) {
+ 		prevptr->pnext = plptr->pnext ;
+ 		free( plptr ) ;
+ 	    } else if( plptr->pnext != (PLISTPTR) NULL ) {
+ 		l->plist = plptr->pnext ;
+ 		free( plptr ) ;
+ 	    } else {
+ 		free( plptr ) ;
+ 		f = l->father ;
+ 		if( f->nsons == 3 ) {
+ 		    if( f->son1 == l ) {
+ 			f->son1 = f->son2 ;
+ 			f->son2 = f->son3 ;
+ 			f->son3 = (TNODEPTR) NULL ;
+ 			f->Lval = f->son1->value ;
+ 			f->Mval = f->son2->value ;
+ 		    } else if( f->son2 == l ) {
+ 			f->son2 = f->son3 ;
+ 			f->son3 = (TNODEPTR) NULL ;
+ 			f->Mval = f->son2->value ;
+ 		    } else {
+ 			f->son3 = (TNODEPTR) NULL ;
+ 			tpatch( f , value ) ;
+ 		    }
+ 		    free( l ) ;
+ 		    f->nsons = 2 ;
+ 		} else {
+ 		    if( f == *root ) {
+ 			if( (*root)->son1 == l ) {
+ 			    (*root)->value = (*root)->son2->value ;
+ 			    (*root)->plist = (*root)->son2->plist ;
+ 			} else {
+ 			    (*root)->value = (*root)->son1->value ;
+ 			    (*root)->plist = (*root)->son1->plist  ;
+ 			}
+ 			free( (*root)->son1 ) ;
+ 			free( (*root)->son2 ) ;
+ 			(*root)->son1 = (TNODEPTR) NULL ;
+ 			(*root)->son2 = (TNODEPTR) NULL ;
+ 			(*root)->nsons = 0 ;
+ 		    } else {
+ 			if( f->son1 == l ) {
+ 			    s = f->son2 ;
+ 			} else {
+ 			    s = f->son1 ;
+ 			}
+ 			if( f->father->son1 == f ) {
+ 			    g = f->father->son2 ;
+ 			    if( f->father->nsons == 2 ) {
+ 				if( g->nsons == 2 ) {
+ 				    g->nsons = 3 ;
+ 				    g->son3 = g->son2 ;
+ 				    g->son2 = g->son1 ;
+ 				    g->son1 = s ;
+ 				    s->father = g ;
+ 				    free( l ) ;
+ 				    g->Lval = s->value ;
+ 				    g->Mval = g->son2->value ;
+ 				    tsubson( root , f ) ;
+ 				} else {
+ 				    g->nsons = 2 ;
+ 				    f->son1 = s ;
+ 				    f->son2 = g->son1 ;
+ 				    g->son1 = g->son2 ;
+ 				    g->son2 = g->son3 ;
+ 				    f->son2->father = f ;
+ 				    g->son3 = (TNODEPTR) NULL ;
+ 				    f->Lval = s->value ;
+ 				    f->Mval = f->son2->value ;
+ 				    g->Lval = g->son1->value ;
+ 				    g->Mval = g->son2->value ;
+ 				    g->father->Lval = f->Mval ;
+ 				    free( l ) ;
+ 				}
+ 			    } else {
+ 				if( g->nsons == 2 ) {
+ 				    g->nsons = 3 ;
+ 				    g->son3 = g->son2 ;
+ 				    g->son2 = g->son1 ;
+ 				    g->son1 = s ;
+ 				    s->father = g ;
+ 				    free( l ) ;
+ 				    g->Lval = s->value ;
+ 				    g->Mval = g->son2->value ;
+ 				    f->father->son1 = f->father->son2 ;
+ 				    f->father->son2 = f->father->son3 ;
+ 				    f->father->son3 = (TNODEPTR) NULL ;
+ 				    f->father->nsons = 2 ;
+ 				    f->father->Lval = f->father->Mval ;
+ 				    if( f->father->son2->nsons == 2 ) {
+ 					f->father->Mval = 
+ 						f->father->son2->Mval ;
+ 				    } else {
+ 					f->father->Mval =
+ 					 f->father->son2->son3->value ;
+ 				    }
+ 				    free( f ) ;
+ 				} else {
+ 				    g->nsons = 2 ;
+ 				    f->son1 = s ;
+ 				    f->son2 = g->son1 ;
+ 				    g->son1 = g->son2 ;
+ 				    g->son2 = g->son3 ;
+ 				    f->son2->father = f ;
+ 				    g->son3 = (TNODEPTR) NULL ;
+ 				    f->Lval = s->value ;
+ 				    f->Mval = f->son2->value ;
+ 				    g->Lval = g->son1->value ;
+ 				    g->Mval = g->son2->value ;
+ 				    g->father->Lval = f->Mval ;
+ 				    free( l ) ;
+ 				}
+ 			    }
+ 			} else if( f->father->son2 == f ) {
+ 			    if( f->father->nsons == 2 ) {
+ 				g = f->father->son1 ;
+ 				if( g->nsons == 2 ) {
+ 				    g->nsons = 3 ;
+ 				    g->son3 = s ;
+ 				    s->father = g ;
+ 				    free( l ) ;
+ 				    f->father->Lval = s->value ;
+ 				    tsubson( root , f ) ;
+ 				} else {
+ 				    g->nsons = 2 ;
+ 				    f->son1 = g->son3 ;
+ 				    f->son2 = s ;
+ 				    f->son1->father = f ;
+ 				    g->son3 = (TNODEPTR) NULL ;
+ 				    f->Lval = f->son1->value ;
+ 				    f->Mval = s->value ;
+ 				    f->father->Lval = g->Mval ;
+ 				    f->father->Mval = f->Mval ;
+ 				    tpatch( f->father , f->Mval ) ;
+ 				    free( l ) ;
+ 				}
+ 			    } else {
+ 				g = f->father->son3 ;
+ 				if( g->nsons == 2 ) {
+ 				    g->nsons = 3 ;
+ 				    g->son3 = g->son2 ;
+ 				    g->son2 = g->son1 ;
+ 				    g->son1 = s ;
+ 				    s->father = g ;
+ 				    free( l ) ;
+ 				    g->Lval = s->value ;
+ 				    g->Mval = g->son2->value ;
+ 				    g->father->Mval = g->son3->value ;
+ 				    free( f ) ;
+ 				    g->father->son2 = g->father->son3 ;
+ 				    g->father->son3 = (TNODEPTR) NULL ;
+ 				    g->father->nsons = 2 ;
+ 				} else {
+ 				    g->nsons = 2 ;
+ 				    f->son1 = s ;
+ 				    f->son2 = g->son1 ;
+ 				    f->son2->father = f ;
+ 				    g->son1 = g->son2 ;
+ 				    g->son2 = g->son3 ;
+ 				    g->son3 = (TNODEPTR) NULL ;
+ 				    g->Lval = g->son1->value ;
+ 				    g->Mval = g->son2->value ;
+ 				    f->Lval = f->son1->value ;
+ 				    f->Mval = f->son2->value ;
+ 				    f->father->Mval = f->Mval ;
+ 				    free( l ) ;
+ 				}
+ 			    }
+ 			} else {
+ 			    g = f->father->son2 ;
+ 			    if( g->nsons == 2 ) {
+ 				g->nsons = 3 ;
+ 				g->son3 = s ;
+ 				s->father = g ;
+ 				free( l ) ;
+ 				g->father->Mval = s->value ;
+ 				tpatch( g->father , s->value ) ;
+ 				g->father->son3 = (TNODEPTR) NULL ;
+ 				g->father->nsons = 2 ;
+ 				free( f ) ;
+ 			    } else {
+ 				g->nsons = 2 ;
+ 				f->son1 = g->son3 ;
+ 				f->son2 = s ;
+ 				f->son1->father = f ;
+ 				g->son3 = (TNODEPTR) NULL ;
+ 				f->Lval = f->son1->value ;
+ 				f->Mval = s->value ;
+ 				g->father->Mval = g->Mval ;
+ 				tpatch( f->father , s->value ) ;
+ 				free( l ) ;
+ 			    }
+ 			}
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return ;
+ }
+ 
+ 
+ void tsubson( TNODEPTR *root , TNODEPTR l )
+ {
+ 
+ TNODEPTR f , s , g ;
+ int LMval ;
+ 
+ f = l->father ;
+ if( f == *root ) {
+     if( (*root)->son1 == l ) {
+ 	s = (*root)->son2 ;
+     } else {
+ 	s = (*root)->son1 ;
+     }
+     s->father = (TNODEPTR) NULL ;
+     free( l ) ;
+     free( *root ) ;
+     *root = s ;
+ } else {
+     if( f->son1 == l ) {
+ 	s = f->son2 ;
+ 	LMval = f->Mval ;
+     } else {
+ 	s = f->son1 ;
+ 	LMval = f->Lval ;
+     }
+     if( f->father->son1 == f ) {
+ 	g = f->father->son2 ;
+ 	if( f->father->nsons == 2 ) {
+ 	    if( g->nsons == 2 ) {
+ 		g->nsons = 3 ;
+ 		g->son3 = g->son2 ;
+ 		g->son2 = g->son1 ;
+ 		g->son1 = s ;
+ 		s->father = g ;
+ 		free( l ) ;
+ 		g->Mval = g->Lval ;
+ 		g->Lval = LMval ;
+ 		tsubson( root , f ) ;
+ 	    } else {
+ 		g->nsons = 2 ;
+ 		f->son1 = s ;
+ 		f->son2 = g->son1 ;
+ 		g->son1 = g->son2 ;
+ 		g->son2 = g->son3 ;
+ 		f->son2->father = f ;
+ 		g->son3 = (TNODEPTR) NULL ;
+ 		f->Lval = LMval ;
+ 		f->Mval = g->Lval ;
+ 		g->Lval = g->Mval ;
+ 		g->Mval = g->father->Mval ;
+ 		g->father->Lval = f->Mval ;
+ 		free( l ) ;
+ 	    }
+ 	} else {
+ 	    if( g->nsons == 2 ) {
+ 		g->nsons = 3 ;
+ 		g->son3 = g->son2 ;
+ 		g->son2 = g->son1 ;
+ 		g->son1 = s ;
+ 		s->father = g ;
+ 		free( l ) ;
+ 		g->Mval = g->Lval ;
+ 		g->Lval = LMval ;
+ 		f->father->son1 = f->father->son2 ;
+ 		f->father->son2 = f->father->son3 ;
+ 		f->father->son3 = (TNODEPTR) NULL ;
+ 		f->father->nsons = 2 ;
+ 		f->father->Lval = f->father->Mval ;
+ 		free( f ) ;
+ 		f = g->father->son2 ;
+ 		while( f->nsons == 3 ) {
+ 		    f = f->son3 ;
+ 		}
+ 		if( f->nsons == 0 ) {
+ 		    g->father->Mval = f->value ;
+ 		} else {
+ 		    g->father->Mval = f->Mval ;
+ 		}
+ 	    } else {
+ 		g->nsons = 2 ;
+ 		f->son1 = s ;
+ 		f->son2 = g->son1 ;
+ 		g->son1 = g->son2 ;
+ 		g->son2 = g->son3 ;
+ 		f->son2->father = f ;
+ 		g->son3 = (TNODEPTR) NULL ;
+ 		f->Lval = LMval ;
+ 		f->Mval = g->Lval ;
+ 		g->Lval = g->Mval ;
+ 		g->Mval = g->father->Mval ;
+ 		g->father->Lval = f->Mval ;
+ 		free( l ) ;
+ 	    }
+ 	}
+     } else if( f->father->son2 == f ) {
+ 	if( f->father->nsons == 2 ) {
+ 	    g = f->father->son1 ;
+ 	    if( g->nsons == 2 ) {
+ 		g->nsons = 3 ;
+ 		g->son3 = s ;
+ 		s->father = g ;
+ 		free( l ) ;
+ 		f->father->Lval = LMval ;
+ 		tsubson( root , f ) ;
+ 	    } else {
+ 		g->nsons = 2 ;
+ 		f->son1 = g->son3 ;
+ 		f->son2 = s ;
+ 		f->son1->father = f ;
+ 		g->son3 = (TNODEPTR) NULL ;
+ 		f->Lval = g->father->Lval ;
+ 		f->Mval = LMval ;
+ 		g->father->Lval = g->Mval ;
+ 		g->father->Mval = LMval ;
+ 		tpatch( f->father , f->Mval ) ;
+ 		free( l ) ;
+ 	    }
+ 	} else {
+ 	    g = f->father->son3 ;
+ 	    if( g->nsons == 2 ) {
+ 		g->nsons = 3 ;
+ 		g->son3 = g->son2 ;
+ 		g->son2 = g->son1 ;
+ 		g->son1 = s ;
+ 		s->father = g ;
+ 		free( l ) ;
+ 		g->father->Mval = g->Mval ;
+ 		g->Mval = g->Lval ;
+ 		g->Lval = LMval ;
+ 		free( f ) ;
+ 		g->father->son2 = g->father->son3 ;
+ 		g->father->son3 = (TNODEPTR) NULL ;
+ 		g->father->nsons = 2 ;
+ 	    } else {
+ 		g->nsons = 2 ;
+ 		f->son1 = s ;
+ 		f->son2 = g->son1 ;
+ 		f->son2->father = f ;
+ 		g->son1 = g->son2 ;
+ 		g->son2 = g->son3 ;
+ 		g->son3 = (TNODEPTR) NULL ;
+ 		f->Lval = LMval ;
+ 		f->Mval = g->Lval ;
+ 		g->Lval = g->Mval ;
+ 		g->father->Mval = f->Mval ;
+ 		f = g->son2 ;
+ 		while( f->nsons == 3 ) {
+ 		    f = f->son3 ;
+ 		}
+ 		if( f->nsons == 0 ) {
+ 		    g->Mval = f->value ;
+ 		} else {
+ 		    g->Mval = f->Mval ;
+ 		}
+ 		free( l ) ;
+ 	    }
+ 	}
+     } else {
+ 	g = f->father->son2 ;
+ 	if( g->nsons == 2 ) {
+ 	    g->nsons = 3 ;
+ 	    g->son3 = s ;
+ 	    s->father = g ;
+ 	    free( l ) ;
+ 	    g->father->Mval = LMval ;
+ 	    tpatch( g->father , LMval ) ;
+ 	    g->father->son3 = (TNODEPTR) NULL ;
+ 	    g->father->nsons = 2 ;
+ 	    free( f ) ;
+ 	} else {
+ 	    g->nsons = 2 ;
+ 	    f->son1 = g->son3 ;
+ 	    f->son2 = s ;
+ 	    f->son1->father = f ;
+ 	    g->son3 = (TNODEPTR) NULL ;
+ 	    f->Lval = g->father->Mval ;
+ 	    f->Mval = LMval ;
+ 	    g->father->Mval = g->Mval ;
+ 	    tpatch( f->father , LMval ) ;
+ 	    free( l ) ;
+ 	}
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ TNODEPTR tdsearch( int value , TNODEPTR r )
+ {
+ 
+ if( r == (TNODEPTR) NULL ) {
+     return( (TNODEPTR) NULL ) ;
+ } else if( r->nsons == 0 ) {
+     return( r ) ;
+ } else {
+     if( value <= r->Lval ) {
+ 	return( tdsearch( value , r->son1 ) ) ;
+     } else if( value <= r->Mval ) { 
+ 	return( tdsearch( value , r->son2 ) ) ;
+     } else {
+ 	return( tdsearch( value , r->son3 ) ) ;
+     }
+ }
+ }
+ 
+ 
+ TNODEPTR tfind( int value , TNODEPTR r )
+ {
+ 
+ if( r->son1->value == value ) {
+     return( r->son1 ) ;
+ } else if( r->son2->value == value ) {
+     return( r->son2 ) ;
+ } else if( r->nsons == 3 ) {
+     if( r->son3->value == value ) {
+ 	return( r->son3 ) ;
+     }
+ } 
+ return( (TNODEPTR) NULL ) ;
+ }
+ 
+ 
+ 
+ void makenode( TNODEPTR *v , int value , int property )
+ {
+ *v = (TNODEPTR) malloc( sizeof( TNODE ) ) ;
+ (*v)->son1 = (TNODEPTR) NULL ;
+ (*v)->son2 = (TNODEPTR) NULL ;
+ (*v)->son3 = (TNODEPTR) NULL ;
+ (*v)->son4 = (TNODEPTR) NULL ;
+ (*v)->value = value ;
+ (*v)->nsons = 0 ;
+ (*v)->plist = (PLISTPTR) malloc( sizeof( PLIST ) ) ;
+ (*v)->plist->property = property ;
+ (*v)->plist->pnext = (PLISTPTR) NULL ;
+ 
+ return ;
+ }
+ 
+ 
+ 
+ void addplist( TNODEPTR v , int property ) 
+ {
+ 
+ PLISTPTR plptr ;
+ 
+ plptr = (PLISTPTR) malloc( sizeof( PLIST ) ) ;
+ plptr->pnext = v->plist ;
+ v->plist = plptr ;
+ v->plist->property = property ;
+ 
+ return ;
+ }
+ 
+ 
+ 
+ PLISTPTR pfind( TNODEPTR v , int property , PLISTPTR *prevptr ) 
+ {
+ 
+ PLISTPTR plptr ;
+ 
+ *prevptr = (PLISTPTR) NULL ;
+ plptr = v->plist ;
+ while( plptr != (PLISTPTR) NULL ) {
+     if( plptr->property == property ) {
+ 	return( plptr ) ;
+     }
+     *prevptr = plptr ;
+     plptr = plptr->pnext ;
+ }
+ 
+ return( (PLISTPTR) NULL ) ;
+ }
+ 
+ 
+ 
+ int tprop( TNODEPTR r , int value )
+ {
+ 
+ TNODEPTR v , f ;
+ 
+ if( r == (TNODEPTR) NULL ) {
+     return( -1 ) ;
+ } else if( r->nsons == 0 ) {
+     if( r->value == value ) {
+ 	return( r->plist->property ) ;
+     } else {
+ 	return( -1 ) ;
+     }
+ } else {
+     f = tsearch( value , r ) ;
+     if( f == (TNODEPTR) NULL ) {
+ 	return( -1 ) ;
+     } else {
+ 	v = tfind( value , f ) ;
+ 	if( v == (TNODEPTR) NULL ) {
+ 	    return( -1 ) ;
+ 	} else {
+ 	    return( v->plist->property ) ;
+ 	}
+     }
+ }
+ }
+ 
+ 
+ 
+ PLISTPTR tplist( TNODEPTR r , int value )
+ {
+ 
+ TNODEPTR v , f ;
+ 
+ if( r == (TNODEPTR) NULL ) {
+     return( (PLISTPTR) NULL ) ;
+ } else if( r->nsons == 0 ) {
+     if( r->value == value ) {
+ 	return( r->plist ) ;
+     } else {
+ 	return( (PLISTPTR) NULL ) ;
+     }
+ } else {
+     f = tsearch( value , r ) ;
+     if( f == (TNODEPTR) NULL ) {
+ 	return( (PLISTPTR) NULL ) ;
+     } else {
+ 	v = tfind( value , f ) ;
+ 	if( v == (TNODEPTR) NULL ) {
+ 	    return( (PLISTPTR) NULL ) ;
+ 	} else {
+ 	    return( v->plist ) ;
+ 	}
+     }
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.h:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/23tree.h	Tue Oct  5 16:19:41 2004
***************
*** 0 ****
--- 1,29 ----
+ #include "port.h"
+ 
+ typedef struct plist {
+     int property ;
+     struct plist *pnext  ;
+ } 
+ PLIST, *PLISTPTR ;
+ 
+ typedef struct tnode {
+     int value ;
+     int nsons ;
+     struct tnode *son1  ;
+     struct tnode *son2  ;
+     struct tnode *son3  ;
+     struct tnode *son4  ;
+     struct tnode *father;
+     int Lval  ;
+     int Mval  ;
+     PLISTPTR plist ;
+ } 
+ TNODE, *TNODEPTR ;
+ 
+ #define RAND ((randVar = randVar * 1103515245 + 12345) & 0x7fffffff)
+ 
+ TNODEPTR tsearch() ;
+ TNODEPTR tdsearch() ;
+ TNODEPTR tfind() ;
+ PLISTPTR pfind() ;
+ PLISTPTR tplist() ;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/Makefile
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/Makefile:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/Makefile	Tue Oct  5 16:19:41 2004
***************
*** 0 ****
--- 1,6 ----
+ LEVEL = ../../../..
+ 
+ PROG = timberwolfmc
+ LDFLAGS=-lm
+ include $(LEVEL)/MultiSource/Makefile.multisrc
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/addpins.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/addpins.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/addpins.c	Tue Oct  5 16:19:41 2004
***************
*** 0 ****
--- 1,134 ----
+ #include "custom.h"
+ extern double Hdefault ;
+ extern double Vdefault ;
+ 
+ void addpins(void)
+ {
+ 
+ int i , extraNets , cell , pin ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr , term ;
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ 
+ 
+ extraNets = numcells ;
+ 
+ netarray = (DIMBOXPTR *) realloc( netarray , (numnets + extraNets + 1) * 
+ 						sizeof(DIMBOXPTR));
+ for( i = 1 + numnets ; i <= numnets + extraNets ; i++ ) {
+     dimptr = netarray[i] = (DIMBOXPTR) malloc( sizeof( DIMBOX ) ) ;
+     dimptr->netptr  = NETNULL ;
+     dimptr->nname   = NULL    ;
+     dimptr->skip    = 0       ;
+     dimptr->flag    = 0       ;
+     dimptr->xmin    = 0       ;
+     dimptr->newxmin = 0       ;
+     dimptr->xmax    = 0       ;
+     dimptr->newxmax = 0       ;
+     dimptr->ymin    = 0       ;
+     dimptr->newymin = 0       ;
+     dimptr->ymax    = 0       ;
+     dimptr->newymax = 0       ;
+     dimptr->Hweight = Hdefault ;
+     dimptr->Vweight = Vdefault ;
+ }
+ pinnames = (char **) realloc( pinnames, 
+ 		    (maxterm + 2 * extraNets + 1) * sizeof(char *) );
+ for( pin = 1 + maxterm ; pin <= maxterm + 2 * extraNets ; pin++ ) {
+     pinnames[pin] = (char *) malloc( 9 * sizeof(char) ) ;
+     sprintf( pinnames[pin] , "PHANTOM" ) ;
+ }
+ 
+ termarray = (TERMNETSPTR *) realloc( termarray , 
+ 		(maxterm + 2 * extraNets + 1) * sizeof(TERMNETSPTR) );
+ for( pin = 1 + maxterm ; pin <= maxterm + 2 * extraNets ; pin++ ) {
+     termarray[pin] = (TERMNETSPTR) malloc( sizeof(TERMNETS) ) ;
+ }
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     tileptr = cellptr->config[cellptr->orient] ;
+     termptr = tileptr->termptr ;
+     term = tileptr->termptr = (TERMBOXPTR) malloc( sizeof(TERMBOX) ) ;
+     term->nextterm = termptr ;
+     term->xpos = 0 ;
+     term->ypos = 0 ;
+     term->terminal = maxterm + 2 * cell - 1 ;
+ 
+     netptr = netarray[numnets + cell]->netptr = 
+ 				(NETBOXPTR) malloc( sizeof(NETBOX) );
+     netptr->terminal = maxterm + 2 * cell - 1 ;
+     netptr->cell = cell ;
+     netptr->flag = 0 ;
+     netptr->skip = 0 ;
+     netptr->xpos = cellptr->xcenter ;
+     netptr->ypos = cellptr->ycenter ;
+     termarray[netptr->terminal]->net = numnets + cell ;
+     termarray[netptr->terminal]->termptr = netptr ;
+ 
+     netptr = netptr->nextterm = (NETBOXPTR) malloc( sizeof(NETBOX) );
+     netptr->terminal = maxterm + 2 * cell ;
+     netptr->cell = cell ;
+     netptr->flag = 0 ;
+     netptr->skip = 0 ;
+     netptr->xpos = (blockl + blockr) / 2 ;
+     netptr->ypos = (blockb + blockt) / 2 ;
+     netptr->nextterm = NETNULL ;
+     termarray[netptr->terminal]->net = numnets + cell ;
+     termarray[netptr->terminal]->termptr = netptr ;
+ }
+ 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ 
+ void subpins(void)
+ {
+ 
+ int i , extraNets , cell , pin ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr , term ;
+ DIMBOXPTR dimptr ;
+ 
+ 
+ extraNets = numcells ;
+ 
+ for( i = 1 + numnets ; i <= numnets + extraNets ; i++ ) {
+     dimptr = netarray[i] ;
+     free( dimptr->netptr->nextterm ) ;
+     free( dimptr->netptr ) ;
+     dimptr->netptr  = NETNULL ;
+     dimptr->nname   = NULL    ;
+     dimptr->skip    = 0       ;
+     dimptr->flag    = 0       ;
+     dimptr->xmin    = 0       ;
+     dimptr->newxmin = 0       ;
+     dimptr->xmax    = 0       ;
+     dimptr->newxmax = 0       ;
+     dimptr->ymin    = 0       ;
+     dimptr->newymin = 0       ;
+     dimptr->ymax    = 0       ;
+     dimptr->newymax = 0       ;
+ }
+ 
+ for( pin = 1 + maxterm ; pin <= maxterm + 2 * extraNets ; pin++ ) {
+     termarray[pin] = (TERMNETSPTR) NULL ;
+ }
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     tileptr = cellptr->config[cellptr->orient] ;
+     termptr = tileptr->termptr ;
+     term = termptr->nextterm ;
+     tileptr->termptr = term ;
+     free( termptr ) ;
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/analyze.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/analyze.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/analyze.c	Tue Oct  5 16:19:41 2004
***************
*** 0 ****
--- 1,340 ----
+ #include "custom.h"
+ #include "23tree.h"
+ int *how_many;
+ 
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ extern double wireratio( int numofcells, double cellspernet, double netsperd,
+ 			double dnetspercell );
+ 
+ void qsortx(char *base, int n, int size);
+ void qst(char *base, char *max);
+ 
+ double analyze(void)
+ {
+ 
+ int **number , i , net , net1 , net2 , num , cell ;
+ int *count , different , cnum , c2num , *arraynet ;
+ int num_nets , tot_cels ;
+ double C , C1 , ratio ;
+ #ifdef notdef
+ double C2 , C3;
+ #endif
+ NETBOXPTR netptr ;
+ 
+ 
+ 
+ count  = (int *) malloc( (1 + numcells) * sizeof( int ) ) ;
+ number = (int **) malloc( (1 + numnets) * sizeof( int *) ) ;
+ how_many = (int *) malloc( (1 + numnets) * sizeof( int ) ) ;
+ arraynet = (int *) malloc( (1 + numnets) * sizeof( int ) ) ;
+ for( net = 0 ; net <= numnets ; net++ ) {
+     number[net] = (int *) malloc( (1 + numcells) * sizeof(int) ) ;
+ }
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     for( cell = 0 ; cell <= numcells ; cell++ ) {
+ 	count[cell] = 0 ;
+ 	number[net][cell] = 0 ;
+     }
+     netptr = netarray[net]->netptr ;
+     for( ; netptr != (NETBOXPTR) NULL ; netptr = netptr->nextterm ){
+ 	if( netptr->cell <= numcells ) {
+ 	    count[netptr->cell] = 1 ;
+ 	}
+     }
+     /*
+      *  I would like to find the number of distinct nets
+      */
+     for( cell = 1 ; cell <= numcells ; cell++ ) { 
+ 	if( count[cell] == 1 ) {
+ 	    number[net][ ++number[net][0] ] = cell ;
+ 	}
+     }
+ }
+ /* ********************************************************** */
+ num_nets = 0 ;
+ tot_cels = 0 ;
+ for( net1 = 1 ; net1 <= numnets ; net1++ ) {
+     if( number[net1][0] <= 1 ) {
+ 	continue ;
+     }
+     num_nets++ ;
+     tot_cels += number[net1][0] ;
+ }
+ 
+ 
+ fprintf(fpo,"\n\n*************************************\n");
+ fprintf(fpo,"AVERAGE NUMBER OF CELLS PER NET: %f\n",
+ 		(double) tot_cels / (double) num_nets	) ;
+ fprintf(fpo,"*************************************\n\n\n");
+ /* ********************************************************** */
+ for( net1 = 1 ; net1 <= numnets ; net1++ ) {
+     if( number[net1][0] == 0 ) {
+ 	how_many[net1] = 0 ;
+ 	continue ;
+     }
+     if( number[net1][0] == 1 ) {
+ 	number[net1][0] = 0 ;
+ 	how_many[net1] = 0 ;
+ 	continue ;
+     }
+     how_many[net1] = 1 ;
+     for( net2 = net1 + 1 ; net2 <= numnets ; net2++ ) {
+ 	if( number[net2][0] != number[net1][0] ) {
+ 	    continue ;
+ 	}
+ 	different = 0 ;
+ 	for( i = 1 ; i <= numcells ; i++ ) {
+ 	    if( number[net2][i] != number[net1][i] ) {
+ 		different = 1 ;
+ 		break ;
+ 	    }
+ 	}
+ 	if( ! different ) {
+ 	    number[net2][0] = 0 ;
+ 	    how_many[net1]++ ;
+ 	}
+     }
+ }
+ 
+ arraynet[0] = 0 ;
+ for( net = 1 ; net <= numnets ; net++ ) {
+     if( how_many[net] <= 0 ) {
+ 	continue ;
+     }
+     arraynet[ ++arraynet[0] ] = net ;
+ }
+ num = arraynet[0] ;
+ arraynet[0] = arraynet[ arraynet[0] ] ;
+ qsortx( (char *) arraynet ,  num , sizeof( int ) ) ;
+ /*  sorted: most occurrences first  */
+ 
+ num = 0 ;
+ cnum = 0 ;
+ c2num = 0 ;
+ for( net = 1 ; net <= numnets ; net++ ) {
+     if( number[net][0] > 0 ) {
+ 	cnum += number[net][0] - 1 ;
+ 	c2num += number[net][0] ;
+ 	num++ ;
+     }
+ }
+ C = (double) num / (double) numcells ;
+ C1 = (double) cnum / (double) num ;
+ 
+ #ifdef notdef
+ C2 = (double) c2num / (double) num ;
+ C3 = (double) cnum / (double)(numcells - 1) ;
+ 
+ fprintf(fpo,"\n\n\n**********************************************\n\n");
+ fprintf(fpo,"The average number of distinct nets per cell is\n");
+ fprintf(fpo,"given by: %6.2f\n\n", C );
+ fprintf(fpo,"The average number of cells per net is\n");
+ fprintf(fpo,"given by: %6.2f\n\n", C2 );
+ fprintf(fpo,"The average number of other cells per net is\n");
+ fprintf(fpo,"given by: %6.2f\n\n", C1 );
+ fprintf(fpo,"The ratio of total cells specified per net to\n");
+ fprintf(fpo,"numcells is given by: %6.2f\n\n", C3 );
+ fprintf(fpo,"The average number of cells connected to a cell is\n");
+ fprintf(fpo,"given by: %6.2f\n\n", C * C1 );
+ fprintf(fpo,"**********************************************\n\n\n");
+ #endif
+ 
+ ratio = wireratio( numcells, C1, 
+ 		((double) numnets / (double) numcells) / C , C ) ;
+ 
+ fprintf(fpo,"Expected Wire Reduction Relative to Random:%6.2f\n\n",ratio);
+ fflush(fpo);
+ 
+ return( ratio );
+ }
+ 
+ 
+ 
+ 
+ 
+ int comparex( int *a , int *b )
+ {
+     return( how_many[*b] - how_many[*a] ) ;
+ }
+ 
+ 
+ /* @(#)qsort.c	4.2 (Berkeley) 3/9/83 */
+ 
+ 
+ #define		THRESH		4	/* threshold for insertion */
+ #define		MTHRESH		6	/* threshold for median */
+ 
+ int	qsz;			/* size of each record */
+ int	thresh;			/* THRESHold in chars */
+ int	mthresh;		/* MTHRESHold in chars */
+ 
+ 
+ void qsortx(char *base, int n, int size)
+ {
+ 	register char c, *i, *j, *lo, *hi;
+ 	char *min, *max;
+ 
+ 	if (n <= 1)
+ 		return;
+ 	qsz = size;
+ 	thresh = qsz * THRESH;
+ 	mthresh = qsz * MTHRESH;
+ 	max = base + n * qsz;
+ 	if (n >= THRESH) {
+ 		qst(base, max);
+ 		hi = base + thresh;
+ 	} else {
+ 		hi = max;
+ 	}
+ 	/*
+ 	 * First put smallest element, which must be in the first THRESH, in
+ 	 * the first position as a sentinel.  This is done just by searching
+ 	 * the first THRESH elements (or the first n if n < THRESH), finding
+ 	 * the min, and swapping it into the first position.
+ 	 */
+ 	for (j = lo = base; (lo += qsz) < hi; )
+ 		if (comparex(j, lo) > 0)
+ 			j = lo;
+ 	if (j != base) {
+ 		/* swap j into place */
+ 		for (i = base, hi = base + qsz; i < hi; ) {
+ 			c = *j;
+ 			*j++ = *i;
+ 			*i++ = c;
+ 		}
+ 	}
+ 	/*
+ 	 * With our sentinel in place, we now run the following hyper-fast
+ 	 * insertion sort.  For each remaining element, min, from [1] to [n-1],
+ 	 * set hi to the index of the element AFTER which this one goes.
+ 	 * Then, do the standard insertion sort shift on a character at a time
+ 	 * basis for each element in the frob.
+ 	 */
+ 	for (min = base; (hi = min += qsz) < max; ) {
+ 		while (comparex(hi -= qsz, min) > 0)
+ 			/* void */;
+ 		if ((hi += qsz) != min) {
+ 			for (lo = min + qsz; --lo >= min; ) {
+ 				c = *lo;
+ 				for (i = j = lo; (j -= qsz) >= hi; i = j)
+ 					*i = *j;
+ 				*i = c;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ /*
+  * qst:
+  * Do a quicksort
+  * First, find the median element, and put that one in the first place as the
+  * discriminator.  (This "median" is just the median of the first, last and
+  * middle elements).  (Using this median instead of the first element is a big
+  * win).  Then, the usual partitioning/swapping, followed by moving the
+  * discriminator into the right place.  Then, figure out the sizes of the two
+  * partions, do the smaller one recursively and the larger one via a repeat of
+  * this code.  Stopping when there are less than THRESH elements in a partition
+  * and cleaning up with an insertion sort (in our caller) is a huge win.
+  * All data swaps are done in-line, which is space-losing but time-saving.
+  * (And there are only three places where this is done).
+  */
+ 
+ void qst(char *base, char *max)
+ {
+ 	register char c, *i, *j, *jj;
+ 	register int ii;
+ 	char *mid, *tmp;
+ 	int lo, hi;
+ 
+ 	/*
+ 	 * At the top here, lo is the number of characters of elements in the
+ 	 * current partition.  (Which should be max - base).
+ 	 * Find the median of the first, last, and middle element and make
+ 	 * that the middle element.  Set j to largest of first and middle.
+ 	 * If max is larger than that guy, then it's that guy, else compare
+ 	 * max with loser of first and take larger.  Things are set up to
+ 	 * prefer the middle, then the first in case of ties.
+ 	 */
+ 	lo = max - base;		/* number of elements as chars */
+ 	do	{
+ 		mid = i = base + qsz * ((lo / qsz) >> 1);
+ 		if (lo >= mthresh) {
+ 			j = (comparex((jj = base), i) > 0 ? jj : i);
+ 			if (comparex(j, (tmp = max - qsz)) > 0) {
+ 				/* switch to first loser */
+ 				j = (j == jj ? i : jj);
+ 				if (comparex(j, tmp) < 0)
+ 					j = tmp;
+ 			}
+ 			if (j != i) {
+ 				ii = qsz;
+ 				do	{
+ 					c = *i;
+ 					*i++ = *j;
+ 					*j++ = c;
+ 				} while (--ii);
+ 			}
+ 		}
+ 		/*
+ 		 * Semi-standard quicksort partitioning/swapping
+ 		 */
+ 		for (i = base, j = max - qsz; ; ) {
+ 			while (i < mid && comparex(i, mid) <= 0)
+ 				i += qsz;
+ 			while (j > mid) {
+ 				if (comparex(mid, j) <= 0) {
+ 					j -= qsz;
+ 					continue;
+ 				}
+ 				tmp = i + qsz;	/* value of i after swap */
+ 				if (i == mid) {
+ 					/* j <-> mid, new mid is j */
+ 					mid = jj = j;
+ 				} else {
+ 					/* i <-> j */
+ 					jj = j;
+ 					j -= qsz;
+ 				}
+ 				goto swap;
+ 			}
+ 			if (i == mid) {
+ 				break;
+ 			} else {
+ 				/* i <-> mid, new mid is i */
+ 				jj = mid;
+ 				tmp = mid = i;	/* value of i after swap */
+ 				j -= qsz;
+ 			}
+ 		swap:
+ 			ii = qsz;
+ 			do	{
+ 				c = *i;
+ 				*i++ = *jj;
+ 				*jj++ = c;
+ 			} while (--ii);
+ 			i = tmp;
+ 		}
+ 		/*
+ 		 * Look at sizes of the two partitions, do the smaller
+ 		 * one first by recursion, then do the larger one by
+ 		 * making sure lo is its size, base and max are update
+ 		 * correctly, and branching back.  But only repeat
+ 		 * (recursively or by branching) if the partition is
+ 		 * of at least size THRESH.
+ 		 */
+ 		i = (j = mid) + qsz;
+ 		if ((lo = j - base) <= (hi = max - i)) {
+ 			if (lo >= thresh)
+ 				qst(base, j);
+ 			base = i;
+ 			lo = hi;
+ 		} else {
+ 			if (hi >= thresh)
+ 				qst(i, max);
+ 			max = j;
+ 		}
+ 	} while (lo >= thresh);
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/bellman.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/bellman.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/bellman.c	Tue Oct  5 16:19:42 2004
***************
*** 0 ****
--- 1,57 ----
+ #include "geo.h"
+ #define DEBUG
+ extern FILE *fpo ;
+ 
+ void bellman(void)
+ {
+ 
+ int i , j , D , distance ;
+ WCPTR ptr ;
+ 
+ xBellArray = (BELLBOXPTR) malloc((1 + numXnodes) * sizeof(BELLBOX));
+ yBellArray = (BELLBOXPTR) malloc((1 + numYnodes) * sizeof(BELLBOX));
+ 
+ xBellArray[1].from     = 0 ;
+ xBellArray[1].distance = 0 ;
+ for( i = 2 ; i <= numXnodes ; i++ ) {
+     xBellArray[i].distance = VBIG ;
+ }
+ 
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     D = xBellArray[i].distance ;
+     for( ptr = xNodeArray[i]; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	j = ptr->node ;
+ 	distance = - (ptr->length) ;
+ 	if( xBellArray[j].distance > D + distance ) {
+ 	    xBellArray[j].distance = D + distance ;
+ 	    xBellArray[j].from = i ;
+ 	}
+     }
+ }
+ 
+ yBellArray[1].from     = 0 ;
+ yBellArray[1].distance = 0 ;
+ for( i = 2 ; i <= numYnodes ; i++ ) {
+     yBellArray[i].distance = VBIG ;
+ }
+ 
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     D = yBellArray[i].distance ;
+     for( ptr = yNodeArray[i]; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	j = ptr->node ;
+ 	distance = - (ptr->length) ;
+ 	if( yBellArray[j].distance > D + distance ) {
+ 	    yBellArray[j].distance = D + distance ;
+ 	    yBellArray[j].from = i ;
+ 	}
+     }
+ }
+ #ifdef DEBUG
+ fprintf(fpo,"Longest Hori. Path in Circuit Graph has span: <%d>\n",
+ 			    - xBellArray[numXnodes].distance ) ;
+ fprintf(fpo,"Longest Vert. Path in Circuit Graph has span: <%d>\n",
+ 			    - yBellArray[numYnodes].distance ) ;
+ #endif
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/buster.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/buster.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/buster.c	Tue Oct  5 16:19:42 2004
***************
*** 0 ****
--- 1,131 ----
+ #include "custom.h"
+ extern BUSTBOXPTR A , R ;
+ 
+ 
+ void buster(void)
+ {
+ 
+ int k , Pk[2] , Pl[2] , Pm[2]  ;
+ int xmin , ymin , kmin , found ;
+ 
+ 
+ /*  find Pk  */
+ ymin = 1000000000 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( A[k].yc < ymin ) {
+ 	ymin = A[k].yc ;
+     }
+ }  /* we have the lowest y coordinate  */
+ xmin = 1000000000 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( A[k].yc == ymin ) {
+ 	if( A[k].xc < xmin ) {
+ 	    xmin = A[k].xc ;
+ 	    kmin = k ;
+ 	}
+     }
+ }  /*  we have the leftmost lowest corner  */
+ Pk[0] = xmin ;
+ Pk[1] = ymin ;
+ xmin = 1000000000 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( k == kmin ) {
+ 	continue ;
+     }
+     if( A[k].yc == ymin ) {
+ 	if( A[k].xc < xmin ) {
+ 	    xmin = A[k].xc ;
+ 	}
+     }
+ }   /*  we have the next leftmost lowest corner  */
+ Pl[0] = xmin ;
+ Pl[1] = ymin ;
+ ymin = 1000000000 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( A[k].yc == Pk[1] ) {
+ 	continue ;
+     }
+     if( A[k].yc < ymin ) {
+ 	ymin = A[k].yc ;
+     }
+ }  /* we have the next lowest y coordinate  */
+ xmin = 1000000000 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( A[k].yc == ymin ) {
+ 	if( A[k].xc < Pk[0] || A[k].xc > Pl[0] ) {
+ 	    continue ;
+ 	}
+ 	if( A[k].xc < xmin ) {
+ 	    xmin = A[k].xc ;
+ 	}
+     }
+ }  /*  we have the leftmost next lowest corner  */
+ Pm[0] = xmin ;
+ Pm[1] = ymin ;
+ 
+ /*
+  *  According to the instruction sheet I read, we can
+  *  output the bounding rectangle of Pk , Pl , Pm.
+  */
+ R[1].xc = Pk[0] ;
+ R[1].yc = Pk[1] ;
+ R[2].xc = Pk[0] ;
+ R[2].yc = Pm[1] ;
+ R[3].xc = Pl[0] ;
+ R[3].yc = Pm[1] ;
+ R[4].xc = Pl[0] ;
+ R[4].yc = Pk[1] ;
+ 
+ /*  
+  *  Now weed out those elements of R which are in A and
+  *  add those elements of R which are not in A.
+  *  Note that index 1 and 4 are necessarily in A, and thus
+  *  have to be removed from A.
+  */
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( R[1].xc == A[k].xc && R[1].yc == A[k].yc ) {
+ 	A[k].xc = A[ A[0].xc ].xc ;
+ 	A[k].yc = A[ A[0].xc-- ].yc ;
+ 	break ;
+     }
+ }
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( R[4].xc == A[k].xc && R[4].yc == A[k].yc ) {
+ 	A[k].xc = A[ A[0].xc ].xc ;
+ 	A[k].yc = A[ A[0].xc-- ].yc ;
+ 	break ;
+     }
+ }
+ found = 0 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( R[2].xc == A[k].xc && R[2].yc == A[k].yc ) {
+ 	A[k].xc = A[ A[0].xc ].xc ;
+ 	A[k].yc = A[ A[0].xc-- ].yc ;
+ 	found = 1 ;
+ 	break ;
+     }
+ }
+ if( found == 0 ) {
+     /*
+      *  Add the thing to the list A
+      */
+     A[ ++A[0].xc ].xc = R[2].xc ;
+     A[ A[0].xc ].yc = R[2].yc ;
+ }
+ found = 0 ;
+ for( k = 1 ; k <= A[0].xc ; k++ ) {
+     if( R[3].xc == A[k].xc && R[3].yc == A[k].yc ) {
+ 	A[k].xc = A[ A[0].xc ].xc ;
+ 	A[k].yc = A[ A[0].xc-- ].yc ;
+ 	found = 1 ;
+ 	break ;
+     }
+ }
+ if( found == 0 ) {
+     /*
+      *  Add the thing to the list A
+      */
+     A[ ++A[0].xc ].xc = R[3].xc ;
+     A[ A[0].xc ].yc = R[3].yc ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/changraph.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/changraph.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/changraph.c	Tue Oct  5 16:19:42 2004
***************
*** 0 ****
--- 1,498 ----
+ #include "geo.h"
+ #define DEBUG
+ 
+ extern int tprop( TNODEPTR r , int value );
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void exploreUp(void);
+ void exploreRite(void);
+ int constructVedge( int index1 , int index2 );
+ int constructHedge( int index1 , int index2 );
+ 
+ void changraph(void)
+ {
+ #ifdef notdef
+ char filename[1024] ;
+ FILE *fp ;
+ #endif
+ int i , index1 , index2 , hiend , loend , length ;
+ 
+ vChanBeginRoot = (TNODEPTR) NULL ;
+ vChanEndRoot   = (TNODEPTR) NULL ;
+ hChanBeginRoot = (TNODEPTR) NULL ;
+ hChanEndRoot   = (TNODEPTR) NULL ;
+ eNum = 0 ;
+ eArray = (EBOXPTR) malloc( 100 * sizeof(EBOX) ) ;
+ 
+ /* XXX Ahh, Sechen code, lint torture testing */
+ /* exploreUp( HRlist , 0 , -1000000 ) ; */
+ exploreUp();
+ 
+ edgeTransition = eNum ;
+ 
+ /* exploreRite( VRlist , 0 , -1000000 ) ; */
+ exploreRite();
+ 
+ eIndexArray = (int **) malloc( (1 + numRects) * sizeof( int * ) ) ;
+ for( i = 1 ; i <= numRects ; i++ ) {
+     eIndexArray[i] = (int *) malloc( (1 + numRects) * sizeof( int ) ) ;
+ }
+ 
+ #ifdef notdef
+ sprintf( filename, "%s.gph", cktName ) ;
+ fp = fopen( filename , "w" ) ;
+ #endif
+ 
+ for( i = 1 ; i <= eNum ; i++ ) {
+     index1 = eArray[i].index1 ;
+     index2 = eArray[i].index2 ;
+     eIndexArray[index1][index2] = i ;
+     eIndexArray[index2][index1] = i ;
+     if( i <= edgeTransition ) {
+ 	hiend = rectArray[index2].b ;
+ 	loend = rectArray[index1].t ;
+ 	length = rectArray[index2].yc - rectArray[index1].yc  ;
+ 	tinsert( &vChanBeginRoot , eArray[i].lbside , i ) ;
+ 	tinsert( &vChanEndRoot , eArray[i].rtside , i ) ;
+     } else {
+ 	hiend = rectArray[index2].l ;
+ 	loend = rectArray[index1].r ;
+ 	length = rectArray[index2].xc - rectArray[index1].xc  ;
+ 	tinsert( &hChanBeginRoot , eArray[i].lbside , i ) ;
+ 	tinsert( &hChanEndRoot , eArray[i].rtside , i ) ;
+     }
+     eArray[i].length = length ;
+     eArray[i].hiend = hiend ;
+     eArray[i].loend = loend ;
+ #ifdef notdef
+     fprintf( fp, "edge %5d %5d   length %8d  capacity %8d\n",
+ 		    index1 , index2 , length , eArray[i].width ) ;
+ #endif
+ }
+ #ifdef notdef
+ fclose(fp);
+ #endif
+ 
+ #ifdef DEBUG
+ fprintf(fpdebug,"CHANNEL-GRAPH NODES:\n");
+ for( i = 1 ; i <= numRects ; i++ ) {
+     fprintf(fpdebug,"rect Node: %d  at: %d %d  width:%d  height:%d\n",
+ 		i , rectArray[i].xc , rectArray[i].yc ,
+ 		rectArray[i].r - rectArray[i].l ,
+ 				rectArray[i].t - rectArray[i].b ) ;
+ }
+ #endif
+ 
+ return ;
+ }
+ 
+ 
+ 
+ void exploreUp(void)
+ {
+ 
+ DLINK2PTR beptr ;
+ int beg , end , left , rite , finishLine , b , l , r , rec , index ;
+ 
+ for( rec = 1 ; rec <= numRects ; rec++ ) {
+     beg  = rectArray[rec].b ;
+     end  = rectArray[rec].t ;
+     rite = rectArray[rec].r ;
+     left = rectArray[rec].l ;
+     finishLine = 1000000 ;
+     beptr = BEptrs[ tprop( BEroot , beg ) ] ;
+     for( ; beptr != (DLINK2PTR) NULL; beptr = beptr->next ){
+ 	index = beptr->index ;
+ 	b = rectArray[index].b ;
+ 	if( b > finishLine ) {
+ 	    break ;
+ 	}
+ 	l = rectArray[index].l ;
+ 	r = rectArray[index].r ;
+ 	if( b <= end || l > rite || r < left ) {
+ 	    continue ;
+ 	}
+ 	if( constructVedge( rec , index ) ) {
+ 	    break ;
+ 	}
+ 	finishLine = rectArray[index].t ;
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void exploreRite(void)
+ {
+ 
+ DLINK2PTR leptr ;
+ int beg , end , top , bot , finishLine , l , b , t , rec , index ;
+ 
+ for( rec = 1 ; rec <= numRects ; rec++ ) {
+     beg = rectArray[rec].l ;
+     end = rectArray[rec].r ;
+     top = rectArray[rec].t ;
+     bot = rectArray[rec].b ;
+     finishLine = 1000000 ;
+     leptr = LEptrs[ tprop( LEroot , beg ) ] ;
+     for( ; leptr != (DLINK2PTR) NULL; leptr = leptr->next ){
+ 	index = leptr->index ;
+ 	l = rectArray[index].l ;
+ 	if( l > finishLine ) {
+ 	    break ;
+ 	}
+ 	b = rectArray[index].b ;
+ 	t = rectArray[index].t ;
+ 	if( l <= end || b > top || t < bot ) {
+ 	    continue ;
+ 	}
+ 	if( constructHedge( rec , index ) ) {
+ 	    break ;
+ 	}
+ 	finishLine = rectArray[index].r ;
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ int constructVedge( int index1 , int index2 )
+ {
+ 
+ DLINK1PTR v1ptr , v2ptr , vptr ;
+ int l1 , l2 , r1 , r2 , l , r , b , t , edge1 , edge2 , el , er ;
+ int eb , et , eb1 , et1 , eb2 , et2 ;
+ int edge , x ;
+ 
+ l1 = rectArray[index1].l ;
+ r1 = rectArray[index1].r ;
+ l2 = rectArray[index2].l ;
+ r2 = rectArray[index2].r ;
+ l = ( l1 >= l2 ) ? l1 : l2 ;
+ r = ( r1 <= r2 ) ? r1 : r2 ;
+ b = rectArray[index1].t ; 
+ t = rectArray[index2].b ; 
+ 
+ el = -1000000 ;
+ v1ptr = VDptrs[ tprop( VDroot , l ) ] ;
+ for( ; v1ptr != (DLINK1PTR) NULL; v1ptr = v1ptr->next ) {
+     edge1 = v1ptr->edge ;
+     if( edgeList[edge1].loc > r ) {
+ 	break ;
+     }
+     if( edgeList[edge1].UorR > 0 ) {
+ 	continue ;
+     }
+     if( edgeList[edge1].start > b || edgeList[edge1].end < t ) {
+ 	continue ;
+     }
+     el = edgeList[edge1].loc ;
+     vptr = v1ptr ;
+ }
+ if( el == -1000000 ) {
+     return(0) ;
+ }
+ v2ptr = Vptrs[ tprop( Vroot , el ) ] ;
+ for( ; v2ptr != (DLINK1PTR) NULL; v2ptr = v2ptr->next ) {
+     edge2 = v2ptr->edge ;
+     if( edgeList[edge2].UorR < 0 ) {
+ 	continue ;
+     }
+     if( edgeList[edge2].start > b || edgeList[edge2].end < t ) {
+ 	continue ;
+     }
+     er = edgeList[edge2].loc ;
+     break ;
+ }
+ if( er > r ) {
+     return(0) ;
+ }
+ v1ptr = vptr ;
+ edge1 = v1ptr->edge ;
+ 
+ et1 = edgeList[edge1].end ;
+ eb1 = edgeList[edge1].start ;
+ et2 = edgeList[edge2].end ;
+ eb2 = edgeList[edge2].start ;
+ if( edgeList[edge1].fixed == 1 && edgeList[edge2].fixed == 1 ) {
+     if( edgeList[edge1].cell > 0 && edgeList[edge2].cell > 0 ) {
+ 	et = (et1 >= et2) ? et1 : et2 ;
+ 	eb = (eb1 <= eb2) ? eb1 : eb2 ;
+     } else if( edgeList[edge1].cell > 0 ) {
+ 	et = et1 ;
+ 	eb = eb1 ;
+     } else if( edgeList[edge2].cell > 0 ) {
+ 	et = et2 ;
+ 	eb = eb2 ;
+     } else {
+ 	et = 1000000 ;
+ 	eb = -1000000 ;
+     }
+ } else if( edgeList[edge1].fixed == 1 ) {
+     if( edgeList[edge1].cell > 0 ) {
+ 	et = et1 ;
+ 	eb = eb1 ;
+     } else {
+ 	et = 1000000 ;
+ 	eb = -1000000 ;
+     }
+ } else if( edgeList[edge2].fixed == 1 ) {
+     if( edgeList[edge2].cell > 0 ) {
+ 	et = et2 ;
+ 	eb = eb2 ;
+     } else {
+ 	et = 1000000 ;
+ 	eb = -1000000 ;
+     }
+ } else {
+     et = 1000000 ;
+     eb = -1000000 ;
+ }
+ if( ! ( et > rectArray[index2].t ) ){
+     if( rectArray[index2].yc < et ) {
+ 	rectArray[index2].yc = et ;
+ 	rectArray[index2].yreset = 2 ;
+     }
+ }
+ if( ! ( eb < rectArray[index1].b ) ){
+     if( rectArray[index1].yc > eb ) {
+ 	rectArray[index1].yc = eb ;
+ 	rectArray[index1].yreset = 1 ;
+     }
+ }
+ if( rectArray[index1].xc < el || rectArray[index1].xc > er ) {
+     rectArray[index1].xc = (el + er) / 2 ;
+ }
+ if( rectArray[index2].xc < el || rectArray[index2].xc > er ) {
+     rectArray[index2].xc = (el + er) / 2 ;
+ }
+ 
+ if( edgeList[edge1].fixed == 0 ) {
+     vptr = Vptrs[ tprop( Vroot , el ) ] ;
+     x = edgeList[vptr->edge].loc ;
+     vptr = vptr->next ;
+     for( ; vptr != (DLINK1PTR) NULL; vptr = vptr->next ) {
+ 	if( edgeList[vptr->edge].loc > x ) {
+ 	    break ;
+ 	}
+     }
+     for( vptr = vptr->prev; vptr != (DLINK1PTR) NULL; 
+ 					    vptr = vptr->prev ) {
+ 	if( vptr == v2ptr ) {
+ 	    continue ;
+ 	}
+ 	edge = vptr->edge ;
+ 	if( edgeList[edge].UorR < 0 ) {
+ 	    continue ;
+ 	}
+ 	if( edgeList[edge].start > b || edgeList[edge].end < t ) {
+ 	    continue ;
+ 	}
+ 	break ;
+     }
+     el -= (el - edgeList[edge].loc) - (el - edgeList[edge].loc) / 2 ;
+ }
+ if( edgeList[edge2].fixed == 0 ) {
+     vptr = Vptrs[ tprop( Vroot , er ) ] ;
+     for(; vptr != (DLINK1PTR) NULL; vptr = vptr->next ) {
+ 	if( vptr == v1ptr ) {
+ 	    continue ;
+ 	}
+ 	edge = vptr->edge ;
+ 	if( edgeList[edge].UorR > 0 ) {
+ 	    continue ;
+ 	}
+ 	if( edgeList[edge].start > b || edgeList[edge].end < t ) {
+ 	    continue ;
+ 	}
+ 	break ;
+     }
+     er += (edgeList[edge].loc - er) / 2 ;
+ }
+ 
+ if( ++eNum % 100 == 0 ) {
+     eArray = (EBOXPTR) realloc( eArray, (eNum + 100) * sizeof(EBOX));
+ }
+ eArray[eNum].index1 = index1 ;
+ eArray[eNum].index2 = index2 ;
+ eArray[eNum].width  = er - el ;
+ eArray[eNum].lbside = el ;
+ eArray[eNum].rtside = er ;
+ eArray[eNum].edge1 = edge1 ;
+ eArray[eNum].edge2 = edge2 ;
+ 
+ return(1) ;
+ }
+ 
+ 
+ 
+ 
+ int constructHedge( int index1 , int index2 )
+ {
+ 
+ DLINK1PTR h1ptr , h2ptr , hptr ;
+ int b1 , b2 , t1 , t2 , b , l , r , t , edge1 , edge2 , eb , et ;
+ int el , er , el1 , er1 , el2 , er2 ;
+ int edge , x ;
+ 
+ b1 = rectArray[index1].b ;
+ t1 = rectArray[index1].t ;
+ b2 = rectArray[index2].b ;
+ t2 = rectArray[index2].t ;
+ b = ( b1 >= b2 ) ? b1 : b2 ;
+ t = ( t1 <= t2 ) ? t1 : t2 ;
+ l = rectArray[index1].r ; 
+ r = rectArray[index2].l ; 
+ 
+ eb = -1000000 ;
+ h1ptr = HRptrs[ tprop( HRroot , b ) ] ;
+ for( ; h1ptr != (DLINK1PTR) NULL; h1ptr = h1ptr->next ) {
+     edge1 = h1ptr->edge ;
+     if( edgeList[edge1].loc > t ) {
+ 	break ;
+     }
+     if( edgeList[edge1].UorR < 0 ) {
+ 	continue ;
+     }
+     if( edgeList[edge1].start > l || edgeList[edge1].end < r ) {
+ 	continue ;
+     }
+     eb = edgeList[edge1].loc ;
+     hptr = h1ptr ;
+ }
+ if( eb == -1000000 ) {
+     return(0) ;
+ }
+ h2ptr = Hptrs[ tprop( Hroot , eb ) ] ;
+ for( ; h2ptr != (DLINK1PTR) NULL; h2ptr = h2ptr->next ) {
+     edge2 = h2ptr->edge ;
+     if( edgeList[edge2].UorR > 0 ) {
+ 	continue ;
+     }
+     if( edgeList[edge2].start > l || edgeList[edge2].end < r ) {
+ 	continue ;
+     }
+     et = edgeList[edge2].loc ;
+     break ;
+ }
+ if( et > t ) {
+     return(0) ;
+ }
+ h1ptr = hptr ;
+ edge1 = h1ptr->edge ;
+ 
+ er1 = edgeList[edge1].end ;
+ el1 = edgeList[edge1].start ;
+ er2 = edgeList[edge2].end ;
+ el2 = edgeList[edge2].start ;
+ if( edgeList[edge1].fixed == 1 && edgeList[edge2].fixed == 1 ) {
+     if( edgeList[edge1].cell > 0 && edgeList[edge2].cell > 0 ) {
+ 	er = (er1 >= er2) ? er1 : er2 ;
+ 	el = (el1 <= el2) ? el1 : el2 ;
+     } else if( edgeList[edge1].cell > 0 ) {
+ 	er = er1 ;
+ 	el = el1 ;
+     } else if( edgeList[edge2].cell > 0 ) {
+ 	er = er2 ;
+ 	el = el2 ;
+     } else {
+ 	er = 1000000 ;
+ 	el = -1000000 ;
+     }
+ } else if( edgeList[edge1].fixed == 1 ) {
+     if( edgeList[edge1].cell > 0 ) {
+ 	er = er1 ;
+ 	el = el1 ;
+     } else {
+ 	er = 1000000 ;
+ 	el = -1000000 ;
+     }
+ } else if( edgeList[edge2].fixed == 1 ) {
+     if( edgeList[edge2].cell > 0 ) {
+ 	er = er2 ;
+ 	el = el2 ;
+     } else {
+ 	er = 1000000 ;
+ 	el = -1000000 ;
+     }
+ } else {
+     er = 1000000 ;
+     el = -1000000 ;
+ }
+ if( ! ( er > rectArray[index2].r ) ){
+     if( rectArray[index2].xc < er ) {
+ 	rectArray[index2].xc = er ;
+ 	rectArray[index2].xreset = 2 ;
+     }
+ }
+ if( ! ( el < rectArray[index1].l ) ){
+     if( rectArray[index1].xc > el ) {
+ 	rectArray[index1].xc = el ;
+ 	rectArray[index1].xreset = 1 ;
+     }
+ }
+ if( rectArray[index1].yc < eb || rectArray[index1].yc > et ) {
+     rectArray[index1].yc = (eb + et) / 2 ;
+ }
+ if( rectArray[index2].yc < eb || rectArray[index2].yc > et ) {
+     rectArray[index2].yc = (eb + et) / 2 ;
+ }
+ 
+ if( edgeList[edge1].fixed == 0 ) {
+     hptr = Hptrs[ tprop( Hroot , eb ) ] ;
+     x = edgeList[hptr->edge].loc ;
+     hptr = hptr->next ;
+     for( ; hptr != (DLINK1PTR) NULL; hptr = hptr->next ) {
+ 	if( edgeList[hptr->edge].loc > x ) {
+ 	    break ;
+ 	}
+     }
+     for( hptr = hptr->prev; hptr != (DLINK1PTR) NULL; 
+ 					    hptr = hptr->prev ) {
+ 	if( hptr == h2ptr ) {
+ 	    continue ;
+ 	}
+ 	edge = hptr->edge ;
+ 	if( edgeList[edge].UorR > 0 ) {
+ 	    continue ;
+ 	}
+ 	if( edgeList[edge].start > l || edgeList[edge].end < r ) {
+ 	    continue ;
+ 	}
+ 	break ;
+     }
+     eb -= (eb - edgeList[edge].loc) - (eb - edgeList[edge].loc) / 2 ;
+ }
+ if( edgeList[edge2].fixed == 0 ) {
+     hptr = Hptrs[ tprop( Hroot , et ) ] ;
+     for(; hptr != (DLINK1PTR) NULL; hptr = hptr->next ) {
+ 	if( hptr == h1ptr ) {
+ 	    continue ;
+ 	}
+ 	edge = hptr->edge ;
+ 	if( edgeList[edge].UorR < 0 ) {
+ 	    continue ;
+ 	}
+ 	if( edgeList[edge].start > l || edgeList[edge].end < r ) {
+ 	    continue ;
+ 	}
+ 	break ;
+     }
+     et += (edgeList[edge].loc - et) / 2 ;
+ }
+ 
+ if( ++eNum % 100 == 0 ) {
+     eArray = (EBOXPTR) realloc( eArray, (eNum + 100) * sizeof(EBOX));
+ }
+ eArray[eNum].index1 = index1 ;
+ eArray[eNum].index2 = index2 ;
+ eArray[eNum].width  = et - eb ;
+ eArray[eNum].lbside = eb ;
+ eArray[eNum].rtside = et ;
+ eArray[eNum].edge1 = edge1 ;
+ eArray[eNum].edge2 = edge2 ;
+ 
+ return(1) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/checkpen.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/checkpen.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/checkpen.c	Tue Oct  5 16:19:43 2004
***************
*** 0 ****
--- 1,167 ----
+ #include "custom.h"
+ 
+ int checkover( int cell , int xc , int yc , int orient , int b , int flag ,
+ 	      int borient );
+ 
+ int checkpen(void)
+ {
+ 
+ int cell , check ;
+ 
+ check = 0 ;
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     check += checkover( cell, cellarray[cell]->xcenter, 
+ 			      cellarray[cell]->ycenter,
+ 			      cellarray[cell]->orient , 0 , 1 , 0 ) ;
+ }
+ return( check ) ;
+ }
+ 
+ 
+ 
+ 
+ int checkover( int cell , int xc , int yc , int orient , int b , int flag ,
+                 int borient )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr1 , tileptr2 , tileptr01, tileptr02 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ orient ]  ;
+ 
+ startx01 = xc + tileptr01->left    ;
+ endx01   = xc + tileptr01->right   ;
+ starty01 = yc + tileptr01->bottom  ;
+ endy01   = yc + tileptr01->top     ;
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell || othercell > numcells ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    if( othercell != b ) {
+ 		tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 		xcenter = cellptr2->xcenter ;
+ 		ycenter = cellptr2->ycenter ;
+ 	    } else if( flag == 0 ) {
+ 		tileptr02 = cellptr2->config[borient] ;
+ 		xcenter = cellptr1->xcenter ;
+ 		ycenter = cellptr1->ycenter ;
+ 	    } else {
+ 		continue ;
+ 	    }
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 		/*
+ 		fprintf(fpo,"Overlap condition: cell:%d othercell:%d",
+ 						cell, othercell ) ;
+ 		fprintf(fpo,"   overlap:%d\n", value ) ;
+ 		*/
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    startx1 =  xc + tileptr1->left   ;
+ 		    endx1   =  xc + tileptr1->right  ;
+ 		    starty1 =  yc + tileptr1->bottom ;
+ 		    endy1   =  yc + tileptr1->top    ;
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config1.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config1.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config1.c	Tue Oct  5 16:19:43 2004
***************
*** 0 ****
--- 1,75 ----
+ #include "custom.h"
+ extern int perim ;
+ int totChanLen ;
+ int totNetLen  ;
+ 
+ extern void placepads(void);
+ extern void loadbins(int new);
+ 
+ void config1(void)
+ {
+ 
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ int l , r , b , t , totalArea , cell ;
+ 
+ 
+ /*
+  *   Sum the areas of the cells
+  */
+ totalArea = 0 ;
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cellptr->numtiles == 1 ) {
+ 	tileptr = cellptr->config[cellptr->orient] ;
+ 	l = tileptr->left   ;
+ 	r = tileptr->right  ;
+ 	b = tileptr->bottom ;
+ 	t = tileptr->top    ;
+ 	totalArea += (r - l) * (t - b) ;
+     } else {
+ 	tileptr = cellptr->config[cellptr->orient]->nexttile ;
+ 	for( ; tileptr != TILENULL; tileptr = tileptr->nexttile ){
+ 	    l = tileptr->left   ;
+ 	    r = tileptr->right  ;
+ 	    b = tileptr->bottom ;
+ 	    t = tileptr->top    ;
+ 	    totalArea += (r - l) * (t - b) ;
+ 	}
+     }
+ }
+ if( coreGiven == 0 ) {
+     blockr = blockt = (int) sqrt( (double) totalArea ) + 1 ;
+     totChanLen = perim / 2 - (blockr + blockt) ;
+     aveChanWid = 0 ;
+ } else {
+     r = t = (int) sqrt( (double) totalArea ) + 1 ;
+     totChanLen = perim / 2 - (r + t) ;
+     aveChanWid = 0 ;
+ }
+ 
+ slopeX = (double)(maxWeight - baseWeight) / ( (double) blockr * 0.5 ) ;
+ slopeY = (double)(maxWeight - baseWeight) / ( (double) blockt * 0.5 ) ;
+ basefactor = (double) baseWeight ;
+ 
+ placepads() ;
+ 
+ blockmx = (blockr + blockl) / 2 ;
+ blockmy = (blockt + blockb) / 2 ;
+ 
+ binWidthX = (blockr - blockl) / numBinsX ;
+ if( (blockr - blockl - binWidthX * numBinsX) >= numBinsX / 2 ) {
+     binWidthX++ ;
+ }
+ binOffsetX = blockl + 1 - binWidthX ;
+ 
+ binWidthY = (blockt - blockb) / numBinsY ;
+ if( (blockt - blockb - binWidthY * numBinsY) >= numBinsY / 2 ) {
+     binWidthY++ ;
+ }
+ binOffsetY = blockb + 1 - binWidthY ;
+ 
+ loadbins(1) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config2.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config2.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config2.c	Tue Oct  5 16:19:43 2004
***************
*** 0 ****
--- 1,174 ----
+ #include "custom.h"
+ extern double chipaspect ;
+ extern int perim ;
+ extern int totChanLen ;
+ extern int totNetLen  ;
+ extern int core_expansion_given ;
+ extern double core_expansion ;
+ extern int wire_est_factor ;
+ double expandExtra ;
+ extern int defaultTracks ;
+ 
+ extern void placepads(void);
+ extern void loadbins(int new);
+ 
+ void config2(void)
+ {
+ 
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ int l , r , b , t , sum , cell , tempint ;
+ double totNewArea , totalArea , temp , dub , reduction_factor ;
+ 
+ 
+ /*
+  *   Sum the areas of the cells
+  */
+ totalArea = 0 ;
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cellptr->numtiles == 1 ) {
+ 	tileptr = cellptr->config[cellptr->orient] ;
+ 	l = tileptr->left   ;
+ 	r = tileptr->right  ;
+ 	b = tileptr->bottom ;
+ 	t = tileptr->top    ;
+ 	totalArea += (r - l) * (t - b) ;
+     } else {
+ 	tileptr = cellptr->config[cellptr->orient]->nexttile ;
+ 	for( ; tileptr != TILENULL ; tileptr = tileptr->nexttile ) {
+ 	    l = tileptr->left   ;
+ 	    r = tileptr->right  ;
+ 	    b = tileptr->bottom ;
+ 	    t = tileptr->top    ;
+ 	    totalArea += (r - l) * (t - b) ;
+ 	}
+     }
+ }
+ if( coreGiven == 0 ) {
+     blockr = blockt = (int) sqrt( totalArea ) ;
+     totChanLen = perim / 2 - (blockr + blockt) ;
+     temp = ((double) totNetLen / (double) totChanLen) /
+ 		((double) layersFactor) ; 
+ } else {
+     r = t = (int) sqrt( totalArea ) ;
+     totChanLen = perim / 2 - (r + t) ;
+     temp = ((double) totNetLen / (double) totChanLen) /
+ 		((double) layersFactor) ; 
+ }
+ temp += (double) defaultTracks ;
+ tempint = (int)( temp ) + 3 ; /* d+1 tracks + roundoff */
+ tempint *= trackspacing ;
+ 
+ reduction_factor = 1.8 + (double) wire_est_factor / 10.0 ;
+ aveChanWid = (int)( (double) tempint / reduction_factor ) ;
+ 
+ aveChanWid += 2 ;
+ fprintf(fpo,"\n\nConfiguration Data\nInternal Channel Length:%d\n",
+ 							totChanLen ) ;
+ fprintf(fpo,"Average Channel Width (un-normalized):%d\n\n", tempint );
+ fprintf(fpo,"Average Channel Width:%d\n\n", aveChanWid ) ;
+ 
+ if( coreGiven == 0 ) {
+     /*
+      *   Compute total new area
+      */
+ 
+     totNewArea = 0 ;
+     for( cell = 1 ; cell <= numcells ; cell++ ) {
+ 	cellptr = cellarray[cell] ;
+ 	if( cellptr->numtiles == 1 ) {
+ 	    tileptr = cellptr->config[cellptr->orient] ;
+ 	    l = tileptr->left   ;
+ 	    r = tileptr->right  ;
+ 	    b = tileptr->bottom ;
+ 	    t = tileptr->top    ;
+ 	    totNewArea += (r - l + maxWeight * maxWeight * aveChanWid) *
+ 			  (t - b + maxWeight * maxWeight * aveChanWid) ;
+ 	} else {
+ 	    sum = 0 ;
+ 	    tileptr = cellptr->config[cellptr->orient]->nexttile ;
+ 	    for( ; tileptr != TILENULL ; tileptr = tileptr->nexttile ) {
+ 		l = tileptr->left   ;
+ 		r = tileptr->right  ;
+ 		b = tileptr->bottom ;
+ 		t = tileptr->top    ;
+ 		sum += (r - l) * (t - b) ;
+ 	    }
+ 	    tileptr = cellptr->config[cellptr->orient] ;
+ 	    l = tileptr->left   ;
+ 	    r = tileptr->right  ;
+ 	    b = tileptr->bottom ;
+ 	    t = tileptr->top    ;
+ 	    totNewArea += (r - l + maxWeight * maxWeight * aveChanWid) * 
+ 			  (t - b + maxWeight * maxWeight * aveChanWid) -
+ 			  (r - l) * (t - b) + sum ;
+ 	}
+     }
+     /*
+     expandExtra = ( 117.5 - 5.0 * ( ((double) aveChanWid) / 
+ 			 ((double) trackspacing) ) ) / 100.0 ;
+     if( expandExtra < 1.05 ) {
+ 	expandExtra = 1.05 ;
+     } 
+     */
+     expandExtra = 1.05 ;
+ 
+     if( numcells < 10 ) {
+ 	expandExtra += (double) (10 - numcells) * 0.01 ;
+ 	if( expandExtra > 1.10 ) {
+ 	    expandExtra = 1.10 ;
+ 	}
+     }
+     
+     blockr = blockt = (int)( expandExtra * sqrt( totNewArea ) ) + 1 ;
+     fprintf(fpo,"Core Expansion Factor: %f\n", expandExtra ) ;
+ 
+     dub = log10( (double) blockr / sqrt( (double) numcells ) ) ;
+     if( (!core_expansion_given) && dub >= 3.0 ) {
+ 	expandExtra += 0.02 + (0.04 * (dub - 3.0)) ;
+ 	if( expandExtra > 1.10 ) {
+ 	    expandExtra = 1.10 ;
+ 	}
+ 	blockr = blockt = (int)( expandExtra * sqrt( totNewArea ) ) + 1 ;
+ 	fprintf(fpo,"Core Expansion Factor: %f\n", expandExtra ) ;
+     }
+     if( core_expansion_given ) {
+ 	expandExtra = core_expansion ;
+ 	blockr = blockt = (int)( expandExtra * sqrt( totNewArea ) ) + 1 ;
+ 	fprintf(fpo,"Core Expansion Factor: %f\n", expandExtra ) ;
+     }
+ 	
+     
+ 
+     /* 
+      *    Take into account the aspect ratio requested by the user
+      */
+     blockt = (int)( sqrt(chipaspect) * (double) blockt ) + 1 ;
+     blockr = (int)( 1.0 / sqrt(chipaspect) * (double) blockr ) + 1 ;
+ }
+ slopeX = (double)(maxWeight - baseWeight) / ( (double) blockr * 0.5 ) ;
+ slopeY = (double)(maxWeight - baseWeight) / ( (double) blockt * 0.5 ) ;
+ basefactor = (double) baseWeight ;
+ 
+ placepads() ;
+ 
+ blockmx = (blockr + blockl) / 2 ;
+ blockmy = (blockt + blockb) / 2 ;
+ 
+ binWidthX = (blockr - blockl) / numBinsX ;
+ if( (blockr - blockl - binWidthX * numBinsX) >= numBinsX / 2 ) {
+     binWidthX++ ;
+ }
+ binOffsetX = blockl + 1 - binWidthX ;
+ 
+ binWidthY = (blockt - blockb) / numBinsY ;
+ if( (blockt - blockb - binWidthY * numBinsY) >= numBinsY / 2 ) {
+     binWidthY++ ;
+ }
+ binOffsetY = blockb + 1 - binWidthY ;
+ 
+ loadbins(0) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config3.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config3.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/config3.c	Tue Oct  5 16:19:44 2004
***************
*** 0 ****
--- 1,120 ----
+ #include "custom.h"
+ #define L 1
+ #define T 2
+ #define R 3
+ #define B 4
+ 
+ void config3(void)
+ {
+ 
+ CELLBOXPTR cellptr ;
+ int pad , left , right , top , bottom ;
+ int deltaX , deltaY , target , cell , l , r , b , t ;
+ 
+ left = 1000000 ;
+ bottom = 1000000 ;
+ top = 0 ;
+ right = 0 ;
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     l = cellptr->xcenter + cellptr->config[cellptr->orient]->left
+ 		     - (2 * cellptr->config[cellptr->orient]->lborder) ;
+     r = cellptr->xcenter + cellptr->config[cellptr->orient]->right
+ 		     + (2 * cellptr->config[cellptr->orient]->rborder) ;
+     b = cellptr->ycenter + cellptr->config[cellptr->orient]->bottom
+ 		     - (2 * cellptr->config[cellptr->orient]->bborder) ;
+     t = cellptr->ycenter + cellptr->config[cellptr->orient]->top
+ 		     + (2 * cellptr->config[cellptr->orient]->tborder) ;
+     if( l < left ) {
+ 	left = l ;
+     }
+     if( r > right ) {
+ 	right = r ;
+     }
+     if( b < bottom ) {
+ 	bottom = b ;
+     }
+     if( t > top ) {
+ 	top = t ;
+     }
+ }
+ deltaX = 0 ; /* (int)( 0.1 * (double)(right - left) ) ; */
+ deltaY = 0 ; /* (int)( 0.1 * (double)(top - bottom) ) ; */
+ 
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     cellptr = cellarray[pad] ;
+     if( cellptr->padside != B ) {
+ 	continue ;
+     }
+     target = bottom - deltaY ;
+     b = cellptr->ycenter + cellptr->config[cellptr->orient]->top ;
+     b = target - b ;
+ }
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     cellptr = cellarray[pad] ;
+     if( cellptr->padside != T ) {
+ 	continue ;
+     }
+     target = top + deltaY ;
+     t = cellptr->ycenter + cellptr->config[cellptr->orient]->bottom ;
+     t -= target ;
+ }
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     cellptr = cellarray[pad] ;
+     if( cellptr->padside != L ) {
+ 	continue ;
+     }
+     target = left - deltaX ;
+     l = cellptr->xcenter + cellptr->config[cellptr->orient]->right ;
+     l = target - l ;
+ }
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     cellptr = cellarray[pad] ;
+     if( cellptr->padside != R ) {
+ 	continue ;
+     }
+     target = right + deltaX ;
+     r = cellptr->xcenter + cellptr->config[cellptr->orient]->left ;
+     r -= target ;
+ }
+ 
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == B ) {
+ 	cellarray[pad]->ycenter += b ;
+     } else if( cellarray[pad]->padside == T ) {
+ 	cellarray[pad]->ycenter -= t ;
+     } else if( cellarray[pad]->padside == L ) {
+ 	cellarray[pad]->xcenter += l ;
+     } else if( cellarray[pad]->padside == R ) {
+ 	cellarray[pad]->xcenter -= r ;
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void reconfigSides( double degree )
+ {
+ CELLBOXPTR ptr ;
+ int deltaX , deltaY ;
+ 
+ 
+ deltaX = (int)( degree * (double)(blockr - blockl) ) ;
+ deltaY = (int)( degree * (double)(blockt - blockb) ) ;
+ 
+ ptr = cellarray[ numcells + numpads + 1 ] ;
+ ptr->xcenter -= deltaX ;
+ 
+ ptr = cellarray[ numcells + numpads + 2 ] ;
+ ptr->xcenter += deltaX ;
+ 
+ ptr = cellarray[ numcells + numpads + 3 ] ;
+ ptr->ycenter -= deltaY ;
+ 
+ ptr = cellarray[ numcells + numpads + 4 ] ;
+ ptr->ycenter += deltaY ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/custom.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/custom.h:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/custom.h	Tue Oct  5 16:19:44 2004
***************
*** 0 ****
--- 1,232 ----
+ #include "port.h"
+ 
+ #define MaxSites 50
+ #define ZERO 0
+ #define ALLOC(type)    (  (type *) malloc ( sizeof(type) )  )
+ #define LINE printf(" file : %s  line # %d\n", __FILE__,__LINE__);
+ #define ABS(value)   ( (value)>=0 ? (value) : -(value) ) 
+ #define ROUND(value) ( ( (value) - (int)(value) ) >= 0.5 ? ((int)(value) + 1) : ((int)(value)) ) 
+ #define RAND ((randVar = randVar * 1103515245 + 12345) & 0x7fffffff)
+ 
+ #define CELLNULL (CELLBOXPTR) NULL
+ #define NETNULL (NETBOXPTR) NULL
+ #define DIMNULL (DIMBOXPTR) NULL
+ #define TILENULL (TILEBOXPTR) NULL
+ #define TERMNULL (TERMBOXPTR) NULL
+ #define TERMNETSNULL (TERMNETSPTR) NULL
+ #define LNULL (LOCBOX *) NULL
+ 
+ typedef struct bustbox {
+     int xc ;
+     int yc ;
+ } BUSTBOX , *BUSTBOXPTR ;
+ 
+ typedef struct locbox {
+     int xpos ;
+     int ypos ;
+     int oxpos ;
+     int oypos ;
+ } LOCBOX ;
+ 
+ typedef struct contentbox {
+     int contents ;
+     int newContents ;
+     int capacity ;
+     int HorV ;
+     int span ;
+ } CONTENTBOX ;
+ 
+ typedef struct uncombox {
+     int terminal  ;
+     int site      ;
+     int newsite   ;
+     int numLocs   ;
+     int numranges ;
+     int range1    ;
+     int range2    ;
+     int sequence  ;
+     int groupflag ;
+     int finalx    ;
+     int finaly    ;
+ } UNCOMBOX ;
+ 
+ typedef struct netbox {
+     struct netbox *nextterm ;
+     int xpos ;
+     int ypos ;
+     int newx ;
+     int newy ;
+     int terminal ;
+     int flag ;
+     int cell ;
+     int PorE ;
+     int skip ;
+ } *NETBOXPTR , NETBOX ;
+ 
+ typedef struct termbox { 
+     struct termbox *nextterm ;
+     int xpos     ;
+     int ypos     ;
+     int oxpos    ;
+     int oypos    ;
+     int terminal ;
+ } *TERMBOXPTR , TERMBOX ;
+ 
+ typedef struct tilebox { 
+     struct tilebox *nexttile ;
+     double lweight ;
+     double rweight ;
+     double bweight ;
+     double tweight ;
+     int lborder    ;
+     int rborder    ;
+     int bborder    ;
+     int tborder    ;
+     int left       ;
+     int right      ;
+     int bottom     ;
+     int top        ;
+     int oleft      ;
+     int oright     ;
+     int obottom    ;
+     int otop       ;
+     TERMBOXPTR termptr ;
+     LOCBOX *siteLocArray ;
+ } *TILEBOXPTR , TILEBOX ;
+ 
+ typedef struct psidebox {
+     int length   ;
+     double pincount;
+     int vertical ;
+     int position ;
+ } PSIDEBOX ;
+ 
+ typedef struct sidebox {
+     int firstSite ;
+     int lastSite  ;
+ } SIDEBOX ;
+ 
+ typedef struct cellbox { 
+     char *cname             ;
+     int class               ;
+     int xcenter             ;
+     int ycenter             ;
+     int orientList[9]       ;
+     int orient              ;
+     int numtiles            ;
+     int numsides            ;
+     int numterms            ;
+     int numgroups           ;
+     int softflag            ;
+     int padside             ;
+     double sidespace        ;
+     double aspect           ;
+     double aspectO          ;
+     double aspUB            ;
+     double aspLB            ;
+     int numsites            ;
+     int numUnComTerms       ;
+     CONTENTBOX *siteContent ;
+     UNCOMBOX *unComTerms    ;
+     TILEBOXPTR config[8]    ;
+     SIDEBOX *sideArray      ;
+ } *CELLBOXPTR , CELLBOX ;
+ 
+ typedef struct dimbox {
+     NETBOXPTR netptr   ;
+     int skip     ;
+     int xmin     ;
+     int newxmin  ;
+     int xmax     ;
+     int newxmax  ;
+     int ymin     ;
+     int flag     ;
+     int newymin  ;
+     int ymax     ;
+     int newymax  ;
+     double Hweight ;
+     double Vweight ;
+     char *nname  ;
+ } *DIMBOXPTR , DIMBOX ;
+ 
+ typedef struct termnets {
+     int net ;
+     NETBOXPTR termptr ;
+ } *TERMNETSPTR , TERMNETS ;
+ 
+ typedef struct hash {
+     char *hname ;
+     int hnum ;
+     struct hash *hnext ;
+ } HASHBOX , *HASHPTR ;
+ 
+ extern CELLBOXPTR *cellarray   ;
+ extern DIMBOXPTR *netarray     ;
+ extern TERMNETSPTR *termarray  ;
+ extern int ***blockarray ;
+ 
+ extern int bdxlength , bdylength ;
+ extern int blockl , blockr , blockt , blockb ;
+ extern int blockmx , blockmy ;
+ 
+ extern int numcells  ;
+ extern int numpads   ;
+ extern int numBinsX  ;
+ extern int numBinsY  ;
+ extern int binWidthX ;
+ extern int binWidthY ;
+ extern int binOffsetX;
+ extern int binOffsetY;
+ extern int *bucket   ;
+ extern int maxWeight ;
+ extern int baseWeight;
+ extern double slopeX    ;
+ extern double slopeY    ;
+ extern double basefactor;
+ extern int aveChanWid;
+ 
+ extern int penalty   ;
+ extern int funccost  ;
+ extern int offset    ;
+ extern int overfill  ;
+ 
+ extern HASHPTR *hashtab ;
+ extern int netctr ;
+ extern double T ;
+ extern int randVar ;
+ extern FILE *fpo ;
+ extern char **pinnames ;
+ extern char *cktName ;
+ extern int numnets ;
+ extern int maxterm ;
+ extern int attmax  ;
+ 
+ extern int *occa1ptr ;
+ extern int *occa2ptr ;
+ extern int *occb1ptr ;
+ extern int *occb2ptr ;
+ extern int binX   ; 
+ extern int binY   ; 
+ 
+ extern double pinsPerLen ;
+ extern PSIDEBOX *pSideArray ;
+ extern int trackspacing ;
+ extern int pinSpacing   ;
+ extern double lapFactor ;
+ extern int (*overlap)() ;
+ extern int (*overlapf)() ;
+ extern int (*overlapx)() ;
+ extern int goverlap() ;
+ extern int goverlapf() ;
+ extern int goverlapx() ;
+ extern int woverlap() ;
+ extern int woverlapf() ;
+ extern int woverlapx() ;
+ 
+ extern int gOffsetX ;
+ extern int gOffsetY ;
+ extern int gridX ;
+ extern int gridY ;
+ extern int coreGiven ;
+ extern int gridGiven ;
+ extern int layersFactor ;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/density.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/density.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/density.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,242 ----
+ #include "geo.h"
+ #include "route.h"
+ #define DEBUG
+ extern FILE *fpo ;
+ extern int defaultTracks ;
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void density(void)
+ {
+ 
+ int net , m , eIndex , start , end , channelDensity , i ;
+ int qbot , qtop , c , count , max , width ;
+ int cell1 , cell2 , edge1 , edge2 , extraSpace1 , extraSpace2 ;
+ TNODEPTR node , *q ;
+ CHANBOXPTR cptr ;
+ PLISTPTR plptr ;
+ WCPTR ptr ;
+ CLBOXPTR clptr ;
+ 
+ for( eIndex = 1 ; eIndex <= eNum ; eIndex++ ) {
+     eArray[eIndex].root = (TNODEPTR) NULL ;
+ }
+ 
+ for( net = 1 ; net <= largestNet ; net++ ) {
+     m = netRoutes[net].currentRoute ;
+     cptr = netRoutes[net].alternate[m]->chanList ;
+     for( ; cptr != (CHANBOXPTR) NULL ; cptr = cptr->next ) {
+ 	eIndex = eIndexArray[ cptr->from ][ cptr->to ] ;
+ 	if( cptr->from == eArray[eIndex].index1 ) {
+ 	    start = cptr->foffset ;
+ 	    end   = eArray[eIndex].length - cptr->toffset ;
+ 	} else {
+ 	    start = cptr->toffset ;
+ 	    end   = eArray[eIndex].length - cptr->foffset ;
+ 	}
+ 	if( end > start ) {
+ 	    tinsert( &(eArray[eIndex].root) , start ,  1 ) ;
+ 	    tinsert( &(eArray[eIndex].root) , end + 1 , -1 ) ;
+ 	}
+     }
+ }
+ 
+ #ifdef DEBUG
+ fprintf(fpo,"CHANNEL DENSITIES:\n");    
+ #endif
+ q = (TNODEPTR *) malloc( 10001 * sizeof(TNODEPTR) ) ;
+ for( eIndex = 1 ; eIndex <= eNum ; eIndex++ ) {
+     if( eArray[eIndex].root == (TNODEPTR) NULL ) {
+ 	eArray[eIndex].density = 0 ;
+ 	continue ;
+     }
+     channelDensity = 0 ;
+     max  = 0 ;
+     qtop = 0 ;
+     qbot = 0 ;
+     q[0] = eArray[eIndex].root ;
+     while( qtop >= qbot ) {
+ 	node = q[ qbot++ ] ;
+ 	if( node->nsons > 0 ) {
+ 	    q[ ++qtop ] = node->son1 ;
+ 	    q[ ++qtop ] = node->son2 ;
+ 	    if( node->son3 != (TNODEPTR) NULL ) {
+ 		q[ ++qtop ] = node->son3 ;
+ 	    }
+ 	} else {
+ 	    plptr = node->plist ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ){
+ 		channelDensity += node->plist->property ;
+ 	    }
+ 	    if( channelDensity > max ) {
+ 		max = channelDensity ;
+ 	    }
+ 	}
+     }
+     eArray[eIndex].density = max ;
+ 
+ #ifdef DEBUG
+     fprintf(fpo,"channel:%d  node1:%d  node2:%d  density:%d\n",
+ 	eIndex, eArray[eIndex].index1, eArray[eIndex].index2, max );
+ #endif
+ 
+ }
+ free(q);
+ 
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     for( ptr = xNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	ptr->length = 0 ;
+ 	count = ptr->channels[0] ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    ptr->length += eArray[ ptr->channels[c] ].density ;
+ 	}
+ 	if( ptr->length > 0 ) {
+ 	    ptr->length += defaultTracks + 2 ;
+ 	    ptr->length *= pitch ;
+ 	} else if( defaultTracks > 0 ) {
+ 	    ptr->length = defaultTracks + 1 ;
+ 	    ptr->length *= pitch ;
+ 	}
+     }
+ }
+ 
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     for( ptr = yNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	ptr->length = 0 ;
+ 	count = ptr->channels[0] ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    ptr->length += eArray[ ptr->channels[c] ].density ;
+ 	}
+ 	if( ptr->length > 0 ) {
+ 	    ptr->length += defaultTracks + 2 ;
+ 	    ptr->length *= pitch ;
+ 	} else if( defaultTracks > 0 ) {
+ 	    ptr->length = defaultTracks + 1 ;
+ 	    ptr->length *= pitch ;
+ 	}
+     }
+ }
+ 
+ 
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     for( ptr = xNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	width = 0 ;
+ 	edge1 = eArray[ ptr->channels[1] ].edge1 ;
+ 	cell1 = edgeList[edge1].cell ;
+ 	count = ptr->channels[0] ;
+ 	edge2 = eArray[ ptr->channels[count] ].edge2 ;
+ 	cell2 = edgeList[edge2].cell ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    width += eArray[ ptr->channels[c] ].width ;
+ 	}
+ 	extraSpace1 = ptr->length / 2 ;
+ 	extraSpace2 = ptr->length - (ptr->length / 2) ;
+ 	if( cell1 > 0 ) {
+ 	    clptr = cellList[cell1] ;
+ 	    for( ; ; clptr = clptr->next ) {
+ 		if( clptr->edge == edge1 ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( width - ptr->length < clptr->compact ) {
+ 		clptr->compact = width - ptr->length ;
+ 		clptr->extraSpace = extraSpace1 ;
+ 	    }
+ 	    clptr->HorV  = 0 ;
+ 	    clptr->loc   = edgeList[edge1].loc ;
+ 	    clptr->start = edgeList[edge1].start ;
+ 	    clptr->end   = edgeList[edge1].end ;
+ 	}
+ 	if( cell2 > 0 ) {
+ 	    clptr = cellList[cell2] ;
+ 	    for( ; ; clptr = clptr->next ) {
+ 		if( clptr->edge == edge2 ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( width - ptr->length < clptr->compact ) {
+ 		clptr->compact = width - ptr->length ;
+ 		clptr->extraSpace = extraSpace2 ;
+ 	    }
+ 	    clptr->HorV  = 0 ;
+ 	    clptr->loc   = edgeList[edge2].loc ;
+ 	    clptr->start = edgeList[edge2].start ;
+ 	    clptr->end   = edgeList[edge2].end ;
+ 	}
+     }
+ }
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     for( ptr = yNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	width = 0 ;
+ 	edge1 = eArray[ ptr->channels[1] ].edge1 ;
+ 	cell1 = edgeList[edge1].cell ;
+ 	count = ptr->channels[0] ;
+ 	edge2 = eArray[ ptr->channels[count] ].edge2 ;
+ 	cell2 = edgeList[edge2].cell ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    width += eArray[ ptr->channels[c] ].width ;
+ 	}
+ 	extraSpace1 = ptr->length / 2 ;
+ 	extraSpace2 = ptr->length - (ptr->length / 2) ;
+ 	if( cell1 > 0 ) {
+ 	    clptr = cellList[cell1] ;
+ 	    for( ; ; clptr = clptr->next ) {
+ 		if( clptr->edge == edge1 ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( width - ptr->length < clptr->compact ) {
+ 		clptr->compact = width - ptr->length ;
+ 		clptr->extraSpace = extraSpace1 ;
+ 	    }
+ 	    clptr->HorV  = 1 ;
+ 	    clptr->loc   = edgeList[edge1].loc ;
+ 	    clptr->start = edgeList[edge1].start ;
+ 	    clptr->end   = edgeList[edge1].end ;
+ 	}
+ 	if( cell2 > 0 ) {
+ 	    clptr = cellList[cell2] ;
+ 	    for( ; ; clptr = clptr->next ) {
+ 		if( clptr->edge == edge2 ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( width - ptr->length < clptr->compact ) {
+ 		clptr->compact = width - ptr->length ;
+ 		clptr->extraSpace = extraSpace2 ;
+ 	    }
+ 	    clptr->HorV  = 1 ;
+ 	    clptr->loc   = edgeList[edge2].loc ;
+ 	    clptr->start = edgeList[edge2].start ;
+ 	    clptr->end   = edgeList[edge2].end ;
+ 	}
+     }
+ }
+ #ifdef DEBUG
+ for( c = 1 ; c <= numberCells ; c++ ) {
+     clptr = cellList[c] ;
+     fprintf(fpdebug,"CELL: <%d>\n",c);
+     for( ; clptr != (CLBOXPTR) NULL ; clptr = clptr->next ) {
+ 	fprintf(fpdebug,"edge:%d  extraSpace:%d  ",
+ 			clptr->edge, clptr->extraSpace ) ;
+ 	fprintf(fpdebug,"HorV:%d  loc:%d  start:%d  ",
+ 			clptr->HorV, clptr->loc, clptr->start ) ;
+ 	fprintf(fpdebug,"end:%d\n", clptr->end ) ;
+     }
+ }
+ #endif
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/doborder.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/doborder.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/doborder.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,175 ----
+ #include "custom.h"
+ #include "geo.h"
+ extern int numberCells ;
+ /* #define DEBUG */
+ 
+ int findBorder( int c , int loc , int beg , int end , int HorV );
+ 
+ void doborder(void)
+ {
+ 
+ int cell , i , orient ;
+ int l , b , r , t , xc , yc ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr , tptr , tptr0 ;
+ CLBOXPTR clptr , cl2ptr ;
+ 
+ 
+ #ifdef DEBUG
+ fprintf(fpo,"\n\nGlobal Router Wiring Space Determination:\n");
+ #endif
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+ #ifdef DEBUG
+     fprintf(fpo,"cell number: %d  with orientation: %d\n", 
+ 					cell , cellptr->orient ) ;
+ #endif
+     for( ; tileptr != TILENULL ; tileptr = tileptr->nexttile ) {
+ 	
+ 	l = tileptr->left   + xc ;
+ 	r = tileptr->right  + xc ;
+ 	b = tileptr->bottom + yc ;
+ 	t = tileptr->top    + yc ;
+ 	tileptr->lborder = findBorder( cell , l , b , t , 0 ) ;
+ 	tileptr->rborder = findBorder( cell , r , b , t , 0 ) ;
+ 	tileptr->bborder = findBorder( cell , b , l , r , 1 ) ;
+ 	tileptr->tborder = findBorder( cell , t , l , r , 1 ) ;
+ #ifdef DEBUG
+ 	fprintf(fpo,"tile:\n");
+ 	fprintf(fpo,"     left border: %d\n", tileptr->lborder ) ;
+ 	fprintf(fpo,"     top  border: %d\n", tileptr->tborder ) ;
+ 	fprintf(fpo,"     rite border: %d\n", tileptr->rborder ) ;
+ 	fprintf(fpo,"     bot  border: %d\n", tileptr->bborder ) ;
+ #endif
+     }
+     if( cellptr->orient != 0 ) {
+ 	tptr0 = cellptr->config[0] ;
+ 	tptr  = cellptr->config[cellptr->orient] ;
+ 	for( ; tptr != TILENULL ; tptr = tptr->nexttile ,
+ 				  tptr0 = tptr0->nexttile ) {
+ 	    switch( cellptr->orient ) {
+ 		case 1 : tptr0->tborder = tptr->bborder ;
+ 			 tptr0->bborder = tptr->tborder ;
+ 			 tptr0->rborder = tptr->rborder ;
+ 			 tptr0->lborder = tptr->lborder ;
+ 			 break ;
+ 		case 2 : tptr0->rborder = tptr->lborder ;
+ 			 tptr0->lborder = tptr->rborder ;
+ 			 tptr0->rborder = tptr->rborder ;
+ 			 tptr0->lborder = tptr->lborder ;
+ 			 break ;
+ 		case 3 : tptr0->tborder = tptr->bborder ;
+ 			 tptr0->bborder = tptr->tborder ;
+ 			 tptr0->rborder = tptr->lborder ;
+ 			 tptr0->lborder = tptr->rborder ;
+ 			 break ;
+ 		case 4 : tptr0->tborder = tptr->lborder ;
+ 			 tptr0->bborder = tptr->rborder ;
+ 			 tptr0->rborder = tptr->bborder ;
+ 			 tptr0->lborder = tptr->tborder ;
+ 			 break ;
+ 		case 5 : tptr0->tborder = tptr->rborder ;
+ 			 tptr0->bborder = tptr->lborder ;
+ 			 tptr0->rborder = tptr->tborder ;
+ 			 tptr0->lborder = tptr->bborder ;
+ 			 break ;
+ 		case 6 : tptr0->lborder = tptr->bborder ;
+ 			 tptr0->bborder = tptr->rborder ;
+ 			 tptr0->rborder = tptr->tborder ;
+ 			 tptr0->tborder = tptr->lborder ;
+ 			 break ;
+ 		case 7 : tptr0->lborder = tptr->tborder ;
+ 			 tptr0->bborder = tptr->lborder ;
+ 			 tptr0->rborder = tptr->bborder ;
+ 			 tptr0->tborder = tptr->rborder ;
+ 			 break ;
+ 	    }
+ 	}
+     }
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( orient == cellptr->orient ) {
+ 	    continue ;
+ 	}
+ 	tptr0 = cellptr->config[0] ;
+ 	tptr  = cellptr->config[orient] ;
+ 	for( ; tptr != TILENULL ; tptr = tptr->nexttile ,
+ 				  tptr0 = tptr0->nexttile ) {
+ 	    switch( orient ) {
+ 		case 1 : tptr->tborder = tptr0->bborder ;
+ 			 tptr->bborder = tptr0->tborder ;
+ 			 tptr->rborder = tptr0->rborder ;
+ 			 tptr->lborder = tptr0->lborder ;
+ 			 break ;
+ 		case 2 : tptr->rborder = tptr0->lborder ;
+ 			 tptr->lborder = tptr0->rborder ;
+ 			 tptr->rborder = tptr0->rborder ;
+ 			 tptr->lborder = tptr0->lborder ;
+ 			 break ;
+ 		case 3 : tptr->tborder = tptr0->bborder ;
+ 			 tptr->bborder = tptr0->tborder ;
+ 			 tptr->rborder = tptr0->lborder ;
+ 			 tptr->lborder = tptr0->rborder ;
+ 			 break ;
+ 		case 4 : tptr->tborder = tptr0->lborder ;
+ 			 tptr->bborder = tptr0->rborder ;
+ 			 tptr->rborder = tptr0->bborder ;
+ 			 tptr->lborder = tptr0->tborder ;
+ 			 break ;
+ 		case 5 : tptr->tborder = tptr0->rborder ;
+ 			 tptr->bborder = tptr0->lborder ;
+ 			 tptr->rborder = tptr0->tborder ;
+ 			 tptr->lborder = tptr0->bborder ;
+ 			 break ;
+ 		case 6 : tptr->lborder = tptr0->tborder ;
+ 			 tptr->bborder = tptr0->lborder ;
+ 			 tptr->rborder = tptr0->bborder ;
+ 			 tptr->tborder = tptr0->rborder ;
+ 			 break ;
+ 		case 7 : tptr->lborder = tptr0->bborder ;
+ 			 tptr->bborder = tptr0->rborder ;
+ 			 tptr->rborder = tptr0->tborder ;
+ 			 tptr->tborder = tptr0->lborder ;
+ 			 break ;
+ 	    }
+ 	}
+ 
+     }
+ }
+ 
+ for( i = 1 ; i <= numberCells ; i++ ) {
+     clptr = cellList[i] ;
+     while( clptr != (CLBOXPTR) NULL ) {
+ 	cl2ptr = clptr->next ;
+ 	free( clptr ) ;
+ 	clptr = cl2ptr ;
+     }
+ }
+ free( cellList ) ;
+ 
+ return ;
+ }
+ 
+ int findBorder( int c , int loc , int beg , int end , int HorV )
+ {
+ int extraSpace ;
+ CLBOXPTR clptr ;
+ 
+ extraSpace = 0 ;
+ for( clptr = cellList[c]; clptr != (CLBOXPTR) NULL; clptr = clptr->next){
+     if( clptr->HorV != HorV || clptr->loc != loc ) {
+ 	continue ;
+     }
+     if( clptr->end <= beg || clptr->start >= end ) {
+ 	continue ;
+     }
+     if( clptr->extraSpace > extraSpace ) {
+ 	extraSpace = clptr->extraSpace ;
+     }
+ }
+ 
+ return( extraSpace ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/doublecheck.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/doublecheck.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/doublecheck.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,93 ----
+ #include "custom.h"
+ 
+ void doublecheck(void)
+ {
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ CELLBOXPTR ptr ;
+ TERMBOXPTR term ;
+ TERMNETSPTR termptr ;
+ 
+ int cell , net , terminal , pin ;
+ int x , y , site ;
+ int xpos , ypos , cost , value ;
+ 
+ cost  = 0 ;
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     term = ptr->config[ptr->orient]->termptr ;
+     for( ; term != TERMNULL ; term = term->nextterm ) {
+ 	termptr = termarray[term->terminal ];
+ 	termptr->termptr->xpos = term->xpos + ptr->xcenter ;
+ 	termptr->termptr->ypos = term->ypos + ptr->ycenter ;
+     }
+     if( ptr->softflag == 1 ) {
+ 	for( pin = 1 ; pin <= ptr->numUnComTerms ; pin++ ) {
+ 	   site = ptr->unComTerms[pin].site ;
+ 	   terminal = ptr->unComTerms[pin].terminal ;
+ 	   xpos = ptr->config[ptr->orient]->siteLocArray[site].xpos;
+ 	   ypos = ptr->config[ptr->orient]->siteLocArray[site].ypos;
+ 	    
+ 	   termptr = termarray[terminal] ;
+ 	   termptr->termptr->xpos = xpos + ptr->xcenter ;
+ 	   termptr->termptr->ypos = ypos + ptr->ycenter ;
+ 	}
+     }
+ }
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     dimptr =  netarray[net] ;
+     if( dimptr->skip == 1 ) {
+ 	continue ;
+     }
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	dimptr->xmin = dimptr->xmax = netptr->xpos ;
+ 	dimptr->ymin = dimptr->ymax = netptr->ypos ;
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	x = netptr->xpos ;
+ 	y = netptr->ypos ;
+ 
+ 	if( x < dimptr->xmin ) {
+ 	    dimptr->xmin = x ;
+ 	} else if( x > dimptr->xmax ) {
+ 	    dimptr->xmax = x ;
+ 	}
+ 	if( y < dimptr->ymin ) {
+ 	    dimptr->ymin = y ;
+ 	} else if( y > dimptr->ymax ) {
+ 	    dimptr->ymax = y ;
+ 	}
+     }
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)( dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ 
+ value = 0 ;
+ for( cell = 1 ; cell <= numcells + numpads + 4 ; cell++ ) {
+     if( cell > numcells && cell <= numcells + numpads ) {
+ 	continue ;
+     }
+     value += (*overlap)( cell, cellarray[cell]->xcenter, 
+ 			      cellarray[cell]->ycenter,
+ 			      cellarray[cell]->orient , 0 , 1 , 0 ) ;
+ }
+ value /= 2 ;  
+ fprintf(fpo,"DoubleCheck Wire Cost: %d      ", cost );
+ fprintf(fpo,"Penalty: %d\n", value );
+ return;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/finalout.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/finalout.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/finalout.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,247 ----
+ #include "custom.h"
+ extern int attpercell ;
+ extern int bigcell ;
+ extern int toobig ;
+ extern int attmax ;
+ extern int doChannelGraph ;
+ extern int doGlobalRoute ;
+ extern int doCompaction ;
+ extern int bbleft , bbright , bbbottom , bbtop ;
+ extern double Tsave ;
+ int finalShot ;
+ int redoFlag ;
+ int TWsignal ;
+ 
+ extern int checkpen(void);
+ extern void addpins(void);
+ extern void doborder(void);
+ extern void subpins(void);
+ extern void gpass2( FILE *fp );
+ extern void grdcell( FILE *fp );
+ extern void rebin(int flag);
+ extern int findcost(void);
+ extern void outgeo(void);
+ extern void outpin(void);
+ extern void fixpenal(void);
+ extern void gmain(void);
+ extern void rmain(void);
+ extern void scrappin(void);
+ extern void wirecosts( int *withPads , int *withOutPads );
+ extern void initbb(void);
+ extern void utemp(void);
+ extern void finalpin(void);
+ extern void prboard(void);
+ extern void outbig(void);
+ extern void outsmall(void);
+ extern void output(void);
+ extern void savewolf(void);
+ 
+ void prepOutput(void);
+ 
+ void finalout(void)
+ {
+ FILE *fp ;
+ int c , withPads , withOutPads ;
+ char filename[1024] ;
+ char command[128] ;
+ double Tscale , bound ;
+ 
+ TWsignal = 0 ;
+ 
+ Tscale = Tsave / 100000.0 ;
+ bound = log10( Tsave ) ;
+ if( bound > 6.0 ) {
+     bound = bound - 1.0 ;
+ } else {
+     bound = 5.0 ;
+ }
+ bound = pow( 4.0 , bound ) ;
+ 
+ redoFlag = 0 ;
+ 
+ prepOutput() ;
+ 
+ sprintf(filename, "%s.cel" , cktName ) ;
+ fp = fopen( filename , "r") ;
+ 
+ gpass2( fp ) ;
+ grdcell( fp ) ;
+ fclose( fp ) ;
+ 
+ overlap  = goverlap  ;
+ overlapf = goverlapf ;
+ overlapx = goverlapx ;
+ rebin(0) ;
+ 
+ lapFactor *= 2.0 ;
+ offset = (int)( 4.0 / lapFactor ) ;
+ fprintf(fpo,"\n\nNew Value for lapFactor: %f\n", lapFactor );
+ fprintf(fpo,"New Value for offset: %d\n\n", offset );
+ 
+ funccost = findcost() ;
+ outgeo() ;
+ outpin() ;
+ 
+ if( checkpen() > 0 ) {
+ 
+     fixpenal() ;
+     redoFlag = 1 ;
+     prepOutput() ;
+     rebin(0) ;
+ 
+     funccost = findcost() ;
+     outgeo() ;
+     outpin() ;
+     if( checkpen() > 0 ) {
+ 	fprintf(fpo,"TimberWolf failed to resolve overlap problem.\n\n");
+ 	fflush(fpo);
+ 	return;
+     } else {
+ 	fprintf(fpo,"\n\nPotential Overlap Problem Averted\n\n");
+ 	fflush(fpo);
+     }
+ }
+ 
+ if( doCompaction > 0 ) {
+     finalShot = 1 ;
+     gmain() ;
+     rmain() ;
+     redoFlag = 0 ;
+     addpins() ;
+ 
+     sprintf( command , "cp %s.cfs cfss1", cktName ) ;
+     system( command ) ;
+     sprintf( command , "cp %s.cfb cfbb1", cktName ) ;
+     system( command ) ;
+ 
+     for( c = 1 ; c <= doCompaction ; c++ ) {
+ 
+ 	finalShot = c ;
+ 	if( c == doCompaction ) {
+ 	    lapFactor *= 2.0 ;
+ 	    offset = (int)( 4.0 / lapFactor ) ;
+ 	    fprintf(fpo,"\n\nNew Value for lapFactor: %f\n", lapFactor );
+ 	    fprintf(fpo,"New Value for offset: %d\n\n", offset );
+ 	}
+ 
+ 	doborder() ;
+ 	rebin(1) ;
+ 
+ 	if( c == 1 ) {
+ 	    scrappin() ;
+ 	    attmax  = 50 * numcells ;
+ 	    bigcell = numcells * 11 ;
+ 	    toobig = bigcell + 1 ;
+ 	}
+ 
+ 	/*
+ 	if( c == 1 ) {
+ 	    reconfigSides( 0.02 ) ;
+ 	}
+ 	if( c == doCompaction ) {
+ 	    reconfigSides( 0.05 ) ;
+ 	}
+ 	*/
+ 	
+ 	funccost = findcost() ;
+ 	fprintf(fpo,"\n\nCompactor Pass Number: %d\n", c ) ;
+ 	fprintf(fpo,"    begins with:  route cost: %d  overlap: %d  ",
+ 						funccost , penalty ) ;
+ 	fprintf(fpo,"  overfill: %d\n", overfill ) ;
+ 
+ 	wirecosts( &withPads , &withOutPads ) ;
+ 	fprintf(fpo,"\n\nCOMPACT #%d: TOTAL Wire Length:\n", c );
+ 	fprintf(fpo,"(before) WITH Pads: %d    WITHOUT Pads: %d\n\n",
+ 					withPads , withOutPads ) ;
+ 
+ 	initbb() ;
+ 	if( c == 1 ) {
+ 	    fprintf(fpo,"\n\nCORE Bounding Box: l:%d r:%d b:%d t:%d\n\n",
+ 			    bbleft , bbright , bbbottom , bbtop ) ;
+ 	}
+ 	/* T = 600.0 * Tscale ; */
+ 	T = log10( 0.015 * bound ) / log10( 4.0 ) ;
+ 	T = pow( 10.0 , T ) ;
+ 	utemp() ;
+ 	fprintf(fpo,"    ends with:    route cost: %d  overlap: %d  ",
+ 						funccost , penalty ) ;
+ 	fprintf(fpo,"  overfill: %d\n", overfill ) ;
+ 	fflush( fpo ) ;
+ 
+ 	/*
+ 	if( c == doCompaction ) {
+ 	    config3() ;
+ 	    funccost = findcost() ;
+ 	}
+ 	*/
+ 
+ 	prepOutput() ;
+ 	outgeo() ;
+ 	outpin() ;
+ 
+ 	rebin(0) ;
+ 	if( checkpen() > 0 ) {
+ 	    fixpenal() ;
+ 	    redoFlag = 1 ;
+ 	    prepOutput() ;
+ 	    rebin(0) ;
+ 
+ 	    funccost = findcost() ;
+ 	    outgeo() ;
+ 	    outpin() ;
+ 
+ 	    if( checkpen() > 0 ) {
+ 		fprintf(fpo,"TimberWolf failed to resolve overlap ");
+ 		fprintf(fpo,"problem.  \n Will have to die\n\n");
+ 		fflush(fpo);
+ 		return;
+ 	    }
+ 	}
+ 	wirecosts( &withPads , &withOutPads ) ;
+ 	fprintf(fpo,"\n\nCOMPACT #%d: TOTAL Wire Length:\n", c );
+ 	fprintf(fpo,"(after) WITH Pads: %d    WITHOUT Pads: %d\n\n",
+ 					withPads , withOutPads ) ;
+ 
+ 	gmain() ;
+ 	rmain() ;
+ 	redoFlag = 0 ;
+ 
+ 	sprintf( command , "cp %s.cfs cfss%d", cktName , c + 1) ;
+ 	system( command ) ;
+ 	sprintf( command , "cp %s.cfb cfbb%d", cktName , c + 1) ;
+ 	system( command ) ;
+     }
+     subpins() ;
+     fprintf(fpo,"\n\nCORE Bounding Box: l:%d r:%d b:%d t:%d\n\n",
+ 			    bbleft , bbright , bbbottom , bbtop ) ;
+ } else {
+     if( doChannelGraph ) {
+ 	gmain() ;
+     }
+     if( doGlobalRoute ) {
+ 	rmain() ;
+     }
+ }
+ 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ void prepOutput(void)
+ {
+ 
+ finalpin() ;
+ 
+ prboard () ;
+ outbig()   ;
+ outsmall() ;
+ output()   ;
+ if( finalShot == 0 ) {
+     savewolf() ;
+ }
+ 
+ return ;
+ }
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/finalpin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/finalpin.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/finalpin.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,704 ----
+ #include "custom.h"
+ int HorV ;
+ int nPinLocs ;
+ UNCOMBOX *UCptr ;
+ typedef struct flogbox {
+     int pin ;
+     int placed ;
+     int finalx ;
+     int finaly ;
+ }
+ FBOX ,
+ *FBOXPTR ;
+ FBOXPTR lArray ;
+ 
+ extern int findLoc( int pin );
+ 
+ void finalpin(void)
+ {
+ 
+ CELLBOXPTR ptr ;
+ CONTENTBOX *SCptr ;
+ LOCBOX *SLptr ;
+ double aspFactor ;
+ int cell , i , j , k , site , span , trueSpan , pin1 , overlapping ;
+ int xprev , yprev , totalPin , loc , xnext , ynext , sum ;
+ int firstLoc , lastLoc , val , isoNum , loFill , hiFill , hit ;
+ int totLeft , first , second , secLoc , prefer , lastPin ;
+ int endSeqs[101] , begSeqs[101] , conSeqs[11][101] , isolated[201] ;
+ int nextS , nextUp ;
+ 
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     if( ptr->numUnComTerms == 0 ) {
+ 	continue ;
+     }
+     SCptr = ptr->siteContent ;
+     SLptr = ptr->config[ ptr->orient ]->siteLocArray ;
+     UCptr = ptr->unComTerms ;
+     for( i = 1 ; i <= ptr->numUnComTerms ; i++ ) {
+ 	UCptr[i].finalx = -100000000 ;
+ 	UCptr[i].finaly = -100000000 ;
+     }
+     for( site = 1 ; site <= ptr->numsites ; site++ ) {
+ 	if( SCptr[ site ].contents <= 0 ) {
+ 	    continue ;
+ 	}
+ 	/* 
+ 	 *  Now we have a site with nonzero contents.
+ 	 */
+ 	span = SCptr[ site ].span ;
+ 	HorV = SCptr[ site ].HorV ;
+ 	if( ptr->orient <= 3 ) {
+ 	    aspFactor = sqrt( ptr->aspect / ptr->aspectO ) ;
+ 	} else {
+ 	    aspFactor = sqrt( ptr->aspectO / ptr->aspect ) ;
+ 	    if( HorV == 1 ) {
+ 		HorV = 0 ;
+ 	    } else {
+ 		HorV = 1 ;
+ 	    }
+ 	}
+ 	if( HorV ) {
+ 	    trueSpan = (int) ( (double) span * aspFactor ) ;
+ 	    if( (double) span - (double) trueSpan / aspFactor >
+ 		(double) (trueSpan + 1) / aspFactor -
+ 						(double) span ) {
+ 		trueSpan++ ;
+ 	    }
+ 	} else {
+ 	    trueSpan = (int) ( (double) span / aspFactor ) ;
+ 	    if( (double) span - (double) trueSpan * aspFactor >
+ 		(double) (trueSpan + 1) * aspFactor -
+ 						(double) span ) {
+ 		trueSpan++ ;
+ 	    }
+ 	}
+ 	nPinLocs = trueSpan / pinSpacing ;
+ 	if( trueSpan - nPinLocs * pinSpacing > (nPinLocs + 1) *
+ 				    pinSpacing - trueSpan ) {
+ 	    nPinLocs++ ;
+ 	}
+ 	/*  
+ 	 *   prepare the location array for the pins  
+ 	 */
+ 	lArray = (FBOXPTR) malloc( (nPinLocs + 1) * sizeof( FBOX ));
+ 	for( i = 1 ; i <= nPinLocs ; i++ ) {
+ 	    lArray[ i ].placed = 0 ;
+ 	    lArray[ i ].pin = 0 ;
+ 	    lArray[ i ].finalx = 0 ;
+ 	    lArray[ i ].finaly = 0 ;
+ 	}
+ 	/*
+ 	 *  center of trueSpan is at:
+ 	 *  SLptr[ site ].xpos  and  SLptr[ site ].ypos
+ 	 */
+ 	if( HorV ) {      /*  a vertical trueSpan  */
+ 	    if( site == ptr->numsites ) {
+ 		nextS = 1 ;
+ 	    } else {
+ 		nextS = site + 1 ;
+ 	    }
+ 	    if( SLptr[nextS].ypos > SLptr[site].ypos ) {
+ 		nextUp = 1 ;
+ 	    } else {
+ 		nextUp = 0 ;
+ 	    }
+ 	    for( i = 1 ; i <= nPinLocs ; i++ ) {
+ 		lArray[ i ].finalx = SLptr[ site ].xpos ;
+ 		if( nextUp == 0 ) {
+ 		    lArray[ i ].finaly = SLptr[ site ].ypos - 
+ 			trueSpan / 2 + (i - 1) * pinSpacing ;
+ 		} else {
+ 		    lArray[ i ].finaly = SLptr[ site ].ypos - 
+ 			(trueSpan + 1) / 2 + i * pinSpacing ;
+ 		}
+ 	    }
+ 	} else {       /* a horizontal trueSpan  */
+ 	    if( site == ptr->numsites ) {
+ 		nextS = 1 ;
+ 	    } else {
+ 		nextS = site + 1 ;
+ 	    }
+ 	    if( SLptr[nextS].xpos > SLptr[site].xpos ) {
+ 		nextUp = 1 ;
+ 	    } else {
+ 		nextUp = 0 ;
+ 	    }
+ 	    for( i = 1 ; i <= nPinLocs ; i++ ) {
+ 		lArray[ i ].finaly = SLptr[ site ].ypos ;
+ 		if( nextUp == 0 ) {
+ 		    lArray[ i ].finalx = SLptr[ site ].xpos - 
+ 			    trueSpan / 2 + (i - 1) * pinSpacing ;
+ 		} else {
+ 		    lArray[ i ].finalx = SLptr[ site ].xpos - 
+ 			(trueSpan + 1) / 2 + i * pinSpacing ;
+ 		}
+ 	    }
+ 	}
+ 
+ 	/*  initialize the storage arrays  */
+ 	for( j = 0 ; j <= 100 ; j++ ) {
+ 	    endSeqs[ j ] = 0 ;
+ 	    begSeqs[ j ] = 0 ;
+ 	    for( i = 0 ; i <= 10 ; i++ ) {
+ 		conSeqs[ i ][ j ] = 0 ;
+ 	    }
+ 	}
+ 	for( j = 0 ; j <= 200 ; j++ ) {
+ 	    isolated[ j ] = 0 ;
+ 	}
+ 
+ 	/*  Now let's look at the pins belonging to this site */
+ 
+ 	for( pin1 = 1 ; pin1 <= ptr->numUnComTerms ; pin1++ ) {
+ 	    if( UCptr[ pin1 ].site == site ) {
+ 		/*
+ 		 *  We have found a pin in this site
+ 		 */
+ 		if( UCptr[ pin1 ].sequence == 0 ) {
+ 		    /*
+ 		     *  This pin is the continuation of a
+ 		     *  sequence started in a previous site.
+ 		     *  Look at the previous pin to see
+ 		     *  what its site is.
+ 		     */
+ 		    if( endSeqs[0] == 0 ) {
+ 			xprev = SLptr[ UCptr[pin1 - 1].site ].xpos ;
+ 			yprev = SLptr[ UCptr[pin1 - 1].site ].ypos ;
+ 			if( ABS( lArray[ 1 ].finalx - xprev ) +
+ 			    ABS( lArray[ 1 ].finaly - yprev )  <
+ 			    ABS( lArray[nPinLocs].finalx - xprev ) +
+ 			    ABS( lArray[nPinLocs].finaly - yprev )){
+ 			    /*
+ 			     *  Then the previous site is nearer
+ 			     *  pin location number 1. So place this
+ 			     *  pin in location number 1.
+ 			     */
+ 			    endSeqs[0] = 1 ;
+ 			    endSeqs[1] = 1 ;
+ 			    endSeqs[2] = pin1 ;
+ 			} else {
+ 			    endSeqs[0] = 1 ;
+ 			    endSeqs[1] = nPinLocs ;
+ 			    endSeqs[2] = pin1 ;
+ 			}
+ 			for(++pin1; pin1 <= ptr->numUnComTerms; 
+ 						    pin1++){
+ 			    if( UCptr[ pin1 ].sequence != 0 ||
+ 				UCptr[ pin1 ].site != site ) {
+ 				break ;
+ 			    }
+ 			    endSeqs[ ++endSeqs[0] + 1 ] = pin1 ;
+ 			}
+ 		    } else {
+ 			fprintf(fpo,"OOPs: a endSeqs ");
+ 			fprintf(fpo,"cannot fit in the");
+ 			fprintf(fpo," site:%d\n", site );
+ 			fprintf(fpo,"TimberWolf has ");
+ 			fprintf(fpo,"to leave it out\n");
+ 			fprintf(fpo,"Current cell: %d\n", cell ) ;
+ 
+ 			for(++pin1; pin1 <= ptr->numUnComTerms; 
+ 							pin1++){
+ 			    if( UCptr[ pin1 ].sequence != 0 ||
+ 				UCptr[ pin1 ].site != site ) {
+ 				break ;
+ 			    }
+ 			}
+ 		    }
+ 		    pin1-- ;
+ 		} else if( UCptr[ pin1 ].sequence > 1 ) {
+ 		    conSeqs[ ++conSeqs[0][0] ][0] = 1 ;
+ 		    conSeqs[ conSeqs[0][0] ][2] = pin1 ;
+ 		    for(++pin1; pin1 <= ptr->numUnComTerms; pin1++){
+ 			if( UCptr[ pin1 ].sequence != 0 ||
+ 				      UCptr[ pin1 ].site != site ) {
+ 			    if( UCptr[ pin1 ].sequence == 0 ) {
+ 				/*
+ 				 *  Lo and behold, a begSeqs here.
+ 				 *  Transfer this entry in conSeqs
+ 				 *  to begSeqs and zero out the
+ 				 *  latest conSeqs entry.
+ 				 */
+ 				i = conSeqs[ conSeqs[0][0] ][0] + 1;
+ 				if( begSeqs[0] == 0 ) {
+ 				    for( ; i >= 0 ; i-- ) {
+ 					begSeqs[ i ] = conSeqs[
+ 					      conSeqs[0][0] ][ i ] ;
+ 					conSeqs[ conSeqs[0][0] ][i] 
+ 							       = 0 ;
+ 				    }
+ 				} else {
+ 				    fprintf(fpo,"OOPs: a begSeqs ");
+ 				    fprintf(fpo,"cannot fit in ");
+ 				    fprintf(fpo," site:%d\n", site);
+ 				    fprintf(fpo,"TimberWolf has t");
+ 				    fprintf(fpo,"o leave it out\n");
+ 				    fprintf(fpo,"Current cell:%d\n",
+ 							    cell ) ;
+ 				    for( ; i >= 0 ; i-- ) {
+ 					conSeqs[ conSeqs[0][0] ][i] 
+ 							       = 0 ;
+ 				    }
+ 				}
+ 				conSeqs[0][0]-- ;
+ 			    }
+ 			    break ;
+ 			}
+ 			conSeqs[ conSeqs[0][0] ]
+ 			       [ ++conSeqs[ conSeqs[0][0] ][0] + 1 ]
+ 			       = pin1 ;
+ 		    }
+ 		    pin1-- ;
+ 		} else {  /* sequence # was numero uno  */
+ 		    isolated[ 2 * ++isolated[0] ] = pin1 ;
+ 		}
+ 	    }
+ 	}
+ 	/*
+ 	 *   At this point, all the pins for a given site
+ 	 *   are in the "arrays" endSeqs, begSeqs, conSeqs,
+ 	 *   and isolated.  The next thing to do is to sort
+ 	 *   all this info out.
+ 	 */
+ 	/*
+ 	 *   First of all, do the ending sequences --- since we
+ 	 *   already know which end of the site they are
+ 	 *   coming from.  Of course, if we have any such.
+ 	 */
+ 	totalPin = endSeqs[0] ;
+ 	if( totalPin > nPinLocs ) {
+ 	    fprintf(fpo,"OOPs: an endSeqs cannot fit in site:%d\n",
+ 							  site ) ;
+ 	    fprintf(fpo,"TimberWolf will have to leave it out\n") ;
+ 	    fprintf(fpo,"Current cell: %d\n", cell ) ;
+ 	}
+ 	if( endSeqs[0] > 0 && totalPin <= nPinLocs ) {
+ 	    if( endSeqs[1] == 1 ) {
+ 		lArray[1].pin = endSeqs[2] ;
+ 		lArray[1].placed = 1 ;
+ 		loc = 1 ;
+ 		for( i = 2 ; i <= endSeqs[0] ; i++ ) {
+ 		    lArray[ ++loc ].pin = endSeqs[ i + 1 ] ;
+ 		    lArray[ loc ].placed = 1 ;
+ 		}
+ 	    } else {
+ 		lArray[ nPinLocs ].pin = endSeqs[2] ;
+ 		lArray[ nPinLocs ].placed = 1 ;
+ 		loc = nPinLocs ;
+ 		for( i = 2 ; i <= endSeqs[0] ; i++ ) {
+ 		    lArray[ --loc ].pin = endSeqs[ i + 1 ] ;
+ 		    lArray[ loc ].placed = 1 ;
+ 		}
+ 	    }
+ 	}
+ 	/*
+ 	 *  Now we have to deal with beginning sequences
+ 	 *  which begin in this site and carry on to the
+ 	 *  next site.
+ 	 */
+ 	if( begSeqs[0] > 0 && totalPin + begSeqs[0] <= nPinLocs ) {
+ 	    totalPin += begSeqs[0] ;
+ 	    lastPin = begSeqs[ begSeqs[0] + 1 ] ;
+ 	    /*
+ 	     *
+ 	     *  Look at the next pin to see
+ 	     *  what its site is.
+ 	     */
+ 	    xnext = SLptr[ UCptr[ lastPin + 1 ].site ].xpos ;
+ 	    ynext = SLptr[ UCptr[ lastPin + 1 ].site ].ypos ;
+ 	    if( ABS( lArray[ 1 ].finalx - xnext ) +
+ 		ABS( lArray[ 1 ].finaly - ynext )  <
+ 		ABS( lArray[ nPinLocs ].finalx - xnext ) +
+ 		ABS( lArray[ nPinLocs ].finaly - ynext )) {
+ 		/*
+ 		 *  Then the next site is nearer
+ 		 *  pin location number 1.  So place this
+ 		 *  pin in location number 1.
+ 		 */
+ 		lArray[1].pin = begSeqs[ begSeqs[0] + 1 ] ;
+ 		lArray[1].placed = 1 ;
+ 		loc = 1 ;
+ 		for( i = begSeqs[0] - 1 ; i >= 1 ; i-- ) {
+ 		    lArray[ ++loc ].pin = begSeqs[ i + 1 ] ;
+ 		    lArray[ loc ].placed = 1 ;
+ 		}
+ 	    } else {
+ 		lArray[ nPinLocs ].pin = begSeqs[ begSeqs[0] + 1 ] ;
+ 		lArray[ nPinLocs ].placed = 1 ;
+ 		loc = nPinLocs ;
+ 		for( i = begSeqs[0] - 1 ; i >= 1 ; i-- ) {
+ 		    lArray[ --loc ].pin = begSeqs[ i + 1 ] ;
+ 		    lArray[ loc ].placed = 1 ;
+ 		}
+ 	    }
+ 	} else if( totalPin + begSeqs[0] > nPinLocs ) {
+ 	    fprintf(fpo,"OOPs: a begSeqs cannot fit in site:%d\n",
+ 							  site ) ;
+ 	    fprintf(fpo,"TimberWolf will have to leave it out\n") ;
+ 	    fprintf(fpo,"Current cell: %d\n", cell ) ;
+ 	} 
+ 	/*
+ 	 *   Now we have a bit more work to do.  We have
+ 	 *   to examine the contained sequences and the
+ 	 *   isolated pins.  For each pin, we have to find
+ 	 *   its most desirable position in the site
+ 	 *   from location 1 thru nPinLocs.
+ 	 */
+ 	for( i = 1 ; i <= conSeqs[0][0] ; i++ ) {
+ 	    if( totalPin + conSeqs[ i ][0] > nPinLocs ) {
+ 		fprintf(fpo,"OOPs: TimberWolf has to ignore a \n");
+ 		fprintf(fpo,"contained sequence in site:%d\n",site);
+ 		fprintf(fpo,"Current cell: %d\n", cell ) ;
+ 		continue ;
+ 	    } else {
+ 		totalPin += conSeqs[ i ][0] ;
+ 	    }
+ 	    sum = 0 ;
+ 	    for( j = 1 ; j <= conSeqs[ i ][0] ; j++ ) {
+ 		if( j == 1 ) {
+ 		    firstLoc = findLoc( conSeqs[ i ][ j + 1 ] ) ;
+ 		    sum += firstLoc ;
+ 		} else if( j == conSeqs[ i ][0] ) {
+ 		    lastLoc = findLoc( conSeqs[ i ][ j + 1 ] ) ;
+ 		    sum += lastLoc ;
+ 		} else {
+ 		    sum += findLoc( conSeqs[ i ][ j + 1 ] ) ;
+ 		}
+ 	    }
+ 	    /*
+ 	     *  The average best place to go for this sequence
+ 	     *  is sum divided by conSeqs[ i ][0].
+ 	     */
+ 	    val = sum / conSeqs[ i ][0] - conSeqs[ i ][0] / 2 ; 
+ 	    if( val < 1 ) {
+ 		val = 1 ;
+ 	    } else if( val > nPinLocs - conSeqs[ i ][0] + 1 ) {
+ 		val = nPinLocs - conSeqs[ i ][0] + 1 ;
+ 	    }
+ 	    if( firstLoc > lastLoc ) {
+ 		conSeqs[ i ][1] = -val ;
+ 	    } else {
+ 		conSeqs[ i ][1] = val ;
+ 	    }
+ 	}
+ 	/*
+ 	 *   And now its finally time to deal with the isolated
+ 	 *   pins.  First, let's see if we can deal with all
+ 	 *   of them.
+ 	 */
+        
+ 	if( totalPin + isolated[0] > nPinLocs ) {
+ 	    isoNum = nPinLocs - totalPin ;
+ 	    fprintf(fpo,"OOPs: isolated pin(s) cannot fit in ");
+ 	    fprintf(fpo,"the site: %d\n", site ) ;
+ 	    fprintf(fpo,"TimberWolf will have to ignore this ");
+ 	    fprintf(fpo,"number of pins: %d\n", 
+ 				totalPin + isolated[0] - nPinLocs );
+ 	    fprintf(fpo,"Current cell: %d\n", cell ) ;
+ 	} else {
+ 	    isoNum = isolated[0] ;
+ 	}
+ 	/*
+ 	 *   Here we go
+ 	 */
+ 	for( i = 1 ; i <= isoNum ; i++ ) {
+ 	    isolated[ 2 * i - 1 ] = findLoc( isolated[ 2 * i ] ) ;
+ 	}
+ 
+ 	/*
+ 	 *   And ... Now ... Here's ...... the Pin Placer
+ 	 */
+ 	
+ 	/*
+ 	 *   One would surmise that since the beginning and
+ 	 *   ending sequences are already placed , then the
+ 	 *   next thing to do is to place the contained 
+ 	 *   sequences.  Finally, of course, the isolated pins.
+ 	 */
+ 	/*
+ 	 *   The basic method will be to establish two
+ 	 *   endpoints ( say, "left" and "right", if HorV is 0 )
+ 	 *   such that all locs to the left of "left" are
+ 	 *   filled and all locs to the right of "right" are
+ 	 *   also filled.  Then, any conSeqs wanting to start
+ 	 *   to the left of "left" will be packed tight to
+ 	 *   "left" and "left" will be updated accordingly.
+ 	 *   Similarly, all conSeqs wanting to extend beyond
+ 	 *   right will be packed tight to "right" and "right"
+ 	 *   will be updated.
+ 	 */
+ 	loFill = 0 ;
+ 	for( i = 1 ; i <= nPinLocs ; i++ ) {
+ 	    if( lArray[ i ].placed == 1 ) {
+ 		loFill = i ;
+ 	    } else {
+ 		break ;
+ 	    }
+ 	}
+ 	hiFill = nPinLocs + 1 ;
+ 	for( i = nPinLocs ; i >= 1 ; i-- ) {
+ 	    if( lArray[ i ].placed == 1 ) {
+ 		hiFill = i ;
+ 	    } else {
+ 		break ;
+ 	    }
+ 	}
+ 
+ 	hit = 1 ;
+ 	while( hit == 1 ) {
+ 	    hit = 0 ;
+ 	    for( i = 1 ; i <= conSeqs[0][0] ; i++ ) {
+ 		if( conSeqs[i][1] == 0 ) {
+ 		    continue ;
+ 		}
+ 		if( ABS( conSeqs[i][1] ) <= loFill + 1 ) {
+ 		    /*
+ 		     *  Place sequence i starting from loFill + 1
+ 		     */
+ 		    if( conSeqs[i][1] > 0 ) {
+ 			for( j = 1 ; j <= conSeqs[i][0] ; j++ ) {
+ 			    lArray[ loFill + j ].pin = 
+ 						  conSeqs[i][j+1] ;
+ 			    lArray[ loFill + j ].placed = 1 ;
+ 			}
+ 		    } else {
+ 			for( j = 1 , k = conSeqs[i][0] ; 
+ 				   j <= conSeqs[i][0] ; j++ , k--) {
+ 			    lArray[ loFill + j ].pin = 
+ 						  conSeqs[i][k+1] ;
+ 			    lArray[ loFill + j ].placed = 1 ;
+ 			}
+ 		    }
+ 		    loFill += conSeqs[i][0] ;
+ 		    conSeqs[i][1] = 0 ;
+ 		    hit = 1 ;
+ 		} else if( ABS( conSeqs[i][1] ) + 
+ 				    conSeqs[i][0] >= hiFill ) {
+ 		    /*
+ 		     *  Place sequence i starting from 
+ 		     *  hiFill - conSeqs[i][0]
+ 		     */
+ 		    if( conSeqs[i][1] > 0 ) {
+ 			for( j = hiFill - conSeqs[i][0] , k = 1 ; 
+ 				    j < hiFill ; j++ , k++ ) {
+ 			    lArray[ j ].pin = conSeqs[i][k+1] ;
+ 			    lArray[ j ].placed = 1 ;
+ 			}
+ 		    } else {
+ 			for( j = hiFill - conSeqs[i][0] , 
+ 				    k = conSeqs[i][0] ; 
+ 				    j < hiFill ; j++ , k-- ) {
+ 			    lArray[ j ].pin = conSeqs[i][k+1] ;
+ 			    lArray[ j ].placed = 1 ;
+ 			}
+ 		    }
+ 		    hiFill -= conSeqs[i][0] ;
+ 		    conSeqs[i][1] = 0 ;
+ 		    hit = 1 ;
+ 		}
+ 	    }
+ 	}
+ 	/*
+ 	 *   Ok, that was the easy placement.  Now we have to
+ 	 *   deal with any other conSeqs that may be left
+ 	 *   which apparently want to sit in the middle of
+ 	 *   the site.
+ 	 */
+ 	/*
+ 	 *   Now select the lowest-most remaining sequence.
+ 	 *   Put it in its bestPos if the other remaining
+ 	 *   sequences can fit in the remaining space above.
+ 	 *   Otherwise, back it off as necessary.
+ 	 */
+ 	totLeft = 0 ;
+ 	for( i = 1 ; i <= conSeqs[0][0] ; i++ ) {
+ 	    if( conSeqs[i][1] == 0 ) {
+ 		continue ;
+ 	    }
+ 	    totLeft += conSeqs[i][0] ;
+ 	}
+ 
+ 	while( totLeft > 0 ) {
+ 	    first = 0 ;
+ 	    second = 0 ;
+ 	    firstLoc = nPinLocs + 1 ;
+ 	    secLoc = nPinLocs + 1 ;
+ 	    for( i = 1 ; i <= conSeqs[0][0] ; i++ ) {
+ 		if( conSeqs[i][1] == 0 ) {
+ 		    continue ;
+ 		}
+ 		if( ABS( conSeqs[i][1] ) < firstLoc ) {
+ 		    if( first != 0 ) {
+ 			second = first ;
+ 			secLoc = firstLoc ;
+ 		    }
+ 		    firstLoc = ABS( conSeqs[i][1] ) ;
+ 		    first = i ;
+ 		} else if( ABS( conSeqs[i][1] ) < secLoc ) {
+ 		    secLoc = ABS( conSeqs[i][1] ) ;
+ 		    second = i ;
+ 		}
+ 	    }
+ 	    while( firstLoc + totLeft > hiFill ) {
+ 		    /*
+ 		     *   Insufficient room if we start at firstLoc
+ 		     */
+ 		firstLoc-- ;
+ 	    }
+ 		/*
+ 		 *   If secLoc intersects firstLoc to firstLoc +
+ 		 *   ( length of firstseq - 1 ) then back off
+ 		 *   firstLoc ( if possible ) by an amount
+ 		 *   equal to 1/2 of the amount of overlapping
+ 		 */
+ 	    if( secLoc < firstLoc + conSeqs[ first ][0] - 1 ) {
+ 		overlapping = firstLoc + conSeqs[ first ][0] - 1 -
+ 							secLoc ;
+ 		while( (firstLoc + 
+ 				conSeqs[ first ][0] - 1 - secLoc) > 
+ 						    overlapping / 2 ) {
+ 		    if( firstLoc - 1 > loFill ) {
+ 			firstLoc-- ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		    /*
+ 		     *  We want to place both of these sequences
+ 		     */
+ 		if( conSeqs[ first ][1] > 0 ) {
+ 		    for( j = 1 ; j <= conSeqs[ first ][0] ; j++ ) {
+ 			lArray[ firstLoc - 1 + j ].pin = 
+ 					     conSeqs[ first ][j+1] ;
+ 			lArray[ firstLoc - 1 + j ].placed = 1 ;
+ 		    }
+ 		} else {
+ 		    for( j = 1 , k = conSeqs[ first ][0] ; 
+ 			   j <= conSeqs[ first ][0] ; j++ , k--) {
+ 			lArray[ firstLoc - 1 + j ].pin = 
+ 					     conSeqs[ first ][k+1] ;
+ 			lArray[ firstLoc - 1 + j ].placed = 1 ;
+ 		    }
+ 		}
+ 		loFill = firstLoc + conSeqs[ first ][0] - 1 ;
+ 		conSeqs[ first ][1] = 0 ;
+ 		totLeft -= conSeqs[ first ][0] ;
+ 
+ 		if( conSeqs[ second ][1] > 0 ) {
+ 		    for( j = 1 ; j <= conSeqs[ second ][0] ; j++ ) {
+ 			lArray[ loFill + j ].pin = 
+ 				     conSeqs[ second ][j+1] ;
+ 			lArray[ loFill + j ].placed = 1 ;
+ 		    }
+ 		} else {
+ 		    for( j = 1 , k = conSeqs[ second ][0] ; 
+ 			   j <= conSeqs[ second ][0] ; j++ , k--) {
+ 			lArray[ loFill + j ].pin = 
+ 				     conSeqs[ second ][k+1] ;
+ 			lArray[ loFill + j ].placed = 1 ;
+ 		    }
+ 		}
+ 		loFill = loFill + conSeqs[ second ][0] ;
+ 		conSeqs[ second ][1] = 0 ;
+ 		totLeft -= conSeqs[ second ][0] ;
+ 	    } else {  /*  place only the "first" sequence  */
+ 		if( conSeqs[ first ][1] > 0 ) {
+ 		    for( j = 1 ; j <= conSeqs[ first ][0] ; j++ ) {
+ 			lArray[ firstLoc - 1 + j ].pin = 
+ 					     conSeqs[ first ][j+1] ;
+ 			lArray[ firstLoc - 1 + j ].placed = 1 ;
+ 		    }
+ 		} else {
+ 		    for( j = 1 , k = conSeqs[ first ][0] ; 
+ 			   j <= conSeqs[ first ][0] ; j++ , k--) {
+ 			lArray[ firstLoc - 1 + j ].pin = 
+ 					     conSeqs[ first ][k+1] ;
+ 			lArray[ firstLoc - 1 + j ].placed = 1 ;
+ 		    }
+ 		}
+ 		loFill = firstLoc + conSeqs[ first ][0] - 1 ;
+ 		conSeqs[ first ][1] = 0 ;
+ 		totLeft -= conSeqs[ first ][0] ;
+ 	    }
+ 	}
+ 
+ 	/*
+ 	 *   Whew!!!!  Finally to the isolated pins!
+ 	 */
+ 	/*
+ 	 *  For the first pass, any pins which can be
+ 	 *  placed exactly in their most desirable places
+ 	 *  are so placed.
+ 	 */
+ 	for( i = 1 ; i <= isoNum ; i++ ) {
+ 	    if( lArray[ isolated[ 2 * i - 1 ] ].placed == 0 ) {
+ 		lArray[ isolated[ 2 * i - 1 ] ].placed = 1 ;
+ 		lArray[ isolated[ 2 * i - 1 ] ].pin =
+ 						 isolated[ 2 * i ] ;
+ 		isolated[ 2 * i - 1 ] = 0 ;
+ 	    }
+ 	}
+ 	/*
+ 	 *  Now comes the trickier stuff for those pins which
+ 	 *  cannot go exactly where they would like to go
+ 	 */
+ 	for( i = 1 ; i <= isoNum ; i++ ) {
+ 	    prefer = isolated[ 2 * i - 1 ] ;
+ 	    if( prefer == 0 ) {
+ 		continue ;
+ 	    }
+ 	    for( k = 1 ; k < nPinLocs ; k++ ) {
+ 		if( prefer + k <= nPinLocs ) {
+ 		    if( lArray[ prefer + k ].placed == 0 ) {
+ 			lArray[ prefer + k ].placed = 1 ;
+ 			lArray[ prefer + k ].pin =
+ 						 isolated[ 2 * i ] ;
+ 			isolated[ 2 * i - 1 ] = 0 ;
+ 			break ;
+ 		    }
+ 		}
+ 		if( prefer - k >= 1 ) {
+ 		    if( lArray[ prefer - k ].placed == 0 ) {
+ 			lArray[ prefer - k ].placed = 1 ;
+ 			lArray[ prefer - k ].pin =
+ 						 isolated[ 2 * i ] ;
+ 			isolated[ 2 * i - 1 ] = 0 ;
+ 			break ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	/*
+ 	 *  Believe it or not, all the pins for this site
+ 	 *  have been placed.  Now all we have to do is
+ 	 *  put the placement information into the array
+ 	 *  pointed to by UCptr.
+ 	 */
+ 	for( i = 1 ; i <= nPinLocs ; i++ ) {
+ 	    if( lArray[ i ].placed == 1 ) {
+ 	       UCptr[ lArray[ i ].pin ].finalx = lArray[ i ].finalx;
+ 	       UCptr[ lArray[ i ].pin ].finaly = lArray[ i ].finaly;
+ 	    }
+ 	}
+ 	/*
+ 	 *   And that's it folks, for this particular site.
+ 	 *   Prep for the next one.
+ 	 */
+ 	free( lArray ) ;
+     }
+     for( i = 1 ; i <= ptr->numUnComTerms ; i++ ) {
+ 	if( UCptr[i].finalx == -100000000  && 
+ 				UCptr[i].finaly == -100000000 ) {
+ 	    /* 
+ 	     *  If at first you don't succeed, take a wild guess
+ 	     */
+ 	    UCptr[i].finalx = SLptr[ UCptr[i].site ].xpos ;
+ 	    UCptr[i].finaly = SLptr[ UCptr[i].site ].ypos ;
+ 	}
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findcheck.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findcheck.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findcheck.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,154 ----
+ #include "custom.h"
+ extern int iwire, iwirex , iwirey , icost ;
+ extern int fwire, fwirex , fwirey , fcost ;
+ 
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ 
+ void finalcheck(void)
+ {
+ 
+ FILE *fp ;
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ TILEBOXPTR tileptr ;
+ CELLBOXPTR ptr ;
+ TERMBOXPTR term ;
+ TERMNETSPTR termptr ;
+ char filename[1024] ;
+ int cell , net , terminal , pin ;
+ int x , y , site , l , r , b , t , xc , yc ;
+ int xpos , ypos , value ;
+ 
+ sprintf( filename , "%s.wat" , cktName ) ;
+ fp = fopen( filename , "w" ) ;
+ 
+ fcost  = 0 ;
+ fwire  = 0 ;
+ fwirex = 0 ;
+ fwirey = 0 ;
+ fprintf(fp,"Cell wire estimation weighting factors per side:\n");
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     if( cell <= numcells ) {
+ 	xc = cellarray[cell]->xcenter ;
+ 	yc = cellarray[cell]->ycenter ;
+ 	tileptr = cellarray[cell]->config[cellarray[cell]->orient] ;
+ 	l = xc + tileptr->left  ; 
+ 	r = xc + tileptr->right ; 
+ 	b = yc + tileptr->bottom; 
+ 	t = yc + tileptr->top   ; 
+ 	fprintf(fp,"  Cell: %s\n", cellarray[cell]->cname ) ;
+ 	fprintf(fp,"        Border for left:%d  Pin_Factor:%g\n",
+ 	    wireestx( l , b , t , tileptr->lweight ), tileptr->lweight);
+ 	fprintf(fp,"        Border for rite:%d  Pin_Factor:%g\n",
+ 	    wireestx( r , b , t , tileptr->rweight ), tileptr->rweight);
+ 	fprintf(fp,"        Border for  bot:%d  Pin_Factor:%g\n",
+ 	    wireestx( b , l , r , tileptr->bweight ), tileptr->bweight);
+ 	fprintf(fp,"        Border for  top:%d  Pin_Factor:%g\n",
+ 	    wireestx( t , l , r , tileptr->tweight ), tileptr->tweight);
+     }
+     ptr = cellarray[ cell ] ;
+     term = ptr->config[ptr->orient]->termptr ;
+     for( ; term != TERMNULL ; term = term->nextterm ) {
+ 	termptr = termarray[term->terminal ];
+ 	termptr->termptr->xpos = term->xpos + ptr->xcenter ;
+ 	termptr->termptr->ypos = term->ypos + ptr->ycenter ;
+     }
+     if( ptr->softflag == 1 ) {
+ 	for( pin = 1 ; pin <= ptr->numUnComTerms ; pin++ ) {
+ 	   site = ptr->unComTerms[pin].site ;
+ 	   terminal = ptr->unComTerms[pin].terminal ;
+ 	   xpos = ptr->config[ptr->orient]->siteLocArray[site].xpos;
+ 	   ypos = ptr->config[ptr->orient]->siteLocArray[site].ypos;
+ 	    
+ 	   termptr = termarray[terminal] ;
+ 	   termptr->termptr->xpos = xpos + ptr->xcenter ;
+ 	   termptr->termptr->ypos = ypos + ptr->ycenter ;
+ 	}
+     }
+ }
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     dimptr =  netarray[net] ;
+     if( dimptr->skip == 1 ) {
+ 	continue ;
+     }
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	dimptr->xmin = dimptr->xmax = netptr->xpos ;
+ 	dimptr->ymin = dimptr->ymax = netptr->ypos ;
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	x = netptr->xpos ;
+ 	y = netptr->ypos ;
+ 
+ 	if( x < dimptr->xmin ) {
+ 	    dimptr->xmin = x ;
+ 	} else if( x > dimptr->xmax ) {
+ 	    dimptr->xmax = x ;
+ 	}
+ 	if( y < dimptr->ymin ) {
+ 	    dimptr->ymin = y ;
+ 	} else if( y > dimptr->ymax ) {
+ 	    dimptr->ymax = y ;
+ 	}
+     }
+     fwirex += dimptr->xmax - dimptr->xmin ;
+     fwirey += dimptr->ymax - dimptr->ymin ;
+     fwire  += dimptr->xmax - dimptr->xmin + dimptr->ymax - dimptr->ymin;
+     fcost += ((int)( dimptr->Hweight *
+ 	    (double)( dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ 
+ value = 0 ;
+ for( cell = 1 ; cell <= numcells + numpads + 4 ; cell++ ) {
+     if( cell > numcells && cell <= numcells + numpads ) {
+ 	continue ;
+     }
+     value += (*overlapf)( cell, cellarray[cell]->xcenter, 
+ 			      cellarray[cell]->ycenter,
+ 			      cellarray[cell]->orient , 0 , 1 , 0 ) ;
+ }
+ value /= 2 ;  
+ fprintf(fpo,"\nFinal Overlap Penalty Function Value: %d\n", value );
+ return;
+ }
+ 
+ 
+ 
+ void initcheck(void)
+ {
+ 
+ DIMBOXPTR dimptr ;
+ 
+ int net ;
+ 
+ icost  = 0 ;
+ iwire  = 0 ;
+ iwirex = 0 ;
+ iwirey = 0 ;
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     dimptr =  netarray[net] ;
+     iwirex += dimptr->xmax - dimptr->xmin ;
+     iwirey += dimptr->ymax - dimptr->ymin ;
+     iwire  += dimptr->xmax - dimptr->xmin + dimptr->ymax - dimptr->ymin;
+     icost += ((int)( dimptr->Hweight *
+ 	    (double)( dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ return;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findcost.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findcost.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findcost.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,129 ----
+ #include "custom.h"
+ extern int finalShot ;
+ extern double Tsave ;
+ 
+ int findcost(void)
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ CELLBOXPTR cellptr , ptr ;
+ TERMBOXPTR term ;
+ TERMNETSPTR termptr ;
+ 
+ int cell , net , terminal , pin ;
+ int x , y , cost , site , contents , capacity , temp ;
+ int xpos , ypos ;
+ double Tscale ;
+ 
+ Tscale = Tsave / 100000.0 ;
+ 
+ cost = 0 ;
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[cell] ;
+     term = ptr->config[ptr->orient]->termptr ;
+     for( ; term != TERMNULL ; term = term->nextterm ) {
+ 	termptr = termarray[term->terminal ];
+ 	termptr->termptr->xpos = term->xpos + ptr->xcenter ;
+ 	termptr->termptr->ypos = term->ypos + ptr->ycenter ;
+     }
+     if( ptr->softflag == 1 ) {
+ 	for( pin = 1 ; pin <= ptr->numUnComTerms ; pin++ ) {
+ 	   site = ptr->unComTerms[pin].site ;
+ 	   terminal = ptr->unComTerms[pin].terminal ;
+ 	   xpos = ptr->config[ptr->orient]->siteLocArray[site].xpos;
+ 	   ypos = ptr->config[ptr->orient]->siteLocArray[site].ypos;
+ 	    
+ 	   termptr = termarray[terminal] ;
+ 	   termptr->termptr->xpos = xpos + ptr->xcenter ;
+ 	   termptr->termptr->ypos = ypos + ptr->ycenter ;
+ 	}
+     }
+ }
+ 
+ if( finalShot > 0 ) {
+     temp = numnets + numcells ;
+ } else {
+     temp = numnets ;
+ }
+ for( net = 1 ; net <= temp ; net++ ) {
+     dimptr =  netarray[net] ;
+     if( dimptr == DIMNULL ) {
+ 	continue ;
+     }
+     if( dimptr->skip == 1 ) {
+ 	continue ;
+     }
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	dimptr->xmin = dimptr->xmax = netptr->xpos ;
+ 	dimptr->ymin = dimptr->ymax = netptr->ypos ;
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	x = netptr->xpos ;
+ 	y = netptr->ypos ;
+ 
+ 	if( x < dimptr->xmin ) {
+ 	    dimptr->xmin = x ;
+ 	} else if( x > dimptr->xmax ) {
+ 	    dimptr->xmax = x ;
+ 	}
+ 	if( y < dimptr->ymin ) {
+ 	    dimptr->ymin = y ;
+ 	} else if( y > dimptr->ymax ) {
+ 	    dimptr->ymax = y ;
+ 	}
+     }
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)( dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ 
+ 
+ penalty = 0 ;
+ for( cell = 1 ; cell <= numcells + numpads + 4 ; cell++ ) {
+     if( cell > numcells && cell <= numcells + numpads ) {
+ 	continue ;
+     }
+     penalty += (*overlap)( cell, cellarray[cell]->xcenter, 
+ 			      cellarray[cell]->ycenter,
+ 			      cellarray[cell]->orient , 0 , 1 , 0 ) ;
+ }
+ penalty /= 2 ;  
+ 	/*  
+ 	 *    we should have found the overlap of a & b as well as
+ 	 *    b & a
+ 	 */
+ 
+ 
+ overfill = 0 ;
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     if( cellarray[ cell ]->softflag == 0 ) {
+ 	continue ;
+     }
+     cellptr = cellarray[ cell ] ;
+     for( site = 1 ; site <= cellptr->numsites ; site++ ) {
+ 	contents = cellptr->siteContent[ site ].contents ;
+ 	capacity = cellptr->siteContent[ site ].capacity ;
+ 	if( contents > capacity ) {
+ 	    temp = contents - capacity ;
+ 	    overfill += (int)(Tscale * 10.0 * (double)(temp * temp) );
+ 	}
+     }
+ }
+ return( cost ) ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findloc.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findloc.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findloc.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,308 ----
+ #include "custom.h"
+ extern int HorV ;
+ extern int nPinLocs ;
+ extern UNCOMBOX *UCptr ;
+ typedef struct flogbox {
+     int pin ;
+     int placed ;
+     int finalx ;
+     int finaly ;
+ }
+ FBOX ,
+ *FBOXPTR ;
+ extern FBOXPTR lArray ;
+ 
+ 
+ 
+ /*   
+  *   We have here a little function which 
+  *   takes as an argument the given UCpin and returns
+  *   the best possible location in the site.
+  */
+ 
+ int findLoc( int pin ) 
+ {
+ 
+ int bigoX , bigoY , litoX , litoY ;
+ int aPin , bestPos , meanx , meany , distant , i ;
+ NETBOXPTR netptr ;
+ 
+ bigoX = 0 ;
+ bigoY = 0 ;
+ litoX = 1000000000 ;
+ litoY = 1000000000 ;
+ 
+ aPin = UCptr[ pin ].terminal ;
+ 
+ netptr = netarray[ termarray[aPin]->net ]->netptr ;
+ for( ; netptr != NETNULL; netptr = netptr->nextterm ) {
+     if( netptr->terminal != aPin ) {
+ 	if( netptr->xpos < litoX ) {
+ 	    litoX = netptr->xpos ;
+ 	} 
+ 	if( netptr->xpos > bigoX ) {
+ 	    bigoX = netptr->xpos ;
+ 	}
+ 	if( netptr->ypos < litoY ) {
+ 	    litoY = netptr->ypos ;
+ 	} 
+ 	if( netptr->ypos > bigoY ) {
+ 	    bigoY = netptr->ypos ;
+ 	}
+     }
+ }
+ if( HorV ) {
+     if( lArray[ nPinLocs ].finaly > lArray[1].finaly ) {
+ 	if( litoY >= lArray[ nPinLocs ].finaly ) {
+ 	    bestPos = nPinLocs ;
+ 	} else if( bigoY <= lArray[1].finaly ) {
+ 	    bestPos = 1 ;
+ 	} else if( bigoY <= lArray[ nPinLocs ].finaly &&
+ 				   litoY >= lArray[1].finaly ) {
+ 		/*
+ 		 *   bounding box of net (sans aPin) is
+ 		 *   within span of site.  Find nearest loc
+ 		 *   (in the site) to the center of b.b.
+ 		 */
+ 	    meany = (bigoY + litoY) / 2 ;
+ 	    distant = ABS( meany - lArray[1].finaly ) ;
+ 	    for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		if( ABS( meany - lArray[i].finaly ) < distant ) {
+ 		    distant = ABS(meany - lArray[i].finaly);
+ 		} else {
+ 		    break ;
+ 		}
+ 	    }
+ 	    bestPos = i - 1 ;
+ 	} else if( bigoY >= lArray[ nPinLocs ].finaly &&
+ 				   litoY <= lArray[1].finaly ) {
+ 		/*
+ 		 *   Site is spanned (contained) by the b.b.
+ 		 *   Select middle loc.
+ 		 */
+ 	    bestPos = (nPinLocs + 1) / 2 ;
+ 	} else {  /*  only some overlapping exists  */
+ 		/*
+ 		 *   Find edge of b.b. inside site.
+ 		 */
+ 	    if( litoY < lArray[ nPinLocs ].finaly &&
+ 				litoY > lArray[ 1 ].finaly ) {
+ 		    /*
+ 		     *   Find nearest loc to litoY
+ 		     */
+ 		distant = ABS( litoY - lArray[1].finaly ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( litoY - lArray[i].finaly ) < distant ){
+ 			distant = ABS(litoY - lArray[i].finaly) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = ( i + nPinLocs ) / 2 ;
+ 	    } else {
+ 		    /*
+ 		     *   Find nearest loc to bigoY
+ 		     */
+ 		distant = ABS( bigoY - lArray[1].finaly ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( bigoY - lArray[i].finaly ) < distant ){
+ 			distant = ABS(bigoY - lArray[i].finaly) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = i / 2 ;
+ 	    }
+ 	}
+     } else {
+ 	if( litoY >= lArray[1].finaly ) {
+ 	    bestPos = 1 ;
+ 	} else if( bigoY <= lArray[ nPinLocs ].finaly ) {
+ 	    bestPos = nPinLocs ;
+ 	} else if( bigoY <= lArray[1].finaly &&
+ 			     litoY >= lArray[ nPinLocs ].finaly ) {
+ 		/*
+ 		 *   bounding box of net (sans aPin) is
+ 		 *   within span of site.  Find nearest loc
+ 		 *   (in the site) to the center of b.b.
+ 		 */
+ 	    meany = (bigoY + litoY) / 2 ;
+ 	    distant = ABS( meany - lArray[1].finaly ) ;
+ 	    for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		if( ABS( meany - lArray[i].finaly ) < distant ) {
+ 		    distant = ABS(meany - lArray[i].finaly);
+ 		} else {
+ 		    break ;
+ 		}
+ 	    }
+ 	    bestPos = i - 1 ;
+ 	} else if( bigoY >= lArray[1].finaly &&
+ 			      litoY <= lArray[ nPinLocs ].finaly ) {
+ 		/*
+ 		 *   Site is spanned (contained) by the b.b.
+ 		 *   Select middle loc.
+ 		 */
+ 	    bestPos = (nPinLocs + 1) / 2 ;
+ 	} else {  /*  only some overlapping exists  */
+ 		/*
+ 		 *   Find edge of b.b. inside site.
+ 		 */
+ 	    if( litoY < lArray[1].finaly &&
+ 			    litoY > lArray[ nPinLocs ].finaly ) {
+ 		    /*
+ 		     *   Find nearest loc to litoY
+ 		     */
+ 		distant = ABS( litoY - lArray[1].finaly ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( litoY - lArray[i].finaly ) < distant ){
+ 			distant = ABS(litoY - lArray[i].finaly) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = i / 2 ;
+ 	    } else {
+ 		    /*
+ 		     *   Find nearest loc to bigoY
+ 		     */
+ 		distant = ABS( bigoY - lArray[1].finaly ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( bigoY - lArray[i].finaly ) < distant ){
+ 			distant = ABS(bigoY - lArray[i].finaly) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = ( i + nPinLocs ) / 2 ;
+ 	    }
+ 	}
+     }
+ } else {  /*  a horizontal site  */
+     if( lArray[ nPinLocs ].finalx > lArray[1].finalx ) {
+ 	if( litoX >= lArray[ nPinLocs ].finalx ) {
+ 	    bestPos = nPinLocs ;
+ 	} else if( bigoX <= lArray[1].finalx ) {
+ 	    bestPos = 1 ;
+ 	} else if( bigoX <= lArray[ nPinLocs ].finalx &&
+ 				   litoX >= lArray[1].finalx ) {
+ 		/*
+ 		 *   bounding box of net (sans aPin) is
+ 		 *   within span of site.  Find nearest loc
+ 		 *   (in the site) to the center of b.b.
+ 		 */
+ 	    meanx = (bigoX + litoX) / 2 ;
+ 	    distant = ABS( meanx - lArray[1].finalx ) ;
+ 	    for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		if( ABS( meanx - lArray[i].finalx ) < distant ) {
+ 		    distant = ABS(meanx - lArray[i].finalx);
+ 		} else {
+ 		    break ;
+ 		}
+ 	    }
+ 	    bestPos = i - 1 ;
+ 	} else if( bigoX >= lArray[ nPinLocs ].finalx &&
+ 				   litoX <= lArray[1].finalx ) {
+ 		/*
+ 		 *   Site is spanned (contained) by the b.b.
+ 		 *   Select middle loc.
+ 		 */
+ 	    bestPos = (nPinLocs + 1) / 2 ;
+ 	} else {  /*  only some overlapping exists  */
+ 		/*
+ 		 *   Find edge of b.b. inside site.
+ 		 */
+ 	    if( litoX < lArray[ nPinLocs ].finalx &&
+ 				litoX > lArray[ 1 ].finalx ) {
+ 		    /*
+ 		     *   Find nearest loc to litoX
+ 		     */
+ 		distant = ABS( litoX - lArray[1].finalx ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( litoX - lArray[i].finalx ) < distant ){
+ 			distant = ABS(litoX - lArray[i].finalx) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = ( i + nPinLocs ) / 2 ;
+ 	    } else {
+ 		    /*
+ 		     *   Find nearest loc to bigoX
+ 		     */
+ 		distant = ABS( bigoX - lArray[1].finalx ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( bigoX - lArray[i].finalx ) < distant ){
+ 			distant = ABS(bigoX - lArray[i].finalx) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = i / 2 ;
+ 	    }
+ 	}
+     } else {
+ 	if( litoX >= lArray[1].finalx ) {
+ 	    bestPos = 1 ;
+ 	} else if( bigoX <= lArray[ nPinLocs ].finalx ) {
+ 	    bestPos = nPinLocs ;
+ 	} else if( bigoX <= lArray[1].finalx &&
+ 			     litoX >= lArray[ nPinLocs ].finalx ) {
+ 		/*
+ 		 *   bounding box of net (sans aPin) is
+ 		 *   within span of site.  Find nearest loc
+ 		 *   (in the site) to the center of b.b.
+ 		 */
+ 	    meanx = (bigoX + litoX) / 2 ;
+ 	    distant = ABS( meanx - lArray[1].finalx ) ;
+ 	    for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		if( ABS( meanx - lArray[i].finalx ) < distant ) {
+ 		    distant = ABS(meanx - lArray[i].finalx);
+ 		} else {
+ 		    break ;
+ 		}
+ 	    }
+ 	    bestPos = i - 1 ;
+ 	} else if( bigoX >= lArray[1].finalx &&
+ 			      litoX <= lArray[ nPinLocs ].finalx ) {
+ 		/*
+ 		 *   Site is spanned (contained) by the b.b.
+ 		 *   Select middle loc.
+ 		 */
+ 	    bestPos = (nPinLocs + 1) / 2 ;
+ 	} else {  /*  only some overlapping exists  */
+ 		/*
+ 		 *   Find edge of b.b. inside site.
+ 		 */
+ 	    if( litoX < lArray[1].finalx &&
+ 			    litoX > lArray[ nPinLocs ].finalx ) {
+ 		    /*
+ 		     *   Find nearest loc to litoX
+ 		     */
+ 		distant = ABS( litoX - lArray[1].finalx ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( litoX - lArray[i].finalx ) < distant ){
+ 			distant = ABS(litoX - lArray[i].finalx) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = i / 2 ;
+ 	    } else {
+ 		    /*
+ 		     *   Find nearest loc to bigoX
+ 		     */
+ 		distant = ABS( bigoX - lArray[1].finalx ) ;
+ 		for( i = 2 ; i <= nPinLocs ; i++ ) {
+ 		    if( ABS( bigoX - lArray[i].finalx ) < distant ){
+ 			distant = ABS(bigoX - lArray[i].finalx) ;
+ 		    } else {
+ 			break ;
+ 		    }
+ 		}
+ 		bestPos = ( i + nPinLocs ) / 2 ;
+ 	    }
+ 	}
+     }
+ }
+ return( bestPos ) ;
+ }  /* end of findLoc */


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findnodes.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findnodes.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findnodes.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,462 ----
+ #include "geo.h"
+ #define DEBUG
+ #ifdef DEBUG
+ extern FILE *fpNodes ;
+ #endif
+ extern int doPlacement ;
+ 
+ extern int tprop( TNODEPTR r , int value );
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ int backCheck( int l , int r , int b , int t );
+ void rectlink(void);
+ void makeRLEtree(void);
+ void makeRBEtree(void);
+ 
+ void findnodes(void)
+ {
+ 
+ DLINK1PTR hptr , vrptr , htptr , vlptr , v1ptr , v2ptr ;
+ int hedge , hstart , hend , hloc  ;
+ int htedge, htstart, htend, htloc , ht1 , ht2 ;
+ int vrend , vrstart , vrloc , vredge ;
+ int vlend , vlstart , vlloc , vledge ;
+ int l , r , b , t , last , x ;
+ int bb , tt , done , check , lt , rt ;
+ 
+ numRects  = 0 ;
+ rectArray = (RECTPTR) malloc( 100 * sizeof( RECT ) ) ;
+ 
+ last = -100000 ;
+ for( hptr = Hlist ; hptr != (DLINK1PTR) NULL ; hptr = hptr->next ) {
+     hedge = hptr->edge ;
+     if( edgeList[hedge].UorR < 0 ) {
+ 	continue ;
+     }
+     hstart = edgeList[hedge].start ;
+     hend   = edgeList[hedge].end   ;
+     hloc   = edgeList[hedge].loc   ;
+ 
+     vlptr = Vptrs[ tprop( Vroot , hstart ) ] ;
+     vrloc = -100000 ;
+     for( ; vlptr != (DLINK1PTR) NULL; vlptr = vlptr->next ){
+ 	vledge = vlptr->edge ;
+ 	if( edgeList[vledge].UorR > 0 ) {
+ 	    continue ;
+ 	}
+ 	vlloc = edgeList[vledge].loc ;
+ 	if( vlloc > hend ) {
+ 	    break ;
+ 	}
+ 	if( vlloc < vrloc ) {
+ 	    continue ;
+ 	}
+ 	vlstart = edgeList[vledge].start ;
+ 	vlend   = edgeList[vledge].end   ;
+ 	
+ 	if( vlstart > hloc || vlend < hloc ) {
+ 	    continue ;
+ 	}
+ 	if( edgeList[hedge].fixed == 0 ) {
+ 	    if( !( (edgeList[vledge].fixed == 0) ||
+ 		   (edgeList[vledge].fixed == 1 && vlloc == hstart) ) ){
+ 		continue ;
+ 	    }
+ 	} else {
+ 	    if( edgeList[vledge].fixed == 1 && vlend == hloc ) {
+ 		continue ;
+ 	    }
+ 	}
+ 
+ 	b  = hloc  ;
+ 	l  = vlloc ;
+ 
+ 	vrptr = Vptrs[ tprop( Vroot , hstart ) ] ;
+ 	for( ; vrptr != (DLINK1PTR) NULL; vrptr = vrptr->next ) {
+ 	    vredge = vrptr->edge ;
+ 	    if( edgeList[vredge].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    vrloc = edgeList[vredge].loc ;
+ 	    if( ! (vrloc >= vlloc)  ) {
+ 		continue ;
+ 	    }
+ 	    vrstart = edgeList[vredge].start ;
+ 	    vrend   = edgeList[vredge].end   ;
+ 	
+ 	    if( vrstart > hloc || vrend < hloc ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[hedge].fixed == 0 ) {
+ 		if( !( (edgeList[vredge].fixed == 0) ||
+ 		       (edgeList[vredge].fixed == 1 && vrloc == hend) ) ){
+ 		    continue ;
+ 		}
+ 	    } else {
+ 		if( edgeList[vredge].fixed == 1 && vrend == hloc ) {
+ 		    continue ;
+ 		}
+ 	    }
+ 
+ 	    r  = vrloc  ;
+ 
+ 	    htptr = Hptrs[ tprop( Hroot , hloc ) ] ;
+ 	    done = 0 ;
+ 	    for( ; htptr != (DLINK1PTR) NULL ; htptr = htptr->next ) {
+ 		htedge = htptr->edge ;
+ 		if( edgeList[htedge].UorR > 0 ) {
+ 		    continue ;
+ 		}
+ 		htloc = edgeList[htedge].loc ;
+ 		if( ! (htloc >= hloc) ) {
+ 		    continue ;
+ 		}
+ 		htstart = edgeList[htedge].start ;
+ 		htend   = edgeList[htedge].end   ;
+ 		if( htstart > r || htend < l ) {
+ 		    continue ;
+ 		}
+ 		if( r == l ) { 
+ 		    if( (htstart < l || (htstart == l && 
+ 					 (edgeList[htedge].fixed == 0 ||
+ 					 (edgeList[htedge].UorR < 0 &&
+ 					  edgeList[ edgeList[htedge].
+ 					  nextEdge ].UorR < 0) ) )) && 
+ 				      (htend > r || (htend == r &&
+ 					 (edgeList[htedge].fixed == 0 ||
+ 					 (edgeList[htedge].UorR < 0 &&
+ 					  edgeList[ edgeList[htedge].
+ 					  prevEdge ].UorR > 0 ) ) )) ) {
+ 			ht1 = ht2 = htedge ;
+ 			done = 4 ;
+ 		    }
+ 		} else {
+ 		    if( done == 0 ) {
+ 			if( (htstart < l || (htstart == l && 
+ 					 (edgeList[htedge].fixed == 0 ||
+ 					 (edgeList[htedge].UorR < 0 &&
+ 					  edgeList[ edgeList[htedge].
+ 					  nextEdge ].UorR < 0) ) )) && 
+ 				  (htend > l || (htend == l &&
+ 				     edgeList[htedge].fixed == 0 )) ) {
+ 
+ 			    if( (htstart < r || (htstart == r && 
+ 				      edgeList[htedge].fixed == 0 )) && 
+ 				  (htend > r || (htend == r &&
+ 					 (edgeList[htedge].fixed == 0 ||
+ 					 (edgeList[htedge].UorR < 0 &&
+ 					  edgeList[ edgeList[htedge].
+ 					  prevEdge ].UorR > 0 ) ) )) ) {
+ 				ht1 = ht2 = htedge ;
+ 				done = 4 ;
+ 			    }
+ 			}
+ 		    }
+ 		    if( done == 1 || done == 0 ) {
+ 			if( (htstart < r || (htstart == r && 
+ 				      edgeList[htedge].fixed == 0 )) && 
+ 				  (htend > r || (htend == r &&
+ 					 (edgeList[htedge].fixed == 0 ||
+ 					 (edgeList[htedge].UorR < 0 &&
+ 					  edgeList[ edgeList[htedge].
+ 					  prevEdge ].UorR > 0 ) ) )) ) {
+ 			    ht2 = htedge ;
+ 			    if( done == 1 ) {
+ 				done = 3 ;
+ 			    } else {
+ 				done = 2 ;
+ 			    }
+ 			}
+ 		    }
+ 		    if( done == 2 || done == 0 ) {
+ 			if( (htstart < l || (htstart == l && 
+ 					 (edgeList[htedge].fixed == 0 ||
+ 					 (edgeList[htedge].UorR < 0 &&
+ 					  edgeList[ edgeList[htedge].
+ 					  nextEdge ].UorR < 0) ) )) && 
+ 				  (htend > l || (htend == l &&
+ 				     edgeList[htedge].fixed == 0 )) ) {
+ 			    ht1 = htedge ;
+ 			    if( done == 2 ) {
+ 				done = 3 ;
+ 			    } else {
+ 				done = 1 ;
+ 			    }
+ 			}
+ 		    }
+ 		}
+ 		if( done < 3 ) {
+ 		    continue ;
+ 		} else {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( done < 3 ) {
+ 		break ;
+ 	    }
+ 	    t = htloc  ;
+ 	    if( edgeList[ht1].loc < edgeList[ht2].loc ) {
+ 		lt = edgeList[ht2].start ;
+ 		rt = edgeList[ht2].end   ;
+ 	    } else if( edgeList[ht1].loc > edgeList[ht2].loc ) {
+ 		lt = edgeList[ht1].start ;
+ 		rt = edgeList[ht1].end   ;
+ 	    } else {
+ 		lt = edgeList[ht1].start ;
+ 		rt = edgeList[ht2].end   ;
+ 	    }
+ 	    if( vlend <= t && lt < l ) {
+ 		check = edgeList[ht1].fixed ;
+ 		v1ptr = Vptrs[ tprop( Vroot , l ) ] ;
+ 		x = edgeList[ v1ptr->edge ].loc ;
+ 		v1ptr = v1ptr->next ;
+ 		for( ; v1ptr != (DLINK1PTR) NULL; 
+ 				v1ptr = v1ptr->next ){
+ 		    if( edgeList[ v1ptr->edge ].loc > x ) {
+ 			break ;
+ 		    }
+ 		}
+ 		v1ptr = v1ptr->prev ;
+ 		for( ; v1ptr != (DLINK1PTR) NULL; 
+ 				v1ptr = v1ptr->prev ){
+ 		    if( edgeList[ v1ptr->edge ].UorR > 0 ) {
+ 			continue ;
+ 		    }
+ 		    tt = edgeList[ v1ptr->edge ].end ;
+ 		    bb = edgeList[ v1ptr->edge ].start ;
+ 
+ 		    if( bb > t || tt < t ) {
+ 			continue ;
+ 		    }
+ 		    if( check ) {
+ 			if( bb == t && tt > bb ) {
+ 			    continue ;
+ 			}
+ 		    } else {
+ 			if( (edgeList[ v1ptr->edge ].fixed == 1) &&
+ 					    (bb == t || tt == t) ) {
+ 			    continue ;
+ 			}
+ 		    }
+ 		    l = edgeList[ v1ptr->edge ].loc ;
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( vrend <= t && rt > r ) {
+ 		check = edgeList[ht2].fixed ;
+ 		v2ptr = Vptrs[ tprop( Vroot , r ) ] ;
+ 		for( ; v2ptr != (DLINK1PTR) NULL; 
+ 				v2ptr = v2ptr->next ){
+ 		    if( edgeList[ v2ptr->edge ].UorR < 0 ) {
+ 			continue ;
+ 		    }
+ 		    tt = edgeList[ v2ptr->edge ].end ;
+ 		    bb = edgeList[ v2ptr->edge ].start ;
+ 
+ 		    if( bb > t || tt < t ) {
+ 			continue ;
+ 		    }
+ 		    if( check ) {
+ 			if( bb == t && tt > bb ) {
+ 			    continue ;
+ 			}
+ 		    } else {
+ 			if( (edgeList[ v2ptr->edge ].fixed == 1) &&
+ 					    (bb == t || tt == t) ) {
+ 			    continue ;
+ 			}
+ 		    }
+ 		    r = edgeList[ v2ptr->edge ].loc ;
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( backCheck( l , r , b , t ) ) {
+ 		break ;
+ 	    }
+ 	    if( ++numRects % 100 == 0 ) {
+ 		rectArray = (RECTPTR) realloc( rectArray ,
+ 			    (numRects + 100) * sizeof(RECT) ) ;
+ 	    }
+ 	    rectArray[numRects].l = l   ;
+ 	    rectArray[numRects].r = r   ;
+ 	    rectArray[numRects].b = b   ;
+ 	    rectArray[numRects].t = t   ;
+ 	    rectArray[numRects].ur = 0  ;
+ 	    rectArray[numRects].ul = 0  ;
+ 	    rectArray[numRects].lr = 0  ;
+ 	    rectArray[numRects].ll = 0  ;
+ 	    rectArray[numRects].xc = (l + r) / 2 ;
+ 	    rectArray[numRects].yc = (b + t) / 2 ;
+ 	    rectArray[numRects].xreset = 0 ;
+ 	    rectArray[numRects].yreset = 0 ;
+ 	    tinsert( &hRectRoot , l , numRects ) ;
+ 	    tinsert( &vRectRoot , b , numRects ) ;
+ #ifdef DEBUG
+ 	    fprintf(fpdebug,"rect Node: %d  at: %d %d ",
+ 			numRects , rectArray[numRects].xc ,
+ 			rectArray[numRects].yc ) ;
+ 	    fprintf(fpdebug,"  width:%d  height:%d\n",
+ 				     r - l , t - b ) ;
+ 	    if( doPlacement ) {
+ 		fprintf(fpNodes,"L NC;\n94 X%d %d %d;\n",
+ 			    numRects , (r + l)/2 , (t + b)/2 );
+ 	    }
+ #endif
+ 	    break ;
+ 	}
+     }
+ }
+ rectlink() ;
+ makeRLEtree() ;
+ makeRBEtree() ;
+ 
+ #ifdef DEBUG
+ if( doPlacement ) {
+     fprintf( fpNodes , "E\n" );
+     fclose( fpNodes ) ;
+ }
+ #endif
+ 
+ return ;
+ }
+ 
+ 
+ 
+ int backCheck( int l , int r , int b , int t )
+ {
+ 
+ int rec , lChk , rChk , bChk , tChk ;
+ 
+ for( rec = numRects ; rec >= 1 ; rec-- ) {
+     lChk = rectArray[rec].l ;
+     rChk = rectArray[rec].r ;
+     if( l > rChk || r < lChk ) {
+ 	continue ;
+     }
+     break ;
+ }
+ if( rec == 0 ) {
+     return(0) ;
+ } else {
+     bChk = rectArray[rec].b ;
+     tChk = rectArray[rec].t ;
+     if( b > tChk || t < bChk ) {
+ 	return(0) ;
+     } else {
+ 	return(1) ;
+     }
+ }
+ }
+ 
+ 
+ void rectlink(void)
+ {
+ 
+ TNODEPTR junkptr ;
+ DLINK2PTR ptr , pptr ;
+ int center , index ;
+ 
+ HRlist = (DLINK2PTR) NULL ;
+ VRlist = (DLINK2PTR) NULL ;
+ 
+ tpop( &hRectRoot , &junkptr , &center , &index ) ;
+ if( junkptr == (TNODEPTR) NULL ) {
+     return ;
+ }
+ HRlist = (DLINK2PTR) malloc( sizeof( DLINK2 ) ) ;
+ HRlist->index  = index  ;
+ HRlist->next = (DLINK2PTR) NULL ;
+ HRlist->prev = (DLINK2PTR) NULL ;
+ 
+ tpop( &vRectRoot , &junkptr , &center , &index ) ;
+ VRlist = (DLINK2PTR) malloc( sizeof( DLINK2 ) ) ;
+ VRlist->index  = index  ;
+ VRlist->next = (DLINK2PTR) NULL ;
+ VRlist->prev = (DLINK2PTR) NULL ;
+ 
+ pptr = HRlist ;
+ for( ; ; ) {
+     tpop( &hRectRoot , &junkptr , &center , &index ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = (DLINK2PTR) malloc( sizeof( DLINK2 ) ) ;
+     ptr->index  = index ;
+     ptr->prev = pptr ;
+     ptr->next = (DLINK2PTR) NULL ;
+     pptr->next = ptr ;
+     pptr = ptr ;
+ }
+ 
+ pptr = VRlist ;
+ for( ; ; ) {
+     tpop( &vRectRoot , &junkptr , &center , &index ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = (DLINK2PTR) malloc( sizeof( DLINK2 ) ) ;
+     ptr->index  = index ;
+     ptr->prev = pptr ;
+     ptr->next = (DLINK2PTR) NULL ;
+     pptr->next = ptr ;
+     pptr = ptr ;
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void makeRLEtree(void)
+ {
+ 
+ DLINK2PTR leptr ;
+ int last , index , count ;
+ 
+ LEroot = (TNODEPTR) NULL ;
+ LEptrs = (DLINK2PTR *) malloc( 100 * sizeof(DLINK2PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( leptr = HRlist ; leptr != (DLINK2PTR) NULL ; leptr = leptr->next ){
+     index = leptr->index ;
+     if( rectArray[index].l > last ) {
+ 	last = rectArray[index].l ;
+ 	if( ++count % 100 == 0 ) {
+ 	    LEptrs = (DLINK2PTR *) realloc( LEptrs ,
+ 				(count + 100) * sizeof(DLINK2PTR) ) ;
+ 	}
+ 	LEptrs[count] = leptr ;
+ 	tinsert( &LEroot , last , count ) ;
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void makeRBEtree(void)
+ {
+ 
+ DLINK2PTR beptr ;
+ int last , index , count ;
+ 
+ BEroot = (TNODEPTR) NULL ;
+ BEptrs = (DLINK2PTR *) malloc( 100 * sizeof(DLINK2PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( beptr = VRlist ; beptr != (DLINK2PTR) NULL ; beptr = beptr->next ){
+     index = beptr->index ;
+     if( rectArray[index].b > last ) {
+ 	last = rectArray[index].b ;
+ 	if( ++count % 100 == 0 ) {
+ 	    BEptrs = (DLINK2PTR *) realloc( BEptrs ,
+ 				(count + 100) * sizeof(DLINK2PTR) ) ;
+ 	}
+ 	BEptrs[count] = beptr ;
+ 	tinsert( &BEroot , last , count ) ;
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findside.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findside.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/findside.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,34 ----
+ #include "custom.h"
+ 
+ int findside( CELLBOXPTR cellptr , int x , int y )
+ {
+ 
+ int k , min , kmin ;
+ 
+ min = 10000000 ;
+ for( k = 1 ; k <= cellptr->numsides ; k++ ) {
+     if( pSideArray[k].vertical == 1 ) {
+ 	if( ABS(x - pSideArray[k].position) < min ) {
+ 	    min = ABS(x - pSideArray[k].position) ;
+ 	    kmin = k ;
+ 	}
+     } else {
+ 	if( ABS(y - pSideArray[k].position) < min ) {
+ 	    min = ABS(y - pSideArray[k].position) ;
+ 	    kmin = k ;
+ 	}
+     }
+ }
+ return( kmin ) ;
+ 
+ }
+ 
+ 
+ 
+ void loadside( int side , double factor )
+ {
+ 
+ pSideArray[side].pincount += factor ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fixpenal.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fixpenal.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fixpenal.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,347 ----
+ #include "custom.h"
+ #define L 1
+ #define T 2
+ #define R 3
+ #define B 4
+ int dx , dy ;
+ 
+ int whoOverlaps( int cell , int xc , int yc , int orient , int b , 
+ 		int flag , int borient );
+ void padOverlaps(void);
+ 
+ void fixpenal(void)
+ {
+ 
+ int cell , other , d , bx , by , d1 , d2 ;
+ int problems ;
+ 
+ bx = (blockr + blockl) / 2 ;
+ by = (blockt + blockb) / 2 ;
+ 
+ problems = 1 ;
+ while( problems ) {
+     problems = 0 ;
+     for( cell = 1 ; cell <= numcells ; cell++ ) {
+ 	other = whoOverlaps( cell, cellarray[cell]->xcenter, 
+ 				  cellarray[cell]->ycenter,
+ 				  cellarray[cell]->orient , 0 , 1 , 0 ) ;
+ 	if( other > 0 ) {
+ 	    d1 = (int) sqrt((double)((ABS(cellarray[cell]->xcenter - bx) *
+ 			      ABS(cellarray[cell]->xcenter - bx)) +
+ 			     (ABS(cellarray[cell]->ycenter - by) *
+ 			      ABS(cellarray[cell]->ycenter - by)) ) ) ;
+ 	    d2 = (int) sqrt((double)((ABS(cellarray[other]->xcenter - bx) *
+ 			      ABS(cellarray[other]->xcenter - bx)) +
+ 			     (ABS(cellarray[other]->ycenter - by) *
+ 			      ABS(cellarray[other]->ycenter - by)) ) ) ;
+ 	    if( dx == 0 ) {
+ 		dx = 1000000 ;
+ 	    }
+ 	    if( dy == 0 ) {
+ 		dy = 1000000 ;
+ 	    }
+ 	    d = (dx <= dy) ? dx : dy ;
+ 	    if( d == dx ) {
+ 		if( d1 > d2 ) {
+ 		    if( cellarray[cell]->xcenter > bx ) {
+ 			cellarray[cell]->xcenter += d ;
+ 		    } else {
+ 			cellarray[cell]->xcenter -= d ;
+ 		    }
+ 		} else {
+ 		    if( cellarray[other]->xcenter > bx ) {
+ 			cellarray[other]->xcenter += d ;
+ 		    } else {
+ 			cellarray[other]->xcenter -= d ;
+ 		    }
+ 		}
+ 	    } else {
+ 		if( d1 > d2 ) {
+ 		    if( cellarray[cell]->ycenter > by ) {
+ 			cellarray[cell]->ycenter += d ;
+ 		    } else {
+ 			cellarray[cell]->ycenter -= d ;
+ 		    }
+ 		} else {
+ 		    if( cellarray[other]->ycenter > by ) {
+ 			cellarray[other]->ycenter += d ;
+ 		    } else {
+ 			cellarray[other]->ycenter -= d ;
+ 		    }
+ 		}
+ 	    }
+ 	    cell-- ;
+ 	    problems = 1 ;
+ 	}
+     }
+ }
+ padOverlaps() ;
+ 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ int whoOverlaps( int cell , int xc , int yc , int orient , int b , 
+                   int flag , int borient )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr1 , tileptr2 , tileptr01, tileptr02 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ dx = 0 ;
+ dy = 0 ;
+ 
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ orient ]  ;
+ 
+ startx01 = xc + tileptr01->left    ;
+ endx01   = xc + tileptr01->right   ;
+ starty01 = yc + tileptr01->bottom  ;
+ endy01   = yc + tileptr01->top     ;
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell || othercell > numcells ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    if( othercell != b ) {
+ 		tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 		xcenter = cellptr2->xcenter ;
+ 		ycenter = cellptr2->ycenter ;
+ 	    } else if( flag == 0 ) {
+ 		tileptr02 = cellptr2->config[borient] ;
+ 		xcenter = cellptr1->xcenter ;
+ 		ycenter = cellptr1->ycenter ;
+ 	    } else {
+ 		continue ;
+ 	    }
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 
+ 		dx = endx - startx ;
+ 		dy = endy - starty ;
+ 		return( othercell ) ;
+ 	    } else {
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    startx1 =  xc + tileptr1->left   ;
+ 		    endx1   =  xc + tileptr1->right  ;
+ 		    starty1 =  yc + tileptr1->bottom ;
+ 		    endy1   =  yc + tileptr1->top    ;
+ 		
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 	
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			if( dx > 0 ) {
+ 			    if( endx - startx < dx ) {
+ 				dx = endx - startx ;
+ 			    }
+ 			} else {
+ 			    dx = endx - startx ;
+ 			}
+ 			if( dy > 0 ) {
+ 			    if( endy - starty < dy ) {
+ 				dy = endy - starty ;
+ 			    }
+ 			} else {
+ 			    dy = endy - starty ;
+ 			}
+ 		    }
+ 		}
+ 		if( dx != 0 || dy != 0 ) {
+ 		    return( othercell ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return(0) ;
+ }
+ 
+ 
+ 
+ void padOverlaps(void)
+ {
+ 
+ CELLBOXPTR cellptr , padptr ;
+ TILEBOXPTR tileptr ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int deltaX , deltaY , pad , cell ;
+ 
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     tileptr = cellptr->config[cellptr->orient] ;
+ 
+     startx1 = cellptr->xcenter + tileptr->left   ;
+     endx1   = cellptr->xcenter + tileptr->right  ;
+     starty1 = cellptr->ycenter + tileptr->bottom ;
+     endy1   = cellptr->ycenter + tileptr->top    ;
+ 
+     if( startx1 >= blockl && endx1 <= blockr &&
+ 			    starty1 >= blockb && endy1 <= blockt ) {
+ 	continue ;
+     }
+     if( startx1 < blockl ) {
+ 	for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ){
+ 	    padptr = cellarray[pad] ;
+ 	    if( padptr->padside != L ) {
+ 		continue ;
+ 	    }
+ 	    deltaX = padptr->xcenter + 
+ 			padptr->config[padptr->orient]->right - startx1 ;
+ 	    if( deltaX <= 0 ) {
+ 		break ;
+ 	    }
+ 	    for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 		padptr = cellarray[pad] ;
+ 		if( padptr->padside == L ) {
+ 		    padptr->xcenter -= deltaX ;
+ 		}
+ 	    }
+ 	    break ;
+ 	}
+     } else if( endx1 > blockr ) {
+ 	for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ){
+ 	    padptr = cellarray[pad] ;
+ 	    if( padptr->padside != R ) {
+ 		continue ;
+ 	    }
+ 	    deltaX = endx1 - ( padptr->xcenter + 
+ 			padptr->config[padptr->orient]->left ) ;
+ 	    if( deltaX <= 0 ) {
+ 		break ;
+ 	    }
+ 	    for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 		padptr = cellarray[pad] ;
+ 		if( padptr->padside == R ) {
+ 		    padptr->xcenter += deltaX ;
+ 		}
+ 	    }
+ 	    break ;
+ 	}
+     } else if( starty1 < blockb ) {
+ 	for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ){
+ 	    padptr = cellarray[pad] ;
+ 	    if( padptr->padside != B ) {
+ 		continue ;
+ 	    }
+ 	    deltaY = padptr->ycenter + 
+ 			padptr->config[padptr->orient]->top - starty1 ;
+ 	    if( deltaY <= 0 ) {
+ 		break ;
+ 	    }
+ 	    for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 		padptr = cellarray[pad] ;
+ 		if( padptr->padside == B ) {
+ 		    padptr->ycenter -= deltaY ;
+ 		}
+ 	    }
+ 	    break ;
+ 	}
+     } else if( endy1 > blockt ) {
+ 	for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ){
+ 	    padptr = cellarray[pad] ;
+ 	    if( padptr->padside != T ) {
+ 		continue ;
+ 	    }
+ 	    deltaY = endy1 - ( padptr->ycenter + 
+ 			padptr->config[padptr->orient]->bottom ) ;
+ 	    if( deltaY <= 0 ) {
+ 		break ;
+ 	    }
+ 	    for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 		padptr = cellarray[pad] ;
+ 		if( padptr->padside == T ) {
+ 		    padptr->ycenter += deltaY ;
+ 		}
+ 	    }
+ 	    break ;
+ 	}
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fulllink.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fulllink.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fulllink.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,194 ----
+ #include "geo.h"
+ 
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+                   int *property);
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void makeVertDownTree(void);
+ void makeHoriRiteTree(void);
+ void makeVertTree(void);
+ void makeHoriTree(void);
+ 
+ void fulllink(void)
+ {
+ 
+ TNODEPTR junkptr ;
+ DLINK1PTR ptr , pptr , nptr ;
+ int location , index ;
+ 
+ Hlist = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ Hlist->edge = edgeCount ;
+ Hlist->next = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ Hlist->prev = (DLINK1PTR) NULL ;
+ Hlist->next->next = (DLINK1PTR) NULL ;
+ Hlist->next->prev = Hlist ;
+ Hlist->next->edge = edgeCount - 2 ;
+ Hend = Hlist->next ;
+ 
+ Vlist = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ Vlist->edge = edgeCount - 3 ;
+ Vlist->next = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ Vlist->prev = (DLINK1PTR) NULL ;
+ Vlist->next->next = (DLINK1PTR) NULL ;
+ Vlist->next->prev = Vlist ;
+ Vlist->next->edge = edgeCount - 1 ;
+ Vend = Vlist->next ;
+ 
+ pptr = Hlist ;
+ nptr = Hlist->next ;
+ for( ; ; ) {
+     tpop( &hEdgeRoot , &junkptr , &location , &index ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+     ptr->edge = index ;
+     ptr->prev = pptr ;
+     ptr->next = nptr ;
+     pptr->next = ptr ;
+     nptr->prev = ptr ;
+     pptr = ptr ;
+ }
+ 
+ pptr = Vlist ;
+ nptr = Vlist->next ;
+ for( ; ; ) {
+     tpop( &vEdgeRoot , &junkptr , &location , &index ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+     ptr->edge = index ;
+     ptr->prev = pptr ;
+     ptr->next = nptr ;
+     pptr->next = ptr ;
+     nptr->prev = ptr ;
+     pptr = ptr ;
+ }
+ 
+ makeVertDownTree() ;
+ makeHoriRiteTree() ;
+ makeVertTree()     ;
+ makeHoriTree()     ;
+ 
+ return ;
+ }
+ 
+ void makeVertTree(void)
+ {
+ 
+ DLINK1PTR vptr ;
+ int last , edge , count ;
+ 
+ Vroot = (TNODEPTR) NULL ;
+ Vptrs = (DLINK1PTR *) malloc( 100 * sizeof(DLINK1PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( vptr = Vlist ; vptr != (DLINK1PTR) NULL ; vptr = vptr->next ) {
+     edge = vptr->edge ;
+     if( edgeList[edge].loc > last ) {
+ 	last = edgeList[edge].loc ;
+ 	if( ++count % 100 == 0 ) {
+ 	    Vptrs = (DLINK1PTR *) realloc( Vptrs ,
+ 				(count + 100) * sizeof(DLINK1PTR) ) ;
+ 	}
+ 	Vptrs[count] = vptr ;
+ 	tinsert( &Vroot , last , count ) ;
+     }
+ }
+ 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ void makeHoriTree(void)
+ {
+ 
+ DLINK1PTR hptr ;
+ int last , edge , count ;
+ 
+ Hroot = (TNODEPTR) NULL ;
+ Hptrs = (DLINK1PTR *) malloc( 100 * sizeof(DLINK1PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( hptr = Hlist ; hptr != (DLINK1PTR) NULL ; hptr = hptr->next ) {
+     edge = hptr->edge ;
+     if( edgeList[edge].loc > last ) {
+ 	last = edgeList[edge].loc ;
+ 	if( ++count % 100 == 0 ) {
+ 	    Hptrs = (DLINK1PTR *) realloc( Hptrs ,
+ 				(count + 100) * sizeof(DLINK1PTR) ) ;
+ 	}
+ 	Hptrs[count] = hptr ;
+ 	tinsert( &Hroot , last , count ) ;
+     }
+ }
+ 
+ return ;
+ }
+ 
+ void makeVertDownTree(void)
+ {
+ 
+ DLINK1PTR vptr ;
+ int last , edge , count ;
+ 
+ VDroot = (TNODEPTR) NULL ;
+ VDptrs = (DLINK1PTR *) malloc( 100 * sizeof(DLINK1PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( vptr = Vlist ; vptr != (DLINK1PTR) NULL ; vptr = vptr->next ) {
+     edge = vptr->edge ;
+     if( edgeList[edge].UorR > 0 ) {
+ 	continue ;
+     }
+     if( edgeList[edge].loc > last ) {
+ 	last = edgeList[edge].loc ;
+ 	if( ++count % 100 == 0 ) {
+ 	    VDptrs = (DLINK1PTR *) realloc( VDptrs ,
+ 				(count + 100) * sizeof(DLINK1PTR) ) ;
+ 	}
+ 	VDptrs[count] = vptr ;
+ 	tinsert( &VDroot , last , count ) ;
+     }
+ }
+ 
+ return ;
+ }
+ 
+ 
+ 
+ void makeHoriRiteTree(void)
+ {
+ 
+ DLINK1PTR hptr ;
+ int last , edge , count ;
+ 
+ HRroot = (TNODEPTR) NULL ;
+ HRptrs = (DLINK1PTR *) malloc( 100 * sizeof(DLINK1PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( hptr = Hlist ; hptr != (DLINK1PTR) NULL ; hptr = hptr->next ) {
+     edge = hptr->edge ;
+     if( edgeList[edge].UorR < 0 ) {
+ 	continue ;
+     }
+     if( edgeList[edge].loc > last ) {
+ 	last = edgeList[edge].loc ;
+ 	if( ++count % 100 == 0 ) {
+ 	    HRptrs = (DLINK1PTR *) realloc( HRptrs ,
+ 				(count + 100) * sizeof(DLINK1PTR) ) ;
+ 	}
+ 	HRptrs[count] = hptr ;
+ 	tinsert( &HRroot , last , count ) ;
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fuloop.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fuloop.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/fuloop.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,120 ----
+ #include "custom.h"
+ extern int newxx , newyy ;
+ extern int flips ;
+ extern double Tsave ;
+ 
+ extern void forceGrid( int x , int y );
+ extern int usite1( int a , int xb , int yb);
+ extern void selectpin( CELLBOXPTR acellptr );
+ 
+ void fuloop(void)
+ {
+ 
+ CELLBOXPTR acellptr;
+ TERMBOXPTR termptr ;
+ int a , numberx , numbery ;
+ int attempts , i ;
+ int xb , yb , axcenter , aycenter ;
+ int flip1 , att1 ;
+ int ll , rr , bb , tt ;
+ int scalex , scaley ;
+ double bound ;
+ 
+ flips    = 0 ;
+ attempts = 0 ;
+ flip1    = 0 ;
+ att1     = 0 ;
+ 
+ bound = log10( Tsave ) ;
+ if( bound > 6.0 ) {
+     bound = bound - 1.0 ;
+ } else {
+     bound = 5.0 ;
+ }
+ bound = pow( 4.0 , bound ) ;
+ 
+ numberx = (int)( pow( 4.0 , log10(T) ) / bound * (double) bdxlength ) ;
+ numberx *= 2 ;
+ if( numberx < 3 ) {
+     numberx = 3 ;
+ } else if( numberx > bdxlength ) {
+     numberx = bdxlength ;
+ }
+ 
+ numbery = (int)( pow( 4.0 , log10(T) ) / bound * (double) bdylength ) ;
+ numbery *= 2 ;
+ if( numbery < 3 ) {
+     numbery = 3 ;
+ } else if( numbery > bdylength ) {
+     numbery = bdylength ;
+ } 
+ scalex = numberx / 3 ;
+ scaley = numbery / 3 ;
+ fprintf(fpo,"range limiter:%d units either way in x",numberx);
+ fprintf(fpo,"   compared to bdxlength:%d\n",bdxlength);
+ fprintf(fpo,"range limiter:%d units either way in y",numbery);
+ fprintf(fpo,"   compared to bdylength:%d\n",bdylength);
+ fprintf(fpo,"scalex:%d  scaley:%d\n", scalex , scaley ) ;
+ 
+ while( attempts < attmax ) {
+     do {
+ 	a = (int) ( (double) numcells * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( a == numcells + 1 ) ;
+ 
+     acellptr = cellarray[ a ]   ;
+ 
+     if( acellptr->class != 0 ) {
+ 	continue ;
+     }
+     axcenter = acellptr->xcenter ;
+     aycenter = acellptr->ycenter ;
+ 
+     ll = (blockl > axcenter-numberx) ? (blockl - axcenter) / scalex :
+ 		( (blockr <= axcenter - numberx) ? 
+ 		(blockr - axcenter) / scalex : (- numberx / scalex) ) ;
+     rr = (blockr < axcenter+numberx) ? (blockr - axcenter) / scalex :
+ 		( (blockl >= axcenter + numberx) ? 
+ 		(blockl - axcenter) /scalex : (numberx / scalex) ) ;
+     bb = (blockb > aycenter-numbery) ? (blockb - aycenter) / scaley :
+ 		( (blockt <= aycenter - numbery) ? 
+ 		(blockt - aycenter) / scaley : (- numbery / scaley) ) ;
+     tt = (blockt < aycenter+numbery) ? (blockt - aycenter) / scaley :
+ 		( (blockb >= aycenter + numbery) ? 
+ 		(blockb - aycenter) / scaley : (numbery / scaley) ) ;
+     xb = (int)((double)(rr - ll + 1) * ((double)RAND /
+ 				    (double) 0x7fffffff ) ) + ll ;
+     yb = (int)((double)(tt - bb + 1) * ((double)RAND /
+ 				    (double) 0x7fffffff ) ) + bb ;
+     if( xb == 0 && yb == 0 ) {
+ 	continue ;
+     }
+     xb = axcenter + scalex * xb ;
+     yb = aycenter + scaley * yb ;
+ 
+     if( gridGiven ) {
+ 	termptr  = acellptr->config[acellptr->orient]->termptr ;
+ 	forceGrid( xb + termptr->xpos , yb + termptr->ypos ) ;
+ 	xb = newxx - termptr->xpos ;
+ 	yb = newyy - termptr->ypos ;
+     }
+ 
+     if( usite1( a , xb , yb ) ) {
+ 	flips++ ;
+ 	flip1++ ;
+     }
+     attempts++ ;
+     att1++ ;
+ 
+     if( acellptr->numUnComTerms != 0 ){
+ 	for( i = 1 ; i <= acellptr->numgroups ; i++ ) {
+ 	    selectpin( acellptr ) ;
+ 	}
+     }
+ }
+ fprintf(fpo,"acceptance breakdown:\n"); 
+ fprintf(fpo,"              single cell: %d / %d\n", flip1 , att1) ;
+ fprintf(fpo,"\tno. of accepted flips: %d\n", flips ) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/genorient.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/genorient.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/genorient.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,610 ----
+ #include "custom.h"
+ 
+ extern void move( int moveType );
+ extern void rect( int *l , int *b , int *r , int *t );
+ extern void point( int *x , int *y );
+ extern void delHtab(void);
+ 
+ void genorient(void)
+ {
+ 
+ int cell , orient , tilenum , termnum , aorient ;
+ int height , length , site , net ;
+ CELLBOXPTR ptr ;
+ TILEBOXPTR tptr0 , tptr ;
+ TERMBOXPTR tmptr0 , tmptr ;
+ LOCBOX *siteptr0 , *siteptr ;
+ NETBOXPTR netptr ;
+ 
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[cell] ;
+     aorient = ptr->orient ;
+     if( aorient != 0 ) {
+ 	tptr0 = ptr->config[0] ;
+ 	height = tptr0->top - tptr0->bottom ;
+ 	length = tptr0->right - tptr0->left ;
+ 	switch( aorient ) {
+ 	    case 1 : orient = 1 ;
+ 		     break ;
+ 	    case 2 : orient = 2 ;
+ 		     break ;
+ 	    case 3 : orient = 3 ;
+ 		     break ;
+ 	    case 4 : orient = 4 ;
+ 		     break ;
+ 	    case 5 : orient = 5 ;
+ 		     break ;
+ 	    case 6 : orient = 7 ;
+ 		     break ;
+ 	    case 7 : orient = 6 ;
+ 		     break ;
+ 	}
+ 	tptr = ptr->config[aorient] = (TILEBOXPTR) malloc(sizeof(TILEBOX));
+ 	tptr->nexttile = TILENULL ;
+ 	tptr->termptr  = TERMNULL      ;
+ 	tptr->left     = tptr0->left   ;
+ 	tptr->right    = tptr0->right  ;
+ 	tptr->bottom   = tptr0->bottom ;
+ 	tptr->top      = tptr0->top    ;
+ 	tptr->oleft    = tptr0->oleft   ;
+ 	tptr->oright   = tptr0->oright  ;
+ 	tptr->obottom  = tptr0->obottom ;
+ 	tptr->otop     = tptr0->otop    ;
+ 
+ 	tptr->lweight = tptr0->lweight ;
+ 	tptr->rweight = tptr0->rweight ;
+ 	tptr->bweight = tptr0->bweight ;
+ 	tptr->tweight = tptr0->tweight ;
+ 	switch( orient ) {
+ 	    case 1 :  
+ 		tptr0->lweight = tptr->lweight ;
+ 		tptr0->rweight = tptr->rweight ;
+ 		tptr0->bweight = tptr->tweight ;
+ 		tptr0->tweight = tptr->bweight ;
+ 		break ;
+ 	    case 2 :
+ 		tptr0->lweight = tptr->rweight ;
+ 		tptr0->rweight = tptr->lweight ;
+ 		tptr0->bweight = tptr->bweight ;
+ 		tptr0->tweight = tptr->tweight ;
+ 		break ;
+ 	    case 3 :
+ 		tptr0->lweight = tptr->rweight ;
+ 		tptr0->rweight = tptr->lweight ;
+ 		tptr0->bweight = tptr->tweight ;
+ 		tptr0->tweight = tptr->bweight ;
+ 		break ;
+ 	    case 4 :
+ 		tptr0->lweight = tptr->tweight ;
+ 		tptr0->rweight = tptr->bweight ;
+ 		tptr0->bweight = tptr->rweight ;
+ 		tptr0->tweight = tptr->lweight ;
+ 		break ;
+ 	    case 5 :
+ 		tptr0->lweight = tptr->bweight ;
+ 		tptr0->rweight = tptr->tweight ;
+ 		tptr0->bweight = tptr->lweight ;
+ 		tptr0->tweight = tptr->rweight ;
+ 		break ;
+ 	    case 6 :
+ 		tptr0->lweight = tptr->tweight ;
+ 		tptr0->rweight = tptr->bweight ;
+ 		tptr0->bweight = tptr->lweight ;
+ 		tptr0->tweight = tptr->rweight ;
+ 		break ;
+ 	    case 7 :
+ 		tptr0->lweight = tptr->bweight ;
+ 		tptr0->rweight = tptr->tweight ;
+ 		tptr0->bweight = tptr->rweight ;
+ 		tptr0->tweight = tptr->lweight ;
+ 		break ;
+ 	}
+ 
+ 	move( orient ) ;
+ 
+ 	rect( &tptr0->left, &tptr0->bottom, &tptr0->right, &tptr0->top );
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 	    tptr0->left++  ;
+ 	    tptr0->right++ ;
+ 	}
+ 	tptr0->oleft    = tptr0->left   ;
+ 	tptr0->oright   = tptr0->right  ;
+ 	if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 	    tptr0->bottom++ ;
+ 	    tptr0->top++    ;
+ 	}
+ 	tptr0->obottom  = tptr0->bottom ;
+ 	tptr0->otop     = tptr0->top    ;
+ 	for( tilenum = 1 ; tilenum <= ptr->numtiles ; tilenum++ ) {
+ 	    tptr0 = tptr0->nexttile ;
+ 	    tptr  = tptr->nexttile = (TILEBOXPTR) malloc(
+ 					    sizeof( TILEBOX ) ) ;
+ 	    tptr->nexttile = TILENULL ;
+ 	    tptr->termptr  = TERMNULL      ;
+ 	    tptr->left    = tptr0->left   ;
+ 	    tptr->right   = tptr0->right   ;
+ 	    tptr->bottom  = tptr0->bottom  ;
+ 	    tptr->top     = tptr0->top     ;
+ 	    tptr->oleft   = tptr0->oleft   ;
+ 	    tptr->oright  = tptr0->oright  ;
+ 	    tptr->obottom = tptr0->obottom ;
+ 	    tptr->otop    = tptr0->otop    ;
+ 
+ 	    tptr->lweight = tptr0->lweight ;
+ 	    tptr->rweight = tptr0->rweight ;
+ 	    tptr->bweight = tptr0->bweight ;
+ 	    tptr->tweight = tptr0->tweight ;
+ 	    switch( orient ) {
+ 		case 1 :  
+ 		    tptr0->lweight = tptr->lweight ;
+ 		    tptr0->rweight = tptr->rweight ;
+ 		    tptr0->bweight = tptr->tweight ;
+ 		    tptr0->tweight = tptr->bweight ;
+ 		    break ;
+ 		case 2 :
+ 		    tptr0->lweight = tptr->rweight ;
+ 		    tptr0->rweight = tptr->lweight ;
+ 		    tptr0->bweight = tptr->bweight ;
+ 		    tptr0->tweight = tptr->tweight ;
+ 		    break ;
+ 		case 3 :
+ 		    tptr0->lweight = tptr->rweight ;
+ 		    tptr0->rweight = tptr->lweight ;
+ 		    tptr0->bweight = tptr->tweight ;
+ 		    tptr0->tweight = tptr->bweight ;
+ 		    break ;
+ 		case 4 :
+ 		    tptr0->lweight = tptr->tweight ;
+ 		    tptr0->rweight = tptr->bweight ;
+ 		    tptr0->bweight = tptr->rweight ;
+ 		    tptr0->tweight = tptr->lweight ;
+ 		    break ;
+ 		case 5 :
+ 		    tptr0->lweight = tptr->bweight ;
+ 		    tptr0->rweight = tptr->tweight ;
+ 		    tptr0->bweight = tptr->lweight ;
+ 		    tptr0->tweight = tptr->rweight ;
+ 		    break ;
+ 		case 6 :
+ 		    tptr0->lweight = tptr->tweight ;
+ 		    tptr0->rweight = tptr->bweight ;
+ 		    tptr0->bweight = tptr->lweight ;
+ 		    tptr0->tweight = tptr->rweight ;
+ 		    break ;
+ 		case 7 :
+ 		    tptr0->lweight = tptr->bweight ;
+ 		    tptr0->rweight = tptr->tweight ;
+ 		    tptr0->bweight = tptr->rweight ;
+ 		    tptr0->tweight = tptr->lweight ;
+ 		    break ;
+ 	    }
+ 
+ 	    move( orient ) ; 
+ 
+ 	    rect( &tptr0->left, &tptr0->bottom, &tptr0->right , 
+ 						&tptr0->top ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 		tptr0->left++  ;
+ 		tptr0->right++ ;
+ 	    }
+ 	    tptr0->oleft   = tptr0->left   ;
+ 	    tptr0->oright  = tptr0->right  ;
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 		tptr0->bottom++ ;
+ 		tptr0->top++    ;
+ 	    }
+ 	    tptr0->obottom = tptr0->bottom ;
+ 	    tptr0->otop    = tptr0->top    ;
+ 	}
+ 
+ 	/*  And NOW for the fixed terminals */
+ 
+ 	if( ptr->numterms != 0 ) {
+ 	    tmptr0 = ptr->config[0]->termptr ;
+ 	    tmptr = ptr->config[aorient]->termptr = (TERMBOXPTR) 
+ 					  malloc( sizeof( TERMBOX ) ) ;
+ 	    tmptr->nextterm = TERMNULL ;
+ 	    tmptr->terminal = tmptr0->terminal ;
+ 	    tmptr->xpos = tmptr0->xpos ;
+ 	    tmptr->ypos = tmptr0->ypos ;
+ 	    tmptr->oxpos = tmptr0->oxpos ;
+ 	    tmptr->oypos = tmptr0->oypos ;
+ 
+ 	    move( orient ) ; 
+ 
+ 	    point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 		tmptr0->xpos++  ;
+ 	    }
+ 	    tmptr0->oxpos = tmptr0->xpos ;
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 		tmptr0->ypos++ ;
+ 	    }
+ 	    tmptr0->oypos = tmptr0->ypos ;
+ 	    for( termnum = 2 ; termnum <= ptr->numterms ; termnum++ ) {
+ 		tmptr0 = tmptr0->nextterm ;
+ 		tmptr  = tmptr->nextterm = (TERMBOXPTR) malloc(
+ 					    sizeof( TERMBOX ) ) ;
+ 		tmptr->nextterm = TERMNULL ;
+ 		tmptr->terminal = tmptr0->terminal ;
+ 		tmptr->xpos = tmptr0->xpos ;
+ 		tmptr->ypos = tmptr0->ypos ;
+ 		tmptr->oxpos = tmptr0->oxpos ;
+ 		tmptr->oypos = tmptr0->oypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 		    tmptr0->xpos++  ;
+ 		}
+ 		tmptr0->oxpos = tmptr0->xpos ;
+ 		if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 		    tmptr0->ypos++ ;
+ 		}
+ 		tmptr0->oypos = tmptr0->ypos ;
+ 	    }
+ 	}
+ 
+ 	/*  Now the sites for the soft cells */
+ 
+ 	if( ptr->numsites != 0 ) {
+ 	    siteptr0 = ptr->config[0]->siteLocArray ;
+ 	    siteptr = ptr->config[aorient]->siteLocArray = (LOCBOX *) 
+ 		      malloc( (ptr->numsites + 1) * sizeof( LOCBOX ) ) ;
+ 	    for( site = 1 ; site <= ptr->numsites ; site++ ) {
+ 		siteptr[site].xpos = siteptr0[site].xpos ;
+ 		siteptr[site].ypos = siteptr0[site].ypos ;
+ 		siteptr[site].oxpos = siteptr0[site].oxpos ;
+ 		siteptr[site].oypos = siteptr0[site].oypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &(siteptr0[ site ].xpos) , 
+ 		       &(siteptr0[ site ].ypos) );
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 		    siteptr0[ site ].xpos++ ;
+ 		}
+ 		siteptr0[site].oxpos = siteptr0[site].xpos ;
+ 		if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 		    siteptr0[ site ].ypos++ ;
+ 		}
+ 		siteptr0[site].oypos = siteptr0[site].ypos ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ /* ************************************************** */
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[ cell ]  ;
+     height = ptr->config[0]->top - ptr->config[0]->bottom ;
+     length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( orient == ptr->orient ) {
+ 	    continue ;
+ 	}
+ 	if( ptr->orientList[orient] == 0 ) {
+ 	    continue ;
+ 	}
+ 	tptr0 = ptr->config[ 0 ] ;
+ 	tptr  = ptr->config[ orient ] = (TILEBOXPTR) malloc(
+ 					    sizeof( TILEBOX ) ) ;
+ 	tptr->nexttile = TILENULL      ;
+ 	tptr->left     = tptr0->left   ;
+ 	tptr->right    = tptr0->right  ;
+ 	tptr->bottom   = tptr0->bottom ;
+ 	tptr->top      = tptr0->top    ;
+ 	tptr->termptr  = TERMNULL      ;
+ 
+ 	switch( orient ) {
+ 	    case 1 :  
+ 		tptr->lweight = tptr0->lweight ;
+ 		tptr->rweight = tptr0->rweight ;
+ 		tptr->bweight = tptr0->tweight ;
+ 		tptr->tweight = tptr0->bweight ;
+ 		break ;
+ 	    case 2 :
+ 		tptr->lweight = tptr0->rweight ;
+ 		tptr->rweight = tptr0->lweight ;
+ 		tptr->bweight = tptr0->bweight ;
+ 		tptr->tweight = tptr0->tweight ;
+ 		break ;
+ 	    case 3 :
+ 		tptr->lweight = tptr0->rweight ;
+ 		tptr->rweight = tptr0->lweight ;
+ 		tptr->bweight = tptr0->tweight ;
+ 		tptr->tweight = tptr0->bweight ;
+ 		break ;
+ 	    case 4 :
+ 		tptr->lweight = tptr0->tweight ;
+ 		tptr->rweight = tptr0->bweight ;
+ 		tptr->bweight = tptr0->rweight ;
+ 		tptr->tweight = tptr0->lweight ;
+ 		break ;
+ 	    case 5 :
+ 		tptr->lweight = tptr0->bweight ;
+ 		tptr->rweight = tptr0->tweight ;
+ 		tptr->bweight = tptr0->lweight ;
+ 		tptr->tweight = tptr0->rweight ;
+ 		break ;
+ 	    case 6 :
+ 		tptr->lweight = tptr0->tweight ;
+ 		tptr->rweight = tptr0->bweight ;
+ 		tptr->bweight = tptr0->lweight ;
+ 		tptr->tweight = tptr0->rweight ;
+ 		break ;
+ 	    case 7 :
+ 		tptr->lweight = tptr0->bweight ;
+ 		tptr->rweight = tptr0->tweight ;
+ 		tptr->bweight = tptr0->rweight ;
+ 		tptr->tweight = tptr0->lweight ;
+ 		break ;
+ 	}
+ 
+ 	move( orient ) ;
+ 	rect( &tptr->left , &tptr->bottom , &tptr->right , 
+ 						    &tptr->top ) ;
+ 	tptr->oleft   = tptr->left   ;
+ 	tptr->oright  = tptr->right  ;
+ 	tptr->obottom = tptr->bottom ;
+ 	tptr->otop    = tptr->top    ;
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 	    tptr->left++  ;
+ 	    tptr->right++ ;
+ 	    tptr->oleft++  ;
+ 	    tptr->oright++ ;
+ 	}
+ 	if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 	    tptr->bottom++ ;
+ 	    tptr->top++    ;
+ 	    tptr->obottom++ ;
+ 	    tptr->otop++    ;
+ 	}
+ 	for( tilenum = 1 ; tilenum <= ptr->numtiles ; tilenum++ ) {
+ 	    tptr0 = tptr0->nexttile ;
+ 	    tptr  = tptr->nexttile = (TILEBOXPTR) malloc(
+ 					    sizeof( TILEBOX ) ) ;
+ 	    tptr->nexttile = TILENULL      ;
+ 	    tptr->left     = tptr0->left   ;
+ 	    tptr->right    = tptr0->right  ;
+ 	    tptr->bottom   = tptr0->bottom ;
+ 	    tptr->top      = tptr0->top    ;
+ 	    tptr->termptr  = TERMNULL      ;
+ 
+ 	    switch( orient ) {
+ 		case 1 :  
+ 		    tptr->lweight = tptr0->lweight ;
+ 		    tptr->rweight = tptr0->rweight ;
+ 		    tptr->bweight = tptr0->tweight ;
+ 		    tptr->tweight = tptr0->bweight ;
+ 		    break ;
+ 		case 2 :
+ 		    tptr->lweight = tptr0->rweight ;
+ 		    tptr->rweight = tptr0->lweight ;
+ 		    tptr->bweight = tptr0->bweight ;
+ 		    tptr->tweight = tptr0->tweight ;
+ 		    break ;
+ 		case 3 :
+ 		    tptr->lweight = tptr0->rweight ;
+ 		    tptr->rweight = tptr0->lweight ;
+ 		    tptr->bweight = tptr0->tweight ;
+ 		    tptr->tweight = tptr0->bweight ;
+ 		    break ;
+ 		case 4 :
+ 		    tptr->lweight = tptr0->tweight ;
+ 		    tptr->rweight = tptr0->bweight ;
+ 		    tptr->bweight = tptr0->rweight ;
+ 		    tptr->tweight = tptr0->lweight ;
+ 		    break ;
+ 		case 5 :
+ 		    tptr->lweight = tptr0->bweight ;
+ 		    tptr->rweight = tptr0->tweight ;
+ 		    tptr->bweight = tptr0->lweight ;
+ 		    tptr->tweight = tptr0->rweight ;
+ 		    break ;
+ 		case 6 :
+ 		    tptr->lweight = tptr0->tweight ;
+ 		    tptr->rweight = tptr0->bweight ;
+ 		    tptr->bweight = tptr0->lweight ;
+ 		    tptr->tweight = tptr0->rweight ;
+ 		    break ;
+ 		case 7 :
+ 		    tptr->lweight = tptr0->bweight ;
+ 		    tptr->rweight = tptr0->tweight ;
+ 		    tptr->bweight = tptr0->rweight ;
+ 		    tptr->tweight = tptr0->lweight ;
+ 		    break ;
+ 	    }
+ 
+ 	    move( orient ) ;
+ 	    rect( &tptr->left, &tptr->bottom, &tptr->right , 
+ 						    &tptr->top ) ;
+ 	    tptr->oleft   = tptr->left   ;
+ 	    tptr->oright  = tptr->right  ;
+ 	    tptr->obottom = tptr->bottom ;
+ 	    tptr->otop    = tptr->top    ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 		tptr->left++  ;
+ 		tptr->right++ ;
+ 		tptr->oleft++  ;
+ 		tptr->oright++ ;
+ 	    }
+ 
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 		tptr->bottom++ ;
+ 		tptr->top++    ;
+ 		tptr->obottom++ ;
+ 		tptr->otop++    ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ /*  And NOW for the fixed terminals */
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     if( ptr->numterms == 0 ) {
+ 	continue ;
+     }
+     height = ptr->config[0]->top - ptr->config[0]->bottom ;
+     length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( orient == ptr->orient ) {
+ 	    continue ;
+ 	}
+ 	if( ptr->orientList[orient] == 0 ) {
+ 	    continue ;
+ 	}
+ 	tmptr0 = ptr->config[ 0 ]->termptr ;
+ 	tmptr = ptr->config[ orient ]->termptr = (TERMBOXPTR) 
+ 				      malloc( sizeof( TERMBOX ) ) ;
+ 	tmptr->nextterm = TERMNULL         ;
+ 	tmptr->terminal = tmptr0->terminal ;
+ 	tmptr->xpos     = tmptr0->xpos     ;
+ 	tmptr->ypos     = tmptr0->ypos     ;
+ 
+ 	move( orient ) ;
+ 	point( &tmptr->xpos , &tmptr->ypos ) ;
+ 
+ 	tmptr->oxpos = tmptr->xpos ;
+ 	tmptr->oypos = tmptr->ypos ;
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 	    tmptr->xpos++  ;
+ 	    tmptr->oxpos++  ;
+ 	}
+ 	if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 	    tmptr->ypos++ ;
+ 	    tmptr->oypos++ ;
+ 	}
+ 	for( termnum = 2 ; termnum <= ptr->numterms ; termnum++ ) {
+ 	    tmptr0 = tmptr0->nextterm ;
+ 	    tmptr  = tmptr->nextterm = (TERMBOXPTR) malloc(
+ 					    sizeof( TERMBOX ) ) ;
+ 	    tmptr->nextterm = TERMNULL ;
+ 	    tmptr->terminal = tmptr0->terminal ;
+ 	    tmptr->xpos     = tmptr0->xpos ;
+ 	    tmptr->ypos     = tmptr0->ypos ;
+ 
+ 	    move( orient ) ;
+ 	    point( &tmptr->xpos , &tmptr->ypos ) ;
+ 
+ 	    tmptr->oxpos = tmptr->xpos ;
+ 	    tmptr->oypos = tmptr->ypos ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 		tmptr->xpos++  ;
+ 		tmptr->oxpos++  ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 		tmptr->ypos++ ;
+ 		tmptr->oypos++ ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ /*  Now the sites for the soft cells */
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     if( ptr->softflag == 0 ) {
+ 	continue ;
+     }
+     if( ptr->numsites == 0 ) {
+ 	continue ;
+     }
+     height = ptr->config[0]->top - ptr->config[0]->bottom ;
+     length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+     siteptr0 = ptr->config[ 0 ]->siteLocArray ;
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( orient == ptr->orient ) {
+ 	    continue ;
+ 	}
+ 	if( ptr->orientList[orient] == 0 ) {
+ 	    continue ;
+ 	}
+ 	siteptr = ptr->config[ orient ]->siteLocArray = (LOCBOX *) 
+ 	      malloc( (ptr->numsites + 1) * sizeof( LOCBOX ) ) ;
+ 
+ 	for( site = 1 ; site <= ptr->numsites ; site++ ) {
+ 	    siteptr[ site ].xpos = siteptr0[ site ].xpos ;
+ 	    siteptr[ site ].ypos = siteptr0[ site ].ypos ;
+ 
+ 	    move( orient ) ;
+ 
+ 	    point( &(siteptr[ site ].xpos) , 
+ 		   &(siteptr[ site ].ypos) );
+ 
+ 	    siteptr[ site ].oxpos = siteptr[ site ].xpos ;
+ 	    siteptr[ site ].oypos = siteptr[ site ].ypos ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 		siteptr[ site ].xpos++ ;
+ 		siteptr[ site ].oxpos++ ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 		siteptr[ site ].ypos++ ;
+ 		siteptr[ site ].oypos++ ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ delHtab() ;
+ for( net = 1 ; net <= numnets ; net++ ) {
+     for( netptr = netarray[ net ]->netptr ; netptr != NETNULL ;
+ 				    netptr = netptr->nextterm ) {
+ 	termarray[ netptr->terminal ] = (TERMNETSPTR) malloc(
+ 					sizeof( TERMNETS ) ) ;
+ 	termarray[ netptr->terminal ]->net = net ;
+ 	termarray[ netptr->terminal ]->termptr = netptr ;
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gentwf.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gentwf.c:1.1
*** /dev/null	Tue Oct  5 16:20:04 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gentwf.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,137 ----
+ #include "geo.h"
+ extern int TWsignal ;
+ 
+ void gentwf(void)
+ {
+ 
+ FILE *fp2 , *fp1  ;
+ char filename[1024] , c2[4] , c3[4] , c4[4] ,c5[12] , c6[4] ;
+ char pname[128] , nname[128] ;
+ int x , y , cell , PorE , offset , channel , hit ;
+ int node1 , node2 , min , edge , loc , ecount , max ;
+ FLAREPTR ifptr , ofptr , savefptr ;
+ 
+ 
+ sprintf( filename, "%s.pin", cktName ) ;
+ fp1 = fopen( filename , "r" ) ;
+ sprintf( filename, "%s.twf", cktName ) ;
+ fp2 = fopen( filename , "w" ) ;
+ 
+ while( fscanf(fp1," %s ", c6) == 1 ) {
+     if( strcmp( c6 , "net" ) == 0 ) {
+ 	fscanf(fp1, " %s ", nname ) ;
+ 	fprintf(fp2,"\nnet %s\n", nname);
+     } else if( strcmp( c6 , "pin" ) == 0 ) {
+ 	fscanf(fp1,"%s %s %d %s %d %s %d %s %d", pname ,
+ 		    c2 , &x , c3 , &y , c4 , &cell , c5 , &PorE) ;
+ 	if( PorE == 1 ) {
+ 	    fprintf(fp2,"    pin   %s  nodes   ", pname);
+ 	} else {
+ 	    fprintf(fp2,"    equiv %s  nodes   ", pname);
+ 	}
+ 	min = 1000000 ;
+ 	ifptr = xNodules[cell].inList ;
+ 	for( ; ifptr != (FLAREPTR) NULL ; ifptr = ifptr->next ) {
+ 	    edge = ifptr->fixEdge ;
+ 	    loc = edgeList[edge].loc ;
+ 	    if( ABS(loc - x) < min ) {
+ 		if( y <= rectArray[ 
+ 			    eArray[ ifptr->eindex[1] ].index2 ].yc &&
+ 			    y >= rectArray[ 
+ 			    eArray[ ifptr->eindex[1] ].index1 ].yc ) {
+ 		    min = ABS(loc - x) ;
+ 		    savefptr = ifptr ;
+ 		    hit = 1 ;
+ 		}
+ 	    }
+ 	}
+ 	ofptr = xNodules[cell].outList ;
+ 	for( ; ofptr != (FLAREPTR) NULL ; ofptr = ofptr->next ) {
+ 	    edge = ofptr->fixEdge ;
+ 	    loc = edgeList[edge].loc ;
+ 	    if( ABS(loc - x) < min ) {
+ 		if( y <= rectArray[ 
+ 			    eArray[ ofptr->eindex[1] ].index2 ].yc &&
+ 			    y >= rectArray[ 
+ 			    eArray[ ofptr->eindex[1] ].index1 ].yc ) {
+ 		    min = ABS(loc - x) ;
+ 		    savefptr = ofptr ;
+ 		    hit = 1 ;
+ 		}
+ 	    }
+ 	}
+ 	ifptr = yNodules[cell].inList ;
+ 	for( ; ifptr != (FLAREPTR) NULL ; ifptr = ifptr->next ) {
+ 	    edge = ifptr->fixEdge ;
+ 	    loc = edgeList[edge].loc ;
+ 	    if( ABS(loc - y) < min ) {
+ 		if( x <= rectArray[ 
+ 			    eArray[ ifptr->eindex[1] ].index2 ].xc &&
+ 			    x >= rectArray[ 
+ 			    eArray[ ifptr->eindex[1] ].index1 ].xc ) {
+ 		    min = ABS(loc - y) ;
+ 		    savefptr = ifptr ;
+ 		    hit = 2 ;
+ 		}
+ 	    }
+ 	}
+ 	ofptr = yNodules[cell].outList ;
+ 	for( ; ofptr != (FLAREPTR) NULL ; ofptr = ofptr->next ) {
+ 	    edge = ofptr->fixEdge ;
+ 	    loc = edgeList[edge].loc ;
+ 	    if( ABS(loc - y) < min ) {
+ 		if( x <= rectArray[ 
+ 			    eArray[ ofptr->eindex[1] ].index2 ].xc &&
+ 			    x >= rectArray[ 
+ 			    eArray[ ofptr->eindex[1] ].index1 ].xc ) {
+ 		    min = ABS(loc - y) ;
+ 		    savefptr = ofptr ;
+ 		    hit = 2 ;
+ 		}
+ 	    }
+ 	}
+ 	ecount = 0 ;
+ 	do {
+ 	    channel = savefptr->eindex[++ecount] ;
+ 	} while( eArray[channel].notActive == 1 ) ;
+ 
+ 	node1 = eArray[channel].index1 ;
+ 	node2 = eArray[channel].index2 ;
+ 	if( hit == 1 ) {
+ 	    offset = y - rectArray[node1].yc ;
+ 	    max = rectArray[node2].yc - rectArray[node1].yc ;
+ 	} else {
+ 	    offset = x - rectArray[node1].xc ;
+ 	    max = rectArray[node2].xc - rectArray[node1].xc ;
+ 	}
+ 	if( offset < 0 ) {
+ 	    printf("\n\n");
+ 	    printf("Pin: %s has location outside the range\n",
+ 							    pname );
+ 	    printf("of the edge: %d %d to which it was assigned\n",
+ 				node1, node2 ) ;
+ 	    printf("by an amount: %d\n", offset ) ;
+ 	    printf("\n\n");
+ 	    fflush(stdout);
+ 	    offset = 0 ;
+ 	    TWsignal = 1 ;
+ 	} else if( offset > max ) {
+ 	    printf("\n\n\n\n\n\n");
+ 	    printf("Pin: %s has location outside the range\n",
+ 							    pname );
+ 	    printf("of the edge: %d %d to which it was assigned\n",
+ 				node1, node2 ) ;
+ 	    printf("by an amount: %d\n", offset - max ) ;
+ 	    printf("\n\n");
+ 	    fflush(stdout);
+ 	    offset = max ;
+ 	    TWsignal = 1 ;
+ 	}
+ 	fprintf(fp2,"%d  %d  at  %d\n", node1 , node2 , offset ) ;
+     }
+ }
+ fclose(fp1) ;
+ fclose(fp2) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/geo.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/geo.h:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/geo.h	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,134 ----
+ #include "port.h"
+ #include "23tree.h"
+ #define VBIG 10000000
+ #define ABS(value)   ( (value)>=0 ? (value) : -(value) ) 
+ 
+ typedef struct edgebox {
+     int cell   ;
+     int start  ;
+     int end    ;
+     int loc    ;
+     int length ;
+     int UorR   ;
+     int fixed  ;
+     int prevEdge ;
+     int nextEdge ;
+     int node     ;
+ } EDGEBOX, *EDGEBOXPTR ;
+ 
+ typedef struct dlink1 {
+     int edge ;
+     struct dlink1 *prev ;
+     struct dlink1 *next ;
+ } DLINK1 , *DLINK1PTR ;
+ 
+ typedef struct dlink2 {
+     int index  ;
+     struct dlink2 *prev ;
+     struct dlink2 *next ;
+ } DLINK2 , *DLINK2PTR ;
+ 
+ typedef struct rect {
+     int xc ;
+     int yc ;
+     int xreset ;
+     int yreset ;
+     int l ;
+     int r ;
+     int b ;
+     int t ;
+     int ur ;
+     int ul ;
+     int lr ;
+     int ll ;
+     int nedges ;
+ } RECT , *RECTPTR ;
+ 
+ typedef struct ebox {
+     int index1  ;
+     int index2  ;
+     int width   ;
+     int lbside  ;
+     int rtside  ;
+     int length  ;
+     int hiend   ;
+     int loend   ;
+     int edge1   ;
+     int edge2   ;
+     int density ;
+     int notActive ;
+     TNODEPTR root ;
+ } EBOX, *EBOXPTR ;
+ 
+ typedef struct bellbox {
+     int distance ;
+     int from ;
+ } BELLBOX, *BELLBOXPTR ;
+ 
+ typedef struct flare {
+     int fixEdge ;
+     int *eindex ;
+     struct flare *next ;
+ } FLARE, *FLAREPTR ;
+ 
+ typedef struct nodbox {
+     FLAREPTR inList ;
+     FLAREPTR outList ;
+     int done ;
+ } NODBOX, *NODPTR ;
+ 
+ typedef struct wcbox {
+     int fixedWidth ;
+     int node ;
+     int *channels ;
+     int length ;
+     struct wcbox *next ;
+ } WCBOX, *WCPTR ;
+ 
+ typedef struct clbox {
+     int edge  ;
+     int extraSpace ;
+     int HorV ;
+     int loc ;
+     int start ;
+     int end ;
+     int compact ;
+     struct clbox *next ;
+ } CLBOX, *CLBOXPTR ;
+ 
+ extern CLBOXPTR *cellList ;
+ extern int pitch ;
+ extern BELLBOXPTR xBellArray , yBellArray ;
+ extern int **eIndexArray ;
+ extern WCPTR *xNodeArray , *yNodeArray ;
+ extern NODPTR xNodules , yNodules ;
+ extern int numXnodes , numYnodes ;
+ extern int numberCells ;
+ extern int edgeTransition ;
+ extern char *cktName ;
+ extern TNODEPTR LEroot , BEroot ;
+ extern TNODEPTR VDroot , HRroot ;
+ extern TNODEPTR Vroot , Hroot ;
+ extern TNODEPTR vChanEndRoot , vChanBeginRoot ;
+ extern TNODEPTR hChanEndRoot , hChanBeginRoot ;
+ extern DLINK2PTR *LEptrs , *BEptrs ;
+ extern DLINK1PTR *VDptrs , *HRptrs ;
+ extern DLINK1PTR *Vptrs , *Hptrs ;
+ extern EBOXPTR eArray ;
+ extern int eNum ;
+ extern RECTPTR rectArray ;
+ extern int numRects ;
+ extern DLINK1PTR Hlist , Vlist ;
+ extern DLINK2PTR HRlist , VRlist ;
+ extern DLINK1PTR Hend , Vend ;
+ extern DLINK1PTR hFixedList , vFixedList ;
+ extern DLINK1PTR hFixedEnd , vFixedEnd ;
+ extern EDGEBOXPTR edgeList ;
+ extern int edgeCount ;
+ extern int numProbes ;
+ extern TNODEPTR hFixedEdgeRoot ;
+ extern TNODEPTR vFixedEdgeRoot ;
+ extern TNODEPTR hEdgeRoot , vEdgeRoot ;
+ extern TNODEPTR hRectRoot , vRectRoot ;
+ extern int bbl , bbr , bbb , bbt ;
+ extern FILE *fpdebug ;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ggenorien.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ggenorien.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ggenorien.c	Tue Oct  5 16:19:45 2004
***************
*** 0 ****
--- 1,212 ----
+ #include "custom.h"
+ extern int ecount ;
+ 
+ extern void point( int *x , int *y );
+ extern void move( int moveType );
+ extern void delHtab(void);
+ 
+ void ggenorien(void)
+ {
+ 
+ int cell , orient , termnum , aorient ;
+ int height , length , net , terminal , xpos , ypos , pin ;
+ CELLBOXPTR ptr ;
+ TERMBOXPTR tmptr0 , tmptr , cptr , koptr , term ;
+ NETBOXPTR netptr ;
+ TERMNETSPTR termptr ;
+ 
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     if( ptr->numterms == 0 || ptr->softflag == 1 ) {
+ 	continue ;
+     }
+     height = ptr->config[0]->top - ptr->config[0]->bottom ;
+     length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( ptr->config[orient] == TILENULL ) {
+ 	    continue ;
+ 	}
+ 	cptr = ptr->config[orient]->termptr ;
+ 	ptr->config[orient]->termptr = TERMNULL ;
+ 	if( cptr != TERMNULL ) {
+ 	    koptr = cptr ;
+ 	    while( cptr->nextterm != TERMNULL ) {
+ 		cptr = cptr->nextterm ;
+ 		free( koptr ) ;
+ 		koptr = cptr ;
+ 	    }
+ 	    free( cptr ) ;
+ 	}
+     }
+     aorient = ptr->orientList[8] ;
+     if( aorient != 0 ) {
+ 	switch( aorient ) {
+ 	    case 1 : orient = 1 ;
+ 		     break ;
+ 	    case 2 : orient = 2 ;
+ 		     break ;
+ 	    case 3 : orient = 3 ;
+ 		     break ;
+ 	    case 4 : orient = 4 ;
+ 		     break ;
+ 	    case 5 : orient = 5 ;
+ 		     break ;
+ 	    case 6 : orient = 7 ;
+ 		     break ;
+ 	    case 7 : orient = 6 ;
+ 		     break ;
+ 	}
+ 	tmptr0 = ptr->config[0]->termptr ;
+ 	tmptr = ptr->config[aorient]->termptr = (TERMBOXPTR) 
+ 					  malloc( sizeof( TERMBOX ) ) ;
+ 	tmptr->nextterm = TERMNULL ;
+ 	tmptr->xpos = tmptr0->xpos ;
+ 	tmptr->ypos = tmptr0->ypos ;
+ 	tmptr->oxpos = tmptr0->oxpos ;
+ 	tmptr->oypos = tmptr0->oypos ;
+ 
+ 	move( orient ) ; 
+ 
+ 	point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 	    tmptr0->xpos++  ;
+ 	}
+ 	tmptr0->oxpos = tmptr0->xpos ;
+ 	if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 	    tmptr0->ypos++ ;
+ 	}
+ 	tmptr0->oypos = tmptr0->ypos ;
+ 	for( termnum = 2 ; termnum <= ptr->numterms ; termnum++ ) {
+ 	    tmptr0 = tmptr0->nextterm ;
+ 	    tmptr  = tmptr->nextterm = (TERMBOXPTR) malloc(
+ 					sizeof( TERMBOX ) ) ;
+ 	    tmptr->nextterm = TERMNULL ;
+ 	    tmptr->xpos = tmptr0->xpos ;
+ 	    tmptr->ypos = tmptr0->ypos ;
+ 	    tmptr->oxpos = tmptr0->oxpos ;
+ 	    tmptr->oypos = tmptr0->oypos ;
+ 
+ 	    move( orient ) ; 
+ 
+ 	    point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 		tmptr0->xpos++  ;
+ 	    }
+ 	    tmptr0->oxpos = tmptr0->xpos ;
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 		tmptr0->ypos++ ;
+ 	    }
+ 	    tmptr0->oypos = tmptr0->ypos ;
+ 	}
+     }
+     height = ptr->config[0]->top - ptr->config[0]->bottom ;
+     length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( orient == ptr->orientList[8] ) {
+ 	    continue ;
+ 	}
+ 	if( ptr->orientList[orient] == 0 ) {
+ 	    continue ;
+ 	}
+ 	tmptr0 = ptr->config[0]->termptr ;
+ 	tmptr = ptr->config[orient]->termptr = (TERMBOXPTR) 
+ 				      malloc( sizeof( TERMBOX ) ) ;
+ 	tmptr->nextterm = TERMNULL         ;
+ 	tmptr->terminal = tmptr0->terminal ;
+ 	tmptr->xpos     = tmptr0->xpos     ;
+ 	tmptr->ypos     = tmptr0->ypos     ;
+ 
+ 	move( orient ) ;
+ 	point( &tmptr->xpos , &tmptr->ypos ) ;
+ 
+ 	tmptr->oxpos = tmptr->xpos ;
+ 	tmptr->oypos = tmptr->ypos ;
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 	    tmptr->xpos++  ;
+ 	    tmptr->oxpos++  ;
+ 	}
+ 	if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 	    tmptr->ypos++ ;
+ 	    tmptr->oypos++ ;
+ 	}
+ 	for( termnum = 2 ; termnum <= ptr->numterms ; termnum++ ) {
+ 	    tmptr0 = tmptr0->nextterm ;
+ 	    tmptr  = tmptr->nextterm = (TERMBOXPTR) malloc(
+ 					    sizeof( TERMBOX ) ) ;
+ 	    tmptr->nextterm = TERMNULL ;
+ 	    tmptr->terminal = tmptr0->terminal ;
+ 	    tmptr->xpos     = tmptr0->xpos ;
+ 	    tmptr->ypos     = tmptr0->ypos ;
+ 
+ 	    move( orient ) ;
+ 	    point( &tmptr->xpos , &tmptr->ypos ) ;
+ 
+ 	    tmptr->oxpos = tmptr->xpos ;
+ 	    tmptr->oypos = tmptr->ypos ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 		tmptr->xpos++  ;
+ 		tmptr->oxpos++  ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 		tmptr->ypos++ ;
+ 		tmptr->oypos++ ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ delHtab() ;
+ for( net = 1 ; net <= numnets ; net++ ) {
+     for( netptr = netarray[ net ]->netptr ; netptr != NETNULL ;
+ 				    netptr = netptr->nextterm ) {
+ 	if( netptr->terminal > maxterm ) {
+ 	    termarray[ netptr->terminal ] = (TERMNETSPTR) malloc(
+ 					    sizeof( TERMNETS ) ) ;
+ 	    termarray[ netptr->terminal ]->net = net ;
+ 	    termarray[ netptr->terminal ]->termptr = netptr ;
+ 	}
+     }
+ }
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     if( ptr->softflag == 0 ) {
+ 	term = ptr->config[ptr->orient]->termptr ;
+ 	for( ; term != TERMNULL ; term = term->nextterm ) {
+ 	    termptr = termarray[term->terminal ];
+ 	    termptr->termptr->xpos = term->xpos + ptr->xcenter ;
+ 	    termptr->termptr->ypos = term->ypos + ptr->ycenter ;
+ 	}
+     } else {
+ 	for( pin = 1 ; pin <= ptr->numUnComTerms ; pin++ ) {
+ 	   terminal = ptr->unComTerms[pin].terminal ;
+ 	   xpos = ptr->unComTerms[pin].finalx ;
+ 	   ypos = ptr->unComTerms[pin].finaly ;
+ 	   termptr = termarray[terminal] ;
+ 	   termptr->termptr->xpos = xpos + ptr->xcenter ;
+ 	   termptr->termptr->ypos = ypos + ptr->ycenter ;
+ 	}
+     }
+ }
+ maxterm += ecount ;
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gglobals.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gglobals.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gglobals.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,132 ----
+ #include "port.h"
+ #include "23tree.h"
+ 
+ typedef struct edgebox {
+     int cell   ;
+     int start  ;
+     int end    ;
+     int loc    ;
+     int length ;
+     int UorR   ;
+     int fixed  ;
+     int prevEdge ;
+     int nextEdge ;
+     int node     ;
+ } EDGEBOX, *EDGEBOXPTR ;
+ 
+ typedef struct dlink1 {
+     int edge ;
+     struct dlink1 *prev ;
+     struct dlink1 *next ;
+ } DLINK1 , *DLINK1PTR ;
+ 
+ typedef struct dlink2 {
+     int index  ;
+     struct dlink2 *prev ;
+     struct dlink2 *next ;
+ } DLINK2 , *DLINK2PTR ;
+ 
+ typedef struct rect {
+     int xc ;
+     int yc ;
+     int xreset ;
+     int yreset ;
+     int l ;
+     int r ;
+     int b ;
+     int t ;
+     int ur ;
+     int ul ;
+     int lr ;
+     int ll ;
+     int nedges ;
+ } RECT , *RECTPTR ;
+ 
+ typedef struct ebox {
+     int index1  ;
+     int index2  ;
+     int width   ;
+     int lbside  ;
+     int rtside  ;
+     int length  ;
+     int hiend   ;
+     int loend   ;
+     int edge1   ;
+     int edge2   ;
+     int density ;
+     int notActive ;
+     TNODEPTR root ;
+ } EBOX, *EBOXPTR ;
+ 
+ typedef struct bellbox {
+     int distance ;
+     int from ;
+ } BELLBOX, *BELLBOXPTR ;
+ 
+ typedef struct flare {
+     int fixEdge ;
+     int *eindex ;
+     struct flare *next ;
+ } FLARE, *FLAREPTR ;
+ 
+ typedef struct nodbox {
+     FLAREPTR inList ;
+     FLAREPTR outList ;
+     int done ;
+ } NODBOX, *NODPTR ;
+ 
+ typedef struct wcbox {
+     int fixedWidth ;
+     int node ;
+     int *channels ;
+     int length ;
+     struct wcbox *next ;
+ } WCBOX, *WCPTR ;
+ 
+ typedef struct clbox {
+     int edge  ;
+     int extraSpace ;
+     int HorV ;
+     int loc ;
+     int start ;
+     int end ;
+     int compact ;
+     struct clbox *next ;
+ } CLBOX, *CLBOXPTR ;
+ 
+ CLBOXPTR *cellList ;
+ int pitch ;
+ BELLBOXPTR xBellArray , yBellArray ;
+ int **eIndexArray ;
+ WCPTR *xNodeArray , *yNodeArray ;
+ NODPTR xNodules , yNodules ;
+ int numXnodes , numYnodes ;
+ int numberCells ;
+ int edgeTransition ;
+ char *cktName ;
+ TNODEPTR VDroot , HRroot ;
+ TNODEPTR LEroot , BEroot ;
+ TNODEPTR Vroot , Hroot ;
+ TNODEPTR vChanEndRoot , vChanBeginRoot ;
+ TNODEPTR hChanEndRoot , hChanBeginRoot ;
+ DLINK2PTR *LEptrs , *BEptrs ;
+ DLINK1PTR *VDptrs , *HRptrs ;
+ DLINK1PTR *Vptrs , *Hptrs ;
+ EBOXPTR eArray ;
+ int eNum ;
+ RECTPTR rectArray ;
+ int numRects ;
+ DLINK1PTR Hlist , Vlist ;
+ DLINK2PTR HRlist , VRlist ;
+ DLINK1PTR Hend , Vend ;
+ DLINK1PTR hFixedList , vFixedList ;
+ DLINK1PTR hFixedEnd , vFixedEnd ;
+ EDGEBOXPTR edgeList ;
+ int edgeCount ;
+ int numProbes ;
+ TNODEPTR hFixedEdgeRoot ;
+ TNODEPTR vFixedEdgeRoot ;
+ TNODEPTR hEdgeRoot , vEdgeRoot ;
+ TNODEPTR hRectRoot , vRectRoot ;
+ int bbl , bbr , bbb , bbt ;
+ FILE *fpdebug ;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/globals.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/globals.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/globals.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,230 ----
+ #include "port.h"
+ 
+ #define ZERO 0
+ #define ALLOC(type)    (  (type *) malloc ( sizeof(type) )  )
+ #define LINE printf(" file : %s  line # %d\n", __FILE__,__LINE__);
+ #define ABS(value)   ( (value)>=0 ? (value) : -(value) ) 
+ 
+ #define CELLNULL (CELLBOXPTR) NULL
+ #define NETNULL (NETBOXPTR) NULL
+ #define DIMNULL (DIMBOXPTR) NULL
+ #define TILENULL (TILEBOXPTR) NULL
+ #define TERMNULL (TERMBOXPTR) NULL
+ #define TERMNETSNULL (TERMNETSPTR) NULL
+ #define LNULL (LOCBOX *) NULL
+ 
+ typedef struct bustbox {
+     int xc ;
+     int yc ;
+ } BUSTBOX , *BUSTBOXPTR ;
+ 
+ typedef struct locbox {
+     int xpos ;
+     int ypos ;
+     int oxpos ;
+     int oypos ;
+ } LOCBOX ;
+ 
+ typedef struct contentbox {
+     int contents ;
+     int newContents ;
+     int capacity ;
+     int HorV ;
+     int span ;
+ } CONTENTBOX ;
+ 
+ typedef struct uncombox {
+     int terminal  ;
+     int site      ;
+     int newsite   ;
+     int numLocs   ;
+     int numranges ;
+     int range1    ;
+     int range2    ;
+     int sequence  ;
+     int groupflag ;
+     int finalx    ;
+     int finaly    ;
+ } UNCOMBOX ;
+ 
+ typedef struct netbox {
+     struct netbox *nextterm ;
+     int xpos ;
+     int ypos ;
+     int newx ;
+     int newy ;
+     int terminal ;
+     int flag ;
+     int cell ;
+     int PorE ;
+     int skip ;
+ } *NETBOXPTR , NETBOX ;
+ 
+ typedef struct termbox { 
+     struct termbox *nextterm ;
+     int xpos     ;
+     int ypos     ;
+     int oxpos     ;
+     int oypos     ;
+     int terminal ;
+ } *TERMBOXPTR , TERMBOX ;
+ 
+ typedef struct tilebox { 
+     struct tilebox *nexttile ;
+     double lweight;
+     double rweight;
+     double bweight;
+     double tweight;
+     int lborder   ;
+     int rborder   ;
+     int bborder   ;
+     int tborder   ;
+     int left      ;
+     int right     ;
+     int bottom    ;
+     int top       ;
+     int oleft     ;
+     int oright    ;
+     int obottom   ;
+     int otop      ;
+     TERMBOXPTR termptr ;
+     LOCBOX *siteLocArray ;
+ } *TILEBOXPTR , TILEBOX ;
+ 
+ typedef struct psidebox {
+     int length   ;
+     double pincount;
+     int vertical ;
+     int position ;
+ } PSIDEBOX ;
+ 
+ typedef struct sidebox {
+     int firstSite ;
+     int lastSite  ;
+ } SIDEBOX ;
+ 
+ typedef struct cellbox { 
+     char *cname             ;
+     int class               ;
+     int xcenter             ;
+     int ycenter             ;
+     int orientList[9]       ;
+     int orient              ;
+     int numtiles            ;
+     int numsides            ;
+     int numterms            ;
+     int numgroups           ;
+     int softflag            ;
+     int padside             ;
+     double sidespace        ;
+     double aspect           ;
+     double aspectO          ;
+     double aspUB            ;
+     double aspLB            ;
+     int numsites            ;
+     int numUnComTerms       ;
+     CONTENTBOX *siteContent ;
+     UNCOMBOX *unComTerms    ;
+     TILEBOXPTR config[8]    ;
+     SIDEBOX *sideArray      ;
+ } *CELLBOXPTR , CELLBOX ;
+ 
+ typedef struct dimbox {
+     NETBOXPTR netptr   ;
+     int skip       ;
+     int xmin       ;
+     int newxmin    ;
+     int xmax       ;
+     int newxmax    ;
+     int ymin       ;
+     int flag       ;
+     int newymin    ;
+     int ymax       ;
+     int newymax    ;
+     double Hweight ;
+     double Vweight ;
+     char *nname    ;
+ } *DIMBOXPTR , DIMBOX ;
+ 
+ typedef struct termnets {
+     int net ;
+     NETBOXPTR termptr ;
+ } *TERMNETSPTR , TERMNETS ;
+ 
+ typedef struct hash {
+     char *hname ;
+     int hnum ;
+     struct hash *hnext ;
+ } HASHBOX , *HASHPTR ;
+ 
+ CELLBOXPTR *cellarray   ;
+ DIMBOXPTR *netarray     ;
+ TERMNETSPTR *termarray  ;
+ int ***blockarray ;
+ 
+ int bdxlength , bdylength ;
+ int blockl , blockr , blockt , blockb ;
+ int blockmx , blockmy ;
+ 
+ int numcells  ;
+ int numpads   ;
+ int numBinsX  ;
+ int numBinsY  ;
+ int binWidthX ;
+ int binWidthY ;
+ int binOffsetX;
+ int binOffsetY;
+ int *bucket   ;
+ int maxWeight ;
+ int baseWeight;
+ double slopeX    ;
+ double slopeY    ;
+ double basefactor;
+ int aveChanWid;
+ 
+ int penalty   ;
+ int funccost  ;
+ int offset    ;
+ int overfill  ;
+ 
+ HASHPTR *hashtab ;
+ int netctr ;
+ double T   ;
+ int randVar ;
+ FILE *fpo ;
+ char **pinnames ;
+ char *cktName ;
+ int maxterm ;
+ int numnets ;
+ int attmax  ;
+ 
+ int *occa1ptr ;
+ int *occa2ptr ;
+ int *occb1ptr ;
+ int *occb2ptr ;
+ int binX   ; 
+ int binY   ; 
+ 
+ double pinsPerLen ;
+ PSIDEBOX *pSideArray ;
+ int trackspacing ;
+ int pinSpacing   ;
+ double lapFactor ;
+ 
+ int (*overlap)() ;
+ int (*overlapf)() ;
+ int (*overlapx)() ;
+ int goverlap() ;
+ int goverlapf() ;
+ int goverlapx() ;
+ int woverlap() ;
+ int woverlapf() ;
+ int woverlapx() ;
+ 
+ int gOffsetX ;
+ int gOffsetY ;
+ int gridX ;
+ int gridY ;
+ int coreGiven ;
+ int gridGiven ;
+ int layersFactor ;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gmain.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gmain.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gmain.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,218 ----
+ #include "geo.h"
+ 
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ extern void fulllink(void);
+ extern void findnodes(void);
+ extern void changraph(void);
+ extern void gentwf(void);
+ extern void readgeo( FILE *fp );
+ extern void makelink(void);
+ extern void hprobes(void);
+ extern void vprobes(void);
+ extern void xgraph(void);
+ extern void ygraph(void);
+ extern void reduceg(void);
+ extern void printgph(void);
+ 
+ void gmain(void)
+ {
+ 
+ FILE *fp , *fopen() ;
+ TNODEPTR tnode ;
+ char filename[1024] ;
+ int dummy1 , dummy2 , i ;
+ FLAREPTR fptr , f2ptr ;
+ DLINK2PTR hrptr , hr2ptr ;
+ DLINK1PTR hptr , h2ptr ;
+ 
+ 
+ sprintf( filename , "%s.debug" , cktName ) ;
+ if( (fpdebug = fopen ( filename , "w")) == (FILE *) NULL ) {
+     printf("can't open %s\n", filename ) ;
+     exit(0);
+ }
+ 
+ sprintf( filename , "%s.geo" , cktName ) ;
+ if( (fp = fopen ( filename , "r")) == (FILE *) NULL ) {
+     fprintf(fpdebug,"Error: file: %s not present\n", filename );
+     exit(0);
+ }
+ 
+ readgeo( fp ) ;
+ makelink()    ;
+ hprobes()     ;
+ vprobes()     ;
+ 
+ free( Vptrs ) ;
+ free( Hptrs ) ;
+ if( Vroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &Vroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( Hroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &Hroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ 
+ fulllink()  ;
+ findnodes() ;
+ changraph() ;
+ xgraph()    ;
+ ygraph()    ;
+ reduceg()   ;
+ printgph()  ;
+ gentwf()    ;
+ 
+ /*   ***********************************************    */
+ /*         THIS SECTION IS CLEAN-UP                     */
+ /*   ***********************************************    */
+ 
+ 
+ free( rectArray ) ;
+ 
+ hrptr = HRlist ;
+ while( hrptr != (DLINK2PTR) NULL ) {
+     hr2ptr = hrptr->next ;
+     free( hrptr ) ;
+     hrptr = hr2ptr ;
+ }
+ hrptr = VRlist ;
+ while( hrptr != (DLINK2PTR) NULL ) {
+     hr2ptr = hrptr->next ;
+     free( hrptr ) ;
+     hrptr = hr2ptr ;
+ }
+ 
+ free( LEptrs ) ;
+ free( BEptrs ) ;
+ if( LEroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &LEroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( BEroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &BEroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ hptr = Hlist ;
+ while( hptr != (DLINK1PTR) NULL ) {
+     h2ptr = hptr->next ;
+     free( hptr ) ;
+     hptr = h2ptr ;
+ }
+ 
+ hptr = Vlist ;
+ while( hptr != (DLINK1PTR) NULL ) {
+     h2ptr = hptr->next ;
+     free( hptr ) ;
+     hptr = h2ptr ;
+ }
+ 
+ free( Vptrs ) ;
+ free( Hptrs ) ;
+ if( Vroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &Vroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( Hroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &Hroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ free( VDptrs ) ;
+ free( HRptrs ) ;
+ if( VDroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &VDroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( HRroot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &HRroot , &tnode , &dummy1 , &dummy2 ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ 
+ hptr = hFixedList ;
+ while( hptr != (DLINK1PTR) NULL ) {
+     h2ptr = hptr->next ;
+     free( hptr ) ;
+     hptr = h2ptr ;
+ }
+ hptr = vFixedList ;
+ while( hptr != (DLINK1PTR) NULL ) {
+     h2ptr = hptr->next ;
+     free( hptr ) ;
+     hptr = h2ptr ;
+ }
+ 
+ for( i = 0 ; i <= numberCells + 1 ; i++ ) {
+     fptr = xNodules[i].outList ;
+     while( fptr != (FLAREPTR) NULL ) {
+ 	free( fptr->eindex ) ;
+ 	f2ptr = fptr->next ;
+ 	free( fptr ) ;
+ 	fptr = f2ptr ;
+     }
+     fptr = xNodules[i].inList ;
+     while( fptr != (FLAREPTR) NULL ) {
+ 	free( fptr->eindex ) ;
+ 	f2ptr = fptr->next ;
+ 	free( fptr ) ;
+ 	fptr = f2ptr ;
+     }
+     fptr = yNodules[i].outList ;
+     while( fptr != (FLAREPTR) NULL ) {
+ 	free( fptr->eindex ) ;
+ 	f2ptr = fptr->next ;
+ 	free( fptr ) ;
+ 	fptr = f2ptr ;
+     }
+     fptr = yNodules[i].inList ;
+     while( fptr != (FLAREPTR) NULL ) {
+ 	free( fptr->eindex ) ;
+ 	f2ptr = fptr->next ;
+ 	free( fptr ) ;
+ 	fptr = f2ptr ;
+     }
+ }
+ free( xNodules ) ;
+ free( yNodules ) ;
+ 
+ fclose( fpdebug );
+ fclose( fp );
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlap.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlap.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlap.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,171 ----
+ #include "custom.h"
+ 
+ int goverlap( int cell , int xc , int yc , int orient , int b , int flag ,
+                int borient )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr1 , tileptr2 , tileptr01, tileptr02 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ orient ]  ;
+ 
+ startx01 = xc + tileptr01->left    ;
+ endx01   = xc + tileptr01->right   ;
+ starty01 = yc + tileptr01->bottom  ;
+ endy01   = yc + tileptr01->top     ;
+ if( cell <= numcells ) {
+     startx01 -= tileptr01->lborder ;
+     endx01   += tileptr01->rborder ;
+     starty01 -= tileptr01->bborder ;
+     endy01   += tileptr01->tborder ;
+ }
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    if( othercell != b ) {
+ 		tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 		xcenter = cellptr2->xcenter ;
+ 		ycenter = cellptr2->ycenter ;
+ 	    } else if( flag == 0 ) {
+ 		tileptr02 = cellptr2->config[borient] ;
+ 		xcenter = cellptr1->xcenter ;
+ 		ycenter = cellptr1->ycenter ;
+ 	    } else {
+ 		continue ;
+ 	    }
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( othercell <= numcells ) {
+ 		startx02 -= tileptr02->lborder ;
+ 		endx02   += tileptr02->rborder ;
+ 		starty02 -= tileptr02->bborder ; 
+ 		endy02   += tileptr02->tborder ;
+ 	    }
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 		/*
+ 		fprintf(fpo,"Overlap condition: cell:%d othercell:%d",
+ 						cell, othercell ) ;
+ 		fprintf(fpo,"   overlap:%d\n", value ) ;
+ 		*/
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    startx1 =  xc + tileptr1->left   ;
+ 		    endx1   =  xc + tileptr1->right  ;
+ 		    starty1 =  yc + tileptr1->bottom ;
+ 		    endy1   =  yc + tileptr1->top    ;
+ 		    if( cell <= numcells ) {
+ 			startx1 -= tileptr1->lborder ;
+ 			endx1   += tileptr1->rborder ;
+ 			starty1 -= tileptr1->bborder ;
+ 			endy1   += tileptr1->tborder ;
+ 		    }
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 			if( othercell <= numcells ) {
+ 			    startx2 -= tileptr2->lborder ;
+ 			    endx2   += tileptr2->rborder ;
+ 			    starty2 -= tileptr2->bborder ;
+ 			    endy2   += tileptr2->tborder ;
+ 			}
+ 
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlapf.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlapf.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlapf.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,178 ----
+ #include "custom.h"
+ 
+ int goverlapf( int cell , int xc , int yc , int orient , int b , int flag ,
+                int borient )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr1 , tileptr2 , tileptr01, tileptr02 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ orient ]  ;
+ 
+ startx01 = xc + tileptr01->left    ;
+ endx01   = xc + tileptr01->right   ;
+ starty01 = yc + tileptr01->bottom  ;
+ endy01   = yc + tileptr01->top     ;
+ if( cell <= numcells ) {
+     startx01 -= tileptr01->lborder ;
+     endx01   += tileptr01->rborder ;
+     starty01 -= tileptr01->bborder ;
+     endy01   += tileptr01->tborder ;
+ }
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    if( othercell != b ) {
+ 		tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 		xcenter = cellptr2->xcenter ;
+ 		ycenter = cellptr2->ycenter ;
+ 	    } else if( flag == 0 ) {
+ 		tileptr02 = cellptr2->config[borient] ;
+ 		xcenter = cellptr1->xcenter ;
+ 		ycenter = cellptr1->ycenter ;
+ 	    } else {
+ 		continue ;
+ 	    }
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( othercell <= numcells ) {
+ 		startx02 -= tileptr02->lborder ;
+ 		endx02   += tileptr02->rborder ;
+ 		starty02 -= tileptr02->bborder ;
+ 		endy02   += tileptr02->tborder ;
+ 	    }
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 		fprintf(fpo,"Overlap condition: cell1:%d cell2:%d",
+ 						cell, othercell ) ;
+ 		fprintf(fpo,"   value:%d   amount:%d\n",
+ 			(int)(lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ),
+ 				(endy - starty) * (endx - startx) ) ;
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    startx1 =  xc + tileptr1->left   ;
+ 		    endx1   =  xc + tileptr1->right  ;
+ 		    starty1 =  yc + tileptr1->bottom ;
+ 		    endy1   =  yc + tileptr1->top    ;
+ 		    if( cell <= numcells ) {
+ 			startx1 -= tileptr1->lborder ;
+ 			endx1   += tileptr1->rborder ;
+ 			starty1 -= tileptr1->bborder ;
+ 			endy1   += tileptr1->tborder ;
+ 		    }
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 			if( othercell <= numcells ) {
+ 			    startx2 -= tileptr2->lborder ;
+ 			    endx2   += tileptr2->rborder ;
+ 			    starty2 -= tileptr2->bborder ;
+ 			    endy2   += tileptr2->tborder ;
+ 			}
+ 
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		    fprintf(fpo,"Overlap condition: cell1:%d cell2:%d",
+ 						cell, othercell ) ;
+ 		    fprintf(fpo,"   value:%d   amount:%d\n",
+ 					    (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ,
+ 							    tempval ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlapx.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlapx.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/goverlapx.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,170 ----
+ #include "custom.h"
+ 
+ int goverlapx( int cell, int oleft, int obottom, int Wdiv2, int Hdiv2, 
+                double aspFactor )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr01, tileptr1, tileptr02, tileptr2 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ double val ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ cellptr1->orient ]  ;
+ 
+ 
+ startx01 = cellptr1->xcenter - Wdiv2 ;
+ 
+ val = (double)(tileptr01->oright - oleft) / aspFactor ;
+ endx01 = cellptr1->xcenter + ROUND( val ) - Wdiv2;
+ 
+ starty01 = cellptr1->ycenter - Hdiv2 ;
+ 
+ val = (double)(tileptr01->otop - obottom) * aspFactor ;
+ endy01 = cellptr1->ycenter + ROUND( val ) - Hdiv2;
+ 
+ startx01 -= tileptr01->lborder ;
+ endx01   += tileptr01->rborder ;
+ starty01 -= tileptr01->bborder ;
+ endy01   += tileptr01->tborder ;
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 	    xcenter = cellptr2->xcenter ;
+ 	    ycenter = cellptr2->ycenter ;
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( othercell <= numcells ) {
+ 		startx02 -= tileptr02->lborder ;
+ 		endx02   += tileptr02->rborder ;
+ 		starty02 -= tileptr02->bborder ;
+ 		endy02   += tileptr02->tborder ;
+ 	    }
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    val = (double)(tileptr1->oleft - oleft) / aspFactor;
+ 		    startx1 = cellptr1->xcenter + ROUND( val ) - Wdiv2 ;
+ 
+ 		    val = (double)(tileptr1->oright - oleft)/ aspFactor;
+ 		    endx1 = cellptr1->xcenter + ROUND( val ) - Wdiv2 ;
+ 
+ 		    val = (double)(tileptr1->obottom - obottom) * 
+ 							    aspFactor;
+ 		    starty1 = cellptr1->ycenter + ROUND( val ) - Hdiv2 ;
+ 
+ 		    val = (double)(tileptr1->otop - obottom)* aspFactor;
+ 		    endy1 = cellptr1->ycenter + ROUND( val ) - Hdiv2 ;
+ 		    startx1 -= tileptr1->lborder ;
+ 		    endx1   += tileptr1->rborder ;
+ 		    starty1 -= tileptr1->bborder ;
+ 		    endy1   += tileptr1->tborder ;
+ 
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 			if( othercell <= numcells ) {
+ 			    startx2 -= tileptr2->lborder ;
+ 			    endx2   += tileptr2->rborder ;
+ 			    starty2 -= tileptr2->bborder ;
+ 			    endy2   += tileptr2->tborder ;
+ 			}
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gpass2.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gpass2.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/gpass2.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,120 ----
+ #include "custom.h"
+ extern BUSTBOXPTR C ;
+ 
+ extern void maketabl(void);
+ extern int addhash( char hname[] );
+ 
+ void gpass2( FILE *fp )
+ {
+ 
+ int i ;
+ int xpos , ypos , class ;
+ int sequence , firstside , lastside ;
+ int cellnum , pinctr , term ;
+ int corner , ncorners , x , y , ecount , orient , norients ;
+ double aspub , asplb , space ;
+ char input[1024] ;
+ 
+ ecount = 0 ;
+ netctr = 0 ;
+ pinctr = 0 ;
+ maketabl() ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "cell") == 0 ) {
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+     } else if( strcmp( input , "pin") == 0 ) {
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	fscanf( fp , " %s " , input ) ; /* "signal"   */
+ 	fscanf( fp , " %s " , input ) ; /* signal name */
+ 	pinctr++ ;
+ 	addhash( input ) ;
+ 	fscanf( fp , " %d %d " , &xpos , &ypos );
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 	ecount++ ;
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	fscanf( fp , " %d %d " , &xpos , &ypos );
+     } else if( strcmp( input , "softcell") == 0 ) {
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , "%lf" , &asplb ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , "%lf" , &aspub ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+     } else if( strcmp( input , "sequence") == 0 ||
+ 				    strcmp( input , "group") == 0 ) {
+ 	fscanf( fp , " %d " , &sequence ) ;
+ 	for( i = 1 ; i <= sequence ; i++ ) {
+ 	    fscanf( fp , " %s " , input ) ; /* "pin"    */
+ 	    fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	    fscanf( fp , " %s " , input ) ; /* pin name */
+ 	    fscanf( fp , " %s " , input ) ; /* "signal"   */
+ 	    fscanf( fp , " %s " , input ) ; /* signal name */
+ 	    pinctr++ ;
+ 	    addhash( input ) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d %d " , &firstside , &lastside ) ;
+     } else if( strcmp( input , "pad") == 0 ) {
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+     } else if( strcmp( input , "sidespace") == 0 ) {
+ 	fscanf( fp , " %lf " , &space ) ;
+     }
+ }
+ rewind( fp ) ;
+ 
+ termarray = (TERMNETSPTR *) realloc( termarray , 
+ 		(pinctr + ecount + 1) * sizeof( TERMNETSPTR ) );
+ for( term = 1 + pinctr ; term <= pinctr + ecount ; term++ ) {
+     termarray[ term ] = TERMNETSNULL ;
+ }
+ 
+ pinnames = (char **) realloc( pinnames, 
+ 			(pinctr + ecount + 1) * sizeof(char *) );
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/grdcell.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/grdcell.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/grdcell.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,268 ----
+ #include "custom.h"
+ extern BUSTBOXPTR A ;
+ int ecount ;
+ 
+ extern void gpass2( FILE *fp );
+ extern void ggenorien(void);
+ extern int hashfind( char hname[] );
+ 
+ void grdcell( FILE *fp )
+ {
+ 
+ int i , cell , class ;
+ int xcenter , ycenter ;
+ int xpos , ypos ;
+ int sequence , k ;
+ int firstside , lastside , ncorners , corner , orient , norients ;
+ int x , y , minx , miny , maxx , maxy ;
+ int cellnum , pinctr , netx ;
+ double aspub , asplb , space ;
+ char input[1024] ;
+ CELLBOXPTR ptr ;
+ TERMBOXPTR term , saveterm ;
+ NETBOXPTR netptr , saveptr ;
+ 
+ gpass2( fp ) ;
+ pinctr = 0   ;
+ ecount = 0   ;
+ 
+ cell = 0 ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "cell") == 0 ) {
+ 	ptr = cellarray[ ++cell ] ;
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 
+ 	for( k = 0 ; k <= 30 ; k++ ) {
+ 	    A[k].xc = 0 ;
+ 	    A[k].yc = 0 ;
+ 	}
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    A[ ++A[0].xc ].xc = x ;
+ 	    A[ A[0].xc ].yc = y ;
+ 	}
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    x = A[k].xc ;
+ 	    y = A[k].yc ;
+ 	    if( k == 1 ) {
+ 		minx = x ;
+ 		miny = y ;
+ 		maxx = x ;
+ 		maxy = y ;
+ 	    } else {
+ 		if( x < minx ) {
+ 		    minx = x ;
+ 		}
+ 		if( x > maxx ) {
+ 		    maxx = x ;
+ 		}
+ 		if( y < miny ) {
+ 		    miny = y ;
+ 		}
+ 		if( y > maxy ) {
+ 		    maxy = y ;
+ 		}
+ 	    }
+ 	}
+ 	xcenter = (maxx + minx) / 2 ;
+ 	ycenter = (maxy + miny) / 2 ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+ 
+     } else if( strcmp( input , "pad") == 0 ) {
+ 
+ 	ptr = cellarray[ ++cell ] ;
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* pad name */
+ 	for( k = 0 ; k <= 30 ; k++ ) {
+ 	    A[k].xc = 0 ;
+ 	    A[k].yc = 0 ;
+ 	}
+ 
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    A[ ++A[0].xc ].xc = x ;
+ 	    A[ A[0].xc ].yc = y ;
+ 	}
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    x = A[k].xc ;
+ 	    y = A[k].yc ;
+ 	    if( k == 1 ) {
+ 		minx = x ;
+ 		miny = y ;
+ 		maxx = x ;
+ 		maxy = y ;
+ 	    } else {
+ 		if( x < minx ) {
+ 		    minx = x ;
+ 		}
+ 		if( x > maxx ) {
+ 		    maxx = x ;
+ 		}
+ 		if( y < miny ) {
+ 		    miny = y ;
+ 		}
+ 		if( y > maxy ) {
+ 		    maxy = y ;
+ 		}
+ 	    }
+ 	}
+ 	xcenter = (maxx + minx) / 2 ;
+ 	ycenter = (maxy + miny) / 2 ;
+ 
+     } else if( strcmp( input , "padside") == 0 ) {
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+ 
+     } else if( strcmp( input , "sidespace") == 0 ) {
+ 	fscanf( fp , " %lf " , &space ) ;
+ 
+     } else if( strcmp( input , "softcell") == 0 ) {
+ 
+ 	ptr = cellarray[ ++cell ] ;
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+ 
+     } else if( strcmp( input , "pin") == 0 ) {
+ 
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	fscanf( fp , " %s " , input ) ; /* "signal" */
+ 	fscanf( fp , " %s " , input ) ; /* signal name */
+ 	fscanf( fp , " %d %d " , &xpos , &ypos ) ;
+ 
+ 	pinctr++ ;
+ 
+ 	netx = hashfind( input ) ;
+ 	netptr  = netarray[netx]->netptr ;
+ 	for( ; ; netptr = netptr->nextterm ){ 
+ 	    if( netptr->terminal == pinctr ) {
+ 		break ;
+ 	    }
+ 	}
+ 	netptr->cell = cell ;
+ 	netptr->PorE = 1 ;
+ 
+ 	if( ptr->softflag == 0 ) {
+ 	    term = ptr->config[0]->termptr ;
+ 	    for( ; ; term = term->nextterm ){ 
+ 		if( term->terminal == pinctr ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    term->xpos  = xpos - xcenter ;
+ 	    term->ypos  = ypos - ycenter ;
+ 	    term->oxpos = xpos - xcenter ;
+ 	    term->oypos = ypos - ycenter ;
+ 	}
+ 
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	pinnames[++ecount + maxterm] = (char *)
+ 			malloc((strlen(input) + 1) * sizeof(char) );
+ 	sprintf( pinnames[ecount + maxterm] , "%s" , input ) ;
+ 
+ 	saveptr = netptr->nextterm ;
+ 	netptr  = netptr->nextterm = (NETBOXPTR) 
+ 					 malloc( sizeof(NETBOX) );
+ 	netptr->nextterm = saveptr ;
+ 	netptr->terminal = ecount + maxterm ;
+ 	netptr->xpos     = 0    ;
+ 	netptr->ypos     = 0    ;
+ 	netptr->newx     = 0    ;
+ 	netptr->newy     = 0    ;
+ 	netptr->flag     = 0    ;
+ 	netptr->cell     = cell ;
+ 	netptr->PorE     = 0 ;
+ 	netptr->skip     = 0 ;
+ 
+ 	fscanf( fp , " %d %d " , &xpos , &ypos ) ;
+ 
+ 	ptr->numterms++ ;
+ 	
+ 	saveterm = term->nextterm ;
+ 	term = term->nextterm = (TERMBOXPTR) malloc( sizeof(TERMBOX) ) ;
+ 
+ 	term->nextterm = saveterm ;
+ 	term->terminal = ecount + maxterm ;
+ 	term->xpos  = xpos - xcenter ;
+ 	term->ypos  = ypos - ycenter ;
+ 	term->oxpos = xpos - xcenter ;
+ 	term->oypos = ypos - ycenter ;
+ 	
+     } else if( strcmp( input , "asplb") == 0 ) {
+ 
+ 	fscanf( fp , "%lf" , &asplb ) ;
+ 
+     } else if( strcmp( input , "aspub") == 0 ) {
+ 
+ 	fscanf( fp , "%lf" , &aspub ) ;
+ 
+     } else if( strcmp( input , "sequence") == 0 ||
+ 				    strcmp( input , "group") == 0 ) {
+ 	fscanf( fp , " %d " , &sequence ) ;
+ 	for( i = 1 ; i <= sequence ; i++ ) {
+ 	    fscanf( fp , " %s " , input ) ; /* "pin"    */
+ 	    fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	    fscanf( fp , " %s " , input ) ; /* pin name */
+ 	    pinctr++ ;
+ 	    fscanf( fp , " %s " , input ) ; /* "signal" */
+ 	    fscanf( fp , " %s " , input ) ; /* signal name */
+ 
+ 	    netx = hashfind( input ) ;
+ 	    netptr  = netarray[netx]->netptr ;
+ 	    for( ; ; netptr = netptr->nextterm ){ 
+ 		if( netptr->terminal == pinctr ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    netptr->cell = cell ;
+ 	    netptr->PorE = 1 ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d %d " , &firstside , &lastside ) ;
+     }
+ }
+ 
+ ggenorien() ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/grepair.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/grepair.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/grepair.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,53 ----
+ #include "route.h"
+ 
+ 
+ void grepair(void)
+ {
+ GNODEPTR gptr , g2ptr ;
+ int i ;
+ 
+ for( i = 1 ; i <= numnodes + maxpnode ; i++ ) {
+     gptr = gnodeArray[i] ;
+     if( gptr == (GNODEPTR) NULL ) {
+ 	continue ;
+     }
+     if( i <= numnodes ) {
+ 	if( gptr->node <= numnodes ) {
+ 	    continue ;
+ 	} else {
+ 	    for( ; ; ) {
+ 		if( gptr != (GNODEPTR) NULL ) { 
+ 		    g2ptr = gptr->next ;
+ 		    if( gptr->node > numnodes ) {
+ 			free( gptr ) ;
+ 			gptr = g2ptr ;
+ 		    } else{
+ 			gnodeArray[i] = gptr ;
+ 			break ;
+ 		    }
+ 		} else {
+ 		    gnodeArray[i] = (GNODEPTR) NULL ; 
+ 		    break ;
+ 		}
+ 	    }
+ 	}
+ 	gptr = gnodeArray[i] ;
+ 	for( ; ; ) {
+ 	    if( gptr == (GNODEPTR) NULL ) { 
+ 		break ;
+ 	    }
+ 	    gptr->length = gptr->ilength ;
+ 	    gptr->cost = gptr->ilength ;
+ 	    gptr = gptr->next ;
+ 	}
+     } else {
+ 	while( gptr != (GNODEPTR) NULL ) { 
+ 	    g2ptr = gptr->next ;
+ 	    free( gptr ) ;
+ 	    gptr = g2ptr ;
+ 	}
+ 	gnodeArray[i] = (GNODEPTR) NULL ; 
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/hash.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/hash.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/hash.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,103 ----
+ #include "custom.h"
+ 
+ void maketabl(void)
+ {
+ int i ;
+ 
+ hashtab = ( HASHPTR * ) malloc( 1009 * sizeof( HASHPTR ) ) ;
+ for( i = 0 ; i < 1009 ; i++ ) {
+     hashtab[i] = ( HASHPTR ) NULL ;
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void delHtab(void)
+ {
+ 
+ int i ;
+ HASHPTR hptr , zapptr ;
+ 
+ for( i = 0 ; i < 1009 ; i++ ) {
+     hptr = hashtab[i] ;
+     if( hptr != (HASHPTR) NULL ) {
+ 	zapptr = hptr ;
+ 	while( hptr->hnext != (HASHPTR) NULL ) {
+ 	    hptr = hptr->hnext ;
+ 	    free( zapptr ) ;
+ 	    zapptr = hptr ;
+ 	}
+ 	free( hptr ) ;
+     }
+ }
+ free( hashtab ) ;
+ return ;
+ }
+ 
+ 
+ int addhash( char hname[] )
+ {
+ 
+ int i ;
+ HASHPTR hptr ;
+ unsigned int hsum = 0 ;
+ 
+ for( i = 0 ; i < strlen( hname ) ; i++ ) {
+     hsum += ( unsigned int ) hname[i] ;
+ }
+ hsum %= 1009 ;
+ if( (hptr = hashtab[hsum]) == (HASHPTR) NULL ) {
+     hptr = hashtab[hsum] = (HASHPTR) malloc( sizeof( HASHBOX ) ) ;
+     hptr->hnext = (HASHPTR) NULL ;
+     hptr->hnum = ++netctr ;
+     hptr->hname = (char *)malloc( (strlen(hname) + 1) * sizeof( char ));
+     sprintf( hptr->hname , "%s" , hname ) ;
+     return(1) ;
+ } else {
+     for( ; ; ) {
+ 	if( strcmp( hname , hptr->hname ) == 0 ) {
+ 	    return(0) ;
+ 	}
+ 	if( hptr->hnext == (HASHPTR) NULL ) {
+ 	    hptr = hptr->hnext = (HASHPTR) malloc( sizeof(HASHBOX));
+ 	    hptr->hnext = (HASHPTR) NULL ;
+ 	    hptr->hnum = ++netctr ;
+ 	    hptr->hname = (char *)malloc((strlen(hname)+ 1) * 
+ 							sizeof(char));
+ 	    sprintf( hptr->hname , "%s" , hname ) ;
+ 	    return(1) ;
+ 	} else {
+ 	    hptr = hptr->hnext ;
+ 	}
+     }
+ }
+ }
+ 
+ 
+ int hashfind( char hname[] )
+ {
+ 
+ int i ;
+ HASHPTR hptr ;
+ unsigned int hsum = 0 ;
+ 
+ for( i = 0 ; i < strlen( hname ) ; i++ ) {
+     hsum += ( unsigned int ) hname[i] ;
+ }
+ hsum %= 1009 ;
+ if( (hptr = hashtab[hsum]) == (HASHPTR) NULL ) {
+     return(0) ;
+ } else {
+     for( ; ; ) {
+ 	if( strcmp( hname , hptr->hname ) == 0 ) {
+ 	    return( hptr->hnum ) ;
+ 	}
+ 	if( hptr->hnext == (HASHPTR) NULL ) {
+ 	    return(0) ;
+ 	} else {
+ 	    hptr = hptr->hnext ;
+ 	}
+     }
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/hprobes.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/hprobes.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/hprobes.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,339 ----
+ #include "geo.h"
+ #define DEBUG
+ 
+ extern int tprop( TNODEPTR r , int value );
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void doubleBack( DLINK1PTR dptr );
+ 
+ void hprobes(void)
+ {
+ 
+ DLINK1PTR downPtr , up1ptr , up2ptr , checkPtr , ptr ;
+ int dx , dy1 , dy2 , dedge , by1 , by2 , uedge , edge , check ;
+ int u1y2 , u1y1 , u1x , u2y2 , u2y1 , u2x ;
+ 
+ downPtr = vFixedList ;
+ for( ; downPtr != (DLINK1PTR) NULL ; downPtr = downPtr->next ) {
+     dedge = downPtr->edge ;
+     if( edgeList[dedge].UorR > 0 ) {
+ 	continue ;
+     }
+     dx  = edgeList[dedge].loc   ;
+     dy1 = edgeList[dedge].start ;
+     dy2 = edgeList[dedge].end   ;
+     
+     if( edgeList[ edgeList[dedge].prevEdge ].UorR == 1 ) {
+ 	up2ptr = Vptrs[ tprop( Vroot , dx ) ] ;
+ 	for(; up2ptr != (DLINK1PTR) NULL ; up2ptr = up2ptr->next){
+ 	    uedge = up2ptr->edge ;
+ 	    if( edgeList[uedge].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    u2x  = edgeList[uedge].loc   ;
+ 	    u2y1 = edgeList[uedge].start ;
+ 	    u2y2 = edgeList[uedge].end   ;
+ 	    if( u2y2 < dy2 || u2y1 >= dy2 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+     } else {
+ 	up2ptr = (DLINK1PTR) NULL ;
+     }
+     if( edgeList[ edgeList[dedge].nextEdge ].UorR == -1 ) {
+ 	up1ptr = Vptrs[ tprop( Vroot , dx ) ] ;
+ 	for(; up1ptr != (DLINK1PTR) NULL ; up1ptr = up1ptr->next){
+ 	    uedge = up1ptr->edge ;
+ 	    if( edgeList[uedge].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    u1x  = edgeList[uedge].loc   ;
+ 	    u1y1 = edgeList[uedge].start ;
+ 	    u1y2 = edgeList[uedge].end   ;
+ 	    if( u1y2 <= dy1 || u1y1 > dy1 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+     } else {
+ 	up1ptr = (DLINK1PTR) NULL ;
+     }
+     if( up2ptr != (DLINK1PTR) NULL && up2ptr == up1ptr ) {
+ 	check = 1 ;
+ 	checkPtr = Vptrs[ tprop( Vroot , dx ) ] ;
+ 	for(; checkPtr != (DLINK1PTR) NULL ;
+ 				    checkPtr = checkPtr->next ) {
+ 	    if( edgeList[ checkPtr->edge ].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].loc >= u2x ) {
+ 		break ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].start >= dy2 ||
+ 			edgeList[ checkPtr->edge ].end <= dy1 ) {
+ 		continue ;
+ 	    }
+ 	    check = 0 ;
+ 	    break ;
+ 	}
+ 	if( check ) {
+ 	    edgeList[++numProbes + edgeCount].start  = dx ;
+ 	    edgeList[numProbes + edgeCount].end      = u2x  ;
+ 	    edgeList[numProbes + edgeCount].loc      = dy2 ;
+ 	    edgeList[numProbes + edgeCount].length   = u2x - dx ;
+ 	    edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	    edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	    edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 	    tinsert( &hEdgeRoot, dy2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	    fprintf(fpdebug,"hprobe:%d  ", numProbes ) ;
+ 	    fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					dx , u2x , dy2 , 1 ) ;
+ #endif
+ 	    edgeList[++numProbes + edgeCount].start  = dx ;
+ 	    edgeList[numProbes + edgeCount].end      = u2x  ;
+ 	    edgeList[numProbes + edgeCount].loc      = dy1 ;
+ 	    edgeList[numProbes + edgeCount].length   = u2x - dx ;
+ 	    edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	    edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	    edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 	    tinsert( &hEdgeRoot, dy1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	    fprintf(fpdebug,"hprobe:%d  ", numProbes ) ;
+ 	    fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					dx , u2x , dy1 , -1 ) ;
+ #endif
+ 	} else {
+ 	    doubleBack( downPtr ) ;	
+ 	}
+ 	continue ;
+     }
+     if( up2ptr != (DLINK1PTR) NULL &&
+ 	    edgeList[ edgeList[up2ptr->edge].prevEdge ].UorR == -1 ) {
+ 	ptr = Vptrs[ tprop( Vroot , u2x ) ] ;
+ 	for( ptr = ptr->next; ptr != (DLINK1PTR) NULL; ptr = ptr->next){
+ 	    if( edgeList[ptr->edge].loc > u2x ) {
+ 		break ;
+ 	    }
+ 	}
+ 	if( ptr == (DLINK1PTR) NULL ) {
+ 	    ptr = vFixedEnd ;
+ 	} else {
+ 	    ptr = ptr->prev ;
+ 	}
+ 	for( ; ptr != (DLINK1PTR) NULL; ptr = ptr->prev){
+ 	    edge = ptr->edge ;
+ 	    if( edgeList[edge].UorR > 0 ) {
+ 		continue ;
+ 	    }
+ 	    by1 = edgeList[edge].start ;
+ 	    by2 = edgeList[edge].end   ;
+ 	    if( by2 <= u2y1 || by1 > u2y1 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+ 	if( downPtr == ptr ) {
+ 	    check = 1 ;
+ 	    checkPtr = Vptrs[ tprop( Vroot , dx ) ] ;
+ 	    for(; checkPtr != (DLINK1PTR) NULL ;
+ 				    checkPtr = checkPtr->next ) {
+ 		if( edgeList[ checkPtr->edge ].UorR < 0 ) {
+ 		    continue ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].loc >= u2x ) {
+ 		    break ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].start >= dy2 ||
+ 			edgeList[ checkPtr->edge ].end <= u2y1 ) {
+ 		    continue ;
+ 		}
+ 		check = 0 ;
+ 		break ;
+ 	    }
+ 	    if( check ) {
+ 		edgeList[++numProbes + edgeCount].start  = dx ;
+ 		edgeList[numProbes + edgeCount].end      = u2x  ;
+ 		edgeList[numProbes + edgeCount].loc      = dy2 ;
+ 		edgeList[numProbes + edgeCount].length   = u2x - dx ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 		tinsert( &hEdgeRoot, dy2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"hprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					dx , u2x , dy2 , 1 ) ;
+ #endif
+ 		edgeList[++numProbes + edgeCount].start  = dx ;
+ 		edgeList[numProbes + edgeCount].end      = u2x  ;
+ 		edgeList[numProbes + edgeCount].loc      = u2y1 ;
+ 		edgeList[numProbes + edgeCount].length   = u2x - dx ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 		tinsert( &hEdgeRoot, u2y1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"hprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 				    dx , u2x , u2y1 , -1 ) ;
+ #endif
+ 	    }
+ 	}
+     }
+     if( up1ptr != (DLINK1PTR) NULL &&
+ 	    edgeList[ edgeList[up1ptr->edge].nextEdge ].UorR == 1 ) {
+ 	ptr = Vptrs[ tprop( Vroot , u1x ) ] ;
+ 	for( ptr = ptr->next; ptr != (DLINK1PTR) NULL; ptr = ptr->next){
+ 	    if( edgeList[ptr->edge].loc > u1x ) {
+ 		break ;
+ 	    }
+ 	}
+ 	if( ptr == (DLINK1PTR) NULL ) {
+ 	    ptr = vFixedEnd ;
+ 	} else {
+ 	    ptr = ptr->prev ;
+ 	}
+ 	for( ; ptr != (DLINK1PTR) NULL; ptr = ptr->prev){
+ 	    edge = ptr->edge ;
+ 	    if( edgeList[edge].UorR > 0 ) {
+ 		continue ;
+ 	    }
+ 	    by1 = edgeList[edge].start ;
+ 	    by2 = edgeList[edge].end   ;
+ 	    if( by2 < u1y2 || by1 >= u1y2 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+ 	if( downPtr == ptr ) {
+ 	    check = 1 ;
+ 	    checkPtr = Vptrs[ tprop( Vroot , dx ) ] ;
+ 	    for(; checkPtr != (DLINK1PTR) NULL ;
+ 				    checkPtr = checkPtr->next ) {
+ 		if( edgeList[ checkPtr->edge ].UorR < 0 ) {
+ 		    continue ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].loc >= u1x ) {
+ 		    break ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].start >= u1y2 ||
+ 			edgeList[ checkPtr->edge ].end <= dy1 ) {
+ 		    continue ;
+ 		}
+ 		check = 0 ;
+ 		break ;
+ 	    }
+ 	    if( check ) {
+ 		edgeList[++numProbes + edgeCount].start  = dx ;
+ 		edgeList[numProbes + edgeCount].end      = u1x  ;
+ 		edgeList[numProbes + edgeCount].loc      = u1y2 ;
+ 		edgeList[numProbes + edgeCount].length   = u1x - dx ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 		tinsert( &hEdgeRoot, u1y2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"hprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					dx , u1x , u1y2 , 1 ) ;
+ #endif
+ 		edgeList[++numProbes + edgeCount].start  = dx ;
+ 		edgeList[numProbes + edgeCount].end      = u1x  ;
+ 		edgeList[numProbes + edgeCount].loc      = dy1 ;
+ 		edgeList[numProbes + edgeCount].length   = u1x - dx ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 		tinsert( &hEdgeRoot, dy1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"hprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					dx , u1x , dy1 , -1 ) ;
+ #endif
+ 	    }
+ 	}
+     }
+     doubleBack( downPtr ) ;
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void doubleBack( DLINK1PTR dptr )
+ {
+ 
+ int dx , dy1 , dy2 , ux , uy1 , uy2 , check , edge ;
+ DLINK1PTR checkPtr , ptr ;
+ 
+ dx  = edgeList[ dptr->edge ].loc   ;
+ dy2 = edgeList[ dptr->edge ].end   ;
+ dy1 = edgeList[ dptr->edge ].start ;
+ 
+ ptr = Vptrs[ tprop( Vroot , dx ) ] ;
+ for( ; ptr != (DLINK1PTR) NULL ; ptr = ptr->next ) {
+     edge = ptr->edge ;
+     if( edgeList[edge].UorR < 0 ) {
+ 	continue ;
+     }
+     ux  = edgeList[edge].loc   ;
+     uy1 = edgeList[edge].start ;
+     uy2 = edgeList[edge].end   ;
+     if( ! ( uy2 < dy2 && uy1 > dy1 )  ) {
+ 	continue ;
+     }
+     if( edgeList[ edgeList[edge].prevEdge ].UorR == -1 &&
+ 		edgeList[ edgeList[edge].nextEdge ].UorR == 1 ) {
+ 	check = 1 ;
+ 	checkPtr = Vptrs[ tprop( Vroot , dx ) ] ;
+ 	for(; checkPtr != (DLINK1PTR) NULL ; checkPtr = checkPtr->next){
+ 	    if( checkPtr == dptr ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].UorR > 0 ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].loc > ux ) {
+ 		break ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].start >= uy2 ||
+ 			edgeList[ checkPtr->edge ].end <= uy1 ) {
+ 		continue ;
+ 	    }
+ 	    check = 0 ;
+ 	    break ;
+ 	}
+     } else {
+ 	check = 0 ;
+     }
+     if( check ) {
+ 	edgeList[++numProbes + edgeCount].start  = dx ;
+ 	edgeList[numProbes + edgeCount].end      = ux ;
+ 	edgeList[numProbes + edgeCount].loc      = uy2 ;
+ 	edgeList[numProbes + edgeCount].length   = ux - dx ;
+ 	edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 	tinsert( &hEdgeRoot, uy2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	fprintf(fpdebug,"hprobe:%d  start:%d  end:%d  loc:%d  UorR:%d\n",
+ 		    numProbes, dx , ux , uy2 , 1 ) ;
+ #endif
+ 	edgeList[++numProbes + edgeCount].start  = dx ;
+ 	edgeList[numProbes + edgeCount].end      = ux ;
+ 	edgeList[numProbes + edgeCount].loc      = uy1 ;
+ 	edgeList[numProbes + edgeCount].length   = ux - dx ;
+ 	edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 	tinsert( &hEdgeRoot, uy1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	fprintf(fpdebug,"hprobe:%d  start:%d  end:%d  loc:%d  UorR:%d\n",
+ 		    numProbes, dx , ux , uy1 , -1 ) ;
+ #endif
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/indepmake
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/indepmake:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/indepmake	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,220 ----
+ #
+ #  Octtools 3.0 Makefile
+ #
+ #  TimberWolfMC - Macro-Cell place and route program
+ #
+ #  Makefile created on Tue Jan 24 16:06:52 PST 1989 by octtools (using 'create-octtools-makefile')
+ #
+ #  Copyright (c) 1988, 1989, Regents of the University of California
+ #
+ #
+ # Description of the 'targets':
+ #
+ #  all:			create the tags file, run lint, build the tool/package
+ #  install:		build the tool/package and install all the necessary files
+ #  uninstall:		remove the files that would be installed with 'make install'
+ #  debug:		build and install the debug versions of the package
+ #				(for tools, build the debug versions and leave in the
+ #				source directories; note: debug versions of tools
+ #				MUST be built using 'make debug' or 'make debug-*')
+ #  header:		install the exported header files for the package
+ #  lint:		run lint
+ #  clean:		remove the binary, object files, and temporary files
+ #  require:		echo a list of packages used in the compilation of the tool/package
+ #  toolrequire:		echo a list of tools used in the running of the tool
+ #  test:		run a simple test on the tool/package
+ #  tags:		build the 'tags' file (for 'vi')
+ #  TAGS:		build the 'TAGS' file (for 'emacs')
+ #  info:		echo a one-line description of the tool/package
+ #  print:		print out the man page or doc file for the tool/package
+ #  dist:		dist the tool/package
+ #  test-dist:		tell what would be disted in 'make dist' were run
+ #  depend:		generate the dependency information
+ #  strip-depend:	remove the dependency information
+ #
+ #
+ # Description of the 'variables':
+ #
+ #  BUILD:		name of the program that builds a 'Makefile' from
+ #				'Makefile.template'
+ #  CAD:			location of the CAD tools (for installation)
+ #  CADROOT:		run-time location of the CAD libraries (can have '~')
+ #  CC:			name of the C-compiler
+ #  COMPFLAG:		compilation level (usually nothing, -g, -pg, or -O)
+ #  CP:			name of the program used for installation ('cp' for installing
+ #				the file each time, 'ln -s' for installing a link)
+ #  LDFLAGS:		flags used for linking (e.g., -lXMenu -lX -lm)
+ #  LINTCREATEFLAG:	flag used by 'lint' for creating lint libraries
+ #				(-C for BSD, ULTRIX 2.2; -o for IBM RT/PC, ULTRIX 3.0)
+ #  PRINTER:		name of the printer
+ #  SHELL:		shell used by 'make' (should always be the bourne shell)
+ #
+ #
+ #------------------------------------------------------------------------------
+ 
+ # for HPUX
+ SHELL	= /bin/sh
+ 
+ CAD	= /net/shambhala/users/octtools-3.0
+ CADROOT	= ~octtools
+ UTILS	= /net/shambhala/users/octtools-3.0/utils
+ 
+ LINTCREATEFLAG = -C
+ COMPFLAG=
+ CP = cp
+ BUILD = ${UTILS}/bin/create-octtools-makefile
+ 
+ NAME	= TimberWolfMC
+ 
+ # packages required for this package/tool
+ REQUIRE	= mm port
+ 
+ # tools required for this tool
+ TOOLREQUIRE = 
+ 
+ SRCS1 = 23tree.c addpins.c analyze.c bellman.c buster.c changraph.c checkpen.c config1.c config2.c config3.c density.c doborder.c doublecheck.c finalout.c finalpin.c
+ OBJS1 = 23tree.o addpins.o analyze.o bellman.o buster.o changraph.o checkpen.o config1.o config2.o config3.o density.o doborder.o doublecheck.o finalout.o finalpin.o
+ 
+ SRC	= ${SRCS1} findcheck.c findcost.c findloc.c findnodes.c findside.c fixpenal.c fulllink.c fuloop.c genorient.c gentwf.c ggenorien.c gglobals.c globals.c gmain.c goverlap.c goverlapf.c goverlapx.c gpass2.c grdcell.c grepair.c hash.c hprobes.c initbb.c loadbins.c loadpg.c main.c makebins.c makelink.c makesite.c move.c mshortest.c mt.c neworient.c outbig.c outgeo.c outpin.c output.c outsmall.c parser.c pass2.c perimeter.c placepads.c placepin.c prboard.c prepair.c prestrict.c printgph.c printnets.c procesnet.c readcells.c readgeo.c readgraph.c readnets.c readpar.c readpnode.c rebin.c reduceg.c rglobals.c rmain.c routenet.c savewolf.c scrapnet.c scrappin.c selectpin.c setpwates.c shortpath.c test2loop.c testloop.c twstats.c uaspect.c ufixnet.c ufixpin.c uloop.c unbust.c upin.c upinswap.c usite0.c usite1.c usite2.c usiteo1.c usiteo2.c usoftnet.c usoftpin.c utemp.c vprobes.c watesides.c wirecosts.c wireest.c wireratio.c woverlap.c woverlapf.c woverlapx.c xgraph.c ygraph.c
+ LSRC	= ${SRCS1} findcheck.c findcost.c findloc.c findnodes.c findside.c fixpenal.c fulllink.c fuloop.c genorient.c gentwf.c ggenorien.c gglobals.c globals.c gmain.c goverlap.c goverlapf.c goverlapx.c gpass2.c grdcell.c grepair.c hash.c hprobes.c initbb.c loadbins.c loadpg.c main.c makebins.c makelink.c makesite.c move.c mshortest.c mt.c neworient.c outbig.c outgeo.c outpin.c output.c outsmall.c parser.c pass2.c perimeter.c placepads.c placepin.c prboard.c prepair.c prestrict.c printgph.c printnets.c procesnet.c readcells.c readgeo.c readgraph.c readnets.c readpar.c readpnode.c rebin.c reduceg.c rglobals.c rmain.c routenet.c savewolf.c scrapnet.c scrappin.c selectpin.c setpwates.c shortpath.c test2loop.c testloop.c twstats.c uaspect.c ufixnet.c ufixpin.c uloop.c unbust.c upin.c upinswap.c usite0.c usite1.c usite2.c usiteo1.c usiteo2.c usoftnet.c usoftpin.c utemp.c vprobes.c watesides.c wirecosts.c wireest.c wireratio.c woverlap.c woverlapf.c woverlapx.c xgraph.c ygraph.c
+ OBJ	= ${OBJS1} findcheck.o findcost.o findloc.o findnodes.o findside.o fixpenal.o fulllink.o fuloop.o genorient.o gentwf.o ggenorien.o gglobals.o globals.o gmain.o goverlap.o goverlapf.o goverlapx.o gpass2.o grdcell.o grepair.o hash.o hprobes.o initbb.o loadbins.o loadpg.o main.o makebins.o makelink.o makesite.o move.o mshortest.o mt.o neworient.o outbig.o outgeo.o outpin.o output.o outsmall.o parser.o pass2.o perimeter.o placepads.o placepin.o prboard.o prepair.o prestrict.o printgph.o printnets.o procesnet.o readcells.o readgeo.o readgraph.o readnets.o readpar.o readpnode.o rebin.o reduceg.o rglobals.o rmain.o routenet.o savewolf.o scrapnet.o scrappin.o selectpin.o setpwates.o shortpath.o test2loop.o testloop.o twstats.o uaspect.o ufixnet.o ufixpin.o uloop.o unbust.o upin.o upinswap.o usite0.o usite1.o usite2.o usiteo1.o usiteo2.o usoftnet.o usoftpin.o utemp.o vprobes.o watesides.o wirecosts.o wireest.o wireratio.o woverlap.o woverlapf.o woverlapx.o xgraph.o ygraph.o
+ HDR	= 23tree.h custom.h geo.h kenk.h lists.h mt.h route.h
+ 
+ TOOLINSTALL= ${CAD}/bin/${TARGET} ${CAD}/man/man1/${MAN}
+ INSTALL	= ${PKGINSTALL} ${TOOLINSTALL} 
+ 
+ DISTDEST= ${CAD}/src/${NAME}
+ DISTHOST= octtools at shambhala
+ MISC	= Makefile Makefile.template 
+ 
+ LIBS	= $(CAD)/lib/libmm$(COMPFLAG).a $(CAD)/lib/liberrtrap$(COMPFLAG).a $(CAD)/lib/libuprintf$(COMPFLAG).a $(CAD)/lib/libport$(COMPFLAG).a
+ LINTLIBS= $(CAD)/lib/llib-lmm.ln $(CAD)/lib/llib-lport.ln
+ 
+ TARGET	= ${NAME}
+ TARGETG	= ${NAME}-g
+ TARGETPG	= ${NAME}-pg
+ MAN	= ${NAME}.1
+ 
+ PRINTER	= lps40
+ MACROS	= -man.4.3
+ PRINT	= enscript
+ TROFF	= ptroff
+ TBL	= tbl
+ 
+ MAKEVARS =	\
+ 		"CAD=${CAD}" \
+ 		"CADROOT=${CADROOT}" \
+ 		"CC=${CC}" \
+ 		"CP=${CP}" \
+ 		"COMPFLAG=${COMPFLAG}" \
+ 		"LINTCREATEFLAG=${LINTCREATEFLAG}" \
+ 		"MAKE=$(MAKE)" \
+ 		"MACROS=${MACROS}" \
+ 		"P=${P}" \
+ 		"PRINT=${PRINT}" \
+ 		"PRINTER=${PRINTER}" \
+ 		"TBL=${TBL}" \
+ 		"TROFF=${TROFF}" \
+ 		"UTILS=${UTILS}" \
+ 		"VPATH=${VPATH}"
+ 
+ INCLUDE	= -I${CAD}/include 
+ CFLAGS	= ${COMPFLAG} ${INCLUDE} '-DCADROOT="${CADROOT}"'
+ VERSION	= "-DCUR_DATE=\"`date | awk '{print $$2, $$3, $$6}'`\"" \
+ 	  "-DCUR_TIME=\"`date | awk '{print $$4}'`\""
+ LINTFLAGS= ${INCLUDE} '-DCADROOT="${CADROOT}"'
+ LDFLAGS	= -lm
+ 
+ #-----------------------------------------------------------------------
+ 
+ all: ${SRC}
+ 	indep-frend -I. -I../include ${SRC} -lmm -lerrtrap -luprintf -lport ${LDFLAGS} ; rm database
+ 
+ 
+ #all: tags lint ${TARGET}
+ 
+ #build: Makefile.template
+ #	${BUILD} Makefile.template
+ build:
+ 
+ install: ${INSTALL}
+ 
+ uninstall:
+ 	rm -f ${INSTALL}
+ 
+ version.o: version.c
+ 	${CC} ${CFLAGS} ${VERSION} -c version.c
+ 	touch version.c
+ 
+ debug: debug-g debug-pg
+ 
+ 
+ debug-g:
+ 	rm -f ${OBJ}
+ 	$(MAKE) COMPFLAG=-g ${MFLAGS} ${MAKEVARS} ${TARGETG}
+ 
+ debug-pg:
+ 	rm -f ${OBJ}
+ 	$(MAKE) COMPFLAG=-pg ${MFLAGS} ${MAKEVARS} ${TARGETPG}
+ 
+ 
+ ${TARGET} ${TARGETG} ${TARGETPG}: ${OBJ} ${LIBS}
+ 	${CC} ${COMPFLAG} -o $@ ${OBJ} ${LIBS} ${LDFLAGS}
+ 
+ header::
+ 
+ ${CAD}/bin/${TARGET}: ${TARGET}
+ 	rm -f $@
+ 	${CP} $? $@
+ 	strip $@
+ 
+ ${CAD}/man/man1/${MAN}: ${MAN}
+ 	${TBL} < $? > $@
+ 
+ lint: ${LSRC} ${DRVRSRC} ${HDR} ${LINTLIBS}
+ 	lint ${LINTFLAGS} ${LSRC} ${DRVRSRC} ${LINTLIBS} ${LDFLAGS} | tee lint
+ 
+ clean::
+ 	rm -f ${OBJ} ${DRVROBJ} ${TARGET} ${TARGETG} ${TARGETPG} ${DRIVER} tags TAGS ${LIB} ${LIBG} ${LIBPG} ${LINTLIB} lint make.out mktemp
+ 
+ require:
+ 	@echo ${REQUIRE}
+ 
+ toolrequire:
+ 	@echo ${TOOLREQUIRE}
+ 
+ test::
+ 	@test -f ${CAD}/bin/${TARGET}
+ 
+ tags: ${LSRC} ${DRVRSRC} ${HDR}
+ 	ctags ${LSRC} ${DRVRSRC} ${HDR}
+ 
+ TAGS: ${LSRC} ${DRVRSRC} ${HDR}
+ 	etags ${LSRC} ${DRVRSRC} ${HDR}
+ 
+ info:
+ 	@echo '${NAME}:  Macro-Cell place and route program'
+ 
+ print: ${DOC} ${MAN}
+ 	${TBL} < ${MAN} | ${TROFF} -P${PRINTER} ${MACROS}
+ 
+ dist: ${SRC} ${DRVRSRC} ${HDR} ${DOC} ${MAN}
+ 	rdist -Rich ${SRC} ${DRVRSRC} ${HDR} ${DOC} ${MAN} ${MISC} ${DISTHOST}:${DISTDEST}
+ 
+ test-dist: ${SRC} ${DRVRSRC} ${HDR} ${DOC} ${MAN}
+ 	rdist -Richv ${SRC} ${DRVRSRC} ${HDR} ${DOC} ${MAN} ${MISC} ${DISTHOST}:${DISTDEST}
+ 
+ depend: ${SRC} ${DRVRSRC} ${HDR}
+ 	@rm -f mktemp
+ 	@sed '/^#--DO NOT CHANGE ANYTHING AFTER THIS LINE/,$$d' Makefile > mktemp
+ 	@echo '#--DO NOT CHANGE ANYTHING AFTER THIS LINE' >> mktemp
+ 	@${UTILS}/bin/cc-M ${INCLUDE} ${SRC} ${DRVRSRC} | sed 's|${CAD}|$${CAD}|g' >>mktemp
+ 	@mv mktemp Makefile
+ 
+ strip-depend:
+ 	@rm -f mktemp
+ 	@sed '/^#--DO NOT CHANGE ANYTHING AFTER THIS LINE/,$$d' Makefile > mktemp
+ 	@mv mktemp Makefile
+ 
+ #--EXTRA TARGETS
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/initbb.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/initbb.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/initbb.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,160 ----
+ #include "custom.h"
+ int bbleft , bbright , bbbottom , bbtop ;
+ int bbbl , bbbr , bbbb , bbbt ;
+ 
+ void initbb(void)
+ {
+ 
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ int xcenter , ycenter , cell , l , r , b , t ;
+ 
+ bbleft = 1000000 ;
+ bbbottom = 1000000 ;
+ bbtop = 0 ;
+ bbright = 0 ;
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     xcenter = cellptr->xcenter ;
+     ycenter = cellptr->ycenter ;
+     tileptr = cellptr->config[cellptr->orient] ;
+     l = xcenter + tileptr->left ;
+     r = xcenter + tileptr->right ;
+     b = ycenter + tileptr->bottom ;
+     t = ycenter + tileptr->top ;
+     if( l < bbleft ) {
+ 	bbleft = l ;
+     }
+     if( r > bbright ) {
+ 	bbright = r ;
+     }
+     if( b < bbbottom ) {
+ 	bbbottom = b ;
+     }
+     if( t > bbtop ) {
+ 	bbtop = t ;
+     }
+ }
+ return ;
+ 
+ }
+ 
+ 
+ 
+ 
+ int deltaBB( int cell , int xb , int yb )
+ {
+ 
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ int xcenter , ycenter , l , r , b , t , c ;
+ int cost ;
+ 
+ cost = 0 ;
+ cellptr = cellarray[cell] ;
+ xcenter = cellptr->xcenter ;
+ ycenter = cellptr->ycenter ;
+ tileptr = cellptr->config[cellptr->orient] ;
+ l = xcenter + tileptr->left ;
+ r = xcenter + tileptr->right ;
+ b = ycenter + tileptr->bottom ;
+ t = ycenter + tileptr->top ;
+ if( l == bbleft ) {
+     bbbl = 1000000 ;
+     for( c = 1 ; c <= numcells ; c++ ) {
+ 	if( cell == c ) {
+ 	    continue ;
+ 	}
+ 	cellptr = cellarray[c] ;
+ 	xcenter = cellptr->xcenter ;
+ 	tileptr = cellptr->config[cellptr->orient] ;
+ 	l = xcenter + tileptr->left ;
+ 	if( l < bbbl ) {
+ 	    bbbl = l ;
+ 	}
+     }
+     cost -= bbbl - bbleft ;
+ } else {
+     bbbl = bbleft ;
+ }
+ if( r == bbright ) {
+     bbbr = 0 ;
+     for( c = 1 ; c <= numcells ; c++ ) {
+ 	if( cell == c ) {
+ 	    continue ;
+ 	}
+ 	cellptr = cellarray[c] ;
+ 	xcenter = cellptr->xcenter ;
+ 	tileptr = cellptr->config[cellptr->orient] ;
+ 	r = xcenter + tileptr->right ;
+ 	if( r > bbbr ) {
+ 	    bbbr = r ;
+ 	}
+     }
+     cost -= bbright - bbbr ;
+ } else {
+     bbbr = bbright ;
+ }
+ if( b == bbbottom ) {
+     bbbb = 1000000 ;
+     for( c = 1 ; c <= numcells ; c++ ) {
+ 	if( cell == c ) {
+ 	    continue ;
+ 	}
+ 	cellptr = cellarray[c] ;
+ 	ycenter = cellptr->ycenter ;
+ 	tileptr = cellptr->config[cellptr->orient] ;
+ 	b = ycenter + tileptr->bottom ;
+ 	if( b < bbbb ) {
+ 	    bbbb = b ;
+ 	}
+     }
+     cost -= bbbb - bbbottom ;
+ } else {
+     bbbb = bbbottom ;
+ }
+ if( t == bbtop ) {
+     bbbt = 0 ;
+     for( c = 1 ; c <= numcells ; c++ ) {
+ 	if( cell == c ) {
+ 	    continue ;
+ 	}
+ 	cellptr = cellarray[c] ;
+ 	ycenter = cellptr->ycenter ;
+ 	tileptr = cellptr->config[cellptr->orient] ;
+ 	t = ycenter + tileptr->top ;
+ 	if( t > bbbt ) {
+ 	    bbbt = t ;
+ 	}
+     }
+     cost -= bbtop - bbbt ;
+ } else {
+     bbbt = bbtop ;
+ }
+ 
+ cellptr = cellarray[cell] ;
+ tileptr = cellptr->config[cellptr->orient] ;
+ l = xb + tileptr->left ;
+ r = xb + tileptr->right ;
+ b = yb + tileptr->bottom ;
+ t = yb + tileptr->top ;
+ if( l < bbbl ) {
+     bbbl = l ;
+     cost += bbbl - l ;
+ }
+ if( r > bbbr ) {
+     bbbr = r ;
+     cost += r - bbbr ;
+ }
+ if( b < bbbb ) {
+     bbbb = b ;
+     cost += bbbb - b ;
+ }
+ if( t > bbbt ) {
+     bbbt = t ;
+     cost += t - bbbt ;
+ }
+ return(cost) ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/kenk.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/kenk.h:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/kenk.h	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,69 ----
+ #include "port.h"
+ 
+ #define MAXNAMLEN 255
+ 
+ #define UNIX42
+ 
+ #define PRIVATE static
+ #define PUBLIC
+ #define PROC void
+ #define FORWARD extern
+ #define IMPORTS extern
+ #define EXPORTS extern
+ 
+ #define EOS '\0'
+ typedef char * String;
+ 
+ #define ELIF else if
+ #define LOOP for(;;)
+ #define AND &&
+ #define OR ||
+ #define NOT !
+ 
+ #define MAX(dragon,eagle) ((dragon) > (eagle) ? (dragon) : (eagle))
+ #define MIN(dragon,eagle) ((dragon) < (eagle) ? (dragon) : (eagle))
+ #define ABS(dragon) ((dragon) >= 0 ? (dragon) : (-(dragon)))
+ #define LOG2(x) log((double)(x))/.6931471806
+ 
+ #ifndef UNIX42
+ #define	CTRL(c) ('c' & 037)
+ #endif
+ #define	CTRLQ(c) (c & 037)
+ 
+ #define SEMP \
+ {\
+   register int i;\
+ \
+   for(i = 1;i < NSIG;++i)\
+     sighold(i);\
+ }
+ #define SEMV \
+ {\
+   register int i;\
+ \
+   for(i = 1;i < NSIG;++i)\
+     sigrelse(i);\
+ }
+ 
+ #define MAXINT 1000000000
+ #define MININT -1000000000
+ 
+ #define PI 3.14159
+ 
+ typedef char * RefAny;
+ 
+ #define ROUND(panther)\
+ ((panther) >= 0\
+ ? ((panther)-(int)(panther) >= .5\
+   ? (int)(panther)+1\
+   : (int)(panther))\
+ : (ABS((panther)-(int)(panther)) >= .5\
+   ? (int)(panther)-1\
+   : (int)(panther)))
+ 
+ #define ASSERT(ex)\
+ if(!(ex)) {\
+   fprintf(stderr,"Assertion failed in file %s at line # %d.\n",\
+   __FILE__, __LINE__);\
+   fflush(stderr);\
+   abort(); }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/lists.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/lists.h:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/lists.h	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,122 ----
+ #include "port.h"
+ /*
+ Macros to manage heap data and linked lists.
+ 
+ Assume:
+ 
+   typedef struct Type Type;
+   struct Type {
+     Type *succ; };
+   Type *node,*head;
+   head = NULL;
+ 
+ has been elaborated where head is the head of the list.
+ Elaborating:
+ 
+   node = ALLOCNODE(Type);
+   INSERTNODE(Type,head,node,succ);
+ 
+ allocates and inserts a list node pointed to by node.
+ Elaborating:
+ 
+   DELETENODE(Type,head,node,succ);
+   FREENODE(Type,node);
+ 
+ deletes and frees the list node pointed to by node.
+ 
+ Copyright Ken Keller 1981
+ */
+ 
+ #ifdef TEST99
+ #include "kenk.h"
+ #endif
+ 
+ #define ALLOCNODE(Type)\
+ (Type *)malloc(sizeof(Type))
+ 
+ #define INSERTNODE(Type,head,node,succ)\
+ {\
+   if((head) == NULL) {\
+     (head) = (node);\
+     (node)->succ = NULL; }\
+   else {\
+     (node)->succ = (head);\
+     (head) = (node); }\
+ }
+ 
+ #define DELETENODE(Type,head,node,succ)\
+ {\
+   register Type *lastType,*type;\
+ \
+   if((head) == NULL)\
+     ;\
+   lastType = NULL;\
+   type = (head);\
+   while(type->succ != NULL)\
+     if(type == (node))\
+       break;\
+     else {\
+       lastType = type;\
+       type = type->succ; }\
+   if(lastType == NULL)\
+     (head) = (node)->succ;\
+   else lastType->succ = (node)->succ;\
+ }
+ 
+ #define FREENODE(Type,node) free(node);
+ 
+ #ifdef TEST99
+ main()
+ {
+   typedef struct Dragon Dragon;
+   struct Dragon {
+     Dragon *succ;
+     int i; };
+   Dragon *head = NULL;
+   Dragon *node;
+   int cmd,i;
+ 
+   LOOP {
+     printf("1 Insert node.\n");
+     printf("2 Delete node.\n");
+     printf("3 Print list.\n");
+     scanf("%d",&cmd);
+     switch(cmd) {
+       case 1:
+ 	printf("Integer?");
+ 	scanf("%d",&i);
+ 	node = ALLOCNODE(Dragon);
+ 	INSERTNODE(Dragon,head,node,succ);
+ 	node->i = i;
+ 	break;
+       case 2:
+ 	if(head == NULL) {
+ 	  printf("Can't.  List is empty.\n");
+ 	  break; }
+ 	printf("Integer?");
+ 	scanf("%d",&i);
+ 	node = head;
+ 	while(node != NULL)
+ 	  if(node->i == i) {
+ 	    DELETENODE(Dragon,head,node,succ);
+ 	    FREENODE(Dragon,node);
+ 	    break; }
+           else node = node->succ;
+         if(node == NULL)
+ 	  printf("Can't.  Not in list.\n");
+ 	break;
+       case 3:
+ 	if(head == NULL) {
+ 	  printf("List is empty.\n");
+ 	  break; }
+ 	node = head;
+ 	while(node != NULL) {
+ 	  printf("%d ",node->i);
+ 	  node = node->succ; }
+         printf("\n");
+ 	break;
+       default:
+ 	printf("What?\n");
+ 	break; }/*switch*/ }/*LOOP*/
+ }
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/loadbins.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/loadbins.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/loadbins.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,309 ----
+ #include "custom.h"
+ extern int finalShot ;
+ 
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern int wireesty( int yc , int xx1 , int xx2 , double factor3 );
+ 
+ void loadbins(int new)
+ {
+ 
+ CELLBOXPTR ptr ;
+ TILEBOXPTR tileptr , tptr ;
+ int i , j , k ;
+ int startx , endx , starty , endy , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ int cell , left , right , bottom , top , rl , tb ;
+ int maxhalfdim ;
+ 
+ 
+ for( i = 0 ; i <= numBinsX ; i++ ) {
+     for( j = 0 ; j <= numBinsY ; j++ ) {
+ 	for( k = 0 ; k <= 4 + numcells ; k++ ) {
+ 	    blockarray[i][j][k] = 0 ;
+ 	}
+     }
+ }
+ 
+ 
+ left   = blockl ;
+ right  = blockr ;
+ bottom = blockb ;
+ top    = blockt ;
+ 
+ rl = (right - left) / 2 ;
+ tb = (top - bottom) / 2 ;
+ maxhalfdim = ( (right - left) >= (top - bottom) ) ?
+ 				    right - left : top - bottom ;
+ 
+ if( new ) {
+     i = 0 ; 
+ 
+     /* ************************************************************** */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] = ALLOC( CELLBOX ) ;
+ 
+     ptr->numtiles = 1  ;
+     ptr->numterms = 0  ;
+     ptr->xcenter  = left - maxhalfdim / 2 ;
+     ptr->ycenter  = (top + bottom) / 2    ; 
+ 
+     tptr = ptr->config[0] = ALLOC( TILEBOX )  ;
+     tptr->termptr = TERMNULL ;
+     tptr->nexttile = ALLOC( TILEBOX )   ;
+ 
+     tptr->nexttile->nexttile = TILENULL ;
+     tptr->nexttile->termptr = TERMNULL  ;
+ 
+     for( j = 1 ; j < 8 ; j++ ) {
+ 	ptr->config[ j ] = TILENULL ;
+     }
+ 
+     tptr->left            = -maxhalfdim / 2 ;
+     tptr->nexttile->left  = -maxhalfdim / 2 ;
+     tptr->right           =  maxhalfdim / 2 ;
+     tptr->nexttile->right =  maxhalfdim / 2 ;
+ 
+     tptr->bottom           = -tb    ;
+     tptr->nexttile->bottom = -tb    ;
+     tptr->top              = (top - bottom) - tb ;
+     tptr->nexttile->top    = (top - bottom) - tb ;
+ 	    
+     /* ************************************************************* */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] = ALLOC( CELLBOX ) ;
+ 
+     ptr->numtiles = 1  ;
+     ptr->numterms = 0  ;
+     ptr->xcenter  = right + maxhalfdim / 2 ;
+     ptr->ycenter  = (top + bottom) / 2     ; 
+ 
+     tptr = ptr->config[0] = ALLOC( TILEBOX )  ;
+     tptr->termptr = TERMNULL ;
+     tptr->nexttile = ALLOC( TILEBOX )   ;
+ 
+     tptr->nexttile->nexttile = TILENULL ;
+     tptr->nexttile->termptr  = TERMNULL ;
+ 
+     for( j = 1 ; j < 8 ; j++ ) {
+ 	ptr->config[ j ] = TILENULL ;
+     }
+ 
+     tptr->left            = -maxhalfdim / 2 ;
+     tptr->nexttile->left  = -maxhalfdim / 2 ;
+     tptr->right           =  maxhalfdim / 2 ;
+     tptr->nexttile->right =  maxhalfdim / 2 ;
+ 
+     tptr->bottom           = -tb ;
+     tptr->nexttile->bottom = -tb ;
+     tptr->top              = (top - bottom) - tb ;
+     tptr->nexttile->top    = (top - bottom) - tb ;
+ 	    
+ 
+     /* ************************************************************* */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] = ALLOC( CELLBOX ) ;
+ 
+     ptr->numtiles = 1  ;
+     ptr->numterms = 0  ;
+     ptr->xcenter  = (left + right) / 2      ; 
+     ptr->ycenter  = bottom - maxhalfdim / 2 ;
+ 
+     tptr = ptr->config[0] = ALLOC( TILEBOX ) ;
+     tptr->termptr  = TERMNULL ;
+     tptr->nexttile = ALLOC( TILEBOX ) ;
+ 
+     tptr->nexttile->nexttile = TILENULL ;
+     tptr->nexttile->termptr  = TERMNULL ;
+ 
+     for( j = 1 ; j < 8 ; j++ ) {
+ 	ptr->config[j] = TILENULL ;
+     }
+ 
+     tptr->bottom           = -maxhalfdim / 2 ;
+     tptr->nexttile->bottom = -maxhalfdim / 2 ;
+     tptr->top              =  maxhalfdim / 2 ;
+     tptr->nexttile->top    =  maxhalfdim / 2 ;
+ 
+     tptr->left            = -rl    ;
+     tptr->nexttile->left  = -rl    ;
+     tptr->right           = (right - left) - rl ;
+     tptr->nexttile->right = (right - left) - rl ;
+ 	    
+ 
+     /* ************************************************************** */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] = ALLOC( CELLBOX ) ;
+ 
+     ptr->numtiles = 1  ;
+     ptr->numterms = 0  ;
+     ptr->xcenter  = (left + right) / 2   ; 
+     ptr->ycenter  = top + maxhalfdim / 2 ;
+ 
+     tptr = ptr->config[0] = ALLOC( TILEBOX ) ;
+     tptr->termptr  = TERMNULL ;
+     tptr->nexttile = ALLOC( TILEBOX ) ;
+ 
+     tptr->nexttile->nexttile = TILENULL ;
+     tptr->nexttile->termptr  = TERMNULL ;
+ 
+     for( j = 1 ; j < 8 ; j++ ) {
+ 	ptr->config[j] = TILENULL ;
+     }
+ 
+     tptr->bottom           = -maxhalfdim / 2 ;
+     tptr->nexttile->bottom = -maxhalfdim / 2 ;
+     tptr->top              =  maxhalfdim / 2 ;
+     tptr->nexttile->top    =  maxhalfdim / 2 ;
+ 
+     tptr->left            = -rl ;
+     tptr->nexttile->left  = -rl ;
+     tptr->right           = (right - left) - rl ;
+     tptr->nexttile->right = (right - left) - rl ;
+ 
+ } else {
+ 
+     i = 0 ; 
+ 
+     /* ************************************************************** */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] ;
+ 
+     ptr->xcenter  = left - maxhalfdim / 2 ;
+     ptr->ycenter  = (top + bottom) / 2    ; 
+ 
+     tptr = ptr->config[0] ;
+ 
+     tptr->left            = -maxhalfdim / 2 ;
+     tptr->nexttile->left  = -maxhalfdim / 2 ;
+     tptr->right           =  maxhalfdim / 2 ;
+     tptr->nexttile->right =  maxhalfdim / 2 ;
+ 
+     tptr->bottom           = -tb    ;
+     tptr->nexttile->bottom = -tb    ;
+     tptr->top              = (top - bottom) - tb ;
+     tptr->nexttile->top    = (top - bottom) - tb ;
+ 	    
+     /* ************************************************************* */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] ;
+ 
+     ptr->xcenter  = right + maxhalfdim / 2 ;
+     ptr->ycenter  = (top + bottom) / 2     ; 
+ 
+     tptr = ptr->config[0] ;
+ 
+     tptr->left            = -maxhalfdim / 2 ;
+     tptr->nexttile->left  = -maxhalfdim / 2 ;
+     tptr->right           =  maxhalfdim / 2 ;
+     tptr->nexttile->right =  maxhalfdim / 2 ;
+ 
+     tptr->bottom           = -tb ;
+     tptr->nexttile->bottom = -tb ;
+     tptr->top              = (top - bottom) - tb ;
+     tptr->nexttile->top    = (top - bottom) - tb ;
+ 	    
+ 
+     /* ************************************************************* */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] ;
+ 
+     ptr->xcenter  = (left + right) / 2      ; 
+     ptr->ycenter  = bottom - maxhalfdim / 2 ;
+ 
+     tptr = ptr->config[0] ;
+ 
+     tptr->bottom           = -maxhalfdim / 2 ;
+     tptr->nexttile->bottom = -maxhalfdim / 2 ;
+     tptr->top              =  maxhalfdim / 2 ;
+     tptr->nexttile->top    =  maxhalfdim / 2 ;
+ 
+     tptr->left            = -rl    ;
+     tptr->nexttile->left  = -rl    ;
+     tptr->right           = (right - left) - rl ;
+     tptr->nexttile->right = (right - left) - rl ;
+ 	    
+ 
+     /* ************************************************************** */
+ 
+     ptr = cellarray[ numcells + numpads + ++i ] ;
+ 
+     ptr->xcenter  = (left + right) / 2   ; 
+     ptr->ycenter  = top + maxhalfdim / 2 ;
+ 
+     tptr = ptr->config[0] ;
+ 
+     tptr->bottom           = -maxhalfdim / 2 ;
+     tptr->nexttile->bottom = -maxhalfdim / 2 ;
+     tptr->top              =  maxhalfdim / 2 ;
+     tptr->nexttile->top    =  maxhalfdim / 2 ;
+ 
+     tptr->left            = -rl ;
+     tptr->nexttile->left  = -rl ;
+     tptr->right           = (right - left) - rl ;
+     tptr->nexttile->right = (right - left) - rl ;
+ 
+ }
+ 
+ for( cell = 1 ; cell <= numcells + numpads + 4 ; cell++ ) {
+     if( cell > numcells && cell <= numcells + numpads ) {
+ 	continue ;
+     }
+     ptr = cellarray[cell] ;
+     tileptr = ptr->config[ptr->orient] ;
+ 
+     startx = ptr->xcenter + tileptr->left ;
+     endx   = ptr->xcenter + tileptr->right;
+     starty = ptr->ycenter + tileptr->bottom ; 
+     endy   = ptr->ycenter + tileptr->top;
+     if( cell <= numcells ) {
+ 	if( finalShot == 0 ) {
+ 	    startx -= wireestx(startx, starty, endy, tileptr->lweight );
+ 	    endx   += wireestx(endx, starty, endy, tileptr->rweight );
+ 	    starty -= wireesty(starty, startx, endx, tileptr->bweight );
+ 	    endy   += wireesty(endy, startx, endx, tileptr->tweight );
+ 	} else {
+ 	    startx -= tileptr->lborder ;
+ 	    endx   += tileptr->rborder;
+ 	    starty -= tileptr->bborder ; 
+ 	    endy   += tileptr->tborder;
+ 	}
+     }
+ 
+     lowBinX = (startx - binOffsetX) / binWidthX ;
+     if( lowBinX < 1 ) {
+ 	lowBinX = 1 ;
+     } else if( lowBinX > numBinsX ) {
+ 	lowBinX = numBinsX ;
+     }
+     highBinX = (endx - binOffsetX) / binWidthX ;
+     if( highBinX > numBinsX ) {
+ 	highBinX = numBinsX ;
+     } else if( highBinX < 1 ) {
+ 	highBinX = 1 ;
+     }
+     if( lowBinX == highBinX ) {
+ 	lowBinY = (starty - binOffsetY) / binWidthY ;
+ 	if( lowBinY < 1 ) {
+ 	    lowBinY = 1 ;
+ 	} else if( lowBinY > numBinsY ) {
+ 	    lowBinY = numBinsY ;
+ 	}
+ 	highBinY = (endy - binOffsetY) / binWidthY ;
+ 	if( highBinY > numBinsY ) {
+ 	    highBinY = numBinsY ;
+ 	} else if( highBinY < 1 ) {
+ 	    highBinY = 1 ;
+ 	}
+ 	if( lowBinY == highBinY ) {
+ 	    occuptr = blockarray[lowBinX][lowBinY] ;
+ 	} else {
+ 	    occuptr = bucket ;
+ 	}
+     } else {
+ 	occuptr = bucket ;
+     }
+     occuptr[ ++occuptr[0]] = cell ;
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/loadpg.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/loadpg.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/loadpg.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,244 ----
+ #include "route.h"
+ 
+ int identify2( int *node1 , int *node2 , int distance , int *bound1 , 
+ 	      int *bound2 , GNODEPTR *gpptr );
+ 
+ void loadpg( int net , int totalnodes )
+ {
+ 
+ int i , node1 , node2 , pnode , PorE , distance , splitL , capacity ;
+ int savepnode , bound1 , bound2 , j , pnode1 , pnode2 ;
+ QUADPTR qptr ;
+ GNODEPTR gptr , g2ptr , gptr1 , gptr2 ;
+ LIST2PTR lptr ;
+ 
+ 
+ qptr = pinlist ;
+ for( i = 1 ; i <= totalnodes ; i++ ) {
+     node1 = qptr->node1 ;
+     node2 = qptr->node2 ;
+     distance = qptr->distance ;
+     PorE = qptr->PorE ;
+     j = identify2( &node1, &node2, distance, &bound1, &bound2, &gptr );
+     if( j == 0 ) {
+ 	fprintf(fpo,"pin number: %d of net: %d was supposed to ",
+ 						    i , net ) ;
+ 	fprintf(fpo,"lie between nodes: %d and %d\n", node1, node2);
+ 	fprintf(fpo,"However, the graph doesn't have an edge ");
+ 	fprintf(fpo,"between these two nodes\n");
+ 	exit(0);
+     } else if( j == 1 ) {
+ 	fprintf(fpo,"pin number: %d of net: %d ", i , net ) ;
+ 	fprintf(fpo,"specified to lie between nodes: %d and %d\n",
+ 						node1 , node2 ) ;
+ 	fprintf(fpo,"is not within the scope of this channel\n");
+ 	exit(0);
+     }
+     splitL = bound2 - bound1 ;
+     capacity = gptr->capacity ;
+     if( node1 <= numnodes && node2 <= numnodes ) {
+ 	gptr->length = VLARGE ;
+ 	gptr->cost = VLARGE ;
+ 	gptr = gnodeArray[node2] ;
+ 	while( gptr->node != node1 ) {
+ 	    gptr = gptr->next ;
+ 	}
+ 	gptr->length = VLARGE ;
+ 	gptr->cost = VLARGE ;
+     } else {
+ 	if( gnodeArray[node1] == gptr ) {
+ 	    gnodeArray[node1] = gptr->next ;
+ 	    free( gptr ) ;
+ 	} else {
+ 	    g2ptr = gnodeArray[node1] ;
+ 	    while( g2ptr->next != gptr ) {
+ 		g2ptr = g2ptr->next ;
+ 	    }
+ 	    g2ptr->next = gptr->next ;
+ 	    free( gptr ) ;
+ 	}
+ 	if( gnodeArray[node2]->node == node1 ) {
+ 	    gptr = gnodeArray[node2] ;
+ 	    gnodeArray[node2] = gnodeArray[node2]->next ;
+ 	    free( gptr ) ;
+ 	} else {
+ 	    g2ptr = gnodeArray[node2] ;
+ 	    while( g2ptr->next->node != node1 ) {
+ 		g2ptr = g2ptr->next ;
+ 	    }
+ 	    gptr = g2ptr->next ;
+ 	    g2ptr->next = gptr->next ;
+ 	    free( gptr ) ;
+ 	}
+     }
+     pnode = i + numnodes ;
+     if( PorE == 1 ) {
+ 	savepnode = i ;
+ 	pnodeArray[i].eptr = 0 ;
+     } else {
+ 	lptr = pnodeArray[savepnode].equiv ;
+ 	pnodeArray[i].eptr = savepnode ;
+ 	pnodeArray[savepnode].equiv = (LIST2PTR) malloc(sizeof(LIST2));
+ 	pnodeArray[savepnode].equiv->next = lptr ;
+ 	pnodeArray[savepnode].equiv->node = i ;
+     }
+     distance -= bound1 ;
+     gnodeArray[pnode] = (GNODEPTR) malloc( sizeof(GNODE) ) ;
+     gnodeArray[pnode]->node = node1 ;
+     gnodeArray[pnode]->length = distance ;
+     gnodeArray[pnode]->ilength = distance ;
+     gnodeArray[pnode]->cost = distance ;
+     gnodeArray[pnode]->capacity = capacity ;
+     gnodeArray[pnode]->inactive = 0 ;
+     gnodeArray[pnode]->einactive = 0 ;
+     gnodeArray[pnode]->next = (GNODEPTR) malloc( sizeof(GNODE) ) ;
+     gnodeArray[pnode]->next->node = node2 ;
+     gnodeArray[pnode]->next->length = splitL - distance ;
+     gnodeArray[pnode]->next->ilength = splitL - distance ;
+     gnodeArray[pnode]->next->cost = splitL - distance ;
+     gnodeArray[pnode]->next->capacity = capacity ;
+     gnodeArray[pnode]->next->inactive = 0 ;
+     gnodeArray[pnode]->next->einactive = 0 ;
+     gnodeArray[pnode]->next->next = (GNODEPTR) NULL ;
+ 
+     gptr = gnodeArray[node1] ;
+     gnodeArray[node1] = (GNODEPTR) malloc( sizeof(GNODE) ) ;
+     gnodeArray[node1]->next = gptr ;
+     gnodeArray[node1]->node = pnode ;
+     gnodeArray[node1]->ilength = distance ;
+     gnodeArray[node1]->length = distance ;
+     gnodeArray[node1]->cost = distance ;
+     gnodeArray[node1]->capacity = capacity ;
+     gnodeArray[node1]->inactive = 0 ;
+     gnodeArray[node1]->einactive = 0 ;
+ 
+     gptr = gnodeArray[node2] ;
+     gnodeArray[node2] = (GNODEPTR) malloc( sizeof(GNODE) ) ;
+     gnodeArray[node2]->next = gptr ;
+     gnodeArray[node2]->node = pnode ;
+     gnodeArray[node2]->ilength = splitL - distance ;
+     gnodeArray[node2]->length = splitL - distance ;
+     gnodeArray[node2]->cost = splitL - distance ;
+     gnodeArray[node2]->capacity = capacity ;
+     gnodeArray[node2]->inactive = 0 ;
+     gnodeArray[node2]->einactive = 0 ;
+ 
+     qptr = qptr->next ;
+ }
+ for( i = 1 ; i <= totalnodes ; i++ ) {
+     pnode1 = i + numnodes ;
+     gptr = gnodeArray[pnode1] ;
+     /* Mitch added check if gptr is null */
+     for( ; gptr != (GNODEPTR) NULL ; gptr = (gptr ? gptr->next : gptr)) {
+ 	pnode2 = gptr->node ;
+ 	j = pnode2 - numnodes ;
+ 	if( pnode2 <= numnodes || j < i ) {
+ 	    continue ;
+ 	}
+ 	if( (pnodeArray[i].eptr != 0) && (pnodeArray[j].eptr != 0) ) {
+ 	    if( pnodeArray[i].eptr != pnodeArray[j].eptr ) {
+ 		continue ;
+ 	    }
+ 	} else if( pnodeArray[i].eptr == 0 && pnodeArray[j].eptr == 0){
+ 	    continue ;
+ 	} else {
+ 	    if( pnodeArray[i].eptr != 0 ) {
+ 		if( pnodeArray[i].eptr != j ) {
+ 		    continue ;
+ 		}
+ 	    } else {
+ 		if( pnodeArray[j].eptr != i ) {
+ 		    continue ;
+ 		}
+ 	    }
+ 	}
+ 	gptr1 = gnodeArray[pnode1] ;
+ 	gptr2 = gnodeArray[pnode2] ;
+ 	gptr = gptr1 ;
+ 	/* Mitch added check if gptr is null */
+ 	for( ; gptr; ) {
+ 	    if( gptr->node == pnode2 ) {
+ 		gptr->cost = VLARGE ;
+ 		break ;
+ 	    }
+ 	    gptr = gptr->next ;
+ 	}
+ 	gptr = gptr2 ;
+ 	/* Mitch added check if gptr is null */
+ 	for( ; gptr; ) {
+ 	    if( gptr->node == pnode1 ) {
+ 		gptr->cost = VLARGE ;
+ 		break ;
+ 	    }
+ 	    gptr = gptr->next ;
+ 	}
+     }
+ }
+ 
+ return ;
+ }
+ 
+ 
+ 
+ int identify2( int *node1 , int *node2 , int distance , int *bound1 , 
+                 int *bound2 , GNODEPTR *gpptr )
+ {
+ 
+ GNODEPTR gptr1 , gptr ;
+ int c , count , i , prev , temp , limit ;
+ 
+ gptr1 = gnodeArray[ *node1 ] ;
+ 
+ for( i = 1 ; i <= 4 ; i++ ) {
+     gtrace[i][0] = 1 ;
+     gtrace[i][1] = *node1 ;
+ }
+ count = 0 ;
+ for( gptr = gptr1 ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+     if( gptr->length >= VLARGE ) {
+ 	continue ;
+     }
+     count++ ;
+     gtrace[count][ ++gtrace[count][0] ] = gptr->node ;
+ }
+ for( c = 1 ; c <= count ; c++ ) {
+     while( gtrace[c][ gtrace[c][0] ] > numnodes ) {
+ 	prev = gtrace[c][ gtrace[c][0] - 1 ] ;
+ 	gptr = gnodeArray[ gtrace[c][ gtrace[c][0] ] ] ;
+ 	if( gptr->node == prev ) {
+ 	    gptr = gptr->next ;
+ 	}
+ 	gtrace[c][ ++gtrace[c][0] ] = gptr->node ;
+     }
+ }
+ for( c = 1 ; c <= count ; c++ ) {
+     if( gtrace[c][ gtrace[c][0] ] == *node2 ) {
+ 	break ;
+     }
+ }
+ if( c > count ) {
+     return(0);
+ }
+ temp = 0 ;
+ limit = gtrace[c][0] ;
+ for( i = 1 ; i < limit ; i++ ) {
+     gptr = gnodeArray[ gtrace[c][i] ] ;
+     while( gptr->node != gtrace[c][i + 1] ) {
+ 	gptr =  gptr->next ;
+     }
+     prev = temp ;
+     temp += gptr->length ;
+     if( temp >= distance ) {
+ 	break ;
+     }
+ }
+ if( i >= limit ) {
+     return(1);
+ }
+ *node1 = gtrace[c][i] ;
+ *node2 = gtrace[c][i + 1] ;
+ *bound1 = prev ;
+ *bound2 = temp ;
+ *gpptr = gptr ;
+ return(2);
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/main.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/main.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/main.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,426 ----
+ #include "custom.h"
+ double spot_control ;
+ int spotPenalty ;
+ int spotXhash ;
+ int spotYhash ;
+ char **spots ;
+ int numXspots ;
+ int numYspots ;
+ int spotSize  ;
+ extern int finalShot ;
+ int choose ;
+ int bigcell  ;
+ int toobig   ;
+ extern int totNetLen ;
+ extern int wireEstimateOnly ;
+ double chipaspect ;
+ int iwire, iwirex , iwirey , icost ;
+ int fwire, fwirex , fwirey , fcost ;
+ double totFunc ;
+ double totPen  ;
+ int cost_only ;
+ int attpercell ;
+ int doPlacement ;
+ int doChannelGraph ;
+ int doGlobalRoute ;
+ int doCompaction ;
+ double Tsave ;
+ double aveCellSide ;
+ double analyze() ;
+ int rangeLimit ;
+ 
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern int wireesty( int yc , int xx1 , int xx2 , double factor3 );
+ extern void readpar(void);
+ extern void readcells( FILE *fp );
+ extern void scrapnet(void);
+ extern void config1(void);
+ extern void readnets( FILE *fp );
+ extern int findcost(void);
+ extern void initcheck(void);
+ extern int testloop( int trials );
+ extern void config2(void);
+ extern int test2loop( int trials );
+ extern void utemp(void);
+ extern void finalout(void);
+ extern void finalcheck(void);
+ extern void twstats(void);
+ extern void gmain(void);
+ extern void rmain(void);
+ 
+ void TW_oldinput( FILE *fp );
+ void prepSpots(void);
+ 
+ void main( int argc , char *argv[])
+ {
+ 
+ FILE *fp , *fopen() ;
+ char filename[1024] ;
+ int attempts , padflippers , cell , i , w , h ;
+ double temp1 , temp2 , fraction , ratio ;
+ double aveCside , variance , standardDev ;
+ 
+ offset     = 0  ;
+ lapFactor  = 1.0;
+ 
+ finalShot = 0 ;
+ maxWeight  = 2  ;
+ baseWeight = 1  ;
+ layersFactor = 1 ;
+ totNetLen  = 0  ;
+ randVar = -1 ;
+ 
+ if( argc != 2 ) {
+     printf("TimberWolf usage:  TimberWolf circuitName <CR> \n");
+     exit(0);
+ }
+ cktName = (char *)malloc( (strlen( argv[1] ) + 1 ) * sizeof( char ) ) ;
+ sprintf( cktName , "%s" , argv[1] ) ;
+ 
+ sprintf( filename, "%s.out" , cktName ) ;
+ if( (fpo = fopen( filename , "w")) == (FILE *) NULL ) {
+     printf("can't open %s\n", filename ) ;
+     exit (0);
+ }
+ 
+ fprintf(fpo,"TimberWolfMC dated: June 29 1986\n");
+ 
+ readpar() ;
+ 
+ if( doPlacement ) {
+     overlap  = woverlap  ;
+     overlapf = woverlapf ;
+     overlapx = woverlapx ;
+ 
+     if( randVar == -1 ) {
+ 	randVar = time(0) ;
+     }
+     fprintf(fpo,"\nThe rand generator seed was: %d\n\n\n", randVar ) ;
+     fflush(fpo);
+ 
+ 
+     sprintf(filename, "%s.cel" , cktName ) ;
+     if( (fp = fopen( filename , "r")) == (FILE *) NULL ) {
+ 	fprintf(fpo,"can't open %s\n", filename ) ;
+ 	exit (0);
+     } 
+     readcells( fp ) ;
+     scrapnet() ;
+     config1() ;
+     bdxlength = blockr - blockl ;
+     bdylength = blockt - blockb ;
+     fprintf(fpo,"bdxlength:%d    bdylength:%d\n",bdxlength,bdylength);
+     fflush(fpo);
+     fclose(fp);
+ 
+     sprintf(filename, "%s.net", cktName ) ;
+     if ( (fp = fopen ( filename , "r")) == (FILE *) NULL ) {
+ 	fprintf(fpo,"can't open %s\n", filename ) ;
+ 	exit(0);
+     } 
+     readnets( fp ) ;
+ 
+     sprintf(filename, "%s.sav", cktName ) ;
+     if( (fp = fopen( filename , "w") ) == NULL ) {
+ 	fprintf(fpo,"can't open %s\n", filename ) ;
+ 	exit(0) ;
+     } else {
+ 	fclose(fp) ;
+     }
+ 
+ 
+     funccost = findcost() ;
+     initcheck() ;
+ 
+     fprintf(fpo,"\n\n\nTHE ROUTE COST OF THE CURRENT PLACEMENT: %d\n", 
+ 						    funccost ) ;
+     fprintf(fpo,"\nTHE PENALTY OF THE CURRENT PLACEMENT: %d\n" , 
+ 							penalty ) ;
+     fprintf(fpo,"\nTHE OVERFILL OF THE CURRENT PIN PLACEMENT: %d\n",
+ 							 overfill );
+     fflush(fpo);
+ 
+ 
+     ratio = analyze() ;
+ 
+     if( wireEstimateOnly ) {
+ 	exit(0);
+     }
+     /*
+      *   This portion readjusts after taking into account expected
+      *   routing area
+      */
+     T = 1000000000.0 ;
+     bigcell = numcells * 11 ;
+     toobig  = bigcell + 1 ;
+     attempts = testloop( 100 * numcells ) ;
+     totNetLen = (int)( (totFunc / (double) attempts) / ratio ) ;
+     i = 0 ;
+     for( cell = 1 ; cell <= numcells ; cell++ ) {
+ 	if( cellarray[cell]->softflag == 1 ) {
+ 	    i++ ;
+ 	}
+     }
+     fraction = (double) i / (double) numcells ;
+     temp1 = (double) (totNetLen) / 
+ 		(1.0 + (fraction / (sqrt( (double) numcells )))) ;
+     totNetLen = (int) temp1 ;
+ 
+     config2() ;
+     bdxlength = blockr - blockl ;
+     bdylength = blockt - blockb ;
+ 
+     temp2 = ((double) bdxlength * (double) bdylength) / (double) numcells;
+     aveCellSide = sqrt( temp2 ) ;
+     /*
+     temp2 = (double) aveChanWid * 1.8 / aveCellSide ;
+     if( temp2 > 0.16 ) {
+ 	temp2 -= 0.14 ;
+ 	totNetLen = (int)( (double) totNetLen * ( 1.0 + 8.0 * temp2 ) );
+ 	config2() ;
+ 	bdxlength = blockr - blockl ;
+ 	bdylength = blockt - blockb ;
+ 	temp2 = ((double) bdxlength * 
+ 				(double) bdylength) / (double) numcells;
+ 	aveCellSide = sqrt( temp2 ) ;
+ 	temp2 = (double) aveChanWid * 1.8 / aveCellSide ;
+     }
+     */
+ 
+ 
+     fprintf(fpo,"bdxlength:%d    bdylength:%d\n",bdxlength,bdylength);
+     funccost = findcost() ;
+     fprintf(fpo,"\n\n\n");
+     fprintf(fpo,"parameter adjust: route:%d  penalty:%d  overfill:%d\n",
+ 			    funccost, penalty, overfill ) ;
+     fflush(fpo);
+ 
+     bigcell = numcells * 11 ;
+     toobig  = bigcell + 1 ;
+     attempts = test2loop( 100 * numcells ) ;
+     totFunc /= (double) attempts ;
+     totPen  /= (double) attempts ;
+     lapFactor = 0.40 * totFunc / totPen ;
+ 
+     temp1 = (double) numnets / (double) numcells ;
+     temp2 = ((double) bdxlength * (double) bdylength) / (double) numcells;
+     temp2 = sqrt( temp2 ) ;
+     T = 100000.0 * ( temp2 / 127.0 ) ;
+ 
+     fprintf(fpo,"nets.per.cell:%g  ave.cell.side:%g\n",temp1,temp2);
+ 
+     temp1 = 1.8 * (double) aveChanWid / aveCellSide ;
+     if( temp1 <= 0.08 ) {
+ 	temp1 = - log10(temp1) - 0.10 ;
+ 	temp1 = ( 0.001 * pow( 10.0 , temp1 ) ) - 0.02 ;
+ 	if( lapFactor < temp1 ) {
+ 	    lapFactor = temp1 ;
+ 	}
+ 	if( lapFactor < 0.02 ) {
+ 	    lapFactor = 0.02 ;
+ 	}
+     } else {
+ 	if( lapFactor < 0.02 ) {
+ 	    lapFactor = 0.02 ;
+ 	}
+     }
+ 
+     fprintf(fpo,"\n\nOVERLAP FACTOR (COMPUTED) : %f\n\n", lapFactor ) ;
+     offset    = (int)( 4.0 / lapFactor ) ;
+ 
+     aveCside = 0.0 ;
+     for( cell = 1 ; cell <= numcells ; cell++ ) {
+ 	w = cellarray[cell]->config[ cellarray[cell]->orient ]->right -
+ 	    cellarray[cell]->config[ cellarray[cell]->orient ]->left ;
+ 	h = cellarray[cell]->config[ cellarray[cell]->orient ]->top -
+ 	    cellarray[cell]->config[ cellarray[cell]->orient ]->bottom ;
+ 	w += maxWeight * maxWeight * aveChanWid ;
+         h += maxWeight * maxWeight * aveChanWid ;
+ 	aveCside += sqrt( (double)(w * h) ) ;
+     }
+     aveCside /= (double) numcells ;
+ 
+     variance = 0.0 ;
+     for( cell = 1 ; cell <= numcells ; cell++ ) {
+ 	w = cellarray[cell]->config[ cellarray[cell]->orient ]->right -
+ 	    cellarray[cell]->config[ cellarray[cell]->orient ]->left ;
+ 	h = cellarray[cell]->config[ cellarray[cell]->orient ]->top -
+ 	    cellarray[cell]->config[ cellarray[cell]->orient ]->bottom ;
+ 	w += maxWeight * maxWeight * aveChanWid ;
+         h += maxWeight * maxWeight * aveChanWid ;
+ 	variance += ( sqrt( (double)(w * h) ) - aveCside ) *
+ 		    ( sqrt( (double)(w * h) ) - aveCside ) ;
+     }
+     variance /= (double) numcells ;
+     standardDev = sqrt( variance ) ;
+     fprintf(fpo,"MEAN AND STANDARD DEVIATION OF SQRT OF CELL AREA:\n");
+     fprintf(fpo,"MEAN: %g   STANDARD DEVIATION: %g\n", aveCside, 
+ 							standardDev );
+     rangeLimit = (int)( aveCside + 2.0 * standardDev ) ;
+ 
+     if( T < 100000.0 ) {
+ 	T = 100000.0 ;
+     }
+     Tsave = T ;
+     funccost  = findcost() ;
+     if( T > ((double) funccost / 10.0) ) {
+ 	T = (double) funccost / 10.0 ;
+ 	Tsave = T ;
+ 	funccost  = findcost() ;
+     }
+     fprintf(fpo,"\n\n\nThe New Cost Values after readjustment:\n\n");
+     fprintf(fpo,"route:%d  penalty:%d  overfill:%d\n\n\n",
+ 			    funccost, penalty, overfill ) ;
+     fflush(fpo);
+ 
+     sprintf(filename, "%s.res", cktName ) ;
+     if( (fp = fopen( filename , "r") ) == NULL ) {
+ 	fprintf(fpo,"restart file: %s  wasn't present\n", filename ) ;
+     } else {
+ 	fprintf(fpo,"reading data from %s\n", filename ) ;
+ 	TW_oldinput( fp ) ;
+ 	funccost = findcost() ;
+ 	fprintf(fpo,"\n\n\nTHE ROUTE COST OF THE CURRENT PLACEMENT: %d\n"
+ 						  , funccost ) ;
+ 	fprintf(fpo,"\n\nTHE PENALTY OF THE CURRENT PLACEMENT: %d\n" ,
+ 						     penalty ) ;
+ 	fprintf(fpo,"\n\nTHE OVERFILL OF THE CURRENT PIN PLACEMENT: %d\n",
+ 						     overfill ) ;
+     }
+     fflush(fpo);
+ 
+ 
+     if( !cost_only ) {
+ 	fprintf(fpo,"\nTimberWolfMC Cell Placement Ready for Action\n\n");
+ 
+ 	padflippers = 0 ;
+ 	for( cell = numcells + 1; cell <= numcells + numpads; cell++ ){
+ 	    if( cellarray[cell]->class > 0 ) {
+ 		padflippers++ ;
+ 	    }
+ 	}
+ 
+ 	attmax  =  attpercell * (numcells + padflippers) ;
+ 	if( padflippers >= 2 ) {
+ 	    bigcell = (numcells + numpads) * 11 ;
+ 	    choose  = numcells + numpads ;
+ 	} else {
+ 	    bigcell = numcells * 11 ;
+ 	    choose  = numcells ;
+ 	}
+ 	toobig  = bigcell + 1 ;
+ 	prepSpots() ;
+ 	utemp() ;
+     }
+ 
+     finalout() ;
+ 
+     finalcheck() ;
+     twstats() ;
+ } else if( doChannelGraph ) {
+     gmain() ;
+     if( doGlobalRoute ) {
+ 	rmain() ;
+     }
+ } else if( doGlobalRoute ) {
+     rmain() ;
+ }
+ fprintf(fpo,"\n\n************************************ \n\n");
+ fprintf(fpo,"TimberWolfMC has completed its mission\n");
+ fprintf(fpo,"\n\n************************************ \n\n");
+ fclose(fpo);
+ exit(0);
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void prepSpots(void)
+ {
+ 
+ TILEBOXPTR tileptr ;
+ int w , h , s , min , max , x , y , cell ;
+ int l , r , b , t ;
+ int lspot , rspot , bspot , tspot ;
+ 
+ min = 10000000 ;
+ max = -10000000 ;
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     w = cellarray[cell]->config[ cellarray[cell]->orient ]->right -
+ 	cellarray[cell]->config[ cellarray[cell]->orient ]->left ;
+     h = cellarray[cell]->config[ cellarray[cell]->orient ]->top -
+ 	cellarray[cell]->config[ cellarray[cell]->orient ]->bottom ;
+     s = (w < h) ? w : h ;
+     min = (s < min) ? s : min ;
+     min = (min > 1) ? min : 1 ;
+     s = (w > h) ? w : h ;
+     max = (s >= max) ? s : max ;
+ }
+ spotXhash = blockl - max ;
+ spotYhash = blockb - max ;
+ spotSize = ( (min / 4) > ((blockr - blockl) / 2000) ) ?
+ 			    (min / 4) : ((blockr - blockl) / 2000) ;
+ numXspots = ( (blockr + max - spotXhash) / spotSize ) + 1 ;
+ numYspots = ( (blockt + max - spotYhash) / spotSize ) + 1 ;
+ fprintf(fpo,"numXspots:%d       numYspots:%d\n\n",numXspots,numYspots);
+ 
+ spots = (char **) malloc( numXspots * sizeof(char *) ) ;
+ for( x = 0 ; x < numXspots ; x++ ) {
+     spots[x] = (char *) malloc( numYspots * sizeof(char) ) ;
+     for( y = 0 ; y < numYspots ; y++ ) {
+ 	spots[x][y] = 0 ;
+     }
+ }
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     tileptr = cellarray[cell]->config[ cellarray[cell]->orient ] ;
+     l = cellarray[cell]->xcenter + tileptr->left ;
+     r = cellarray[cell]->xcenter + tileptr->right ;
+     b = cellarray[cell]->ycenter + tileptr->bottom ;
+     t = cellarray[cell]->ycenter + tileptr->top ;
+ 
+     l -= wireestx(l,b,t,tileptr->lweight ) ;
+     r += wireestx(r,b,t,tileptr->rweight ) ;
+     b -= wireesty(b,l,r,tileptr->bweight ) ;
+     t += wireesty(t,l,r,tileptr->tweight ) ;
+ 
+     lspot = (l - spotXhash) / spotSize ;
+     rspot = (r - spotXhash) / spotSize ;
+     bspot = (b - spotYhash) / spotSize ;
+     tspot = (t - spotYhash) / spotSize ;
+ 
+     for( x = lspot + 1 ; x < rspot ; x++ ) {
+ 	for( y = bspot + 1 ; y < tspot ; y++ ) {
+ 	    spots[x][y]++ ;
+ 	}
+     }
+ }
+ 
+ lspot = (blockl - spotXhash) / spotSize ;
+ rspot = (blockr - spotXhash) / spotSize ;
+ bspot = (blockb - spotYhash) / spotSize ;
+ tspot = (blockt - spotYhash) / spotSize ;
+ for( x = 0 ; x < numXspots ; x++ ) {
+     for( y = 0 ; y < numYspots ; y++ ) {
+ 	if( x >= lspot && x <= rspot && y >= bspot && y <= tspot ) {
+ 	    continue ;
+ 	}
+ 	spots[x][y]++ ;
+     }
+ }
+ 
+ spotPenalty = 0 ;
+ for( x = 0 ; x < numXspots ; x++ ) {
+     for( y = 0 ; y < numYspots ; y++ ) {
+ 	spotPenalty += (int)(spot_control * 
+ 		((double)(ABS(spots[x][y] - 1))) * ((double)(spotSize)));
+     }
+ }
+ fprintf(fpo,"Value of Spot Control: %f\n", spot_control ) ;
+ fprintf(fpo,"Value of Spot Size: %d\n", spotSize ) ;
+ fprintf(fpo,"Initial Value of Spot Penalty: %d\n\n", spotPenalty ) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makebins.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makebins.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makebins.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,113 ----
+ #include "custom.h"
+ 
+ void makebins( int numc )
+ {
+ 
+ double b , e , c ;
+ int a , b1 , xbins , ybins ;
+ int saveHx , saveHy , saveLx , saveLy , totalH , totalL ;
+ int saveL2x , saveL2y , totalL2 ;
+ int i , j , x , y , diff ;
+ 
+ c = (double) numc ;
+ for( b1 = 1 ; b1 <= 19 ; b1++ ) {
+     for( a = 0 ; a <= 99 ; a++ ) {
+ 	b = b1 + (double) a / 100.0 ;
+ 	e = pow((double)b, 4.0) - 
+ 			(2 * sqrt(c) + 2.0) * pow((double)b,3.0) +
+ 			(2 * sqrt(c) + 1.0) * pow((double)b,2.0) + c ;
+ 	if( e < 0 ) {
+ 	    b1 = 20 ;
+ 	    break ;
+ 	}
+     }
+ }
+ xbins = (int) b + 1 ;
+ ybins = (int) b + 1 ;
+ 
+ totalH = xbins + ybins ;
+ totalL = totalH - 1 ;
+ totalL2 = totalL - 1 ;
+ 
+ saveHx = 100 ;
+ diff = 32000 ;
+ for( x = 1 ; x <= xbins ; x++ ) {
+     y = totalH - x ;
+     if( x * y < b * b - 0.5 ) {
+ 	continue ;
+     }
+     if( x * y - b * b < diff ) {
+ 	diff = x * y - b * b ;
+ 	saveHx = x ;
+ 	saveHy = y ;
+     }
+ }
+ saveLx = 100 ;
+ diff = 32000 ;
+ for( x = 1 ; x <= xbins ; x++ ) {
+     y = totalL - x ;
+     if( x * y < b * b - 0.5 ) {
+ 	continue ;
+     }
+     if( x * y - b * b < diff ) {
+ 	diff = x * y - b * b ;
+ 	saveLx = x ;
+ 	saveLy = y ;
+     }
+ }
+ saveL2x = 100 ;
+ diff = 32000 ;
+ for( x = 1 ; x <= xbins ; x++ ) {
+     y = totalL2 - x ;
+     if( x * y < b * b - 0.5 ) {
+ 	continue ;
+     }
+     if( x * y - b * b < diff ) {
+ 	diff = x * y - b * b ;
+ 	saveL2x = x ;
+ 	saveL2y = y ;
+     }
+ }
+ if( saveLx < 100 && saveHx < 100 ) {
+     if( saveLx * saveLy <= saveHx * saveHy ) {
+ 	xbins = saveLx ;
+ 	ybins = saveLy ;
+     } else {
+ 	xbins = saveHx ;
+ 	ybins = saveHy ;
+     }
+ } else if( saveHx < 100 ) {
+     xbins = saveHx ;
+     ybins = saveHy ;
+ } else if( saveLx < 100 ) {
+     xbins = saveLx ;
+     ybins = saveLy ;
+ }
+ if( saveLx < 100 || saveHx < 100 ) {
+     if( saveL2x < 100 ) {
+ 	if( xbins * ybins >= saveL2x * saveL2y ) {
+ 	    xbins = saveL2x ;
+ 	    ybins = saveL2y ;
+ 	}
+     }
+ } else {
+     xbins = saveL2x ;
+     ybins = saveL2y ;
+ }
+ numBinsX = xbins ;
+ numBinsY = ybins ;
+ 
+ fprintf( fpo , "numBinsX automatically set to:%d\n", numBinsX );
+ fprintf( fpo , "numBinsY automatically set to:%d\n", numBinsY );
+ 
+ blockarray = (int ***) malloc( (1 + numBinsX) * sizeof(int **) ) ; 
+ for( i = 0 ; i <= numBinsX ; i++ ) {
+     blockarray[i] = (int **) malloc((1 + numBinsY) * sizeof(int *));
+     for( j = 0 ; j <= numBinsY ; j++ ) {
+ 	blockarray[i][j] = (int *) malloc((5 + numcells) * 
+ 						       sizeof(int));
+     }
+ }
+ bucket = blockarray[0][0] ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makelink.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makelink.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makelink.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,130 ----
+ #include "geo.h"
+ 
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value , 
+                   int *property);
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void makeVtree(void);
+ void makeHtree(void);
+ 
+ void makelink(void)
+ {
+ 
+ TNODEPTR junkptr ;
+ DLINK1PTR ptr , pptr , nptr ;
+ int location , index ;
+ 
+ hFixedList = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ hFixedList->edge = edgeCount ;
+ hFixedList->next = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ hFixedList->prev = (DLINK1PTR) NULL ;
+ hFixedList->next->next = (DLINK1PTR) NULL ;
+ hFixedList->next->prev = hFixedList ;
+ hFixedList->next->edge = edgeCount - 2 ;
+ hFixedEnd = hFixedList->next ;
+ 
+ vFixedList = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ vFixedList->edge = edgeCount - 3 ;
+ vFixedList->next = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+ vFixedList->prev = (DLINK1PTR) NULL ;
+ vFixedList->next->next = (DLINK1PTR) NULL ;
+ vFixedList->next->prev = vFixedList ;
+ vFixedList->next->edge = edgeCount - 1 ;
+ vFixedEnd = vFixedList->next ;
+ 
+ pptr = hFixedList ;
+ nptr = hFixedList->next ;
+ for( ; ; ) {
+     tpop( &hFixedEdgeRoot , &junkptr , &location , &index ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+     ptr->edge = index ;
+     ptr->prev = pptr ;
+     ptr->next = nptr ;
+     pptr->next = ptr ;
+     nptr->prev = ptr ;
+     pptr = ptr ;
+ }
+ 
+ pptr = vFixedList ;
+ nptr = vFixedList->next ;
+ for( ; ; ) {
+     tpop( &vFixedEdgeRoot , &junkptr , &location , &index ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = (DLINK1PTR) malloc( sizeof( DLINK1 ) ) ;
+     ptr->edge = index ;
+     ptr->prev = pptr ;
+     ptr->next = nptr ;
+     pptr->next = ptr ;
+     nptr->prev = ptr ;
+     pptr = ptr ;
+ }
+ makeVtree() ;
+ makeHtree() ;
+ 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ void makeVtree(void)
+ {
+ 
+ DLINK1PTR vptr ;
+ int last , edge , count ;
+ 
+ Vroot = (TNODEPTR) NULL ;
+ Vptrs = (DLINK1PTR *) malloc( 100 * sizeof(DLINK1PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( vptr = vFixedList ; vptr != (DLINK1PTR) NULL ; vptr = vptr->next ) {
+     edge = vptr->edge ;
+     if( edgeList[edge].loc > last ) {
+ 	last = edgeList[edge].loc ;
+ 	if( ++count % 100 == 0 ) {
+ 	    Vptrs = (DLINK1PTR *) realloc( Vptrs ,
+ 				(count + 100) * sizeof(DLINK1PTR) ) ;
+ 	}
+ 	Vptrs[count] = vptr ;
+ 	tinsert( &Vroot , last , count ) ;
+     }
+ }
+ 
+ return ;
+ }
+ 
+ 
+ 
+ 
+ void makeHtree(void)
+ {
+ 
+ DLINK1PTR hptr ;
+ int last , edge , count ;
+ 
+ Hroot = (TNODEPTR) NULL ;
+ Hptrs = (DLINK1PTR *) malloc( 100 * sizeof(DLINK1PTR) ) ;
+ count = 0 ;
+ 
+ last = -1000000 ;
+ for( hptr = hFixedList ; hptr != (DLINK1PTR) NULL ; hptr = hptr->next ) {
+     edge = hptr->edge ;
+     if( edgeList[edge].loc > last ) {
+ 	last = edgeList[edge].loc ;
+ 	if( ++count % 100 == 0 ) {
+ 	    Hptrs = (DLINK1PTR *) realloc( Hptrs ,
+ 				(count + 100) * sizeof(DLINK1PTR) ) ;
+ 	}
+ 	Hptrs[count] = hptr ;
+ 	tinsert( &Hroot , last , count ) ;
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makesite.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makesite.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/makesite.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,223 ----
+ #include "custom.h"
+ typedef struct kbox {
+     int cap ;
+     int HV ;
+     int sp ;
+     int x ;
+     int y ;
+ }
+ KBOX ,
+ *KBOXPTR ;
+ 
+ extern KBOXPTR kArray ;
+ double val1 , val2 ;
+ 
+ int Vside( int cell , int x , int yy1 , int yy2 , int flag )
+ {
+ 
+ double aspFactor , aspect , aspLB ;
+ int worstLen , pPinLocs , k , length , base ;
+ int TotSites ;
+ double siteSpace ;
+ 
+ length = ABS(yy2 - yy1) ;
+ aspect = cellarray[ cell ]->aspect ;
+ aspLB  = cellarray[ cell ]->aspLB ;
+ if( aspLB + 0.01 > cellarray[ cell]->aspUB ) {
+     aspFactor = 1.0 ;
+ } else {
+     aspFactor = sqrt( aspLB / aspect ) ;
+ }
+ worstLen = (int) (aspFactor * (double) length) ;
+ if( (double)(worstLen + 1) / aspFactor - (double) length <
+ 		(double) length - (double) worstLen / aspFactor ) {
+     worstLen++ ;
+ }
+ 
+ pPinLocs = worstLen / pinSpacing - 1 ;
+ if( flag ) {
+     if( pPinLocs > MaxSites ) {
+ 	for( k = 1 ; k <= MaxSites ; k++ ) {
+ 	    kArray[ k ].cap = 0 ;
+ 	    kArray[ k ].HV = 0 ;
+ 	    kArray[ k ].sp = 0 ;
+ 	    kArray[ k ].x = 0 ;
+ 	    kArray[ k ].y = 0 ;
+ 	}
+ 	base = pPinLocs / MaxSites ;
+ 	for( k = 1 ; k <= MaxSites ; k++ ) {
+ 	    kArray[ k ].cap += base ;
+ 	}
+ 	for( k = 1 ; k <= pPinLocs % MaxSites ; k++ ) {
+ 	    kArray[ k ].cap++ ;
+ 	}
+     } else {  /* prepare pPinLocs sites */
+ 	for( k = 1 ; k <= pPinLocs ; k++ ) {
+ 	    kArray[ k ].cap = 0 ;
+ 	    kArray[ k ].HV = 0 ;
+ 	    kArray[ k ].sp = 0 ;
+ 	    kArray[ k ].x = 0 ;
+ 	    kArray[ k ].y = 0 ;
+ 	}
+ 	for( k = 1 ; k <= pPinLocs ; k++ ) {
+ 	    kArray[ k ].cap = 1 ;
+ 	}
+     }
+ }
+ 
+ /*
+     TotSites = minimum of ( MaxSites and pPinLocs ) 
+ */
+ if( pPinLocs <= MaxSites ) {
+     TotSites = pPinLocs ;
+ } else {
+     TotSites = MaxSites ;
+ }
+ siteSpace = (double) length / (double) (TotSites + 1) ;
+ 
+ /* 
+     Suppose we encountered coordinates yy1 and yy2 for a given
+     vertical side, and of course that the x-coordinate is simply x.
+     ( yy1 < yy2 is required )
+ */
+ 
+ if( flag ) {
+     if( yy2 > yy1 ) {
+ 	for( k = 1 ; k <= TotSites ; k++ ) {
+ 	    kArray[ k ].x = x ;
+ 	    val1 = (k + 1) * siteSpace ;
+ 	    val2 = k * siteSpace ;
+ 	    kArray[ k ].y = ROUND( val2 ) + yy1 ;
+ 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
+ 	    kArray[ k ].HV = 1 ;
+ 	}
+     } else {
+ 	for( k = 1 ; k <= TotSites ; k++ ) {
+ 	    kArray[ k ].x = x ;
+ 	    val1 = (k + 1) * siteSpace ;
+ 	    val2 = k * siteSpace ;
+ 	    kArray[ k ].y = yy1 - ROUND( val2 ) ;
+ 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
+ 	    kArray[ k ].HV = 1 ;
+ 	}
+     }
+ }
+ 
+ /*
+  *
+  *   --- BIG NOTE ---
+  *
+  *   Any fixed terminals intersecting a site cause the contents
+  *   of that site to be incremented by one. This will inhibit
+  *   sequences from passing on thru. ( try to remember to
+  *   get the check pointer to reflect this fact )
+  */
+ 
+ return( TotSites ) ;
+ }
+ 
+ 
+ 
+ 
+ int Hside( int cell , int xx1 , int xx2 , int y , int flag )
+ {
+ 
+ double aspFactor , aspect , aspUB ;
+ int worstLen , pPinLocs , k , length , base ;
+ int TotSites ;
+ double siteSpace ;
+ 
+ length = ABS(xx2 - xx1) ;
+ aspect = cellarray[ cell ]->aspect ;
+ aspUB  = cellarray[ cell ]->aspUB ;
+ if( cellarray[ cell ]->aspLB + 0.01 > aspUB ) {
+     aspFactor = 1.0 ;
+ } else {
+     aspFactor = sqrt( aspect / aspUB ) ;
+ }
+ worstLen = (int) (aspFactor * (double) length) ;
+ if( (double)(worstLen + 1) / aspFactor - (double) length <
+ 		(double) length - (double) worstLen / aspFactor ) {
+     worstLen++ ;
+ }
+ 
+ pPinLocs = worstLen / pinSpacing - 1 ;
+ if( flag ) {
+     if( pPinLocs > MaxSites ) {
+ 	for( k = 1 ; k <= MaxSites ; k++ ) {
+ 	    kArray[ k ].cap = 0 ;
+ 	    kArray[ k ].HV = 0 ;
+ 	    kArray[ k ].sp = 0 ;
+ 	    kArray[ k ].x = 0 ;
+ 	    kArray[ k ].y = 0 ;
+ 	}
+ 	base = pPinLocs / MaxSites ;
+ 	for( k = 1 ; k <= MaxSites ; k++ ) {
+ 	    kArray[ k ].cap += base ;
+ 	}
+ 	for( k = 1 ; k <= pPinLocs % MaxSites ; k++ ) {
+ 	    kArray[ k ].cap++ ;
+ 	}
+     } else {  /* prepare pPinLocs sites */
+ 	for( k = 1 ; k <= pPinLocs ; k++ ) {
+ 	    kArray[ k ].cap = 0 ;
+ 	    kArray[ k ].HV = 0 ;
+ 	    kArray[ k ].sp = 0 ;
+ 	    kArray[ k ].x = 0 ;
+ 	    kArray[ k ].y = 0 ;
+ 	}
+ 	for( k = 1 ; k <= pPinLocs ; k++ ) {
+ 	    kArray[ k ].cap = 1 ;
+ 	}
+     }
+ }
+ 
+ /*
+     TotSites = minimum of ( MaxSites and pPinLocs ) 
+ */
+ if( pPinLocs <= MaxSites ) {
+     TotSites = pPinLocs ;
+ } else {
+     TotSites = MaxSites ;
+ }
+ siteSpace = (double) length / (double) (TotSites + 1) ;
+ 
+ /* 
+    Suppose we encountered coordinates xx1 and xx2 for a given
+    horizontal side, and of course that the y-coordinate is simply y.
+ */
+ 
+ if( flag ) {
+     if( xx2 > xx1 ) {
+ 	for( k = 1 ; k <= TotSites ; k++ ) {
+ 	    kArray[ k ].y = y ;
+ 	    val1 = (k + 1) * siteSpace ;
+ 	    val2 = k * siteSpace ;
+ 	    kArray[ k ].x = ROUND( val2 ) + xx1 ;
+ 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
+ 	    kArray[ k ].HV = 0 ;
+ 	}
+     } else {
+ 	for( k = 1 ; k <= TotSites ; k++ ) {
+ 	    kArray[ k ].y = y ;
+ 	    val1 = (k + 1) * siteSpace ;
+ 	    val2 = k * siteSpace ;
+ 	    kArray[ k ].x = xx1 - ROUND( val2 ) ;
+ 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
+ 	    kArray[ k ].HV = 0 ;
+ 	}
+     }
+ }
+ 
+ /*
+  *
+  *   --- BIG NOTE ---
+  *
+  *   Any fixed terminals intersecting a site cause the contents
+  *   of that site to be incremented by one. This will inhibit
+  *   sequences from passing on thru. ( try to remember to
+  *   get the check pointer to reflect this fact )
+  */
+ 
+ return( TotSites ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/move.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/move.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/move.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,124 ----
+ #include "port.h"
+ #include "mt.h"
+ 
+ extern void MTPoint(MT *t,int *x,int *y);
+ extern void MTIdentity(MT *t);
+ extern void MTMY(MT *t);
+ extern void MTMX(MT *t);
+ extern void MTRotate(MT *t,int x,int y);
+ 
+ static MT *mt = (MT *) NULL ;
+ 
+ 
+ 
+ void point( int *x , int *y )
+ {
+     int xx , yy ;
+ 
+     if( mt == (MT *) NULL ) {
+ 
+         return;
+     }
+ 
+     xx = *x ;
+     yy = *y ;
+ 
+     MTPoint( mt , &xx , &yy ) ;
+ 
+     *x = xx ;
+     *y = yy ;
+ 
+     return ;
+ }
+ 
+ 
+ 
+ void rect( int *l , int *b , int *r , int *t )
+ {
+ 
+     int temp ;
+ 
+     point( l , b ) ;
+     point( r , t ) ;
+ 
+     if( *l > *r ) {
+ 
+         temp = *l   ;
+         *l   = *r   ;
+         *r   = temp ; 
+     }
+ 
+     if( *b > *t ) {
+ 
+         temp = *b   ;
+         *b   = *t   ;
+         *t   = temp ; 
+     }
+ 
+     return ;
+ }
+ 
+ 
+ 
+ void move( int moveType )
+ {
+ 
+     if( mt == (MT *) NULL ) {
+ 
+     	mt = MTBegin() ;
+     }
+ 
+     MTIdentity( mt ) ;
+ 
+     switch( moveType ) {
+ 
+         case 0 :
+ 
+             return ;
+ 
+ 
+         case 1 :
+ 
+             MTMY( mt ) ; 
+     	    return     ;
+ 
+ 
+         case 2 :
+ 
+             MTMX( mt ) ; 
+ 	    return     ;
+ 
+ 
+         case 3 :
+ 
+             MTRotate( mt , -1 , 0 ) ; 
+ 	    return ; 
+ 
+ 
+         case 4 :
+ 
+             MTMX( mt ) ; 
+ 	    MTRotate( mt , 0 , 1 ) ; 
+ 	    return ;
+ 
+ 
+         case 5 :
+ 
+             MTMX( mt ) ; 
+ 	    MTRotate( mt , 0 , -1 ) ; 
+ 	    return ;
+ 
+ 
+         case 6 :
+ 
+             MTRotate( mt , 0 , 1 ) ; 
+ 	    return ;
+ 
+ 
+         case 7 :
+ 
+             MTRotate( mt , 0 , -1 ) ; 
+ 	    return ;
+ 
+     }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mshortest.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mshortest.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mshortest.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,525 ----
+ /* #define DEBUG */
+ #include "route.h"
+ #include "23tree.h"
+ extern int bareMinimum ;
+ extern int doCompaction ;
+ extern int finalShot ;
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ extern int prestrict( short int *ptr, int p , int source , int target );
+ extern void tmax( TNODEPTR *root , TNODEPTR *node , int *value ,
+                   int *property);
+ 
+ void greduce(short int *ptr,int p,int ex0,int ex1,int ex2,int ex3,int ex4 );
+ void gunreduce(short int *ptr,int p,int ex0,int ex1,int ex2,int ex3,int ex4 );
+ 
+ /*ARGSUSED*/
+ int mshortest( int source , int soleTarget )
+ {
+ 
+ int target , i , j , k , d , t , distance , from , index , pindex , c ;
+ int numberPaths , p , q , *eptr , exnum , tree2size ;
+ int ex[5] , number , junk , treeSize , value , count , targetLimit ;
+ int wasInactive , node1 , xindex , targetCount , foo ;
+ int initialCount , initialLimit ;
+ short int dummy[2] ;
+ short int *ptr ;
+ NNODEPTR nptr ;
+ TNODEPTR root1 , node , rsave , junkptr , indexRoot , targetRoot ;
+ TNODEPTR initialRoot ;
+ GNODEPTR gptr , gptr1 ;
+ 
+ rsave = (TNODEPTR) NULL ;
+ indexRoot = (TNODEPTR) NULL ;
+ targetRoot = (TNODEPTR) NULL ;
+ initialRoot = (TNODEPTR) NULL ;
+ 
+ for( i = 1 ; i <= 2 + 2 * Mpaths ; i++ ) {
+     tinsert( &indexRoot , i , 0 ) ;
+ }
+ treeSize = 0 ;
+ tree2size = 0 ;
+ wasInactive = 0 ;
+ nptr = pnodeArray[ source - numnodes ].nodeList ;
+ 
+ for( t = 1 ; t <= targetPtr ; t++ ) {
+     target = targetList[t] ;
+     tinsert( &initialRoot , nptr[target].distance , t ) ;
+ }
+ 
+ initialCount = 0 ;
+ initialLimit = ((int)(0.1 * (double) targetPtr) + 1) + 2 * Mpaths ;
+ 
+ if( initialLimit > targetPtr ) {
+     initialLimit = targetPtr ;
+ }
+ if( bareMinimum ) {
+     if( finalShot == doCompaction ) {
+ 	initialLimit = 2 ;
+     } else {
+ 	initialLimit = 1 ;
+     }
+ }
+ 
+ while( initialCount < initialLimit ) {
+     tpop( &initialRoot , &junkptr , &foo , &t ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     target = targetList[t] ;
+     gptr = gnodeArray[target] ;
+     node1 = gptr->node ;
+     gptr1 = gnodeArray[node1] ;
+     for( ; ; ) {
+ 	if( gptr1->node == target ) {
+ 	    if( gptr1->einactive == 1 ) {
+ 		gptr1->einactive = 0 ;
+ 		wasInactive = 1 ;
+ 		gptr = gptr->next ;
+ 		for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 		    node1 = gptr->node ;
+ 		    gptr1 = gnodeArray[node1] ;
+ 		    for( ; ; ) {
+ 			if( gptr1->node == target ) {
+ 			    gptr1->einactive = 0 ;
+ 			    break ;
+ 			}
+ 			gptr1 = gptr1->next ;
+ 		    }
+ 		}
+ 	    }
+ 	    break ;
+ 	}
+ 	gptr1 = gptr1->next ;
+     }
+     dummy[1] = source ;
+     d = prestrict( dummy , 1 , source , target ) ;
+     if( wasInactive == 1 ) {
+ 	gptr = gnodeArray[target] ;
+ 	for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	    node1 = gptr->node ;
+ 	    gptr1 = gnodeArray[node1] ;
+ 	    for( ; ; ) {
+ 		if( gptr1->node == target ) {
+ 		    gptr1->einactive = 1 ;
+ 		    break ;
+ 		}
+ 		gptr1 = gptr1->next ;
+ 	    }
+ 	}
+ 	wasInactive = 0 ;
+     }
+     if( d >= 0 ) { 
+ 	tinsert( &targetRoot , nptr[target].temp , t ) ;
+ 	initialCount++ ;
+     }
+ }
+ if( initialRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &initialRoot , &junkptr , &foo , &t ) ;
+ 	if( junkptr == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ targetLimit = Mpaths ;
+ targetCount = 0 ;
+ 
+ while( targetCount < targetLimit ) {
+ 
+     tpop( &targetRoot , &junkptr , &foo , &t ) ;
+     if( junkptr == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     
+     numberPaths = 0 ;
+     root1 = (TNODEPTR) NULL ;
+ 
+ 
+     target = targetList[t] ;
+     gptr = gnodeArray[target] ;
+     node1 = gptr->node ;
+     gptr1 = gnodeArray[node1] ;
+     for( ; ; ) {
+ 	if( gptr1->node == target ) {
+ 	    if( gptr1->einactive == 1 ) {
+ 		gptr1->einactive = 0 ;
+ 		wasInactive = 1 ;
+ 		gptr = gptr->next ;
+ 		for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 		    node1 = gptr->node ;
+ 		    gptr1 = gnodeArray[node1] ;
+ 		    for( ; ; ) {
+ 			if( gptr1->node == target ) {
+ 			    gptr1->einactive = 0 ;
+ 			    break ;
+ 			}
+ 			gptr1 = gptr1->next ;
+ 		    }
+ 		}
+ 	    }
+ 	    break ;
+ 	}
+ 	gptr1 = gptr1->next ;
+     }
+     dummy[1] = source ;
+     d = prestrict( dummy , 1 , source , target ) ;
+     if( d < 0 ) {
+ 	if( wasInactive == 1 ) {
+ 	    gptr = gnodeArray[target] ;
+ 	    for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 		node1 = gptr->node ;
+ 		gptr1 = gnodeArray[node1] ;
+ 		for( ; ; ) {
+ 		    if( gptr1->node == target ) {
+ 			gptr1->einactive = 1 ;
+ 			break ;
+ 		    }
+ 		    gptr1 = gptr1->next ;
+ 		}
+ 	    }
+ 	    wasInactive = 0 ;
+ 	}
+ 	continue ;
+     }
+     distance = nptr[target].temp ;
+ 
+     targetCount++ ;
+     from = nptr[target].from2 ;
+     number = 1 ;
+     tempArray[1] = target ;
+     while( from != 0 ) {
+ 	tempArray[++number] = from ;
+ 	from = nptr[from].from2 ;
+     }
+     tpop( &indexRoot , &junkptr , &pindex , &junk ) ;
+ 
+ #ifdef DEBUG
+     printf("pindex:%d\n",pindex);
+     fflush(stdout);
+ #endif
+ 
+     pathArray[pindex].p = 1 ;
+     pathArray[pindex].q = number - 1 ;
+     pathArray[pindex].excluded = 0 ;
+     for( j = 1 ; j <= number ; j++ ) {
+ 	pathArray[pindex].nodeset[ number - j + 1 ] = tempArray[j] ;
+     }
+     tinsert( &root1 , distance , pindex ) ;
+     treeSize++ ;
+ 
+     for( ; ; ) {
+ 	tpop( &root1 , &node , &distance , &index ) ;
+ 	treeSize-- ;
+ 	if( node == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+ 	tinsert( &rsave , distance , index ) ;
+ 	tree2size++ ;
+ 	if( ++numberPaths >= Mpaths ) {
+ 	    break ;
+ 	}
+ 	ptr = pathArray[index].nodeset ;
+ 	p = pathArray[index].p ;
+ 	q = pathArray[index].q ;
+ 	exnum = pathArray[index].excluded ;
+ 	eptr = pathArray[index].exlist ;
+ 	if( p == q ) {
+ 	    ex[0] = exnum + 1 ;
+ 	    for( i = 1 ; i <= exnum ; i++ ) {
+ 		 ex[i] = eptr[i] ;
+ 	    }
+ 	    ex[ ex[0] ] = ptr[ p + 1 ] ;
+ 
+ 	    greduce( ptr, p, ex[0], ex[1], ex[2], ex[3], ex[4] ) ;
+ 	    d = prestrict( ptr, p , source , target ) ;
+ 	    gunreduce( ptr, p, ex[0], ex[1], ex[2], ex[3], ex[4] ) ;
+ 	    if( d < 0 ) {
+ 		continue ;
+ 	    }
+ 	    distance = nptr[target].temp + d ;
+ 	    from = nptr[target].from2 ;
+ 	    number = 1 ;
+ 	    tempArray[1] = target ;
+ 	    while( from != 0 ) {
+ 		tempArray[++number] = from ;
+ 		from = nptr[from].from2 ;
+ 	    }
+ 	    for( i = p - 1 ; i >= 1 ; i-- ) {
+ 		tempArray[++number] = ptr[i] ;
+ 	    }
+ 	    tpop( &indexRoot , &junkptr , &pindex , &junk ) ;
+ 
+ #ifdef DEBUG
+ 	    printf("pindex:%d\n",pindex);
+ 	    fflush(stdout);
+ #endif
+ 
+ 	    pathArray[pindex].p = p ;
+ 	    pathArray[pindex].q = number - 1 ;
+ 	    pathArray[pindex].excluded = ex[0] ;
+ 	    for( i = 1 ; i <= ex[0] ; i++ ) {
+ 		pathArray[pindex].exlist[i] = ex[i] ;
+ 	    }
+ 	    for( j = 1 ; j <= number ; j++ ) {
+ 		pathArray[pindex].nodeset[number - j + 1] = tempArray[j];
+ 	    }
+ 	    tinsert( &root1 , distance , pindex ) ;
+ 	    treeSize++ ;
+ 
+ 	    
+ 	    count = treeSize - (Mpaths - numberPaths) ;
+ 	    if( count > 0 ) {
+ 		for( c = 1 ; c <= count ; c++ ) {
+ 		    tmax( &root1, &node, &value, &xindex ) ;
+ 		    tdelete( &root1, value, xindex ) ;
+ 		    tinsert( &indexRoot, xindex, 0 ) ;
+ 		}
+ 		treeSize -= count ;
+ 	    }
+ 	   
+ 	} else {
+ 	    for( k = 1 ; k <= q - p + 1 ; k++ ) {
+ 		if( k == 1 ) {
+ 		    ex[0] = exnum + 1 ;
+ 		    for( i = 1 ; i <= exnum ; i++ ) {
+ 			 ex[i] = eptr[i] ;
+ 		    }
+ 		    ex[ ex[0] ] = ptr[ p + 1 ] ;
+ 		} else {
+ 		    ex[ ex[0] = 1 ] = ptr[ p + k ] ;
+ 		}
+ 		greduce( ptr, p + k - 1, 
+ 				ex[0], ex[1], ex[2], ex[3], ex[4] ) ;
+ 		d = prestrict( ptr, p + k - 1 , source , target ) ;
+ 		gunreduce( ptr, p + k - 1, 
+ 				ex[0], ex[1], ex[2], ex[3], ex[4] ) ;
+ 		if( d < 0 ) {
+ 		    continue ;
+ 		}
+ 		distance = nptr[target].temp + d ;
+ 		from = nptr[target].from2 ;
+ 		number = 1 ;
+ 		tempArray[1] = target ;
+ 		while( from != 0 ) {
+ 		    tempArray[++number] = from ;
+ 		    from = nptr[from].from2 ;
+ 		}
+ 		for( i = p + k - 2 ; i >= 1 ; i-- ) {
+ 		    tempArray[++number] = ptr[i] ;
+ 		}
+ 		tpop( &indexRoot , &junkptr , &pindex , &junk ) ;
+ 		treeSize++ ;
+ 
+ #ifdef DEBUG
+ 		printf("pindex:%d\n",pindex);
+ 		fflush(stdout);
+ #endif
+ 
+ 		pathArray[pindex].p = p + k - 1 ;
+ 		pathArray[pindex].q = number - 1 ;
+ 		pathArray[pindex].excluded = ex[0] ;
+ 		for( i = 1 ; i <= ex[0] ; i++ ) {
+ 		    pathArray[pindex].exlist[i] = ex[i] ;
+ 		}
+ 		for( j = 1 ; j <= number ; j++ ) {
+ 		    pathArray[pindex].nodeset[number - j + 1] = 
+ 							tempArray[j];
+ 		}
+ 		tinsert( &root1 , distance , pindex ) ;
+ 
+ 		
+ 		count = treeSize - (Mpaths - numberPaths) ;
+ 		if( count > 0 ) {
+ 		    for( c = 1 ; c <= count ; c++ ) {
+ 			tmax( &root1, &node, &value, &xindex ) ;
+ 			tdelete( &root1, value, xindex ) ;
+ 			tinsert( &indexRoot, xindex, 0 ) ;
+ 		    }
+ 		    treeSize -= count ;
+ 		}
+ 	
+ 	    }
+ 	}
+     }
+     count = tree2size - Mpaths ;
+     if( count > 0 ) {
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    tmax( &rsave, &node, &value, &xindex ) ;
+ 	    tdelete( &rsave, value, xindex ) ;
+ 	    tinsert( &indexRoot, xindex, 0 ) ;
+ 	}
+ 	tree2size -= count ;
+     }
+    
+     if( root1 != (TNODEPTR) NULL ) {
+ 	for( ; ; ) {
+ 	    tpop( &root1 , &node , &distance , &index ) ;
+ 	    if( node == (TNODEPTR) NULL ) {
+ 		break ;
+ 	    }
+ 	}
+     }
+     treeSize = 0 ;
+     if( wasInactive == 1 ) {
+ 	gptr = gnodeArray[target] ;
+ 	for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	    node1 = gptr->node ;
+ 	    gptr1 = gnodeArray[node1] ;
+ 	    for( ; ; ) {
+ 		if( gptr1->node == target ) {
+ 		    gptr1->einactive = 1 ;
+ 		    break ;
+ 		}
+ 		gptr1 = gptr1->next ;
+ 	    }
+ 	}
+ 	wasInactive = 0 ;
+     }
+ }
+ numberPaths = 0 ;
+ for( ; ; ) {
+     tpop( &rsave , &node , &distance , &index ) ;
+     if( node == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = pathArray[index].nodeset ;
+     k = pathArray[index].q + 1 ;
+     pathList[++numberPaths][0] = k ;
+     pathList[numberPaths][k + 1] = distance ;
+     for( i = 1 ; i <= k ; i++ ) {
+ 	pathList[numberPaths][i] = ptr[i] ;
+     }
+     if( numberPaths >= Mpaths ) {
+ 	break ;
+     }
+ }
+ if( indexRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &indexRoot , &node , &distance , &index ) ;
+ 	if( node == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( targetRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &targetRoot , &junkptr , &foo , &t ) ;
+ 	if( junkptr == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ return( numberPaths ) ;
+ }
+ 
+ 
+     
+ 
+ void greduce(short int *ptr,int p,int ex0,int ex1,int ex2,int ex3,int ex4 )
+ {
+ 
+ int l , node , node1 , node2 , exl[5] ;
+ GNODEPTR gptr , gptr1 , gptr2 ;
+ 
+ exl[1] = ex1 ;
+ exl[2] = ex2 ;
+ exl[3] = ex3 ;
+ exl[4] = ex4 ;
+ node1 = ptr[p] ;
+ gptr1 = gnodeArray[ node1 ] ;
+ for( l = 1 ; l <= ex0 ; l++ ) {
+     node2 = exl[l] ;
+     gptr2 = gnodeArray[ node2 ] ;
+     gptr = gptr1 ;
+     for( ; ; ) {
+ 	if( gptr->node == node2 ) {
+ 	    gptr->cost = VLARGE ;
+ 	    break ;
+ 	}
+ 	gptr = gptr->next ;
+     }
+     gptr = gptr2 ;
+     for( ; ; ) {
+ 	if( gptr->node == node1 ) {
+ 	    gptr->cost = VLARGE ;
+ 	    break ;
+ 	}
+ 	gptr = gptr->next ;
+     }
+ }
+ for( l = 1 ; l < p ; l++ ) {
+     node = ptr[l] ;
+     gptr = gnodeArray[node] ;
+     for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	node1 = gptr->node ;
+ 	gptr1 = gnodeArray[node1] ;
+ 	for( ; ; ) {
+ 	    if( gptr1->node == node ) {
+ 		gptr1->inactive = 1 ;
+ 		break ;
+ 	    }
+ 	    gptr1 = gptr1->next ;
+ 	}
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ 
+ 
+ void gunreduce(short int *ptr,int p,int ex0,int ex1,int ex2,int ex3,int ex4 )
+ {
+ 
+ int l , node , node1 , node2 , exl[5] ;
+ GNODEPTR gptr , gptr1 , gptr2 ;
+ 
+ exl[1] = ex1 ;
+ exl[2] = ex2 ;
+ exl[3] = ex3 ;
+ exl[4] = ex4 ;
+ node1 = ptr[p] ;
+ gptr1 = gnodeArray[ node1 ] ;
+ for( l = 1 ; l <= ex0 ; l++ ) {
+     node2 = exl[l] ;
+     gptr2 = gnodeArray[ node2 ] ;
+     gptr = gptr1 ;
+     for( ; ; ) {
+ 	if( gptr->node == node2 ) {
+ 	    gptr->cost = gptr->length ;
+ 	    break ;
+ 	}
+ 	gptr = gptr->next ;
+     }
+     gptr = gptr2 ;
+     for( ; ; ) {
+ 	if( gptr->node == node1 ) {
+ 	    gptr->cost = gptr->length ;
+ 	    break ;
+ 	}
+ 	gptr = gptr->next ;
+     }
+ }
+ for( l = 1 ; l < p ; l++ ) {
+     node = ptr[l] ;
+     gptr = gnodeArray[node] ;
+     for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	node1 = gptr->node ;
+ 	gptr1 = gnodeArray[node1] ;
+ 	for( ; ; ) {
+ 	    if( gptr1->node == node ) {
+ 		gptr1->inactive = 0 ;
+ 		break ;
+ 	    }
+ 	    gptr1 = gptr1->next ;
+ 	}
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mt.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mt.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mt.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,479 ----
+ /*
+ Fast 2D Manhattan transformation package including
+ transformation inversion.
+ See Newman and Sproull's Principles of Interactive Computer
+ Graphics to understand it.
+ Employed heavily by the Squid DBMS.
+ 
+ Copyright Ken Keller 1981
+ */
+ 
+ #include "port.h"
+ #include "kenk.h"
+ #include "lists.h"
+ #include "mt.h"
+ 
+ typedef enum {false,true} Bool;
+ 
+ void MTIdentity(MT *t);
+ void MTTranslate(MT *t,int x,int y);
+ static void MTInvert(MT *t);
+ 
+ MT *MTBegin(void)
+ /*
+ Returns pointer to transformation structure
+ that will be passed as an argument
+ to all of the package's routines.
+ If pointer is NULL, the structure can't be allocated.
+ MTBegin may be invoked any number of times.
+ */
+ {
+   MT *t;
+ 
+   if((t = ALLOCNODE(MT)) == NULL)
+     return(NULL);
+   t->sp = 0;
+   MTIdentity(t);
+   return(t);
+ }
+ 
+ void MTEnd(MT *t)
+ /*
+ Deallocates transformation structure.
+ */
+ {
+   FREENODE(MT,t);
+ }
+ 
+ void MTIdentity(MT *t)
+ /*
+ Make current transformation the identity transformation.
+ */
+ {
+   t->ti[0][0] = t->ti[1][1] = t->ti[2][2] = 
+     t->t[0][0] = t->t[1][1] = t->t[2][2] = 1;
+   t->t[0][1] = t->t[1][0] = t->t[0][2] = t->t[1][2] = 
+   t->t[2][0] = t->t[2][1] =
+     t->ti[0][1] = t->ti[1][0] = t->ti[0][2] = t->ti[1][2] = 
+     t->ti[2][0] = t->ti[2][1] = 0;
+ }
+ 
+ void MTTranslate(MT *t,int x,int y)
+ /*
+ Translate by (x,y). 
+ */
+ {
+   t->t[2][0] = t->t[2][0]+x;
+   t->t[2][1] = t->t[2][1]+y;
+   MTInvert(t);
+ }
+ 
+ void MTMY(MT *t)
+ /*
+ Mirror y coordinates. 
+ */
+ {
+   t->t[0][1] = -t->t[0][1];
+   t->t[1][1] = -t->t[1][1];
+   t->t[2][1] = -t->t[2][1];
+   MTInvert(t);
+ }
+ 
+ void MTMX(MT *t)
+ /*
+ Mirror x coordinates.
+ */
+ {
+   t->t[0][0] = -t->t[0][0];
+   t->t[1][0] = -t->t[1][0];
+   t->t[2][0] = -t->t[2][0];
+   MTInvert(t);
+ }
+ 
+ void MTRotate(MT *t,int x,int y)
+ /*
+ Rotate counter clockwise by direction vector (x,y).
+ Only 0, 90, 180, and 270 degrees have an effect.
+ */
+ {
+   register int i1;
+ 
+   if(x == 0) {
+     if(ABS(y) > 1)
+       if(y < 0)
+ 	y = -1;
+       else y = 1; }
+   ELIF(y == 0) {
+     if(ABS(x) > 1)
+       if(x < 0)
+ 	x = -1;
+       else x = 1; }
+   if(x == 1 AND y == 0) /*Don't rotate at all.*/
+     return; 
+   ELIF(x == 0 AND y == -1) /*Rotate ccw by 270 degrees.*/ {
+     i1 = t->t[0][0];
+     t->t[0][0] = t->t[0][1];
+     t->t[0][1] = -i1;
+     i1 = t->t[1][0];
+     t->t[1][0] = t->t[1][1];
+     t->t[1][1] = -i1;
+     i1 = t->t[2][0];
+     t->t[2][0] = t->t[2][1];
+     t->t[2][1] = -i1; }
+   ELIF(x == 0 AND y == 1) /*Rotate ccw by 90 degrees.*/ {
+     i1 = t->t[0][0];
+     t->t[0][0] = -t->t[0][1];
+     t->t[0][1] = i1;
+     i1 = t->t[1][0];
+     t->t[1][0] = -t->t[1][1];
+     t->t[1][1] = i1;
+     i1 = t->t[2][0];
+     t->t[2][0] = -t->t[2][1];
+     t->t[2][1] = i1; }
+   ELIF(x == -1 AND y == 0) /*Rotate ccw by 180 degrees.*/ {
+     register int i,j;
+ 
+     for(i = 0;i < 3;++i)
+       for(j = 0;j < 2;++j)
+         t->t[i][j] = -t->t[i][j]; }
+   MTInvert(t);
+ }
+ 
+ void MTConcat(MT *t,int a[3][3])
+ /*
+ Make current transformation the product of the
+ current transformation and a.
+ */
+ {
+   register int i1,i2,i3,i4,i5,i6;
+ 
+   i1 = t->t[0][0]*a[0][0]+
+     t->t[0][1]*a[1][0];
+   i2 = t->t[0][0]*a[0][1]+
+     t->t[0][1]*a[1][1];
+   i3 = t->t[1][0]*a[0][0]+
+     t->t[1][1]*a[1][0];
+   i4 = t->t[1][0]*a[0][1]+
+     t->t[1][1]*a[1][1];
+   i5 = t->t[2][0]*a[0][0]+
+     t->t[2][1]*a[1][0]+
+     a[2][0];
+   i6 = t->t[2][0]*a[0][1]+
+     t->t[2][1]*a[1][1]+
+     a[2][1];
+   t->t[0][0] = i1;
+   t->t[0][1] = i2;
+   t->t[1][0] = i3;
+   t->t[1][1] = i4;
+   t->t[2][0] = i5;
+   t->t[2][1] = i6;
+   MTInvert(t);
+ }
+ 
+ void MTPoint(MT *t,int *x,int *y)
+ /*
+ MT (x,y) by current transformation.
+ */
+ {
+   int i1;
+ 
+   i1 = *x*t->t[0][0]+*y*t->t[1][0]+
+     t->t[2][0];
+   *y = *x*t->t[0][1]+*y*t->t[1][1]+
+     t->t[2][1];
+   *x = i1;
+ }
+ 
+ void MTIPoint(MT *t,int *x,int *y)
+ /*
+ Invert (x,y).
+ */
+ {
+   int i1;
+ 
+   i1 = *x*t->ti[0][0]+*y*t->ti[1][0]+
+     t->ti[2][0];
+   *y = *x*t->ti[0][1]+*y*t->ti[1][1]+
+     t->ti[2][1];
+   *x = i1;
+ }
+ 
+ Bool MTPushP(MT *t)
+ /*
+ Pushes current transformation on the transformation stack.
+ Current transformation is not changed.
+ Returns false if stack is full, else true.
+ */
+ {
+   register int i,j;
+ 
+   if(t->sp == TSTKSIZE)
+     return(false);
+   for(i = 0;i < 3;++i)
+     for(j = 0;j < 2;++j)
+       t->stk[t->sp][i][j] = 
+         t->t[i][j];
+   ++t->sp;
+   return(true);
+ }
+ 
+ Bool MTPopP(MT *t)
+ /*
+ Makes the top of the transformation stack the current transformation and
+ pops the stack.
+ Returns false if stack is empty, else true.
+ */
+ {
+   register int i,j;
+ 
+   if(t->sp == 0)
+     return(false);
+   --t->sp;
+   for(i = 0;i < 3;++i)
+     for(j = 0;j < 2;++j)
+       t->t[i][j] = t->stk[t->sp]
+         [i][j];
+   MTInvert(t);
+   return(true);
+ }
+ 
+ Bool MTPremultiplyP(MT *t)
+ /*
+ Make the current transformation the matrix product of the
+ the current transformation and the top of the transformation stack.
+ Returns false if stack is empty.
+ */
+ {
+   register int i1,i2,i3,i4,i5,i6,sp;
+ 
+   if(t->sp == 0)
+     return(false);
+   sp = t->sp-1;
+   i1 = t->t[0][0]*t->stk[sp][0][0]+
+     t->t[0][1]*t->stk[sp][1][0];
+   i2 = t->t[0][0]*t->stk[sp][0][1]+
+     t->t[0][1]*t->stk[sp][1][1];
+   i3 = t->t[1][0]*t->stk[sp][0][0]+
+     t->t[1][1]*t->stk[sp][1][0];
+   i4 = t->t[1][0]*t->stk[sp][0][1]+
+     t->t[1][1]*t->stk[sp][1][1];
+   i5 = t->t[2][0]*t->stk[sp][0][0]+
+     t->t[2][1]*t->stk[sp][1][0]+
+     t->stk[sp][2][0];
+   i6 = t->t[2][0]*t->stk[sp][0][1]+
+     t->t[2][1]*t->stk[sp][1][1]+
+     t->stk[sp][2][1];
+   t->t[0][0] = i1;
+   t->t[0][1] = i2;
+   t->t[1][0] = i3;
+   t->t[1][1] = i4;
+   t->t[2][0] = i5;
+   t->t[2][1] = i6;
+   MTInvert(t);
+   return(true);
+ }
+ 
+ Bool MTDecodeP(MT *t,char **s)
+ /*
+ Decodes current transformation into its "CIF equivalent" and
+ returns it in the string s.
+ Returns false if can't decode.
+ */
+ {
+   register int a,b,c,d,tx,ty;
+   static char cif[81];
+ 
+   if(NOT MTPushP(t))
+     return(false);
+   /*
+   Let
+   a c
+   b d
+   be the upper left corner of t->t.
+   */
+   a = t->t[0][0];
+   b = t->t[1][0];
+   c = t->t[0][1];
+   d = t->t[1][1];
+   tx = t->t[2][0];
+   ty = t->t[2][1];
+   MTIdentity(t);
+   if(a == 0 AND b == 1 AND c == 1 AND d == 0) {
+     MTMX(t);
+     MTRotate(t,0,-1);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"MX R 0 -1 T %d %d",tx,ty);
+     else sprintf(cif,"MX R 0 -1"); }
+   ELIF(a == 0 AND b == -1 AND c == -1 AND d == 0) {
+     MTMX(t);
+     MTRotate(t,0,1);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"MX R 0 1 T %d %d",tx,ty);
+     else sprintf(cif,"MX R 0 1"); }
+   ELIF(a == 0 AND b == 1 AND c == -1 AND d == 0) {
+     MTRotate(t,0,-1);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"R 0 -1 T %d %d",tx,ty);
+     else sprintf(cif,"R 0 -1"); }
+   ELIF(a == 0 AND b == -1 AND c == 1 AND d == 0) {
+     MTRotate(t,0,1);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"R 0 1 T %d %d",tx,ty);
+     else sprintf(cif,"R 0 1"); }
+   ELIF(a == 1 AND b == 0 AND c == 0 AND d == 1) {
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"T %d %d",tx,ty); 
+     else cif[0] = EOS;}
+   ELIF(a == -1 AND b == 0 AND c == 0 AND d == -1) {
+     MTRotate(t,-1,0);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"R -1 0 T %d %d",tx,ty);
+     else sprintf(cif,"R -1 0"); }
+   ELIF(a == -1 AND b == 0 AND c == 0 AND d == 1) {
+     MTMX(t);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"MX T %d %d",tx,ty);
+     else sprintf(cif,"MX"); }
+   ELIF(a == 1 AND b == 0 AND c == 0 AND d == -1) {
+     MTMY(t);
+     MTTranslate(t,tx,ty);
+     if(tx != 0 OR ty != 0) 
+       sprintf(cif,"MY T %d %d",tx,ty);
+     else sprintf(cif,"MY"); }
+   else {
+     MTPopP(t);
+     return(false); }
+   if(t->t[0][0] == a AND t->t[0][1] == c AND t->t[1][0] == b AND 
+ 		t->t[1][1] == d) {
+     MTPopP(t);
+     *s = cif;
+     return(true); }
+   else {
+     MTPopP(t);
+     return(false); }
+ }
+ 
+ static void MTInvert(MT *t)
+ /*
+ From CSVAX:ouster  Thu Jun 25 15:26:13 1981
+ To: ESVAX:keller
+ Subject: MT ti
+ 
+ Caesar uses the following mechanism for inverting a transform, which
+ I have verified exhaustively to be correct for transforms with no
+ scaling and rotations that are multiples of 90 degrees.
+ 
+ If the original transform is
+ a d 0
+ b e 0
+ c f 1
+ 
+ then the inverse is
+ 
+  1  0  0	 a b 0
+  0  1  0  times  d e 0
+ -c -f  0	 0 0 0
+ 
+ Try this for all 8 possible combinations of mirroring and rotation to
+ convince yourself that it works.
+ 					-John-
+ 
+ So, the inverse is
+ a b 0
+ d e 0
+ -ca-fd -cb-fe
+ 
+ KK 7/81
+ */
+ {
+   t->ti[0][0] = t->t[0][0]; /*a*/
+   t->ti[0][1] = t->t[1][0]; /*d*/
+   t->ti[1][0] = t->t[0][1]; /*b*/
+   t->ti[1][1] = t->t[1][1]; /*e*/
+   /*-ca-fd*/
+   t->ti[2][0] = -t->t[2][0]*t->t[0][0]-t->t[2][1]*t->t[0][1];
+   /*-cb-fe*/
+   t->ti[2][1] = -t->t[2][0]*t->t[1][0]-t->t[2][1]*t->t[1][1];
+   t->ti[0][2] = t->ti[1][2] = 0;
+   t->ti[2][2] = 1;
+ }
+ 
+ #ifdef TEST1
+ void main(void)
+ {
+   int selection;
+   MT *t;
+   char *cif;
+ 
+   t = MTBegin();
+   MTIdentity(t);
+   LOOP {
+     printf("\n");
+     printf("1 Mirror in x.\n");
+     printf("2 Mirror in y.\n");
+     printf("3 Rotate by 90.\n");
+     printf("4 Rotate by 180.\n");
+     printf("5 Rotate by 270.\n");
+     printf("6 Translate by a random amount.\n");
+     printf("7 Decode.\n"); 
+     printf("8 Is inverse correct?\n"); 
+     printf("9 Current transform?\n"); 
+     scanf("%d",&selection);
+     printf("\n");
+     switch(selection) {
+       case 1:
+ 	MTMX(t);
+ 	break;
+       case 2:
+ 	MTMY(t);
+ 	break;
+       case 3:
+ 	MTRotate(t,0,1);
+ 	break;
+       case 4:
+ 	MTRotate(t,-1,0);
+ 	break;
+       case 5:
+ 	MTRotate(t,0,-1);
+ 	break;
+       case 6:
+ 	MTTranslate(t,33,17);
+ 	break;
+       case 7:
+ 	if(MTDecodeP(t,&cif))
+ 	  printf("Decoding is %s.\n",cif); 
+ 	else printf("Couldn't decode.\n");
+ 	break;
+       case 8:
+ 	MTPushP(t);
+ 	/*Multiply t->t by t->ti.*/
+ 	MTConcat(t,t->ti);
+ 	/*Is the product the identity matrix?*/
+ 	if(t->t[0][0] == 1 AND t->t[1][1] == 1 AND 
+ 	  t->t[2][2] == 1 AND t->t[0][1] == 0 AND t->t[0][2] == 0
+ 	  AND t->t[1][0] == 0 AND t->t[1][2] == 0 AND 
+ 	  t->t[2][0] == 0 AND t->t[2][1] == 0)
+ 	  printf("Yes.\n");
+         else printf("No.\n");
+ 	MTPopP(t);
+ 	break;
+       case 9: {
+ 	int i,j;
+ 
+ 	for(i = 0;i < 3;++i) {
+ 	  for(j = 0;j < 3;++j)
+ 	    printf("%d ",t->t[i][j]);
+ 	  printf("\n"); } }
+ 	break;
+       default:
+ 	printf("What?\n");
+ 	break; } }
+ }
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mt.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mt.h:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/mt.h	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,21 ----
+ #include "port.h"
+ /*
+ Types for fast 2D Manhattan transformation package.
+ 
+ Copyright Ken Keller 1981
+ */
+ 
+ #define TSTKSIZE 100
+ 
+ typedef struct MT {
+   /*Transformation stack pointer.*/
+   int sp;
+   /*Transformation stack.*/
+   int stk[TSTKSIZE][3][3];
+   /*Current transform.*/
+   int t[3][3];
+   /*Inverse of current transform.*/
+   int ti[3][3]; }
+   MT ;
+ 
+ extern MT *MTBegin();


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/neworient.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/neworient.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/neworient.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,92 ----
+ #include "custom.h"
+ 
+ int newOrient( CELLBOXPTR cellptr , int range )
+ {
+ 
+ int incidence , count , i , orient ;
+ 
+ orient = cellptr->orient ;
+ if( range == 4 ) {
+     if( orient >= 4 ) {
+ 	count = 0 ;
+ 	for( i = 0 ; i <= 3 ; i++ ) {
+ 	    if( cellptr->orientList[i] == 1 ) {
+ 		count++ ;
+ 	    }
+ 	}
+ 	if( count == 0 ) {
+ 	    return( -1 ) ;
+ 	}
+ 	do {
+ 	    incidence = (int) ( (double) count * 
+ 			      ( (double) RAND / 
+ 			      (double) 0x7fffffff ) ) + 1 ;
+ 	} while( incidence == count + 1 ) ;
+ 
+ 	count = 0 ;
+ 	for( i = 0 ; i <= 3 ; i++ ) {
+ 	    if( cellptr->orientList[i] == 1 ) {
+ 		if( ++count == incidence ) {
+ 		    return( i ) ;
+ 		}
+ 	    }
+ 	}
+ 	
+     } else {
+ 	count = 0 ;
+ 	for( i = 4 ; i <= 7 ; i++ ) {
+ 	    if( cellptr->orientList[i] == 1 ) {
+ 		count++ ;
+ 	    }
+ 	}
+ 	if( count == 0 ) {
+ 	    return( -1 ) ;
+ 	}
+ 	do {
+ 	    incidence = (int) ( (double) count * 
+ 			     ( (double) RAND / 
+ 			     (double) 0x7fffffff ) ) + 1 ;
+ 	} while( incidence == count + 1 ) ;
+ 
+ 	count = 0 ;
+ 	for( i = 4 ; i <= 7 ; i++ ) {
+ 	    if( cellptr->orientList[i] == 1 ) {
+ 		if( ++count == incidence ) {
+ 		    return( i ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ } else {
+     count = 0 ;
+     for( i = 0 ; i <= 7 ; i++ ) {
+ 	if( i == orient ) {
+ 	    continue ;
+ 	}
+ 	if( cellptr->orientList[i] == 1 ) {
+ 	    count++ ;
+ 	}
+     }
+     if( count == 0 ) {
+ 	return( -1 ) ;
+     }
+     do {
+ 	incidence = (int) ( (double) count * 
+ 			  ( (double) RAND / 
+ 			  (double) 0x7fffffff ) ) + 1 ;
+     } while( incidence == count + 1 ) ;
+ 
+     count = 0 ;
+     for( i = 0 ; i <= 7 ; i++ ) {
+ 	if( i == orient ) {
+ 	    continue ;
+ 	}
+ 	if( cellptr->orientList[i] == 1 ) {
+ 	    if( ++count == incidence ) {
+ 		return( i ) ;
+ 	    }
+ 	}
+     }
+ }
+ /*NOTREACHED*/
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outbig.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outbig.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outbig.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,126 ----
+ #include "custom.h"
+ extern int finalShot ;
+ BUSTBOXPTR PtsArray ;
+ BUSTBOXPTR PtsOut   ;
+ typedef struct Rangle {
+     int rl ;
+     int rr ;
+     int rb ;
+     int rt ;
+ } RANGLE ;
+ RANGLE *rectang ;
+ 
+ extern void initPts( int cell , char *name , int orient );
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern void addPts( int l , int r , int b , int t );
+ extern void unbust(void);
+ 
+ void outbig(void)
+ {
+ 
+ FILE *fp ;
+ int j , x , y , pin ;
+ int cell , Wwd ;
+ int l , b , r , t , xc , yc , k ;
+ char filename[1024] ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr ;
+ 
+ k = ( bdxlength > bdylength ) ? bdxlength : bdylength ;
+ Wwd = (int)( (double) k / 500.0 ) + 1 ;
+ 
+ if( finalShot == 0 ) {
+     rectang = (RANGLE *) malloc( 26 * sizeof( RANGLE ) ) ;
+     PtsArray = (BUSTBOXPTR) malloc( 101 * sizeof(BUSTBOX) ) ;
+     PtsOut   = (BUSTBOXPTR) malloc( 101 * sizeof(BUSTBOX) ) ;
+ }
+ 
+ sprintf( filename, "%s.cfb", cktName ) ;
+ if( (fp = fopen( filename , "w") ) == NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit(0) ;
+ }
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+     termptr = tileptr->termptr ;
+ 
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     
+     initPts( cell , cellptr->cname , cellptr->orient ) ;
+ 
+     l = tileptr->left ;
+     r = tileptr->right ;
+     b = tileptr->bottom ;
+     t = tileptr->top ;
+     if( cell <= numcells ) {
+ 	if( finalShot == 0 ) {
+ 	    l -= wireestx( xc+l , yc+b , yc+t , tileptr->lweight ) ;
+ 	    r += wireestx( xc+r , yc+b , yc+t , tileptr->rweight ) ;
+ 	    b -= wireestx( yc+b , xc+l , xc+r , tileptr->bweight ) ;
+ 	    t += wireestx( yc+t , xc+l , xc+r , tileptr->tweight ) ;
+ 	} else {
+ 	    l -= tileptr->lborder ;
+ 	    r += tileptr->rborder ;
+ 	    b -= tileptr->bborder ;
+ 	    t += tileptr->tborder ;
+ 	}
+     }
+     addPts( l , r , b , t ) ;
+ 
+     l += xc ;
+     r += xc ;
+     b += yc ;
+     t += yc ;
+     fprintf(fp,"L NC;\n94 %s %d %d;\n",
+ 			    cellptr->cname , (r + l)/2 , (t + b)/2 );
+     unbust() ;
+     /*
+      *  The vertices comprising the outline are in order
+      *  in the array: PtsOut[]
+      */
+ 
+     fprintf(fp,"L NC;\nW %d", Wwd );
+     for( k = 1 ; k < PtsOut[0].xc ; k++ ) {
+ 	fprintf(fp," %d %d", xc + PtsOut[k].xc, yc + PtsOut[k].yc );
+     }
+     fprintf(fp," %d %d;\n", xc + PtsOut[1].xc, yc + PtsOut[1].yc );
+ 
+    
+     for( ; termptr != TERMNULL ; termptr = termptr->nextterm ) {
+ 	x = xc + termptr->xpos ; 
+ 	y = yc + termptr->ypos ; 
+ 	pin = termptr->terminal ;
+ 	if( strcmp( pinnames[pin] , "PHANTOM" ) != 0 ) {
+ 	    fprintf(fp,"L NC;\n94 %s %d %d;\n",
+ 		    netarray[ termarray[pin]->net ]->nname, x , y ) ;
+ 	}
+     }
+     
+     if( cellptr->softflag == 1 ) {
+ 	for( j = 1 ; j <= cellptr->numUnComTerms ; j++ ) {
+ 	    x = xc + cellptr->unComTerms[j].finalx ;
+ 	    y = yc + cellptr->unComTerms[j].finaly ;
+ 	    pin  = cellptr->unComTerms[j].terminal ;
+ 	    fprintf(fp,"L NC;\n94 %s %d %d;\n", 
+ 		     netarray[ termarray[pin]->net ]->nname, x , y ) ;
+ 	}
+     }
+ }
+ 
+ l = blockl ;
+ r = blockr ;
+ b = blockb ;
+ t = blockt ;
+ 
+ fprintf(fp,"L NC;\n");
+ fprintf(fp,"W %d %d %d %d %d %d %d %d %d %d %d;\n", Wwd ,
+ 					l, b, l, t, r, t, r, b, l, b ) ;
+ 
+ fprintf( fp , "E\n" );
+ fclose( fp ) ;
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outgeo.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outgeo.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outgeo.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,198 ----
+ #include "custom.h"
+ extern BUSTBOXPTR PtsArray ;
+ extern BUSTBOXPTR PtsOut   ;
+ typedef struct Rangle {
+     int rl ;
+     int rr ;
+     int rb ;
+     int rt ;
+ } RANGLE ;
+ extern RANGLE *rectang ;
+ 
+ #define L 1
+ #define T 2
+ #define R 3
+ #define B 4
+ 
+ extern void initPts( int cell , char *name , int orient );
+ extern void addPts( int l , int r , int b , int t );
+ extern void unbust(void);
+ 
+ void outgeo(void)
+ {
+ 
+ FILE *fp ;
+ int cell ;
+ int l , b , r , t , xc , yc , k ;
+ char filename[1024] ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ 
+ 
+ sprintf( filename, "%s.geo", cktName ) ;
+ if( (fp = fopen( filename , "w") ) == NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit(0) ;
+ }
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[cell] ;
+ 
+     tileptr = cellptr->config[ cellptr->orient ] ;
+ 
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     
+     initPts( cell , cellptr->cname , cellptr->orient ) ;
+     for( tileptr = tileptr->nexttile ; tileptr != TILENULL ;
+ 				tileptr = tileptr->nexttile ) {
+ 	
+ 	l = tileptr->left ;
+ 	r = tileptr->right ;
+ 	b = tileptr->bottom ;
+ 	t = tileptr->top ;
+ 	addPts( l , r , b , t ) ;
+     }
+     unbust() ;
+ 
+     fprintf(fp,"cell %s \n", cellptr->cname ) ;
+     fprintf(fp,"%d vertices ", PtsOut[0].xc - 1 );
+   
+     for( k = 1 ; k < PtsOut[0].xc ; k++ ) {
+ 	fprintf(fp," %d %d", xc + PtsOut[k].xc, yc + PtsOut[k].yc );
+     }
+     fprintf(fp,"\n");
+ }
+ 
+ l = 100000000 ;
+ b = 100000000 ;
+ r = -100000000 ;
+ t = -100000000 ;
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cellptr->padside != L ) {
+ 	continue ;
+     }
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+ 
+     if( xc + tileptr->left < l ) {
+ 	l = xc + tileptr->left ;
+     }
+     if( xc + tileptr->right > r ) {
+ 	r = xc + tileptr->right ;
+     }
+     if( yc + tileptr->bottom < b ) {
+ 	b = yc + tileptr->bottom ;
+     }
+     if( yc + tileptr->top > t ) {
+ 	t = yc + tileptr->top ;
+     }
+ }
+ if( t != -100000000 ) {
+     fprintf(fp,"cell %s \n", "pad.macro.l" ) ;
+     fprintf(fp,"4 vertices ") ;
+     fprintf(fp," %d %d %d %d %d %d %d %d\n", l, b, l, t, r, t, r, b ) ;
+ }
+ 
+ l = 100000000 ;
+ b = 100000000 ;
+ r = -100000000 ;
+ t = -100000000 ;
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cellptr->padside != T ) {
+ 	continue ;
+     }
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+ 
+     if( xc + tileptr->left < l ) {
+ 	l = xc + tileptr->left ;
+     }
+     if( xc + tileptr->right > r ) {
+ 	r = xc + tileptr->right ;
+     }
+     if( yc + tileptr->bottom < b ) {
+ 	b = yc + tileptr->bottom ;
+     }
+     if( yc + tileptr->top > t ) {
+ 	t = yc + tileptr->top ;
+     }
+ }
+ if( t != -100000000 ) {
+     fprintf(fp,"cell %s \n", "pad.macro.t" ) ;
+     fprintf(fp,"4 vertices ") ;
+     fprintf(fp," %d %d %d %d %d %d %d %d\n", l, b, l, t, r, t, r, b ) ;
+ }
+ 
+ l = 100000000 ;
+ b = 100000000 ;
+ r = -100000000 ;
+ t = -100000000 ;
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cellptr->padside != R ) {
+ 	continue ;
+     }
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+ 
+     if( xc + tileptr->left < l ) {
+ 	l = xc + tileptr->left ;
+     }
+     if( xc + tileptr->right > r ) {
+ 	r = xc + tileptr->right ;
+     }
+     if( yc + tileptr->bottom < b ) {
+ 	b = yc + tileptr->bottom ;
+     }
+     if( yc + tileptr->top > t ) {
+ 	t = yc + tileptr->top ;
+     }
+ }
+ if( t != -100000000 ) {
+     fprintf(fp,"cell %s \n", "pad.macro.r" ) ;
+     fprintf(fp,"4 vertices ") ;
+     fprintf(fp," %d %d %d %d %d %d %d %d\n", l, b, l, t, r, t, r, b ) ;
+ }
+ 
+ l = 100000000 ;
+ b = 100000000 ;
+ r = -100000000 ;
+ t = -100000000 ;
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cellptr->padside != B ) {
+ 	continue ;
+     }
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+ 
+     if( xc + tileptr->left < l ) {
+ 	l = xc + tileptr->left ;
+     }
+     if( xc + tileptr->right > r ) {
+ 	r = xc + tileptr->right ;
+     }
+     if( yc + tileptr->bottom < b ) {
+ 	b = yc + tileptr->bottom ;
+     }
+     if( yc + tileptr->top > t ) {
+ 	t = yc + tileptr->top ;
+     }
+ }
+ if( t != -100000000 ) {
+     fprintf(fp,"cell %s \n", "pad.macro.b" ) ;
+     fprintf(fp,"4 vertices ") ;
+     fprintf(fp," %d %d %d %d %d %d %d %d\n", l, b, l, t, r, t, r, b ) ;
+ }
+ 
+ fclose( fp ) ;
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outpin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outpin.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outpin.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,100 ----
+ #include "custom.h"
+ #define L 1
+ #define T 2
+ #define R 3
+ #define B 4
+ 
+ void outpin(void)
+ {
+ 
+ FILE *fp ;
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ int net , count , cell , c[5] ;
+ char filename[1024] ;
+ 
+ sprintf( filename, "%s.pin", cktName ) ;
+ if( (fp = fopen( filename , "w") ) == NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit(0) ;
+ }
+ c[1] = 0 ;
+ c[2] = 0 ;
+ c[3] = 0 ;
+ c[4] = 0 ;
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     if( cellarray[cell]->padside == L ) {
+ 	c[1] = 1 ;
+ 	break ;
+     }
+ }
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     if( cellarray[cell]->padside == T ) {
+ 	c[2] = 1 ;
+ 	break ;
+     }
+ }
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     if( cellarray[cell]->padside == R ) {
+ 	c[3] = 1 ;
+ 	break ;
+     }
+ }
+ for( cell = numcells + 1 ; cell <= numcells + numpads ; cell++ ) {
+     if( cellarray[cell]->padside == B ) {
+ 	c[4] = 1 ;
+ 	break ;
+     }
+ }
+ c[0] = numcells + 1 ;
+ if( c[1] == 1 ) {
+     c[1] = c[0]++ ;
+ }
+ if( c[2] == 1 ) {
+     c[2] = c[0]++ ;
+ }
+ if( c[3] == 1 ) {
+     c[3] = c[0]++ ;
+ }
+ if( c[4] == 1 ) {
+     c[4] = c[0]++ ;
+ }
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     count = 0 ;
+     dimptr =  netarray[net] ;
+     for( netptr = dimptr->netptr ; netptr != NETNULL ;
+ 				    netptr = netptr->nextterm ) {
+ 	if( netptr->PorE > 0 ) {
+ 	    count++ ;
+ 	}
+     }
+     if( count <= 1 ) {
+ 	continue ;
+     }
+     dimptr =  netarray[net] ;
+     fprintf(fp,"net %s\n", dimptr->nname ) ;
+     for( netptr = dimptr->netptr ; netptr != NETNULL ;
+ 				    netptr = netptr->nextterm ) {
+ 	if( netptr->cell <= numcells ) {
+ 	    cell = netptr->cell ;
+ 	} else {
+ 	    if( cellarray[netptr->cell]->padside == L ) {
+ 		cell = c[1] ;
+ 	    } else if( cellarray[netptr->cell]->padside == T ) {
+ 		cell = c[2] ;
+ 	    } else if( cellarray[netptr->cell]->padside == R ) {
+ 		cell = c[3] ;
+ 	    } else if( cellarray[netptr->cell]->padside == B ) {
+ 		cell = c[4] ;
+ 	    }
+ 	}
+ 	fprintf(fp,"pin %s  x %d  y %d  cell %d  PinOrEquiv %d\n",
+ 		pinnames[netptr->terminal] , netptr->xpos ,
+ 		netptr->ypos , cell , netptr->PorE ) ;
+     }
+     fprintf(fp,"\n");
+ }
+ fclose(fp);
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/output.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/output.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/output.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,91 ----
+ #include "custom.h"
+ extern BUSTBOXPTR PtsArray ;
+ extern BUSTBOXPTR PtsOut   ;
+ typedef struct Rangle {
+     int rl ;
+     int rr ;
+     int rb ;
+     int rt ;
+ } RANGLE ;
+ extern RANGLE *rectang ;
+ 
+ extern void initPts( int cell , char *name , int orient );
+ extern void addPts( int l , int r , int b , int t );
+ extern void unbust(void);
+ 
+ void output(void)
+ {
+ 
+ FILE *fp ;
+ int j , x , y , pin ;
+ int cell ;
+ int l , b , r , t , xc , yc , k ;
+ char filename[1024] ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr ;
+ 
+ 
+ sprintf( filename, "%s.dat", cktName ) ;
+ if( (fp = fopen( filename , "w") ) == NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit(0) ;
+ }
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     if( cell <= numcells ) {
+ 	fprintf(fp,"cell %s  orientation %d\n", cellptr->cname , 
+ 						cellptr->orient ) ;
+ 	fprintf(fp,"vertices ");
+     } else {
+ 	fprintf(fp,"pad %s\n", cellptr->cname ) ;
+ 	fprintf(fp,"vertices ");
+     }
+     tileptr = cellptr->config[ cellptr->orient ] ;
+     termptr = tileptr->termptr ;
+ 
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     
+     initPts( cell , cellptr->cname , cellptr->orient ) ;
+     for( tileptr = tileptr->nexttile ; tileptr != TILENULL ;
+ 				tileptr = tileptr->nexttile ) {
+ 	
+ 	l = tileptr->left ;
+ 	r = tileptr->right ;
+ 	b = tileptr->bottom ;
+ 	t = tileptr->top ;
+ 	addPts( l , r , b , t ) ;
+     }
+     unbust() ;
+     for( k = 1 ; k < PtsOut[0].xc ; k++ ) {
+ 	fprintf(fp," %d %d", xc + PtsOut[k].xc, yc + PtsOut[k].yc );
+     }
+     fprintf(fp,"\n");
+ 
+    
+     for( ; termptr != TERMNULL ; termptr = termptr->nextterm ) {
+ 	x = xc + termptr->xpos ; 
+ 	y = yc + termptr->ypos ; 
+ 	pin = termptr->terminal ;
+ 	if( strcmp( pinnames[pin] , "PHANTOM" ) != 0 ) {
+ 	    fprintf(fp,"pin %s %s %d %d\n", pinnames[pin] , 
+ 		    netarray[ termarray[pin]->net ]->nname, x , y ) ;
+ 	}
+     }
+     
+     if( cellptr->softflag == 1 ) {
+ 	for( j = 1 ; j <= cellptr->numUnComTerms ; j++ ) {
+ 	    x = xc + cellptr->unComTerms[j].finalx ;
+ 	    y = yc + cellptr->unComTerms[j].finaly ;
+ 	    pin  = cellptr->unComTerms[j].terminal ;
+ 	    fprintf(fp,"pin %s %s %d %d\n", pinnames[pin] , 
+ 		     netarray[ termarray[pin]->net ]->nname, x , y ) ;
+ 	}
+     }
+ }
+ fclose( fp ) ;
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outsmall.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outsmall.c:1.1
*** /dev/null	Tue Oct  5 16:20:05 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/outsmall.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,122 ----
+ #include "custom.h"
+ #define DEBUG
+ extern BUSTBOXPTR PtsArray ;
+ extern BUSTBOXPTR PtsOut   ;
+ typedef struct Rangle {
+     int rl ;
+     int rr ;
+     int rb ;
+     int rt ;
+ } RANGLE ;
+ extern RANGLE *rectang ;
+ #ifdef DEBUG
+ FILE *fpNodes ;
+ #endif
+ extern int redoFlag ;
+ 
+ extern void initPts( int cell , char *name , int orient );
+ extern void addPts( int l , int r , int b , int t );
+ extern void unbust(void);
+ 
+ void outsmall(void)
+ {
+ 
+ FILE *fp ;
+ int j , x , y , pin ;
+ int cell , Wwd ;
+ int l , b , r , t , xc , yc , k ;
+ char filename[1024] ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr ;
+ 
+ k = ( bdxlength > bdylength ) ? bdxlength : bdylength ;
+ Wwd = (int)( (double) k / 500.0 ) + 1 ;
+ /* Wwd = (int)( (double) k / 180.0 ) + 1 ; */
+ 
+ sprintf( filename, "%s.cfs", cktName ) ;
+ if( (fp = fopen( filename , "w") ) == NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit(0) ;
+ }
+ #ifdef DEBUG
+ if( redoFlag ) {
+     fclose(fpNodes) ;
+ }
+ fpNodes = fp ;
+ #endif
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[cell] ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+     termptr = tileptr->termptr ;
+ 
+     xc = cellptr->xcenter ;
+     yc = cellptr->ycenter ;
+     
+     initPts( cell , cellptr->cname , cellptr->orient ) ;
+     for( tileptr = tileptr->nexttile ; tileptr != TILENULL ;
+ 				tileptr = tileptr->nexttile ) {
+ 	
+ 	l = tileptr->left ;
+ 	r = tileptr->right ;
+ 	b = tileptr->bottom ;
+ 	t = tileptr->top ;
+ 	addPts( l , r , b , t ) ;
+ 
+ 	l += xc ;
+ 	r += xc ;
+ 	b += yc ;
+ 	t += yc ;
+ 	fprintf(fp,"L NC;\n94 %s %d %d;\n",
+ 			    cellptr->cname , (r + l)/2 , (t + b)/2 );
+     }
+     unbust() ;
+     /*
+      *  The vertices comprising the outline are in order
+      *  in the array: PtsOut[]
+      */
+ 
+     fprintf(fp,"L NC;\nW %d", Wwd );
+     for( k = 1 ; k < PtsOut[0].xc ; k++ ) {
+ 	fprintf(fp," %d %d", xc + PtsOut[k].xc, yc + PtsOut[k].yc );
+     }
+     fprintf(fp," %d %d;\n", xc + PtsOut[1].xc, yc + PtsOut[1].yc );
+ 
+    
+     for( ; termptr != TERMNULL ; termptr = termptr->nextterm ) {
+ 	x = xc + termptr->xpos ; 
+ 	y = yc + termptr->ypos ; 
+ 	pin = termptr->terminal ;
+ 	if( strcmp( pinnames[pin] , "PHANTOM" ) != 0 ) {
+ 	    fprintf(fp,"L NC;\n94 %s %d %d;\n",
+ 		    netarray[ termarray[pin]->net ]->nname, x , y ) ;
+ 	}
+     }
+     
+     if( cellptr->softflag == 1 ) {
+ 	for( j = 1 ; j <= cellptr->numUnComTerms ; j++ ) {
+ 	    x = xc + cellptr->unComTerms[j].finalx ;
+ 	    y = yc + cellptr->unComTerms[j].finaly ;
+ 	    pin  = cellptr->unComTerms[j].terminal ;
+ 	    fprintf(fp,"L NC;\n94 %s %d %d;\n", 
+ 		     netarray[ termarray[pin]->net ]->nname, x , y ) ;
+ 	}
+     }
+ }
+ 
+ l = blockl ;
+ r = blockr ;
+ b = blockb ;
+ t = blockt ;
+ 
+ fprintf(fp,"L NC;\n");
+ fprintf(fp,"W %d %d %d %d %d %d %d %d %d %d %d;\n", Wwd ,
+ 					l, b, l, t, r, t, r, b, l, b ) ;
+ 
+ #ifndef DEBUG
+ fprintf( fp , "E\n" );
+ fclose( fp ) ;
+ #endif
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/parser.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/parser.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/parser.c	Tue Oct  5 16:19:46 2004
***************
*** 0 ****
--- 1,617 ----
+ #include "custom.h"
+ int *fixLRBT ;
+ double *padspace ;
+ 
+ extern void makebins( int numc );
+ 
+ void parser( FILE *fp )
+ {
+ 
+ int i , space , cell , test , orient , norients ;
+ int xpos , ypos , pad ;
+ int code , class ;
+ int sequence , firstside , lastside , cellnum ;
+ int corner , ncorners , x , y , minx , miny , maxx , maxy ;
+ double aspub , asplb ;
+ char input[1024] ;
+ CELLBOXPTR ptr ;
+ 
+ 
+ maxterm = 0    ;
+ cell = 0       ;
+ pad = 0        ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "cell") == 0 ) {
+ 	test = fscanf( fp , "%d" , &cellnum ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input cell # in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input keyword name \n");
+ 	    fprintf(fpo," in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( strcmp( input , "name" ) != 0 ) {
+ 	    fprintf(fpo,"Failed to input keyword name \n");
+ 	    fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input cell name in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	cell++ ;
+ 	code = 3 ;
+ 	test = fscanf( fp , " %d " , &ncorners ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input corners in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( ncorners < 4 ) {
+ 	    fprintf(fpo,"Failed to input at least 4 corners");
+ 	    fprintf(fpo," in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "corners") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: corners ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    test = fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    if( test != 2 ) {
+ 		fprintf(fpo,"Failed to input corner coordinates\n");
+ 		fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 		exit(0);
+ 	    } else {
+ 		if( corner == 1 ) {
+ 		    minx = x ;
+ 		    miny = y ;
+ 		    maxx = x ;
+ 		    maxy = y ;
+ 		} else {
+ 		    if( x < minx ) {
+ 			minx = x ;
+ 		    }
+ 		    if( x > maxx ) {
+ 			maxx = x ;
+ 		    }
+ 		    if( y < miny ) {
+ 			miny = y ;
+ 		    }
+ 		    if( y > maxy ) {
+ 			maxy = y ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "class") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: class ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &class ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input class in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &norients ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input orientations in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( norients < 1 || norients > 8 ) {
+ 	    fprintf(fpo,"Failed to input orientations between 1 and ");
+ 	    fprintf(fpo,"8 in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "orientations") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: orientations ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    test = fscanf( fp , " %d " , &x ) ;
+ 	    if( test != 1 ) {
+ 		fprintf(fpo,"Failed to input expected orientations\n");
+ 		fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	code = 4 ;
+     } else if( strcmp( input , "pin") == 0 ) {
+ 	if( code != 4 && code != 2 ) {
+ 	    fprintf(fpo,"parser unexpectedly found: pin ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	code = 4 ;
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"parser failed to find keyword: name ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( strcmp( input , "name" ) != 0 ) {
+ 	    fprintf(fpo,"parser failed to find keyword: name ");
+ 	    fprintf(fpo,"in the .cel file; instead found:%s\n", input);
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"parser failed to find pin name ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"parser failed to find keyword: signal ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( strcmp( input , "signal" ) != 0 ) {
+ 	    fprintf(fpo,"parser failed to find keyword: signal ");
+ 	    fprintf(fpo,"in the .cel file; instead found:%s\n", input);
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"parser failed to find signal name ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d %d " , &xpos , &ypos );
+ 	if( test != 2 ) {
+ 	    fprintf(fpo,"Failed to input coordinates for a pin\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"parser failed to find keyword: name ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( strcmp( input , "name" ) != 0 ) {
+ 	    fprintf(fpo,"parser failed to find keyword: name ");
+ 	    fprintf(fpo,"in the .cel file; instead found:%s\n", input);
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"parser failed to find pin name ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d %d " , &xpos , &ypos );
+ 	if( test != 2 ) {
+ 	    fprintf(fpo,"Failed to input coordinates for a pin\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "softcell") == 0 ) {
+ 	test = fscanf( fp , "%d" , &cellnum ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input cell number \n");
+ 	    fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input keyword name \n");
+ 	    fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( strcmp( input , "name" ) != 0 ) {
+ 	    fprintf(fpo,"Failed to input keyword name \n");
+ 	    fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input cell name in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	cell++ ;
+ 	code = 1 ;
+ 	test = fscanf( fp , " %d " , &ncorners ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input corners in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( ncorners < 4 ) {
+ 	    fprintf(fpo,"Failed to input at least 4 corners");
+ 	    fprintf(fpo," in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "corners") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: corners ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    test = fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    if( test != 2 ) {
+ 		fprintf(fpo,"Failed to input corner coordinates\n");
+ 		fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 		exit(0);
+ 	    } else {
+ 		if( corner == 1 ) {
+ 		    minx = x ;
+ 		    miny = y ;
+ 		    maxx = x ;
+ 		    maxy = y ;
+ 		} else {
+ 		    if( x < minx ) {
+ 			minx = x ;
+ 		    }
+ 		    if( x > maxx ) {
+ 			maxx = x ;
+ 		    }
+ 		    if( y < miny ) {
+ 			miny = y ;
+ 		    }
+ 		    if( y > maxy ) {
+ 			maxy = y ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "asplb") == 0 ) {
+ 	    test = fscanf( fp , "%lf" , &asplb ) ;
+ 	    if( test != 1 ) {
+ 		fprintf(fpo,"Failed to input asplb in the .cel file\n");
+ 		fprintf(fpo,"cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	} else {
+ 	    fprintf(fpo,"parser failed to find: asplb ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "aspub") == 0 ) {
+ 	    test = fscanf( fp , "%lf" , &aspub ) ;
+ 	    if( test != 1 ) {
+ 		fprintf(fpo,"Failed to input aspub in the .cel file\n");
+ 		fprintf(fpo,"cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	} else {
+ 	    fprintf(fpo,"parser failed to find: aspub ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "class") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: class ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &class ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input class in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &norients ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input orientations in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( norients < 1 || norients > 8 ) {
+ 	    fprintf(fpo,"Failed to input orientations between 1 and ");
+ 	    fprintf(fpo,"8 in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "orientations") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: orientations ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    test = fscanf( fp , " %d " , &x ) ;
+ 	    if( test != 1 ) {
+ 		fprintf(fpo,"Failed to input expected orientations\n");
+ 		fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	code = 2 ;
+     } else if( strcmp( input , "sequence") == 0 ||
+ 				    strcmp( input , "group") == 0 ) {
+ 	if( code != 2 ) {
+ 	    fprintf(fpo,"parser unexpectedly found: sequence/group ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &sequence ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input a seq/group in .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( i = 1 ; i <= sequence ; i++ ) {
+ 	    fscanf( fp , " %s " , input ) ;
+ 	    if( strcmp( input , "pin") == 0 ) {
+ 		test = fscanf( fp , "%s" , input ) ;
+ 		if( test != 1 ) {
+ 		    fprintf(fpo,"parser did not find keyword: ");
+ 		    fprintf(fpo,"name in the .cel file\n");
+ 		    fprintf(fpo,"cell:%d\n", cell );
+ 		    exit(0);
+ 		}
+ 		if( strcmp( input , "name" ) != 0 ) {
+ 		    fprintf(fpo,"parser failed to find keyword: ");
+ 		    fprintf(fpo,"name in the .cel file:"); 
+ 		    fprintf(fpo," instead found:%s\n", input);
+ 		    fprintf(fpo,"cell:%d\n", cell );
+ 		    exit(0);
+ 		}
+ 		test = fscanf( fp , "%s" , input ) ;
+ 		if( test != 1 ) {
+ 		    fprintf(fpo,"parser failed to find pin name ");
+ 		    fprintf(fpo,"in the .cel file\n");
+ 		    fprintf(fpo,"cell:%d\n", cell );
+ 		    exit(0);
+ 		}
+ 		test = fscanf( fp , "%s" , input ) ;
+ 		if( test != 1 ) {
+ 		    fprintf(fpo,"parser failed to find keyword: ");
+ 		    fprintf(fpo,"signal in the .cel file\n");
+ 		    fprintf(fpo,"cell:%d\n", cell );
+ 		    exit(0);
+ 		}
+ 		if( strcmp( input , "signal" ) != 0 ) {
+ 		    fprintf(fpo,"parser failed to find keyword: ");
+ 		    fprintf(fpo,"signal in the .cel file;\n");
+ 		    fprintf(fpo," instead found:%s\n", input);
+ 		    fprintf(fpo,"cell:%d\n", cell );
+ 		    exit(0);
+ 		}
+ 		test = fscanf( fp , "%s" , input ) ;
+ 		if( test != 1 ) {
+ 		    fprintf(fpo,"parser failed to find signal ");
+ 		    fprintf(fpo,"name in the .cel file\n");
+ 		    fprintf(fpo,"cell:%d\n", cell );
+ 		    exit(0);
+ 		}
+ 	    } else {
+ 		fprintf(fpo,"parser failed to find: pin ");
+ 		fprintf(fpo,"in the .cel file\n");
+ 		fprintf(fpo,"cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "side.restriction") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: side.restriction ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d %d " , &firstside , &lastside ) ;
+ 	if( test != 2 ) {
+ 	    fprintf(fpo,"Failed to input the 2 side.restriction \n");
+ 	    fprintf(fpo,"sides in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "pad") == 0 ) {
+ 	test = fscanf( fp , "%d" , &cellnum ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input pad # in the .cel file\n");
+ 	    fprintf(fpo,"pad:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input keyword name \n");
+ 	    fprintf(fpo," in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( strcmp( input , "name" ) != 0 ) {
+ 	    fprintf(fpo,"Failed to input keyword name \n");
+ 	    fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , "%s" , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input cell name in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	pad++ ;
+ 	code = 3 ;
+ 	test = fscanf( fp , " %d " , &ncorners ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input corners in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( ncorners < 4 ) {
+ 	    fprintf(fpo,"Failed to input at least 4 corners");
+ 	    fprintf(fpo," in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "corners") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: corners ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    test = fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    if( test != 2 ) {
+ 		fprintf(fpo,"Failed to input corner coordinates\n");
+ 		fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 		exit(0);
+ 	    } else {
+ 		if( corner == 1 ) {
+ 		    minx = x ;
+ 		    miny = y ;
+ 		    maxx = x ;
+ 		    maxy = y ;
+ 		} else {
+ 		    if( x < minx ) {
+ 			minx = x ;
+ 		    }
+ 		    if( x > maxx ) {
+ 			maxx = x ;
+ 		    }
+ 		    if( y < miny ) {
+ 			miny = y ;
+ 		    }
+ 		    if( y > maxy ) {
+ 			maxy = y ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "padside") == 0 ) {
+ 	    test = fscanf( fp , " %s " , input ) ;
+ 	    if( test != 1 ) {
+ 		fprintf( fpo, "Failed to input padside ");
+ 		fprintf( fpo, "in the .cel file\n");
+ 		fprintf( fpo, "Current pad: %d\n", pad ) ;
+ 		exit(0);
+ 	    }
+ 	} else {
+ 	    fprintf( fpo, "Failed to find keyword padside ");
+ 	    fprintf( fpo, "for a pad\n") ;
+ 	    fprintf( fpo, "Current pad: %d\n", pad ) ;
+ 	    exit(0) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "class") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: class ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &class ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input class in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &norients ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"Failed to input orientations in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	if( norients < 1 || norients > 8 ) {
+ 	    fprintf(fpo,"Failed to input orientations between 1 and ");
+ 	    fprintf(fpo,"8 in the .cel file; cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "orientations") != 0 ) {
+ 	    fprintf(fpo,"parser failed to find: orientations ");
+ 	    fprintf(fpo,"in the .cel file\n");
+ 	    fprintf(fpo,"cell:%d\n", cell );
+ 	    exit(0);
+ 	}
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    test = fscanf( fp , " %d " , &x ) ;
+ 	    if( test != 1 ) {
+ 		fprintf(fpo,"Failed to input expected orientations\n");
+ 		fprintf(fpo,"in the .cel file; cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	code = 4 ;
+     } else if( strcmp( input , "sidespace") == 0 ) {
+ 	test = fscanf( fp , " %d " , &space ) ;
+     } else {
+ 	fprintf(fpo,"found unparsable keyword ");
+ 	fprintf(fpo," %s " , input ); 
+ 	fprintf(fpo,"in the .cel file\n");
+ 	fprintf(fpo,"cell:%d\n", cell );
+ 	exit(0);
+     }
+ }
+ 
+ numcells = cell ;
+ numpads = pad ;
+ 
+ rewind( fp ) ;
+ 
+ makebins( numcells ) ;
+ 
+ cellarray = (CELLBOXPTR *) malloc( (5 + numcells + numpads) *
+ 					 sizeof( CELLBOXPTR ) ) ;
+ for( cell = 1 ; cell <= numcells + numpads + 4 ; cell++ ) {
+ 
+     ptr = cellarray[ cell ] = ALLOC( CELLBOX ) ;
+ 
+     ptr->xcenter    = 0 ;
+     ptr->ycenter    = 0 ;
+     ptr->orient     = 0 ;
+     ptr->numtiles   = 0 ;
+     ptr->numterms   = 0 ;
+     ptr->numsites   = 0 ;
+     ptr->numgroups  = 0 ;
+     ptr->softflag   = 0 ;
+     ptr->padside    = 0 ;
+     ptr->numUnComTerms = 0 ;
+     ptr->aspect = 1.0 ;
+     ptr->aspUB = 1.0 ;
+     ptr->aspLB = 1.0 ;
+ 
+     for( i = 0 ; i < 8 ; i++ ) {
+ 	ptr->config[ i ] = TILENULL ;
+ 	ptr->orientList[i] = 0 ;
+     }
+ }
+ padspace = (double *) malloc( (numpads + 1) * sizeof(double) ) ;
+ for( i = 1 ; i <= numpads ; i++ ) {
+     padspace[i] = 0.0 ;
+ }
+ fixLRBT  = (int *) malloc( 4 * sizeof( int ) ) ;
+ fixLRBT[0] = 0 ;
+ fixLRBT[1] = 0 ;
+ fixLRBT[2] = 0 ;
+ fixLRBT[3] = 0 ;
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/pass2.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/pass2.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/pass2.c	Tue Oct  5 16:19:47 2004
***************
*** 0 ****
--- 1,267 ----
+ #include "custom.h"
+ int totPins ;
+ BUSTBOXPTR C ;
+ /*
+  *  One of the main purposes of pass2 is to ascertain the number of 
+  *  uncommitted pins per cell
+  */
+ 
+ extern void maketabl(void);
+ extern int addhash( char hname[] );
+ 
+ void pass2( FILE *fp )
+ {
+ 
+ int i , cell , class ;
+ int xpos , ypos ;
+ int k , xx1 , xx2 , yy1 , yy2 ;
+ int sequence , firstside , lastside ;
+ int soft , cellnum , pinctr , term ;
+ int corner , ncorners , x , y , ecount , orient , norients ;
+ double aspub , asplb , space ;
+ char input[1024] ;
+ CELLBOXPTR ptr ;
+ DIMBOXPTR nptr ;
+ 
+ C = ( BUSTBOXPTR ) malloc( 101 * sizeof( BUSTBOX ) ) ;
+ cell = 0 ;
+ ecount = 0 ;
+ netctr = 0 ;
+ pinctr = 0 ;
+ maketabl() ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "cell") == 0 ) {
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	ptr = cellarray[ ++cell ] ;
+ 	soft = 0 ;
+ 	for( k = 0 ; k <= 100 ; k++ ) {
+ 	    C[k].xc = 0 ;
+ 	    C[k].yc = 0 ;
+ 	}
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    C[ ++C[0].xc ].xc = x ;
+ 	    C[ C[0].xc ].yc = y ;
+ 	}
+ 	for( k = 1 ; k <= C[0].xc ; k++ ) {
+ 	    xx1 = C[k].xc ;
+ 	    yy1 = C[k].yc ;
+ 	    if( k == C[0].xc ) {
+ 		xx2 = C[1].xc ;
+ 		yy2 = C[1].yc ;
+ 	    } else {
+ 		xx2 = C[ k + 1 ].xc ;
+ 		yy2 = C[ k + 1 ].yc ;
+ 	    }
+ 	    if( xx1 == xx2 && yy1 == yy2 ) {
+ 		fprintf(fpo,"a zero length side was found for\n");
+ 		fprintf(fpo,"the current cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	    if( xx1 != xx2 && yy1 != yy2 ) {
+ 		fprintf(fpo,"a non rectilinear side was found \n");
+ 		fprintf(fpo,"for the current cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+     } else if( strcmp( input , "pin") == 0 ) {
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	fscanf( fp , " %s " , input ) ; /* "signal"   */
+ 	fscanf( fp , " %s " , input ) ; /* signal name */
+ 	pinctr++ ;
+ 	addhash( input ) ;
+ 	fscanf( fp , " %d %d " , &xpos , &ypos );
+ 	if( soft == 1 && ptr->numUnComTerms != 0 ) {
+ 	    for( k = 1 ; k <= C[0].xc ; k++ ) {
+ 		xx1 = C[k].xc ;
+ 		yy1 = C[k].yc ;
+ 		if( k == C[0].xc ) {
+ 		    xx2 = C[1].xc ;
+ 		    yy2 = C[1].yc ;
+ 		} else {
+ 		    xx2 = C[ k + 1 ].xc ;
+ 		    yy2 = C[ k + 1 ].yc ;
+ 		}
+ 		if( xx1 == xx2 ) {
+ 		    if( xpos == xx1 ) {
+ 			ptr->numUnComTerms++ ;
+ 			break ;
+ 		    }
+ 		} else if( ypos == yy1 ) {
+ 		    ptr->numUnComTerms++ ;
+ 		    break ;
+ 		}
+ 	    }
+ 	}
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 	if( soft == 1 ) {
+ 	    fprintf(fpo,"equiv pin cannot reside on soft cell\n");
+ 	    fprintf(fpo,"problematic cell: %d\n", cell );
+ 	    exit(0);
+ 	}
+ 	ecount++ ;
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	fscanf( fp , " %d %d " , &xpos , &ypos );
+     } else if( strcmp( input , "softcell") == 0 ) {
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	ptr = cellarray[ ++cell ] ;
+ 	soft = 1 ;
+ 	for( k = 0 ; k <= 100 ; k++ ) {
+ 	    C[k].xc = 0 ;
+ 	    C[k].yc = 0 ;
+ 	}
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    C[ ++C[0].xc ].xc = x ;
+ 	    C[ C[0].xc ].yc = y ;
+ 	}
+ 	for( k = 1 ; k <= C[0].xc ; k++ ) {
+ 	    xx1 = C[k].xc ;
+ 	    yy1 = C[k].yc ;
+ 	    if( k == C[0].xc ) {
+ 		xx2 = C[1].xc ;
+ 		yy2 = C[1].yc ;
+ 	    } else {
+ 		xx2 = C[ k + 1 ].xc ;
+ 		yy2 = C[ k + 1 ].yc ;
+ 	    }
+ 	    if( xx1 == xx2 && yy1 == yy2 ) {
+ 		fprintf(fpo,"a zero length side was found for\n");
+ 		fprintf(fpo,"the current cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	    if( xx1 != xx2 && yy1 != yy2 ) {
+ 		fprintf(fpo,"a non rectilinear side found \n");
+ 		fprintf(fpo,"for the current cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , "%lf" , &asplb ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , "%lf" , &aspub ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+     } else if( strcmp( input , "sequence") == 0 ||
+ 				    strcmp( input , "group") == 0 ) {
+ 	fscanf( fp , " %d " , &sequence ) ;
+ 	ptr->numUnComTerms += sequence ;
+ 	for( i = 1 ; i <= sequence ; i++ ) {
+ 	    fscanf( fp , " %s " , input ) ; /* "pin"    */
+ 	    fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	    fscanf( fp , " %s " , input ) ; /* pin name */
+ 	    fscanf( fp , " %s " , input ) ; /* "signal"   */
+ 	    fscanf( fp , " %s " , input ) ; /* signal name */
+ 	    pinctr++ ;
+ 	    addhash( input ) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d %d " , &firstside , &lastside ) ;
+     } else if( strcmp( input , "pad") == 0 ) {
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	ptr = cellarray[ ++cell ] ;
+ 	soft = 0 ;
+ 	for( k = 0 ; k <= 100 ; k++ ) {
+ 	    C[k].xc = 0 ;
+ 	    C[k].yc = 0 ;
+ 	}
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    C[ ++C[0].xc ].xc = x ;
+ 	    C[ C[0].xc ].yc = y ;
+ 	}
+ 	for( k = 1 ; k <= C[0].xc ; k++ ) {
+ 	    xx1 = C[k].xc ;
+ 	    yy1 = C[k].yc ;
+ 	    if( k == C[0].xc ) {
+ 		xx2 = C[1].xc ;
+ 		yy2 = C[1].yc ;
+ 	    } else {
+ 		xx2 = C[ k + 1 ].xc ;
+ 		yy2 = C[ k + 1 ].yc ;
+ 	    }
+ 	    if( xx1 == xx2 && yy1 == yy2 ) {
+ 		fprintf(fpo,"a zero length side was found for\n");
+ 		fprintf(fpo,"the current cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	    if( xx1 != xx2 && yy1 != yy2 ) {
+ 		fprintf(fpo,"a non rectilinear side found \n");
+ 		fprintf(fpo,"for the current cell:%d\n", cell );
+ 		exit(0);
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &x ) ;
+ 	}
+     } else if( strcmp( input , "sidespace") == 0 ) {
+ 	fscanf( fp , " %lf " , &space ) ;
+     }
+ }
+ rewind( fp ) ;
+ 
+ termarray = (TERMNETSPTR *) malloc( (pinctr + 1) * 
+ 				    sizeof( TERMNETSPTR ) );
+ for( term = 1 ; term <= pinctr ; term++ ) {
+     termarray[ term ] = TERMNETSNULL ;
+ }
+ maxterm = pinctr ;
+ 
+ pinnames = (char **) malloc( (pinctr + 1) * sizeof( char * ) ) ;
+ 
+ numnets = netctr ;
+ netarray = (DIMBOXPTR *) malloc( (netctr + 1) * sizeof(DIMBOXPTR));
+ for( i = 1 ; i <= netctr ; i++ ) {
+     nptr = netarray[ i ] = (DIMBOXPTR) malloc( sizeof( DIMBOX ) ) ;
+     nptr->netptr  = NETNULL ;
+     nptr->nname   = NULL    ;
+     nptr->skip    = 0       ;
+     nptr->flag    = 0       ;
+     nptr->xmin    = 0       ;
+     nptr->newxmin = 0       ;
+     nptr->xmax    = 0       ;
+     nptr->newxmax = 0       ;
+     nptr->ymin    = 0       ;
+     nptr->newymin = 0       ;
+     nptr->ymax    = 0       ;
+     nptr->newymax = 0       ;
+ }
+ 
+ totPins = ecount + maxterm ;
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/perimeter.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/perimeter.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/perimeter.c	Tue Oct  5 16:19:47 2004
***************
*** 0 ****
--- 1,17 ----
+ #include "custom.h"
+ extern BUSTBOXPTR A ;
+ 
+ int perimeter(void)
+ {
+ int i , sum ;
+ 
+ sum = 0 ;
+ for( i = 1 ; i <= A[0].xc ; i++ ) {
+     if( i == A[0].xc ) {
+ 	sum += ABS(A[1].xc - A[i].xc) + ABS(A[1].yc - A[i].yc) ;
+     } else {
+ 	sum += ABS(A[i + 1].xc - A[i].xc) + ABS(A[i + 1].yc - A[i].yc) ;
+     }
+ }
+ return( sum ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/placepads.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/placepads.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/placepads.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,343 ----
+ #include "custom.h"
+ #define L 1
+ #define T 2
+ #define R 3
+ #define B 4
+ extern double *padspace ;
+ extern int *fixLRBT ;
+ 
+ void placepads(void)
+ {
+ 
+ int coreHeight , coreWidth , zxshift , zyshift , pad , count ;
+ int height , width , maxHeight , maxWidth , space , separation ;
+ int extraSpace , last , xshift ;
+ 
+ coreHeight = blockt ;
+ coreWidth  = blockr ;
+ blockb  = 0 ;
+ blockl  = 0 ;
+ zxshift = 0 ;
+ zyshift = 0 ;
+ xshift  = 0 ;
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == B ) {
+ 	count = 1 ;
+ 	height = cellarray[pad]->config[0]->top -
+ 				 cellarray[pad]->config[0]->bottom ;
+ 	width = cellarray[pad]->config[0]->right -
+ 				 cellarray[pad]->config[0]->left ;
+ 	for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 	    if( cellarray[pad]->padside != B ) {
+ 		break ;
+ 	    }
+ 	    count++ ;
+ 	    if( cellarray[pad]->config[0]->top -
+ 			cellarray[pad]->config[0]->bottom > height ) {
+ 		height = cellarray[pad]->config[0]->top
+ 				   - cellarray[pad]->config[0]->bottom ;
+ 	    }
+ 	    width += cellarray[pad]->config[0]->right -
+ 				      cellarray[pad]->config[0]->left ;
+ 	}
+ 	maxHeight = height ;
+ 	if( fixLRBT[2] == 0 ) {
+ 	    space = coreWidth - width ;
+ 	    separation = space / (count + 1) ;
+ 	    if( separation < 0 ) {
+ 		separation = 0 ;
+ 	    }
+ 	} else {
+ 	    space = ( coreWidth >= width ) ? coreWidth : width ;
+ 	}
+ 	if( width > coreWidth ) {
+ 	    zxshift = (width - coreWidth) / 2 ;
+ 	    coreWidth = width ;
+ 	}
+ 	extraSpace = 0.1 * (blockt - blockb) ;
+ 	blockb += maxHeight + extraSpace ;
+ 	blockt += maxHeight + extraSpace ;
+ 
+ 	for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 	    if( cellarray[pad]->padside == B ) {
+ 		height = cellarray[pad]->config[0]->top -
+ 				     cellarray[pad]->config[0]->bottom ;
+ 		width =  cellarray[pad]->config[0]->right -
+ 				     cellarray[pad]->config[0]->left ;
+ 		if( fixLRBT[2] == 0 ) {
+ 		    cellarray[pad]->xcenter = separation + width / 2 ;
+ 		} else {
+ 		    cellarray[pad]->xcenter = padspace[pad - numcells]
+ 							    * space ;
+ 		}
+ 		cellarray[pad]->ycenter = maxHeight - ( height - 
+ 							height / 2 ) ;
+ 		last = separation + width ;
+ 
+ 		for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 		    if( cellarray[pad]->padside != B ) {
+ 			break ;
+ 		    }
+ 		    height = cellarray[pad]->config[0]->top -
+ 			     cellarray[pad]->config[0]->bottom ;
+ 		    width =  cellarray[pad]->config[0]->right -
+ 			     cellarray[pad]->config[0]->left ;
+ 		    if( fixLRBT[2] == 0 ) {
+ 			cellarray[pad]->xcenter = last + separation + 
+ 						    width / 2 ;
+ 		    } else {
+ 			cellarray[pad]->xcenter = 
+ 				    padspace[ pad - numcells ] * space ;
+ 		    }
+ 		    cellarray[pad]->ycenter = maxHeight - ( height - 
+ 							height / 2 ) ;
+ 		    last += separation + width ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ 
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == T ) {
+ 	count = 1 ;
+ 	width = cellarray[pad]->config[0]->right -
+ 				      cellarray[pad]->config[0]->left ;
+ 	for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 	    if( cellarray[pad]->padside != T ) {
+ 		break ;
+ 	    }
+ 	    count++ ;
+ 	    width += cellarray[pad]->config[0]->right -
+ 				      cellarray[pad]->config[0]->left ;
+ 	}
+ 	if( fixLRBT[3] == 0 ) {
+ 	    space = coreWidth - width ;
+ 	    separation = space / (count + 1) ;
+ 	    if( separation < 0 ) {
+ 		separation = 0 ;
+ 	    }
+ 	} else {
+ 	    space = (coreWidth >= width ) ? coreWidth : width ;
+ 	}
+ 	if( width > coreWidth ) {
+ 	    zxshift += (width - coreWidth) / 2 ;
+ 	}
+ 
+ 	for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 	    if( cellarray[pad]->padside == T ) {
+ 		height = cellarray[pad]->config[0]->top -
+ 			 cellarray[pad]->config[0]->bottom ;
+ 		width =  cellarray[pad]->config[0]->right -
+ 			 cellarray[pad]->config[0]->left ;
+ 		if( fixLRBT[3] == 0 ) {
+ 		    cellarray[pad]->xcenter = separation + width / 2 ;
+ 		} else {
+ 		    cellarray[pad]->xcenter = padspace[pad - numcells]
+ 							      * space ;
+ 		}
+ 		cellarray[pad]->ycenter = blockt + 0.1 * 
+ 					(blockt - blockb) + height / 2 ;
+ 		last = separation + width ;
+ 
+ 		for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 		    if( cellarray[pad]->padside != T ) {
+ 			break ;
+ 		    }
+ 		    height = cellarray[pad]->config[0]->top -
+ 			     cellarray[pad]->config[0]->bottom ;
+ 		    width =  cellarray[pad]->config[0]->right -
+ 			     cellarray[pad]->config[0]->left ;
+ 		    if( fixLRBT[3] == 0 ) {
+ 			cellarray[pad]->xcenter = last + separation + 
+ 							    width / 2 ;
+ 		    } else {
+ 			cellarray[pad]->xcenter = 
+ 				    padspace[ pad - numcells ] * space ;
+ 		    }
+ 		    cellarray[pad]->ycenter = blockt + 0.1 * 
+ 					(blockt - blockb) + height / 2 ;
+ 		    last += separation + width ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ 
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == L ) {
+ 	count = 1 ;
+ 	height = cellarray[pad]->config[0]->top -
+ 				     cellarray[pad]->config[0]->bottom ;
+ 	width = cellarray[pad]->config[0]->right -
+ 				      cellarray[pad]->config[0]->left ;
+ 	for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 	    if( cellarray[pad]->padside != L ) {
+ 		break ;
+ 	    }
+ 	    count++ ;
+ 	    if( cellarray[pad]->config[0]->right -
+ 			    cellarray[pad]->config[0]->left > width ) {
+ 		width = cellarray[pad]->config[0]->right -
+ 				     cellarray[pad]->config[0]->left ;
+ 	    }
+ 	    height += cellarray[pad]->config[0]->top -
+ 				  cellarray[pad]->config[0]->bottom ;
+ 	}
+ 	maxWidth = width ;
+ 	if( fixLRBT[0] == 0 ) {
+ 	    space = coreHeight - height ;
+ 	    separation = space / (count + 1) ;
+ 	    if( separation < 0 ) {
+ 		separation = 0 ;
+ 	    }
+ 	} else {
+ 	    space = (coreHeight >= height ) ? coreHeight : height ;
+ 	}
+ 	if( height > coreHeight ) {
+ 	    zyshift = (height - coreHeight) / 2 ;
+ 	    coreHeight = height ;
+ 	}
+ 	extraSpace = 0.1 * (blockr - blockl) ;
+ 	blockr += maxWidth + extraSpace ;
+ 	blockl += maxWidth + extraSpace ;
+ 	xshift =  maxWidth + extraSpace ;
+ 
+ 	for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 	    if( cellarray[pad]->padside == L ) {
+ 		height = cellarray[pad]->config[0]->top -
+ 				 cellarray[pad]->config[0]->bottom ;
+ 		width =  cellarray[pad]->config[0]->right -
+ 				 cellarray[pad]->config[0]->left ;
+ 		if( fixLRBT[0] == 0 ) {
+ 		    cellarray[pad]->ycenter = blockb + separation + 
+ 							height / 2 ;
+ 		} else {
+ 		    cellarray[pad]->ycenter = blockb +
+ 				padspace[ pad - numcells ] * space ;
+ 		}
+ 		cellarray[pad]->xcenter = maxWidth - 
+ 						(width - width / 2) ;
+ 		last = blockb + separation + height ;
+ 
+ 		for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 		    if( cellarray[pad]->padside != L ) {
+ 			break ;
+ 		    }
+ 		    height = cellarray[pad]->config[0]->top -
+ 				     cellarray[pad]->config[0]->bottom ;
+ 		    width =  cellarray[pad]->config[0]->right -
+ 				     cellarray[pad]->config[0]->left ;
+ 		    if( fixLRBT[0] == 0 ) {
+ 			cellarray[pad]->ycenter = last + separation + 
+ 							height / 2 ;
+ 		    } else {
+ 			cellarray[pad]->ycenter = blockb +
+ 				    padspace[ pad - numcells ] * space ;
+ 		    }
+ 		    cellarray[pad]->xcenter = maxWidth - (width -
+ 							    width / 2) ;
+ 		    last += separation + height ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ 
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == R ) {
+ 	count = 1 ;
+ 	height = cellarray[pad]->config[0]->top -
+ 				 cellarray[pad]->config[0]->bottom ;
+ 
+ 	for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 	    if( cellarray[pad]->padside != R ) {
+ 		break ;
+ 	    }
+ 	    count++ ;
+ 	    height += cellarray[pad]->config[0]->top -
+ 				      cellarray[pad]->config[0]->bottom;
+ 	}
+ 	if( fixLRBT[1] == 0 ) {
+ 	    space = coreHeight - height ;
+ 	    separation = space / (count + 1) ;
+ 	    if( separation < 0 ) {
+ 		separation = 0 ;
+ 	    }
+ 	} else {
+ 	    space = (coreHeight >= height) ? coreHeight : height ;
+ 	}
+ 	if( height > coreHeight ) {
+ 	    zyshift += (height - coreHeight) / 2 ;
+ 	}
+ 
+ 	for( pad = numcells + 1; pad <= numcells + numpads; pad++){
+ 	    if( cellarray[pad]->padside == R ) {
+ 		height = cellarray[pad]->config[0]->top -
+ 				     cellarray[pad]->config[0]->bottom ;
+ 		width =  cellarray[pad]->config[0]->right -
+ 				     cellarray[pad]->config[0]->left ;
+ 		if( fixLRBT[1] == 0 ) {
+ 		    cellarray[pad]->ycenter = blockb + separation + 
+ 							    height / 2 ;
+ 		} else {
+ 		    cellarray[pad]->ycenter = blockb +
+ 				    padspace[ pad - numcells ] * space ;
+ 		}
+ 		cellarray[pad]->xcenter = blockr + 
+ 				0.1 * (blockr - blockl) + width / 2 ;
+ 		last = blockb + separation + height ;
+ 
+ 		for( pad++ ; pad <= numcells + numpads ; pad++ ) {
+ 		    if( cellarray[pad]->padside != R ) {
+ 			break ;
+ 		    }
+ 		    height = cellarray[pad]->config[0]->top -
+ 				     cellarray[pad]->config[0]->bottom ;
+ 		    width =  cellarray[pad]->config[0]->right -
+ 				     cellarray[pad]->config[0]->left ;
+ 		    if( fixLRBT[1] == 0 ) {
+ 			cellarray[pad]->ycenter = last + separation + 
+ 						    height / 2 ;
+ 		    } else {
+ 			cellarray[pad]->ycenter = blockb +
+ 				    padspace[pad - numcells] * space ;
+ 		    }
+ 		    cellarray[pad]->xcenter = blockr + 
+ 				0.1 * (blockr - blockl) + width / 2 ;
+ 		    last += separation + height ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ 
+ /*
+  *    Center the Core
+  */
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == T || cellarray[pad]->padside == B ){
+ 	cellarray[pad]->xcenter += xshift ;
+     }
+ }
+ 
+ /*
+  *    Center the Core  ( due to pad limitation ) 
+  */
+ blockl += zxshift ;
+ blockr += zxshift ;
+ blockb += zyshift ;
+ blockt += zyshift ;
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == R ) {
+ 	cellarray[pad]->xcenter += 2 * zxshift ;
+     }
+ }
+ for( pad = numcells + 1 ; pad <= numcells + numpads ; pad++ ) {
+     if( cellarray[pad]->padside == T ) {
+ 	cellarray[pad]->ycenter += 2 * zyshift ;
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/placepin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/placepin.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/placepin.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,168 ----
+ #include "custom.h"
+ 
+ void placepin(void)
+ {
+ int i , j , cell ;
+ int k , firstsite , lastsite , numsites ;
+ int sum , truth , amount , l , m , n ;
+ int side , site ;
+ CELLBOXPTR ptr ;
+ CONTENTBOX *SCptr ;
+ UNCOMBOX *UCptr ;
+ 
+  /*  
+      We have yet to find an initial placement for the soft cell
+      terminals.  Scan through all the cells and check for
+      softflag == 1.  Then those with firstSite == lastSite
+      must be placed in that site.  Find a placement for all
+      other terminals.
+  */
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     ptr = cellarray[ cell ] ;
+     if( ptr->softflag == 0 || ptr->numsites == 0 ) {
+ 	continue ;
+     }
+     UCptr = ptr->unComTerms ;
+     SCptr = ptr->siteContent ;
+ 
+     for( i = 1 ; i <= ptr->numUnComTerms ; i++ ) {
+ 	if( UCptr[i].sequence != 0 ) {
+ 	    if( UCptr[i].numranges == 1 ) {
+ 		sum = 0 ;
+ 		n = ptr->sideArray[ UCptr[i].range1 ].firstSite ; 
+ 		for(; n <= ptr->sideArray[ UCptr[i].range1 ].lastSite ; 
+ 				 				n++ ) {
+ 		    sum += SCptr[n].capacity ;
+ 		}
+ 		if( sum < UCptr[i].sequence ) {
+ 		    fprintf(fpo,"DEATH: Sequence was specified which");
+ 		    fprintf(fpo," required more capacity than given\n");
+ 		    fprintf(fpo,"sides could hanlde. Problem cell:%d\n",
+ 								cell ) ;
+ 		    exit(0) ;
+ 		}
+ 	    } else if( UCptr[i].numranges == 2 ) {
+ 		sum = 0 ;
+ 		n = ptr->sideArray[ UCptr[i].range1 ].firstSite ; 
+ 		for(; n <= ptr->sideArray[ UCptr[i].range1 ].lastSite ; 
+ 				 				n++ ) {
+ 		    sum += SCptr[n].capacity ;
+ 		}
+ 		if( sum < UCptr[i].sequence ) {
+ 		    fprintf(fpo,"DEATH: Sequence was specified which");
+ 		    fprintf(fpo," required more capacity than given\n");
+ 		    fprintf(fpo,"sides could hanlde. Problem cell:%d\n",
+ 								cell ) ;
+ 		    exit(0) ;
+ 		}
+ 		sum = 0 ;
+ 		n = ptr->sideArray[ UCptr[i].range2 ].firstSite ; 
+ 		for(; n <= ptr->sideArray[ UCptr[i].range2 ].lastSite ; 
+ 				 				n++ ) {
+ 		    sum += SCptr[n].capacity ;
+ 		}
+ 		if( sum < UCptr[i].sequence ) {
+ 		    fprintf(fpo,"DEATH: Sequence was specified which");
+ 		    fprintf(fpo," required more capacity than given\n");
+ 		    fprintf(fpo,"sides could hanlde. Problem cell:%d\n",
+ 								cell ) ;
+ 		    exit(0) ;
+ 		}
+ 	    } else if( UCptr[i].numranges > 2 ) {
+ 		sum = 0 ;
+ 		n = 1 ;
+ 		for(; n <= ptr->sideArray[ptr->numsides].lastSite; n++){
+ 		    sum += SCptr[n].capacity ;
+ 		}
+ 		if( sum < UCptr[i].sequence ) {
+ 		    fprintf(fpo,"DEATH: Sequence was specified which");
+ 		    fprintf(fpo," required more capacity than given\n");
+ 		    fprintf(fpo,"sides could hanlde. Problem cell:%d\n",
+ 								cell ) ;
+ 		    exit(0) ;
+ 		}
+ 	    }
+ 	    /*
+ 	     *  Strategy:  Randomly select a legal side for the
+ 	     *  sequence.  Then randomly pick a starting site on
+ 	     *  this side such that the sequence fits on the side
+ 	     */
+ 	    if( UCptr[i].numranges > 2 ) {
+ 		do {
+ 		    side = (int)( (double) UCptr[i].numranges *
+ 			( (double) RAND / (double)0x7fffffff) ) + 1 ;
+ 		} while( side == UCptr[i].numranges + 1 ) ;
+ 	    } else if( UCptr[i].numranges == 2 ) {
+ 		do {
+ 		    side = (int)( (double) UCptr[i].numranges *
+ 			( (double) RAND / (double)0x7fffffff) ) + 1 ;
+ 		} while( side == UCptr[i].numranges + 1 ) ;
+ 		if( side == 1 ) {
+ 		    side = UCptr[i].range1 ;
+ 		} else {
+ 		    side = UCptr[i].range2 ;
+ 		}
+ 	    } else if( UCptr[i].numranges == 1 ) {
+ 		side = UCptr[i].range1 ;
+ 	    }
+ 	    if( UCptr[i].numranges == 0 ) {
+ 		firstsite = UCptr[i].range1 ;
+ 		lastsite  = firstsite       ;
+ 		numsites  = 1               ;
+ 	    } else {
+ 		firstsite = ptr->sideArray[side].firstSite ;
+ 		lastsite  = ptr->sideArray[side].lastSite  ;
+ 		numsites  = lastsite - firstsite + 1       ;
+ 	    }
+ 
+ 	    do {
+ 		j = (int)( (double)numsites *
+ 			    ( (double)RAND / (double)0x7fffffff) ) ;
+ 		sum = 0 ;
+ 		truth = 1 ;
+ 		for( k = firstsite + j ; ; k++ ) {
+ 		    if( k > lastsite ) {
+ 			truth = 0 ;
+ 			break ;
+ 		    } else {
+ 			sum += SCptr[k].capacity ;
+ 			if( sum >= UCptr[i].sequence ) {
+ 			    break ;
+ 			    /* 
+ 			       We found it. 
+ 			       The sequence can be housed in
+ 			       sites (firstsite + j) thru (k)
+ 			    */
+ 			}
+ 		    }
+ 		}
+ 	    } while( !truth ) ; 
+ 
+ 	    /* The sites below are going to be filled to capacity by
+ 	       the sequence beginning with i  */
+ 	    sum = 0 ;
+ 	    l   = i ;
+ 	    for( site = firstsite + j ; site < k ; site++ ) {
+ 		amount = SCptr[site].capacity ;
+ 		sum += amount ;
+ 		SCptr[site].contents += amount ;
+ 		for( m = l ; m < l + amount ; m++ ) {
+ 		    UCptr[m].site = site ;
+ 		}
+ 		l += amount ;
+ 	    }
+ 	    /*  Now we have to add to the contents of site k
+ 		which was partially filled by the sequence
+ 		beginning with i  */
+ 	    amount = UCptr[i].sequence - sum ;
+ 	    SCptr[k].contents += amount ;
+ 	    for( m = l ; m < l + amount ; m++ ) {
+ 		UCptr[m].site = k ;
+ 	    }
+ 	}
+     }
+ }
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/port.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/port.h:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/port.h	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,210 ----
+ #ifndef PORT_H
+ #define PORT_H
+ 
+ /*
+  * int32 should be defined as the most economical sized integer capable of
+  * holding a 32 bit quantity
+  * int16 should be similarly defined
+  */
+ 
+ /* XXX hack */
+ #ifndef MACHDEP_INCLUDED
+ #define MACHDEP_INCLUDED
+ #ifdef vax
+ typedef int int32;
+ typedef short int16;
+ #else
+      /* Ansi-C promises that these definitions should always work */
+ typedef long int32;
+ typedef int int16;
+ #endif /* vax */
+ #endif /* MACHDEP_INCLUDED */
+ 
+ 
+ #ifndef __STDC__
+ #ifndef __DATE__
+ #ifdef CUR_DATE
+ #define __DATE__	CUR_DATE
+ #else
+ #define __DATE__	"unknown-date"
+ #endif /* CUR_DATE */
+ #endif /* __DATE__ */
+ 
+ #ifndef __TIME__
+ #ifdef CUR_TIME
+ #define __TIME__	CUR_TIME
+ #else
+ #define __TIME__	"unknown-time"
+ #endif /* CUR_TIME */
+ #endif /* __TIME__ */
+ #endif /* __STDC__ */
+ 
+ #ifdef sun386
+ #define PORTAR
+ #endif
+ 
+ #include <stdio.h>
+ #include <ctype.h>
+ #include <sys/types.h>
+ #undef HUGE
+ #include <math.h>
+ #include <signal.h>
+ 
+ #if defined(ultrix) && defined(SIGLOST)
+ #define ultrix3
+ #else
+ #define ultrix2
+ #endif
+ 
+ #if defined(ultrix3) && defined(mips)
+ extern double rint();
+ extern double trunc();
+ #endif
+ 
+ #if defined(sun) && defined(FD_SETSIZE)
+ #define sunos4
+ #else
+ #define sunos3
+ #endif
+ 
+ #if defined(sequent) || defined(news800)
+ #define LACK_SYS5
+ #endif
+ 
+ #if defined(ultrix3) || defined(sunos4)
+ #define SIGNAL_FN	void
+ #else
+ /* sequent, ultrix2, 4.3BSD (vax, hp), sunos3 */
+ #define SIGNAL_FN	int
+ #endif
+ 
+ /* Some systems have 'fixed' certain functions which used to be int */
+ #if defined(ultrix) || defined(SABER) || defined(hpux) || defined(aiws) || defined(apollo) || defined(__STDC__)
+ #define VOID_HACK void
+ #else
+ #define VOID_HACK int
+ #endif
+ 
+ #ifndef NULL
+ #define NULL 0
+ #endif /* NULL */
+ 
+ /*
+  * CHARBITS should be defined only if the compiler lacks "unsigned char".
+  * It should be a mask, e.g. 0377 for an 8-bit machine.
+  */
+ 
+ #ifndef CHARBITS
+ #	define	UNSCHAR(c)	((unsigned char)(c))
+ #else
+ #	define	UNSCHAR(c)	((c)&CHARBITS)
+ #endif
+ 
+ #define SIZET int
+ 
+ #ifdef __STDC__
+ #define CONST const
+ #define VOIDSTAR   void *
+ #else
+ #define CONST
+ #define VOIDSTAR   char *
+ #endif /* __STDC__ */
+ 
+ 
+ /* Some machines fail to define some functions in stdio.h */
+ #ifndef __STDC__
+ extern FILE *popen(), *tmpfile();
+ extern int pclose();
+ #ifndef clearerr		/* is a macro on many machines, but not all */
+ extern VOID_HACK clearerr();
+ #endif /* clearerr */
+ #ifndef rewind
+ extern VOID_HACK rewind();
+ #endif /* rewind */
+ #endif /* __STDC__ */
+ 
+ 
+ /* most machines don't give us a header file for these */
+ #ifdef __STDC__
+ #include <stdlib.h>
+ #else
+ #ifdef hpux
+ extern int abort();
+ extern void free(), exit(), perror();
+ #else
+ extern VOID_HACK abort(), free(), exit(), perror();
+ #endif /* hpux */
+ extern char *getenv(), *malloc(), *realloc(), *calloc();
+ #ifdef aiws
+ extern int sprintf();
+ #else
+ extern char *sprintf();
+ #endif
+ extern int system();
+ extern double atof();
+ extern long atol();
+ extern int sscanf();
+ #endif /* __STDC__ */
+ 
+ 
+ /* some call it strings.h, some call it string.h; others, also have memory.h */
+ #ifdef __STDC__
+ #include <string.h>
+ #else
+ /* ANSI C string.h -- 1/11/88 Draft Standard */
+ extern char *strcpy(), *strncpy(), *strcat(), *strncat(), *strerror();
+ extern char *strpbrk(), *strtok(), *strchr(), *strrchr(), *strstr();
+ extern int strcoll(), strxfrm(), strncmp(), strlen(), strspn(), strcspn();
+ extern char *memmove(), *memccpy(), *memchr(), *memcpy(), *memset();
+ extern int memcmp(), strcmp();
+ #endif /* __STDC__ */
+ 
+ #ifdef lint
+ #undef putc			/* correct lint '_flsbuf' bug */
+ #endif /* lint */
+ 
+ /* a few extras */
+ extern VOID_HACK srandom();
+ extern long random();
+ 
+ #if defined(ultrix3)
+ extern unsigned sleep();
+ #else
+ extern VOID_HACK sleep();
+ #endif
+ 
+ /* assertion macro */
+ 
+ #ifndef assert
+ #ifdef __STDC__
+ #include <assert.h>
+ #else
+ #ifndef NDEBUG
+ #define assert(ex) {\
+     if (! (ex)) {\
+ 	(void) fprintf(stderr, "Assertion failed: file %s, line %d\n",\
+ 	    __FILE__, __LINE__);\
+ 	(void) fflush(stdout);\
+ 	abort();\
+     }\
+ }
+ #else
+ #define assert(ex) {;}
+ #endif
+ #endif
+ #endif
+ 
+ /* handle the various limits */
+ #if defined(__STDC__) || defined(POSIX)
+ #include <limits.h>
+ #else
+ #define USHRT_MAX	(~ (unsigned short int) 0)
+ #define UINT_MAX	(~ (unsigned int) 0)
+ #define ULONG_MAX	(~ (unsigned long int) 0)
+ #define SHRT_MAX	((short int) (USHRT_MAX >> 1))
+ #define INT_MAX		((int) (UINT_MAX >> 1))
+ #define LONG_MAX	((long int) (ULONG_MAX >> 1))
+ #endif
+ 
+ #endif /* PORT_H */
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prboard.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prboard.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prboard.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,72 ----
+ #include "custom.h"
+ 
+ void prboard(void)
+ {
+ 
+ int xcenter , ycenter ;
+ int j , cell , site , terminal , xpos , ypos ;
+ CELLBOXPTR cellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr ;
+ FILE *fp , *fopen() ;
+ char filename[1024] ;
+ 
+ sprintf( filename, "%s.brd" , cktName ) ;
+ if( (fp = fopen ( filename , "w")) == (FILE *) NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit(0);
+ }
+ 
+ for( cell = 1 ; cell <= numcells + numpads ; cell++ ) {
+     cellptr = cellarray[ cell ] ;
+     tileptr = cellptr->config[ cellptr->orient ] ;
+     termptr = tileptr->termptr ;
+ 
+     xcenter = cellptr->xcenter ;
+     ycenter = cellptr->ycenter ;
+     
+     fprintf(fp,"\n\n\n\nBOUNDING BOX OF CELL:%6d  is ", cell );
+     fprintf(fp,"LEFT:%6d  BOTTOM:%6d  RIGHT:%6d  TOP:%6d\n",
+ 	tileptr->left  + xcenter , tileptr->bottom + ycenter ,
+ 	tileptr->right + xcenter , tileptr->top + ycenter ) ;
+ 
+     fprintf(fp,"\nTHESE ARE THE TILES COMPRISING THIS CELL\n");
+ 
+     for( tileptr = tileptr->nexttile ; tileptr != TILENULL ;
+ 				tileptr = tileptr->nexttile ) {
+ 	fprintf(fp,"LEFT:%6d  BOTTOM:%6d" , 
+ 	   tileptr->left  + xcenter,tileptr->bottom + ycenter);
+ 	fprintf(fp,"  RIGHT:%6d  TOP:%6d\n\n" , 
+ 	   tileptr->right + xcenter, tileptr->top + ycenter );
+     }
+ 
+     fprintf(fp,"THESE ARE THE TERMINALS FOR THIS CELL\n");
+ 
+     for( ; termptr != TERMNULL ; termptr = termptr->nextterm ){
+ 
+ 	fprintf(fp,"TERMINAL:%s   XPOS:%6d   YPOS:%6d\n\n" ,
+ 				pinnames[termptr->terminal] , 
+ 				termptr->xpos + xcenter , 
+ 				termptr->ypos + ycenter ) ;
+     }
+     if( cellptr->softflag == 1 ) {
+ 	for( j = 1 ; j <= cellptr->numUnComTerms ; j++ ) {
+ 	    terminal = cellptr->unComTerms[ j ].terminal ;
+ 	    site = cellptr-> unComTerms[ j ].site ;
+ 	    xpos = cellptr->config[ cellptr->orient ]->
+ 				siteLocArray[ site ].xpos ;
+ 	    ypos = cellptr->config[ cellptr->orient ]->
+ 				siteLocArray[ site ].ypos ;
+ 	    fprintf(fp,"TERMINAL:%s   XPOS:%6d   YPOS:%6d\n" ,
+ 			pinnames[terminal] , xpos + xcenter , 
+ 					   ypos + ycenter ) ;
+ 	    fprintf(fp,"ACTUALS           XPOS:%6d   YPOS:%6d\n\n",
+ 		 cellptr->unComTerms[ j ].finalx + xcenter , 
+ 		 cellptr->unComTerms[ j ].finaly + ycenter ) ;
+ 	    fprintf(fp,"   SITE:%6d\n\n", site ) ;
+ 	}
+     }
+ }
+ fclose( fp ) ;
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prepair.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prepair.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prepair.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,28 ----
+ #include "route.h"
+ 
+ void prepair( int numpnodes )
+ {
+ 
+ int i , j ;
+ LIST2PTR lptr , l2ptr ;
+ 
+ for( i = 1 ; i <= numpnodes ; i++ ) {
+     pnodeArray[i].eptr = 0 ;
+     for( j = 1 ; j <= numnodes + numpnodes ; j++ ) {
+ 	pnodeArray[i].nodeList[j].temp = 0 ;
+ 	pnodeArray[i].nodeList[j].distance = 0 ;
+ 	pnodeArray[i].nodeList[j].from = 0 ;
+ 	pnodeArray[i].nodeList[j].from2 = 0 ;
+     }
+     if( (lptr = pnodeArray[i].equiv) != (LIST2PTR) NULL ) {
+ 	do {
+ 	    l2ptr = lptr->next ;
+ 	    free( lptr ) ;
+ 	    lptr = l2ptr ;
+ 	} while( lptr != (LIST2PTR) NULL ) ;
+ 	pnodeArray[i].equiv = (LIST2PTR) NULL ;
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prestrict.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prestrict.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/prestrict.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,81 ----
+ #include "route.h"
+ #include "23tree.h"
+ extern int pnodeAlength ;
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+                   int *property);
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ 
+ int prestrict( short int *ptr, int p , int source , int target )
+ {
+ 
+ TNODEPTR rootx , dumnode ;
+ NNODEPTR nptr ;
+ GNODEPTR gptr , gptr1 ;
+ int i , j , snode , node , D , nextnode , distance , node1 , node2 ;
+ int extraD , flag ;
+ 
+ snode = ptr[p] ;
+ nptr = pnodeArray[ source - numnodes ].nodeList ;
+ 
+ rootx = (TNODEPTR) NULL ;
+ for( j = 1 ; j <= numnodes + pnodeAlength ; j++ ) {
+     if( j == snode ) {
+ 	tinsert( &rootx , 0 , j ) ;
+ 	nptr[snode].temp = 0 ;
+ 	nptr[snode].from2 = 0 ;
+ 	continue ;
+     }
+     nptr[j].temp = VLARGE ;
+ }
+ flag = 0 ;
+ 
+ for( ; ; ) {
+     tpop( &rootx , &dumnode , &D , &nextnode ) ;
+     if( dumnode == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     if( nextnode == target ) {
+ 	flag = 1 ;
+ 	for( ; ; ) {
+ 	    tpop( &rootx , &dumnode , &D , &nextnode ) ;
+ 	    if( dumnode == (TNODEPTR) NULL ) {
+ 		break ;
+ 	    }
+ 	}
+ 	break ;
+     }
+     gptr = gnodeArray[nextnode] ;
+     for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	if( gptr->inactive == 1 || gptr->einactive == 1 ) {
+ 	    continue ;
+ 	}
+ 	distance = gptr->cost ;
+ 	node = gptr->node ;
+ 	if( nptr[node].temp > D + distance ) {
+ 	    tdelete( &rootx , nptr[node].temp , node ) ;
+ 	    tinsert( &rootx , D + distance , node ) ;
+ 	    nptr[node].temp = D + distance ;
+ 	    nptr[node].from2 = nextnode ;
+ 	}
+     }
+ }
+ if( flag == 0 ) {
+     return( -1 ) ;
+ }
+ extraD = 0 ;
+ for( i = 1 ; i < p ; i++ ) {
+     node1 = ptr[i] ;
+     node2 = ptr[i + 1] ;
+     gptr1 = gnodeArray[node1] ;
+     for( ; ; ) {
+ 	if( gptr1->node == node2 ) {
+ 	    extraD += gptr1->cost ;
+ 	    break ;
+ 	}
+ 	gptr1 = gptr1->next ;
+     }
+ }
+ return( extraD ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/printgph.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/printgph.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/printgph.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,38 ----
+ #include "geo.h"
+ 
+ void printgph(void)
+ {
+ 
+ char filename[1024] ;
+ FILE *fp , *fpr ;
+ int i , index1 , index2 , length , width ;
+ 
+ 
+ sprintf( filename, "%s.rte", cktName ) ;
+ fpr = fopen( filename , "w" ) ;
+ sprintf( filename, "%s.gph", cktName ) ;
+ fp = fopen( filename , "w" ) ;
+ 
+ for( i = 1 ; i <= eNum ; i++ ) {
+     if( eArray[i].notActive == 0 ) {
+ 	index1 = eArray[i].index1 ;
+ 	index2 = eArray[i].index2 ;
+ 	if( i <= edgeTransition ) {
+ 	    length = rectArray[index2].yc - rectArray[index1].yc  ;
+ 	} else {
+ 	    length = rectArray[index2].xc - rectArray[index1].xc  ;
+ 	}
+ 	eArray[i].length = length ;
+ 	width  = eArray[i].width  ;
+ 	fprintf( fp, "edge %5d %5d   length %8d  capacity %8d\n",
+ 			    index1 , index2 , length , width ) ;
+ 
+ 	fprintf(fpr,"edge  node: %5d  xloc: %d  yloc: %d    node: %5d  xloc: %d  yloc: %d   length: %d   capacity: %d\n", index1, rectArray[index1].xc,
+ 	rectArray[index1].yc, index2, rectArray[index2].xc,
+ 	rectArray[index2].yc, length, width ) ;
+     }
+ }
+ fclose(fp);
+ fclose(fpr);
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/printnets.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/printnets.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/printnets.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,86 ----
+ #include "route.h"
+ 
+ void printnets(void)
+ {
+ 
+ int *iptr , m , net , i , distance , num ;
+ CHANBOXPTR cptr ;
+ char filename[1024] ;
+ #ifdef notdef
+ FILE *fp1;
+ #endif
+ FILE *fp2 ;
+ 
+ #ifdef notdef
+ sprintf( filename, "%s.prt" , cktName ) ;
+ if( (fp1 = fopen( filename , "w" )) == (FILE *) NULL ) {
+     fprintf( fpo, "can't open %s\n", filename ) ;
+     exit(0);
+ }
+ #endif
+ 
+ sprintf( filename, "%s.pyt" , cktName ) ;
+ if( (fp2 = fopen( filename , "w" )) == (FILE *) NULL ) {
+     fprintf( fpo, "can't open %s\n", filename ) ;
+     exit(0);
+ }
+ 
+ for( net = 1 ; net <= largestNet ; net++ ) {
+     for( m = 1 ; m <= netRoutes[net].numRoutes ; m++ ) {
+ 	iptr = netRoutes[net].alternate[m]->pinList ;
+ 	cptr = netRoutes[net].alternate[m]->chanList ;
+ 	distance = netRoutes[net].alternate[m]->distance ;
+ #ifdef notdef
+ 	fprintf(fp1,"\n\n*** NET: %s ***   Alternative:%d",
+ 				    nnameArray[net] , m ) ;
+ 	fprintf(fp1,"    NET_LENGTH: %d\n", distance ) ;
+ 	fprintf(fp1,"pin list\n");
+ #endif
+ 	if( m == 1 ) {
+ 	    fprintf(fp2,"\n\nnet %s ", nnameArray[net] ) ;
+ 	    fprintf(fp2,"    length %d\n", distance ) ;
+ 	    fprintf(fp2,"pins %d\n", iptr[0] );
+ 	}
+ 	for( i = 1 ; i <= iptr[0] ; i++ ) {
+ #ifdef notdef
+ 	    fprintf(fp1,"        %s\n", 
+ 		pnameArray[ pinOffset[net] + iptr[i] ] ) ;
+ #endif
+ 	    if( m == 1 ) {
+ 		fprintf(fp2,"        %s\n", 
+ 		    pnameArray[ pinOffset[net] + iptr[i] ] ) ;
+ 	    }
+ 	}
+ #ifdef notdef
+ 	fprintf(fp1,"channel list\n");
+ #endif
+ 	num = 0 ;
+ 	while( cptr != (CHANBOXPTR) NULL ) {
+ #ifdef notdef
+ 	    fprintf(fp1,"        %d - %d      starting offset: %d   ",
+ 			cptr->from, cptr->to, cptr->foffset ) ;
+ 	    fprintf(fp1," ending offset: %d\n", cptr->toffset ) ;
+ #endif
+ 	    num++ ;
+ 	    cptr = cptr->next ;
+ 	}
+ 	if( m == 1 ) {
+ 	    fprintf(fp2,"channels %d\n", num );
+ 	    cptr = netRoutes[net].alternate[m]->chanList ;
+ 	    while( cptr != (CHANBOXPTR) NULL ) {
+ 		fprintf(fp2,"        %d %d %d %d\n", cptr->from, 
+ 			    cptr->to, cptr->foffset, cptr->toffset );
+ 	
+ 		cptr = cptr->next ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ #ifdef notdef
+ fclose(fp1);
+ #endif
+ 
+ fclose(fp2);
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/procesnet.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/procesnet.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/procesnet.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,365 ----
+ #include "route.h"
+ #include "23tree.h"
+ TNODEPTR netRoot ;
+ 
+ extern void grepair(void);
+ extern void prepair( int numpnodes );
+ extern void loadpg( int net , int totalnodes );
+ extern void shortpath( int numpnodes );
+ extern void routenet( int segments , int numpnodes );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ 
+ void mergeSeg(void);
+ void joinSeg( int a , int aend , int b , int bend );
+ 
+ void procesnet( int net , int segments , int addnodes )
+ {
+ int node1, distance, i, j, k, numberRoutes, pin1 , prev ;
+ int index, bound, *iptr, pincount, fnode, tnode, pin2 ;
+ int firstNode, lastNode, neighbor1, neighbor2, foffset, toffset ;
+ short int *isptr ;
+ CHANBOXPTR lastcptr ;
+ TNODEPTR dumnode ;
+ 
+ if( segments == 1 ) {
+     return ;
+ }
+ 
+ grepair() ;
+ prepair( addnodes ) ;
+ 
+ loadpg( net , addnodes ) ;
+ shortpath( addnodes ) ;
+ 
+ routenet( segments , addnodes ) ;
+ 
+ numberRoutes = 0 ;
+ 
+ for( ; ; ) {
+     tpop( &netRoot , &dumnode , &distance , &index ) ;
+     if( dumnode == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     numberRoutes++ ;
+     isptr = savePaths[index] ;
+     bound = isptr[0] ;
+ 
+     i = 1 ;
+     netSegArray[0][0] = 1 ;
+     netSegArray[i][0] = 0 ;
+     for( k = 1 ; k < bound ; k++ ) {
+ 	if( isptr[k] == 0 ) {
+ 	    i++ ;
+ 	    netSegArray[0][0]++ ;
+ 	    netSegArray[i][0] = 0 ;
+ 	    continue ;
+ 	}
+ 	netSegArray[i][ ++netSegArray[i][0] ] = isptr[k] ;
+     }
+     mergeSeg() ;
+ 
+     pincount = 0 ;
+     for( i = 1 ; i <= netSegArray[0][0] ; i++ ) {
+ 	for( j = 1 ; j <= netSegArray[i][0] ; j++ ) {
+ 	    if( netSegArray[i][j] > numnodes ) {
+ 		pincount++ ;
+ 	    }
+ 	}
+     }
+     netRoutes[net].alternate[numberRoutes]->pinList = (int *) malloc(
+ 				    (1 + pincount) * sizeof( int ) ) ;
+     iptr = netRoutes[net].alternate[numberRoutes]->pinList ;
+     netRoutes[net].alternate[numberRoutes]->distance = distance ;
+     iptr[0] = pincount ;
+     pincount = 0 ;
+ 
+     for( i = 1 ; i <= netSegArray[0][0] ; i++ ) {
+ 	for( j = 1 ; j <= netSegArray[i][0] ; j++ ) {
+ 	    if( netSegArray[i][j] > numnodes ) {
+ 		iptr[ ++pincount ] = netSegArray[i][j] - numnodes ;
+ 	    }
+ 	}
+     }
+     lastcptr = (CHANBOXPTR) NULL ;
+ 
+     for( i = 1 ; i <= netSegArray[0][0] ; i++ ) {
+ 	firstNode = 0 ;
+ 	for( j = 1 ; j <= netSegArray[i][0] ; j++ ) {
+ 	    if( netSegArray[i][j] <= numnodes ) {
+ 		if( firstNode == 0 ) {
+ 		    firstNode = j ;
+ 		}
+ 		lastNode = j ;
+ 	    }
+ 	}
+ 	if( firstNode == 0 ) {     /* all nodes in one channel */
+ 	    pin1 = netSegArray[i][1] ;
+ 	    pin2 = netSegArray[i][2] ;
+ 	    neighbor1 = gnodeArray[pin1]->node ;
+ 	    neighbor2 = gnodeArray[pin1]->next->node ;
+ 	    if( neighbor2 == pin2 ) {
+ 		foffset = gnodeArray[pin1]->length ;
+ 		fnode = neighbor1 ;
+ 	    } else {
+ 		foffset = gnodeArray[pin1]->next->length ;
+ 		fnode = neighbor2 ;
+ 	    }
+ 	    prev = pin1 ;
+ 	    while( fnode > numnodes ) {
+ 		neighbor1 = gnodeArray[fnode]->node ;
+ 		neighbor2 = gnodeArray[fnode]->next->node ;
+ 		if( neighbor2 == prev ) {
+ 		    foffset += gnodeArray[fnode]->length ;
+ 		    prev = fnode ;
+ 		    fnode = neighbor1 ;
+ 		} else {
+ 		    foffset += gnodeArray[fnode]->next->length ;
+ 		    prev = fnode ;
+ 		    fnode = neighbor2 ;
+ 		}
+ 	    }
+ 	    pin1 = netSegArray[i][ netSegArray[i][0] ] ;
+ 	    pin2 = netSegArray[i][ netSegArray[i][0] - 1 ] ;
+ 	    neighbor1 = gnodeArray[pin1]->node ;
+ 	    neighbor2 = gnodeArray[pin1]->next->node ;
+ 	    if( neighbor2 == pin2 ) {
+ 		toffset = gnodeArray[pin1]->length ;
+ 		tnode = neighbor1 ;
+ 	    } else {
+ 		toffset = gnodeArray[pin1]->next->length ;
+ 		tnode = neighbor2 ;
+ 	    }
+ 	    prev = pin1 ;
+ 	    while( tnode > numnodes ) {
+ 		neighbor1 = gnodeArray[tnode]->node ;
+ 		neighbor2 = gnodeArray[tnode]->next->node ;
+ 		if( neighbor2 == prev ) {
+ 		    toffset += gnodeArray[tnode]->length ;
+ 		    prev = tnode ;
+ 		    tnode = neighbor1 ;
+ 		} else {
+ 		    toffset += gnodeArray[tnode]->next->length ;
+ 		    prev = tnode ;
+ 		    tnode = neighbor2 ;
+ 		}
+ 	    }
+ 	    if( lastcptr == (CHANBOXPTR) NULL ) {
+ 		netRoutes[net].alternate[numberRoutes]->chanList = 
+ 			(CHANBOXPTR) malloc( sizeof( CHANBOX ) ) ;
+ 		lastcptr = netRoutes[net].alternate[numberRoutes]->
+ 							chanList ;
+ 	    } else {
+ 		lastcptr = lastcptr->next =
+ 			(CHANBOXPTR) malloc( sizeof( CHANBOX ) ) ;
+ 	    }
+ 	    lastcptr->from = fnode ;
+ 	    lastcptr->to   = tnode ;
+ 	    lastcptr->foffset = foffset ;
+ 	    lastcptr->toffset = toffset  ;
+ 	    lastcptr->next = (CHANBOXPTR) NULL ;
+ 	} else {
+ 	    if( firstNode > 1 ) {
+ 		pin1 = netSegArray[i][1] ;
+ 		pin2 = netSegArray[i][2] ;
+ 		neighbor1 = gnodeArray[pin1]->node ;
+ 		neighbor2 = gnodeArray[pin1]->next->node ;
+ 		if( neighbor2 == pin2 ) {
+ 		    foffset = gnodeArray[pin1]->length ;
+ 		    fnode = neighbor1 ;
+ 		} else {
+ 		    foffset = gnodeArray[pin1]->next->length ;
+ 		    fnode = neighbor2 ;
+ 		}
+ 		prev = pin1 ;
+ 		while( fnode > numnodes ) {
+ 		    neighbor1 = gnodeArray[fnode]->node ;
+ 		    neighbor2 = gnodeArray[fnode]->next->node ;
+ 		    if( neighbor2 == prev ) {
+ 			foffset += gnodeArray[fnode]->length ;
+ 			prev = fnode ;
+ 			fnode = neighbor1 ;
+ 		    } else {
+ 			foffset += gnodeArray[fnode]->next->length ;
+ 			prev = fnode ;
+ 			fnode = neighbor2 ;
+ 		    }
+ 		}
+ 		if( lastcptr == (CHANBOXPTR) NULL ) {
+ 		    netRoutes[net].alternate[numberRoutes]->chanList = 
+ 			    (CHANBOXPTR) malloc( sizeof( CHANBOX ) ) ;
+ 		    lastcptr = netRoutes[net].alternate[numberRoutes]->
+ 							    chanList ;
+ 		} else {
+ 		    lastcptr = lastcptr->next =
+ 			    (CHANBOXPTR) malloc( sizeof( CHANBOX ) ) ;
+ 		}
+ 		lastcptr->from = fnode ;
+ 		lastcptr->foffset = foffset ;
+ 		lastcptr->to   = netSegArray[i][ firstNode ] ;
+ 		lastcptr->toffset = 0 ;
+ 		lastcptr->next = (CHANBOXPTR) NULL ;
+ 	    }
+ 	    node1 = firstNode ;
+ 	    for( ; ; ) {
+ 		for( j = node1 + 1 ; j <= lastNode ; j++ ) {
+ 		    if( netSegArray[i][j] <= numnodes ) {
+ 			break ;
+ 		    }
+ 		}
+ 		if( j > lastNode ) {
+ 		    break ;
+ 		} else {
+ 		    if( lastcptr == (CHANBOXPTR) NULL ) {
+ 			netRoutes[net].alternate[numberRoutes]->
+ 			chanList = (CHANBOXPTR) malloc(sizeof(CHANBOX));
+ 			lastcptr = netRoutes[net].alternate[
+ 					numberRoutes]-> chanList ;
+ 		    } else {
+ 			lastcptr = lastcptr->next =
+ 			    (CHANBOXPTR) malloc( sizeof( CHANBOX ) ) ;
+ 		    }
+ 		    lastcptr->from = netSegArray[i][node1] ;
+ 		    lastcptr->foffset = 0 ;
+ 		    lastcptr->to   = netSegArray[i][j] ;
+ 		    lastcptr->toffset = 0 ;
+ 		    lastcptr->next = (CHANBOXPTR) NULL ;
+ 		    node1 = j ; 
+ 	   	}
+ 	    }
+ 	    if( lastNode < netSegArray[i][0] ) {
+ 		pin1 = netSegArray[i][ netSegArray[i][0] ] ;
+ 		pin2 = netSegArray[i][ netSegArray[i][0] - 1 ] ;
+ 		neighbor1 = gnodeArray[pin1]->node ;
+ 		neighbor2 = gnodeArray[pin1]->next->node ;
+ 		if( neighbor2 == pin2 ) {
+ 		    toffset = gnodeArray[pin1]->length ;
+ 		    tnode = neighbor1 ;
+ 		} else {
+ 		    toffset = gnodeArray[pin1]->next->length ;
+ 		    tnode = neighbor2 ;
+ 		}
+ 		prev = pin1 ;
+ 		while( tnode > numnodes ) {
+ 		    neighbor1 = gnodeArray[tnode]->node ;
+ 		    neighbor2 = gnodeArray[tnode]->next->node ;
+ 		    if( neighbor2 == prev ) {
+ 			toffset += gnodeArray[tnode]->length ;
+ 			prev = tnode ;
+ 			tnode = neighbor1 ;
+ 		    } else {
+ 			toffset += gnodeArray[tnode]->next->length ;
+ 			prev = tnode ;
+ 			tnode = neighbor2 ;
+ 		    }
+ 		}
+ 		lastcptr = lastcptr->next =
+ 			    (CHANBOXPTR) malloc( sizeof( CHANBOX ) ) ;
+ 		lastcptr->from = netSegArray[i][lastNode] ;
+ 		lastcptr->foffset = 0 ;
+ 		lastcptr->to   = tnode ;
+ 		lastcptr->toffset = toffset ;
+ 		lastcptr->next = (CHANBOXPTR) NULL ;
+ 	    }
+ 	}
+     }
+ 
+     if( numberRoutes >= MAXPATHS ) {
+ 	break ;
+     }
+ }
+ netRoutes[net].numRoutes = numberRoutes ;
+ 
+ return ;
+ }
+ 
+ 
+ 
+ void mergeSeg(void)
+ {
+ 
+ int i , j , flag ;
+ 
+ flag = 0 ;
+ 
+ for( i = 1 ; i < netSegArray[0][0] ; i++ ) {
+     if( netSegArray[i][1] > numnodes ) {
+ 	for( j = i + 1 ; j <= netSegArray[0][0] ; j++ ) {
+ 	    if( netSegArray[i][1] == netSegArray[j][1] ) {
+ 		joinSeg( i , -1 , j , -1 ) ;
+ 		flag = 1 ;
+ 		break ;
+ 	    } else if( netSegArray[i][1] == 
+ 			    netSegArray[j][ netSegArray[j][0] ] ) {
+ 		joinSeg( i , -1 , j , 1 ) ;
+ 		flag = 1 ;
+ 		break ;
+ 	    }
+ 	}
+ 	if( flag == 1 ) {
+ 	    flag = 0 ;
+ 	    i-- ;
+ 	    continue ;
+ 	}
+     }
+     if( netSegArray[i][ netSegArray[i][0] ] > numnodes ) {
+ 	for( j = i + 1 ; j <= netSegArray[0][0] ; j++ ) {
+ 	    if( netSegArray[i][ netSegArray[i][0] ] == 
+ 				netSegArray[j][ netSegArray[j][0] ] ) {
+ 		joinSeg( i , 1 , j , 1 ) ;
+ 		i-- ;
+ 		break ;
+ 	    } else if( netSegArray[i][ netSegArray[i][0] ] == 
+ 						netSegArray[j][1] ) {
+ 		joinSeg( i , 1 , j , -1 ) ;
+ 		i-- ;
+ 		break ;
+ 	    }
+ 	}
+     }
+ }
+ return ;
+ }
+ 
+ 
+ 
+ 
+ void joinSeg( int a , int aend , int b , int bend )
+ {
+ 
+ int i , j ;
+ 
+ if( aend < 0 ) {
+     for( i = netSegArray[a][0] ; i >= 1 ; i-- ) {
+ 	netSegArray[a][i + netSegArray[b][0] - 1] = netSegArray[a][i] ;
+     }
+     if( bend < 0 ) {
+ 	for( i = 1 , j = netSegArray[b][0] ; j >= 2 ; j-- , i++ ) {
+ 	    netSegArray[a][i] = netSegArray[b][j] ;
+ 	}
+     } else {
+ 	for( i = 1 ; i < netSegArray[b][0] ; i++ ) {
+ 	    netSegArray[a][i] = netSegArray[b][i] ;
+ 	}
+     }
+ } else {
+     if( bend < 0 ) {
+ 	for( i = 2 ; i <= netSegArray[b][0] ; i++ ) {
+ 	    netSegArray[a][i + netSegArray[a][0] - 1] = netSegArray[b][i];
+ 	}
+     } else {
+ 	for( i = netSegArray[a][0] + 1, j = netSegArray[b][0] - 1 ;
+ 					    j >= 1 ; i++ , j-- ) {
+ 	    netSegArray[a][i] = netSegArray[b][j] ;
+ 	}
+     }
+ }
+ netSegArray[a][0] += netSegArray[b][0] - 1 ;
+ for( i = b + 1 ; i <= netSegArray[0][0] ; i++ ) {
+     for( j = 0 ; j <= netSegArray[i][0] ; j++ ) {
+ 	netSegArray[i - 1][j] = netSegArray[i][j] ;
+     }
+ }
+ netSegArray[0][0]-- ;
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readcells.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readcells.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readcells.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,797 ----
+ #include "custom.h"
+ int perim ;
+ extern int totPins ;
+ extern double *padspace ;
+ extern int *fixLRBT ;
+ typedef struct kbox {
+     int cap ;
+     int HV ;
+     int sp ;
+     int x ;
+     int y ;
+ }
+ KBOX ,
+ *KBOXPTR ;
+ 
+ KBOXPTR kArray ;
+ 
+ BUSTBOXPTR A , B , R ;
+ 
+ extern void parser( FILE *fp );
+ extern void pass2( FILE *fp );
+ extern int perimeter(void);
+ extern void buster(void);
+ extern int Hside( int cell , int xx1 , int xx2 , int y , int flag );
+ extern int Vside( int cell , int x , int yy1 , int yy2 , int flag );
+ extern int hashfind( char hname[] );
+ extern int findside( CELLBOXPTR cellptr , int x , int y );
+ extern void loadside( int side , double factor );
+ extern void placepin(void);
+ extern void genorient(void);
+ extern void watesides( CELLBOXPTR ptr );
+ extern void setpwates(void );
+ 
+ void readcells( FILE *fp )
+ {
+ 
+ int i , j , cell , temp ;
+ int xcenter , ycenter ;
+ int xpos , ypos , hit , pad , groupflag ;
+ int sequence , k , lastSite , numsites , unComTerms;
+ int first , l , m , prevsites , orient , norients , class ;
+ int firstside , lastside , side , distant , ncorners , corner ;
+ int x , y , minx , miny , maxx , maxy , xx1 , xx2 , yy1 , yy2 ;
+ int cellnum , pinctr , netx , tot , totx , toty ;
+ double aspub , asplb , space ;
+ char input[1024] ;
+ CELLBOXPTR ptr ;
+ TILEBOXPTR tile ;
+ TERMBOXPTR term ;
+ NETBOXPTR netptr , saveptr ;
+ 
+ parser( fp ) ;
+ pass2( fp )  ;
+ pinctr = 0   ;
+ perim  = 0   ;
+ 
+ /*  prepare MaxSites sites  */
+ kArray = (KBOXPTR) malloc( (MaxSites + 1) * sizeof( KBOX ));
+ for( k = 1 ; k <= MaxSites ; k++ ) {
+     kArray[ k ].cap = 0 ;
+     kArray[ k ].HV = 0 ;
+     kArray[ k ].sp = 0 ;
+     kArray[ k ].x = 0 ;
+     kArray[ k ].y = 0 ;
+ }
+ 
+ A = ( BUSTBOXPTR ) malloc( 31 * sizeof( BUSTBOX ) ) ;
+ B = ( BUSTBOXPTR ) malloc( 31 * sizeof( BUSTBOX ) ) ;
+ R = ( BUSTBOXPTR ) malloc( 5 * sizeof( BUSTBOX ) ) ;
+ pSideArray = (PSIDEBOX *) malloc( 31 * sizeof( PSIDEBOX ) ) ;
+ 
+ 
+ cell = 0 ;
+ pad = 0 ;
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+ 
+     if( strcmp( input , "cell") == 0 ) {
+ 	if( cell > 0 ) {
+ 	    watesides( ptr ) ;
+ 	}
+ 	ptr = cellarray[ ++cell ] ;
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	ptr->cname = (char *)malloc((strlen(input) + 1) * sizeof(char));
+ 	sprintf( ptr->cname , "%s" , input ) ;
+ 
+ 	for( k = 0 ; k <= 30 ; k++ ) {
+ 	    A[k].xc = 0 ;
+ 	    A[k].yc = 0 ;
+ 	}
+ 	for( k = 0 ; k <= 5 ; k++ ) {
+ 	    R[k].xc = 0 ;
+ 	    R[k].yc = 0 ;
+ 	}
+ 
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    A[ ++A[0].xc ].xc = x ;
+ 	    A[ A[0].xc ].yc = y ;
+ 	}
+ 	ptr->numsides = ncorners ;
+ 	perim += perimeter() ;
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    if( k < A[0].xc ) {
+ 		if( k % 2 == 1 ) {
+ 		    pSideArray[k].length = ABS(A[k + 1].yc - A[k].yc) ;
+ 		    pSideArray[k].vertical = 1 ;
+ 		    pSideArray[k].pincount = 0 ;
+ 		    pSideArray[k].position = A[k].xc ;
+ 		} else {
+ 		    pSideArray[k].length = ABS(A[k + 1].xc - A[k].xc) ;
+ 		    pSideArray[k].vertical = 0 ;
+ 		    pSideArray[k].pincount = 0 ;
+ 		    pSideArray[k].position = A[k].yc ;
+ 		}
+ 	    } else {
+ 		pSideArray[k].length = ABS(A[1].xc - A[k].xc) ;
+ 		pSideArray[k].vertical = 0 ;
+ 		pSideArray[k].pincount = 0 ;
+ 		pSideArray[k].position = A[k].yc ;
+ 	    }
+ 	}
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    x = A[k].xc ;
+ 	    y = A[k].yc ;
+ 	    if( k == 1 ) {
+ 		minx = x ;
+ 		miny = y ;
+ 		maxx = x ;
+ 		maxy = y ;
+ 	    } else {
+ 		if( x < minx ) {
+ 		    minx = x ;
+ 		}
+ 		if( x > maxx ) {
+ 		    maxx = x ;
+ 		}
+ 		if( y < miny ) {
+ 		    miny = y ;
+ 		}
+ 		if( y > maxy ) {
+ 		    maxy = y ;
+ 		}
+ 	    }
+ 	}
+ 	tile = ptr->config[ 0 ] = (TILEBOXPTR) malloc(
+ 					    sizeof( TILEBOX ) ) ;
+ 	tile->nexttile = TILENULL ;
+ 	tile->termptr = TERMNULL ;
+ 	tile->siteLocArray = LNULL ;
+ 	xcenter = (maxx + minx) / 2 ;
+ 	ycenter = (maxy + miny) / 2 ;
+ 	tile->left   = tile->oleft   = minx - xcenter ;
+ 	tile->right  = tile->oright  = maxx - xcenter ;
+ 	tile->bottom = tile->obottom = miny - ycenter ;
+ 	tile->top    = tile->otop    = maxy - ycenter ;
+ 	tile->lborder = 0 ;
+ 	tile->rborder = 0 ;
+ 	tile->bborder = 0 ;
+ 	tile->tborder = 0 ;
+ 	ptr->xcenter = xcenter ;
+ 	ptr->ycenter = ycenter ;
+ 	ptr->numtiles = 0 ;
+ 	do {
+ 	    ptr->numtiles++ ;
+ 	    tile = tile->nexttile = (TILEBOXPTR) malloc( 
+ 					sizeof( TILEBOX ) ) ;
+ 	    tile->nexttile = TILENULL ;
+ 	    tile->termptr  = TERMNULL ;
+ 	    tile->siteLocArray = LNULL;
+ 	    buster() ;
+ 	    tile->left   = tile->oleft   = R[1].xc - xcenter ;
+ 	    tile->right  = tile->oright  = R[4].xc - xcenter ;
+ 	    tile->bottom = tile->obottom = R[1].yc - ycenter ;
+ 	    tile->top    = tile->otop    = R[2].yc - ycenter ;
+ 	    tile->lborder = 0 ;
+ 	    tile->rborder = 0 ;
+ 	    tile->bborder = 0 ;
+ 	    tile->tborder = 0 ;
+ 	} while( A[0].xc > 0 ) ;
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	ptr->class = class ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &temp ) ;
+ 	    ptr->orientList[temp] = 1 ;
+ 	    if( orient == 1 ) {
+ 		ptr->orientList[8] = ptr->orient = temp ;
+ 	    }
+ 	}
+ 
+     } else if( strcmp( input , "pad") == 0 ) {
+ 
+ 	if( pad == 0 ) {
+ 	    watesides( ptr ) ;
+ 	}
+ 	ptr = cellarray[ ++cell ] ;
+ 	pad++ ;
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* pad name */
+ 	ptr->cname = (char *)malloc((strlen(input) + 1) * sizeof(char));
+ 	sprintf( ptr->cname , "%s" , input ) ;
+ 	for( k = 0 ; k <= 30 ; k++ ) {
+ 	    A[k].xc = 0 ;
+ 	    A[k].yc = 0 ;
+ 	}
+ 	for( k = 0 ; k <= 5 ; k++ ) {
+ 	    R[k].xc = 0 ;
+ 	    R[k].yc = 0 ;
+ 	}
+ 
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    A[ ++A[0].xc ].xc = x ;
+ 	    A[ A[0].xc ].yc = y ;
+ 	}
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    x = A[k].xc ;
+ 	    y = A[k].yc ;
+ 	    if( k == 1 ) {
+ 		minx = x ;
+ 		miny = y ;
+ 		maxx = x ;
+ 		maxy = y ;
+ 	    } else {
+ 		if( x < minx ) {
+ 		    minx = x ;
+ 		}
+ 		if( x > maxx ) {
+ 		    maxx = x ;
+ 		}
+ 		if( y < miny ) {
+ 		    miny = y ;
+ 		}
+ 		if( y > maxy ) {
+ 		    maxy = y ;
+ 		}
+ 	    }
+ 	}
+ 	tile = ptr->config[ 0 ] = (TILEBOXPTR) malloc(
+ 					    sizeof( TILEBOX ) ) ;
+ 	tile->nexttile = TILENULL ;
+ 	tile->termptr = TERMNULL ;
+ 	tile->siteLocArray = LNULL ;
+ 	xcenter = (maxx + minx) / 2 ;
+ 	ycenter = (maxy + miny) / 2 ;
+ 	tile->left   = tile->oleft   = minx - xcenter ;
+ 	tile->right  = tile->oright  = maxx - xcenter ;
+ 	tile->bottom = tile->obottom = miny - ycenter ;
+ 	tile->top    = tile->otop    = maxy - ycenter ;
+ 	tile->lborder = 0 ;
+ 	tile->rborder = 0 ;
+ 	tile->bborder = 0 ;
+ 	tile->tborder = 0 ;
+ 	ptr->xcenter = xcenter ;
+ 	ptr->ycenter = ycenter ;
+ 	ptr->numtiles = 0 ;
+ 	do {
+ 	    ptr->numtiles++ ;
+ 	    tile = tile->nexttile = (TILEBOXPTR) malloc( 
+ 					sizeof( TILEBOX ) ) ;
+ 	    tile->nexttile = TILENULL ;
+ 	    tile->termptr  = TERMNULL ;
+ 	    tile->siteLocArray = LNULL;
+ 	    buster() ;
+ 	    tile->left   = tile->oleft   = R[1].xc - xcenter ;
+ 	    tile->right  = tile->oright  = R[4].xc - xcenter ;
+ 	    tile->bottom = tile->obottom = R[1].yc - ycenter ;
+ 	    tile->top    = tile->otop    = R[2].yc - ycenter ;
+ 	    tile->lborder = 0 ;
+ 	    tile->rborder = 0 ;
+ 	    tile->bborder = 0 ;
+ 	    tile->tborder = 0 ;
+ 	} while( A[0].xc > 0 ) ;
+ 
+     } else if( strcmp( input , "padside") == 0 ) {
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "L" ) == 0 ) {
+ 	    ptr->padside = 1 ;
+ 	} else if( strcmp( input , "T" ) == 0 ) {
+ 	    ptr->padside = 2 ;
+ 	} else if( strcmp( input , "R" ) == 0 ) {
+ 	    ptr->padside = 3 ;
+ 	} else if( strcmp( input , "B" ) == 0 ) {
+ 	    ptr->padside = 4 ;
+ 	} else {
+ 	    fprintf(fpo,"padside not specified properly for ");
+ 	    fprintf(fpo,"pad: %s\n", ptr->cname ) ;
+ 	    exit(0);
+ 	}
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	ptr->class = class ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &temp ) ;
+ 	    ptr->orientList[temp] = 1 ;
+ 	    if( orient == 1 ) {
+ 		ptr->orientList[8] = ptr->orient = temp ;
+ 	    }
+ 	}
+ 
+     } else if( strcmp( input , "sidespace") == 0 ) {
+ 	fscanf( fp , " %lf " , &space ) ;
+ 	if( ptr->padside == 1 ) {
+ 	    fixLRBT[0] = 1 ;	
+ 	    padspace[ pad ] = space ;
+ 	} else if( ptr->padside == 3 ) {
+ 	    fixLRBT[1] = 1 ;	
+ 	    padspace[ pad ] = space ;
+ 	} else if( ptr->padside == 4 ) {
+ 	    fixLRBT[2] = 1 ;	
+ 	    padspace[ pad ] = space ;
+ 	} else if( ptr->padside == 2 ) {
+ 	    fixLRBT[3] = 1 ;	
+ 	    padspace[ pad ] = space ;
+ 	} 
+ 
+     } else if( strcmp( input , "softcell") == 0 ) {
+ 
+ 	if( cell > 0 ) {
+ 	    watesides( ptr ) ;
+ 	}
+ 	ptr = cellarray[ ++cell ] ;
+ 	fscanf( fp , "%d" , &cellnum ) ;
+ 	fscanf( fp , "%s" , input ) ; /* "name" */
+ 	fscanf( fp , "%s" , input ) ; /* cell name */
+ 	ptr->cname = (char *)malloc((strlen(input) + 1) * sizeof(char));
+ 	sprintf( ptr->cname , "%s" , input ) ;
+ 
+ 	ptr->softflag = 1 ;
+ 
+ 	for( k = 0 ; k <= 30 ; k++ ) {
+ 	    A[k].xc = 0 ;
+ 	    A[k].yc = 0 ;
+ 	    B[k].xc = 0 ;
+ 	    B[k].yc = 0 ;
+ 	}
+ 	for( k = 0 ; k <= 5 ; k++ ) {
+ 	    R[k].xc = 0 ;
+ 	    R[k].yc = 0 ;
+ 	}
+ 
+ 	fscanf( fp , " %d " , &ncorners ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( corner = 1 ; corner <= ncorners ; corner++ ) {
+ 	    fscanf( fp , " %d %d " , &x , &y ) ;
+ 	    A[ ++A[0].xc ].xc = x ;
+ 	    A[ A[0].xc ].yc = y ;
+ 	    B[ ++B[0].xc ].xc = x ;
+ 	    B[ B[0].xc ].yc = y ;
+ 	}
+ 	ptr->numsides = ncorners ;
+ 	ptr->sideArray = (SIDEBOX *) malloc( (ncorners + 1) *
+ 						sizeof( SIDEBOX ) ) ;
+ 	perim += perimeter() ;
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    if( k < A[0].xc ) {
+ 		if( k % 2 == 1 ) {
+ 		    pSideArray[k].length = ABS(A[k + 1].yc - A[k].yc) ;
+ 		    pSideArray[k].vertical = 1 ;
+ 		    pSideArray[k].pincount = 0 ;
+ 		    pSideArray[k].position = A[k].xc ;
+ 		} else {
+ 		    pSideArray[k].length = ABS(A[k + 1].xc - A[k].xc) ;
+ 		    pSideArray[k].vertical = 0 ;
+ 		    pSideArray[k].pincount = 0 ;
+ 		    pSideArray[k].position = A[k].yc ;
+ 		}
+ 	    } else {
+ 		pSideArray[k].length = ABS(A[1].xc - A[k].xc) ;
+ 		pSideArray[k].vertical = 0 ;
+ 		pSideArray[k].pincount = 0 ;
+ 		pSideArray[k].position = A[k].yc ;
+ 	    }
+ 	}
+ 
+ 	for( k = 1 ; k <= A[0].xc ; k++ ) {
+ 	    x = A[k].xc ;
+ 	    y = A[k].yc ;
+ 	    if( k == 1 ) {
+ 		minx = x ;
+ 		miny = y ;
+ 		maxx = x ;
+ 		maxy = y ;
+ 	    } else {
+ 		if( x < minx ) {
+ 		    minx = x ;
+ 		}
+ 		if( x > maxx ) {
+ 		    maxx = x ;
+ 		}
+ 		if( y < miny ) {
+ 		    miny = y ;
+ 		}
+ 		if( y > maxy ) {
+ 		    maxy = y ;
+ 		}
+ 	    }
+ 	}
+ 	ptr->aspect = (double)(maxy - miny) / (double)(maxx - minx);
+ 	ptr->aspectO = ptr->aspect ;
+ 
+ 	tile = ptr->config[ 0 ] = (TILEBOXPTR) malloc(
+ 					    sizeof( TILEBOX ) ) ;
+ 	tile->nexttile = TILENULL ;
+ 	tile->termptr = TERMNULL ;
+ 	tile->siteLocArray = LNULL ;
+ 	xcenter = (maxx + minx) / 2 ;
+ 	ycenter = (maxy + miny) / 2 ;
+ 	tile->left   = tile->oleft   = minx - xcenter ;
+ 	tile->right  = tile->oright  = maxx - xcenter ;
+ 	tile->bottom = tile->obottom = miny - ycenter ;
+ 	tile->top    = tile->otop    = maxy - ycenter ;
+ 	tile->lborder = 0 ;
+ 	tile->rborder = 0 ;
+ 	tile->bborder = 0 ;
+ 	tile->tborder = 0 ;
+ 	ptr->xcenter = xcenter ;
+ 	ptr->ycenter = ycenter ;
+ 	ptr->numtiles = 0 ;
+ 	do {
+ 	    ptr->numtiles++ ;
+ 	    tile = tile->nexttile = (TILEBOXPTR) malloc( 
+ 					sizeof( TILEBOX ) ) ;
+ 	    tile->nexttile = TILENULL ;
+ 	    tile->termptr  = TERMNULL ;
+ 	    tile->siteLocArray = LNULL;
+ 	    buster() ;
+ 	    tile->left   = tile->oleft   = R[1].xc - xcenter ;
+ 	    tile->right  = tile->oright  = R[4].xc - xcenter ;
+ 	    tile->bottom = tile->obottom = R[1].yc - ycenter ;
+ 	    tile->top    = tile->otop    = R[2].yc - ycenter ;
+ 	    tile->lborder = 0 ;
+ 	    tile->rborder = 0 ;
+ 	    tile->bborder = 0 ;
+ 	    tile->tborder = 0 ;
+ 	} while( A[0].xc > 0 ) ;
+ 
+ 	numsites = 0 ;
+ 	if( ptr->numUnComTerms != 0 ) {
+ 	    lastSite = 0 ;
+ 	    ptr->unComTerms = (UNCOMBOX *) malloc( 
+ 		(ptr->numUnComTerms + 1) * sizeof( UNCOMBOX ) );
+ 	    for( k = 1 ; k <= B[0].xc ; k++ ) {
+ 		xx1 = B[k].xc ;
+ 		yy1 = B[k].yc ;
+ 		if( k == B[0].xc ) {
+ 		    xx2 = B[1].xc ;
+ 		    yy2 = B[1].yc ;
+ 		} else {
+ 		    xx2 = B[ k + 1 ].xc ;
+ 		    yy2 = B[ k + 1 ].yc ;
+ 		}
+ 		if( yy1 == yy2 ) {  /* side is horizontal */
+ 		    numsites += Hside( cell, xx1, xx2, yy1, 0 );
+ 		} else {
+ 		    numsites += Vside( cell, xx1, yy1, yy2, 0 );
+ 		} 
+ 		ptr->sideArray[k].firstSite = lastSite + 1 ;
+ 		ptr->sideArray[k].lastSite  = numsites ;
+ 		lastSite = numsites ;
+ 	    }
+ 	}
+ 	ptr->numsites = numsites ;
+ 	ptr->siteContent = (CONTENTBOX *) 
+ 	    malloc( (numsites + 1) * sizeof( CONTENTBOX ) ) ;
+ 	ptr->config[0]->siteLocArray = (LOCBOX *) 
+ 		    malloc( (numsites + 1) * sizeof(LOCBOX) ) ;
+ 	if( ptr->numUnComTerms != 0 ) {
+ 	    numsites = 0 ;
+ 	    for( k = 1 ; k <= B[0].xc ; k++ ) {
+ 		xx1 = B[k].xc ;
+ 		yy1 = B[k].yc ;
+ 		if( k == B[0].xc ) {
+ 		    xx2 = B[1].xc ;
+ 		    yy2 = B[1].yc ;
+ 		} else {
+ 		    xx2 = B[ k + 1 ].xc ;
+ 		    yy2 = B[ k + 1 ].yc ;
+ 		}
+ 		prevsites = numsites ;
+ 		if( yy1 == yy2 ) {  /* side is horizontal */
+ 		    numsites += Hside( cell, xx1, xx2, yy1, 1 );
+ 		} else {
+ 		    numsites += Vside( cell, xx1, yy1, yy2, 1 );
+ 		}
+ 		for( j = 1 , l = prevsites + 1 ; l <= numsites ;
+ 						    l++ , j++ ){
+ 		    ptr->siteContent[ l ].HorV = kArray[j].HV ;
+ 		    ptr->siteContent[ l ].span = kArray[j].sp ;
+ 		    ptr->config[0]->siteLocArray[ l ].xpos = 
+ 					  kArray[j].x - xcenter;
+ 		    ptr->config[0]->siteLocArray[ l ].ypos = 
+ 					  kArray[j].y - ycenter;
+ 		    ptr->config[0]->siteLocArray[ l ].oxpos = 
+ 					  kArray[j].x - xcenter;
+ 		    ptr->config[0]->siteLocArray[ l ].oypos = 
+ 					  kArray[j].y - ycenter;
+ 		    ptr->siteContent[ l ].contents = 0 ;
+ 		    ptr->siteContent[ l ].newContents = 0 ;
+ 		    ptr->siteContent[ l ].capacity = 
+ 						kArray[j].cap ;
+ 		}
+ 	    }
+ 	}
+ 	unComTerms = 0 ;
+ 
+     } else if( strcmp( input , "pin") == 0 ) {
+ 
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	pinnames[++pinctr] = (char *)malloc((strlen(input) + 1) * 
+ 						    sizeof(char) );
+ 	sprintf( pinnames[pinctr] , "%s" , input ) ;
+ 	fscanf( fp , " %s " , input ) ; /* "signal" */
+ 	fscanf( fp , " %s " , input ) ; /* signal name */
+ 	netx = hashfind( input ) ;
+ 	if( netarray[netx]->nname == NULL ) {
+ 	    netarray[netx]->nname = (char *)malloc((strlen(input) + 1) *
+ 						    sizeof(char) );
+ 	    sprintf( netarray[netx]->nname , "%s" , input ) ;
+ 	}
+ 	saveptr = netarray[ netx ]->netptr ;
+ 	netptr = netarray[ netx ]->netptr = (NETBOXPTR) 
+ 					 malloc( sizeof(NETBOX) );
+ 	netptr->nextterm = saveptr ;
+ 	netptr->terminal = pinctr ;
+ 	netptr->xpos     = 0    ;
+ 	netptr->ypos     = 0    ;
+ 	netptr->newx     = 0    ;
+ 	netptr->newy     = 0    ;
+ 	netptr->flag     = 0    ;
+ 	netptr->cell     = cell ;
+ 	netptr->skip     = 0    ;
+ 
+ 	fscanf( fp , " %d %d " , &xpos , &ypos ) ;
+ 	if( pad == 0 ) {
+ 	    side = findside( ptr , xpos , ypos ) ;
+ 	    loadside( side , 1.0 ) ;
+ 	}
+ 
+ 	tot = 1 ;
+ 	totx = xpos ;
+ 	toty = ypos ;
+ 	xpos -= xcenter ;
+ 	ypos -= ycenter ;
+ 	hit = 0 ;
+ 	if( ptr->softflag == 1 ) {
+ 	    for( m = 1 ; m <= ptr->numsites ; m++ ) {
+ 		if( ptr->config[0]->siteLocArray[m].xpos == xpos ) {
+ 		    /*
+ 		     *  Find the site with the nearest ypos 
+ 		     */
+ 		    hit = 1 ;
+ 		    distant = ABS( ptr->config[0]->
+ 					    siteLocArray[m].ypos -
+ 					    ypos ) ;
+ 		    for( m++ ; m <= ptr->numsites ; m++ ) {
+ 			if(ptr->config[0]->siteLocArray[m].xpos ==
+ 						    xpos ) {
+ 			    if( ABS( ptr->config[0]->
+ 					    siteLocArray[m].ypos -
+ 					ypos ) < distant ) {
+ 				distant = ABS( ptr->config[0]->
+ 					    siteLocArray[m].ypos -
+ 					    ypos ) ;
+ 			    } else {
+ 				break ;
+ 			    }
+ 			} else {
+ 			    break ;
+ 			}
+ 		    }
+ 		    if( ++unComTerms > ptr->numUnComTerms ) {
+ 			fprintf(fpo,"screwup in readcells: ");
+ 			fprintf(fpo,"failed to properly count ");
+ 			fprintf(fpo,"the no. of uncommitted pins\n");
+ 			exit(0);
+ 		    }
+ 		    ptr->unComTerms[ unComTerms ].sequence = 1 ;
+ 		    ptr->unComTerms[ unComTerms ].terminal = pinctr ;
+ 		    ptr->unComTerms[ unComTerms ].numranges = 0 ;
+ 		    ptr->unComTerms[ unComTerms ].range1    = m - 1 ;
+ 		    break ;
+ 		} else if( ptr->config[0]->siteLocArray[m].ypos ==
+ 					    ypos ) {
+ 		    /*
+ 		     *  Find the site with the nearest xpos 
+ 		     */
+ 		    hit = 1 ;
+ 		    distant = ABS( ptr->config[0]->
+ 					    siteLocArray[m].xpos -
+ 					    xpos ) ;
+ 		    for( m++ ; m <= ptr->numsites ; m++ ) {
+ 			if(ptr->config[0]->siteLocArray[m].ypos ==
+ 						    ypos ) {
+ 			    if( ABS( ptr->config[0]->
+ 					    siteLocArray[m].xpos -
+ 					xpos ) < distant ) {
+ 				distant = ABS( ptr->config[0]->
+ 					    siteLocArray[m].xpos -
+ 					    xpos ) ;
+ 			    } else {
+ 				break ;
+ 			    }
+ 			} else {
+ 			    break ;
+ 			}
+ 		    }
+ 		    if( ++unComTerms > ptr->numUnComTerms ) {
+ 			fprintf(fpo,"screwup in readcells: ");
+ 			fprintf(fpo,"failed to properly count ");
+ 			fprintf(fpo,"the no. of uncommitted pins\n");
+ 			exit(0);
+ 		    }
+ 		    ptr->unComTerms[ unComTerms ].sequence = 1 ;
+ 		    ptr->unComTerms[ unComTerms ].terminal = pinctr ;
+ 		    ptr->unComTerms[ unComTerms ].numranges = 0 ;
+ 		    ptr->unComTerms[ unComTerms ].range1    = m - 1 ;
+ 		    break ;
+ 		}
+ 	    }
+ 	}
+ 	if( hit == 0 ) {
+ 	    ptr->numterms++ ;
+ 	    if( ptr->numterms == 1 ) {
+ 		term = ptr->config[ 0 ]->termptr = 
+ 			(TERMBOXPTR) malloc( sizeof( TERMBOX ) ) ;
+ 	    } else {
+ 		term = term->nextterm = (TERMBOXPTR) malloc( 
+ 					   sizeof( TERMBOX ) ) ;
+ 	    }
+ 	    term->terminal = pinctr ;
+ 	    term->nextterm = TERMNULL ;
+ 	    term->xpos  = xpos ;
+ 	    term->ypos  = ypos ;
+ 	    term->oxpos = xpos ;
+ 	    term->oypos = ypos ;
+ 	}
+ 
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 
+ 	fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	fscanf( fp , " %s " , input ) ; /* pin name */
+ 	fscanf( fp , " %d %d " , &xpos , &ypos ) ;
+ 	if( pad == 0 ) {
+ 	    side = findside( ptr , xpos , ypos ) ;
+ 	    loadside( side , 1.0 ) ;
+ 	}
+ 	tot++ ;
+ 	totx += xpos ;
+ 	toty += ypos ;
+ 	term->xpos = (totx / tot ) - xcenter ;
+ 	term->ypos = (toty / tot ) - ycenter ;
+ 	term->oxpos = (totx / tot ) - xcenter ;
+ 	term->oypos = (toty / tot ) - ycenter ;
+ 
+     } else if( strcmp( input , "asplb") == 0 ) {
+ 
+ 	fscanf( fp , "%lf" , &asplb ) ;
+ 	ptr->aspLB = asplb ;
+ 
+     } else if( strcmp( input , "aspub") == 0 ) {
+ 
+ 	fscanf( fp , "%lf" , &aspub ) ;
+ 	ptr->aspUB = aspub ;
+ 
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &class ) ;
+ 	ptr->class = class ;
+ 	fscanf( fp , " %d " , &norients ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	for( orient = 1 ; orient <= norients ; orient++ ) {
+ 	    fscanf( fp , " %d " , &temp ) ;
+ 	    ptr->orientList[temp] = 1 ;
+ 	    if( orient == 1 ) {
+ 		ptr->orientList[8] = ptr->orient = temp ;
+ 	    }
+ 	}
+ 
+     } else if( strcmp( input , "sequence") == 0 ||
+ 				    strcmp( input , "group") == 0 ) {
+ 	ptr->numgroups++ ;
+ 	if( strcmp( input , "group") == 0 ) {
+ 	    groupflag = 1 ;
+ 	} else {
+ 	    groupflag = 0 ;
+ 	}
+ 	fscanf( fp , " %d " , &sequence ) ;
+ 	for( i = 1 ; i <= sequence ; i++ ) {
+ 	    fscanf( fp , " %s " , input ) ; /* "pin"    */
+ 	    fscanf( fp , " %s " , input ) ; /* "name"   */
+ 	    fscanf( fp , " %s " , input ) ; /* pin name */
+ 	    pinnames[++pinctr] = (char *) malloc((strlen(input) + 1) *
+ 						    sizeof(char));
+ 	    sprintf( pinnames[pinctr] , "%s" , input ) ;
+ 	    fscanf( fp , " %s " , input ) ; /* "signal" */
+ 	    fscanf( fp , " %s " , input ) ; /* signal name */
+ 	    netx = hashfind( input ) ;
+ 	    if( netarray[netx]->nname == NULL ) {
+ 		netarray[netx]->nname = (char *) malloc( 
+ 				    (strlen(input) + 1) * sizeof(char));
+ 		sprintf( netarray[netx]->nname, "%s", input ) ;
+ 	    }
+ 	    saveptr = netarray[netx]->netptr ;
+ 	    netptr  = netarray[netx]->netptr = (NETBOXPTR) 
+ 					     malloc( sizeof(NETBOX) );
+ 	    netptr->nextterm = saveptr ;
+ 	    netptr->terminal = pinctr  ;
+ 	    netptr->xpos     = 0       ;
+ 	    netptr->ypos     = 0       ;
+ 	    netptr->newx     = 0       ;
+ 	    netptr->newy     = 0       ;
+ 	    netptr->flag     = 0       ;
+ 	    netptr->cell     = cell    ;
+ 	    netptr->skip     = 0       ;
+ 
+ 	    unComTerms++ ;
+ 	    if( i == 1 ) {
+ 		first = unComTerms ;
+ 		ptr->unComTerms[first].sequence = sequence ;
+ 	    } else {
+ 		ptr->unComTerms[unComTerms].sequence = 0 ;
+ 	    }
+ 	    ptr->unComTerms[unComTerms].terminal = pinctr ;
+ 	    ptr->unComTerms[unComTerms].groupflag = groupflag ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d %d " , &firstside , &lastside ) ;
+ 	if( firstside < 0 || firstside > B[0].xc ) {
+ 	    fprintf(fpo,"value of firstside out of range\n");
+ 	    fprintf(fpo,"firstside:%d  range:1 to %d\n", firstside,
+ 						    B[0].xc ) ;
+ 	    fprintf(fpo,"current cell is:%d\n", cell ) ;
+ 	    exit(0);
+ 	}
+ 	if( lastside < 0 || lastside > B[0].xc ) {
+ 	    fprintf(fpo,"value of lastside out of range\n");
+ 	    fprintf(fpo,"lastside:%d  range:1 to %d\n", lastside, 
+ 							    B[0].xc ) ;
+ 	    fprintf(fpo,"current cell is:%d\n", cell ) ;
+ 	    exit(0);
+ 	}
+ 	if( firstside == 0 ) {
+ 	    for( i = first ; i <= unComTerms ; i++ ) {
+ 		ptr->unComTerms[i].numranges = ptr->numsides ;
+ 		ptr->unComTerms[i].range1 = 0 ;
+ 	    }
+ 	    for( i = 1 ; i <= ptr->numsides ; i++ ) {
+ 		/* loadside( i , 2 * (double) sequence / 
+ 					    (double) ptr->numsides ) ;
+ 		*/
+ 		loadside( i, (double) sequence / (double) ptr->numsides);
+ 	    }
+ 	} else if( lastside == 0 ) {
+ 	    for( i = first ; i <= unComTerms ; i++ ) {
+ 		ptr->unComTerms[i].numranges = 1 ;
+ 		ptr->unComTerms[i].range1 = firstside ;
+ 	    }
+ 	    loadside( firstside , (double) sequence ) ;
+ 	} else {
+ 	    for( i = first ; i <= unComTerms ; i++ ) {
+ 		ptr->unComTerms[i].numranges = 2 ;
+ 		ptr->unComTerms[i].range1 = firstside ;
+ 		ptr->unComTerms[i].range2 = lastside  ;
+ 	    }
+ 	    loadside( firstside , (double) sequence / 2.0 ) ;
+ 	    loadside( lastside  , (double) sequence / 2.0 ) ;
+ 	}
+     }
+ }
+ 
+ pinsPerLen = (double) totPins / (double) perim ;
+ 
+ setpwates() ;
+ placepin()  ;
+ genorient() ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readgeo.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readgeo.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readgeo.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,197 ----
+ #include "geo.h"
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void readgeo( FILE *fp )
+ {
+ 
+ char input[32] ;
+ int vertices , v , vx , vy , ux , uy , ux0 , uy0 ;
+ int rippleCount , cell , i ;
+ CLBOXPTR clptr ;
+ 
+ bbr = 0 ;
+ bbt = 0 ;
+ bbl = 10000000 ;
+ bbb = 10000000 ;
+ edgeCount = 0 ;
+ rippleCount = 0 ;
+ cell = 0 ;
+ hFixedEdgeRoot = (TNODEPTR) NULL ;
+ vFixedEdgeRoot = (TNODEPTR) NULL ;
+ hEdgeRoot = (TNODEPTR) NULL ;
+ vEdgeRoot = (TNODEPTR) NULL ;
+ edgeList = (EDGEBOXPTR) malloc( 401 * sizeof( EDGEBOX ) ) ;
+ cellList = (CLBOXPTR *) malloc( 50 * sizeof(CLBOXPTR) ) ;
+ for( i = 1 ; i <= 49 ; i++ ) {
+     cellList[i] = (CLBOXPTR) NULL ;
+ }
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "cell") == 0 ) {
+ 	clptr = (CLBOXPTR) NULL ;
+ 	if( ++cell % 50 == 0 ) {
+ 	    cellList = (CLBOXPTR *) realloc( cellList , 
+ 				(cell + 50) * sizeof(CLBOXPTR) ) ;
+ 	    for( i = cell ; i <= cell + 49 ; i++ ) {
+ 		cellList[i] = (CLBOXPTR) NULL ;
+ 	    }
+ 	}
+ 	fscanf( fp , " %s " , input ) ; /* cell name */
+ 	fscanf( fp , " %d " , &vertices ) ;
+ 	fscanf( fp , " %s " , input ) ; /* keyword: vertices */
+ 	for( v = 1 ; v <= vertices ; v++ ) {
+ 	    fscanf( fp , " %d %d " , &vx , &vy ) ;
+ 	    if( vx > bbr ) {
+ 		bbr = vx ;
+ 	    }
+ 	    if( vx < bbl ) {
+ 		bbl = vx ;
+ 	    }
+ 	    if( vy > bbt ) {
+ 		bbt = vy ;
+ 	    }
+ 	    if( vy < bbb ) {
+ 		bbb = vy ;
+ 	    }
+ 	    if( v == 1 ) {
+ 		ux0 = ux = vx ;
+ 		uy0 = uy = vy ;
+ 	    } else {
+ 		edgeCount++ ;
+ 		if( clptr == (CLBOXPTR) NULL ) {
+ 		    cellList[cell] = (CLBOXPTR) malloc(sizeof(CLBOX));
+ 		    clptr = cellList[cell] ;
+ 		} else {
+ 		    clptr->next = (CLBOXPTR) malloc(sizeof(CLBOX));
+ 		    clptr = clptr->next ;
+ 		}
+ 		clptr->next = (CLBOXPTR) NULL ;
+ 		clptr->edge = edgeCount ;
+ 		clptr->extraSpace = 0 ;
+ 		clptr->compact = 1000000 ;
+ 
+ 		if( ++rippleCount > 400 ) {
+ 		    edgeList = (EDGEBOXPTR) realloc( edgeList,
+ 			    (edgeCount + 400) * sizeof(EDGEBOX));
+ 		    rippleCount = 1 ;
+ 		}
+ 		if( v % 2 == 0 ) {
+ 		    edgeList[edgeCount].start  = (uy <= vy) ? uy : vy ;
+ 		    edgeList[edgeCount].end    = (uy <= vy) ? vy : uy ;
+ 		    edgeList[edgeCount].loc    = ux ;
+ 		    edgeList[edgeCount].length = (uy <= vy) ? 
+ 						(vy - uy) : (uy - vy) ;
+ 		    edgeList[edgeCount].UorR   = (uy <= vy) ? 1 : -1 ;
+ 		    tinsert( &vFixedEdgeRoot, ux , edgeCount ) ;
+ 		    tinsert( &vEdgeRoot, ux , edgeCount ) ;
+ 		} else {
+ 		    edgeList[edgeCount].start  = (ux <= vx) ? ux : vx ;
+ 		    edgeList[edgeCount].end    = (ux <= vx) ? vx : ux ;
+ 		    edgeList[edgeCount].loc    = uy ;
+ 		    edgeList[edgeCount].length = (ux <= vx) ? 
+ 						(vx - ux) : (ux - vx) ;
+ 		    edgeList[edgeCount].UorR   = (ux <= vx) ? 1 : -1 ;
+ 		    tinsert( &hFixedEdgeRoot, uy , edgeCount ) ;
+ 		    tinsert( &hEdgeRoot, uy , edgeCount ) ;
+ 		}
+ 		edgeList[edgeCount].cell  = cell ;
+ 		edgeList[edgeCount].fixed = 1 ;
+ 		edgeList[edgeCount].nextEdge = edgeCount + 1 ;
+ 		if( v == 2 ) {
+ 		    edgeList[edgeCount].prevEdge = edgeCount + 
+ 							vertices - 1 ;
+ 		} else {
+ 		    edgeList[edgeCount].prevEdge = edgeCount - 1 ;
+ 		}
+ 		ux = vx ;
+ 		uy = vy ;
+ 	    }
+ 	}
+ 	vx = ux0 ;
+ 	vy = uy0 ;
+ 	edgeCount++ ;
+ 
+ 	clptr = clptr->next = (CLBOXPTR) malloc(sizeof(CLBOX));
+ 	clptr->next = (CLBOXPTR) NULL ;
+ 	clptr->edge = edgeCount ;
+ 	clptr->extraSpace = 0 ;
+ 	clptr->compact = 1000000 ;
+ 
+ 	if( ++rippleCount > 400 ) {
+ 	    edgeList = (EDGEBOXPTR) realloc( edgeList,
+ 		    (edgeCount + 400) * sizeof(EDGEBOX));
+ 	    rippleCount = 1 ;
+ 	}
+ 	edgeList[edgeCount].cell   = cell ;
+ 	edgeList[edgeCount].start  = (ux <= vx) ? ux : vx ;
+ 	edgeList[edgeCount].end    = (ux <= vx) ? vx : ux ;
+ 	edgeList[edgeCount].loc    = uy ;
+ 	edgeList[edgeCount].length = (ux <= vx) ? (vx - ux) : (ux - vx);
+ 	edgeList[edgeCount].UorR   = (ux <= vx) ? 1 : -1 ;
+ 	edgeList[edgeCount].prevEdge = edgeCount - 1 ;
+ 	edgeList[edgeCount].nextEdge = edgeCount - (vertices - 1) ;
+ 	edgeList[edgeCount].fixed    = 1 ;
+ 	tinsert( &hFixedEdgeRoot, uy , edgeCount ) ;
+ 	tinsert( &hEdgeRoot, uy , edgeCount ) ;
+     } else {
+ 	fprintf(fpdebug,"Found unparsable keyword: < %s > in ",
+ 						    input );
+ 	fprintf(fpdebug,"the .geo file\n");
+ 	fprintf(fpdebug,"Current cell: %d\n", cell ) ;
+ 	exit(0);
+     }
+ }
+ numberCells = cell ;
+ 
+ bbb-- ;
+ bbt++ ;
+ bbl-- ;
+ bbr++ ;
+ 
+ edgeList = (EDGEBOXPTR) realloc( edgeList,
+ 			(3 * edgeCount + 5) * sizeof(EDGEBOX));
+ edgeList[++edgeCount].start  = bbb ;
+ edgeList[edgeCount].end      = bbt ;
+ edgeList[edgeCount].loc      = bbl ;
+ edgeList[edgeCount].length   = bbt - bbb ;
+ edgeList[edgeCount].fixed    = 1 ;
+ edgeList[edgeCount].UorR     = -1 ;
+ edgeList[edgeCount].prevEdge = edgeCount + 1 ;
+ edgeList[edgeCount].nextEdge = edgeCount + 3 ;
+ edgeList[edgeCount].cell     = -1 ;
+ 
+ edgeList[++edgeCount].start  = bbl ;
+ edgeList[edgeCount].end      = bbr ;
+ edgeList[edgeCount].loc      = bbt ;
+ edgeList[edgeCount].length   = bbr - bbl ;
+ edgeList[edgeCount].fixed    = 1 ;
+ edgeList[edgeCount].UorR     = -1 ;
+ edgeList[edgeCount].prevEdge = edgeCount + 1 ;
+ edgeList[edgeCount].nextEdge = edgeCount - 1 ;
+ edgeList[edgeCount].cell     = -1 ;
+ 
+ edgeList[++edgeCount].start  = bbb ;
+ edgeList[edgeCount].end      = bbt ;
+ edgeList[edgeCount].loc      = bbr ;
+ edgeList[edgeCount].length   = bbt - bbb ;
+ edgeList[edgeCount].fixed    = 1 ;
+ edgeList[edgeCount].UorR     = 1 ;
+ edgeList[edgeCount].prevEdge = edgeCount + 1 ;
+ edgeList[edgeCount].nextEdge = edgeCount - 1 ;
+ edgeList[edgeCount].cell     = -1 ;
+ 
+ edgeList[++edgeCount].start  = bbl ;
+ edgeList[edgeCount].end      = bbr ;
+ edgeList[edgeCount].loc      = bbb ;
+ edgeList[edgeCount].length   = bbr - bbl ;
+ edgeList[edgeCount].fixed    = 1 ;
+ edgeList[edgeCount].UorR     = 1 ;
+ edgeList[edgeCount].prevEdge = edgeCount - 3 ;
+ edgeList[edgeCount].nextEdge = edgeCount - 1 ;
+ edgeList[edgeCount].cell     = -1 ;
+ 
+ numProbes = 0 ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readgraph.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readgraph.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readgraph.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,105 ----
+ #include "route.h"
+ 
+ void readgraph( FILE *fp )
+ {
+ 
+ char input[32] ;
+ int node1 , node2 , length , capacity , edge , i , test ;
+ GNODEPTR gptr ;
+ 
+ numnodes = 0 ;
+ edge = 0 ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "edge") == 0 ) {
+ 	edge++ ;
+ 	test = fscanf( fp , " %d %d " , &node1 , &node2 ) ;
+ 	if( test != 2 ) {
+ 	    fprintf( fpo, "Failed to input a pair of nodes ");
+ 	    fprintf( fpo, "following keyword edge in the .gph file\n");
+ 	    fprintf( fpo, "Current edge: %d\n", edge ) ;
+ 	    exit(0);
+ 	}
+ 	if( node1 > numnodes ) {
+ 	    numnodes = node1 ;
+ 	}
+ 	if( node2 > numnodes ) {
+ 	    numnodes = node2 ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "length") == 0 ) {
+ 	    test = fscanf( fp , " %d " , &length ) ;
+ 	    if( test != 1 ) {
+ 		fprintf( fpo, "Failed to input length ");
+ 		fprintf( fpo, "in the .gph file\n");
+ 		fprintf( fpo, "Current edge: %d\n", edge ) ;
+ 		exit(0);
+ 	    }
+ 	} else {
+ 	    fprintf( fpo, "Failed to find keyword: length ");
+ 	    fprintf( fpo, "for an edge\n") ;
+ 	    fprintf( fpo, "Current edge: %d\n", edge ) ;
+ 	    exit(0) ;
+ 	}
+ 	fscanf( fp , " %s " , input ) ;
+ 	if( strcmp( input , "capacity") == 0 ) {
+ 	    test = fscanf( fp , " %d " , &capacity ) ;
+ 	    if( test != 1 ) {
+ 		fprintf( fpo, "Failed to input capacity ");
+ 		fprintf( fpo, "in the .gph file\n");
+ 		fprintf( fpo, "Current edge: %d\n", edge ) ;
+ 		exit(0);
+ 	    }
+ 	} else {
+ 	    fprintf( fpo, "Failed to find keyword: capacity ");
+ 	    fprintf( fpo, "for an edge\n") ;
+ 	    fprintf( fpo, "Current edge: %d\n", edge ) ;
+ 	    exit(0) ;
+ 	}
+     } else {
+ 	fprintf( fpo, "Found unknown string when attempting ");
+ 	fprintf( fpo, "to find keyword: edge in the .gph file\n") ;
+ 	fprintf( fpo, "instead found: %s\n", input ) ;
+ 	fprintf( fpo, "Current edge: %d\n", edge ) ;
+ 	exit(0) ;
+     }
+ }
+ 
+ rewind( fp ) ;
+ 
+ gnodeArray = (GNODEPTR *) malloc( (numnodes + 1) * sizeof(GNODEPTR) ) ;
+ for( i = 1 ; i <= numnodes ; i++ ) {
+     gnodeArray[i] = (GNODEPTR) NULL ;
+ }
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "edge") == 0 ) {
+ 	fscanf( fp , " %d %d " , &node1 , &node2 ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &length ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &capacity ) ;
+ 	gptr = gnodeArray[node1] ;
+ 	gnodeArray[node1] =(GNODEPTR) malloc( sizeof(GNODE) ) ;
+ 	gnodeArray[node1]->next = gptr ;
+ 	gnodeArray[node1]->node = node2 ;
+ 	gnodeArray[node1]->length = length ;
+ 	gnodeArray[node1]->ilength = length ;
+ 	gnodeArray[node1]->cost = length ;
+ 	gnodeArray[node1]->capacity = capacity ;
+ 	gnodeArray[node1]->inactive = 0 ;
+ 	gnodeArray[node1]->einactive = 0 ;
+ 	gptr = gnodeArray[node2] ;
+ 	gnodeArray[node2] =(GNODEPTR) malloc( sizeof(GNODE) ) ;
+ 	gnodeArray[node2]->next = gptr ;
+ 	gnodeArray[node2]->node = node1 ;
+ 	gnodeArray[node2]->length = length ;
+ 	gnodeArray[node2]->ilength = length ;
+ 	gnodeArray[node2]->cost = length ;
+ 	gnodeArray[node2]->capacity = capacity ;
+ 	gnodeArray[node2]->inactive = 0 ;
+ 	gnodeArray[node2]->einactive = 0 ;
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readnets.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readnets.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readnets.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,77 ----
+ #include "custom.h"
+ double Hdefault ;
+ double Vdefault ;
+ 
+ extern int hashfind( char hname[] );
+ 
+ void readnets( FILE *fp )
+ {
+ 
+ int net , test , status ;
+ double Hweight , Vweight ;
+ char input[1024] ;
+ 
+ 
+ fscanf( fp , " %s ", input ) ;
+ if( strcmp( input , "allnets") != 0 ) {
+     fprintf( fpo, "The keyword allnets was ");
+     fprintf( fpo, "not properly entered in the .net file\n");
+     exit(0);
+ }
+ fscanf( fp , " %s ", input ) ;
+ if( strcmp( input , "HVweights") != 0 ) {
+     fprintf( fpo, "The keyword HVweights was ");
+     fprintf( fpo, "not properly entered in the .net file\n");
+     exit(0);
+ }
+ test = fscanf( fp , "%lf %lf" , &Hweight , &Vweight ) ;
+ if( test != 2 ) {
+     fprintf( fpo, "The net weights for allnets were ");
+     fprintf( fpo, "not properly entered in the .net file\n");
+     exit(0);
+ }
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     netarray[net]->Hweight = Hweight ;
+     netarray[net]->Vweight = Vweight ;
+ }
+ Hdefault = Hweight ;
+ Vdefault = Vweight ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "net") == 0 ) {
+ 	fscanf( fp , " %s ", input ) ;
+ 	status = hashfind( input ) ;
+ 	if( status == 0 ) {
+ 	    fprintf( fpo, "The net named: %s  in the .net file\n",
+ 						    input );
+ 	    fprintf( fpo, "was not encountered while reading\n");
+ 	    fprintf( fpo, "the .cel file --- FATAL error\n");
+ 	    exit(0);
+ 	}
+ 	fscanf( fp , " %s ", input ) ;
+ 	if( strcmp( input , "HVweights") == 0 ) {
+ 	    test = fscanf( fp , "%lf %lf" , &Hweight , &Vweight ) ;
+ 	    if( test != 2 ) {
+ 		fprintf( fpo, "The critical net weights were ");
+ 		fprintf( fpo, "not properly entered\n");
+ 		fprintf(fpo,"in the .net file after net: %s\n",
+ 							    input);
+ 		exit(0);
+ 	    }
+ 	    netarray[status]->Hweight = Hweight ;
+ 	    netarray[status]->Vweight = Vweight ;
+ 	} else {
+ 	    fprintf(fpo,"Neither the keyword HVweights nor ");
+ 	    fprintf(fpo,"the keyword nofeeds was entered\n");
+ 	    fprintf(fpo,"in the .net file after net: %s\n", input);
+ 	    exit(0);
+ 	}
+     } else {
+ 	fprintf( fpo, "unexpected keyword in the .net file\n");
+ 	exit(0);
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readpar.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readpar.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readpar.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,322 ----
+ #include "custom.h"
+ extern double chipaspect ;
+ extern double spot_control ;
+ extern int cost_only ;
+ extern int attpercell ;
+ extern int doPlacement ;
+ extern int doChannelGraph ;
+ extern int doGlobalRoute ;
+ extern int doCompaction ;
+ extern int pitch ;
+ int core_expansion_given ;
+ int wire_est_factor ;
+ double core_expansion ;
+ int defaultTracks ;
+ int routerMaxPaths ;
+ int routerExtraS   ;
+ int bareFlag ;
+ int wireEstimateOnly ;
+ 
+ void readpar(void)
+ {
+ FILE *fp;
+   
+ int test ;
+ char input[1024] ;
+ char filename[1024] ;
+ 
+ wireEstimateOnly = 0 ;
+ attpercell = -1 ;
+ lapFactor  = 1.0;
+ cost_only  = 0  ;
+ maxWeight  = 2  ;
+ baseWeight = 1  ;
+ chipaspect = -1.0 ;
+ pinSpacing = -1 ;
+ trackspacing = -1 ;
+ doPlacement = 0 ;
+ doChannelGraph = 0 ;
+ doGlobalRoute = 0 ;
+ doCompaction = 0 ;
+ coreGiven = 0 ;
+ gOffsetX = -1000000 ;
+ gOffsetY = -1000000 ;
+ gridX = -1000000 ;
+ gridY = -1000000 ;
+ defaultTracks = -1 ;
+ routerMaxPaths = -1 ;
+ routerExtraS   = -1 ;
+ core_expansion_given = 0 ;
+ spot_control = -1.0 ;
+ 
+ 
+ sprintf( filename, "%s.par" , cktName ) ;
+ if( (fp = fopen( filename , "r")) == (FILE *) NULL ) {
+     fprintf(fpo,"can't open %s\n", filename ) ;
+     exit (0);
+ }
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "initialT") == 0 ) {
+ 	test = fscanf( fp , " %lf " , &T ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value of initialT was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "spot.control") == 0 ) {
+ 	test = fscanf( fp , " %lf " , &spot_control ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value of spot.control was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "core.expansion") == 0 ) {
+ 	test = fscanf( fp , " %lf " , &core_expansion ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value of core.expansion was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+ 	core_expansion_given = 1 ;
+     } else if( strcmp( input , "wire.estimation.factor") == 0 ) {
+ 	test = fscanf( fp , " %d " , &wire_est_factor ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value of wire.estimation.factor was not ");
+ 	    fprintf(fpo,"properly entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "cost_only") == 0 ) {
+ 	cost_only = 1 ;
+     } else if( strcmp( input , "random.seed") == 0 ) {
+ 	test = fscanf( fp , " %d " , &randVar ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value of random.seed was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "att.per.cell") == 0 ) {
+ 	test = fscanf( fp , " %d " , &attpercell ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value of att.per.cell was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "track.spacing") == 0 ) {
+ 	test = fscanf( fp , " %d " , &trackspacing ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for track.spacing was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+ 	pitch = trackspacing ;
+     } else if( strcmp( input , "pin.spacing") == 0 ) {
+ 	test = fscanf( fp , " %d " , &pinSpacing ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for pin.spacing was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "chip.aspect.ratio") == 0 ) {
+ 	test = fscanf( fp , " %lf " , &chipaspect ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for chip.aspect.ratio was not");
+ 	    fprintf(fpo," properly entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "router.max.paths") == 0 ) {
+ 	test = fscanf( fp , " %d " , &routerMaxPaths ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for router.max.paths was");
+ 	    fprintf(fpo," not properly entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "router.extra.sources") == 0 ) {
+ 	test = fscanf( fp , " %d " , &routerExtraS ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for router.extra.sources was");
+ 	    fprintf(fpo," not properly entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "default.tracks.per.channel") == 0 ) {
+ 	test = fscanf( fp , " %d " , &defaultTracks ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for default.tracks.per.channel was");
+ 	    fprintf(fpo," not properly entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "wire.estimation.only") == 0 ) {
+ 	wireEstimateOnly = 1 ;
+     } else if( strcmp( input , "do.placement") == 0 ) {
+ 	doPlacement = 1 ;
+     } else if( strcmp( input , "do.channel.graph") == 0 ) {
+ 	doChannelGraph = 1 ;
+     } else if( strcmp( input , "do.global.route") == 0 ) {
+ 	doGlobalRoute = 1 ;
+     } else if( strcmp( input , "do.compaction") == 0 ) {
+ 	test = fscanf( fp , " %d " , &doCompaction ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for do.compaction was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "core") == 0 ) {
+ 	test = fscanf( fp , " %d %d %d %d " , &blockl , &blockr,
+ 						&blockb , &blockt ) ;
+ 	if( test != 4 ) {
+ 	    fprintf(fpo,"The 4 values for core were not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+ 	coreGiven = 1 ;
+     } else if( strcmp( input , "gridOffsetX") == 0 ) {
+ 	test = fscanf( fp , " %d " , &gOffsetX ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for gridOffsetX was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "gridOffsetY") == 0 ) {
+ 	test = fscanf( fp , " %d " , &gOffsetY ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for gridOffsetY was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "gridX") == 0 ) {
+ 	test = fscanf( fp , " %d " , &gridX ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for gridX was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "gridY") == 0 ) {
+ 	test = fscanf( fp , " %d " , &gridY ) ;
+ 	if( test != 1 ) {
+ 	    fprintf(fpo,"The value for gridY was not properly");
+ 	    fprintf(fpo,"entered in the .par file\n");
+ 	    exit(0);
+ 	}
+     } else {
+ 	fprintf(fpo,"Unexpected keyword in the .par file\n");
+ 	exit(0);
+     }
+ }
+ 
+ if( doPlacement ) {
+     if( gridX >= 0 || gridY >= 0 || gOffsetX >= 0 || gOffsetY >= 0 ) {
+ 	if( !(gridX >= 0 && gridY >= 0 && 
+ 				gOffsetX >= 0 && gOffsetY >= 0 ) ) {
+ 	    fprintf(fpo,"Error: It appears as though the grid is\n");
+ 	    fprintf(fpo,"not fully specified\n");
+ 	    exit(0);
+ 	} else {
+ 	    gridGiven = 1 ;
+ 	}
+     }
+     if( attpercell == -1 ) {
+ 	fprintf(fpo,"att.per.cell was not entered in the .par file\n");
+ 	exit(0);
+     } else {
+ 	fprintf(fpo,"att.per.cell: %d\n" , attpercell ) ;
+     }
+     if( trackspacing < 0 ) {
+ 	fprintf(fpo,"track.spacing was not entered in .par file\n");
+ 	exit(0);
+     } else {
+ 	fprintf(fpo,"track.spacing: %d\n" , trackspacing ) ;
+     }
+     if( pinSpacing < 0 ) {
+ 	fprintf(fpo,"pin.spacing was not entered in the .par file\n");
+ 	exit(0);
+     } else {
+ 	fprintf(fpo,"pin.spacing: %d\n" , pinSpacing ) ;
+     }
+     if( chipaspect < 0.0 ) {
+ 	fprintf(fpo,"chip.aspect.ratio was not entered ");
+ 	fprintf(fpo,"in the .par file\n");
+ 	exit(0);
+     } else {
+ 	fprintf(fpo,"chip.aspect.ratio: %g\n" , chipaspect ) ;
+     }
+     if( spot_control < 0.0 ) {
+ 	fprintf(fpo,"Using default value of spot.control: 1.0\n");
+ 	spot_control = 1.0 ;
+     } else {
+ 	fprintf(fpo,"spot.control set to: %f\n", spot_control );
+     }
+ }
+ if( doPlacement ) {
+     fprintf(fpo,"TimberWolf instructed to do ");
+     fprintf(fpo,"placement of circuit:<%s>\n", cktName ) ;
+ }
+ if( doChannelGraph ) {
+     fprintf(fpo,"TimberWolf instructed to generate ");
+     fprintf(fpo,"channel graph for circuit:<%s>\n", cktName ) ;
+     if( ! doPlacement ) {
+ 	fprintf(fpo,"TimberWolf assumes input files: ");
+ 	fprintf(fpo,"<%s.geo> and <%s.pin> are present in\n",
+ 						cktName, cktName );
+     }
+ }
+ if( doGlobalRoute ) {
+     if( routerMaxPaths < 0 ) {
+ 	fprintf(fpo,"router.max.paths was not entered in .par file\n");
+ 	exit(0);
+     } else {
+ 	fprintf(fpo,"router.max.paths: %d\n" , routerMaxPaths ) ;
+     }
+     if( routerMaxPaths == 0 ) {
+ 	fprintf(fpo,"router.max.paths set to BARE MINIMUM version\n");
+ 	routerMaxPaths = 1 ;
+ 	bareFlag = 1 ;
+     } else {
+ 	bareFlag = 0 ;
+     }
+ 
+ 
+     if( routerExtraS < 0 ) {
+ 	fprintf(fpo,"router.extra.sources was not entered in .par file\n");
+ 	exit(0);
+     } else {
+ 	fprintf(fpo,"router.extra.sources: %d\n" , routerExtraS ) ;
+     }
+     if( doChannelGraph ) {
+ 	if( trackspacing < 0 ) {
+ 	    fprintf(fpo,"track.spacing was not entered in .par file\n");
+ 	    exit(0);
+ 	} else {
+ 	    fprintf(fpo,"track.spacing: %d\n" , trackspacing ) ;
+ 	}
+ 	if( defaultTracks < 0 ) {
+ 	    fprintf(fpo,"default.tracks.per.channel \n");
+ 	    fprintf(fpo,"was not entered in .par file\n");
+ 	    exit(0);
+ 	} else {
+ 	    fprintf(fpo,"default.tracks.per.channel: %d\n",defaultTracks);
+ 	}
+     }
+     fprintf(fpo,"TimberWolf instructed to do ");
+     fprintf(fpo,"global route for circuit:<%s>\n", cktName ) ;
+     if( ! doChannelGraph ) {
+ 	fprintf(fpo,"TimberWolf assumes input files: ");
+ 	fprintf(fpo,"<%s.gph> and <%s.twf> are present in ",
+ 						cktName, cktName );
+ 	fprintf(fpo,"the working directory\n") ;
+     }
+ }
+ if( doCompaction ) {
+     fprintf(fpo,"TimberWolf instructed to do ");
+     fprintf(fpo,"post-placement compaction for circuit:<%s>\n",cktName);
+     if( !(doPlacement && doChannelGraph && doGlobalRoute) ) {
+ 	fprintf(fpo,"Error: TimberWolf cannot do compaction\n");
+ 	fprintf(fpo,"without request to also do: doPlacement,\n");
+ 	fprintf(fpo,"doChannelGraph and doGlobalRoute\n");
+ 	fprintf(fpo,"Hence, request is cancelled\n");
+ 	doCompaction = 0 ;
+     }
+ }
+ 
+ fflush(fpo);
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readpnode.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readpnode.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/readpnode.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,380 ----
+ #include "route.h"
+ int pnodeAlength ;
+ 
+ extern void procesnet( int net , int segments , int addnodes );
+ 
+ void readpnode( FILE *fp )
+ {
+ 
+ char input[1024] ;
+ int pin , net , node1 , node2 , distance , i , j , segments , test ;
+ int pnode ;
+ LIST2PTR lptr , l2ptr ;
+ NNODEPTR nptr ;
+ QUADPTR qptr , q2ptr , tmpqptr ;
+ 
+ maxpnode = 0 ;
+ pnode = 0 ;
+ net = 0 ;
+ numpins = 0 ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "net") == 0 ) {
+ 	net++ ;
+ 	if( pnode > maxpnode ) {
+ 	    maxpnode = pnode ;
+ 	}
+ 	pnode = 0 ;
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input a net name ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "pin") == 0 ) {
+ 	pnode++ ;
+ 	numpins++ ;
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input a pin name ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input keyword: nodes ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	} else if( strcmp( input , "nodes" ) != 0 ) {
+ 	    fprintf( fpo, "Failed to input keyword: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d %d " , &node1 , &node2 ) ;
+ 	if( test != 2 ) {
+ 	    fprintf( fpo, "Failed to input a pair of nodes ");
+ 	    fprintf( fpo, "following keyword nodes in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input keyword: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	} else if( strcmp( input , "at" ) != 0 ) {
+ 	    fprintf( fpo, "Failed to input keyword: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &distance ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input an integer following: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 	pnode++ ;
+ 	numpins++ ;
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input a pin name ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input keyword: nodes ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	} else if( strcmp( input , "nodes" ) != 0 ) {
+ 	    fprintf( fpo, "Failed to input keyword: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d %d " , &node1 , &node2 ) ;
+ 	if( test != 2 ) {
+ 	    fprintf( fpo, "Failed to input a pair of nodes ");
+ 	    fprintf( fpo, "following keyword nodes in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %s " , input ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input keyword: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	} else if( strcmp( input , "at" ) != 0 ) {
+ 	    fprintf( fpo, "Failed to input keyword: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+ 	test = fscanf( fp , " %d " , &distance ) ;
+ 	if( test != 1 ) {
+ 	    fprintf( fpo, "Failed to input an integer following: at ");
+ 	    fprintf( fpo, "in the .twf file\n");
+ 	    fprintf( fpo, "Current net: %d\n", net ) ;
+ 	    exit(0);
+ 	}
+     } else {
+ 	fprintf( fpo, "Found unknown string: < %s >  ", input );
+ 	fprintf( fpo, "in the .twf file\n") ;
+ 	fprintf( fpo, "Current net: %d\n", net ) ;
+ 	exit(0) ;
+     }
+ }
+ if( pnode > maxpnode ) {
+     maxpnode = pnode ;
+ }
+ 
+ rewind( fp ) ;
+ 
+ gnodeArray = (GNODEPTR *) realloc( gnodeArray, (1 + numnodes +
+ 			    maxpnode ) * sizeof( GNODEPTR ) ) ;
+ for( i = numnodes + 1 ; i <= numnodes + maxpnode ; i++ ) {
+     gnodeArray[i] = (GNODEPTR) NULL ;
+ }
+ 
+ gtrace = (short int **) malloc( 5 * sizeof( short int * ) ) ;
+ for( i = 1 ; i <= 4 ; i++ ) {
+     gtrace[i] = (short int *) malloc( (1 + maxpnode) * 
+ 					sizeof( short int ) ) ;
+ }
+ 
+ largestNet = net ;
+ netRoutes = (NRBOXPTR) malloc( (1 + largestNet) * sizeof(NRBOX) ) ;
+ for( i = 1 ; i <= largestNet ; i++ ) {
+     netRoutes[i].currentRoute = 1 ;
+     netRoutes[i].alternate = (ALTBOXPTR *) malloc(
+ 				(1 + MAXPATHS) * sizeof(ALTBOXPTR) ) ;
+     for( j = 1 ; j <= MAXPATHS ; j++ ) {
+ 	netRoutes[i].alternate[j] = (ALTBOXPTR)malloc(sizeof(ALTBOX));
+ 	netRoutes[i].alternate[j]->pinList = (int *) NULL ;
+ 	netRoutes[i].alternate[j]->chanList = (CHANBOXPTR) NULL ;
+     }
+ }
+ 
+ savePaths = (short int **) malloc( (1 + 2 * MAXPATHS) * 
+ 					sizeof( short int *) ) ;
+ for( i = 1 ; i <= 2 * MAXPATHS ; i++ ) {
+     savePaths[i] = (short int *) malloc( (1 + 3 * (numnodes + maxpnode)) * 
+ 					sizeof(short int) ) ;
+ }
+ 
+ pnameArray = (char **) malloc( (1 + numpins) * sizeof( char *) ) ;
+ for( i = 1 ; i <= numpins ; i++ ) {
+     pnameArray[i] = (char *) NULL ;
+ }
+ 
+ nnameArray = (char **) malloc( (1 + net) * sizeof( char *) ) ;
+ for( i = 1 ; i <= net ; i++ ) {
+     nnameArray[i] = (char *) NULL ;
+ }
+ 
+ pinOffset = (int *) malloc( (1 + net) * sizeof( int ) ) ;
+ for( i = 1 ; i <= net ; i++ ) {
+     pinOffset[i] = 0 ;
+ }
+ 
+ segList = (short int *) malloc((1 + 3 * (numnodes + maxpnode)) * 
+ 						sizeof(short int));
+ sourceList = (short int *) malloc( (1 + maxpnode) * 
+ 						sizeof( short int ) ) ;
+ targetList = (short int *) malloc( (1 + maxpnode + numnodes) * 
+ 						sizeof(short int) );
+ delSourceList = (short int *) malloc( (1 + maxpnode) * 
+ 						sizeof( short int ) ) ;
+ addTargetList = (short int *) malloc( (1 + maxpnode + numnodes) * 
+ 						sizeof(short int) );
+ 
+ pathList = (int **) malloc((1 + EXTRASOURCES * MAXPATHS) * 
+ 						sizeof(int *));
+ for( i = 1 ; i <= EXTRASOURCES * MAXPATHS ; i++ ) {
+     pathList[i] = (int *) malloc( (2 + numnodes + maxpnode) * 
+ 						sizeof(int));
+     for( j = 0 ; j <= numnodes + maxpnode + 1 ; j++ ) {
+ 	pathList[i][j] = 0 ;
+     }
+ }
+ 
+ pathArray = (PATHPTR) malloc( (3 + 2 * MAXPATHS) * sizeof( PATH ) ) ;
+ for( i = 1 ; i <= 2 + 2 * MAXPATHS ; i++ ) {
+     pathArray[i].nodeset = (short int *) malloc( 
+ 			(1 + numnodes + maxpnode) * sizeof(short int));
+ }
+ tempArray = (short int *) malloc( (1 + numnodes + maxpnode) * 
+ 						sizeof(short int));
+ 
+ 
+ pnode = 0 ;
+ pnodeAlength = 0 ;
+ net = 0 ;
+ pin = 0 ;
+ pinlist = (QUADPTR) NULL ;
+ qptr = (QUADPTR) NULL ;
+ 
+ while( fscanf( fp , " %s " , input ) == 1 ) {
+     if( strcmp( input , "net") == 0 ) {
+ 	if( net > 0 ) {
+ 	    if( net % 10 == 0 ) {
+ 		fprintf(fpo,"Global Routing Net Number: %d\n", net );
+ 		fflush(fpo);
+ 	    }
+ 	    if( (pnode > pnodeAlength) || 
+ 		    ((pnodeAlength > 30) && (2 * pnode < pnodeAlength) )){
+ 		if( pnodeAlength > 0 ) { 
+ 		    for( i = 1 ; i <= pnodeAlength ; i++ ) {
+ 			lptr = pnodeArray[i].equiv ;
+ 			while( lptr != (LIST2PTR) NULL ) {
+ 			    l2ptr = lptr->next ;
+ 			    free( lptr ) ;
+ 			    lptr = l2ptr ;
+ 			}
+ 			nptr = pnodeArray[i].nodeList ;
+ 			if( nptr != (NNODEPTR) NULL ) {
+ 			    free( pnodeArray[i].nodeList ) ;
+ 			}
+ 		    }
+ 		    for( i = 0 ; i < pnodeAlength ; i++ ) {
+ 			free( netSegArray[i] ) ;
+ 		    }
+ 		    free( (PNODEPTR) pnodeArray ) ;
+ 		    free( (short int **) netSegArray ) ;
+ 		}
+ 		pnodeAlength = pnode ;
+ 		pnodeArray = (PNODEPTR) malloc( (1 + pnode) * 
+ 						sizeof(PNODE) ) ;
+ 		for( i = 1 ; i <= pnode ; i++ ) {
+ 		    pnodeArray[i].nodeList = 
+ 				    (NNODEPTR) malloc( (1 + numnodes +
+ 				    pnode ) * sizeof(NNODE) ) ;
+ 		    pnodeArray[i].eptr = 0 ;
+ 		    pnodeArray[i].equiv = (LIST2PTR) NULL ;
+ 		}
+ 		netSegArray = (short int **) malloc( pnode * 
+ 					    sizeof( short int *) ) ;
+ 		for( i = 0 ; i < pnode ; i++ ) {
+ 		    netSegArray[i] = (short int *) 
+ 				    malloc( (1 + numnodes + pnode) *
+ 				    sizeof( short int ) ) ;
+ 		}
+ 	    }
+ 
+ 	    procesnet( net , segments , pnode ) ;
+ 	}
+ 	net++ ;
+ 	segments = 0 ;
+ 	pinOffset[net] = pin ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	nnameArray[net] = (char *) malloc( (strlen(input) + 1) * 
+ 						sizeof(char) ) ;
+ 	sprintf( nnameArray[net], "%s", input ) ;
+ 	pnode = 0 ;
+ 	while( qptr != (QUADPTR) NULL ) {
+ 	    q2ptr = qptr->prev ;
+ 	    free( qptr ) ;
+ 	    qptr = q2ptr ;
+ 	}
+ 	qptr = (QUADPTR) NULL ;
+ 	pinlist = (QUADPTR) NULL ;
+     } else if( strcmp( input , "pin") == 0 ) {
+ 	pin++ ;
+ 	pnode++ ;
+ 	segments++ ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	pnameArray[pin] = (char *) malloc( (strlen(input) + 1) * 
+ 						sizeof(char) ) ;
+ 	sprintf( pnameArray[pin], "%s", input ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d %d " , &node1 , &node2 ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &distance ) ;
+ 	if( qptr == (QUADPTR) NULL ) {
+ 	    pinlist = qptr = (QUADPTR) malloc( sizeof(QUAD) ) ;
+ 	    qptr->prev = (QUADPTR) NULL ;
+ 	} else {
+ 	    tmpqptr = qptr ;
+ 	    qptr = qptr->next = (QUADPTR) malloc( sizeof(QUAD) ) ;
+ 	    qptr->prev = tmpqptr ;
+ 	}
+ 	qptr->next = (QUADPTR) NULL ;
+ 	qptr->PorE = 1 ;
+ 	qptr->node1 = node1 ;
+ 	qptr->node2 = node2 ;
+ 	qptr->distance = distance ;
+     } else if( strcmp( input , "equiv") == 0 ) {
+ 	pin++ ;
+ 	pnode++ ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	pnameArray[pin] = (char *) malloc( (strlen(input) + 1) * 
+ 						sizeof(char) ) ;
+ 	sprintf( pnameArray[pin], "%s", input ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d %d " , &node1 , &node2 ) ;
+ 	fscanf( fp , " %s " , input ) ;
+ 	fscanf( fp , " %d " , &distance ) ;
+ 	tmpqptr = qptr ;
+ 	qptr = qptr->next = (QUADPTR) malloc( sizeof(QUAD) ) ;
+ 	qptr->prev = tmpqptr ;
+ 	qptr->next = (QUADPTR) NULL ;
+ 	qptr->PorE = -1 ;
+ 	qptr->node1 = node1 ;
+ 	qptr->node2 = node2 ;
+ 	qptr->distance = distance ;
+     }
+ }
+ if( (pnode > pnodeAlength) || (10 * pnode < pnodeAlength) ) {
+     if( pnodeAlength > 0 ) { 
+ 	for( i = 1 ; i <= pnodeAlength ; i++ ) {
+ 	    lptr = pnodeArray[i].equiv ;
+ 	    while( lptr != (LIST2PTR) NULL ) {
+ 		l2ptr = lptr->next ;
+ 		free( lptr ) ;
+ 		lptr = l2ptr ;
+ 	    }
+ 	    nptr = pnodeArray[i].nodeList ;
+ 	    if( nptr != (NNODEPTR) NULL ) {
+ 		free( pnodeArray[i].nodeList ) ;
+ 	    }
+ 	}
+ 	for( i = 0 ; i < pnodeAlength ; i++ ) {
+ 	    free( netSegArray[i] ) ;
+ 	}
+ 	free( (PNODEPTR) pnodeArray ) ;
+ 	free( (short int **) netSegArray ) ;
+     }
+     pnodeAlength = pnode ;
+     pnodeArray = (PNODEPTR) malloc( (1 + pnode) * 
+ 				    sizeof(PNODE) ) ;
+     for( i = 1 ; i <= pnode ; i++ ) {
+ 	pnodeArray[i].nodeList = 
+ 			(NNODEPTR) malloc( (1 + numnodes +
+ 			pnode ) * sizeof(NNODE) ) ;
+ 	pnodeArray[i].eptr = 0 ;
+ 	pnodeArray[i].equiv = (LIST2PTR) NULL ;
+     }
+     netSegArray = (short int **) malloc( pnode * 
+ 				sizeof( short int *) ) ;
+     for( i = 0 ; i < pnode ; i++ ) {
+ 	netSegArray[i] = (short int *) 
+ 			malloc( (1 + numnodes + pnode) *
+ 			sizeof( short int ) ) ;
+     }
+ }
+ 
+ procesnet( net , segments , pnode ) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rebin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rebin.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rebin.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,75 ----
+ #include "custom.h"
+ 
+ void rebin(int flag)
+ {
+ 
+ CELLBOXPTR ptr ;
+ TILEBOXPTR tileptr ;
+ int i , j , k , cell ;
+ int startx , endx , starty , endy , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ 
+ for( i = 0 ; i <= numBinsX ; i++ ) {
+     for( j = 0 ; j <= numBinsY ; j++ ) {
+ 	for( k = 0 ; k <= 4 + numcells ; k++ ) {
+ 	    blockarray[i][j][k] = 0 ;
+ 	}
+     }
+ }
+ 
+ for( cell = 1 ; cell <= numcells + numpads + 4 ; cell++ ) {
+     if( cell > numcells && cell <= numcells + numpads ) {
+ 	continue ;
+     }
+     ptr = cellarray[cell] ;
+     tileptr = ptr->config[ptr->orient] ;
+ 
+     startx = ptr->xcenter + tileptr->left ;
+     endx   = ptr->xcenter + tileptr->right;
+     starty = ptr->ycenter + tileptr->bottom ; 
+     endy   = ptr->ycenter + tileptr->top;
+     if( flag == 1 && cell <= numcells ) {
+ 	startx -= tileptr->lborder ;
+ 	endx   += tileptr->rborder ;
+ 	starty -= tileptr->bborder ;
+ 	endy   += tileptr->tborder ;
+     }
+ 
+     lowBinX = (startx - binOffsetX) / binWidthX ;
+     if( lowBinX < 1 ) {
+ 	lowBinX = 1 ;
+     } else if( lowBinX > numBinsX ) {
+ 	lowBinX = numBinsX ;
+     }
+     highBinX = (endx - binOffsetX) / binWidthX ;
+     if( highBinX > numBinsX ) {
+ 	highBinX = numBinsX ;
+     } else if( highBinX < 1 ) {
+ 	highBinX = 1 ;
+     }
+     if( lowBinX == highBinX ) {
+ 	lowBinY = (starty - binOffsetY) / binWidthY ;
+ 	if( lowBinY < 1 ) {
+ 	    lowBinY = 1 ;
+ 	} else if( lowBinY > numBinsY ) {
+ 	    lowBinY = numBinsY ;
+ 	}
+ 	highBinY = (endy - binOffsetY) / binWidthY ;
+ 	if( highBinY > numBinsY ) {
+ 	    highBinY = numBinsY ;
+ 	} else if( highBinY < 1 ) {
+ 	    highBinY = 1 ;
+ 	}
+ 	if( lowBinY == highBinY ) {
+ 	    occuptr = blockarray[lowBinX][lowBinY] ;
+ 	} else {
+ 	    occuptr = bucket ;
+ 	}
+     } else {
+ 	occuptr = bucket ;
+     }
+     occuptr[ ++occuptr[0]] = cell ;
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/reduceg.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/reduceg.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/reduceg.c	Tue Oct  5 16:19:48 2004
***************
*** 0 ****
--- 1,518 ----
+ #include "geo.h"
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property );
+ 
+ void reduceg(void)
+ {
+ 
+ int i , j , min , minc , WCcount , guideline , twoTimes ;
+ int c , count , c1 , c2 , hit , flag , k ;
+ int length , index1 , index2 , i1 , i2 , c2i1 , vertical ;
+ int xmin , xmax , ymin , ymax , end , start , edge ;
+ TNODEPTR node , Qroot ;
+ WCPTR ptr , *WCarray ;
+ 
+ 
+ Qroot = (TNODEPTR) NULL ;
+ WCarray = (WCPTR *) malloc( 101 * sizeof( WCPTR ) ) ;
+ WCcount = 0 ;
+ 
+ for( i = 1 ; i <= eNum ; i++ ) {
+     eArray[i].notActive = 0 ;
+ }
+ for( i = 1 ; i <= numRects ; i++ ) {
+     rectArray[i].ur = 0 ;
+     rectArray[i].lr = 0 ;
+     rectArray[i].ul = 0 ;
+     rectArray[i].ll = 0 ;
+ }
+ 
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     for( ptr = xNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	count = ptr->channels[0] ;
+ 	
+ 	WCcount++ ;
+ 	if( WCcount % 100 == 0 ) {
+ 	    WCarray = (WCPTR *) realloc( WCarray , (WCcount + 100) *
+ 						sizeof( WCPTR ) ) ;
+ 	}
+ 	length = 0 ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    length += eArray[ ptr->channels[c] ].length ;
+ 	}
+ 	length /= count ;
+ 	WCarray[WCcount] = ptr ;
+ 	tinsert( &Qroot , -length , WCcount ) ;
+ 
+ 	index1 = eArray[ ptr->channels[1] ].index1 ;
+ 	index2 = eArray[ ptr->channels[1] ].index2 ;
+ 	rectArray[index2].ll = 1 ;
+ 	rectArray[index1].ul = 1 ;
+ 
+ 	index1 = eArray[ ptr->channels[count] ].index1 ;
+ 	index2 = eArray[ ptr->channels[count] ].index2 ;
+ 	rectArray[index2].lr = 1 ;
+ 	rectArray[index1].ur = 1 ;
+     }
+ }
+ 
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     for( ptr = yNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	count = ptr->channels[0] ;
+ 
+ 	WCcount++ ;
+ 	if( WCcount % 100 == 0 ) {
+ 	    WCarray = (WCPTR *) realloc( WCarray , (WCcount + 100) *
+ 						sizeof( WCPTR ) ) ;
+ 	}
+ 	length = 0 ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    length += eArray[ ptr->channels[c] ].length ;
+ 	}
+ 	length /= count ;
+ 	WCarray[WCcount] = ptr ;
+ 	tinsert( &Qroot , -length , WCcount ) ;
+ 
+ 	index1 = eArray[ ptr->channels[1] ].index1 ;
+ 	index2 = eArray[ ptr->channels[1] ].index2 ;
+ 	rectArray[index2].ll = 1 ;
+ 	rectArray[index1].lr = 1 ;
+ 
+ 	index1 = eArray[ ptr->channels[count] ].index1 ;
+ 	index2 = eArray[ ptr->channels[count] ].index2 ;
+ 	rectArray[index2].ul = 1 ;
+ 	rectArray[index1].ur = 1 ;
+     }
+ }
+ 
+ for( ; ; ) {
+     tpop( &Qroot , &node , &length , &WCcount ) ;
+     if( node == (TNODEPTR) NULL ) {
+ 	break ;
+     }
+     ptr = WCarray[WCcount] ;
+     count = ptr->channels[0] ;
+     if( count == 1 ) {
+ 	continue ;
+     }
+     vertical = (ptr->channels[1] <= edgeTransition) ? 1 : 0 ;
+ 
+     c1 = 1 ;
+     c2 = 1 ;
+     do {
+ 	c2i1 = eArray[ ptr->channels[c2] ].index1 ; 
+ 	if( rectArray[c2i1].ur == 0 ) {
+ 	    c2++ ;
+ 	    continue ;
+ 	}
+ 	guideline = (eArray[ ptr->channels[c2] ].rtside +
+ 		     eArray[ ptr->channels[c1] ].lbside) / 2 ;
+ 	min = 10000000 ;
+ 	if( vertical ) {
+ 	    ymin = 10000000 ;
+ 	    ymax = 0 ;
+ 	    for( c = c1 ; c <= c2 ; c++ ) {
+ 		i1 = eArray[ ptr->channels[c] ].index1 ;
+ 		i2 = eArray[ ptr->channels[c] ].index2 ;
+ 		if( ABS( rectArray[i1].xc - guideline) < min ) {
+ 		    min = ABS( rectArray[i1].xc - guideline) ;
+ 		    minc = c ;
+ 		}
+ 		if( ABS( rectArray[i2].xc - guideline) < min ) {
+ 		    min = ABS( rectArray[i2].xc - guideline) ;
+ 		    minc = c ;
+ 		}
+ 	    }
+ 	} else {
+ 	    xmin = 10000000 ;
+ 	    xmax = 0 ;
+ 	    for( c = c1 ; c <= c2 ; c++ ) {
+ 		i1 = eArray[ ptr->channels[c] ].index1 ;
+ 		i2 = eArray[ ptr->channels[c] ].index2 ;
+ 		if( ABS( rectArray[i1].yc - guideline) < min ) {
+ 		    min = ABS( rectArray[i1].yc - guideline) ;
+ 		    minc = c ;
+ 		}
+ 		if( ABS( rectArray[i2].yc - guideline) < min ) {
+ 		    min = ABS( rectArray[i2].yc - guideline) ;
+ 		    minc = c ;
+ 		}
+ 	    }
+ 	}
+ 	for( c = c1 ; c <= c2 ; c++ ) {
+ 	    i1 = eArray[ ptr->channels[c] ].index1 ;
+ 	    i2 = eArray[ ptr->channels[c] ].index2 ;
+ 	    if( c != minc ) {
+ 		eArray[ ptr->channels[c] ].notActive = 1 ;
+ 	    } else {
+ 		eArray[ ptr->channels[c] ].rtside = 
+ 			    eArray[ ptr->channels[c2] ].rtside ;
+ 		eArray[ ptr->channels[c] ].lbside = 
+ 			    eArray[ ptr->channels[c1] ].lbside ;
+ 	    }
+ 	    if( c == c1 ) {
+ 		if( vertical == 1 ) {
+ 		    rectArray[i1].ur = 1 ;
+ 		    rectArray[i2].lr = 1 ;
+ 		} else {
+ 		    rectArray[i1].ur = 1 ;
+ 		    rectArray[i2].ul = 1 ;
+ 		}
+ 	    }
+ 	    if( c == c2 ) {
+ 		if( vertical == 1 ) {
+ 		    rectArray[i1].ul = 1 ;
+ 		    rectArray[i2].ll = 1 ;
+ 		} else {
+ 		    rectArray[i1].lr = 1 ;
+ 		    rectArray[i2].ll = 1 ;
+ 		}
+ 	    }
+ 	    if( c > c1 && c < c2 ) {
+ 		if( vertical == 1 ) {
+ 		    rectArray[i1].ul = 1 ;
+ 		    rectArray[i1].ur = 1 ;
+ 		    rectArray[i2].ll = 1 ;
+ 		    rectArray[i2].lr = 1 ;
+ 		} else {
+ 		    rectArray[i1].ur = 1 ;
+ 		    rectArray[i1].lr = 1 ;
+ 		    rectArray[i2].ul = 1 ;
+ 		    rectArray[i2].ll = 1 ;
+ 		}
+ 	    }
+ 	}
+ 	c1 = ++c2 ;
+     } while( c2 <= count ) ;
+ }
+ 
+ for( i = 1 ; i <= numRects ; i++ ) {
+     rectArray[i].nedges = 0 ;
+ }
+ 
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     for( ptr = xNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	count = ptr->channels[0] ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    if( eArray[ ptr->channels[c] ].notActive == 1 ) {
+ 		continue ;
+ 	    }
+ 	    index1 = eArray[ ptr->channels[c] ].index1 ;
+ 	    index2 = eArray[ ptr->channels[c] ].index2 ;
+ 	    rectArray[index2].nedges++ ;
+ 	    rectArray[index1].nedges++ ;
+ 	}
+     }
+ }
+ 
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     for( ptr = yNodeArray[i] ; ptr != (WCPTR) NULL ; ptr = ptr->next ){
+ 	if( ptr->fixedWidth == 1 ) {
+ 	    continue ;
+ 	}
+ 	count = ptr->channels[0] ;
+ 	for( c = 1 ; c <= count ; c++ ) {
+ 	    if( eArray[ ptr->channels[c] ].notActive == 1 ) {
+ 		continue ;
+ 	    }
+ 	    index1 = eArray[ ptr->channels[c] ].index1 ;
+ 	    index2 = eArray[ ptr->channels[c] ].index2 ;
+ 	    rectArray[index2].nedges++ ;
+ 	    rectArray[index1].nedges++ ;
+ 	}
+     }
+ }
+ 
+ hit = 1 ;
+ while( hit ) {
+     hit = 0 ;
+     for( i = 1 ; i <= numXnodes ; i++ ) {
+ 	for( ptr = xNodeArray[i]; ptr != (WCPTR) NULL; ptr = ptr->next ){
+ 	    if( ptr->fixedWidth == 1 ) {
+ 		continue ;
+ 	    }
+ 	    count = ptr->channels[0] ;
+ 	    for( c = 1 ; c <= count ; c++ ) {
+ 		if( eArray[ ptr->channels[c] ].notActive == 1 ) {
+ 		    continue ;
+ 		}
+ 		index1 = eArray[ ptr->channels[c] ].index1 ;
+ 		index2 = eArray[ ptr->channels[c] ].index2 ;
+ 
+ 		if( rectArray[index2].nedges == 1 ||
+ 				    rectArray[index1].nedges == 1 ) {
+ 		    eArray[ ptr->channels[c] ].notActive = 1 ;
+ 		    rectArray[index2].nedges-- ;
+ 		    rectArray[index1].nedges-- ;
+ 		    hit = 1 ;
+ 		    flag = 0 ;
+ 		    for( k = 1 ; ; k++ ) {
+ 			if( c + k <= count ) {
+ 			    if( eArray[ ptr->channels[c + k] ].
+ 						    notActive == 0) {
+ 				    flag = 1 ;
+ 				    eArray[ptr->channels[c + k]].lbside -=
+ 					eArray[ ptr->channels[c] ].rtside -
+ 					eArray[ ptr->channels[c] ].lbside ;
+ 			    }
+ 			}
+ 			if( flag ) {
+ 			    break ;
+ 			}
+ 			if( c - k >= 1 ) {
+ 			    if( eArray[ ptr->channels[c - k] ].
+ 						    notActive == 0){
+ 				    flag = 1 ;
+ 				    eArray[ptr->channels[c - k]].rtside +=
+ 					eArray[ ptr->channels[c] ].rtside -
+ 					eArray[ ptr->channels[c] ].lbside ;
+ 			    }
+ 			}
+ 			if( flag ) {
+ 			    break ;
+ 			}
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ 
+     for( i = 1 ; i <= numYnodes ; i++ ) {
+ 	for( ptr = yNodeArray[i]; ptr != (WCPTR) NULL; ptr = ptr->next ){
+ 	    if( ptr->fixedWidth == 1 ) {
+ 		continue ;
+ 	    }
+ 	    count = ptr->channels[0] ;
+ 	    for( c = 1 ; c <= count ; c++ ) {
+ 		if( eArray[ ptr->channels[c] ].notActive == 1 ) {
+ 		    continue ;
+ 		}
+ 		index1 = eArray[ ptr->channels[c] ].index1 ;
+ 		index2 = eArray[ ptr->channels[c] ].index2 ;
+ 		if( rectArray[index2].nedges == 1 ||
+ 				    rectArray[index1].nedges == 1 ) {
+ 		    eArray[ ptr->channels[c] ].notActive = 1 ;
+ 		    rectArray[index2].nedges-- ;
+ 		    rectArray[index1].nedges-- ;
+ 		    hit = 1 ;
+ 		    flag = 0 ;
+ 		    for( k = 1 ; ; k++ ) {
+ 			if( c + k <= count ) {
+ 			    if( eArray[ ptr->channels[c + k] ].
+ 						    notActive == 0) {
+ 				    flag = 1 ;
+ 				    eArray[ptr->channels[c + k]].lbside -=
+ 					eArray[ ptr->channels[c] ].rtside -
+ 					eArray[ ptr->channels[c] ].lbside ;
+ 			    }
+ 			}
+ 			if( flag ) {
+ 			    break ;
+ 			}
+ 			if( c - k >= 1 ) {
+ 			    if( eArray[ ptr->channels[c - k] ].
+ 						    notActive == 0){
+ 				    flag = 1 ;
+ 				    eArray[ptr->channels[c - k]].rtside +=
+ 					eArray[ ptr->channels[c] ].rtside -
+ 					eArray[ ptr->channels[c] ].lbside ;
+ 			    }
+ 			}
+ 			if( flag ) {
+ 			    break ;
+ 			}
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ 
+ 
+ for( twoTimes = 1 ; twoTimes <= 2 ; twoTimes++ ) {
+     for( i = 1 ; i <= numXnodes ; i++ ) {
+ 	for( ptr = xNodeArray[i] ; ptr != (WCPTR) NULL ; 
+ 						ptr = ptr->next ){
+ 	    if( ptr->fixedWidth == 1 ) {
+ 		continue ;
+ 	    }
+ 	    count = ptr->channels[0] ;
+ 	    if( count <= 1 ) {
+ 		continue ;
+ 	    }
+ 	    
+ 	    if( eArray[ ptr->channels[1] ].notActive == 1 ) {
+ 		i2 = eArray[ ptr->channels[1] ].index2 ;
+ 		i1 = eArray[ ptr->channels[1] ].index1 ;
+ 		edge = eArray[ ptr->channels[1] ].edge1 ;
+ 		start = edgeList[edge].start ;
+ 		end   = edgeList[edge].end ;
+ 		ymax = rectArray[i2].yc ;
+ 		ymin = rectArray[i1].yc ;
+ 		for( c = 2 ; c <= count ; c++ ) {
+ 		    if( eArray[ ptr->channels[c] ].notActive == 0 ) {
+ 			i1 = eArray[ ptr->channels[c] ].index1 ;
+ 			i2 = eArray[ ptr->channels[c] ].index2 ;
+ 			if( rectArray[i2].yc < ymax ) {
+ 			    j = eArray[ ptr->channels[1] ].index2 ;
+ 			    if( rectArray[j].t < end &&
+ 					rectArray[j].yreset == 0 ) {
+ 				rectArray[j].yc = rectArray[i2].yc ;
+ 				rectArray[j].yreset = 1 ;
+ 			    } else if( rectArray[i2].yc < end ) { 
+ 				rectArray[i2].yc = end ;
+ 			    }
+ 			}
+ 			if( rectArray[i1].yc > ymin ) {
+ 			    j = eArray[ ptr->channels[1] ].index1 ;
+ 			    if( start < rectArray[j].b &&
+ 					rectArray[j].yreset == 0 ) {
+ 				rectArray[j].yc = rectArray[i1].yc ;
+ 				rectArray[j].yreset = 1 ;
+ 			    } else if( start < rectArray[i1].yc ) {
+ 				rectArray[i1].yc = start ;
+ 			    }
+ 			}
+ 			break ;
+ 		    }
+ 		}
+ 	    }
+ 	    if( eArray[ ptr->channels[count] ].notActive == 1 ) {
+ 		i2 = eArray[ ptr->channels[count] ].index2 ;
+ 		i1 = eArray[ ptr->channels[count] ].index1 ;
+ 		edge = eArray[ ptr->channels[count] ].edge2 ;
+ 		start = edgeList[edge].start ;
+ 		end   = edgeList[edge].end ;
+ 		ymax = rectArray[i2].yc ;
+ 		ymin = rectArray[i1].yc ;
+ 		for( c = count - 1 ; c >= 1 ; c-- ) {
+ 		    if( eArray[ ptr->channels[c] ].notActive == 0 ) {
+ 			i1 = eArray[ ptr->channels[c] ].index1 ;
+ 			i2 = eArray[ ptr->channels[c] ].index2 ;
+ 			if( rectArray[i2].yc < ymax ) {
+ 			    j = eArray[ ptr->channels[count] ].index2 ;
+ 			    if( rectArray[j].t < end &&
+ 					rectArray[j].yreset == 0 ) {
+ 				rectArray[j].yc = rectArray[i2].yc ;
+ 				rectArray[j].yreset = 1 ;
+ 			    } else if( rectArray[i2].yc < end ) { 
+ 				rectArray[i2].yc = end ;
+ 			    }
+ 			}
+ 			if( rectArray[i1].yc > ymin ) {
+ 			    j = eArray[ ptr->channels[count] ].index1 ;
+ 			    if( start < rectArray[j].b &&
+ 					rectArray[j].yreset == 0 ) {
+ 				rectArray[j].yc = rectArray[i1].yc ;
+ 				rectArray[j].yreset = 1 ;
+ 			    } else if( start < rectArray[i1].yc ) {
+ 				rectArray[i1].yc = start ;
+ 			    }
+ 			}
+ 			break ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ 
+     for( i = 1 ; i <= numYnodes ; i++ ) {
+ 	for( ptr = yNodeArray[i] ; ptr != (WCPTR) NULL ; 
+ 					    ptr = ptr->next ){
+ 	    if( ptr->fixedWidth == 1 ) {
+ 		continue ;
+ 	    }
+ 	    count = ptr->channels[0] ;
+ 	    if( count <= 1 ) {
+ 		continue ;
+ 	    }
+ 
+ 	    if( eArray[ ptr->channels[1] ].notActive == 1 ) {
+ 		i2 = eArray[ ptr->channels[1] ].index2 ;
+ 		i1 = eArray[ ptr->channels[1] ].index1 ;
+ 		edge = eArray[ ptr->channels[1] ].edge1 ;
+ 		start = edgeList[edge].start ;
+ 		end   = edgeList[edge].end ;
+ 		xmax = rectArray[i2].xc ;
+ 		xmin = rectArray[i1].xc ;
+ 		for( c = 2 ; c <= count ; c++ ) {
+ 		    if( eArray[ ptr->channels[c] ].notActive == 0 ) {
+ 			i1 = eArray[ ptr->channels[c] ].index1 ;
+ 			i2 = eArray[ ptr->channels[c] ].index2 ;
+ 			if( rectArray[i2].xc < xmax ) {
+ 			    j = eArray[ ptr->channels[1] ].index2 ;
+ 			    if( rectArray[j].r < end &&
+ 					rectArray[j].xreset == 0 ) {
+ 				rectArray[j].xc = rectArray[i2].xc ;
+ 				rectArray[j].xreset = 1 ;
+ 			    } else if( rectArray[i2].xc < end ) { 
+ 				rectArray[i2].xc = end ;
+ 			    }
+ 			}
+ 			if( rectArray[i1].xc > xmin ) {
+ 			    j = eArray[ ptr->channels[1] ].index1 ;
+ 			    if( start < rectArray[j].l &&
+ 					rectArray[j].xreset == 0 ) {
+ 				rectArray[j].xc = rectArray[i1].xc ;
+ 				rectArray[j].xreset = 1 ;
+ 			    } else if( start < rectArray[i1].xc ) {
+ 				rectArray[i1].xc = start ;
+ 			    }
+ 			}
+ 			break ;
+ 		    }
+ 		}
+ 	    }
+ 	    if( eArray[ ptr->channels[count] ].notActive == 1 ) {
+ 		i2 = eArray[ ptr->channels[count] ].index2 ;
+ 		i1 = eArray[ ptr->channels[count] ].index1 ;
+ 		edge = eArray[ ptr->channels[count] ].edge2 ;
+ 		start = edgeList[edge].start ;
+ 		end   = edgeList[edge].end ;
+ 		xmax = rectArray[i2].xc ;
+ 		xmin = rectArray[i1].xc ;
+ 		for( c = count - 1 ; c >= 1 ; c-- ) {
+ 		    if( eArray[ ptr->channels[c] ].notActive == 0 ) {
+ 			i1 = eArray[ ptr->channels[c] ].index1 ;
+ 			i2 = eArray[ ptr->channels[c] ].index2 ;
+ 			if( rectArray[i2].xc < xmax ) {
+ 			    j = eArray[ ptr->channels[count] ].index2 ;
+ 			    if( rectArray[j].r < end &&
+ 					rectArray[j].xreset == 0 ) {
+ 				rectArray[j].xc = rectArray[i2].xc ;
+ 				rectArray[j].xreset = 1 ;
+ 			    } else if( rectArray[i2].xc < end ) { 
+ 				rectArray[i2].xc = end ;
+ 			    }
+ 			}
+ 			if( rectArray[i1].xc > xmin ) {
+ 			    j = eArray[ ptr->channels[count] ].index1 ;
+ 			    if( start < rectArray[j].l &&
+ 					rectArray[j].xreset == 0 ) {
+ 				rectArray[j].xc = rectArray[i1].xc ;
+ 				rectArray[j].xreset = 1 ;
+ 			    } else if( start < rectArray[i1].xc ) {
+ 				rectArray[i1].xc = start ;
+ 			    }
+ 			}
+ 			break ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rglobals.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rglobals.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rglobals.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,98 ----
+ #include "port.h"
+ 
+ typedef struct chanbox {
+     int from ;
+     int to ;
+     int foffset ;
+     int toffset ;
+     struct chanbox *next ;
+ } CHANBOX, *CHANBOXPTR ;
+ 
+ typedef struct altbox {
+     int *pinList ;
+     int distance ;
+     CHANBOXPTR chanList ;
+ } ALTBOX , *ALTBOXPTR ;
+ 
+ typedef struct nrbox {
+     ALTBOXPTR *alternate ;
+     int numRoutes ;
+     int currentRoute ;
+     int newRoute ;
+ } NRBOX , *NRBOXPTR ;
+ 
+ typedef struct gnode {
+     int node ;
+     int ilength ;
+     int length ;
+     int cost ;
+     int capacity ;
+     int inactive ;
+     int einactive ;
+     struct gnode *next ;
+ } GNODE , *GNODEPTR ;
+ 
+ typedef struct nnode {
+     int temp ;
+     int distance ;
+     short int from ;
+     short int from2 ;
+ } NNODE , *NNODEPTR ;
+ 
+ typedef struct list2 {
+     int node ;
+     struct list2 *next ;
+ } LIST2 , *LIST2PTR ;
+ 
+ typedef struct pnode {
+     int eptr ;
+     NNODEPTR nodeList ;
+     LIST2PTR equiv ;
+ } PNODE , *PNODEPTR ;
+ 
+ typedef struct quad {
+     int PorE ;
+     int node1 ;
+     int node2 ;
+     int distance ;
+     struct quad *next ;
+     struct quad *prev ;
+ } QUAD, *QUADPTR ;
+ 
+ typedef struct path {
+     short int *nodeset ;
+     int p ;
+     int q ; 
+     int excluded ;
+     int exlist[5] ;
+ } PATH, *PATHPTR ;
+ 
+ short int *tempArray ;
+ GNODEPTR *gnodeArray ;
+ PNODEPTR pnodeArray ;
+ int numnodes ;
+ int numpins ;
+ int maxpnode ;
+ char **pnameArray ;
+ char **nnameArray ;
+ int *pinOffset ;
+ QUADPTR pinlist ;
+ int **pathList ;
+ short int **netSegArray ;
+ short int *segList ;
+ int segPtr ;
+ short int *sourceList ;
+ int sourcePtr ;
+ short int *targetList ;
+ int targetPtr ;
+ int Mpaths ;
+ short int *delSourceList ;
+ short int *addTargetList ;
+ int pathLength ;
+ short int **savePaths ;
+ int largestNet ;
+ NRBOXPTR netRoutes ;
+ short int **gtrace ;
+ PATHPTR pathArray ;
+ int MAXPATHS ;
+ int EXTRASOURCES;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rmain.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rmain.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/rmain.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,231 ----
+ #include "route.h"
+ #include "geo.h"
+ extern int doChannelGraph ;
+ extern int doCompaction ;
+ extern int finalShot ;
+ extern int routerMaxPaths ;
+ extern int routerExtraS ;
+ extern int bareFlag ;
+ extern int pnodeAlength ;
+ int bareMinimum ;
+ 
+ extern void readgraph( FILE *fp );
+ extern void readpnode( FILE *fp );
+ extern void printnets(void);
+ extern void density(void);
+ extern void bellman(void);
+ extern void tpop(TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ void rmain(void)
+ {
+ 
+ FILE *fp;
+ char filename[1024] ;
+ GNODEPTR gptr , g2ptr ;
+ QUADPTR qptr , tmpqptr ;
+ CHANBOXPTR cptr , c2ptr ;
+ NNODEPTR nptr ;
+ TNODEPTR tnode ;
+ LIST2PTR lptr , l2ptr ;
+ WCPTR wcptr , wc2ptr ;
+ int i , j , dummy1 , dummy2 ;
+ 
+ 
+ 
+ if( finalShot == doCompaction ) {
+     if( bareFlag == 0 ) {
+ 	MAXPATHS = routerMaxPaths ;
+ 	EXTRASOURCES = routerExtraS ;
+ 	bareMinimum = 0 ;
+     } else {
+ 	MAXPATHS = 1 ;
+ 	EXTRASOURCES = 1 ;
+ 	bareMinimum = 1 ;
+     }
+ } else {
+     MAXPATHS = 1 ;
+     EXTRASOURCES = 1 ;
+     bareMinimum = 1 ;
+ }
+ 
+ 
+ sprintf( filename , "%s.gph" , cktName ) ;
+ if( (fp = fopen ( filename , "r")) == (FILE *) NULL ) {
+     fprintf(fpo,"Error: file: %s not present\n", filename );
+     exit(0);
+ }
+ readgraph( fp ) ;
+ 
+ sprintf( filename , "%s.twf" , cktName ) ;
+ if( (fp = fopen ( filename , "r")) == (FILE *) NULL ) {
+     printf("can't open %s\n", filename ) ;
+     exit(0);
+ }
+ readpnode( fp ) ;
+ 
+ printnets() ;
+ 
+ if( doChannelGraph ) {
+     density() ;
+     bellman() ;
+ }
+ 
+ 
+ 
+ 
+ /*   ***************************************   */
+ /*   EVERYTHING BELOW IS CLEAN-UP OPERATIONS   */
+ /*   ***************************************   */
+ fclose(fp);
+ 
+ 
+ /*  We will want to remove this if we implement the s.a.
+     for the various net routes
+ */
+ for( i = 1 ; i <= eNum ; i++ ) {
+     if( eArray[i].root != (TNODEPTR) NULL ) {
+ 	for( ; ; ) {
+ 	    tpop( &eArray[i].root , &tnode , &dummy1 , &dummy2 ) ;
+ 	    if( tnode == (TNODEPTR) NULL ) {
+ 		break ;
+ 	    }
+ 	}
+     }
+ }
+ free( eArray ) ;
+ 
+ for( i = 1 ; i <= numRects ; i++ ) {
+     free( eIndexArray[i] ) ;
+ }
+ free( eIndexArray ) ;
+ 
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     wcptr = xNodeArray[i] ;
+     while( wcptr != (WCPTR) NULL ) {
+ 	if( wcptr->channels != (int *) NULL ) {
+ 	    free( wcptr->channels ) ;
+ 	}
+ 	wc2ptr = wcptr->next ;
+ 	free( wcptr ) ;
+ 	wcptr = wc2ptr ;
+     }
+ }
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     wcptr = yNodeArray[i] ;
+     while( wcptr != (WCPTR) NULL ) {
+ 	if( wcptr->channels != (int *) NULL ) {
+ 	    free( wcptr->channels ) ;
+ 	}
+ 	wc2ptr = wcptr->next ;
+ 	free( wcptr ) ;
+ 	wcptr = wc2ptr ;
+     }
+ }
+ free( xNodeArray ) ;
+ free( yNodeArray ) ;
+ 
+ free( edgeList ) ;
+ 
+ 
+ free( xBellArray ) ;
+ free( yBellArray ) ;
+ 
+ for( i = 1 ; i <= pnodeAlength ; i++ ) {
+     lptr = pnodeArray[i].equiv ;
+     while( lptr != (LIST2PTR) NULL ) {
+ 	l2ptr = lptr->next ;
+ 	free( lptr ) ;
+ 	lptr = l2ptr ;
+     }
+     nptr =  pnodeArray[i].nodeList ;
+     if( nptr != (NNODEPTR) NULL ) {
+ 	free( pnodeArray[i].nodeList ) ;
+     }
+ }
+ free( pnodeArray ) ;
+ 
+ for( i = 1 ; i <= numnodes + maxpnode ; i++ ) {
+     gptr = gnodeArray[i] ;
+     while( gptr != (GNODEPTR) NULL ) {
+ 	g2ptr = gptr->next ;
+ 	free( gptr ) ;
+ 	gptr = g2ptr ;
+     }
+ }
+ free( gnodeArray ) ;
+ 
+ 
+ 
+ for( i = 1 ; i <= 4 ; i++ ) {
+     free( gtrace[i] );
+ }
+ free( gtrace );
+ 
+ for( i = 1 ; i <= largestNet ; i++ ) {
+     for( j = 1 ; j <= MAXPATHS ; j++ ) {
+ 	cptr = netRoutes[i].alternate[j]->chanList ;
+ 	while( cptr != (CHANBOXPTR) NULL ) {
+ 	    c2ptr = cptr->next ;
+ 	    free( cptr ) ;
+ 	    cptr = c2ptr ;
+ 	}
+ 	free( netRoutes[i].alternate[j]->pinList ) ;
+ 	free( netRoutes[i].alternate[j] ) ;
+     }
+     free( netRoutes[i].alternate ) ;
+ }
+ free( netRoutes );
+ 
+ for( i = 1 ; i <= 2 * MAXPATHS ; i++ ) {
+     free( savePaths[i] ) ; 
+ }
+ free( savePaths ) ;
+ 
+ for( i = 1 ; i <= numpins ; i++ ) {
+     if( pnameArray[i] != (char *) NULL ) {
+ 	free( pnameArray[i] ) ;
+     }
+ }
+ free( pnameArray ) ;
+ 
+ for( i = 1 ; i <= largestNet ; i++ ) {
+     if( nnameArray[i] != (char *) NULL ) {
+ 	free( nnameArray[i] ) ;
+     }
+ }
+ free( nnameArray ) ;
+ 
+ free( pinOffset ) ;
+ 
+ free( segList ) ;
+ 
+ for( i = 0 ; i < pnodeAlength ; i++ ) {
+     free( netSegArray[i] ) ;
+ }
+ free( netSegArray ) ;
+ 
+ free( sourceList ) ; 
+ free( targetList ) ; 
+ free( delSourceList ) ; 
+ free( addTargetList ) ;
+ 
+ for( i = 1 ; i <= EXTRASOURCES * MAXPATHS ; i++ ) {
+     free( pathList[i] ) ;
+ }
+ free( pathList ) ;
+ 
+ for( i = 1 ; i <= 2 + 2 * MAXPATHS ; i++ ) {
+     free( pathArray[i].nodeset ) ;
+ }
+ free( pathArray ) ;
+ 
+ free( tempArray ) ;
+ 
+ for( qptr = pinlist ; qptr != (QUADPTR) NULL ; ) {
+     tmpqptr = qptr->next ;
+     free( qptr ) ;
+     qptr = tmpqptr ;
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/route.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/route.h:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/route.h	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,102 ----
+ #include "port.h"
+ 
+ #define VLARGE 1000000000
+ 
+ typedef struct chanbox {
+     int from ;
+     int to ;
+     int foffset ;
+     int toffset ;
+     struct chanbox *next ;
+ } CHANBOX, *CHANBOXPTR ;
+ 
+ typedef struct altbox {
+     int *pinList ;
+     int distance ;
+     CHANBOXPTR chanList ;
+ } ALTBOX , *ALTBOXPTR ;
+ 
+ typedef struct nrbox {
+     ALTBOXPTR *alternate ;
+     int numRoutes ;
+     int currentRoute ;
+     int newRoute ;
+ } NRBOX , *NRBOXPTR ;
+ 
+ typedef struct gnode {
+     int node ;
+     int ilength ;
+     int length ;
+     int cost ;
+     int capacity ;
+     int inactive ;
+     int einactive ;
+     struct gnode *next ;
+ } GNODE , *GNODEPTR ;
+ 
+ typedef struct nnode {
+     int temp ;
+     int distance ;
+     short int from ;
+     short int from2 ;
+ } NNODE , *NNODEPTR ;
+ 
+ typedef struct list2 {
+     int node ;
+     struct list2 *next ;
+ } LIST2 , *LIST2PTR ;
+ 
+ typedef struct pnode {
+     int eptr ;
+     NNODEPTR nodeList ;
+     LIST2PTR equiv ;
+ } PNODE , *PNODEPTR ;
+ 
+ typedef struct quad {
+     int PorE ;
+     int node1 ;
+     int node2 ;
+     int distance ;
+     struct quad *next ;
+     struct quad *prev ;
+ } QUAD, *QUADPTR ;
+ 
+ typedef struct path {
+     short int *nodeset ;
+     int p ;
+     int q ; 
+     int excluded ;
+     int exlist[5] ;
+ } PATH, *PATHPTR ;
+ 
+ extern short int *tempArray ;
+ extern GNODEPTR *gnodeArray ;
+ extern PNODEPTR pnodeArray ;
+ extern int numnodes ;
+ extern int numpins ;
+ extern char *cktName ;
+ extern int maxpnode ;
+ extern char **pnameArray ;
+ extern char **nnameArray ;
+ extern int *pinOffset ;
+ extern QUADPTR pinlist ;
+ extern FILE *fpo ;
+ extern int **pathList ;
+ extern short int **netSegArray ;
+ extern short int *segList ;
+ extern int segPtr ;
+ extern short int *sourceList ;
+ extern int sourcePtr ;
+ extern short int *targetList ;
+ extern int targetPtr ;
+ extern int Mpaths ;
+ extern short int *delSourceList ;
+ extern short int *addTargetList ;
+ extern int pathLength ;
+ extern short int **savePaths ;
+ extern int largestNet ;
+ extern NRBOXPTR netRoutes ;
+ extern short int **gtrace ;
+ extern PATHPTR pathArray ;
+ extern int MAXPATHS ;
+ extern int EXTRASOURCES ;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/routenet.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/routenet.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/routenet.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,572 ----
+ /* #define DEBUG1 */
+ /* #define DEBUG2 */
+ #include "route.h"
+ #include "23tree.h"
+ extern TNODEPTR netRoot ;
+ TNODEPTR indexRoot ;
+ int treeSize ;
+ int pathIndex ;
+ extern int bareMinimum ;
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ extern void recursePath( int dsptr , int atptr , int attachPt, int addEquivs);
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ extern int mshortest( int source , int soleTarget );
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ extern void tmax( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ 
+ void routenet( int segments , int numpnodes )
+ {
+ 
+ int i , j , savei , min , count , node , node1 , bareflag ;
+ GNODEPTR gptr , gptr1 ; 
+ NNODEPTR nptr ;
+ LIST2PTR lptr ;
+ TNODEPTR tptr ;
+ 
+ 
+ if( segments > 2 ) {
+ 
+     i = MAXPATHS / (segments - 1) ;
+     Mpaths = ( i > 1 ) ? i : 1 ;
+ 
+     while( (pow( (double) Mpaths , (double)(segments - 1) ) > 
+ 			    80.0 * (double) MAXPATHS ) && (Mpaths > 1) ) {
+ 	Mpaths-- ;
+     }
+ } else {
+     Mpaths = 1 ;
+ }
+ 
+ bareflag = 0 ;
+ if( Mpaths == 1 && segments > 19 ) {
+     if( bareMinimum == 0 ) {
+ 	bareMinimum = 1 ;
+ 	bareflag = 1 ;
+     }
+ }
+ 
+ indexRoot = (TNODEPTR) NULL ;
+ treeSize = 0 ;
+ for( i = 1 ; i <= 2 * MAXPATHS ; i++ ) {
+     tinsert( &indexRoot , i , 0 ) ;
+ }
+ 
+ for( i = 1 ; i <= numpnodes ; i++ ) {
+     sourceList[i] = i + numnodes ;
+     delSourceList[i] = 0 ;
+ }
+ sourcePtr = numpnodes ;
+ for( i = 1 ; i <= numnodes + numpnodes ; i++ ) {
+     targetList[i] = 0 ;
+     addTargetList[i] = 0 ;
+ }
+ targetPtr = 0 ;
+ segPtr = 0 ;
+ 
+ min = VLARGE ;
+ for( i = 1 + numnodes ; i <= numpnodes + numnodes ; i++ ) {
+     nptr = pnodeArray[ i - numnodes ].nodeList ;
+     for( j = 1 + numnodes ; j <= numpnodes + numnodes ; j++ ) {
+ 	if( i == j ) {
+ 	    continue ;
+ 	}
+ 	if( (pnodeArray[i - numnodes].eptr != 0) && 
+ 			    (pnodeArray[j - numnodes].eptr != 0) ) {
+ 	    if( pnodeArray[i - numnodes].eptr == 
+ 				pnodeArray[j - numnodes].eptr ) {
+ 		continue ;
+ 	    }
+ 	} else if( (pnodeArray[i - numnodes].eptr == 0) && 
+ 			    (pnodeArray[j - numnodes].eptr == 0) ) {
+ 	} else {
+ 	    if( pnodeArray[i - numnodes].eptr != 0 ) {
+ 		if( pnodeArray[i - numnodes].eptr == j - numnodes ) {
+ 		    continue ;
+ 		}
+ 	    } else {
+ 		if( pnodeArray[j - numnodes].eptr == i - numnodes ) {
+ 		    continue ;
+ 		}
+ 	    }
+ 	}
+ 
+ 	if( nptr[j].distance < min ) {
+ 	    min = nptr[j].distance ;
+ 	    savei = i ;
+ 	}
+     }
+ }
+ pathLength = 0 ;
+ pathIndex = 0 ;
+ delSourceList[1] = savei ;
+ addTargetList[1] = savei ;
+ 
+ count = 0 ;
+ if( pnodeArray[ savei - numnodes ].eptr != 0 ) {
+     count = 1 ;
+     node = pnodeArray[ savei - numnodes ].eptr + numnodes ;
+     delSourceList[2] = node ;
+     addTargetList[2] = node ;
+     lptr = pnodeArray[ pnodeArray[ savei - numnodes ].eptr ].equiv ;
+     while( lptr != (LIST2PTR) NULL ) {
+ 	node = lptr->node + numnodes ;
+ 	if( node == savei ) {
+ 	    lptr = lptr->next ;
+ 	    continue ;
+ 	}
+ 	delSourceList[ ++count + 1 ] = node ;
+ 	addTargetList[ count + 1 ] = node ;
+ 	lptr = lptr->next ;
+     }
+ } else {
+     lptr = pnodeArray[ savei - numnodes ].equiv ;
+     while( lptr != (LIST2PTR) NULL ) {
+ 	node = lptr->node + numnodes ;
+ 	delSourceList[ ++count + 1 ] = node ;
+ 	addTargetList[ count + 1 ] = node ;
+ 	lptr = lptr->next ;
+     }
+ }
+ 
+ for( i = 1 ; i <= count + 1 ; i++ ) {
+     node = addTargetList[i] ;
+     gptr = gnodeArray[node] ;
+     for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	node1 = gptr->node ;
+ 	gptr1 = gnodeArray[node1] ;
+ 	for( ; ; ) {
+ 	    if( gptr1->node == node ) {
+ 		gptr1->einactive = 1 ;
+ 		break ;
+ 	    }
+ 	    gptr1 = gptr1->next ;
+ 	}
+     }
+ }
+ 
+ recursePath( count + 1 , 0 , 0 , count + 1 ) ;
+ 
+ for( i = 1 ; i <= count + 1 ; i++ ) {
+     node = addTargetList[i] ;
+     gptr = gnodeArray[node] ;
+     for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	node1 = gptr->node ;
+ 	gptr1 = gnodeArray[node1] ;
+ 	for( ; ; ) {
+ 	    if( gptr1->node == node ) {
+ 		gptr1->einactive = 0 ;
+ 		break ;
+ 	    }
+ 	    gptr1 = gptr1->next ;
+ 	}
+     }
+ }
+ if( indexRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &indexRoot , &tptr , &i , &j ) ;
+ 	if( tptr == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ if( bareflag == 1 ) {
+     bareMinimum = 0 ;
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void recursePath( int dsptr , int atptr , int attachPt, int addEquivs )
+ {
+ 
+ int i , j , k , l , min , dnode , savei , node , node1 , node2 , t ;
+ int numberPaths , count , numadd ;
+ int numdelete , junk , c , value , index , found , savej ;
+ int extraS , numExtra , s , *extraSlist , x ;
+ short int *dslist , *atlist ;
+ int **tempPL , pathExists , targ , from ;
+ NNODEPTR nptr ;
+ TNODEPTR junkptr , extraRoot ;
+ GNODEPTR gptr , g1ptr , gptr1 , gptr2 ;
+ LIST2PTR lptr ;
+ 
+ #ifdef DEBUG1
+ printf("\n\nTarget List:\n");
+ for( i = 1 ; i <= targetPtr ; i++ ) {
+     printf(" %d ", targetList[i] ) ;
+ }
+ printf("\n");
+ printf("add to targets:\n");
+ for( i = 1 ; i <= atptr + addEquivs ; i++ ) {
+     printf(" %d ", addTargetList[i] ) ;
+ }
+ printf("\n");
+ fflush(stdout);
+ #endif
+ 
+ if( sourcePtr - dsptr == 0 ) {
+     tpop( &indexRoot , &junkptr , &pathIndex , &junk ) ;
+     savePaths[pathIndex][0] = segPtr ;
+     for( i = 1 ; i <= segPtr ; i++ ) {
+ 	savePaths[pathIndex][i] = segList[i] ;
+     }
+ #ifdef DEBUG1
+     printf("pathLength:%d  pathIndex:%d\n", pathLength, pathIndex);
+     for( i = 1 ; i <= segPtr ; i++ ) {
+ 	printf(" %d ", savePaths[pathIndex][i] );
+     }
+     printf("\n");
+     fflush(stdout);
+ #endif
+     tinsert( &netRoot , pathLength , pathIndex ) ;
+     treeSize++ ;
+     return ;
+ }
+ 
+ extraRoot = (TNODEPTR) NULL ;
+ 
+ extraSlist = (int *) malloc( (1 + EXTRASOURCES) * sizeof(int) ) ;
+ tempPL = (int **) malloc((1 + EXTRASOURCES * MAXPATHS) * sizeof(int *));
+ for( i = 1 ; i <= EXTRASOURCES * MAXPATHS ; i++ ) {
+     tempPL[i] = (int *) malloc( 21 * sizeof(int));
+     for( j = 0 ; j <= 20 ; j++ ) {
+ 	tempPL[i][j] = 0 ;
+     }
+ }
+ 
+ dslist = (short int *) malloc( (1 + dsptr) * sizeof(short int) ) ;
+ for( i = 1 ; i <= dsptr ; i++ ) {
+     dslist[i] = delSourceList[i] ;
+ }
+ atlist = (short int *) malloc( (1 + atptr + addEquivs) * 
+ 						sizeof(short int) ) ;
+ for( i = 1 ; i <= atptr + addEquivs ; i++ ) {
+     atlist[i] = addTargetList[i] ;
+ }
+ 
+ 
+ #ifdef DEBUG2
+ printf("Deleted Source Node List:\n");
+ for( i = 1 ; i <= dsptr ; i++ ) {
+     printf(" %d ", dslist[i] ) ;
+ }
+ printf("\nSource Node List (BEFORE):\n");
+ for( i = 1 ; i <= sourcePtr ; i++ ) {
+     printf(" %d ", sourceList[i] ) ;
+ }
+ fflush(stdout);
+ #endif
+ 
+ for( j = 1 ; j <= dsptr ; j++ ) {
+     dnode = dslist[j] ;
+     for( i = 1 ; i <= sourcePtr ; i++ ) {
+ 	if( sourceList[i] == dnode ) {
+ 	    sourceList[i] = sourceList[sourcePtr--] ;
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ #ifdef DEBUG2
+ printf("\nSource Node List (AFTER):\n");
+ for( i = 1 ; i <= sourcePtr ; i++ ) {
+     printf(" %d ", sourceList[i] ) ;
+ }
+ fflush(stdout);
+ #endif
+ 
+ 
+ for( j = 1 ; j <= atptr + addEquivs ; j++ ) {
+     targetList[++targetPtr] = atlist[j] ;
+ }
+ 
+ if( attachPt > 0 ) {
+     for( j = 1 ; j <= atptr ; j++ ) {
+ 	node1 = atlist[j] ;
+ 	if( j == atptr ) {
+ 	    node2 = attachPt ;
+ 	} else {
+ 	    node2 = atlist[ j + 1 ] ;
+ 	}
+ 	gptr1 = gnodeArray[ node1 ] ;
+ 	gptr2 = gnodeArray[ node2 ] ;
+ 	gptr = gptr1 ;
+ 	while( gptr != (GNODEPTR) NULL ) {
+ 	    if( gptr->node == node2 ) {
+ 		gptr->cost = VLARGE ;
+ 		break ;
+ 	    }
+ 	    gptr = gptr->next ;
+ 	}
+ 	gptr = gptr2 ;
+ 	while( gptr != (GNODEPTR) NULL ) {
+ 	    if( gptr->node == node1 ) {
+ 		gptr->cost = VLARGE ;
+ 		break ;
+ 	    }
+ 	    gptr = gptr->next ;
+ 	}
+     }
+ }
+ /* ************************************************************** */
+ 
+ numExtra = 0 ;
+ numberPaths = 0 ;
+ for( extraS = 1 ; extraS <= EXTRASOURCES ; extraS++ ) {
+     if( extraS > 1 && bareMinimum ) {
+ 	break ;
+     }
+     min = VLARGE ;
+     found = 0 ;
+     for( i = 1 ; i <= sourcePtr ; i++ ) {
+ 	for( s = 1 ; s <= numExtra ; s++ ) {
+ 	    if( extraSlist[s] == sourceList[i] ) {
+ 		break ;
+ 	    }
+ 	}
+ 	if( s <= numExtra ) {
+ 	    continue ;
+ 	}
+ 	found = 1 ;
+ 	node = sourceList[i] - numnodes ;
+ 	nptr = pnodeArray[node].nodeList ;
+ 	for( j = 1 ; j <= targetPtr ; j++ ) {
+ 	    targ = targetList[j] ;
+ 	    if( nptr[ targ ].distance < min ) {
+ 
+ 		from = nptr[targ].from ;
+ 		pathExists = 0 ;
+ 		g1ptr = gnodeArray[ targ ] ;
+ 		for( ; pathExists == 0 && g1ptr != (GNODEPTR) NULL ; 
+ 						g1ptr = g1ptr->next ){
+ 		    node = g1ptr->node ;
+ 		    if( node != from ) {
+ 			continue ;
+ 		    }
+ 		    gptr = gnodeArray[node] ;
+ 		    for( ; ; ) {
+ 			if( gptr->node == targ ) {
+ 			    if( gptr->cost < VLARGE ) {
+ 				pathExists = 1 ;
+ 			    }
+ 			    break ;
+ 			}
+ 			gptr = gptr->next ;
+ 		    }
+ 		}
+ 
+ 		if( pathExists ) {
+ 		    min = nptr[ targ ].distance ;
+ 		    savei = sourceList[i] ;
+ 		    savej = j ;
+ 		}
+ 	    }
+ 	}
+     }
+     if( found == 1 ) {
+ 	extraSlist[ ++numExtra ] = savei ;
+ 
+ #ifdef DEBUG2
+ 	printf("\nselected source node: %d\n", savei ) ;
+ 	fflush(stdout);
+ #endif
+ 
+ 	i = numberPaths ;
+ 	numberPaths += mshortest( savei , savej ) ;
+ 	for( i++, l = 1 ; i <= numberPaths ; i++, l++ ) {
+ 	    if( pathList[l][0] + 1 > 20 ) {
+ 		free( (int *) tempPL[i] ) ;
+ 		tempPL[i] = (int *) malloc( (pathList[l][0] + 2) *
+ 						sizeof(int));
+ 	    }
+ 	    for( j = 0 ; j <= pathList[l][0] + 1 ; j++ ) {
+ 		tempPL[i][j] = pathList[l][j] ;
+ 	    }
+ 	    tinsert( &extraRoot , tempPL[i][j - 1] , i ) ;
+ 	}
+     }
+ }
+ /* ************************************************************** */
+ s = ( numberPaths >= Mpaths ) ? Mpaths : numberPaths ;
+ for( l = 1 ; l <= s ; l++ ) {
+     tpop( &extraRoot , &junkptr , &junk , &j ) ;
+     k = tempPL[j][0] ;
+ 
+ #ifdef DEBUG2
+     printf("Spill it: ");
+     for( i = 1 ; i < k ; i++ ) {
+ 	addTargetList[i] = tempPL[j][i] ;
+ 	printf(" %d ", tempPL[j][i] ) ;
+     }
+     printf("\n");
+ fflush(stdout);
+ #else
+     for( i = 1 ; i < k ; i++ ) {
+ 	addTargetList[i] = tempPL[j][i] ;
+     }
+ #endif
+ 
+     numdelete = 0 ;
+     numadd = k - 1 ;
+     for( i = 1 ; i < k ; i++ ) {
+ 	if( addTargetList[i] > numnodes ) {
+ 	    delSourceList[ ++numdelete ] = addTargetList[i] ;
+ 	}
+     }
+     count = 0 ;
+     for( i = 1 ; i <= numdelete ; i++ ) {
+ 	savei = delSourceList[i] ;
+ 	if( pnodeArray[ savei - numnodes ].eptr != 0 ) {
+ 	    node = pnodeArray[ savei - numnodes ].eptr + numnodes ;
+ 	    for( t = 1 ; t <= numdelete + count ; t++ ) {
+ 		if( node == delSourceList[t] ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( t > numdelete + count ) {
+ 		delSourceList[ numdelete + ++count ] = node ;
+ 		addTargetList[ numadd + count ] = node ;
+ 	    }
+ 	    lptr = pnodeArray[ pnodeArray[savei - numnodes].eptr ].equiv;
+ 	} else {
+ 	    lptr = pnodeArray[savei - numnodes].equiv;
+ 	}
+ 	while( lptr != (LIST2PTR) NULL ) {
+ 	    node = lptr->node + numnodes ;
+ 	    for( t = 1 ; t <= numdelete + count ; t++ ) {
+ 		if( node == delSourceList[t] ) {
+ 		    break ;
+ 		}
+ 	    }
+ 	    if( t > numdelete + count ) {
+ 		delSourceList[ numdelete + ++count ] = node ;
+ 		addTargetList[ numadd + count ] = node ;
+ 	    }
+ 	    lptr = lptr->next ;
+ 	}
+     }
+     pathLength += tempPL[j][k + 1] ;
+     numdelete += count ;
+     numadd += count ;
+     for( i = 1 ; i <= k ; i++ ) {
+ 	segList[ i + segPtr ] = tempPL[j][i] ;
+     }
+     segList[ i + segPtr ] = 0 ;
+     segPtr += k + 1 ;
+ 
+     for( x = numadd - count + 1 ; x <= numadd ; x++ ) {
+ 	node = addTargetList[x] ;
+ 	gptr = gnodeArray[node] ;
+ 	for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	    node1 = gptr->node ;
+ 	    gptr1 = gnodeArray[node1] ;
+ 	    for( ; ; ) {
+ 		if( gptr1->node == node ) {
+ 		    gptr1->einactive = 1 ;
+ 		    break ;
+ 		}
+ 		gptr1 = gptr1->next ;
+ 	    }
+ 	}
+     }
+ 
+     recursePath( numdelete , numadd - count , tempPL[j][k] , count ) ;
+ 
+     segPtr -= k + 1 ;
+     pathLength -= tempPL[j][k + 1] ;
+ 
+     for( x = numadd - count + 1 ; x <= numadd ; x++ ) {
+ 	node = addTargetList[x] ;
+ 	gptr = gnodeArray[node] ;
+ 	for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	    node1 = gptr->node ;
+ 	    gptr1 = gnodeArray[node1] ;
+ 	    for( ; ; ) {
+ 		if( gptr1->node == node ) {
+ 		    gptr1->einactive = 0 ;
+ 		    break ;
+ 		}
+ 		gptr1 = gptr1->next ;
+ 	    }
+ 	}
+     }
+ }
+ count = treeSize - MAXPATHS ;
+ if( count > 0 ) {
+     for( c = 1 ; c <= count ; c++ ) {
+ 	tmax( &netRoot , &junkptr , &value , &index ) ;
+ 	tdelete( &netRoot , value , index ) ;
+ 	tinsert( &indexRoot , index , 0 ) ;
+     }
+     treeSize -= count ;
+ }
+ if( extraRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &extraRoot , &junkptr , &junk, &j ) ;
+ 	if( junkptr == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ 
+ for( j = 1 ; j <= dsptr ; j++ ) {
+     sourceList[++sourcePtr] = dslist[j] ;
+ }
+ 
+ #ifdef DEBUG2
+ printf("\nSource Node List (AFTER End of Recurse):\n");
+ for( i = 1 ; i <= sourcePtr ; i++ ) {
+     printf(" %d ", sourceList[i] ) ;
+ }
+ printf("\n");
+ fflush(stdout);
+ #endif
+ 
+ 
+ targetPtr -= atptr + addEquivs ;
+ 
+ 
+ if( attachPt > 0 ) {
+     for( j = 1 ; j <= atptr ; j++ ) {
+ 	node1 = atlist[j] ;
+ 	if( j == atptr ) {
+ 	    node2 = attachPt ;
+ 	} else {
+ 	    node2 = atlist[ j + 1 ] ;
+ 	}
+ 	gptr1 = gnodeArray[ node1 ] ;
+ 	gptr2 = gnodeArray[ node2 ] ;
+ 	gptr = gptr1 ;
+ 	for( ; ; ) {
+ 	    if( gptr->node == node2 ) {
+ 		gptr->cost = gptr->length ;
+ 		break ;
+ 	    }
+ 	    gptr = gptr->next ;
+ 	}
+ 	gptr = gptr2 ;
+ 	for( ; ; ) {
+ 	    if( gptr->node == node1 ) {
+ 		gptr->cost = gptr->length ;
+ 		break ;
+ 	    }
+ 	    gptr = gptr->next ;
+ 	}
+     }
+ }
+ free( (short int *) atlist ) ;
+ free( (short int *) dslist ) ;
+ free( extraSlist ) ;
+ for( i = 1 ; i <= EXTRASOURCES * MAXPATHS ; i++ ) {
+     free( (int *) tempPL[i] ) ;
+ }
+ free( (int **) tempPL ) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/savewolf.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/savewolf.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/savewolf.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,467 ----
+ #include "custom.h"
+ 
+ extern void move( int moveType );
+ extern void rect( int *l , int *b , int *r , int *t );
+ extern void point( int *x , int *y );
+ extern void loadbins(int new);
+ 
+ void savewolf(void)
+ {
+ 
+ FILE *fp ;
+ char filename[1024] ;
+ int cell , terminal ;
+ CELLBOXPTR cellptr ;
+ 
+ sprintf( filename , "%s.sav", cktName ) ;
+ fp = fopen( filename , "w" ) ;
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     cellptr = cellarray[ cell ] ;
+     fprintf( fp , "%d %d %d %d\n", cell , cellptr->orient , 
+ 			cellptr->xcenter , cellptr->ycenter ) ;
+     for( terminal = 1 ; terminal <= cellptr->numUnComTerms ;
+ 						terminal++ ) {
+ 	fprintf( fp , " %d ", cellptr->unComTerms[ terminal ].
+ 							site );
+ 	if( terminal == cellptr->numUnComTerms ) {
+ 	    fprintf( fp , " %lf\n" , cellptr->aspect );
+ 	}
+     }
+ }
+ fclose( fp ) ;
+ return ;
+ }
+ 
+ 
+ void TW_oldinput( FILE *fp )
+ {
+ 
+ int i , cell , orient , tm , site , terminal , height , length ;
+ int xcenter , ycenter , xpos , ypos , x , y ;
+ int oleft , oright , obottom , otop , Hdiv2 , Wdiv2 , aorient ;
+ double aspect , aspFactor , val ;
+ int tilenum , termnum ;
+ CELLBOXPTR ptr ;
+ LOCBOX *SLptr , *siteptr , *siteptr0 ;
+ TILEBOXPTR atileptr , tileptr1 , tptr , tptr0 ;
+ TERMBOXPTR term , atermptr , termptr , tmptr0 , tmptr1 ;
+ TERMNETSPTR teptr ;
+ 
+ 
+ 
+ while( fscanf( fp , " %d %d %d %d ", &cell , &orient , 
+ 				    &xcenter , &ycenter ) == 4 ) {
+     ptr = cellarray[ cell ] ;
+ 
+     ptr->orient  = orient  ;
+     ptr->xcenter = xcenter ;
+     ptr->ycenter = ycenter ;
+     aorient = orient ;
+ 
+     for( terminal = 1; terminal <= ptr->numUnComTerms; terminal++ ){
+ 	if( terminal == 1 ) {
+ 	    for( i = 1 ; i <= ptr->numsites ; i++ ) {
+ 		ptr->siteContent[ i ].contents = 0 ;
+ 	    }
+ 	}
+ 	fscanf( fp , " %d ", &site ) ;
+ 	ptr->unComTerms[ terminal ].site = site ;
+ 	++ptr->siteContent[ site ].contents ;
+ 	if( terminal == ptr->numUnComTerms ) {
+ 	    fscanf( fp , "%lf" , &aspect ) ;
+ 	    ptr->aspect = aspect ;
+ 	}
+     }
+     if( ptr->softflag == 1 && ptr->aspUB > 0.01 + ptr->aspLB ) {
+ 	atileptr = ptr->config[ aorient ] ;
+ 	atermptr = atileptr->termptr ;
+ 	oleft   = atileptr->oleft    ;
+ 	oright  = atileptr->oright   ;
+ 	obottom = atileptr->obottom  ;
+ 	otop    = atileptr->otop     ;
+ 
+ 	SLptr = atileptr->siteLocArray ;
+ 
+ 	if( aorient <= 3 ) {
+ 	    aspFactor = sqrt( aspect / ptr->aspectO ) ;
+ 	} else {
+ 	    aspFactor = sqrt( ptr->aspectO / aspect ) ;
+ 	}
+ 	val = (double)(otop - obottom) * aspFactor ;
+ 	Hdiv2 = ROUND( val ) / 2 ;
+ 	val = (double)(oright - oleft) / aspFactor ;
+ 	Wdiv2 = ROUND( val ) / 2 ;
+ 
+ 	/*
+ 	 *   Time to compute the new coordinates for the cell
+ 	 *   since its aspect ratio has changed.  Do it for
+ 	 *   the orient 0 version and then use the routines
+ 	 *   from readcells() to transfer for other orients.
+ 	 */
+ 
+ 	for( tileptr1 = atileptr ; tileptr1 != TILENULL ;
+ 				   tileptr1 = tileptr1->nexttile ){
+ 	    val = (double)(tileptr1->oleft - oleft) / aspFactor ;
+ 	    tileptr1->left   = ROUND( val ) - Wdiv2 ;
+ 	    val = (double)(tileptr1->oright - oleft) / aspFactor ;
+ 	    tileptr1->right  = ROUND( val ) - Wdiv2 ;
+ 	    val = (double)(tileptr1->obottom - obottom) * aspFactor;
+ 	    tileptr1->bottom = ROUND( val ) - Hdiv2 ;
+ 	    val = (double)(tileptr1->otop - obottom) * aspFactor ;
+ 	    tileptr1->top    = ROUND( val ) - Hdiv2 ;
+ 	}
+ 
+ 	for( termptr = atermptr ; termptr != TERMNULL ; termptr =
+ 					termptr->nextterm ) {
+ 	    val = (double)(termptr->oxpos - oleft) / aspFactor ;
+ 	    termptr->xpos = ROUND( val ) - Wdiv2 ;
+ 	    val = (double)(termptr->oypos - obottom) * aspFactor ;
+ 	    termptr->ypos = ROUND( val ) - Hdiv2 ;
+ 	}
+ 	for( site = 1 ; site <= ptr->numsites ; site++ ) {
+ 	    val = (double)(SLptr[ site ].oxpos - oleft) / aspFactor ;
+ 	    SLptr[site].xpos = ROUND( val ) - Wdiv2 ;
+ 	    val = (double)(SLptr[site].oypos - obottom) * aspFactor ;
+ 	    SLptr[site].ypos = ROUND( val ) - Hdiv2 ;
+        }
+ 
+ 	/*
+ 	    NOW WE HAVE TO LOAD IN THE OTHER CONFIGURATIONS
+ 	*/
+ 
+ 	if( aorient != 0 ) {
+ 	    height = atileptr->top - atileptr->bottom ;
+ 	    length = atileptr->right - atileptr->left ;
+ 	    switch( aorient ) {
+ 		case 1 : orient = 1 ;
+ 			 break ;
+ 		case 2 : orient = 2 ;
+ 			 break ;
+ 		case 3 : orient = 3 ;
+ 			 break ;
+ 		case 4 : orient = 4 ;
+ 			 break ;
+ 		case 5 : orient = 5 ;
+ 			 break ;
+ 		case 6 : orient = 7 ;
+ 			 break ;
+ 		case 7 : orient = 6 ;
+ 			 break ;
+ 	    }
+ 	    tptr0 = ptr->config[ 0 ] ;
+ 	    tptr  = atileptr ;
+ 	    tptr0->left     = tptr->left   ;
+ 	    tptr0->right    = tptr->right  ;
+ 	    tptr0->bottom   = tptr->bottom ;
+ 	    tptr0->top      = tptr->top    ;
+ 
+ 	    move( orient ) ;
+ 
+ 	    rect( &tptr0->left, &tptr0->bottom, &tptr0->right , 
+ 					    &tptr0->top ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || 
+ 					    orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || 
+ 					    orient == 3))){
+ 
+ 		tptr0->left++  ;
+ 		tptr0->right++ ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || 
+ 					    orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || 
+ 					    orient == 7))){
+ 
+ 		tptr0->bottom++ ;
+ 		tptr0->top++    ;
+ 	    }
+ 	    for( tilenum = 1 ; tilenum <= ptr->numtiles ; 
+ 					    tilenum++ ) {
+ 		tptr0 = tptr0->nexttile ;
+ 		tptr  = tptr->nexttile ; 
+ 		tptr0->left   = tptr->left   ;
+ 		tptr0->right  = tptr->right  ;
+ 		tptr0->bottom = tptr->bottom ;
+ 		tptr0->top    = tptr->top    ;
+ 
+ 		move( orient ) ; 
+ 
+ 		rect( &tptr0->left,&tptr0->bottom,&tptr0->right,
+ 					    &tptr0->top ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						 orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || 
+ 						 orient == 3))){
+ 		    tptr0->left++  ;
+ 		    tptr0->right++ ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						 orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || 
+ 						 orient == 7))){
+ 		    tptr0->bottom++ ;
+ 		    tptr0->top++    ;
+ 		}
+ 	    }
+ 
+ 	    /*  And NOW for the fixed terminals */
+ 
+ 	    if( ptr->numterms != 0 ) {
+ 		tmptr0 = ptr->config[ 0 ]->termptr ;
+ 		tmptr1 = atermptr ;
+ 		tmptr0->xpos = tmptr1->xpos ;
+ 		tmptr0->ypos = tmptr1->ypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		    tmptr0->xpos++  ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		    tmptr0->ypos++ ;
+ 		}
+ 		for( termnum = 2 ; termnum <= ptr->numterms ; 
+ 						   termnum++ ) {
+ 		    tmptr0 = tmptr0->nextterm ;
+ 		    tmptr1  = tmptr1->nextterm ; 
+ 		    tmptr0->xpos = tmptr1->xpos ;
+ 		    tmptr0->ypos = tmptr1->ypos ;
+ 
+ 		    move( orient ) ; 
+ 
+ 		    point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 		    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 			(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 			tmptr0->xpos++  ;
+ 		    }
+ 		    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 			(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 			tmptr0->ypos++ ;
+ 		    }
+ 		}
+ 	    }
+ 
+ 	    /*  Now the sites for the soft cells */
+ 
+ 	    if( ptr->numsites != 0 ) {
+ 		siteptr0 = ptr->config[ 0 ]->siteLocArray ;
+ 		siteptr = SLptr ;
+ 		for( site = 1 ; site <= ptr->numsites; site++ ){
+ 		    siteptr0[ site ].xpos = siteptr[site].xpos ;
+ 		    siteptr0[ site ].ypos = siteptr[site].ypos ;
+ 
+ 		    move( orient ) ; 
+ 
+ 		    point( &(siteptr0[ site ].xpos) , 
+ 			   &(siteptr0[ site ].ypos) );
+ 
+ 		    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 			(length % 2 != 0 && (orient == 2 ||
+ 						orient == 3))){
+ 			siteptr0[ site ].xpos++ ;
+ 		    }
+ 		    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 			(length % 2 != 0 && (orient == 4 ||
+ 						orient == 7))){
+ 			siteptr0[ site ].ypos++ ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	/* ************************************************** */
+ 	height = ptr->config[0]->top - ptr->config[0]->bottom ;
+ 	length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+ 	for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	    if( orient == aorient ) {
+ 		continue ;
+ 	    }
+ 	    tptr0 = ptr->config[ 0 ] ;
+ 	    tptr  = ptr->config[ orient ] ; 
+ 	    tptr->left     = tptr0->left   ;
+ 	    tptr->right    = tptr0->right  ;
+ 	    tptr->bottom   = tptr0->bottom ;
+ 	    tptr->top      = tptr0->top    ;
+ 
+ 	    move( orient ) ;
+ 
+ 	    rect( &tptr->left , &tptr->bottom , &tptr->right , 
+ 						&tptr->top ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		tptr->left++  ;
+ 		tptr->right++ ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 
+ 		tptr->bottom++ ;
+ 		tptr->top++    ;
+ 	    }
+ 	    for( tilenum = 1 ; tilenum <= ptr->numtiles ; 
+ 						  tilenum++ ) {
+ 		tptr0 = tptr0->nexttile ;
+ 		tptr  = tptr->nexttile ; 
+ 		tptr->left     = tptr0->left   ;
+ 		tptr->right    = tptr0->right  ;
+ 		tptr->bottom   = tptr0->bottom ;
+ 		tptr->top      = tptr0->top    ;
+ 
+ 		move( orient ) ; 
+ 
+ 		rect( &tptr->left, &tptr->bottom, &tptr->right ,
+ 						  &tptr->top ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		    tptr->left++  ;
+ 		    tptr->right++ ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		    tptr->bottom++ ;
+ 		    tptr->top++    ;
+ 		}
+ 	    }
+ 	}
+ 
+ 	/*  And NOW for the fixed terminals */
+ 
+ 	if( ptr->numterms != 0 ) {
+ 
+ 	    for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 		if( orient == aorient ) {
+ 		    continue ;
+ 		}
+ 		tmptr0 = ptr->config[ 0 ]->termptr ;
+ 		tmptr1 = ptr->config[ orient ]->termptr ; 
+ 		tmptr1->xpos     = tmptr0->xpos     ;
+ 		tmptr1->ypos     = tmptr0->ypos     ;
+ 
+ 		move( orient ) ;
+ 
+ 		point( &tmptr1->xpos , &tmptr1->ypos ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		    tmptr1->xpos++  ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		    tmptr1->ypos++ ;
+ 		}
+ 		for( termnum = 2 ; termnum <= ptr->numterms ; 
+ 						   termnum++ ) {
+ 		    tmptr0 = tmptr0->nextterm ;
+ 		    tmptr1  = tmptr1->nextterm ; 
+ 		    tmptr1->xpos     = tmptr0->xpos ;
+ 		    tmptr1->ypos     = tmptr0->ypos ;
+ 
+ 		    move( orient ) ; 
+ 
+ 		    point( &tmptr1->xpos , &tmptr1->ypos ) ;
+ 
+ 		    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 			(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 			tmptr1->xpos++  ;
+ 		    }
+ 		    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 			(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 			tmptr1->ypos++ ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 
+ 	/*  Now the sites for the soft cells */
+ 
+ 	if( ptr->numsites != 0 ) {
+     
+ 	    siteptr0 = ptr->config[ 0 ]->siteLocArray ;
+ 	    for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 		if( orient == aorient ) {
+ 		    continue ;
+ 		}
+ 		siteptr = ptr->config[ orient ]->siteLocArray ; 
+ 		for( site = 1; site <= ptr->numsites; site++ ) {
+ 		    siteptr[ site ].xpos = siteptr0[site].xpos ;
+ 		    siteptr[ site ].ypos = siteptr0[site].ypos ;
+ 
+ 		    move( orient ) ; 
+ 
+ 		    point( &(siteptr[ site ].xpos) , 
+ 			   &(siteptr[ site ].ypos) );
+ 
+ 		    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 			(length % 2 != 0 && (orient == 2 ||
+ 						orient == 3))){
+ 			siteptr[ site ].xpos++ ;
+ 		    }
+ 		    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 			(length % 2 != 0 && (orient == 4 ||
+ 						orient == 7))){
+ 			siteptr[ site ].ypos++ ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+     for( term = ptr->config[ aorient ]->termptr ; 
+ 		    term != TERMNULL ; term = term->nextterm ) {
+ 	xpos = term->xpos ;
+ 	ypos = term->ypos ;
+ 	teptr = termarray[ term->terminal ] ;
+ 	teptr->termptr->xpos = xpos + xcenter ;
+ 	teptr->termptr->ypos = ypos + ycenter ;
+     }
+     for( tm = 1 ; tm <= ptr->numUnComTerms ; tm++ ) {
+ 	terminal = ptr->unComTerms[ tm ].terminal ;
+ 	site = ptr->unComTerms[ tm ].site ;
+ 	x = ptr->config[ aorient ]->siteLocArray[ site ].xpos ;
+ 	y = ptr->config[ aorient ]->siteLocArray[ site ].ypos ;
+ 
+ 	teptr = termarray[ terminal ] ;
+ 	teptr->termptr->xpos = x + xcenter ;
+ 	teptr->termptr->ypos = y + ycenter ;
+     }
+     loadbins(0) ;
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/scrapnet.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/scrapnet.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/scrapnet.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,38 ----
+ #include "custom.h"
+ 
+ void scrapnet(void)
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ 
+ int *vector , criticalMass , count , temp , net , cell ;
+ 
+ vector = (int *) malloc( (1 + numcells) * sizeof(int) ) ;
+ temp = (int) ( 0.70 * (double) numcells ) ;
+ criticalMass = ( temp > 8 ) ? temp : 8 ;
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     for( cell = 1 ; cell <= numcells ; cell++ ) {
+ 	vector[cell] = 0 ;
+     }
+     count = 0 ;
+     dimptr = netarray[net] ;
+     netptr = dimptr->netptr ;
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	cell = netptr->cell ;
+ 	if( cell <= numcells ) {
+ 	    if( vector[cell] == 0 ) {
+ 		vector[cell] = 1 ;
+ 		count++ ;
+ 	    }
+ 	}
+     }
+     if( count >= criticalMass ) {
+ 	dimptr->skip = 1 ;
+     }
+ }
+ free( vector ) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/scrappin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/scrappin.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/scrappin.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,23 ----
+ #include "custom.h"
+ 
+ void scrappin(void)
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ 
+ int net ;
+ 
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     dimptr = netarray[net] ;
+     netptr = dimptr->netptr ;
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->cell > numcells ) {
+ 	    netptr->skip = 1 ;
+ 	}
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/selectpin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/selectpin.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/selectpin.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,107 ----
+ #include "custom.h"
+ extern int flips ;
+ extern int flipp ;
+ extern int attp  ;
+ 
+ extern int upin( CELLBOXPTR acellptr , int UCpin , int seq , int firstNewSite,
+ 		int lastNewSite );
+ extern int upinswap(CELLBOXPTR acellptr,int pin1,int pin2,int site1,int site2);
+ 
+ void selectpin( CELLBOXPTR acellptr )
+ {
+ 
+ CONTENTBOX *SCptr ;
+ UNCOMBOX *UCptr ;
+ int i, first, last, firstNewSite, lastNewSite, sum, k, seq ;
+ int ok, site, ns , side , pin1 , pin2 ;
+ 
+ 
+ UCptr = acellptr->unComTerms ;
+ /*
+  *  randomly select an uncommitted pin group or
+  *  sequence for transfer to a new site
+  */
+ 
+ do {
+     i = (int) ( (double) acellptr->numUnComTerms * ( 
+ 			    (double)RAND / (double)0x7fffffff)) + 1;
+ } while( i == acellptr->numUnComTerms + 1 );
+ 
+ while( UCptr[i].sequence == 0 ) {
+     i-- ;
+ }
+ 
+ if( UCptr[i].numranges > 2 ) {
+     do {
+ 	side = (int)( (double) UCptr[i].numranges *
+ 	    ( (double) RAND / (double)0x7fffffff) ) + 1 ;
+     } while( side == UCptr[i].numranges + 1 ) ;
+ } else if( UCptr[i].numranges == 2 ) {
+     do {
+ 	side = (int)( (double) UCptr[i].numranges *
+ 	    ( (double) RAND / (double)0x7fffffff) ) + 1 ;
+     } while( side == UCptr[i].numranges + 1 ) ;
+     if( side == 1 ) {
+ 	side = UCptr[i].range1 ;
+     } else {
+ 	side = UCptr[i].range2 ;
+     }
+ } else if( UCptr[i].numranges == 1 ) {
+     side = UCptr[i].range1 ;
+ } else {
+     return ;
+ }
+ first = acellptr->sideArray[side].firstSite ;
+ last  = acellptr->sideArray[side].lastSite  ;
+ ns    = last - first + 1       ;
+ 
+ seq = UCptr[i].sequence ;
+ ok = 0 ;
+ SCptr = acellptr->siteContent ;
+ do {
+     sum = 0 ;
+     site = (int)((double)ns * ((double) RAND / (double)0x7fffffff));
+ 
+     firstNewSite = first + site ;
+     for( k = firstNewSite; k <= last; k++){
+ 	sum += SCptr[k].capacity;
+ 	if( sum >= seq ) {
+ 	    ok = 1 ;
+ 	    lastNewSite = k ;
+ 	    break ;
+ 	}
+     }
+ } while( !ok ) ;
+ 
+ if( firstNewSite != UCptr[i].site ) {
+     if( upin( acellptr, i, seq, firstNewSite, lastNewSite ) ) {
+ 	flips++ ;
+ 	flipp++ ;
+     } 
+     attp++  ;
+ }
+ /* 
+  *  Determine if the pins are "group" specified, and if so,
+  *  swap two of them
+  */
+ if( UCptr[i].groupflag == 1 && seq >= 2 ) {
+     do {
+ 	pin1 = (int)((double)seq * ((double)RAND / 
+ 					    (double)0x7fffffff));
+     } while( pin1 == seq ) ;
+     do {
+ 	pin2 = (int)((double)seq * ((double)RAND / 
+ 					    (double)0x7fffffff));
+     } while( pin2 == seq || pin2 == pin1 ) ;
+ 
+     if( UCptr[i + pin1].site != UCptr[i + pin2].site ) {
+ 	if( upinswap( acellptr, i + pin1 , i + pin2 ,
+ 		    UCptr[i + pin1].site , UCptr[i + pin2].site )) {
+ 	    flips++ ;
+ 	    flipp++ ;
+ 	} 
+ 	attp++  ;
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/setpwates.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/setpwates.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/setpwates.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,36 ----
+ #include "custom.h"
+ 
+ void setpwates(void )
+ {
+ 
+ TILEBOXPTR tileptr ;
+ int cell ;
+ 
+ for( cell = 1 ; cell <= numcells ; cell++ ) {
+     tileptr = cellarray[cell]->config[0] ;
+     for( ; tileptr != TILENULL ; tileptr = tileptr->nexttile ) {
+ 	if( tileptr->lweight > pinsPerLen ) {
+ 	    tileptr->lweight /= pinsPerLen ;
+ 	} else {
+ 	    tileptr->lweight = 1.0 ;
+ 	}
+ 	if( tileptr->rweight > pinsPerLen ) {
+ 	    tileptr->rweight /= pinsPerLen ;
+ 	} else {
+ 	    tileptr->rweight = 1.0 ;
+ 	}
+ 	if( tileptr->bweight > pinsPerLen ) {
+ 	    tileptr->bweight /= pinsPerLen ;
+ 	} else {
+ 	    tileptr->bweight = 1.0 ;
+ 	}
+ 	if( tileptr->tweight > pinsPerLen ) {
+ 	    tileptr->tweight /= pinsPerLen ;
+ 	} else {
+ 	    tileptr->tweight = 1.0 ;
+ 	}
+     }
+ }
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/shortpath.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/shortpath.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/shortpath.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,56 ----
+ /* 
+  *   Basically an O( e log n ) Dijkstra's algorithm
+  */
+ #include "route.h"
+ #include "23tree.h"
+ 
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ 
+ void shortpath( int numpnodes )
+ {
+ 
+ TNODEPTR root , dumnode ;
+ NNODEPTR nptr ;
+ GNODEPTR gptr ;
+ int i , j , pnode , node , D , nextnode , distance ;
+ 
+ for( i = 1 ; i <= numpnodes ; i++ ) {
+     pnode = numnodes + i ;
+     nptr = pnodeArray[i].nodeList ;
+ 
+     root = (TNODEPTR) NULL ;
+     for( j = 1 ; j <= numnodes + numpnodes ; j++ ) {
+ 	if( j == pnode ) {
+ 	    tinsert( &root , 0 , j ) ;
+ 	    nptr[j].distance = 0 ;
+ 	    nptr[pnode].from = 0 ;
+ 	    continue ;
+ 	}
+ 	nptr[j].distance = VLARGE ;
+     }
+ 
+     for( ; ; ) {
+ 	tpop( &root , &dumnode , &D , &nextnode ) ;
+ 	if( dumnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+ 	gptr = gnodeArray[nextnode] ;
+ 	for( ; gptr != (GNODEPTR) NULL ; gptr = gptr->next ) {
+ 	    distance = gptr->length ;
+ 	    node = gptr->node ;
+ 	    if( nptr[node].distance > D + distance ) {
+ 		tdelete( &root , nptr[node].distance , node ) ;
+ 		tinsert( &root , D + distance , node ) ;
+ 		nptr[node].distance = D + distance ;
+ 		nptr[node].from = nextnode ;
+ 	    }
+ 	}
+ 
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/test2loop.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/test2loop.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/test2loop.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,209 ----
+ #include "custom.h"
+ extern int newxx , newyy ;
+ extern int bigcell ;
+ extern int toobig  ;
+ extern double totFunc ;
+ extern double totPen  ;
+ 
+ extern void forceGrid( int x , int y );
+ extern int usite1( int a , int xb , int yb);
+ extern int newOrient( CELLBOXPTR cellptr , int range );
+ extern int usiteo1( int a , int xb , int yb , int newaor );
+ extern int usite0( int a , int newaor );
+ extern int usite2( int a , int b , int ax , int ay , int bx , int by );
+ extern int usiteo2( int a , int b , int ax , int ay , int bx , int by ,
+ 		   int newaor, int newbor );
+ 
+ int test2loop( int trials )
+ {
+ 
+ CELLBOXPTR acellptr , bcellptr ;
+ TERMBOXPTR termptr , btermptr ;
+ int a , b , numberx , numbery ;
+ int attempts , reject ;
+ int xb , yb , axcenter , aycenter ;
+ int aorient , borient , newaor , newbor ;
+ int ll , rr , bb , tt , ax , ay , bx , by ;
+ int scalex , scaley ;
+ 
+ attempts = 0 ;
+ totFunc = 0.0 ;
+ totPen  = 0.0 ;
+ 
+ /* numberx = (int) ( 0.1667 * (double) bdxlength * log10( 0.10 * T ));*/
+ numberx = (int)( pow( 4.0 , log10(T) ) / 1024.0 * (double) bdxlength ) ;
+ if( numberx < 3 ) {
+     numberx = 3 ;
+ } else if( numberx > bdxlength ) {
+     numberx = bdxlength ;
+ }
+ 
+ /* numbery = (int) ( 0.1667 * (double) bdylength * log10( 0.10 * T ));*/
+ numbery = (int)( pow( 4.0 , log10(T) ) / 1024.0 * (double) bdylength ) ;
+ if( numbery < 3 ) {
+     numbery = 3 ;
+ } else if( numbery > bdylength ) {
+     numbery = bdylength ;
+ } 
+ scalex = numberx / 3 ;
+ scaley = numbery / 3 ;
+ fprintf(fpo,"range limiter:%d units either way in x",numberx);
+ fprintf(fpo,"   compared to bdxlength:%d\n",bdxlength);
+ fprintf(fpo,"range limiter:%d units either way in y",numbery);
+ fprintf(fpo,"   compared to bdylength:%d\n",bdylength);
+ fprintf(fpo,"scalex:%d  scaley:%d\n", scalex , scaley ) ;
+ 
+ while( attempts < trials ) {
+     do {
+ 	a = (int) ( (double) numcells * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( a == numcells + 1 ) ;
+ 
+     do {
+ 	b = (int) ( (double) bigcell * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( b == toobig ) ;
+ 
+     if( a == b ) {
+ 	continue ;
+     }
+ 
+     acellptr = cellarray[ a ]   ;
+     aorient  = acellptr->orient ;
+ 
+     if( b > numcells ) {
+ 	if( acellptr->class != 0 ) {
+ 	    continue ;
+ 	}
+ 	axcenter = acellptr->xcenter ;
+ 	aycenter = acellptr->ycenter ;
+ 
+ 	ll = (blockl > axcenter-numberx) ? (blockl - axcenter) / scalex :
+ 		( (blockr <= axcenter - numberx) ? 
+ 		(blockr - axcenter) / scalex : (- numberx / scalex) ) ;
+ 	rr = (blockr < axcenter+numberx) ? (blockr - axcenter) / scalex :
+ 		( (blockl >= axcenter + numberx) ? 
+ 		(blockl - axcenter) /scalex : (numberx / scalex) ) ;
+ 	bb = (blockb > aycenter-numbery) ? (blockb - aycenter) / scaley :
+ 		( (blockt <= aycenter - numbery) ? 
+ 		(blockt - aycenter) / scaley : (- numbery / scaley) ) ;
+ 	tt = (blockt < aycenter+numbery) ? (blockt - aycenter) / scaley :
+ 		( (blockb >= aycenter + numbery) ? 
+ 		(blockb - aycenter) / scaley : (numbery / scaley) ) ;
+ 	xb = (int)((double)(rr - ll + 1) * ((double)RAND /
+ 					(double) 0x7fffffff ) ) + ll ;
+ 	yb = (int)((double)(tt - bb + 1) * ((double)RAND /
+ 					(double) 0x7fffffff ) ) + bb ;
+ 	if( xb == 0 && yb == 0 ) {
+ 	    continue ;
+ 	}
+ 	xb = axcenter + scalex * xb ;
+ 	yb = aycenter + scaley * yb ;
+ 
+ 	if( gridGiven ) {
+ 	    termptr  = acellptr->config[aorient]->termptr ;
+ 	    forceGrid( xb + termptr->xpos , yb + termptr->ypos ) ;
+ 	    xb = newxx - termptr->xpos ;
+ 	    yb = newyy - termptr->ypos ;
+ 	}
+ 
+         if( usite1( a , xb , yb ) ) {
+ 	    attempts++ ;
+ 	    totFunc += (double) funccost ;
+ 	    totPen  += (double) penalty  ;
+ 	} else {
+ 	    newaor = newOrient( acellptr , 4 ) ;
+ 	    reject = 1 ;
+ 	    if( newaor >= 0 ) {
+ 		if( usiteo1( a , xb , yb , newaor ) ) {
+ 		    attempts++ ;
+ 		    totFunc += (double) funccost ;
+ 		    totPen  += (double) penalty  ;
+ 		    reject = 0 ;
+ 		}
+ 	    }
+ 	    if( reject ) {
+ 		newaor = newOrient( acellptr , 8 ) ;
+ 		if( newaor >= 0 ) {
+ 		    if( usite0( a , newaor ) ) {
+ 			attempts++ ;
+ 			totFunc += (double) funccost ;
+ 			totPen  += (double) penalty  ;
+ 			reject = 0 ;
+ 		    }
+ 		}
+ 	    }
+ 	} 
+     } else { /*   b <= numcells   */
+ 	bcellptr = cellarray[b] ;
+ 	if( acellptr->class == -1 || bcellptr->class == -1 ||
+ 			    acellptr->class != bcellptr->class ) {
+ 	    continue ;
+ 	}
+ 	if( gridGiven ) {
+ 	    /*
+ 	     *   Force pin 1 to lie on the underlying grid, specified
+ 	     *   by:  n * (grid) + offset , in each direction.
+ 	     */
+ 	    btermptr = bcellptr->config[bcellptr->orient]->termptr ;
+ 	    termptr = acellptr->config[aorient]->termptr ;
+ 	    forceGrid( bcellptr->xcenter + termptr->xpos , 
+ 		       bcellptr->ycenter + termptr->ypos ) ;
+ 	    ax = newxx - termptr->xpos ;
+ 	    ay = newyy - termptr->ypos ;
+ 	    forceGrid( acellptr->xcenter + btermptr->xpos , 
+ 		       acellptr->ycenter + btermptr->ypos ) ;
+ 	    bx = newxx - btermptr->xpos ;
+ 	    by = newyy - btermptr->ypos ;
+ 	} else {
+ 	    ax = bcellptr->xcenter ;
+ 	    ay = bcellptr->ycenter ;
+ 	    bx = acellptr->xcenter ;
+ 	    by = acellptr->ycenter ;
+ 	}
+ 
+ 	if( usite2( a , b , ax , ay , bx , by )  ) {
+ 	    attempts++ ;
+ 	    totFunc += (double) funccost ;
+ 	    totPen  += (double) penalty  ;
+ 	} else {
+ 	    /*
+ 		try again with opposite orientation types
+ 	    */
+ 	    newaor = newOrient( acellptr , 4 ) ;
+ 	    borient = cellarray[b]->orient ;
+ 	    newbor = newOrient( cellarray[b] , 4 ) ;
+ 	    if( newaor >= 0 || newbor >= 0 ) {
+ 		if( newaor < 0 ) {
+ 		    newaor = aorient ;
+ 		} else if( newbor < 0 ) {
+ 		    newbor = borient ;
+ 		}
+ 		if( gridGiven ) {
+ 		    btermptr = bcellptr->config[newbor]-> termptr ;
+ 		    termptr = acellptr->config[newaor]->termptr ;
+ 		    forceGrid( bcellptr->xcenter + termptr->xpos , 
+ 			       bcellptr->ycenter + termptr->ypos ) ;
+ 		    ax = newxx - termptr->xpos ;
+ 		    ay = newyy - termptr->ypos ;
+ 		    forceGrid( acellptr->xcenter + btermptr->xpos , 
+ 			       acellptr->ycenter + btermptr->ypos ) ;
+ 		    bx = newxx - btermptr->xpos ;
+ 		    by = newyy - btermptr->ypos ;
+ 		} else {
+ 		    ax = bcellptr->xcenter ;
+ 		    ay = bcellptr->ycenter ;
+ 		    bx = acellptr->xcenter ;
+ 		    by = acellptr->ycenter ;
+ 		}
+ 		if( usiteo2( a, b, ax, ay, bx, by, newaor, newbor) ) {
+ 		    attempts++ ;
+ 		    totFunc += (double) funccost ;
+ 		    totPen  += (double) penalty  ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( attempts ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/testloop.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/testloop.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/testloop.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,202 ----
+ #include "custom.h"
+ extern int newxx , newyy ;
+ extern int bigcell ;
+ extern int toobig  ;
+ extern double totFunc ;
+ 
+ extern void forceGrid( int x , int y );
+ extern int usite1( int a , int xb , int yb);
+ extern int newOrient( CELLBOXPTR cellptr , int range );
+ extern int usiteo1( int a , int xb , int yb , int newaor );
+ extern int usite0( int a , int newaor );
+ extern int usite2( int a , int b , int ax , int ay , int bx , int by );
+ extern int usiteo2( int a , int b , int ax , int ay , int bx , int by ,
+ 		   int newaor, int newbor );
+ 
+ int testloop( int trials )
+ {
+ 
+ CELLBOXPTR acellptr , bcellptr ;
+ TERMBOXPTR termptr , btermptr ;
+ int a , b , numberx , numbery ;
+ int attempts , reject ;
+ int xb , yb , axcenter , aycenter ;
+ int aorient , borient , newaor , newbor ;
+ int ll , rr , bb , tt , ax , ay , bx , by ;
+ int scalex , scaley ;
+ 
+ attempts = 0 ;
+ totFunc = 0.0 ;
+ 
+ /* numberx = (int) ( 0.1667 * (double) bdxlength * log10( 0.10 * T ));*/
+ numberx = (int)( pow( 4.0 , log10(T) ) / 1024.0 * (double) bdxlength ) ;
+ if( numberx < 3 ) {
+     numberx = 3 ;
+ } else if( numberx > bdxlength ) {
+     numberx = bdxlength ;
+ }
+ 
+ /* numbery = (int) ( 0.1667 * (double) bdylength * log10( 0.10 * T ));*/
+ numbery = (int)( pow( 4.0 , log10(T) ) / 1024.0 * (double) bdylength ) ;
+ if( numbery < 3 ) {
+     numbery = 3 ;
+ } else if( numbery > bdylength ) {
+     numbery = bdylength ;
+ } 
+ scalex = numberx / 3 ;
+ scaley = numbery / 3 ;
+ fprintf(fpo,"range limiter:%d units either way in x",numberx);
+ fprintf(fpo,"   compared to bdxlength:%d\n",bdxlength);
+ fprintf(fpo,"range limiter:%d units either way in y",numbery);
+ fprintf(fpo,"   compared to bdylength:%d\n",bdylength);
+ fprintf(fpo,"scalex:%d  scaley:%d\n", scalex , scaley ) ;
+ 
+ while( attempts < trials ) {
+     do {
+ 	a = (int) ( (double) numcells * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( a == numcells + 1 ) ;
+ 
+     do {
+ 	b = (int) ( (double) bigcell * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( b == toobig ) ;
+ 
+     if( a == b ) {
+ 	continue ;
+     }
+ 
+     acellptr = cellarray[ a ]   ;
+     aorient  = acellptr->orient ;
+ 
+     if( b > numcells ) {
+ 	if( acellptr->class != 0 ) {
+ 	    continue ;
+ 	}
+ 	axcenter = acellptr->xcenter ;
+ 	aycenter = acellptr->ycenter ;
+ 
+ 	ll = (blockl > axcenter-numberx) ? (blockl - axcenter) / scalex :
+ 		( (blockr <= axcenter - numberx) ? 
+ 		(blockr - axcenter) / scalex : (- numberx / scalex) ) ;
+ 	rr = (blockr < axcenter+numberx) ? (blockr - axcenter) / scalex :
+ 		( (blockl >= axcenter + numberx) ? 
+ 		(blockl - axcenter) /scalex : (numberx / scalex) ) ;
+ 	bb = (blockb > aycenter-numbery) ? (blockb - aycenter) / scaley :
+ 		( (blockt <= aycenter - numbery) ? 
+ 		(blockt - aycenter) / scaley : (- numbery / scaley) ) ;
+ 	tt = (blockt < aycenter+numbery) ? (blockt - aycenter) / scaley :
+ 		( (blockb >= aycenter + numbery) ? 
+ 		(blockb - aycenter) / scaley : (numbery / scaley) ) ;
+ 	xb = (int)((double)(rr - ll + 1) * ((double)RAND /
+ 					(double) 0x7fffffff ) ) + ll ;
+ 	yb = (int)((double)(tt - bb + 1) * ((double)RAND /
+ 					(double) 0x7fffffff ) ) + bb ;
+ 	if( xb == 0 && yb == 0 ) {
+ 	    continue ;
+ 	}
+ 	xb = axcenter + scalex * xb ;
+ 	yb = aycenter + scaley * yb ;
+ 
+ 	if( gridGiven ) {
+ 	    termptr  = acellptr->config[aorient]->termptr ;
+ 	    forceGrid( xb + termptr->xpos , yb + termptr->ypos ) ;
+ 	    xb = newxx - termptr->xpos ;
+ 	    yb = newyy - termptr->ypos ;
+ 	}
+ 
+         if( usite1( a , xb , yb ) ) {
+ 	    attempts++ ;
+ 	    totFunc += (double) funccost ;
+ 	} else {
+ 	    newaor = newOrient( acellptr , 4 ) ;
+ 	    reject = 1 ;
+ 	    if( newaor >= 0 ) {
+ 		if( usiteo1( a , xb , yb , newaor ) ) {
+ 		    attempts++ ;
+ 		    totFunc += (double) funccost ;
+ 		    reject = 0 ;
+ 		}
+ 	    }
+ 	    if( reject ) {
+ 		newaor = newOrient( acellptr , 8 ) ;
+ 		if( newaor >= 0 ) {
+ 		    if( usite0( a , newaor ) ) {
+ 			attempts++ ;
+ 			totFunc += (double) funccost ;
+ 			reject = 0 ;
+ 		    }
+ 		}
+ 	    }
+ 	} 
+     } else { /*   b <= numcells   */
+ 	bcellptr = cellarray[b] ;
+ 	if( acellptr->class == -1 || bcellptr->class == -1 ||
+ 			    acellptr->class != bcellptr->class ) {
+ 	    continue ;
+ 	}
+ 	if( gridGiven ) {
+ 	    /*
+ 	     *   Force pin 1 to lie on the underlying grid, specified
+ 	     *   by:  n * (grid) + offset , in each direction.
+ 	     */
+ 	    btermptr = bcellptr->config[bcellptr->orient]->termptr ;
+ 	    termptr = acellptr->config[aorient]->termptr ;
+ 	    forceGrid( bcellptr->xcenter + termptr->xpos , 
+ 		       bcellptr->ycenter + termptr->ypos ) ;
+ 	    ax = newxx - termptr->xpos ;
+ 	    ay = newyy - termptr->ypos ;
+ 	    forceGrid( acellptr->xcenter + btermptr->xpos , 
+ 		       acellptr->ycenter + btermptr->ypos ) ;
+ 	    bx = newxx - btermptr->xpos ;
+ 	    by = newyy - btermptr->ypos ;
+ 	} else {
+ 	    ax = bcellptr->xcenter ;
+ 	    ay = bcellptr->ycenter ;
+ 	    bx = acellptr->xcenter ;
+ 	    by = acellptr->ycenter ;
+ 	}
+ 
+ 	if( usite2( a , b , ax , ay , bx , by )  ) {
+ 	    attempts++ ;
+ 	    totFunc += (double) funccost ;
+ 	} else {
+ 	    /*
+ 		try again with opposite orientation types
+ 	    */
+ 	    newaor = newOrient( acellptr , 4 ) ;
+ 	    borient = cellarray[b]->orient ;
+ 	    newbor = newOrient( cellarray[b] , 4 ) ;
+ 	    if( newaor >= 0 || newbor >= 0 ) {
+ 		if( newaor < 0 ) {
+ 		    newaor = aorient ;
+ 		} else if( newbor < 0 ) {
+ 		    newbor = borient ;
+ 		}
+ 		if( gridGiven ) {
+ 		    btermptr = bcellptr->config[newbor]-> termptr ;
+ 		    termptr = acellptr->config[newaor]->termptr ;
+ 		    forceGrid( bcellptr->xcenter + termptr->xpos , 
+ 			       bcellptr->ycenter + termptr->ypos ) ;
+ 		    ax = newxx - termptr->xpos ;
+ 		    ay = newyy - termptr->ypos ;
+ 		    forceGrid( acellptr->xcenter + btermptr->xpos , 
+ 			       acellptr->ycenter + btermptr->ypos ) ;
+ 		    bx = newxx - btermptr->xpos ;
+ 		    by = newyy - btermptr->ypos ;
+ 		} else {
+ 		    ax = bcellptr->xcenter ;
+ 		    ay = bcellptr->ycenter ;
+ 		    bx = acellptr->xcenter ;
+ 		    by = acellptr->ycenter ;
+ 		}
+ 		if( usiteo2( a, b, ax, ay, bx, by, newaor, newbor) ) {
+ 		    attempts++ ;
+ 		    totFunc += (double) funccost ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( attempts ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/twstats.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/twstats.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/twstats.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,42 ----
+ #include "custom.h"
+ extern int iwire, iwirex , iwirey , icost ;
+ extern int fwire, fwirex , fwirey , fcost ;
+ 
+ void twstats(void)
+ {
+ 
+ fprintf( fpo,"\nInitial Wiring Cost: %d   Final Wiring Cost: %d\n",
+ 						icost , fcost ) ;
+ if( icost != 0 ) {
+     fprintf(fpo,"############ Percent Wire Cost Reduction: %d\n\n",
+ 	100 - (int)( (double)fcost / (double)icost * 100.0 ) ) ;
+ }
+ 
+ fprintf( fpo,"\nInitial Wire Length: %d   Final Wire Length: %d\n",
+ 					    iwire, fwire ) ;
+ if( icost != 0 ) {
+     fprintf(fpo,"*********** Percent Wire Length Reduction: %d\n\n",
+ 	100 - (int)( (double) fwire / (double) iwire * 100.0 ) );
+ }
+ 
+ fprintf( fpo,"\nInitial Horiz. Wire: %d   Final Horiz. Wire: %d\n",
+ 					    iwirex , fwirex ) ;
+ if( iwirex != 0 ) {
+     fprintf(fpo,"$$$$$$$$$ Percent H-Wire Length Reduction: %d\n\n",
+ 	100 - (int)( (double)fwirex / (double)iwirex * 100.0 ) ) ;
+ }
+ fprintf( fpo,"\nInitial Vert. Wire: %d   Final Vert. Wire: %d\n",
+ 					    iwirey , fwirey ) ;
+ if( iwirey != 0 ) {
+     fprintf(fpo,"@@@@@@@@@ Percent V-Wire Length Reduction: %d\n\n",
+ 	100 - (int)( (double)fwirey / (double)iwirey * 100.0 ) ) ;
+ }
+ 
+ fprintf( fpo , "\nStatistics:\n");
+ fprintf( fpo , "Number of Cells: %d\n", numcells );
+ fprintf( fpo , "Number of Pads: %d\n", numpads );
+ fprintf( fpo , "Number of Nets: %d \n", numnets ) ;
+ fprintf( fpo , "Number of Pins: %d \n", maxterm ) ;
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/uaspect.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/uaspect.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/uaspect.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,467 ----
+ #include "custom.h"
+ 
+ extern void move( int moveType );
+ extern void rect( int *l , int *b , int *r , int *t );
+ extern void point( int *x , int *y );
+ extern int ufixnet( TERMBOXPTR termsptr );
+ extern void ufixpin( TERMBOXPTR termsptr , int flag , int targetx ,
+ 		    int targety );
+ extern int usoftnet( CELLBOXPTR cellptr );
+ extern void usoftpin( CELLBOXPTR cellptr , int flag , int targetx ,
+ 		     int targety , int orient );
+ 
+ int uaspect( int a , double newAspect )
+ {
+ 
+ CELLBOXPTR acellptr , ptr ;
+ TERMNETSPTR tmptr ;
+ TILEBOXPTR atileptr , tptr , tptr0 ;
+ TILEBOXPTR tileptr1 ;
+ TERMBOXPTR termptr , atermptr , tmptr1 , tmptr0 ;
+ UNCOMBOX *UCptr ;
+ LOCBOX *SLptr , *siteptr , *siteptr0 ;
+ 
+ int tm , site , length , height , orient , aorient ;
+ int cost , newpenalty , tilenum , termnum ;
+ int x , y , i ;
+ int axcenter , aycenter , Hdiv2 , Wdiv2 ;
+ int oleft , oright , obottom , otop ;
+ double aspFactor , val ;
+ 
+ 
+ acellptr = cellarray[ a ]    ;
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ aorient  = acellptr->orient  ;
+ atileptr = acellptr->config[ aorient ] ;
+ atermptr = atileptr->termptr ;
+ oleft   = atileptr->oleft    ;
+ oright  = atileptr->oright   ;
+ obottom = atileptr->obottom  ;
+ otop    = atileptr->otop     ;
+ 
+ UCptr = acellptr->unComTerms ;
+ SLptr = atileptr->siteLocArray ;
+ 
+ if( aorient <= 3 ) {
+     aspFactor = sqrt( newAspect / acellptr->aspectO ) ;
+ } else {
+     aspFactor = sqrt( acellptr->aspectO / newAspect ) ;
+ }
+ val = (double)(otop - obottom) * aspFactor ;
+ Hdiv2 = ROUND( val ) / 2 ;
+ val = (double)(oright - oleft) / aspFactor ;
+ Wdiv2 = ROUND( val ) / 2 ;
+ 
+ newpenalty = penalty ;
+ 
+ newpenalty -= (*overlap)( a, axcenter, aycenter, aorient, 0, 1, 0 ) ;
+ occa1ptr = blockarray[binX][binY] ;
+ 
+ newpenalty += (*overlapx)( a, oleft, obottom, Wdiv2, Hdiv2, aspFactor);
+ occa2ptr = blockarray[binX][binY] ;
+ 
+ 
+ for( termptr = atermptr ; termptr != TERMNULL ; termptr =
+ 						termptr->nextterm ) {
+     val = (double)(termptr->oxpos - oleft) / aspFactor ;
+     x = axcenter + ROUND( val ) - Wdiv2 ;
+     val = (double)(termptr->oypos - obottom) * aspFactor ;
+     y = aycenter + ROUND( val ) - Hdiv2 ;
+ 
+     tmptr = termarray[ termptr->terminal ] ;
+     netarray[ tmptr->net ]->flag = 1 ;
+     tmptr->termptr->flag = 1 ;
+     tmptr->termptr->newx = x ;
+     tmptr->termptr->newy = y ;
+ }
+ for( tm = 1 ; tm <= acellptr->numUnComTerms ; tm++ ) {
+     val = (double)(SLptr[ UCptr[tm].site ].oxpos - oleft) / aspFactor ;
+     x = axcenter + ROUND( val ) - Wdiv2 ;
+     val = (double)(SLptr[ UCptr[tm].site ].oypos - obottom) * aspFactor;
+     y = aycenter + ROUND( val ) - Hdiv2 ;
+ 
+     tmptr = termarray[ UCptr[tm].terminal ] ;
+     netarray[ tmptr->net ]->flag = 1 ;
+     tmptr->termptr->flag = 1 ;
+     tmptr->termptr->newx = x ;
+     tmptr->termptr->newy = y ;
+ }
+ 
+ cost = funccost ;
+ 
+ cost += ufixnet( atermptr ) ;
+ cost += usoftnet( acellptr ) ;
+ 
+ 
+ if( ( cost + newpenalty <= funccost + penalty ) || 
+ 	(exp( (double)( funccost + penalty - cost - newpenalty ) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ) {
+ 
+     ufixpin( atermptr, 1, 0 , 0 ) ;
+     usoftpin( acellptr, 1, 0, 0, 0 ) ;
+ 
+     if( occa1ptr != occa2ptr ) {
+ 	for( i = 1 ; occa1ptr[ i ] != a ; i++ ) ;
+ 	occa1ptr[ i ] = occa1ptr[  occa1ptr[0]--  ] ;
+ 	occa2ptr[ ++occa2ptr[0]  ] = a ;
+     }
+ 
+     /*
+      *   Time to compute the new coordinates for the cell
+      *   since its aspect ratio has changed.  Do it for
+      *   the orient 0 version and then use the routines
+      *   from readcells() to transfer for other orients.
+      */
+ 
+     for( tileptr1 = atileptr ; tileptr1 != TILENULL ;
+ 				   tileptr1 = tileptr1->nexttile ){
+ 	val = (double)(tileptr1->oleft - oleft) / aspFactor ;
+ 	tileptr1->left   = ROUND( val ) - Wdiv2 ;
+ 	val = (double)(tileptr1->oright - oleft) / aspFactor ;
+ 	tileptr1->right  = ROUND( val ) - Wdiv2 ;
+ 	val = (double)(tileptr1->obottom - obottom) * aspFactor ;
+ 	tileptr1->bottom = ROUND( val ) - Hdiv2 ;
+ 	val = (double)(tileptr1->otop - obottom) * aspFactor ;
+ 	tileptr1->top    = ROUND( val ) - Hdiv2 ;
+     }
+ 
+     for( termptr = atermptr ; termptr != TERMNULL ; termptr =
+ 					    termptr->nextterm ) {
+ 	val = (double)(termptr->oxpos - oleft) / aspFactor ;
+ 	termptr->xpos = ROUND( val ) - Wdiv2 ;
+ 	val = (double)(termptr->oypos - obottom) * aspFactor ;
+ 	termptr->ypos = ROUND( val ) - Hdiv2 ;
+     }
+     for( site = 1 ; site <= acellptr->numsites ; site++ ) {
+ 	val = (double)(SLptr[ site ].oxpos - oleft) / aspFactor ;
+ 	SLptr[site].xpos = ROUND( val ) - Wdiv2 ;
+ 	val = (double)(SLptr[ site ].oypos - obottom) * aspFactor ;
+ 	SLptr[site].ypos = ROUND( val ) - Hdiv2 ;
+    } 
+ 
+     /*
+ 	NOW WE HAVE TO LOAD IN THE OTHER CONFIGURATIONS
+     */
+ 
+     ptr = acellptr ;
+ 
+     if( aorient != 0 ) {
+ 	height = atileptr->top - atileptr->bottom ;
+ 	length = atileptr->right - atileptr->left ;
+ 	switch( aorient ) {
+ 	    case 1 : orient = 1 ;
+ 		     break ;
+ 	    case 2 : orient = 2 ;
+ 		     break ;
+ 	    case 3 : orient = 3 ;
+ 		     break ;
+ 	    case 4 : orient = 4 ;
+ 		     break ;
+ 	    case 5 : orient = 5 ;
+ 		     break ;
+ 	    case 6 : orient = 7 ;
+ 		     break ;
+ 	    case 7 : orient = 6 ;
+ 		     break ;
+ 	}
+ 	tptr0 = ptr->config[ 0 ] ;
+ 	tptr  = atileptr ;
+ 	tptr0->left     = tptr->left   ;
+ 	tptr0->right    = tptr->right  ;
+ 	tptr0->bottom   = tptr->bottom ;
+ 	tptr0->top      = tptr->top    ;
+ 
+ 	move( orient ) ;
+ 
+ 	rect( &tptr0->left , &tptr0->bottom , &tptr0->right , 
+ 						&tptr0->top ) ;
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || 
+ 					orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || 
+ 					orient == 3))){
+ 
+ 	    tptr0->left++  ;
+ 	    tptr0->right++ ;
+ 	}
+ 	if( (height % 2 != 0 && (orient == 1 || 
+ 					orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || 
+ 					orient == 7))){
+ 
+ 	    tptr0->bottom++ ;
+ 	    tptr0->top++    ;
+ 	}
+ 	for( tilenum = 1 ; tilenum <= ptr->numtiles ; 
+ 						tilenum++ ) {
+ 	    tptr0 = tptr0->nexttile ;
+ 	    tptr  = tptr->nexttile ; 
+ 	    tptr0->left   = tptr->left   ;
+ 	    tptr0->right  = tptr->right  ;
+ 	    tptr0->bottom = tptr->bottom ;
+ 	    tptr0->top    = tptr->top    ;
+ 
+ 	    move( orient ) ; 
+ 
+ 	    rect( &tptr0->left, &tptr0->bottom, &tptr0->right , 
+ 						&tptr0->top ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		tptr0->left++  ;
+ 		tptr0->right++ ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		tptr0->bottom++ ;
+ 		tptr0->top++    ;
+ 	    }
+ 	}
+ 
+ 	/*  And NOW for the fixed terminals */
+ 
+ 	if( ptr->numterms != 0 ) {
+ 	    tmptr0 = ptr->config[ 0 ]->termptr ;
+ 	    tmptr1 = atermptr ;
+ 	    tmptr0->xpos = tmptr1->xpos ;
+ 	    tmptr0->ypos = tmptr1->ypos ;
+ 
+ 	    move( orient ) ; 
+ 
+ 	    point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		tmptr0->xpos++  ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		tmptr0->ypos++ ;
+ 	    }
+ 	    for( termnum = 2 ; termnum <= ptr->numterms ; 
+ 						termnum++ ) {
+ 		tmptr0 = tmptr0->nextterm ;
+ 		tmptr1  = tmptr1->nextterm ; 
+ 		tmptr0->xpos = tmptr1->xpos ;
+ 		tmptr0->ypos = tmptr1->ypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &tmptr0->xpos , &tmptr0->ypos ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		    tmptr0->xpos++  ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		    tmptr0->ypos++ ;
+ 		}
+ 	    }
+ 	}
+ 
+ 	/*  Now the sites for the soft cells */
+ 
+ 	if( ptr->numsites != 0 ) {
+ 	    siteptr0 = ptr->config[ 0 ]->siteLocArray ;
+ 	    siteptr = SLptr ;
+ 	    for( site = 1 ; site <= ptr->numsites ; site++ ) {
+ 		siteptr0[ site ].xpos = siteptr[ site ].xpos ;
+ 		siteptr0[ site ].ypos = siteptr[ site ].ypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &(siteptr0[ site ].xpos) , 
+ 		       &(siteptr0[ site ].ypos) );
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 ||
+ 						orient == 3))){
+ 		    siteptr0[ site ].xpos++ ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 ||
+ 						orient == 7))){
+ 		    siteptr0[ site ].ypos++ ;
+ 		}
+ 	    }
+ 	}
+     }
+     /* ************************************************** */
+     height = ptr->config[0]->top - ptr->config[0]->bottom ;
+     length = ptr->config[0]->right - ptr->config[0]->left ;
+ 
+     for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	if( orient == aorient ) {
+ 	    continue ;
+ 	}
+ 	tptr0 = ptr->config[ 0 ] ;
+ 	tptr  = ptr->config[ orient ] ; 
+ 	tptr->left     = tptr0->left   ;
+ 	tptr->right    = tptr0->right  ;
+ 	tptr->bottom   = tptr0->bottom ;
+ 	tptr->top      = tptr0->top    ;
+ 
+ 	move( orient ) ;
+ 
+ 	rect( &tptr->left , &tptr->bottom , &tptr->right , 
+ 						&tptr->top ) ;
+ 
+ 	if( (height % 2 != 0 && (orient == 4 || orient == 6))||
+ 	    (length % 2 != 0 && (orient == 2 || orient == 3))){
+ 
+ 	    tptr->left++  ;
+ 	    tptr->right++ ;
+ 	}
+ 	if( (height % 2 != 0 && (orient == 1 || orient == 3))||
+ 	    (length % 2 != 0 && (orient == 4 || orient == 7))){
+ 
+ 	    tptr->bottom++ ;
+ 	    tptr->top++    ;
+ 	}
+ 	for( tilenum = 1 ; tilenum <= ptr->numtiles ; 
+ 						tilenum++ ) {
+ 	    tptr0 = tptr0->nexttile ;
+ 	    tptr  = tptr->nexttile ; 
+ 	    tptr->left     = tptr0->left   ;
+ 	    tptr->right    = tptr0->right  ;
+ 	    tptr->bottom   = tptr0->bottom ;
+ 	    tptr->top      = tptr0->top    ;
+ 
+ 	    move( orient ) ; 
+ 
+ 	    rect( &tptr->left, &tptr->bottom, &tptr->right , 
+ 						&tptr->top ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		tptr->left++  ;
+ 		tptr->right++ ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		tptr->bottom++ ;
+ 		tptr->top++    ;
+ 	    }
+ 	}
+     }
+ 
+     /*  And NOW for the fixed terminals */
+ 
+     if( ptr->numterms != 0 ) {
+ 
+ 	for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	    if( orient == aorient ) {
+ 		continue ;
+ 	    }
+ 	    tmptr0 = ptr->config[ 0 ]->termptr ;
+ 	    tmptr1 = ptr->config[ orient ]->termptr ; 
+ 	    tmptr1->xpos     = tmptr0->xpos     ;
+ 	    tmptr1->ypos     = tmptr0->ypos     ;
+ 
+ 	    move( orient ) ;
+ 
+ 	    point( &tmptr1->xpos , &tmptr1->ypos ) ;
+ 
+ 	    if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		(length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		tmptr1->xpos++  ;
+ 	    }
+ 	    if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		(length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		tmptr1->ypos++ ;
+ 	    }
+ 	    for( termnum = 2 ; termnum <= ptr->numterms ; 
+ 						termnum++ ) {
+ 		tmptr0 = tmptr0->nextterm ;
+ 		tmptr1  = tmptr1->nextterm ; 
+ 		tmptr1->xpos     = tmptr0->xpos ;
+ 		tmptr1->ypos     = tmptr0->ypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &tmptr1->xpos , &tmptr1->ypos ) ;
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 || 
+ 						orient == 3))){
+ 		    tmptr1->xpos++  ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 || 
+ 						orient == 7))){
+ 		    tmptr1->ypos++ ;
+ 		}
+ 	    }
+ 	}
+     }
+ 
+     /*  Now the sites for the soft cells */
+ 
+     if( ptr->numsites != 0 ) {
+ 
+ 	siteptr0 = ptr->config[ 0 ]->siteLocArray ;
+ 	for( orient = 1 ; orient <= 7 ; orient++ ) {
+ 	    if( orient == aorient ) {
+ 		continue ;
+ 	    }
+ 	    siteptr = ptr->config[ orient ]->siteLocArray ; 
+ 	    for( site = 1 ; site <= ptr->numsites ; site++ ) {
+ 		siteptr[ site ].xpos = siteptr0[ site ].xpos ;
+ 		siteptr[ site ].ypos = siteptr0[ site ].ypos ;
+ 
+ 		move( orient ) ; 
+ 
+ 		point( &(siteptr[ site ].xpos) , 
+ 		       &(siteptr[ site ].ypos) );
+ 
+ 		if( (height % 2 != 0 && (orient == 4 || 
+ 						orient == 6))||
+ 		    (length % 2 != 0 && (orient == 2 ||
+ 						orient == 3))){
+ 		    siteptr[ site ].xpos++ ;
+ 		}
+ 		if( (height % 2 != 0 && (orient == 1 || 
+ 						orient == 3))||
+ 		    (length % 2 != 0 && (orient == 4 ||
+ 						orient == 7))){
+ 		    siteptr[ site ].ypos++ ;
+ 		}
+ 	    }
+ 	}
+     }
+     /* **************************************************** */
+     acellptr->aspect = newAspect ;
+ 
+     funccost = cost ;
+     penalty = newpenalty ;
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ufixnet.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ufixnet.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ufixnet.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,76 ----
+ #include "custom.h"
+ 
+ int ufixnet( TERMBOXPTR termsptr )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ TERMNETSPTR tmptr ;
+ TERMBOXPTR termptr ;
+ 
+ int cost ;
+ int x , y ;
+ 
+ 
+ cost = 0 ;
+ for( termptr = termsptr ; termptr != TERMNULL ; termptr =
+ 					    termptr->nextterm ) {
+     tmptr = termarray[ termptr->terminal ];
+     dimptr = netarray[ tmptr->net ] ;
+     if( dimptr->flag == 0 || dimptr->skip == 1 ) {
+ 	continue ;
+     }
+     dimptr->flag = 0 ;
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->newx ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->xpos ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->ypos ;
+ 	}
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    x = netptr->newx ;
+ 	    y = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    x = netptr->xpos ;
+ 	    y = netptr->ypos ;
+ 	}
+ 	if( x < dimptr->newxmin ) {
+ 	    dimptr->newxmin = x ;
+ 	} else if( x > dimptr->newxmax ) {
+ 	    dimptr->newxmax = x ;
+ 	}
+ 	if( y < dimptr->newymin ) {
+ 	    dimptr->newymin = y ;
+ 	} else if( y > dimptr->newymax ) {
+ 	    dimptr->newymax = y ;
+ 	}
+     } 
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->newxmax - dimptr->newxmin))) - 
+ 	    ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->newymax - dimptr->newymin))) -
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ return( cost ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ufixpin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ufixpin.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ufixpin.c	Tue Oct  5 16:19:49 2004
***************
*** 0 ****
--- 1,33 ----
+ #include "custom.h"
+ 
+ void ufixpin( TERMBOXPTR termsptr , int flag , int targetx , int targety )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ TERMNETSPTR tmptr ;
+ TERMBOXPTR termptr ;
+ 
+ if( flag == 0 ) {
+     for( termptr = termsptr ; termptr != TERMNULL ; termptr =
+ 						termptr->nextterm ) {
+ 	tmptr = termarray[ termptr->terminal ] ;
+ 	netarray[ tmptr->net ]->flag = 1 ;
+ 	tmptr->termptr->flag = 1 ;
+ 	tmptr->termptr->newx = targetx + termptr->xpos ;
+ 	tmptr->termptr->newy = targety + termptr->ypos ;
+     }
+ } else {
+     for( termptr = termsptr ; termptr != TERMNULL ; termptr =
+ 					    termptr->nextterm ) {
+ 	tmptr = termarray[ termptr->terminal ] ;
+ 	dimptr = netarray[ tmptr->net ] ;
+ 	dimptr->xmin = dimptr->newxmin ;
+ 	dimptr->xmax = dimptr->newxmax ;
+ 	dimptr->ymin = dimptr->newymin ;
+ 	dimptr->ymax = dimptr->newymax ;
+ 	tmptr->termptr->xpos = tmptr->termptr->newx ;
+ 	tmptr->termptr->ypos = tmptr->termptr->newy ;
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/uloop.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/uloop.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/uloop.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,717 ----
+ #include "custom.h"
+ extern char **spots ;
+ extern int spotXhash ;
+ extern int spotYhash ;
+ extern int numXspots ;
+ extern int numYspots ;
+ extern int spotSize  ;
+ extern int choose ;
+ extern int bigcell ;
+ extern int toobig  ;
+ int flips , flipp , attp ;
+ int newxx , newyy ;
+ extern double Tsave ;
+ extern int rangeLimit ;
+ extern int count ;
+ 
+ extern int newOrient( CELLBOXPTR cellptr , int range );
+ extern int usite0( int a , int newaor );
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern int wireesty( int yc , int xx1 , int xx2 , double factor3 );
+ extern int uaspect( int a , double newAspect );
+ extern int usite1( int a , int xb , int yb );
+ extern int usiteo1( int a , int xb , int yb , int newaor );
+ extern int usite2( int a , int b , int ax , int ay , int bx , int by );
+ extern int usiteo2( int a , int b , int ax , int ay , int bx , int by, 
+ 		   int newaor ,int newbor );
+ extern void selectpin( CELLBOXPTR acellptr );
+ 
+ void forceGrid( int x , int y );
+ void pickSpot( CELLBOXPTR cellptr , int orient , int ll , int rr , int bb , 
+ 	      int tt , int *x , int *y );
+ void fixSpot( CELLBOXPTR cellptr , int oldx , int oldy , int oldorient );
+ void fixSpotAsp(CELLBOXPTR cellptr,int lft,int rte,int bot,int top);
+ 
+ void uloop(void)
+ {
+ 
+ CELLBOXPTR acellptr , bcellptr ;
+ TILEBOXPTR tileptr ;
+ TERMBOXPTR termptr , btermptr ;
+ double range , newAspect;
+ int a , b , numberx , numbery ;
+ int attempts , i ;
+ int xb , yb , axcenter , aycenter ;
+ int bxcenter , bycenter ;
+ int aorient , borient , newaor , newbor ;
+ int flip0, flipo, flip2, flipo2, flipa, flip1 ;
+ int att0, atto, att2, atto2, atta, att1 ;
+ int ll , rr , bb , tt , ax , ay , bx , by ;
+ int reject ;
+ int al , ar , ab , at ;
+ int bl , br , bt , min , minstep ;
+ int delt1 , delt2 ;
+ int lft, rte, bot, top, xcenter, ycenter ;
+ 
+ flips    = 0 ;
+ attempts = 0 ;
+ flip0    = 0 ;
+ att0     = 0 ;
+ flipo    = 0 ;
+ atto     = 0 ;
+ flip2    = 0 ;
+ att2     = 0 ;
+ flipo2   = 0 ;
+ atto2    = 0 ;
+ flipa    = 0 ;
+ atta     = 0 ;
+ flip1    = 0 ;
+ att1     = 0 ;
+ flipp    = 0 ;
+ attp     = 0 ;
+ 
+ 
+ numberx = rangeLimit ;
+ numbery = rangeLimit ;
+ if( count < 1 ) {
+     fprintf(fpo,"range limiter:%d units either way in x",numberx);
+     fprintf(fpo,"   compared to bdxlength:%d\n",bdxlength);
+     fprintf(fpo,"range limiter:%d units either way in y",numbery);
+     fprintf(fpo,"   compared to bdylength:%d\n",bdylength);
+ }
+ 
+ while( attempts < attmax ) {
+     do {
+ 	a = (int) ( (double) choose * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( a == choose + 1 ) ;
+ 
+     do {
+ 	b = (int) ( (double) bigcell * ( (double) RAND / 
+ 				    (double) 0x7fffffff ) ) + 1 ;
+     } while( b == toobig ) ;
+ 
+     if( a == b ) {
+ 	continue ;
+     }
+ 
+     acellptr = cellarray[ a ]   ;
+     aorient  = acellptr->orient ;
+ 
+     if( a > numcells && b <= numcells ) {
+ 	newaor = newOrient( acellptr , 8 ) ;
+ 	if( newaor >= 0 ) {
+ 	    if( usite0( a , newaor ) ) {
+ 		flips++ ;
+ 		flip0++ ;
+ 	    }
+ 	    att0++  ;
+ 	}
+     } else if( a <= numcells && b > numcells ) {
+ 	if( acellptr->class != 0 ) {
+ 	    continue ;
+ 	}
+ 	axcenter = acellptr->xcenter ;
+ 	aycenter = acellptr->ycenter ;
+ 
+ 	ll = (axcenter-numberx < blockl) ? blockl :
+ 	     (axcenter - numberx > blockr ? blockr : axcenter - numberx);
+ 	rr = (axcenter+numberx > blockr) ? blockr :
+ 	     (axcenter + numberx < blockl ? blockl : axcenter + numberx);
+ 	bb = (aycenter-numbery < blockb) ? blockb :
+ 	     (aycenter - numbery > blockt ? blockt : aycenter - numbery);
+ 	tt = (aycenter+numbery > blockt) ? blockt :
+ 	     (aycenter + numbery < blockb ? blockb : aycenter + numbery);
+ 
+ 	pickSpot( acellptr , aorient , ll , rr , bb , tt , &xb , &yb ) ;
+ 
+ 	if( gridGiven ) {
+ 	    termptr  = acellptr->config[aorient]->termptr ;
+ 	    forceGrid( xb + termptr->xpos , yb + termptr->ypos ) ;
+ 	    xb = newxx - termptr->xpos ;
+ 	    yb = newyy - termptr->ypos ;
+ 	}
+ 
+         if( usite1( a , xb , yb ) ) {
+ 	    flips++ ;
+ 	    flip1++ ;
+ 	    att1++ ;
+ 	    attempts++ ;
+ 
+ 	    fixSpot( acellptr , axcenter , aycenter , aorient ) ;
+ 
+ 	} else {
+ 	    attempts++ ;
+ 	    att1++ ;
+ 	    newaor = newOrient( acellptr , 4 ) ;
+ 	    reject = 1 ;
+ 	    if( newaor >= 0 ) {
+ 		if( usiteo1( a , xb , yb , newaor ) ) {
+ 		    flips++ ;
+ 		    flipo++ ;
+ 		    atto++  ;
+ 		    reject = 0 ;
+ 
+ 		    fixSpot( acellptr , axcenter , aycenter , aorient ) ;
+ 
+ 		} else {
+ 		    atto++  ;
+ 		}
+ 	    }
+ 	    if( reject ) {
+ 		newaor = newOrient( acellptr , 8 ) ;
+ 		reject = 1 ;
+ 		if( newaor >= 0 ) {
+ 		    if( usite0( a , newaor ) ) {
+ 			flips++ ;
+ 			flip0++ ;
+ 			att0++  ;
+ 			reject = 0 ;
+ 
+ 			fixSpot( acellptr, axcenter, aycenter, aorient);
+ 
+ 		    } else {
+ 			att0++  ;
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	if( acellptr->numUnComTerms != 0 ){
+ 	    for( i = 1 ; i <= acellptr->numgroups ; i++ ) {
+ 		selectpin( acellptr ) ;
+ 	    }
+ 	}
+ 	/*
+ 	 *   The goal here is to generate a new
+ 	 *   aspect ratio for the cell if such
+ 	 *   a thing is permitted.  First test
+ 	 *   for permission.
+ 	 */
+ 	if( acellptr->softflag != 0 &&
+ 		(acellptr->aspUB > 0.01 + acellptr->aspLB)){
+ 	    /*
+ 	     *   We have clearance for an aspect
+ 	     *   ratio change
+ 	     */
+ 	    range = acellptr->aspUB - acellptr->aspLB;
+ 	    newAspect = range * ((double)RAND / 
+ 		    (double) 0x7fffffff) + acellptr->aspLB ;
+ 
+ 	    xcenter = acellptr->xcenter ;
+ 	    ycenter = acellptr->ycenter ;
+ 	    lft = xcenter + acellptr->config[acellptr->orient]->left   ;
+ 	    rte = xcenter + acellptr->config[acellptr->orient]->right  ;
+ 	    bot = ycenter + acellptr->config[acellptr->orient]->bottom ;
+ 	    top = ycenter + acellptr->config[acellptr->orient]->top    ;
+ 
+ 	    if( uaspect( a , newAspect ) ) {
+ 		flips++ ;
+ 		flipa++ ;
+ 
+ 		fixSpotAsp(acellptr,lft,rte,bot,top) ;
+ 	    } 
+ 	    atta++ ;
+ 	}
+     } else { /*  a & b <= numcells or a & b > numcells  */
+ 	bcellptr = cellarray[b] ;
+ 	borient = bcellptr->orient ;
+ 	if( acellptr->class == -1 || bcellptr->class == -1 ||
+ 			    acellptr->class != bcellptr->class ) {
+ 	    continue ;
+ 	}
+ 	if( gridGiven ) {
+ 	    /*
+ 	     *   Force pin 1 to lie on the underlying grid, specified
+ 	     *   by:  n * (grid) + offset , in each direction.
+ 	     */
+ 	    btermptr = bcellptr->config[bcellptr->orient]->termptr ;
+ 	    termptr = acellptr->config[aorient]->termptr ;
+ 	    forceGrid( bcellptr->xcenter + termptr->xpos , 
+ 		       bcellptr->ycenter + termptr->ypos ) ;
+ 	    ax = newxx - termptr->xpos ;
+ 	    ay = newyy - termptr->ypos ;
+ 	    forceGrid( acellptr->xcenter + btermptr->xpos , 
+ 		       acellptr->ycenter + btermptr->ypos ) ;
+ 	    bx = newxx - btermptr->xpos ;
+ 	    by = newyy - btermptr->ypos ;
+ 	} else {
+ 	    ax = bcellptr->xcenter ;
+ 	    ay = bcellptr->ycenter ;
+ 	    bx = acellptr->xcenter ;
+ 	    by = acellptr->ycenter ;
+ 	}
+ 	axcenter = bx ;
+ 	aycenter = by ;
+ 	bxcenter = ax ;
+ 	bycenter = ay ;
+ 	/* ****************************************************** */
+ 	/*  SOMETHING NEW  */
+ 	tileptr = acellptr->config[ aorient ]  ;
+ 	al = ax + tileptr->left    ;
+ 	ar = ax + tileptr->right   ;
+ 	ab = ay + tileptr->bottom  ;
+ 	at = ay + tileptr->top     ;
+ 	if( a <= numcells ) {
+ 	    al -= wireestx(al,ab,at,tileptr->lweight ) ;
+ 	    ar += wireestx(ar,ab,at,tileptr->rweight ) ;
+ 	    ab -= wireesty(ab,al,ar,tileptr->bweight ) ;
+ 	    at += wireesty(at,al,ar,tileptr->tweight ) ;
+ 	}
+ 	tileptr = bcellptr->config[ bcellptr->orient ]  ;
+ 	bl = bx + tileptr->left    ;
+ 	br = bx + tileptr->right   ;
+ 	bb = by + tileptr->bottom  ;
+ 	bt = by + tileptr->top     ;
+ 	if( b <= numcells ) {
+ 	    bl -= wireestx(bl,bb,bt,tileptr->lweight ) ;
+ 	    br += wireestx(br,bb,bt,tileptr->rweight ) ;
+ 	    bb -= wireesty(bb,bl,br,tileptr->bweight ) ;
+ 	    bt += wireesty(bt,bl,br,tileptr->tweight ) ;
+ 	}
+ 	min = 1000000 ;
+ 	minstep = 0 ;
+ 	if( bl >= ar || al >= br || bb >= at || ab >= bt ) {
+ 	    if( bl < ar ) {
+ 		if( ar - bl < min ) { 
+ 		    minstep = 1 ;
+ 		    min = ar - bl ;
+ 		}
+ 	    }
+ 	    if( al < br ) {
+ 		if( br - al < min ) { 
+ 		    minstep = 2 ;
+ 		    min = br - al ;
+ 		}
+ 	    }
+ 	    if( bb < at ) {
+ 		if( at - bb < min ) { 
+ 		    minstep = 3 ;
+ 		    min = at - bb ;
+ 		}
+ 	    }
+ 	    if( ab < bt ) {
+ 		if( bt - ab < min ) { 
+ 		    minstep = 4 ;
+ 		    min = bt - ab ;
+ 		}
+ 	    }
+ 	}
+ 	if( minstep != 0 ) {
+ 	    delt1 = min / 2 ;
+ 	    delt2 = min - min / 2 ;
+ 	    if( minstep == 1 ) {
+ 		bx += delt1 ;
+ 		ax -= delt2 ;
+ 		if( br + delt1 > blockr ) {
+ 		    bx -= br + delt1 - blockr ;
+ 		    ax -= br + delt1 - blockr ;
+ 		} else if( al - delt2 < blockl ) {
+ 		    bx += blockl - (al - delt2) ;
+ 		    ax += blockl - (al - delt2) ;
+ 		}
+ 	    } else if( minstep == 2 ) {
+ 		ax += delt1 ;
+ 		bx -= delt2 ;
+ 		if( ar + delt1 > blockr ) {
+ 		    bx -= ar + delt1 - blockr ;
+ 		    ax -= ar + delt1 - blockr ;
+ 		} else if( bl - delt2 < blockl ) {
+ 		    bx += blockl - (bl - delt2) ;
+ 		    ax += blockl - (bl - delt2) ;
+ 		}
+ 	    } else if( minstep == 3 ) {
+ 		by += delt1 ;
+ 		ay -= delt2 ;
+ 		if( bt + delt1 > blockt ) {
+ 		    by -= bt + delt1 - blockt ;
+ 		    ay -= bt + delt1 - blockt ;
+ 		} else if( ab - delt2 < blockb ) {
+ 		    by += blockb - (ab - delt2) ;
+ 		    ay += blockb - (ab - delt2) ;
+ 		}
+ 	    } else {
+ 		ay += delt1 ;
+ 		by -= delt2 ;
+ 		if( at + delt1 > blockt ) {
+ 		    by -= at + delt1 - blockt ;
+ 		    ay -= at + delt1 - blockt ;
+ 		} else if( bb - delt2 < blockb ) {
+ 		    by += blockb - (bb - delt2) ;
+ 		    ay += blockb - (bb - delt2) ;
+ 		}
+ 	    }
+ 	}
+ 	/* ****************************************************** */
+ 	if( usite2( a , b , ax , ay , bx , by )  ) {
+ 	    flips++ ;
+ 	    flip2++ ;
+ 	    att2++  ;
+ 	    attempts++ ;
+ 
+ 	    fixSpot( acellptr , axcenter , aycenter , aorient ) ;
+ 	    fixSpot( bcellptr , bxcenter , bycenter , borient ) ;
+ 
+ 	} else {
+ 	    att2++  ;
+ 	    attempts++ ;
+ 	    /*
+ 		try again with opposite orientation types
+ 	    */
+ 	    newaor = newOrient( acellptr , 4 ) ;
+ 	    newbor = newOrient( bcellptr , 4 ) ;
+ 	    if( newaor >= 0 || newbor >= 0 ) {
+ 		if( newaor < 0 ) {
+ 		    newaor = aorient ;
+ 		} else if( newbor < 0 ) {
+ 		    newbor = borient ;
+ 		}
+ 		if( gridGiven ) {
+ 		    btermptr = bcellptr->config[newbor]-> termptr ;
+ 		    termptr = acellptr->config[newaor]->termptr ;
+ 		    forceGrid( bcellptr->xcenter + termptr->xpos , 
+ 			       bcellptr->ycenter + termptr->ypos ) ;
+ 		    ax = newxx - termptr->xpos ;
+ 		    ay = newyy - termptr->ypos ;
+ 		    forceGrid( acellptr->xcenter + btermptr->xpos , 
+ 			       acellptr->ycenter + btermptr->ypos ) ;
+ 		    bx = newxx - btermptr->xpos ;
+ 		    by = newyy - btermptr->ypos ;
+ 		} else {
+ 		    ax = bcellptr->xcenter ;
+ 		    ay = bcellptr->ycenter ;
+ 		    bx = acellptr->xcenter ;
+ 		    by = acellptr->ycenter ;
+ 		}
+ 		/* ************************************************** */
+ 		/*  SOMETHING NEW  */
+ 		tileptr = acellptr->config[ newaor ]  ;
+ 		al = ax + tileptr->left    ;
+ 		ar = ax + tileptr->right   ;
+ 		ab = ay + tileptr->bottom  ;
+ 		at = ay + tileptr->top     ;
+ 		if( a <= numcells ) {
+ 		    al -= wireestx(al,ab,at,tileptr->lweight ) ;
+ 		    ar += wireestx(ar,ab,at,tileptr->rweight ) ;
+ 		    ab -= wireesty(ab,al,ar,tileptr->bweight ) ;
+ 		    at += wireesty(at,al,ar,tileptr->tweight ) ;
+ 		}
+ 		tileptr = bcellptr->config[ newbor ]  ;
+ 		bl = bx + tileptr->left    ;
+ 		br = bx + tileptr->right   ;
+ 		bb = by + tileptr->bottom  ;
+ 		bt = by + tileptr->top     ;
+ 		if( b <= numcells ) {
+ 		    bl -= wireestx(bl,bb,bt,tileptr->lweight ) ;
+ 		    br += wireestx(br,bb,bt,tileptr->rweight ) ;
+ 		    bb -= wireesty(bb,bl,br,tileptr->bweight ) ;
+ 		    bt += wireesty(bt,bl,br,tileptr->tweight ) ;
+ 		}
+ 		min = 1000000 ;
+ 		minstep = 0 ;
+ 		if( bl >= ar || al >= br || bb >= at || ab >= bt ) {
+ 		    if( bl < ar ) {
+ 			if( ar - bl < min ) { 
+ 			    minstep = 1 ;
+ 			    min = ar - bl ;
+ 			}
+ 		    }
+ 		    if( al < br ) {
+ 			if( br - al < min ) { 
+ 			    minstep = 2 ;
+ 			    min = br - al ;
+ 			}
+ 		    }
+ 		    if( bb < at ) {
+ 			if( at - bb < min ) { 
+ 			    minstep = 3 ;
+ 			    min = at - bb ;
+ 			}
+ 		    }
+ 		    if( ab < bt ) {
+ 			if( bt - ab < min ) { 
+ 			    minstep = 4 ;
+ 			    min = bt - ab ;
+ 			}
+ 		    }
+ 		}
+ 		if( minstep != 0 ) {
+ 		    delt1 = min / 2 ;
+ 		    delt2 = min - min / 2 ;
+ 		    if( minstep == 1 ) {
+ 			bx += delt1 ;
+ 			ax -= delt2 ;
+ 			if( br + delt1 > blockr ) {
+ 			    bx -= br + delt1 - blockr ;
+ 			    ax -= br + delt1 - blockr ;
+ 			} else if( al - delt2 < blockl ) {
+ 			    bx += blockl - (al - delt2) ;
+ 			    ax += blockl - (al - delt2) ;
+ 			}
+ 		    } else if( minstep == 2 ) {
+ 			ax += delt1 ;
+ 			bx -= delt2 ;
+ 			if( ar + delt1 > blockr ) {
+ 			    bx -= ar + delt1 - blockr ;
+ 			    ax -= ar + delt1 - blockr ;
+ 			} else if( bl - delt2 < blockl ) {
+ 			    bx += blockl - (bl - delt2) ;
+ 			    ax += blockl - (bl - delt2) ;
+ 			}
+ 		    } else if( minstep == 3 ) {
+ 			by += delt1 ;
+ 			ay -= delt2 ;
+ 			if( bt + delt1 > blockt ) {
+ 			    by -= bt + delt1 - blockt ;
+ 			    ay -= bt + delt1 - blockt ;
+ 			} else if( ab - delt2 < blockb ) {
+ 			    by += blockb - (ab - delt2) ;
+ 			    ay += blockb - (ab - delt2) ;
+ 			}
+ 		    } else {
+ 			ay += delt1 ;
+ 			by -= delt2 ;
+ 			if( at + delt1 > blockt ) {
+ 			    by -= at + delt1 - blockt ;
+ 			    ay -= at + delt1 - blockt ;
+ 			} else if( bb - delt2 < blockb ) {
+ 			    by += blockb - (bb - delt2) ;
+ 			    ay += blockb - (bb - delt2) ;
+ 			}
+ 		    }
+ 		}
+ 		/* ************************************************** */
+ 
+ 		if( usiteo2( a, b, ax, ay, bx, by, newaor, newbor) ) {
+ 		    flips++  ;
+ 		    flipo2++ ;
+ 		    atto2++  ;
+ 		    attempts++ ;
+ 
+ 		    fixSpot( acellptr , axcenter , aycenter , aorient ) ;
+ 		    fixSpot( bcellptr , bxcenter , bycenter , borient ) ;
+ 
+ 		} else {
+ 		    atto2++  ;
+ 		    attempts++ ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ fprintf(fpo,"acceptance breakdown:\n"); 
+ fprintf(fpo,"              single cell: %d / %d\n", flip1 , att1) ;
+ fprintf(fpo,"     single w/ orient chg: %d / %d\n", flipo , atto) ;
+ fprintf(fpo,"               orient chg: %d / %d\n", flip0 , att0) ;
+ fprintf(fpo,"                pin moves: %d / %d\n", flipp , attp) ;
+ fprintf(fpo,"        aspect ratio chgs: %d / %d\n", flipa , atta) ;
+ fprintf(fpo,"        cell interchanges: %d / %d\n", flip2 , att2) ;
+ fprintf(fpo,"      interchgs w/ orient: %d / %d\n", flipo2 ,atto2);
+ fprintf(fpo,"\tno. of accepted flips: %d\n", flips ) ;
+ /*
+ doublecheck() ;
+ fprintf(fpo,"TimberWolf Wire Cost: %d   Penalty: %d\n\n",funccost,
+ 							    penalty);
+ */
+ return ;
+ }
+ 
+ 
+ void forceGrid( int x , int y )
+ {
+ 
+ newxx = ( (x - gOffsetX) / gridX ) * gridX + gOffsetX ;
+ if( ABS(newxx + gridX - x) < ABS(newxx - x) ) {
+     newxx += gridX ;
+ }
+ newyy = ( (y - gOffsetY) / gridY ) * gridY + gOffsetY ;
+ if( ABS(newyy + gridY - y) < ABS(newyy - y) ) {
+     newyy += gridY ;
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void pickSpot( CELLBOXPTR cellptr , int orient , int ll , int rr , int bb , 
+                int tt , int *x , int *y )
+ {
+ 
+ TILEBOXPTR tileptr ;
+ int lspot , rspot , bspot , tspot ;
+ int l , r , b , t ;
+ int llspot , rrspot , bbspot , ttspot ;
+ int xrange , yrange ;
+ int xspot , yspot ;
+ int xc , yc ;
+ 
+ llspot = (ll - spotXhash) / spotSize ;
+ rrspot = (rr - spotXhash) / spotSize ;
+ bbspot = (bb - spotYhash) / spotSize ;
+ ttspot = (tt - spotYhash) / spotSize ;
+ xrange = rrspot - llspot + 1 ;
+ yrange = ttspot - bbspot + 1 ;
+ 
+ tileptr = cellptr->config[orient] ;
+ xc = cellptr->xcenter    ;
+ yc = cellptr->ycenter    ;
+ l = xc + tileptr->left   ;
+ r = xc + tileptr->right  ;
+ b = yc + tileptr->bottom ;
+ t = yc + tileptr->top    ;
+ 
+ l -= wireestx(l,b,t,tileptr->lweight ) ;
+ r += wireestx(r,b,t,tileptr->rweight ) ;
+ b -= wireesty(b,l,r,tileptr->bweight ) ;
+ t += wireesty(t,l,r,tileptr->tweight ) ;
+ 
+ lspot = (l - spotXhash) / spotSize ;
+ rspot = (r - spotXhash) / spotSize ;
+ bspot = (b - spotYhash) / spotSize ;
+ tspot = (t - spotYhash) / spotSize ;
+ 
+ xspot = (cellptr->xcenter - spotXhash) / spotSize ;
+ yspot = (cellptr->ycenter - spotYhash) / spotSize ;
+ 
+ 
+ for( ; ; ) {
+     *x = (int) ( (double) xrange * ( (double) RAND / 
+ 				(double) 0x7fffffff ) ) + llspot ;
+     *y = (int) ( (double) yrange * ( (double) RAND / 
+ 				(double) 0x7fffffff ) ) + bbspot ;
+     if( spots[*x][*y] == 0 ) {
+ 	break ;
+     }
+     if( *x >= lspot && *x <= rspot && *y >= bspot && *y <= tspot 
+ 		&& ((ABS(*x - xspot) > 1) || (ABS(*y - yspot) > 1)) ) {
+ 	break ;
+     }
+ }
+ /*
+  *   Randomly select (*x,*y) location within spot [*x,*y]
+  */
+ *x = *x * spotSize + spotXhash ;
+ *y = *y * spotSize + spotYhash ;
+ 
+ *x += (int)((double) spotSize * ((double) RAND / (double) 0x7fffffff));
+ *y += (int)((double) spotSize * ((double) RAND / (double) 0x7fffffff));
+ 
+ return ;
+ }
+ 
+ 
+ void fixSpot( CELLBOXPTR cellptr , int oldx , int oldy , int oldorient )
+ {
+ 
+ TILEBOXPTR tileptr ;
+ int lspot , rspot , bspot , tspot ;
+ int xc , yc , x , y ;
+ int l , r , b , t ;
+ register char *sarray ;
+ 
+ tileptr = cellptr->config[oldorient] ;
+ l = oldx + tileptr->left   ;
+ r = oldx + tileptr->right  ;
+ b = oldy + tileptr->bottom ;
+ t = oldy + tileptr->top    ;
+ 
+ l -= wireestx(l,b,t,tileptr->lweight ) ;
+ r += wireestx(r,b,t,tileptr->rweight ) ;
+ b -= wireesty(b,l,r,tileptr->bweight ) ;
+ t += wireesty(t,l,r,tileptr->tweight ) ;
+ 
+ lspot = (l - spotXhash) / spotSize ;
+ rspot = (r - spotXhash) / spotSize ;
+ bspot = (b - spotYhash) / spotSize ;
+ tspot = (t - spotYhash) / spotSize ;
+ for( x = lspot + 1 ; x < rspot ; x++ ) {
+     sarray = spots[x] + bspot ;
+     for( y = bspot + 1 ; y < tspot ; y++ ) {
+ 	(*(++sarray))-- ;
+     }
+ }
+ 
+ tileptr = cellptr->config[cellptr->orient] ;
+ xc = cellptr->xcenter    ;
+ yc = cellptr->ycenter    ;
+ l = xc + tileptr->left   ;
+ r = xc + tileptr->right  ;
+ b = yc + tileptr->bottom ;
+ t = yc + tileptr->top    ;
+ 
+ l -= wireestx(l,b,t,tileptr->lweight ) ;
+ r += wireestx(r,b,t,tileptr->rweight ) ;
+ b -= wireesty(b,l,r,tileptr->bweight ) ;
+ t += wireesty(t,l,r,tileptr->tweight ) ;
+ 
+ lspot = (l - spotXhash) / spotSize ;
+ rspot = (r - spotXhash) / spotSize ;
+ bspot = (b - spotYhash) / spotSize ;
+ tspot = (t - spotYhash) / spotSize ;
+ 
+ for( x = lspot + 1 ; x < rspot ; x++ ) {
+     sarray = spots[x] + bspot ;
+     for( y = bspot + 1 ; y < tspot ; y++ ) {
+ 	(*(++sarray))++ ;
+     }
+ }
+ 
+ return ;
+ }
+ 
+ 
+ void fixSpotAsp(CELLBOXPTR cellptr,int lft,int rte,int bot,int top)
+ {
+ 
+ TILEBOXPTR tileptr ;
+ int lspot , rspot , bspot , tspot ;
+ int xc , yc , x , y ;
+ int l , r , b , t ;
+ register char *sarray ;
+ 
+ 
+ /* XXX what the HELL is going on here, haven't you ever heard of lint! */
+ /* tileptr has not value at this point in time! */
+ l = lft - wireestx(lft,bot,top,tileptr->lweight ) ;
+ r = rte + wireestx(rte,bot,top,tileptr->rweight ) ;
+ b = bot - wireesty(bot,lft,rte,tileptr->bweight ) ;
+ t = top - wireesty(top,lft,rte,tileptr->tweight ) ;
+ 
+ lspot = (l - spotXhash) / spotSize ;
+ rspot = (r - spotXhash) / spotSize ;
+ bspot = (b - spotYhash) / spotSize ;
+ tspot = (t - spotYhash) / spotSize ;
+ 
+ for( x = lspot + 1 ; x < rspot ; x++ ) {
+     sarray = spots[x] + bspot ;
+     for( y = bspot + 1 ; y < tspot ; y++ ) {
+ 	(*(++sarray))-- ;
+     }
+ }
+ 
+ tileptr = cellptr->config[cellptr->orient] ;
+ xc = cellptr->xcenter    ;
+ yc = cellptr->ycenter    ;
+ l = xc + tileptr->left   ;
+ r = xc + tileptr->right  ;
+ b = yc + tileptr->bottom ;
+ t = yc + tileptr->top    ;
+ 
+ l -= wireestx(l,b,t,tileptr->lweight ) ;
+ r += wireestx(r,b,t,tileptr->rweight ) ;
+ b -= wireesty(b,l,r,tileptr->bweight ) ;
+ t += wireesty(t,l,r,tileptr->tweight ) ;
+ 
+ lspot = (l - spotXhash) / spotSize ;
+ rspot = (r - spotXhash) / spotSize ;
+ bspot = (b - spotYhash) / spotSize ;
+ tspot = (t - spotYhash) / spotSize ;
+ 
+ for( x = lspot + 1 ; x < rspot ; x++ ) {
+     sarray = spots[x] + bspot ;
+     for( y = bspot + 1 ; y < tspot ; y++ ) {
+ 	(*(++sarray))++ ;
+     }
+ }
+ 
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/unbust.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/unbust.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/unbust.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,543 ----
+ #include "custom.h"
+ /* #define DEBUG */
+   /*
+    *  P   : current vertex point
+    *  u() : lowest point directly above P.  Returns 0 if none. 
+    *  l() : rightmost point directly left of P.  Returns 0 if none.
+    *  b() : highest point directly below P.  Returns 0 if none.
+    *  r() : leftmost point directly right of P.  Returns 0 if none.
+    *  outputP() : outputs vertex included in outline.
+    *  elim()    : deletes vertex from list.
+    */
+ typedef struct Rangle {
+     int rl ;
+     int rr ;
+     int rb ;
+     int rt ;
+ } RANGLE ;
+ extern RANGLE *rectang ;
+ extern BUSTBOXPTR PtsArray ;
+ extern BUSTBOXPTR PtsOut   ;
+ extern FILE *fpo ;
+ 
+ int u(int Pt);
+ int l(int Pt);
+ int r(int Pt);
+ int b(int Pt);
+ void elim( int Pt );
+ void outputP( int Pt );
+ void condense(void);
+ int firstP(void);
+ void coincide(void);
+ void dumpError(void);
+ 
+ void unbust(void)
+ {
+     int P , status , P1 ;
+ 
+     coincide() ;  /* eliminate coincidental points */
+     P = firstP() ; /* P is the leftmost of lowest vertices. 
+     /*
+      *  the variable status reflects the direction the last
+      *  step took.  If the last step was: 
+      *  up then status = 1 ;
+      *  left then status = 2 ;
+      *  right then status = 3 ;
+      *  bottom ( or down ) then status = 4 ;
+      *
+      *  After a u move, the next possibilities are ( in order ):
+      * 				l , u , r
+      *  After a l move, the next possibilities are ( in order ):
+      * 				b , l , u
+      *  After a r move, the next possibilities are ( in order ):
+      * 				u , r , b
+      *  After a b move, the next possibilities are ( in order ):
+      * 				r , b , l
+      *  If none of the possibilities are satisfied, there are
+      *  no more vertices to consider.
+      *
+      */
+     if( (P1 = u(P)) == 0 ) {
+ 	fprintf(fpo,"Serious error: could not advance upward ");
+ 	fprintf(fpo,"from first vertex\n");
+ 	exit(0);
+     }
+     outputP(P);
+     P = P1 ;
+     status = 1 ;
+     for( ; ; ) {
+ 	switch( status ) {
+ 	    case 1 : 
+ 		    if( (P1 = l(P)) == 0 ) {
+ 			if( (P1 = u(P)) == 0 ) {
+ 			    if( (P1 = r(P)) == 0 ) {
+ 				outputP(P);
+ 				condense() ;
+ 				return ;
+ 			    } else {
+ 				outputP(P);
+ 				elim(P);
+ 				if( P1 <= PtsArray[0].xc ) {
+ 				    P = P1 ;
+ 				}
+ 				status = 3 ;
+ 			    }
+ 			} else {
+ 			    outputP(P);
+ 			    elim(P);
+ 			    if( P1 <= PtsArray[0].xc ) {
+ 				P = P1 ;
+ 			    }
+ 			    status = 1 ;
+ 			}
+ 		    } else {
+ 			outputP(P);
+ 			elim(P);
+ 			if( P1 <= PtsArray[0].xc ) {
+ 			    P = P1 ;
+ 			}
+ 			status = 2 ;
+ 		    }
+ 		    break ;
+ 	    case 2 :
+ 		    if( (P1 = b(P)) == 0 ) {
+ 			if( (P1 = l(P)) == 0 ) {
+ 			    if( (P1 = u(P)) == 0 ) {
+ 				outputP(P);
+ 				condense() ;
+ 				return ;
+ 			    } else {
+ 				outputP(P);
+ 				elim(P);
+ 				if( P1 <= PtsArray[0].xc ) {
+ 				    P = P1 ;
+ 				}
+ 				status = 1 ;
+ 			    }
+ 			} else {
+ 			    outputP(P);
+ 			    elim(P);
+ 			    if( P1 <= PtsArray[0].xc ) {
+ 				P = P1 ;
+ 			    }
+ 			    status = 2 ;
+ 			}
+ 		    } else {
+ 			outputP(P);
+ 			elim(P);
+ 			if( P1 <= PtsArray[0].xc ) {
+ 			    P = P1 ;
+ 			}
+ 			status = 4 ;
+ 		    }
+ 		    break ;
+ 	    case 3 :
+ 		    if( (P1 = u(P)) == 0 ) {
+ 			if( (P1 = r(P)) == 0 ) {
+ 			    if( (P1 = b(P)) == 0 ) {
+ 				outputP(P);
+ 				condense() ;
+ 				return ;
+ 			    } else {
+ 				outputP(P);
+ 				elim(P);
+ 				if( P1 <= PtsArray[0].xc ) {
+ 				    P = P1 ;
+ 				}
+ 				status = 4 ;
+ 			    }
+ 			} else {
+ 			    outputP(P);
+ 			    elim(P);
+ 			    if( P1 <= PtsArray[0].xc ) {
+ 				P = P1 ;
+ 			    }
+ 			    status = 3 ;
+ 			}
+ 		    } else {
+ 			outputP(P);
+ 			elim(P);
+ 			if( P1 <= PtsArray[0].xc ) {
+ 			    P = P1 ;
+ 			}
+ 			status = 1 ;
+ 		    }
+ 		    break ;
+ 	    case 4 :
+ 		    if( (P1 = r(P)) == 0 ) {
+ 			if( (P1 = b(P)) == 0 ) {
+ 			    if( (P1 = l(P)) == 0 ) {
+ 				outputP(P);
+ 				condense() ;
+ 				return ;
+ 			    } else {
+ 				outputP(P);
+ 				elim(P);
+ 				if( P1 <= PtsArray[0].xc ) {
+ 				    P = P1 ;
+ 				}
+ 				status = 2 ;
+ 			    }
+ 			} else {
+ 			    outputP(P);
+ 			    elim(P);
+ 			    if( P1 <= PtsArray[0].xc ) {
+ 				P = P1 ;
+ 			    }
+ 			    status = 4 ;
+ 			}
+ 		    } else {
+ 			outputP(P);
+ 			elim(P);
+ 			if( P1 <= PtsArray[0].xc ) {
+ 			    P = P1 ;
+ 			}
+ 			status = 3 ;
+ 		    }
+ 		    break ;
+ 	}
+     }
+ }
+ 
+ void addPts( int l , int r , int b , int t )
+ {
+ 
+     PtsArray[ ++PtsArray[0].xc ].xc = l ;
+     PtsArray[   PtsArray[0].xc ].yc = b ;
+     PtsArray[ ++PtsArray[0].xc ].xc = l ;
+     PtsArray[   PtsArray[0].xc ].yc = t ;
+     PtsArray[ ++PtsArray[0].xc ].xc = r ;
+     PtsArray[   PtsArray[0].xc ].yc = b ;
+     PtsArray[ ++PtsArray[0].xc ].xc = r ;
+     PtsArray[   PtsArray[0].xc ].yc = t ;
+     rectang[ ++rectang[0].rl ].rl = l ;
+     rectang[   rectang[0].rl ].rr = r ;
+     rectang[   rectang[0].rl ].rb = b ;
+     rectang[   rectang[0].rl ].rt = t ;
+     return ;
+ }
+ 
+ /*ARGSUSED*/
+ void initPts( int cell , char *name , int orient )
+ {
+     int i ;
+ 
+ #ifdef DEBUG
+     printf("cell:%d  name: %s  orient:%d\n",cell,name,orient);
+     fflush(stdout);
+ #endif
+     for( i = 0 ; i <= 100 ; i++ ) {
+ 	PtsArray[i].xc = 0 ;
+ 	PtsArray[i].yc = 0 ;
+ 	PtsOut[i].xc = 0 ;
+ 	PtsOut[i].xc = 0 ;
+     }
+     for( i = 0 ; i <= 25 ; i++ ) {
+ 	rectang[i].rl = 0 ;
+ 	rectang[i].rr = 0 ;
+ 	rectang[i].rb = 0 ;
+ 	rectang[i].rt = 0 ;
+     }
+     return ;
+ }
+ 
+ int recCheck( int Pt1 , int Pt2 ) 
+ {
+     int Px1 , Py1 , Px2 , Py2 , i , rl , rr , rb , rt ;
+     
+     Px1 = PtsArray[Pt1].xc ;
+     Py1 = PtsArray[Pt1].yc ;
+     Px2 = PtsArray[Pt2].xc ;
+     Py2 = PtsArray[Pt2].yc ;
+     for( i = 1 ; i <= rectang[0].rl ; i++ ) {
+ 	rl = rectang[i].rl ;
+ 	rr = rectang[i].rr ;
+ 	rb = rectang[i].rb ;
+ 	rt = rectang[i].rt ;
+ 	if( Px1 >= rl && Px1 <= rr && Py1 >= rb && Py1 <= rt ) {
+ 	    /*  Pt1 is contained by this rectangle */
+ 	    if( Px2 >= rl && Px2 <= rr && Py2 >= rb && Py2 <= rt ) {
+ 		/*  Pt2 is also contained by this rectangle */
+ 		return(1) ;
+ 	    }
+ 	}
+     }
+     return(0) ;
+ }
+ 
+ int u(int Pt)
+ {
+     int i , ptx , pty , small , smallP ;
+ 
+     small = 100000000 ;
+     smallP = 0 ;
+     ptx = PtsArray[Pt].xc ;
+     pty = PtsArray[Pt].yc ;
+     for( i = 1 ; i <= PtsArray[0].xc ; i++ ) {
+ 	if( i == Pt ) {
+ 	    continue ;
+ 	}
+ 	if( PtsArray[i].xc != ptx ) {
+ 	    continue ;
+ 	}
+ 	/*  Now we have another point on the same vert. line */
+ 	if( PtsArray[i].yc > pty ) {
+ 	    if( PtsArray[i].yc - pty < small ) {
+ 		small = PtsArray[i].yc - pty ;
+ 		smallP = i ;
+ 	    }
+ 	}
+     }
+     if( smallP != 0 ) {
+ 	/* check if two endpoints belong to same rectangle */
+ 	if( recCheck( Pt , smallP ) == 0 ) {
+ 	    /* do not belong to same rectangle */
+ 	    smallP = 0 ;
+ 	}
+     }
+     return( smallP ) ;
+ }
+ 
+ 
+ int l(int Pt)
+ {
+     int i , ptx , pty , small , smallP ;
+ 
+     small = 100000000 ;
+     smallP = 0 ;
+     ptx = PtsArray[Pt].xc ;
+     pty = PtsArray[Pt].yc ;
+     for( i = 1 ; i <= PtsArray[0].xc ; i++ ) {
+ 	if( i == Pt ) {
+ 	    continue ;
+ 	}
+ 	if( PtsArray[i].yc != pty ) {
+ 	    continue ;
+ 	}
+ 	/*  Now we have another point on the same horz. line */
+ 	if( PtsArray[i].xc < ptx ) {
+ 	    if( ptx - PtsArray[i].xc < small ) {
+ 		small = ptx - PtsArray[i].xc ;
+ 		smallP = i ;
+ 	    }
+ 	}
+     }
+     if( smallP != 0 ) {
+ 	/* check if two endpoints belong to same rectangle */
+ 	if( recCheck( Pt , smallP ) == 0 ) {
+ 	    /* do not belong to same rectangle */
+ 	    smallP = 0 ;
+ 	}
+     }
+     return( smallP ) ;
+ }
+ 
+ 
+ int r(int Pt)
+ {
+     int i , ptx , pty , small , smallP ;
+ 
+     small = 100000000 ;
+     smallP = 0 ;
+     ptx = PtsArray[Pt].xc ;
+     pty = PtsArray[Pt].yc ;
+     for( i = 1 ; i <= PtsArray[0].xc ; i++ ) {
+ 	if( i == Pt ) {
+ 	    continue ;
+ 	}
+ 	if( PtsArray[i].yc != pty ) {
+ 	    continue ;
+ 	}
+ 	/*  Now we have another point on the same horz. line */
+ 	if( PtsArray[i].xc > ptx ) {
+ 	    if( PtsArray[i].xc - ptx < small ) {
+ 		small = PtsArray[i].xc - ptx ;
+ 		smallP = i ;
+ 	    }
+ 	}
+     }
+     if( smallP != 0 ) {
+ 	/* check if two endpoints belong to same rectangle */
+ 	if( recCheck( Pt , smallP ) == 0 ) {
+ 	    /* do not belong to same rectangle */
+ 	    smallP = 0 ;
+ 	}
+     }
+     return( smallP ) ;
+ }
+ 
+ 
+ int b(int Pt)
+ {
+     int i , ptx , pty , small , smallP ;
+ 
+     small = 100000000 ;
+     smallP = 0 ;
+     ptx = PtsArray[Pt].xc ;
+     pty = PtsArray[Pt].yc ;
+     for( i = 1 ; i <= PtsArray[0].xc ; i++ ) {
+ 	if( i == Pt ) {
+ 	    continue ;
+ 	}
+ 	if( PtsArray[i].xc != ptx ) {
+ 	    continue ;
+ 	}
+ 	/*  Now we have another point on the same vert. line */
+ 	if( PtsArray[i].yc < pty ) {
+ 	    if( pty - PtsArray[i].yc < small ) {
+ 		small = pty - PtsArray[i].yc ;
+ 		smallP = i ;
+ 	    }
+ 	}
+     }
+     if( smallP != 0 ) {
+ 	/* check if two endpoints belong to same rectangle */
+ 	if( recCheck( Pt , smallP ) == 0 ) {
+ 	    /* do not belong to same rectangle */
+ 	    smallP = 0 ;
+ 	}
+     }
+     return( smallP ) ;
+ }
+ 
+ 
+ void elim( int Pt )
+ {
+     PtsArray[Pt].xc = PtsArray[ PtsArray[0].xc   ].xc ;
+     PtsArray[Pt].yc = PtsArray[ PtsArray[0].xc-- ].yc ;
+     return ;
+ }
+ 
+ void outputP( int Pt )
+ {
+     PtsOut[ ++PtsOut[0].xc ].xc = PtsArray[Pt].xc ;
+     PtsOut[   PtsOut[0].xc ].yc = PtsArray[Pt].yc ;
+     return ;
+ }
+ 
+ void condense(void)
+ {
+     int P1x , P1y , P2x , P2y , P3x , P3y , j , P1 , P2 , P3 ;
+ 
+     if( PtsArray[0].xc != 1 ) {
+ 	printf("Fatal error in unbust.c\n");
+ 	dumpError() ;
+ 	exit(0) ;
+     }
+     P1  = 1 ;
+     P2  = 2 ;
+     for( P3 = 3 ; P3 <= PtsOut[0].xc ; P3++ ) {
+ 	P1x = PtsOut[P1].xc ;
+ 	P1y = PtsOut[P1].yc ;
+ 	P2x = PtsOut[P2].xc ;
+ 	P2y = PtsOut[P2].yc ;
+ 	P3x = PtsOut[P3].xc ;
+ 	P3y = PtsOut[P3].yc ;
+ 	if( P1x == P2x ) {  /* V segment */
+ 	    if( P3x == P1x ) {  /* P2 is extra */
+ 		for( j = P3 ; j <= PtsOut[0].xc ; j++ ) {
+ 		    PtsOut[j - 1].xc = PtsOut[j].xc ;
+ 		    PtsOut[j - 1].yc = PtsOut[j].yc ;
+ 		}
+ 		PtsOut[0].xc-- ;
+ 		P2 = --P3 ;
+ 	    } else {
+ 		P1 = P2 ;
+ 		P2 = P3 ;
+ 	    }
+ 	} else if( P1y == P2y ) {  /* H segment */
+ 	    if( P3y == P1y ) {  /* P2 is extra */
+ 		for( j = P3 ; j <= PtsOut[0].xc ; j++ ) {
+ 		    PtsOut[j - 1].xc = PtsOut[j].xc ;
+ 		    PtsOut[j - 1].yc = PtsOut[j].yc ;
+ 		}
+ 		PtsOut[0].xc-- ;
+ 		P2 = --P3 ;
+ 	    } else {
+ 		P1 = P2 ;
+ 		P2 = P3 ;
+ 	    }
+ 	} else {
+ 	    fprintf(fpo,"Two points in outline not rectilinear ");
+ 	    fprintf(fpo,"and this constitutes death\n");
+ 	    exit(0);
+ 	}
+     }
+     return ;
+ }
+ 
+ 
+ int firstP(void)
+ {
+     int k , ymin , xmin , P ;
+ 
+     ymin = 100000000 ;
+     for( k = 1 ; k <= PtsArray[0].xc ; k++ ) {
+ 	if( PtsArray[k].yc < ymin ) {
+ 	    ymin = PtsArray[k].yc ;
+ 	}
+     }  /* we have the lowest y coordinate  */
+     xmin = 100000000 ;
+     for( k = 1 ; k <= PtsArray[0].xc ; k++ ) {
+ 	if( PtsArray[k].yc == ymin ) {
+ 	    if( PtsArray[k].xc < xmin ) {
+ 		xmin = PtsArray[k].xc ;
+ 		P = k ;
+ 	    }
+ 	}
+     }  /*  we have the leftmost of the lowest vertices  */
+     return( P );
+ }
+ 
+ 
+ void coincide(void)
+ {
+     int i , x0 , y0 , j ;
+     /*
+      *  Now eliminate coincidental points
+      */
+     for( i = 1 ; i <= PtsArray[0].xc ; i++ ) {
+ 	x0 = PtsArray[i].xc ;
+ 	y0 = PtsArray[i].yc ;
+ 	for( j = i + 1 ; j <= PtsArray[0].xc ; j++ ) {
+ 	    if( x0 == PtsArray[j].xc  &&  y0 == PtsArray[j].yc ) {
+ 		/* eliminate point j */
+ 		PtsArray[j  ].xc = PtsArray[ PtsArray[0].xc   ].xc ;
+ 		PtsArray[j--].yc = PtsArray[ PtsArray[0].xc-- ].yc ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ 
+ void dumpError(void)
+ {
+ 
+ int i , x , y , l , r , b , t ;
+ 
+ printf("PtsOut:\n");
+ for( i = 1 ; i <= PtsOut[0].xc ; i++ ) {
+     x = PtsOut[i].xc ;
+     y = PtsOut[i].yc ;
+     printf("x:%d  y:%d\n", x , y ) ;
+ }
+ 
+ printf("PtsArray:\n");
+ for( i = 1 ; i <= PtsArray[0].xc ; i++ ) {
+     x = PtsArray[i].xc ;
+     y = PtsArray[i].yc ;
+     printf("x:%d  y:%d\n", x , y ) ;
+ }
+ 
+ printf("Rectangles:\n");
+ for( i = 1 ; i <= rectang[0].rl ; i++ ) {
+     l = rectang[i].rl ;
+     r = rectang[i].rr ;
+     b = rectang[i].rb ;
+     t = rectang[i].rt ;
+     printf("l:%d  r:%d  b:%d  t:%d\n", l , r , b , t ) ;
+ }
+ 
+ fflush(stdout) ;
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/upin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/upin.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/upin.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,192 ----
+ #include "custom.h"
+ extern double Tsave ;
+ 
+ int upin( CELLBOXPTR acellptr , int UCpin , int seq , int firstNewSite , 
+       int lastNewSite )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ TERMNETSPTR tmptr ;
+ TILEBOXPTR atileptr ;
+ UNCOMBOX *UCptr ;
+ LOCBOX *SLptr ;
+ CONTENTBOX *SCptr ;
+ 
+ int tm , site , cost , newOverFill , capacity , count ;
+ int x , y , newsite ;
+ int excess ; 
+ int axcenter , aycenter ;
+ double Tscale ;
+ 
+ Tscale = Tsave / 100000.0 ;
+ 
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ atileptr = acellptr->config[ acellptr->orient ] ;
+ 
+ UCptr = acellptr->unComTerms   ;
+ SCptr = acellptr->siteContent  ;
+ SLptr = atileptr->siteLocArray ;
+ 
+ newOverFill = overfill ;
+ /*
+     First we must refresh the 'newContents' field of the
+     array pointed to by SCptr
+ */
+ for( site = firstNewSite ; site <= lastNewSite ; site++ ) {
+     SCptr[ site ].newContents = SCptr[ site ].contents ;
+ }
+ for( site = UCptr[ UCpin ].site ; 
+ 	    site <= UCptr[ UCpin + seq - 1 ].site ; site++ ) {
+     SCptr[ site ].newContents = SCptr[ site ].contents ;
+ }
+ 
+ for( tm = UCpin ; tm < UCpin + seq ; tm++ ) {
+     site = UCptr[ tm ].site ;
+     excess = SCptr[ site ].newContents-- - SCptr[ site ].capacity ;
+     if( excess > 0 ) {
+ 	if( excess == 1 ) {
+ 	    newOverFill -= (int)( Tscale * 10.0 ) ; 
+ 	} else {
+ 	    newOverFill -= (int)( Tscale * 10.0 * 
+ 			( (double)(excess * excess)) ) - 
+ 			(int)( Tscale * 10.0 * 
+ 			( (double)((excess - 1) * (excess - 1)))) ;
+ 	}
+     }
+ }
+ 
+ site = firstNewSite - 1 ;
+ capacity = 0 ;
+ count = 0 ;
+ for( tm = UCpin ; tm < UCpin + seq ; tm++ ) {
+     count++ ;
+     if( count > capacity ) {
+ 	site++ ;
+ 	count = 1 ;
+ 	capacity = SCptr[ site ].capacity ;
+     } 
+     excess = ++SCptr[ site ].newContents - capacity ;
+     if( excess > 0 ) {
+ 	if( excess == 1 ) {
+ 	    newOverFill += (int)( Tscale * 10.0 ) ; 
+ 	} else {
+ 	    newOverFill += (int)( Tscale * 10.0 * 
+ 			( (double)(excess * excess)) ) - 
+ 			(int)( Tscale * 10.0 * 
+ 			( (double)((excess - 1) * (excess - 1)))) ;
+ 	}
+     }
+     UCptr[tm].newsite = site ;
+ }
+ 
+ for( tm = UCpin ; tm < UCpin + seq ; tm++ ) {
+     newsite = UCptr[ tm ].newsite ;
+     x = SLptr[ newsite ].xpos + axcenter ;
+     y = SLptr[ newsite ].ypos + aycenter ;
+ 
+     tmptr = termarray[ UCptr[tm].terminal ] ;
+     netarray[ tmptr->net ]->flag = 1 ;
+     tmptr->termptr->flag = 1 ;
+     tmptr->termptr->newx = x ;
+     tmptr->termptr->newy = y ;
+ }
+ 
+ cost = funccost ;
+ 
+ for( tm = UCpin ; tm < UCpin + seq ; tm++ ) {
+     tmptr = termarray[ UCptr[tm].terminal ] ;
+     dimptr = netarray[ tmptr->net ] ;
+     if( dimptr->flag == 0 || dimptr->skip == 1 ) {
+ 	continue ;
+     }
+     dimptr->flag = 0 ;
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->newx ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->xpos ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->ypos ;
+ 	}
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    x = netptr->newx ;
+ 	    y = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    x = netptr->xpos ;
+ 	    y = netptr->ypos ;
+ 	}
+ 	if( x < dimptr->newxmin ) {
+ 	    dimptr->newxmin = x ;
+ 	} else if( x > dimptr->newxmax ) {
+ 	    dimptr->newxmax = x ;
+ 	}
+ 	if( y < dimptr->newymin ) {
+ 	    dimptr->newymin = y ;
+ 	} else if( y > dimptr->newymax ) {
+ 	    dimptr->newymax = y ;
+ 	}
+     }
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->newxmax - dimptr->newxmin))) - 
+ 	    ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->newymax - dimptr->newymin))) -
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ 
+ }
+ 
+ 
+ if( ( cost + newOverFill <= funccost + overfill ) || 
+ 	(exp( (double)( funccost + overfill - cost - newOverFill) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+     for( tm = UCpin ; tm < UCpin + seq ; tm++ ) {
+ 	tmptr = termarray[ UCptr[tm].terminal ] ;
+ 	dimptr = netarray[ tmptr->net ] ;
+ 
+ 	dimptr->xmin = dimptr->newxmin ;
+ 	dimptr->xmax = dimptr->newxmax ;
+ 	dimptr->ymin = dimptr->newymin ;
+ 	dimptr->ymax = dimptr->newymax ;
+ 
+ 	tmptr->termptr->xpos = tmptr->termptr->newx ;
+ 	tmptr->termptr->ypos = tmptr->termptr->newy ;
+     }
+     for( site = firstNewSite ; site <= lastNewSite ; site++ ) {
+ 	SCptr[ site ].contents = SCptr[ site ].newContents ;
+     }
+     for( site = UCptr[ UCpin ].site ; 
+ 		site <= UCptr[ UCpin + seq - 1 ].site ; site++ ) {
+ 	SCptr[ site ].contents = SCptr[ site ].newContents ;
+     }
+     for( tm = UCpin ; tm < UCpin + seq ; tm++ ) {
+ 	UCptr[ tm ].site = UCptr[ tm ].newsite ;
+     }
+ 
+     funccost = cost ;
+     overfill = newOverFill ;
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/upinswap.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/upinswap.c:1.1
*** /dev/null	Tue Oct  5 16:20:06 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/upinswap.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,194 ----
+ #include "custom.h"
+ 
+ int upinswap(CELLBOXPTR acellptr,int pin1,int pin2,int site1,int site2 )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ TERMNETSPTR tmptr ;
+ TILEBOXPTR atileptr ;
+ UNCOMBOX *UCptr ;
+ LOCBOX *SLptr ;
+ int cost , temp ;
+ int x , y ;
+ int axcenter , aycenter ;
+ 
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ atileptr = acellptr->config[ acellptr->orient ] ;
+ UCptr = acellptr->unComTerms   ;
+ SLptr = atileptr->siteLocArray ;
+ 
+ x = SLptr[site2].xpos + axcenter ;
+ y = SLptr[site2].ypos + aycenter ;
+ tmptr = termarray[ UCptr[pin1].terminal ] ;
+ netarray[tmptr->net]->flag = 1 ;
+ tmptr->termptr->flag = 1 ;
+ tmptr->termptr->newx = x ;
+ tmptr->termptr->newy = y ;
+ 
+ 
+ x = SLptr[site1].xpos + axcenter ;
+ y = SLptr[site1].ypos + aycenter ;
+ tmptr = termarray[ UCptr[pin2].terminal ] ;
+ netarray[tmptr->net]->flag = 1 ;
+ tmptr->termptr->flag = 1 ;
+ tmptr->termptr->newx = x ;
+ tmptr->termptr->newy = y ;
+ 
+ 
+ cost = funccost ;
+ 
+ 
+ tmptr = termarray[ UCptr[pin1].terminal ] ;
+ dimptr = netarray[ tmptr->net ] ;
+ if( dimptr->flag != 0 && dimptr->skip != 1 ) {
+     dimptr->flag = 0 ;
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->newx ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->xpos ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->ypos ;
+ 	}
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    x = netptr->newx ;
+ 	    y = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    x = netptr->xpos ;
+ 	    y = netptr->ypos ;
+ 	}
+ 	if( x < dimptr->newxmin ) {
+ 	    dimptr->newxmin = x ;
+ 	} else if( x > dimptr->newxmax ) {
+ 	    dimptr->newxmax = x ;
+ 	}
+ 	if( y < dimptr->newymin ) {
+ 	    dimptr->newymin = y ;
+ 	} else if( y > dimptr->newymax ) {
+ 	    dimptr->newymax = y ;
+ 	}
+     }
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->newxmax - dimptr->newxmin))) - 
+ 	    ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->newymax - dimptr->newymin))) -
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ 
+ tmptr = termarray[ UCptr[pin2].terminal ] ;
+ dimptr = netarray[ tmptr->net ] ;
+ if( dimptr->flag != 0 && dimptr->skip != 1 ) {
+     dimptr->flag = 0 ;
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->newx ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->xpos ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->ypos ;
+ 	}
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    x = netptr->newx ;
+ 	    y = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    x = netptr->xpos ;
+ 	    y = netptr->ypos ;
+ 	}
+ 	if( x < dimptr->newxmin ) {
+ 	    dimptr->newxmin = x ;
+ 	} else if( x > dimptr->newxmax ) {
+ 	    dimptr->newxmax = x ;
+ 	}
+ 	if( y < dimptr->newymin ) {
+ 	    dimptr->newymin = y ;
+ 	} else if( y > dimptr->newymax ) {
+ 	    dimptr->newymax = y ;
+ 	}
+     }
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->newxmax - dimptr->newxmin))) - 
+ 	    ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->newymax - dimptr->newymin))) -
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ 
+ if( ( cost <= funccost ) || (exp( (double)( funccost - cost ) /
+ 		    T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+     
+     tmptr = termarray[ UCptr[pin1].terminal ] ;
+     dimptr = netarray[ tmptr->net ] ;
+     dimptr->xmin = dimptr->newxmin ;
+     dimptr->xmax = dimptr->newxmax ;
+     dimptr->ymin = dimptr->newymin ;
+     dimptr->ymax = dimptr->newymax ;
+     tmptr->termptr->xpos = tmptr->termptr->newx ;
+     tmptr->termptr->ypos = tmptr->termptr->newy ;
+     
+     tmptr = termarray[ UCptr[pin2].terminal ] ;
+     dimptr = netarray[ tmptr->net ] ;
+     dimptr->xmin = dimptr->newxmin ;
+     dimptr->xmax = dimptr->newxmax ;
+     dimptr->ymin = dimptr->newymin ;
+     dimptr->ymax = dimptr->newymax ;
+     tmptr->termptr->xpos = tmptr->termptr->newx ;
+     tmptr->termptr->ypos = tmptr->termptr->newy ;
+ 
+     temp = UCptr[pin1].terminal ;
+     UCptr[pin1].terminal = UCptr[pin2].terminal ;
+     UCptr[pin2].terminal = temp ;
+ 
+     temp = UCptr[pin1].site ;
+     UCptr[pin1].site = UCptr[pin2].site ;
+     UCptr[pin2].site = temp ;
+ 
+     temp = UCptr[pin1].sequence ;
+     UCptr[pin1].sequence = UCptr[pin2].sequence ;
+     UCptr[pin2].sequence = temp ;
+ 
+     funccost = cost ;
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite0.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite0.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite0.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,68 ----
+ #include "custom.h"
+ 
+ extern void ufixpin( TERMBOXPTR termsptr , int flag , int targetx ,
+ 		    int targety );
+ extern int ufixnet( TERMBOXPTR termsptr );
+ extern void usoftpin( CELLBOXPTR cellptr , int flag , int targetx ,
+                       int target , int orient );
+ extern int usoftnet( CELLBOXPTR cellptr );
+ 
+ 
+ int usite0( int a , int newaor )
+ {
+ 
+ CELLBOXPTR acellptr ;
+ TERMBOXPTR anewtermptr ;
+ 
+ int cost , newpenalty , i ;
+ int axcenter , aycenter ;
+ 
+ 
+ acellptr = cellarray[a]    ;
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ anewtermptr = acellptr->config[newaor]->termptr ;
+ 
+ 
+ newpenalty = penalty ;
+ 
+ newpenalty -= (*overlap)( a, axcenter, aycenter, acellptr->orient,
+ 							    0, 1, 0 ) ;
+ occa1ptr = blockarray[binX][binY] ;
+ 
+ newpenalty += (*overlap)( a, axcenter, aycenter, newaor, 0, 1, 0 ) ;
+ occa2ptr = blockarray[binX][binY] ;
+ 
+ 
+ ufixpin( anewtermptr, 0, axcenter, aycenter ) ;
+ usoftpin( acellptr, 0, axcenter, aycenter, newaor ) ;
+ 
+ cost = funccost ;
+ 
+ cost += ufixnet( anewtermptr ) ;
+ cost += usoftnet( acellptr ) ;
+ 
+ 
+ if( ( cost + newpenalty <= funccost + penalty ) || 
+ 	(exp( (double)( funccost + penalty - cost - newpenalty ) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+     ufixpin( anewtermptr, 1, 0, 0 ) ;
+     usoftpin( acellptr, 1, 0, 0, 0 ) ;
+ 
+     if( occa1ptr != occa2ptr ) {
+ 	for( i = 1 ; occa1ptr[ i ] != a ; i++ ) ;
+ 	occa1ptr[ i ] = occa1ptr[  occa1ptr[0]--  ] ;
+ 	occa2ptr[ ++occa2ptr[0]  ] = a ;
+     }
+ 
+     acellptr->orient = newaor ;
+ 
+     funccost = cost ;
+     penalty = newpenalty ;
+ 
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite1.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite1.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite1.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,84 ----
+ #include "custom.h"
+ extern int finalShot ;
+ extern int bbleft , bbright , bbbottom , bbtop ;
+ extern int bbbl , bbbr , bbbb , bbbt ;
+ 
+ extern void ufixpin( TERMBOXPTR termsptr , int flag , int targetx,
+ 		    int targety );
+ extern int ufixnet( TERMBOXPTR termsptr );
+ extern void usoftpin( CELLBOXPTR cellptr , int flag , int targetx ,
+                       int target , int orient );
+ extern int usoftnet( CELLBOXPTR cellptr );
+ extern int deltaBB( int cell , int xb , int yb );
+ 
+ int usite1( int a , int xb , int yb )
+ {
+ 
+ CELLBOXPTR acellptr ;
+ TILEBOXPTR atileptr ;
+ TERMBOXPTR atermptr ;
+ int cost , newpenalty , i ;
+ int axcenter , aycenter , delta ;
+ 
+ acellptr = cellarray[ a ]    ;
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ atileptr = acellptr->config[ acellptr->orient ] ;
+ atermptr = atileptr->termptr ;
+ 
+ 
+ 
+ newpenalty = penalty ;
+ 
+ newpenalty -= (*overlap)( a, axcenter, aycenter, acellptr->orient, 0, 1,0);
+ occa1ptr = blockarray[binX][binY] ;
+ 
+ newpenalty += (*overlap)( a , xb , yb , acellptr->orient , 0, 1, 0 ) ;
+ occa2ptr = blockarray[binX][binY] ;
+ 
+ 
+ ufixpin( atermptr , 0 , xb , yb ) ;
+ usoftpin( acellptr , 0 , xb , yb , acellptr->orient ) ;
+ 
+ cost = funccost ;
+ 
+ cost += ufixnet( atermptr ) ;
+ cost += usoftnet( acellptr ) ;
+ 
+ if( finalShot > 0 ) {
+     delta = deltaBB( a , xb , yb ) ;
+     newpenalty += delta ;
+ }
+ 
+ if( ( cost + newpenalty <= funccost + penalty ) || 
+ 	(exp( (double)( funccost + penalty - cost - newpenalty) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+ 
+     ufixpin( atermptr , 1 , 0 , 0 ) ;
+     usoftpin( acellptr , 1 , 0 , 0 , 0 ) ;
+ 
+     if( occa1ptr != occa2ptr ) {
+ 	for( i = 1 ; occa1ptr[ i ] != a ; i++ ) ;
+ 	occa1ptr[ i ] = occa1ptr[  occa1ptr[0]--  ] ;
+ 	occa2ptr[ ++occa2ptr[0]  ] = a ;
+     }
+ 
+     acellptr->xcenter = xb ;
+     acellptr->ycenter = yb ;
+ 
+     funccost = cost ;
+     if( finalShot > 0 ) {
+ 	newpenalty -= delta ;
+ 	bbleft = bbbl ;
+ 	bbright = bbbr ;
+ 	bbbottom = bbbb ;
+ 	bbtop = bbbt ;
+     }
+     penalty = newpenalty ;
+ 
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite2.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite2.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usite2.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,94 ----
+ #include "custom.h"
+ 
+ extern void ufixpin( TERMBOXPTR termsptr , int flag , int targetx ,
+ 		    int targety );
+ extern int ufixnet( TERMBOXPTR termsptr );
+ extern void usoftpin( CELLBOXPTR cellptr , int flag , int targetx ,
+                       int target , int orient );
+ extern int usoftnet( CELLBOXPTR cellptr );
+ 
+ int usite2( int a , int b , int ax , int ay , int bx , int by )
+ {
+ 
+ CELLBOXPTR acellptr , bcellptr ;
+ TERMBOXPTR atermptr , btermptr ;
+ 
+ int cost , newpenalty , i ;
+ int axcenter , aycenter , bxcenter , bycenter ;
+ int aorient , borient ;
+ 
+ 
+ acellptr = cellarray[ a ]    ;
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ aorient  = acellptr->orient  ;
+ atermptr = acellptr->config[ aorient ]->termptr ;
+ 
+ bcellptr = cellarray[ b ]    ;
+ bxcenter = bcellptr->xcenter ;
+ bycenter = bcellptr->ycenter ;
+ borient  = bcellptr->orient  ;
+ btermptr = bcellptr->config[borient]->termptr ;
+ 
+ 
+ newpenalty = penalty ;
+ 
+ newpenalty -= (*overlap)( a, axcenter, aycenter, aorient, 0, 1 , 0 ) ;
+ occa1ptr = blockarray[binX][binY] ;
+ newpenalty -= (*overlap)( b, bxcenter, bycenter, borient, a, 1 , 0 ) ;
+ occb1ptr = blockarray[binX][binY] ;
+ 
+ newpenalty += (*overlap)( a, ax, ay, aorient, b, 0 , borient );
+ occa2ptr = blockarray[binX][binY] ;
+ newpenalty += (*overlap)( b, bx, by, borient, a, 1, 0 ) ;
+ occb2ptr = blockarray[binX][binY] ;
+ 
+ 
+ ufixpin( atermptr , 0 , ax , ay ) ;
+ usoftpin( acellptr , 0 , ax , ay , aorient ) ;
+ 
+ ufixpin( btermptr , 0 , bx , by ) ;
+ usoftpin( bcellptr , 0 , bx , by , borient ) ;
+ 
+ cost = funccost ;
+ 
+ cost += ufixnet( atermptr ) ;
+ cost += usoftnet( acellptr ) ;
+ cost += ufixnet( btermptr ) ;
+ cost += usoftnet( bcellptr ) ;
+ 
+ 
+ if( ( cost + newpenalty <= funccost + penalty ) || 
+ 	(exp( (double)( funccost + penalty - cost - newpenalty ) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+     ufixpin( atermptr , 1 , 0 , 0 ) ;
+     usoftpin( acellptr , 1 , 0 , 0 , 0 ) ;
+ 
+     ufixpin( btermptr , 1 , 0 , 0 ) ;
+     usoftpin( bcellptr , 1 , 0 , 0 , 0 ) ;
+ 
+     if( occa1ptr != occa2ptr ) {
+ 	for( i = 1 ; occa1ptr[ i ] != a ; i++ ) ;
+ 	occa1ptr[ i ] = occa1ptr[  occa1ptr[0]--  ] ;
+ 	occa2ptr[ ++occa2ptr[0]  ] = a ;
+     }
+     if( occb1ptr != occb2ptr ) {
+ 	for( i = 1 ; occb1ptr[ i ] != b ; i++ ) ;
+ 	occb1ptr[ i ] = occb1ptr[  occb1ptr[0]--  ] ;
+ 	occb2ptr[ ++occb2ptr[0]  ] = b ;
+     }
+ 
+     acellptr->xcenter = ax ;
+     acellptr->ycenter = ay ;
+     bcellptr->xcenter = bx ;
+     bcellptr->ycenter = by ;
+ 
+     funccost = cost ;
+     penalty = newpenalty ;
+ 
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usiteo1.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usiteo1.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usiteo1.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,70 ----
+ #include "custom.h"
+ 
+ extern void ufixpin( TERMBOXPTR termsptr , int flag , int targetx ,
+ 		    int targety );
+ extern int ufixnet( TERMBOXPTR termsptr );
+ extern void usoftpin( CELLBOXPTR cellptr , int flag , int targetx ,
+                       int target , int orient );
+ extern int usoftnet( CELLBOXPTR cellptr );
+ 
+ int usiteo1( int a , int xb , int yb , int newaor )
+ {
+ 
+ CELLBOXPTR acellptr ;
+ TILEBOXPTR anewtileptr ;
+ TERMBOXPTR anewtermptr ;
+ int cost , newpenalty , i ;
+ int axcenter , aycenter ;
+ 
+ 
+ acellptr = cellarray[ a ]    ;
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ anewtileptr = acellptr->config[ newaor ] ;
+ anewtermptr = anewtileptr->termptr ;
+ 
+ 
+ newpenalty = penalty ;
+ 
+ newpenalty -= (*overlap)( a, axcenter, aycenter, 
+ 				    acellptr->orient, 0, 1, 0 );
+ occa1ptr = blockarray[binX][binY] ;
+ 
+ newpenalty += (*overlap)( a , xb , yb , newaor , 0 , 1 , 0 ) ;
+ occa2ptr = blockarray[binX][binY] ;
+ 
+ 
+ ufixpin( anewtermptr , 0 , xb , yb ) ;
+ usoftpin( acellptr , 0 , xb , yb , newaor ) ;
+ 
+ cost = funccost ;
+ 
+ cost += ufixnet( anewtermptr ) ;
+ cost += usoftnet( acellptr ) ;
+ 
+ 
+ if( ( cost + newpenalty <= funccost + penalty ) || 
+ 	(exp( (double)( funccost + penalty - cost - newpenalty) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+     ufixpin( anewtermptr , 1 , 0 , 0 ) ;
+     usoftpin( acellptr , 1 , 0 , 0 , 0 ) ;
+ 
+     if( occa1ptr != occa2ptr ) {
+ 	for( i = 1 ; occa1ptr[ i ] != a ; i++ ) ;
+ 	occa1ptr[ i ] = occa1ptr[  occa1ptr[0]--  ] ;
+ 	occa2ptr[ ++occa2ptr[0]  ] = a ;
+     }
+ 
+     acellptr->xcenter = xb     ;
+     acellptr->ycenter = yb     ;
+     acellptr->orient  = newaor ;
+ 
+     funccost = cost ;
+     penalty = newpenalty ;
+ 
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usiteo2.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usiteo2.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usiteo2.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,98 ----
+ #include "custom.h"
+ 
+ extern void ufixpin( TERMBOXPTR termsptr , int flag , int targetx ,
+ 		    int targety );
+ extern int ufixnet( TERMBOXPTR termsptr );
+ extern void usoftpin( CELLBOXPTR cellptr , int flag , int targetx ,
+                       int target , int orient );
+ extern int usoftnet( CELLBOXPTR cellptr );
+ 
+ int usiteo2( int a , int b , int ax , int ay , int bx , int by , int newaor ,
+              int newbor )
+ {
+ 
+ CELLBOXPTR acellptr , bcellptr ;
+ TERMBOXPTR anewtermptr , bnewtermptr ;
+ 
+ int cost , newpenalty , i ;
+ int axcenter , aycenter , bxcenter , bycenter ;
+ 
+ 
+ acellptr = cellarray[a] ;
+ axcenter = acellptr->xcenter ;
+ aycenter = acellptr->ycenter ;
+ anewtermptr = acellptr->config[newaor]->termptr ;
+ 
+ bcellptr = cellarray[b] ;
+ bxcenter = bcellptr->xcenter ;
+ bycenter = bcellptr->ycenter ;
+ bnewtermptr = bcellptr->config[newbor]->termptr ;
+ 
+ 
+ newpenalty = penalty ;
+ 
+ newpenalty -= (*overlap)( a, axcenter, aycenter, 
+ 				acellptr->orient, 0, 1, 0 ) ;
+ occa1ptr = blockarray[binX][binY] ;
+ 
+ newpenalty -= (*overlap)( b, bxcenter, bycenter, 
+ 				bcellptr->orient, a, 1, 0 ) ;
+ occb1ptr = blockarray[binX][binY] ;
+ 
+ 
+ newpenalty += (*overlap)( a, ax, ay, newaor, b, 0, newbor ) ;
+ occa2ptr = blockarray[binX][binY] ;
+ 
+ newpenalty += (*overlap)( b, bx, by, newbor, a, 1, 0 ) ;
+ occb2ptr = blockarray[binX][binY] ;
+ 
+ 
+ ufixpin( anewtermptr, 0, ax, ay ) ;
+ usoftpin( acellptr, 0, ax, ay, newaor ) ;
+ ufixpin( bnewtermptr, 0, bx, by ) ;
+ usoftpin( bcellptr, 0, bx, by, newbor ) ;
+ 
+ cost = funccost ;
+ 
+ cost += ufixnet( anewtermptr ) ;
+ cost += usoftnet( acellptr ) ;
+ cost += ufixnet( bnewtermptr ) ;
+ cost += usoftnet( bcellptr ) ;
+ 
+ 
+ if( ( cost + newpenalty <= funccost + penalty ) || 
+ 	(exp( (double)( funccost + penalty - cost - newpenalty ) /
+ 	T) > ( (double) RAND / (double)0x7fffffff ) ) ){
+ 
+     ufixpin( anewtermptr, 1, 0, 0 ) ;
+     usoftpin( acellptr, 1, 0, 0, 0 ) ;
+     ufixpin( bnewtermptr, 1, 0, 0 ) ;
+     usoftpin( bcellptr, 1, 0, 0, 0 ) ;
+ 
+     if( occa1ptr != occa2ptr ) {
+ 	for( i = 1 ; occa1ptr[ i ] != a ; i++ ) ;
+ 	occa1ptr[ i ] = occa1ptr[  occa1ptr[0]--  ] ;
+ 	occa2ptr[ ++occa2ptr[0]  ] = a ;
+     }
+     if( occb1ptr != occb2ptr ) {
+ 	for( i = 1 ; occb1ptr[ i ] != b ; i++ ) ;
+ 	occb1ptr[ i ] = occb1ptr[  occb1ptr[0]--  ] ;
+ 	occb2ptr[ ++occb2ptr[0]  ] = b ;
+     }
+ 
+     acellptr->xcenter = ax ;
+     acellptr->ycenter = ay ;
+     bcellptr->xcenter = bx ;
+     bcellptr->ycenter = by ;
+ 
+     acellptr->orient = newaor ;
+     bcellptr->orient = newbor ;
+ 
+     funccost = cost ;
+     penalty = newpenalty ;
+ 
+     return (1) ;
+ } else {
+     return (0) ;
+ }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usoftnet.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usoftnet.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usoftnet.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,77 ----
+ #include "custom.h"
+ 
+ int usoftnet( CELLBOXPTR cellptr )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ TERMNETSPTR tmptr ;
+ UNCOMBOX *UCptr ;
+ 
+ int tm ;
+ int cost ;
+ int x , y ;
+ 
+ cost = 0 ;
+ UCptr = cellptr->unComTerms ;
+ 
+ for( tm = 1 ; tm <= cellptr->numUnComTerms ; tm++ ) {
+     tmptr = termarray[ UCptr[tm].terminal ];
+     dimptr = netarray[ tmptr->net ] ;
+     if( dimptr->flag == 0 || dimptr->skip == 1 ) {
+ 	continue ;
+     }
+     dimptr->flag = 0 ;
+     netptr = dimptr->netptr ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->newx ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    dimptr->newxmin = dimptr->newxmax = netptr->xpos ;
+ 	    dimptr->newymin = dimptr->newymax = netptr->ypos ;
+ 	}
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	if( netptr->flag == 1 ) {
+ 	    x = netptr->newx ;
+ 	    y = netptr->newy ;
+ 	    netptr->flag = 0 ;
+ 	} else {
+ 	    x = netptr->xpos ;
+ 	    y = netptr->ypos ;
+ 	}
+ 	if( x < dimptr->newxmin ) {
+ 	    dimptr->newxmin = x ;
+ 	} else if( x > dimptr->newxmax ) {
+ 	    dimptr->newxmax = x ;
+ 	}
+ 	if( y < dimptr->newymin ) {
+ 	    dimptr->newymin = y ;
+ 	} else if( y > dimptr->newymax ) {
+ 	    dimptr->newymax = y ;
+ 	}
+     }
+     cost += ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->newxmax - dimptr->newxmin))) - 
+ 	    ((int)( dimptr->Hweight *
+ 	    (double)(dimptr->xmax - dimptr->xmin))) +
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->newymax - dimptr->newymin))) -
+ 	    ((int)( dimptr->Vweight *
+ 	    (double)( dimptr->ymax - dimptr->ymin)));
+ }
+ return( cost ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usoftpin.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usoftpin.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/usoftpin.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,39 ----
+ #include "custom.h"
+ 
+ void usoftpin( CELLBOXPTR cellptr , int flag , int targetx , int targety ,
+               int orient )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ TERMNETSPTR tmptr ;
+ UNCOMBOX *UCptr ;
+ LOCBOX *SLptr ;
+ int tm ;
+ 
+ UCptr = cellptr->unComTerms ;
+ SLptr = cellptr->config[ orient ]->siteLocArray ;
+ 
+ if( flag == 0 ) {
+     for( tm = 1 ; tm <= cellptr->numUnComTerms ; tm++ ) {
+ 	tmptr = termarray[ UCptr[tm].terminal ] ;
+ 	netarray[ tmptr->net ]->flag = 1 ;
+ 	tmptr->termptr->flag = 1 ;
+ 	tmptr->termptr->newx = targetx + SLptr[ UCptr[tm].site ].xpos ;
+ 	tmptr->termptr->newy = targety + SLptr[ UCptr[tm].site ].ypos ;
+     }
+ } else {
+     for( tm = 1 ; tm <= cellptr->numUnComTerms ; tm++ ) {
+ 	tmptr = termarray[ UCptr[tm].terminal ] ;
+ 	dimptr = netarray[ tmptr->net ] ;
+ 
+ 	dimptr->xmin = dimptr->newxmin ;
+ 	dimptr->xmax = dimptr->newxmax ;
+ 	dimptr->ymin = dimptr->newymin ;
+ 	dimptr->ymax = dimptr->newymax ;
+ 
+ 	tmptr->termptr->xpos = tmptr->termptr->newx ;
+ 	tmptr->termptr->ypos = tmptr->termptr->newy ;
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/utemp.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/utemp.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/utemp.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,83 ----
+ #include "custom.h"
+ extern int finalShot ;
+ extern int doCompaction ;
+ extern double Tsave ;
+ int count ;
+ 
+ extern void uloop(void);
+ extern void fuloop(void);
+ 
+ void utemp(void)
+ {
+ 
+ double Tfactor , Tscale ;
+ 
+ Tscale = Tsave / 100000.0 ;
+ count = 0 ;
+ 
+ for( ; ; ) {
+     if( finalShot == 0 ) {
+ 	if( T > 3000.0 * Tscale ) {
+ 	    Tfactor = 0.88 ;
+ 	} else if( T > 200.0 * Tscale ) {
+ 	    Tfactor = 0.955 ;
+ 	} else if( T > 20.0 * Tscale ) {
+ 	    Tfactor = 0.85 ;
+ 	} else {
+ 	    Tfactor = 0.80 ;
+ 	}
+ 	uloop() ;
+     } else {
+ 	if( T < 10.0 * Tscale ) {
+ 	    Tfactor = 0.70 ;
+ 	} else {
+ 	    Tfactor = 0.82 ;
+ 	}
+ 	if( finalShot >= 1 ) {
+ 	    fuloop() ;
+ 	} else {
+ 	    uloop() ;
+ 	}
+     }
+ 
+     /* savewolf() ; */
+ 
+     fprintf(fpo,"THE ROUTE COST OF THE CURRENT PLACEMENT: %d\n", 
+ 						funccost ) ;
+     fprintf(fpo,"THE CURRENT PENALTY IS: %d   ", penalty ) ;
+     fprintf(fpo,"THE CURRENT TOTAL COST IS: %d\n", 
+ 				    penalty + overfill + funccost );
+     fprintf(fpo,"THE CURRENT OVERFILL IS: %d\n", overfill ) ;
+     fprintf(fpo,"TEMPERATURE = kT where k=1.0 and T=%g   ",T );
+     fprintf(fpo,"OFFSET: %d\n", offset ) ;
+     fprintf(fpo,"ITERATION NUMBER:%8d\n\n\n", ++count );
+     fflush( fpo ) ;
+     if( (count - 1) % 15 == 0 ) {
+ 	printf("\n");
+     }
+     printf("%3d ", count );
+     fflush( stdout ) ;
+ 
+     T = Tfactor * T ;
+ 
+     if( (finalShot < doCompaction && T < 0.8) || 
+ 	(finalShot == 0 && T < 5.0 * Tscale ) ||
+ 	(finalShot == doCompaction && T < 0.2) ) {
+ 	/*
+ 	 *  * WE ARE FINISHED *
+ 	 */
+ 
+ 	fprintf(fpo,"FINAL ROUTING COST OF THE PLACEMENT: %d\n"
+ 						, funccost ) ;
+ 	fprintf(fpo,"FINAL VALUE OF PENALTY IS: %d   ",penalty);
+ 	fprintf(fpo,"FINAL VALUE OF TOTAL COST IS: %d\n", 
+ 			    funccost + penalty + overfill ) ;
+ 
+ 	fprintf(fpo,"THE FINAL OVERFILL IS: %d\n", overfill ) ;
+ 	fprintf(fpo,"MAX NUMBER OF ATTEMPTED FLIPS PER T:%8d\n",
+ 						    attmax ) ;
+ 	break ;
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/vprobes.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/vprobes.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/vprobes.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,338 ----
+ #include "geo.h"
+ #define DEBUG
+ 
+ extern int tprop( TNODEPTR r , int value );
+ extern void tinsert( TNODEPTR *root , int value , int property );
+ 
+ void doubleDown( DLINK1PTR rptr );
+ 
+ void vprobes(void)
+ {
+ 
+ DLINK1PTR ritePtr , left1ptr , left2ptr , checkPtr , ptr ;
+ int ry , rx1 , rx2 , redge , dx1 , dx2 , ledge , edge , check ;
+ int l1x2 , l1x1 , l1y , l2x2 , l2x1 , l2y ;
+ 
+ ritePtr = hFixedList ;
+ for( ; ritePtr != (DLINK1PTR) NULL ; ritePtr = ritePtr->next ) {
+     redge = ritePtr->edge ;
+     if( edgeList[redge].UorR < 0 ) {
+ 	continue ;
+     }
+     ry  = edgeList[redge].loc   ;
+     rx1 = edgeList[redge].start ;
+     rx2 = edgeList[redge].end   ;
+     
+     if( edgeList[ edgeList[redge].prevEdge ].UorR == 1 ) {
+ 	left1ptr = Hptrs[ tprop( Hroot , ry ) ] ;
+ 	for(; left1ptr != (DLINK1PTR)NULL; left1ptr = left1ptr->next){
+ 	    ledge = left1ptr->edge ;
+ 	    if( edgeList[ledge].UorR > 0 ) {
+ 		continue ;
+ 	    }
+ 	    l1y  = edgeList[ledge].loc   ;
+ 	    l1x1 = edgeList[ledge].start ;
+ 	    l1x2 = edgeList[ledge].end   ;
+ 	    if( l1x2 <= rx1 || l1x1 > rx1 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+     } else {
+ 	left1ptr = (DLINK1PTR) NULL ;
+     }
+     if( edgeList[ edgeList[redge].nextEdge ].UorR == -1 ) {
+ 	left2ptr = Hptrs[ tprop( Hroot , ry ) ] ;
+ 	for(; left2ptr != (DLINK1PTR) NULL ; left2ptr = left2ptr->next){
+ 	    ledge = left2ptr->edge ;
+ 	    if( edgeList[ledge].UorR > 0 ) {
+ 		continue ;
+ 	    }
+ 	    l2y  = edgeList[ledge].loc   ;
+ 	    l2x1 = edgeList[ledge].start ;
+ 	    l2x2 = edgeList[ledge].end   ;
+ 	    if( l2x2 < rx2 || l2x1 >= rx2 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+     } else {
+ 	left2ptr = (DLINK1PTR) NULL ;
+     }
+     if( left1ptr != (DLINK1PTR) NULL && left1ptr == left2ptr ) {
+ 	check = 1 ;
+ 	checkPtr = Hptrs[ tprop( Hroot , ry ) ] ;
+ 	for(; checkPtr != (DLINK1PTR)NULL; checkPtr = checkPtr->next){
+ 	    if( edgeList[ checkPtr->edge ].UorR > 0 ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].loc >= l2y ) {
+ 		break ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].start >= rx2 ||
+ 			edgeList[ checkPtr->edge ].end <= rx1 ) {
+ 		continue ;
+ 	    }
+ 	    check = 0 ;
+ 	    break ;
+ 	}
+ 	if( check ) {
+ 	    edgeList[++numProbes + edgeCount].start  = ry ;
+ 	    edgeList[numProbes + edgeCount].end      = l2y  ;
+ 	    edgeList[numProbes + edgeCount].loc      = rx1 ;
+ 	    edgeList[numProbes + edgeCount].length   = l2y - ry ;
+ 	    edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	    edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	    edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 	    tinsert( &vEdgeRoot, rx1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	    fprintf(fpdebug,"vprobe:%d  ", numProbes ) ;
+ 	    fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					ry , l2y , rx1 , 1 ) ;
+ #endif
+ 	    edgeList[++numProbes + edgeCount].start  = ry ;
+ 	    edgeList[numProbes + edgeCount].end      = l2y  ;
+ 	    edgeList[numProbes + edgeCount].loc      = rx2 ;
+ 	    edgeList[numProbes + edgeCount].length   = l2y - ry ;
+ 	    edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	    edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	    edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 	    tinsert( &vEdgeRoot, rx2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	    fprintf(fpdebug,"vprobe:%d  ", numProbes ) ;
+ 	    fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					ry , l2y , rx2 , -1 ) ;
+ #endif
+ 	} else {
+ 	    doubleDown( ritePtr ) ;	
+ 	}
+ 	continue ;
+     }
+     if( left1ptr != (DLINK1PTR) NULL &&
+ 	    edgeList[ edgeList[left1ptr->edge].prevEdge ].UorR == -1 ) {
+ 	ptr = Hptrs[ tprop( Hroot , l1y ) ] ;
+ 	for( ptr = ptr->next; ptr != (DLINK1PTR) NULL; ptr = ptr->next){
+ 	    if( edgeList[ptr->edge].loc > l1y ) {
+ 		break ;
+ 	    }
+ 	}
+ 	if( ptr == (DLINK1PTR) NULL ) {
+ 	    ptr = hFixedEnd ;
+ 	} else {
+ 	    ptr = ptr->prev ;
+ 	}
+ 	for( ; ptr != (DLINK1PTR) NULL; ptr = ptr->prev){
+ 	    edge = ptr->edge ;
+ 	    if( edgeList[edge].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    dx1 = edgeList[edge].start ;
+ 	    dx2 = edgeList[edge].end   ;
+ 	    if( dx2 < l1x2 || dx1 >= l1x2 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+ 	if( ritePtr == ptr ) {
+ 	    check = 1 ;
+ 	    checkPtr = Hptrs[ tprop( Hroot , ry ) ] ;
+ 	    for(; checkPtr != (DLINK1PTR) NULL ;
+ 				checkPtr = checkPtr->next ) {
+ 		if( edgeList[ checkPtr->edge ].UorR > 0 ) {
+ 		    continue ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].loc >= l1y ) {
+ 		    break ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].start >= l1x2 ||
+ 			edgeList[ checkPtr->edge ].end <= rx1 ) {
+ 		    continue ;
+ 		}
+ 		check = 0 ;
+ 		break ;
+ 	    }
+ 	    if( check ) {
+ 		edgeList[++numProbes + edgeCount].start  = ry ;
+ 		edgeList[numProbes + edgeCount].end      = l1y ;
+ 		edgeList[numProbes + edgeCount].loc      = rx1 ;
+ 		edgeList[numProbes + edgeCount].length   = l1y - ry ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 		tinsert( &vEdgeRoot, rx1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"vprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					ry , l1y , rx1 , 1 ) ;
+ #endif
+ 		edgeList[++numProbes + edgeCount].start  = ry ;
+ 		edgeList[numProbes + edgeCount].end      = l1y  ;
+ 		edgeList[numProbes + edgeCount].loc      = l1x2 ;
+ 		edgeList[numProbes + edgeCount].length   = l1y - ry ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 		tinsert( &vEdgeRoot, l1x2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"vprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					ry , l1y , l1x2 , -1 ) ;
+ #endif
+ 	    }
+ 	}
+     }
+     if( left2ptr != (DLINK1PTR) NULL &&
+ 	    edgeList[ edgeList[left2ptr->edge].nextEdge ].UorR == 1 ) {
+ 	ptr = Hptrs[ tprop( Hroot , l2y ) ] ;
+ 	for( ptr = ptr->next; ptr != (DLINK1PTR) NULL; ptr = ptr->next){
+ 	    if( edgeList[ptr->edge].loc > l2y ) {
+ 		break ;
+ 	    }
+ 	}
+ 	if( ptr == (DLINK1PTR) NULL ) {
+ 	    ptr = hFixedEnd ;
+ 	} else {
+ 	    ptr = ptr->prev ;
+ 	}
+ 	for( ; ptr != (DLINK1PTR) NULL; ptr = ptr->prev){
+ 	    edge = ptr->edge ;
+ 	    if( edgeList[edge].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    dx1 = edgeList[edge].start ;
+ 	    dx2 = edgeList[edge].end   ;
+ 	    if( dx2 <= l2x1 || dx1 > l2x1 ) {
+ 		continue ;
+ 	    }
+ 	    break ;
+ 	}
+ 	if( ritePtr == ptr ) {
+ 	    check = 1 ;
+ 	    checkPtr = Hptrs[ tprop( Hroot , ry ) ] ;
+ 	    for(; checkPtr != (DLINK1PTR) NULL ;
+ 				    checkPtr = checkPtr->next ) {
+ 		if( edgeList[ checkPtr->edge ].UorR > 0 ) {
+ 		    continue ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].loc >= l2y ) {
+ 		    break ;
+ 		}
+ 		if( edgeList[ checkPtr->edge ].start >= rx2 ||
+ 			edgeList[ checkPtr->edge ].end <= l2x1 ) {
+ 		    continue ;
+ 		}
+ 		check = 0 ;
+ 		break ;
+ 	    }
+ 	    if( check ) {
+ 		edgeList[++numProbes + edgeCount].start  = ry ;
+ 		edgeList[numProbes + edgeCount].end      = l2y ;
+ 		edgeList[numProbes + edgeCount].loc      = l2x1 ;
+ 		edgeList[numProbes + edgeCount].length   = l2y - ry ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 		tinsert( &vEdgeRoot, l2x1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"vprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					ry , l2y , l2x1 , 1 ) ;
+ #endif
+ 		edgeList[++numProbes + edgeCount].start  = ry ;
+ 		edgeList[numProbes + edgeCount].end      = l2y  ;
+ 		edgeList[numProbes + edgeCount].loc      = rx2 ;
+ 		edgeList[numProbes + edgeCount].length   = l2y - ry ;
+ 		edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 		edgeList[numProbes + edgeCount].cell     = 0 ;
+ 		edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 		tinsert( &vEdgeRoot, rx2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 		fprintf(fpdebug,"vprobe:%d  ", numProbes ) ;
+ 		fprintf(fpdebug,"start:%d  end:%d  loc:%d  UorR:%d\n",
+ 					ry , l2y , rx2 , -1 ) ;
+ #endif
+ 	    }
+ 	}
+     }
+     doubleDown( ritePtr ) ;
+ }
+ return ;
+ }
+ 
+ 
+ 
+ void doubleDown( DLINK1PTR rptr )
+ {
+ 
+ int ry , rx1 , rx2 , ly , lx1 , lx2 , check , edge ;
+ DLINK1PTR checkPtr , ptr ;
+ 
+ ry  = edgeList[ rptr->edge ].loc   ;
+ rx2 = edgeList[ rptr->edge ].end   ;
+ rx1 = edgeList[ rptr->edge ].start ;
+ 
+ ptr = Hptrs[ tprop( Hroot , ry ) ] ;
+ for( ; ptr != (DLINK1PTR) NULL ; ptr = ptr->next ) {
+     edge = ptr->edge ;
+     if( edgeList[edge].UorR > 0 ) {
+ 	continue ;
+     }
+     ly  = edgeList[edge].loc   ;
+     lx1 = edgeList[edge].start ;
+     lx2 = edgeList[edge].end   ;
+     if( ! ( lx2 < rx2 && lx1 > rx1 )  ) {
+ 	continue ;
+     }
+     if( edgeList[ edgeList[edge].prevEdge ].UorR == -1 &&
+ 		edgeList[ edgeList[edge].nextEdge ].UorR == 1 ) {
+ 	check = 1 ;
+ 	checkPtr = Hptrs[ tprop( Hroot , ry ) ] ;
+ 	for(; checkPtr != (DLINK1PTR) NULL ; checkPtr = checkPtr->next){
+ 	    if( checkPtr == rptr ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].UorR < 0 ) {
+ 		continue ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].loc > ly ) {
+ 		break ;
+ 	    }
+ 	    if( edgeList[ checkPtr->edge ].start >= lx2 ||
+ 			edgeList[ checkPtr->edge ].end <= lx1 ) {
+ 		continue ;
+ 	    }
+ 	    check = 0 ;
+ 	    break ;
+ 	}
+     } else {
+ 	check = 0 ;
+     }
+     if( check ) {
+ 	edgeList[++numProbes + edgeCount].start  = ry ;
+ 	edgeList[numProbes + edgeCount].end      = ly ;
+ 	edgeList[numProbes + edgeCount].loc      = lx1 ;
+ 	edgeList[numProbes + edgeCount].length   = ly - ry ;
+ 	edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	edgeList[numProbes + edgeCount].UorR     = 1 ;
+ 	tinsert( &vEdgeRoot, lx1 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	fprintf(fpdebug,"vprobe:%d  start:%d  end:%d  loc:%d  UorR:%d\n",
+ 		    numProbes, ry , ly , lx1 , 1 ) ;
+ #endif
+ 	edgeList[++numProbes + edgeCount].start  = ry ;
+ 	edgeList[numProbes + edgeCount].end      = ly ;
+ 	edgeList[numProbes + edgeCount].loc      = lx2 ;
+ 	edgeList[numProbes + edgeCount].length   = ly - ry ;
+ 	edgeList[numProbes + edgeCount].fixed    = 0 ;
+ 	edgeList[numProbes + edgeCount].cell     = 0 ;
+ 	edgeList[numProbes + edgeCount].UorR     = -1 ;
+ 	tinsert( &vEdgeRoot, lx2 , numProbes + edgeCount ) ;
+ #ifdef DEBUG
+ 	fprintf(fpdebug,"vprobe:%d  start:%d  end:%d  loc:%d  UorR:%d\n",
+ 		    numProbes, ry , ly , lx2 , -1 ) ;
+ #endif
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/watesides.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/watesides.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/watesides.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,54 ----
+ #include "custom.h"
+ 
+ void watesides( CELLBOXPTR ptr )
+ {
+ 
+ TILEBOXPTR tileptr ;
+ int side , left , right , bottom , top ;
+ 
+ tileptr = ptr->config[0] ;
+ for( ; tileptr != TILENULL ; tileptr = tileptr->nexttile ) {
+     left = ptr->xcenter + tileptr->left ;
+     tileptr->lweight = -1.0 ;
+     for( side = 1 ; side <= ptr->numsides ; side++ ) {
+ 	if( pSideArray[side].vertical == 1 ) {
+ 	    if( pSideArray[side].position == left ) {
+ 		tileptr->lweight = pSideArray[side].pincount / 
+ 				    (double) pSideArray[side].length ; 
+ 	    }
+ 	}
+     }
+     right = ptr->xcenter + tileptr->right ;
+     tileptr->rweight = -1.0 ;
+     for( side = 1 ; side <= ptr->numsides ; side++ ) {
+ 	if( pSideArray[side].vertical == 1 ) {
+ 	    if( pSideArray[side].position == right ) {
+ 		tileptr->rweight = pSideArray[side].pincount / 
+ 				    (double) pSideArray[side].length ; 
+ 	    }
+ 	}
+     }
+     bottom = ptr->ycenter + tileptr->bottom ;
+     tileptr->bweight = -1.0 ;
+     for( side = 1 ; side <= ptr->numsides ; side++ ) {
+ 	if( pSideArray[side].vertical == 0 ) {
+ 	    if( pSideArray[side].position == bottom ) {
+ 		tileptr->bweight = pSideArray[side].pincount / 
+ 				    (double) pSideArray[side].length ; 
+ 	    }
+ 	}
+     }
+     top = ptr->ycenter + tileptr->top ;
+     tileptr->tweight = -1.0 ;
+     for( side = 1 ; side <= ptr->numsides ; side++ ) {
+ 	if( pSideArray[side].vertical == 0 ) {
+ 	    if( pSideArray[side].position == top ) {
+ 		tileptr->tweight = pSideArray[side].pincount / 
+ 				    (double) pSideArray[side].length ; 
+ 	    }
+ 	}
+     }
+ }
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wirecosts.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wirecosts.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wirecosts.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,85 ----
+ #include "port.h"
+ #include "custom.h"
+ 
+ void wirecosts( int *withPads , int *withOutPads )
+ {
+ 
+ DIMBOXPTR dimptr ;
+ NETBOXPTR netptr ;
+ 
+ int x , y , xmin , xmax , ymin , ymax , net ;
+ 
+ *withPads = 0 ;
+ *withOutPads = 0 ;
+ 
+ for( net = 1 ; net <= numnets ; net++ ) {
+     dimptr =  netarray[net] ;
+     netptr = dimptr->netptr ;
+ 
+     xmin = 0 ;
+     xmax = 0 ;
+     ymin = 0 ;
+     ymax = 0 ;
+     for( ; ; netptr = netptr->nextterm ) {
+ 	if( netptr == NETNULL ) {
+ 	    break ;
+ 	}
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	xmin = xmax = netptr->xpos ;
+ 	ymin = ymax = netptr->ypos ;
+ 	netptr = netptr->nextterm ;
+ 	break ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	if( netptr->skip == 1 ) {
+ 	    continue ;
+ 	}
+ 	x = netptr->xpos ;
+ 	y = netptr->ypos ;
+ 
+ 	if( x < xmin ) {
+ 	    xmin = x ;
+ 	} else if( x > xmax ) {
+ 	    xmax = x ;
+ 	}
+ 	if( y < ymin ) {
+ 	    ymin = y ;
+ 	} else if( y > ymax ) {
+ 	    ymax = y ;
+ 	}
+     }
+     *withOutPads += (xmax - xmin) + (ymax - ymin) ;
+ 
+     dimptr =  netarray[net] ;
+     netptr = dimptr->netptr ;
+     xmin = 0 ;
+     xmax = 0 ;
+     ymin = 0 ;
+     ymax = 0 ;
+     if( netptr != NETNULL ) {
+ 	xmin = xmax = netptr->xpos ;
+ 	ymin = ymax = netptr->ypos ;
+ 	netptr = netptr->nextterm ;
+     }
+     for( ; netptr != NETNULL ; netptr = netptr->nextterm ) {
+ 	x = netptr->xpos ;
+ 	y = netptr->ypos ;
+ 
+ 	if( x < xmin ) {
+ 	    xmin = x ;
+ 	} else if( x > xmax ) {
+ 	    xmax = x ;
+ 	}
+ 	if( y < ymin ) {
+ 	    ymin = y ;
+ 	} else if( y > ymax ) {
+ 	    ymax = y ;
+ 	}
+     }
+     *withPads += (xmax - xmin) + (ymax - ymin) ;
+ }
+ return ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wireest.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wireest.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wireest.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,79 ----
+ #include "port.h"
+ #include "custom.h"
+ 
+ int wireestx( int xc , int yy1 , int yy2 , double factor3 )
+ {
+ 
+ int x , y ;
+ double factor1 , factor2 ;
+ 
+ if( xc <= blockmx ) {
+     x = xc - blockl ;
+     if( x < 0 ) {
+ 	x = 0 ;
+     }
+ } else {
+     x = blockr - xc ;
+     if( x < 0 ) {
+ 	x = 0 ;
+     }
+ }
+ if( yy2 >= blockmy && yy1 <= blockmy ) {
+     y = (blockt - blockb) / 2 ;
+ } else if( ABS(yy1 - blockmy) <= ABS(yy2 - blockmy) ) {
+     y = blockt - yy1 ;
+     if( y < 0 ) {
+ 	y = 0 ;
+     }
+ } else {
+     y = yy2 - blockb ;
+     if( y < 0 ) {
+ 	y = 0 ;
+     }
+ }
+ factor1 = slopeX * (double)x + basefactor ;
+ factor2 = slopeY * (double)y + basefactor ;
+ 
+ return( (int)( 0.5 * ( factor1 * factor2 * factor3 * 
+ 					    (double) aveChanWid ) ) ) ;
+ }
+ 
+ 
+ 
+ int wireesty( int yc , int xx1 , int xx2 , double factor3 )
+ {
+ 
+ int x , y ;
+ double factor1 , factor2 ;
+ 
+ if( yc <= blockmy ) {
+     y = yc - blockb ;
+     if( y < 0 ) {
+ 	y = 0 ;
+     }
+ } else {
+     y = blockt - yc ;
+     if( y < 0 ) {
+ 	y = 0 ;
+     }
+ }
+ if( xx2 >= blockmx && xx1 <= blockmx ) {
+     x = (blockr - blockl) / 2 ;
+ } else if( ABS(xx1 - blockmx) <= ABS(xx2 - blockmx) ) {
+     x = blockr - xx1 ;
+     if( x < 0 ) {
+ 	x = 0 ;
+     }
+ } else {
+     x = xx2 - blockl ;
+     if( x < 0 ) {
+ 	x = 0 ;
+     }
+ }
+ factor1 = slopeX * (double)x + basefactor ;
+ factor2 = slopeY * (double)y + basefactor ;
+ 
+ return( (int)( 0.5 * ( factor1 * factor2 * factor3 * 
+ 					    (double) aveChanWid ) ) ) ;
+ 
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wireratio.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wireratio.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/wireratio.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,616 ----
+ /* #include "custom.h" */
+ #include "port.h"
+ #define ABS(value)   ( (value)>=0 ? (value) : -(value) ) 
+ 
+ double Nterm1(double k);
+ double Nterm2(double k);
+ double Nterm3(double k);
+ double Nterm4(double k);
+ double Nterm5(double k);
+ double NNterm1(double k);
+ double NNterm2(double k);
+ double NNterm3(double k);
+ double NNterm4(double k);
+ double NNterm5(double k);
+ double Dterm1(double k);
+ double Dterm2(double k);
+ double Dterm3(double k);
+ double Dterm4(double k);
+ double DDterm1(double k);
+ double DDterm2(double k);
+ double DDterm3(double k);
+ double DDterm4(double k);
+ double factorial( int n );
+ double combination( int n , int k );
+ double probability( int k , int h , int i , int N );
+ double getptree( int h , int L , int N );
+ double probtree( double atatime , int N , double numdraws );
+ void findratio( double *res1 , double *res2 );
+ 
+ double rootN , N , CC ;
+ double a , bb , c ;
+ extern FILE *fpo ;
+ 
+ 
+ 
+ double wireratio( int numofcells, double cellspernet, double netsperd,
+                   double dnetspercell )
+ {
+ 
+ double result1 , result2 , match ;
+ 
+ 
+ 
+ N = (double) numofcells ;
+ CC = probtree(  ((cellspernet >= 1.0) ? (cellspernet) : 1.0) ,
+ 		((numofcells >= 2) ? (numofcells - 1) : 1)   ,
+ 		((dnetspercell >= 1.0) ? (dnetspercell) : 1.0)    ) ;
+ 
+ bb = 100.0 ;
+ a = 0.01 ;
+ 
+ findratio( &result1 , &result2 ) ;
+ match = result2 - result1 ;
+ 
+ a = netsperd - 2.5 ;
+ if( a > 0 ) {
+     a = 0.01 + ((a + 2.5) * 1.25) ;
+ } else {
+     a = 0.01 ;
+ }
+ bb = pow( 10.0 , - cellspernet + 3.3 ) ;
+ 
+ findratio( &result1 , &result2 ) ;
+ 
+ fprintf(fpo,"\n\n_________________________________________________________________________\n\n");
+ fprintf(fpo,"DISTINCT NETS PER CELL ---------------- : %.2f\n", dnetspercell);
+ fprintf(fpo,"NETS PER DISTINCT NET  ---------------- : %.2f\n", netsperd ) ;
+ fprintf(fpo,"CELLS PER DISTINCT NET ---------------- : %.2f\n", cellspernet );
+ fprintf(fpo,"AVE. # CELLS CONNECTED TO A CELL ------ : %.2f\n", CC ) ;
+ fprintf(fpo,    "_________________________________________________________________________\n");
+ 
+ /*
+ printf("Improvement RATIO: %6.2f\n\n", result1 ) ;
+ printf("NEW IMPROVED: Improvement RATIO: %6.2f\n\n", result2 - match ) ;
+ */
+ 
+ return( result2 - match ) ;
+ }
+ 
+ 
+ 
+ 
+ 
+ void findratio( double *res1 , double *res2 )
+ {
+ 
+ 
+ double m , k , x , y , diff , N1 , N2 , D1 , D2 ;
+ int i , j , now , last , savei , savej , lessThanM ;
+ 
+ rootN = sqrt( N ) ;
+ m = rootN - 1 ;
+ 
+ 
+ 
+ lessThanM = 1 ;
+ diff = 1000000.0 ;
+ 
+ for( i = 0 ; i < 1000000 ; i++ ) {
+     j = (i == 0) ? 10 : 0 ;
+     for( ; j < 100 ; j++ ) {
+ 	k = (double) i + ( (double) j / 100.0 ) ;
+ 	if( k > m ) {
+ 	    lessThanM = 0 ;
+ 	    savei = i ;
+ 	    savej = j ;
+ 	    i = 1000000 ;
+ 	    break ;
+ 	}
+ 
+ 	x = (k / (6.0 * N)) * (  (k * k * k)  +  
+ 			(2.0 - 8.0 * rootN) * (k * k)  +
+ 			(12.0 * N - 12.0 * rootN - 1.0) * k  +
+ 			(12.0 * N - 4.0 * rootN - 2.0) ) ;
+ 	now = (x > CC) ? 1 : -1 ;
+ 	if( !( i == 0 && j == 10) ) {
+ 	    if( now != last ) {
+ 		if( diff <= ABS(x - CC) ) {
+ 		    k = k - 0.01 ;
+ 		}
+ 		i = 1000000 ;
+ 		break ;
+ 	    } else {
+ 		last = now ;
+ 		diff = ABS( x - CC ) ;
+ 	    }
+ 	} else {
+ 	    last = now ;
+ 	}
+     }
+ }
+ if( ! lessThanM ) {
+     diff = 1000000.0 ;
+     i = savei ;
+     j = savej ;
+ 
+     for( ; i < 1000000 ; i++ ) {
+ 	if( i > savei ) {
+ 	    j = 0 ;
+ 	}
+ 	for( ; j < 100 ; j++ ) {
+ 	    k = (double) i + ( (double) j / 100.0 ) ;
+ 
+ 	    x = (1.0 / (6.0 * N)) * (  - (k * k * k * k)  +  
+ 		    (8.0 * rootN - 2.0) * (k * k * k)  +
+ 		    (12.0 * rootN - 24.0 * N + 1.0) * (k * k)  +
+ 		    (32.0 * N * rootN - 24.0 * N - 4.0 * rootN + 2.0) * k +
+ 
+ 		    (2.0) * (m * m * m * m)  -  
+ 		    (16.0 * rootN - 4.0) * (m * m * m)  -
+ 		    (24.0 * rootN - 36.0 * N + 2.0) * (m * m)  -
+ 		    (32.0 * N * rootN - 36.0 * N + 4.0) * m   ) ;
+ 	    now = (x > CC) ? 1 : -1 ;
+ 	    if( ! (i == savei && j == savej) ) {
+ 		if( now != last ) {
+ 		    if( diff <= ABS(x - CC) ) {
+ 			k = k - 0.01 ;
+ 		    }
+ 		    i = 1000000 ;
+ 		    break ;
+ 		} else {
+ 		    last = now ;
+ 		    diff = ABS( x - CC ) ;
+ 		}
+ 	    } else {
+ 		last = now ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ /*
+ printf("\nThe value of  k  of your circuit is: %6.2f\n", k ) ;
+ printf("The value of  m  of your circuit is: %6.2f\n\n", m ) ;
+ */
+ 
+ 
+ if( k <= m ) {
+     x = 0.4 * ( ((2.0) * (k * k * k * k)  +
+ 		 (5.0 - 15.0 * rootN) * (k * k * k)  +
+ 		 (20.0 * N - 30.0 * rootN) * (k * k)  +
+ 		 (30.0 * N - 15.0 * rootN - 5.0) * (k)  +
+ 		 (10.0 * N - 2.0))  / 
+ 				(6.0 * CC * N / k) ) ;
+ } else {
+     x = ( - 2.0) * (k * k * k * k * k)  +
+ 	(15.0 * rootN - 5.0) * (k * k * k * k)  +
+ 	(30.0 * rootN - 40.0 * N) * (k * k * k)  +
+ 	(40.0 * N * rootN - 60.0 * N + 5.0 * rootN + 5.0) * (k * k) +
+ 	(40.0 * N * rootN - 20.0 * N - 10.0 * rootN + 2.0) * (k) ;
+ 
+     x += (4.0) * (m * m * m * m * m)  -
+ 	 (30.0 * rootN - 10.0) * (m * m * m * m)  -
+ 	 (60.0 * rootN - 60.0 * N) * (m * m * m)  -
+ 	 (40.0 * N * rootN - 90.0 * N + 20.0 * rootN + 10.0) * (m * m) -
+ 	 (40.0 * N * rootN - 30.0 * N - 10.0 * rootN + 4.0) * (m) ;
+     x = 0.4 * x / (6.0 * CC * N) ;
+ 
+ }
+ 
+ 
+ y = (2.0 / 3.0) * sqrt( N ) ;
+ 
+ *res1 = y / x ;
+ 
+ 
+ c = a + bb ;
+ 
+ if( k > m ) {
+     N1 =  Nterm1(m) - Nterm1(1.0) +
+ 	  Nterm2(m) - Nterm2(1.0) +
+ 	  Nterm3(m) - Nterm3(1.0) +
+ 	  Nterm4(m) - Nterm4(1.0) +
+ 	  Nterm5(m) - Nterm5(1.0) ;
+     D1 =  Dterm1(m) - Dterm1(1.0) +
+ 	  Dterm2(m) - Dterm2(1.0) +
+ 	  Dterm3(m) - Dterm3(1.0) +
+ 	  Dterm4(m) - Dterm4(1.0) ;
+ } else {
+     N1 =  Nterm1(k) - Nterm1(1.0) +
+ 	  Nterm2(k) - Nterm2(1.0) +
+ 	  Nterm3(k) - Nterm3(1.0) +
+ 	  Nterm4(k) - Nterm4(1.0) +
+ 	  Nterm5(k) - Nterm5(1.0) ;
+     D1 =  Dterm1(k) - Dterm1(1.0) +
+ 	  Dterm2(k) - Dterm2(1.0) +
+ 	  Dterm3(k) - Dterm3(1.0) +
+ 	  Dterm4(k) - Dterm4(1.0) ;
+ }
+ 
+ 
+ if( k > m ) {
+     N2 =  NNterm1(k) - NNterm1(m) +
+ 	  NNterm2(k) - NNterm2(m) +
+ 	  NNterm3(k) - NNterm3(m) +
+ 	  NNterm4(k) - NNterm4(m) +
+ 	  NNterm5(k) - NNterm5(m) ;
+     D2 =  DDterm1(k) - DDterm1(m) +
+ 	  DDterm2(k) - DDterm2(m) +
+ 	  DDterm3(k) - DDterm3(m) +
+ 	  DDterm4(k) - DDterm4(m) ;
+ 
+     x = (N1 + N2) / (D1 + D2) ;
+ } else {
+     x = N1 / D1 ;
+ }
+ 
+ *res2 = y / x ;
+ 
+ return ;
+ }
+ 
+ 
+ double Nterm1( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return( ((k*k*k*k) / 6.0) * ((exa / (a)) - (exc / (c))) ) ;
+ }
+ 
+ 
+ double Nterm2( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k * k * k) * 
+ 	(  ((2.0 / 3.0) * ((exa / (a * a)) - (exc / (c * c))))
+ 	   - rootN * ((exa / (a)) - (exc / (c)))   ) ) ;
+ }
+ 
+ 
+ double Nterm3( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k * k) * 
+ 	(  (2.0 * ((exa / (a * a * a)) - (exc / (c * c * c))))
+        - ((3.0 * rootN) * ((exa / (a * a)) - (exc / (c * c))))
+        + (N * ((exa / (a)) - (exc / (c))))   ) ) ;
+ }
+ 
+ 
+ 
+ double Nterm4( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k) * 
+     (  (4.0 * ((exa / (a * a * a * a)) - (exc / (c * c * c * c))))
+    - ((6.0 * rootN) * ((exa / (a * a * a)) - (exc / (c * c * c))))
+        + ((2.0 * N) * ((exa / (a * a)) - (exc / (c * c))))   ) ) ;
+ }
+ 
+ 
+ 
+ double Nterm5( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((4.0 * ((exa / (a*a*a*a*a)) - (exc /(c * c * c * c * c))))
+    - ((6.0 * rootN) * ((exa / (a*a*a*a)) - (exc / (c * c * c * c))))
+        + ((2.0 * N) * ((exa / (a*a*a)) - (exc / (c * c * c)))) );
+ }
+ 
+ 
+ double Dterm1( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return(((k * k * k) / 6.0) * ((exa / (a)) - (exc / (c)))) ;
+ }
+ 
+ 
+ 
+ double Dterm2( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k * k) * 
+ 	(  ((1.0 / 2.0) * ((exa / (a * a)) - (exc / (c * c))))
+ 	   - rootN * ((exa / (a)) - (exc / (c)))   ) ) ;
+ }
+ 
+ 
+ 
+ double Dterm3( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k) * 
+ 	(  ((exa / (a * a * a)) - (exc / (c * c * c)))
+ 	   - ((2.0 * rootN) * ((exa / (a * a)) - (exc / (c * c))))
+ 	   + (N * ((exa / (a)) - (exc / (c))))   ) ) ;
+ }
+ 
+ 
+ double Dterm4( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return( ((exa / (a * a * a * a)) - (exc / (c * c * c * c))) - 
+     ((2.0 * rootN) * ((exa / (a * a * a)) - (exc / (c * c * c))))
+ 	   + (N * ((exa / (a * a)) - (exc / (c * c)))) ) ;
+ }
+ 
+ 
+ double NNterm1( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return( ((k*k*k*k) / -6.0) * ((exa / (a)) - (exc / (c))) ) ;
+ }
+ 
+ 
+ double NNterm2( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k * k * k) * 
+ 	(  ((-2.0 / 3.0) * ((exa / (a * a)) - (exc / (c * c))))
+ 	   + rootN * ((exa / (a)) - (exc / (c)))   ) ) ;
+ }
+ 
+ 
+ double NNterm3( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k * k) * 
+ 	(  (-2.0 * ((exa / (a * a * a)) - (exc / (c * c * c))))
+        + ((3.0 * rootN) * ((exa / (a * a)) - (exc / (c * c))))
+        - (2.0 * N * ((exa / (a)) - (exc / (c))))   ) ) ;
+ }
+ 
+ 
+ 
+ double NNterm4( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k) * 
+     (  (-4.0 * ((exa / (a * a * a * a)) - (exc / (c * c * c * c))))
+    + ((6.0 * rootN) * ((exa / (a * a * a)) - (exc / (c * c * c))))
+        - ((4.0 * N) * ((exa / (a * a)) - (exc / (c * c))))   
+        + (((4.0 / 3.0) * N * rootN) * ((exa / a) - (exc / c)))   ) ) ;
+ }
+ 
+ 
+ 
+ double NNterm5( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((-4.0 * ((exa / (a*a*a*a*a)) - (exc /(c * c * c * c * c))))
+    + ((6.0 * rootN) * ((exa / (a*a*a*a)) - (exc / (c * c * c * c))))
+    - ((4.0 * N) * ((exa / (a*a*a)) - (exc / (c * c * c))))
+    + (((4.0 / 3.0) * N * rootN) * ((exa / (a * a)) - (exc / (c * c ))))  );
+ }
+ 
+ 
+ double DDterm1( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return(((k * k * k) / -6.0) * ((exa / (a)) - (exc / (c)))) ;
+ }
+ 
+ 
+ 
+ double DDterm2( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k * k) * 
+ 	(  ((-1.0 / 2.0) * ((exa / (a * a)) - (exc / (c * c))))
+          + (rootN * ((exa / (a)) - (exc / (c))))   ) ) ;
+ }
+ 
+ 
+ 
+ double DDterm3( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return((k) * 
+ 	(  - ((exa / (a * a * a)) - (exc / (c * c * c)))
+ 	   + ((2.0 * rootN) * ((exa / (a * a)) - (exc / (c * c))))
+ 	   - ((2.0 * N) * ((exa / (a)) - (exc / (c))))   ) ) ;
+ }
+ 
+ 
+ double DDterm4( double k )
+ {
+ double exa , exc ;
+ 
+ exa = - exp( - (a * (k - 1.0)) ) ;
+ exc = - exp( - (c * (k - 1.0)) ) ;
+ return( - ((exa / (a * a * a * a)) - (exc / (c * c * c * c))) + 
+     ((2.0 * rootN) * ((exa / (a * a * a)) - (exc / (c * c * c))))
+     - ((2.0 * N) * ((exa / (a * a)) - (exc / (c * c))))
+     + (((4.0 / 3.0) * N * rootN) * ((exa / (a)) - (exc / (c))))   );
+ }
+ 
+ 
+ 
+ 
+ 
+ double probtree( double atatime , int N , double numdraws )
+ {
+ 
+ int h , L ;
+ double res1, res2, res3, res4, result1, result2 ;
+ double fract1, fract2 ;
+ 
+ 
+ h = (int) atatime ;
+ L = (int) numdraws ;
+ fract1 = atatime - (double) h ;
+ fract2 = numdraws - (double) L ;
+ 
+ res1 = getptree( h , L , N ) ;
+ h++ ;
+ res2 = getptree( h , L , N ) ;
+ 
+ result1 = res1 + (fract1) * (res2 - res1) ;
+ 
+ h-- ;
+ L++ ;
+ res3 = getptree( h , L , N ) ;
+ h++ ;
+ res4 = getptree( h , L , N ) ;
+ 
+ result2 = res3 + (fract1) * (res4 - res3) ;
+ 
+ return( result1 + (fract2) * (result2 - result1) ) ;
+ }
+ 
+ 
+ 
+ 
+ double getptree( int h , int L , int N )
+ {
+ 
+ typedef struct array3d {
+     int value ;
+     double prob ;
+ } array3d ;
+ 
+ array3d *array ;
+ int bound , i , start , target , j ;
+ double numerator , denominator ;
+ 
+ 
+ 
+ bound = 1 ;
+ for( i = 1 ; i <= L ; i++ ) {
+     bound *= (h + 1) ;
+ }
+ bound = (bound - 1) / h ;
+ 
+ start = 1 ;
+ for( i = 1 ; i < L ; i++ ) {
+     start *= (h + 1) ;
+ }
+ start = (start - 1) / h + 1 ;
+ 
+ 
+ array = (array3d *) malloc( (1 + bound) * sizeof( array3d ) ) ;
+ 
+ array[1].value = h ;
+ array[1].prob  = 1.0 ;
+ 
+ for( i = 1 ; i <= start - 1 ; i++ ) {
+     target = (h + 1) * i - (h - 1) ;
+     for( j = 0 ; j <= h ; j++ , target++ ) {
+ 	array[target].value = array[i].value + j ;
+ 	array[target].prob  = array[i].prob * 
+ 				probability( array[i].value , h , j , N ) ;
+     }
+ }
+ 
+ numerator   = 0.0 ;
+ denominator = 0.0 ;
+ for( i = start ; i <= bound ; i++ ) {
+     numerator += array[i].value * array[i].prob ;
+ }
+ for( i = start ; i <= bound ; i++ ) {
+     denominator += array[i].prob ;
+ }
+ free( array ) ;
+ if( numerator < 0.000001 ) {
+     return(0.0) ;
+ } else {
+     return( numerator / denominator ) ;
+ }
+ }
+ 
+ 
+ 
+ double probability( int k , int h , int i , int N )
+ {
+ if( k + i > N ) {
+     return( 0.0 ) ;
+ } else {
+     return( combination( k , h - i ) * combination( N - k , i )  ) ;
+ }
+ }
+ 
+ double combination( int n , int k )
+ {
+ 
+ double result ;
+ int i ;
+ 
+ result = 1.0 ;
+ if( n - k > k ) {
+     for( i = 0 ; i <= k - 1 ; i++ ) {
+ 	result *= (double)( n - i ) ;
+     }
+     return( result / factorial( k )  ) ;
+ } else {
+     for( i = n ; i >= k + 1 ; i-- ) {
+ 	result *= (double)( i ) ;
+     }
+     return( result / factorial( n - k )  ) ;
+ }
+ }
+ 
+ 
+ 
+ double factorial( int n )
+ {
+ 
+ double result ;
+ 
+ result = 1.0 ;
+ for( ; n >= 1 ; n-- ) {
+     result *= (double) n ; 
+ }
+ 
+ return( result ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlap.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlap.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlap.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,186 ----
+ #include "custom.h"
+ 
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern int wireesty( int yc , int xx1 , int xx2 , double factor3 );
+ 
+ int woverlap( int cell , int xc , int yc , int orient , int b , int flag ,
+               int borient )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr1 , tileptr2 , tileptr01, tileptr02 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ orient ]  ;
+ 
+ startx01 = xc + tileptr01->left    ;
+ endx01   = xc + tileptr01->right   ;
+ starty01 = yc + tileptr01->bottom  ;
+ endy01   = yc + tileptr01->top     ;
+ if( cell <= numcells ) {
+     startx01 -= wireestx(startx01,starty01,endy01,tileptr01->lweight ) ;
+     endx01   += wireestx(endx01,starty01,endy01,tileptr01->rweight   ) ;
+     starty01 -= wireesty(starty01,startx01,endx01,tileptr01->bweight ) ;
+     endy01   += wireesty(endy01,startx01,endx01,tileptr01->tweight   ) ;
+ }
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    if( othercell != b ) {
+ 		tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 		xcenter = cellptr2->xcenter ;
+ 		ycenter = cellptr2->ycenter ;
+ 	    } else if( flag == 0 ) {
+ 		tileptr02 = cellptr2->config[borient] ;
+ 		xcenter = cellptr1->xcenter ;
+ 		ycenter = cellptr1->ycenter ;
+ 	    } else {
+ 		continue ;
+ 	    }
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( othercell <= numcells ) {
+ 		startx02 -= wireestx( startx02 , starty02 , endy02 ,
+ 					       tileptr02->lweight ) ;
+ 		endx02   += wireestx( endx02 , starty02 , endy02 ,
+ 						tileptr02->rweight ) ;
+ 		starty02 -= wireesty( starty02 , startx02 , endx02 ,
+ 						tileptr02->bweight ) ;
+ 		endy02   += wireesty( endy02 , startx02 , endx02 ,
+ 						tileptr02->tweight ) ;
+ 	    }
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 		/*
+ 		fprintf(fpo,"Overlap condition: cell:%d othercell:%d",
+ 						cell, othercell ) ;
+ 		fprintf(fpo,"   overlap:%d\n", value ) ;
+ 		*/
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    startx1 =  xc + tileptr1->left   ;
+ 		    endx1   =  xc + tileptr1->right  ;
+ 		    starty1 =  yc + tileptr1->bottom ;
+ 		    endy1   =  yc + tileptr1->top    ;
+ 		    if( cell <= numcells ) {
+ 			startx1 -= wireestx( startx1 , starty1 , endy1 ,
+ 						tileptr1->lweight ) ;
+ 			endx1   += wireestx( endx1 , starty1 , endy1 , 
+ 						tileptr1->rweight ) ;
+ 			starty1 -= wireesty( starty1 , startx1 , endx1 ,
+ 						tileptr1->bweight ) ;
+ 			endy1   += wireesty( endy1 , startx1 , endx1 , 
+ 						tileptr1->tweight ) ;
+ 		    }
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 			if( othercell <= numcells ) {
+ 			    startx2 -= wireestx( startx2 , starty2 , 
+ 					endy2 , tileptr2->lweight ) ;
+ 			    endx2   += wireestx( endx2 , starty2 , 
+ 					endy2 , tileptr2->rweight ) ;
+ 			    starty2 -= wireesty( starty2 , startx2 , 
+ 					endx2 , tileptr2->bweight ) ;
+ 			    endy2   += wireesty( endy2 , startx2 , 
+ 					endx2 , tileptr2->tweight ) ;
+ 			}
+ 
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlapf.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlapf.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlapf.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,193 ----
+ #include "custom.h"
+ 
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern int wireesty( int yc , int xx1 , int xx2 , double factor3 );
+ 
+ int woverlapf( int cell , int xc , int yc , int orient , int b , int flag ,
+                int borient )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr1 , tileptr2 , tileptr01, tileptr02 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ orient ]  ;
+ 
+ startx01 = xc + tileptr01->left    ;
+ endx01   = xc + tileptr01->right   ;
+ starty01 = yc + tileptr01->bottom  ;
+ endy01   = yc + tileptr01->top     ;
+ if( cell <= numcells ) {
+     startx01 -= wireestx(startx01,starty01,endy01,tileptr01->lweight ) ;
+     endx01   += wireestx(endx01,starty01,endy01,tileptr01->rweight   ) ;
+     starty01 -= wireesty(starty01,startx01,endx01,tileptr01->bweight ) ;
+     endy01   += wireesty(endy01,startx01,endx01,tileptr01->tweight   ) ;
+ }
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    if( othercell != b ) {
+ 		tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 		xcenter = cellptr2->xcenter ;
+ 		ycenter = cellptr2->ycenter ;
+ 	    } else if( flag == 0 ) {
+ 		tileptr02 = cellptr2->config[borient] ;
+ 		xcenter = cellptr1->xcenter ;
+ 		ycenter = cellptr1->ycenter ;
+ 	    } else {
+ 		continue ;
+ 	    }
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( othercell <= numcells ) {
+ 		startx02 -= wireestx( startx02 , starty02 , endy02 ,
+ 					       tileptr02->lweight ) ;
+ 		endx02   += wireestx( endx02 , starty02 , endy02 ,
+ 						tileptr02->rweight ) ;
+ 		starty02 -= wireesty( starty02 , startx02 , endx02 ,
+ 						tileptr02->bweight ) ;
+ 		endy02   += wireesty( endy02 , startx02 , endx02 ,
+ 						tileptr02->tweight ) ;
+ 	    }
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 		fprintf(fpo,"Overlap condition: cell1:%d cell2:%d",
+ 						cell, othercell ) ;
+ 		fprintf(fpo,"   value:%d   amount:%d\n",
+ 			(int)(lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ),
+ 				(endy - starty) * (endx - startx) ) ;
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    startx1 =  xc + tileptr1->left   ;
+ 		    endx1   =  xc + tileptr1->right  ;
+ 		    starty1 =  yc + tileptr1->bottom ;
+ 		    endy1   =  yc + tileptr1->top    ;
+ 		    if( cell <= numcells ) {
+ 			startx1 -= wireestx( startx1 , starty1 , endy1 ,
+ 						tileptr1->lweight ) ;
+ 			endx1   += wireestx( endx1 , starty1 , endy1 , 
+ 						tileptr1->rweight ) ;
+ 			starty1 -= wireesty( starty1 , startx1 , endx1 ,
+ 						tileptr1->bweight ) ;
+ 			endy1   += wireesty( endy1 , startx1 , endx1 , 
+ 						tileptr1->tweight ) ;
+ 		    }
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 			if( othercell <= numcells ) {
+ 			    startx2 -= wireestx( startx2 , starty2 , 
+ 					endy2 , tileptr2->lweight ) ;
+ 			    endx2   += wireestx( endx2 , starty2 , 
+ 					endy2 , tileptr2->rweight ) ;
+ 			    starty2 -= wireesty( starty2 , startx2 , 
+ 					endx2 , tileptr2->bweight ) ;
+ 			    endy2   += wireesty( endy2 , startx2 , 
+ 					endx2 , tileptr2->tweight ) ;
+ 			}
+ 
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		    fprintf(fpo,"Overlap condition: cell1:%d cell2:%d",
+ 						cell, othercell ) ;
+ 		    fprintf(fpo,"   value:%d   amount:%d\n",
+ 					    (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ,
+ 							    tempval ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlapx.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlapx.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/woverlapx.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,185 ----
+ #include "custom.h"
+ 
+ extern int wireestx( int xc , int yy1 , int yy2 , double factor3 );
+ extern int wireesty( int yc , int xx1 , int xx2 , double factor3 );
+ 
+ int woverlapx( int cell, int oleft, int obottom, int Wdiv2, int Hdiv2,
+                double aspFactor )
+ {
+ 
+ CELLBOXPTR cellptr1 , cellptr2 ;
+ TILEBOXPTR tileptr01, tileptr1, tileptr02, tileptr2 ;
+ int startx01 , endx01 , starty01 , endy01 , othercell ;
+ int startx02 , endx02 , starty02 , endy02 , value , tempval ;
+ int startx1 , endx1 , starty1 , endy1 ;
+ int startx2 , endx2 , starty2 , endy2 ;
+ int startx , endx , starty , endy , xcenter , ycenter ;
+ int i , j , k , *occuptr ;
+ int lowBinX , highBinX , lowBinY , highBinY ;
+ double val ;
+ 
+ value = 0 ;
+ cellptr1 = cellarray[cell] ;
+ tileptr01 = cellptr1->config[ cellptr1->orient ]  ;
+ 
+ 
+ startx01 = cellptr1->xcenter - Wdiv2 ;
+ 
+ val = (double)(tileptr01->oright - oleft) / aspFactor ;
+ endx01 = cellptr1->xcenter + ROUND( val ) - Wdiv2;
+ 
+ starty01 = cellptr1->ycenter - Hdiv2 ;
+ 
+ val = (double)(tileptr01->otop - obottom) * aspFactor ;
+ endy01 = cellptr1->ycenter + ROUND( val ) - Hdiv2;
+ 
+ startx01 -= wireestx( startx01, starty01, endy01, tileptr01->lweight ) ;
+ endx01   += wireestx( endx01, starty01, endy01, tileptr01->rweight   ) ;
+ starty01 -= wireesty( starty01, startx01, endx01, tileptr01->bweight ) ;
+ endy01   += wireesty( endy01, startx01, endx01, tileptr01->tweight   ) ;
+ /*
+  *   Hash these coordinates to find the possible overlaps
+  *   Bins to check are: bucket + (lowBinX->highBinX, lowBinY->highBinY)
+  */
+ 
+ lowBinX = (startx01 - binOffsetX) / binWidthX ;
+ if( lowBinX < 1 ) {
+     lowBinX = 1 ;
+ } else if( lowBinX > numBinsX ) {
+     lowBinX = numBinsX ;
+ }
+ highBinX = (endx01 - binOffsetX) / binWidthX ;
+ if( highBinX > numBinsX ) {
+     highBinX = numBinsX ;
+ } else if( highBinX < 1 ) {
+     highBinX = 1 ;
+ }
+ lowBinY = (starty01 - binOffsetY) / binWidthY ;
+ if( lowBinY < 1 ) {
+     lowBinY = 1 ;
+ } else if( lowBinY > numBinsY ) {
+     lowBinY = numBinsY ;
+ }
+ highBinY = (endy01 - binOffsetY) / binWidthY ;
+ if( highBinY > numBinsY ) {
+     highBinY = numBinsY ;
+ } else if( highBinY < 1 ) {
+     highBinY = 1 ;
+ }
+ if( lowBinX == highBinX && lowBinY == highBinY ) {
+     binX = lowBinX ;
+     binY = lowBinY ;
+ } else {
+     binX = 0 ;
+     binY = 0 ;
+ }
+ 
+ for( i = 0 ; i <= highBinX ; i++ ) {
+     if( !(i == 0 || i >= lowBinX) ) {
+ 	continue ;
+     }
+     for( j = 0 ; j <= highBinY ; j++ ) {
+ 	if( !((i == 0 && j == 0) || (i > 0 && j >= lowBinY)) ) {
+ 	    continue ;
+ 	}
+ 	occuptr = blockarray[i][j] ;
+ 	for( k = 1 ; k <= occuptr[0] ; k++ ) {
+ 	    othercell = occuptr[k] ;
+ 	    if( othercell == cell ) {
+ 		continue ;
+ 	    }
+ 	    cellptr2 = cellarray[othercell] ;
+ 	    tileptr02 = cellptr2->config[ cellptr2->orient ] ;
+ 	    xcenter = cellptr2->xcenter ;
+ 	    ycenter = cellptr2->ycenter ;
+ 	    startx02 = xcenter + tileptr02->left    ;
+ 	    endx02   = xcenter + tileptr02->right   ;
+ 	    starty02 = ycenter + tileptr02->bottom  ;
+ 	    endy02   = ycenter + tileptr02->top     ;
+ 	    if( othercell <= numcells ) {
+ 		startx02 -= wireestx( startx02 , starty02 , endy02 ,
+ 						tileptr02->lweight ) ;
+ 		endx02   += wireestx( endx02 , starty02 , endy02 ,
+ 						tileptr02->rweight ) ;
+ 		starty02 -= wireesty( starty02 , startx02 , endx02 ,
+ 						tileptr02->bweight ) ;
+ 		endy02   += wireesty( endy02 , startx02 , endx02 ,
+ 						tileptr02->tweight ) ;
+ 	    }
+ 	    if( startx02 >= endx01 || startx01 >= endx02 || 
+ 			starty02 >= endy01 || starty01 >= endy02 ){
+ 		continue ;
+ 	    }
+ 	    if( cellptr1->numtiles == 1 && cellptr2->numtiles == 1 ) {
+ 		startx = (startx01 >= startx02) ? startx01 : startx02 ;
+ 		endx = (endx01 <= endx02) ? endx01 : endx02 ;
+ 		starty = (starty01 >= starty02) ? starty01 : starty02 ;
+ 		endy = (endy01 <= endy02) ? endy01 : endy02 ;
+ 		value += (int)( lapFactor * (double)( (endy - starty) * 
+ 					(endx - startx) + offset ) ) ;
+ 	    } else {
+ 		tempval = 0 ;
+ 		for( tileptr1 = tileptr01->nexttile ;
+ 				    tileptr1 != TILENULL ;
+ 				    tileptr1 = tileptr1->nexttile ) {
+ 		    val = (double)(tileptr1->oleft - oleft) / aspFactor;
+ 		    startx1 = cellptr1->xcenter + ROUND( val ) - Wdiv2 ;
+ 
+ 		    val = (double)(tileptr1->oright - oleft)/ aspFactor;
+ 		    endx1 = cellptr1->xcenter + ROUND( val ) - Wdiv2 ;
+ 
+ 		    val = (double)(tileptr1->obottom - obottom) * 
+ 							    aspFactor;
+ 		    starty1 = cellptr1->ycenter + ROUND( val ) - Hdiv2 ;
+ 
+ 		    val = (double)(tileptr1->otop - obottom)* aspFactor;
+ 		    endy1 = cellptr1->ycenter + ROUND( val ) - Hdiv2 ;
+ 		    startx1 -= wireestx( startx1 , starty1 , endy1 ,
+ 						tileptr1->lweight ) ;
+ 		    endx1   += wireestx( endx1 , starty1 , endy1 ,
+ 						tileptr1->rweight ) ;
+ 		    starty1 -= wireesty( starty1 , startx1 , endx1 ,
+ 						tileptr1->bweight ) ;
+ 		    endy1   += wireesty( endy1 , startx1 , endx1 ,
+ 						tileptr1->tweight ) ;
+ 
+ 		    for( tileptr2 = tileptr02->nexttile ; 
+ 				    tileptr2 != TILENULL ;
+ 				    tileptr2 = tileptr2->nexttile ) {
+ 			startx2 =  xcenter + tileptr2->left  ;
+ 			endx2   =  xcenter + tileptr2->right ;
+ 			starty2 =  ycenter + tileptr2->bottom;
+ 			endy2   =  ycenter + tileptr2->top   ;
+ 			if( othercell <= numcells ) {
+ 			    startx2 -= wireestx( startx2 , starty2 , 
+ 					endy2 , tileptr2->lweight ) ;
+ 			    endx2   += wireestx( endx2 , starty2 , 
+ 					endy2 , tileptr2->rweight ) ;
+ 			    starty2 -= wireesty( starty2 , startx2 , 
+ 					endx2 , tileptr2->bweight ) ;
+ 			    endy2   += wireesty( endy2 , startx2 , 
+ 					endx2 , tileptr2->tweight ) ;
+ 			}
+ 			if( startx2 >= endx1 || startx1 >= endx2 || 
+ 				 starty2 >= endy1 || starty1 >= endy2 ){
+ 			    continue ;
+ 			}
+ 			startx = (startx1 >= startx2) ? 
+ 						    startx1 : startx2 ;
+ 			endx = (endx1 <= endx2) ? endx1 : endx2 ;
+ 			starty = (starty1 >= starty2) ? 
+ 						    starty1 : starty2 ;
+ 			endy = (endy1 <= endy2) ? endy1 : endy2 ;
+ 			tempval += (endy - starty) * (endx - startx) ;
+ 		    }
+ 		}
+ 		if( tempval != 0 ) {
+ 		    value += (int)( lapFactor * (double)
+ 						( tempval + offset ) ) ;
+ 		}
+ 	    }
+ 	}
+     }
+ }
+ return( value ) ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/xgraph.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/xgraph.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/xgraph.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,242 ----
+ #include "geo.h"
+ 
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ 
+ void xgraph(void)
+ {
+ 
+ int i , vedge , location , eindex , et , eb , t , b , cell , count ;
+ int beginEdge , iedge , inode , oedge , onode , lastE ;
+ WCPTR saveptr ;
+ DLINK1PTR vptr ;
+ PLISTPTR plptr ;
+ FLAREPTR fptr , ifptr , ofptr ;
+ TNODEPTR tnode ;
+ 
+ xNodules = (NODPTR) malloc( (2 + numberCells) * sizeof(NODBOX));
+ for( i = 0 ; i <= numberCells + 1 ; i++ ) {
+     xNodules[i].inList = (FLAREPTR) NULL ;
+     xNodules[i].outList = (FLAREPTR) NULL ;
+     xNodules[i].done = 0 ;
+ }
+ vptr = Vlist ;
+ vedge = vptr->edge ;
+ location = edgeList[vedge].loc ;
+ et = edgeList[vedge].end ;
+ eb = edgeList[vedge].start ;
+ plptr = tplist( vChanBeginRoot , location ) ;
+ for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+     eindex = plptr->property ;
+     t = eArray[eindex].hiend ;
+     b = eArray[eindex].loend ;
+     if( ! (b >= eb && t <= et) ) {
+ 	continue ;
+     }
+     fptr = xNodules[0].outList ;
+     xNodules[0].outList = (FLAREPTR) malloc( sizeof(FLARE) ) ;
+     xNodules[0].outList->next = fptr ;
+     xNodules[0].outList->fixEdge = vedge ;
+     xNodules[0].outList->eindex = (int *) malloc( 2 * sizeof(int) ) ; 
+     xNodules[0].outList->eindex[0] = 1 ; 
+     xNodules[0].outList->eindex[1] = eindex ; 
+     xNodules[0].done = 1 ; 
+ }
+ vptr = Vend ;
+ vedge = vptr->edge ;
+ location = edgeList[vedge].loc ;
+ et = edgeList[vedge].end ;
+ eb = edgeList[vedge].start ;
+ plptr = tplist( vChanEndRoot , location ) ;
+ for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+     eindex = plptr->property ;
+     t = eArray[eindex].hiend ;
+     b = eArray[eindex].loend ;
+     if( ! (b >= eb && t <= et) ) {
+ 	continue ;
+     }
+     fptr = xNodules[numberCells + 1].inList ;
+     xNodules[numberCells + 1].inList = (FLAREPTR) malloc(sizeof(FLARE));
+     xNodules[numberCells + 1].inList->next = fptr ;
+     xNodules[numberCells + 1].inList->fixEdge = vedge ;
+     xNodules[numberCells + 1].inList->eindex = (int *) 
+ 						malloc(2 * sizeof(int)); 
+     xNodules[numberCells + 1].inList->eindex[0] = 1 ; 
+     xNodules[numberCells + 1].inList->eindex[1] = eindex ; 
+     xNodules[numberCells + 1].done = 1 ; 
+ }
+ 
+ vptr = vFixedList->next ;
+ for( ; vptr->next != (DLINK1PTR) NULL ; vptr = vptr->next ) {
+     vedge = vptr->edge ;
+     cell = edgeList[vedge].cell ;
+     if( xNodules[cell].done == 1 ) {
+ 	continue ;
+     }
+     xNodules[cell].done = 1 ;
+     beginEdge = vedge ;
+     do {
+ 	if( edgeList[vedge].UorR > 0 ) {
+ 	    location = edgeList[vedge].loc ;
+ 	    plptr = tplist( vChanEndRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		if( eArray[eindex].edge2 != vedge ) {
+ 		    continue ;
+ 		}
+ 		fptr = xNodules[cell].inList ;
+ 		xNodules[cell].inList = (FLAREPTR) malloc(sizeof(FLARE));
+ 		xNodules[cell].inList->next = fptr ;
+ 		xNodules[cell].inList->fixEdge = vedge ;
+ 		xNodules[cell].inList->eindex = (int *) 
+ 						malloc(2 * sizeof(int)); 
+ 		xNodules[cell].inList->eindex[0] = 1 ; 
+ 		xNodules[cell].inList->eindex[1] = eindex ; 
+ 	    }
+ 	} else {
+ 	    location = edgeList[vedge].loc ;
+ 	    plptr = tplist( vChanBeginRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		if( eArray[eindex].edge1 != vedge ) {
+ 		    continue ;
+ 		}
+ 		fptr = xNodules[cell].outList ;
+ 		xNodules[cell].outList = (FLAREPTR) malloc(sizeof(FLARE));
+ 		xNodules[cell].outList->next = fptr ;
+ 		xNodules[cell].outList->fixEdge = vedge ;
+ 		xNodules[cell].outList->eindex = (int *) 
+ 						malloc(2 * sizeof(int)); 
+ 		xNodules[cell].outList->eindex[0] = 1 ; 
+ 		xNodules[cell].outList->eindex[1] = eindex ; 
+ 	    }
+ 	}
+ 	vedge = edgeList[vedge].nextEdge ;
+ 	vedge = edgeList[vedge].nextEdge ;
+     } while( vedge != beginEdge ) ;
+ }
+ 
+ for( cell = 0 ; cell <= numberCells + 1 ; cell++ ) {
+     fptr = xNodules[cell].inList ;
+     for( ; fptr != (FLAREPTR) NULL ; fptr = fptr->next ) {
+ 	for( count = fptr->eindex[0]; count <= fptr->eindex[0]; count++){
+ 	    eindex = fptr->eindex[count] ;
+ 	    location = eArray[eindex].lbside ;
+ 	    et = eArray[eindex].hiend ;
+ 	    eb = eArray[eindex].loend ;
+ 	    vedge = eArray[eindex].edge1 ;
+ 	    plptr = tplist( vChanEndRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		t = eArray[eindex].hiend ;
+ 		b = eArray[eindex].loend ;
+ 		if( ! (b >= eb && t <= et) ) {
+ 		    continue ;
+ 		}
+ 		tdelete( &vChanEndRoot , location , eindex ) ;
+ 		if( ++(fptr->eindex[0]) % 2 == 0 ) {
+ 		    fptr->eindex = (int *) realloc( fptr->eindex ,
+ 				(2 + fptr->eindex[0]) * sizeof(int) ) ;
+ 		}
+ 		fptr->eindex[ fptr->eindex[0] ] = eindex ;
+ 		break ;
+ 	    }
+ 	}
+     }
+     fptr = xNodules[cell].outList ;
+     for( ; fptr != (FLAREPTR) NULL ; fptr = fptr->next ) {
+ 	for( count = fptr->eindex[0]; count <= fptr->eindex[0]; count++){
+ 	    eindex = fptr->eindex[count] ;
+ 	    location = eArray[eindex].rtside ;
+ 	    et = eArray[eindex].hiend ;
+ 	    eb = eArray[eindex].loend ;
+ 	    plptr = tplist( vChanBeginRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		t = eArray[eindex].hiend ;
+ 		b = eArray[eindex].loend ;
+ 		if( ! (b >= eb && t <= et) ) {
+ 		    continue ;
+ 		}
+ 		tdelete( &vChanBeginRoot , location , eindex ) ;
+ 		if( ++(fptr->eindex[0]) % 2 == 0 ) {
+ 		    fptr->eindex = (int *) realloc( fptr->eindex ,
+ 				(2 + fptr->eindex[0]) * sizeof(int) ) ;
+ 		}
+ 		fptr->eindex[ fptr->eindex[0] ] = eindex ;
+ 		break ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ numXnodes = 0 ;
+ for( vptr = vFixedList; vptr != (DLINK1PTR) NULL; vptr = vptr->next ){
+     edgeList[ vptr->edge ].node = ++numXnodes ;
+ }
+ xNodeArray = (WCPTR *) malloc( (1 + numXnodes) * sizeof(WCPTR) );
+ for( i = 1 ; i <= numXnodes ; i++ ) {
+     xNodeArray[i] = (WCPTR) NULL ;
+ }
+ for( cell = 1 ; cell <= numberCells ; cell++ ) {
+     ifptr = xNodules[cell].inList ;
+     for( ; ifptr != (FLAREPTR) NULL ; ifptr = ifptr->next ) {
+ 	iedge = ifptr->fixEdge ;
+ 	inode = edgeList[iedge].node ;
+ 	ofptr = xNodules[cell].outList ;
+ 	for( ; ofptr != (FLAREPTR) NULL ; ofptr = ofptr->next ) {
+ 	    oedge = ofptr->fixEdge ;
+ 	    onode = edgeList[oedge].node ;
+ 	    saveptr = xNodeArray[inode] ;
+ 	    xNodeArray[inode] = (WCPTR) malloc( sizeof(WCBOX));
+ 	    xNodeArray[inode]->next = saveptr ;
+ 	    xNodeArray[inode]->fixedWidth = 1 ;
+ 	    xNodeArray[inode]->node = onode ;
+ 	    xNodeArray[inode]->channels = (int *) NULL ;
+ 	    xNodeArray[inode]->length = edgeList[oedge].loc -
+ 					edgeList[iedge].loc ;
+ 	}
+     }
+ }
+ for( cell = 0 ; cell <= numberCells + 1 ; cell++ ) {
+     ofptr = xNodules[cell].outList ;
+     for( ; ofptr != (FLAREPTR) NULL ; ofptr = ofptr->next ) {
+ 	iedge = ofptr->fixEdge ;
+ 	inode = edgeList[iedge].node ;
+ 
+ 	lastE = ofptr->eindex[ ofptr->eindex[0] ] ;
+ 	onode = edgeList[ eArray[lastE].edge2 ].node ;
+ 
+ 	saveptr = xNodeArray[inode] ;
+ 	xNodeArray[inode] = (WCPTR) malloc( sizeof(WCBOX));
+ 	xNodeArray[inode]->next = saveptr ;
+ 	xNodeArray[inode]->fixedWidth = 0 ;
+ 	xNodeArray[inode]->length = 0 ;
+ 	xNodeArray[inode]->node = onode ;
+ 	xNodeArray[inode]->channels = (int *) malloc( (1 + 
+ 				ofptr->eindex[0] ) * sizeof(int) );
+ 	for( count = 0 ; count <= ofptr->eindex[0] ; count++ ) {
+ 	    xNodeArray[inode]->channels[count] = ofptr->eindex[count] ;
+ 	}
+     }
+ }
+ 
+ if( vChanBeginRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &vChanBeginRoot , &tnode , &location , &eindex ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( vChanEndRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &vChanEndRoot , &tnode , &location , &eindex ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ return ;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ygraph.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ygraph.c:1.1
*** /dev/null	Tue Oct  5 16:20:07 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/ygraph.c	Tue Oct  5 16:19:50 2004
***************
*** 0 ****
--- 1,243 ----
+ #include "geo.h"
+ 
+ extern void tdelete( TNODEPTR *root , int value , int property );
+ extern void tpop( TNODEPTR *root , TNODEPTR *node , int *value ,
+ 		 int *property);
+ 
+ void ygraph(void)
+ {
+ 
+ int i , hedge , location , eindex , er , el , r , l , cell , count ;
+ int beginEdge , iedge , inode , oedge , onode , lastE ;
+ WCPTR saveptr ;
+ DLINK1PTR hptr ;
+ PLISTPTR plptr ;
+ FLAREPTR fptr , ifptr , ofptr ;
+ TNODEPTR tnode ;
+ 
+ 
+ yNodules = (NODPTR) malloc( (2 + numberCells) * sizeof(NODBOX));
+ for( i = 0 ; i <= numberCells + 1 ; i++ ) {
+     yNodules[i].inList = (FLAREPTR) NULL ;
+     yNodules[i].outList = (FLAREPTR) NULL ;
+     yNodules[i].done = 0 ;
+ }
+ hptr = Hlist ;
+ hedge = hptr->edge ;
+ location = edgeList[hedge].loc ;
+ er = edgeList[hedge].end ;
+ el = edgeList[hedge].start ;
+ plptr = tplist( hChanBeginRoot , location ) ;
+ for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+     eindex = plptr->property ;
+     r = eArray[eindex].hiend ;
+     l = eArray[eindex].loend ;
+     if( ! (l >= el && r <= er) ) {
+ 	continue ;
+     }
+     fptr = yNodules[0].outList ;
+     yNodules[0].outList = (FLAREPTR) malloc( sizeof(FLARE) ) ;
+     yNodules[0].outList->next = fptr ;
+     yNodules[0].outList->fixEdge = hedge ;
+     yNodules[0].outList->eindex = (int *) malloc( 2 * sizeof(int) ) ; 
+     yNodules[0].outList->eindex[0] = 1 ; 
+     yNodules[0].outList->eindex[1] = eindex ; 
+     yNodules[0].done = 1 ; 
+ }
+ hptr = Hend ;
+ hedge = hptr->edge ;
+ location = edgeList[hedge].loc ;
+ er = edgeList[hedge].end ;
+ el = edgeList[hedge].start ;
+ plptr = tplist( hChanEndRoot , location ) ;
+ for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+     eindex = plptr->property ;
+     r = eArray[eindex].hiend ;
+     l = eArray[eindex].loend ;
+     if( ! (l >= el && r <= er) ) {
+ 	continue ;
+     }
+     fptr = yNodules[numberCells + 1].inList ;
+     yNodules[numberCells + 1].inList = (FLAREPTR) malloc(sizeof(FLARE));
+     yNodules[numberCells + 1].inList->next = fptr ;
+     yNodules[numberCells + 1].inList->fixEdge = hedge ;
+     yNodules[numberCells + 1].inList->eindex = (int *) 
+ 						malloc(2 * sizeof(int)); 
+     yNodules[numberCells + 1].inList->eindex[0] = 1 ; 
+     yNodules[numberCells + 1].inList->eindex[1] = eindex ; 
+     yNodules[numberCells + 1].done = 1 ; 
+ }
+ 
+ hptr = hFixedList->next ;
+ for( ; hptr->next != (DLINK1PTR) NULL ; hptr = hptr->next ) {
+     hedge = hptr->edge ;
+     cell = edgeList[hedge].cell ;
+     if( yNodules[cell].done == 1 ) {
+ 	continue ;
+     }
+     yNodules[cell].done = 1 ;
+     beginEdge = hedge ;
+     do {
+ 	if( edgeList[hedge].UorR < 0 ) {
+ 	    location = edgeList[hedge].loc ;
+ 	    plptr = tplist( hChanEndRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		if( eArray[eindex].edge2 != hedge ) {
+ 		    continue ;
+ 		}
+ 		fptr = yNodules[cell].inList ;
+ 		yNodules[cell].inList = (FLAREPTR) malloc(sizeof(FLARE));
+ 		yNodules[cell].inList->next = fptr ;
+ 		yNodules[cell].inList->fixEdge = hedge ;
+ 		yNodules[cell].inList->eindex = (int *) 
+ 						malloc(2 * sizeof(int)); 
+ 		yNodules[cell].inList->eindex[0] = 1 ; 
+ 		yNodules[cell].inList->eindex[1] = eindex ; 
+ 	    }
+ 	} else {
+ 	    location = edgeList[hedge].loc ;
+ 	    plptr = tplist( hChanBeginRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		if( eArray[eindex].edge1 != hedge ) {
+ 		    continue ;
+ 		}
+ 		fptr = yNodules[cell].outList ;
+ 		yNodules[cell].outList = (FLAREPTR) malloc(sizeof(FLARE));
+ 		yNodules[cell].outList->next = fptr ;
+ 		yNodules[cell].outList->fixEdge = hedge ;
+ 		yNodules[cell].outList->eindex = (int *) 
+ 						malloc(2 * sizeof(int)); 
+ 		yNodules[cell].outList->eindex[0] = 1 ; 
+ 		yNodules[cell].outList->eindex[1] = eindex ; 
+ 	    }
+ 	}
+ 	hedge = edgeList[hedge].nextEdge ;
+ 	hedge = edgeList[hedge].nextEdge ;
+     } while( hedge != beginEdge ) ;
+ }
+ 
+ for( cell = 0 ; cell <= numberCells + 1 ; cell++ ) {
+     fptr = yNodules[cell].inList ;
+     for( ; fptr != (FLAREPTR) NULL ; fptr = fptr->next ) {
+ 	for( count = fptr->eindex[0]; count <= fptr->eindex[0]; count++){
+ 	    eindex = fptr->eindex[count] ;
+ 	    location = eArray[eindex].lbside ;
+ 	    er = eArray[eindex].hiend ;
+ 	    el = eArray[eindex].loend ;
+ 	    plptr = tplist( hChanEndRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		r = eArray[eindex].hiend ;
+ 		l = eArray[eindex].loend ;
+ 		if( ! (l >= el && r <= er) ) {
+ 		    continue ;
+ 		}
+ 		tdelete( &hChanEndRoot , location , eindex ) ;
+ 		if( ++(fptr->eindex[0]) % 2 == 0 ) {
+ 		    fptr->eindex = (int *) realloc( fptr->eindex ,
+ 				(2 + fptr->eindex[0]) * sizeof(int) ) ;
+ 		}
+ 		fptr->eindex[ fptr->eindex[0] ] = eindex ;
+ 		break ;
+ 	    }
+ 	}
+     }
+     fptr = yNodules[cell].outList ;
+     for( ; fptr != (FLAREPTR) NULL ; fptr = fptr->next ) {
+ 	for( count = fptr->eindex[0]; count <= fptr->eindex[0]; count++){
+ 	    eindex = fptr->eindex[count] ;
+ 	    location = eArray[eindex].rtside ;
+ 	    er = eArray[eindex].hiend ;
+ 	    el = eArray[eindex].loend ;
+ 	    plptr = tplist( hChanBeginRoot , location ) ;
+ 	    for( ; plptr != (PLISTPTR) NULL ; plptr = plptr->pnext ) {
+ 		eindex = plptr->property ;
+ 		r = eArray[eindex].hiend ;
+ 		l = eArray[eindex].loend ;
+ 		if( ! (l >= el && r <= er) ) {
+ 		    continue ;
+ 		}
+ 		tdelete( &hChanBeginRoot , location , eindex ) ;
+ 		if( ++(fptr->eindex[0]) % 2 == 0 ) {
+ 		    fptr->eindex = (int *) realloc( fptr->eindex ,
+ 				(2 + fptr->eindex[0]) * sizeof(int) ) ;
+ 		}
+ 		fptr->eindex[ fptr->eindex[0] ] = eindex ;
+ 		break ;
+ 	    }
+ 	}
+     }
+ }
+ 
+ numYnodes = 0 ;
+ for( hptr = hFixedList; hptr != (DLINK1PTR) NULL; hptr = hptr->next ){
+     edgeList[ hptr->edge ].node = ++numYnodes ;
+ }
+ yNodeArray = (WCPTR *) malloc( (1 + numYnodes) * sizeof(WCPTR) );
+ for( i = 1 ; i <= numYnodes ; i++ ) {
+     yNodeArray[i] = (WCPTR) NULL ;
+ }
+ for( cell = 1 ; cell <= numberCells ; cell++ ) {
+     ifptr = yNodules[cell].inList ;
+     for( ; ifptr != (FLAREPTR) NULL ; ifptr = ifptr->next ) {
+ 	iedge = ifptr->fixEdge ;
+ 	inode = edgeList[iedge].node ;
+ 	ofptr = yNodules[cell].outList ;
+ 	for( ; ofptr != (FLAREPTR) NULL ; ofptr = ofptr->next ) {
+ 	    oedge = ofptr->fixEdge ;
+ 	    onode = edgeList[oedge].node ;
+ 	    saveptr = yNodeArray[inode] ;
+ 	    yNodeArray[inode] = (WCPTR) malloc( sizeof(WCBOX));
+ 	    yNodeArray[inode]->next = saveptr ;
+ 	    yNodeArray[inode]->fixedWidth = 1 ;
+ 	    yNodeArray[inode]->node = onode ;
+ 	    yNodeArray[inode]->channels = (int *) NULL ;
+ 	    yNodeArray[inode]->length = edgeList[oedge].loc -
+ 					edgeList[iedge].loc ;
+ 	}
+     }
+ }
+ for( cell = 0 ; cell <= numberCells + 1 ; cell++ ) {
+     ofptr = yNodules[cell].outList ;
+     for( ; ofptr != (FLAREPTR) NULL ; ofptr = ofptr->next ) {
+ 	iedge = ofptr->fixEdge ;
+ 	inode = edgeList[iedge].node ;
+ 
+ 	lastE = ofptr->eindex[ ofptr->eindex[0] ] ;
+ 	onode = edgeList[ eArray[lastE].edge2 ].node ;
+ 
+ 	saveptr = yNodeArray[inode] ;
+ 	yNodeArray[inode] = (WCPTR) malloc( sizeof(WCBOX));
+ 	yNodeArray[inode]->next = saveptr ;
+ 	yNodeArray[inode]->fixedWidth = 0 ;
+ 	yNodeArray[inode]->length = 0 ;
+ 	yNodeArray[inode]->node = onode ;
+ 	yNodeArray[inode]->channels = (int *) malloc( (1 + 
+ 				ofptr->eindex[0]) * sizeof(int) );
+ 	for( count = 0 ; count <= ofptr->eindex[0] ; count++ ) {
+ 	    yNodeArray[inode]->channels[count] = ofptr->eindex[count] ;
+ 	}
+     }
+ }
+ 
+ if( hChanBeginRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &hChanBeginRoot , &tnode , &location , &eindex ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ if( hChanEndRoot != (TNODEPTR) NULL ) {
+     for( ; ; ) {
+ 	tpop( &hChanEndRoot , &tnode , &location , &eindex ) ;
+ 	if( tnode == (TNODEPTR) NULL ) {
+ 	    break ;
+ 	}
+     }
+ }
+ 
+ return ;
+ }






More information about the llvm-commits mailing list