[llvm-commits] [parallel] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Fontmap LICENSE.TXT Makefile alloc.h alphabet.ps ansi2knr.c arch.h bdftops.ps cframe_.h cheq.ps chess.ps copyleft.c copyleft.ps decrypt.ps dict.h dosstore.h empty.ps errors.h escher.ps estack.h fcutils.ps font.h gdevbj10.c gdevdjet.c gdevega.h gdevmd10.h gdevmem.c gdevprn.c gdevprn.h gdevs.c gdevs.h gdevsnfb.c gdevsun.c gdevvga.h gdevx.c gdevx.h genarch genarch.c gfonts.ps ghost.h ghost.ps ghost2.ps golfer.ps gp_unix.c gp_vms.c gs.c gs.h gschar.c gschar.h gscolor.c gsconfig gscoord.c gscoord.h gsdevice.c gserrors.h gsfile.c gsfont.c gsfont.h gsim2out.c gsimage.c gsline.c gsmain.c gsmatrix.c gsmatrix.h gsmisc.c gspaint.c gspaint.h gspath.c gspath.h gspath2.c gsstate.c gsstate.h gstype1.c gstype1.h gt.c gvirtmem.c gvirtmem.h gx.h gxarith.h gxbitmap.h gxcache.c gxchar.h gxcolor.c gxdevice.h gxdevmem.h gxdither.c gxdraw.c gxfdir.h gxfill.c gxfixed.h gxfont.h gxfont1.h gxht.c gximage.h gxmatrix.h gx! path.c gxpath.h gxpath2.c gxstroke.c gxtype1.h gzcolor.h gzdevice.h gzht.h gzline.h gzpath.h gzstate.h ialloc.c idebug.c idict.c iinit.c iname.c interp.c iscan.c iutil.c lines.ps malloc_.h math_.h memory_.h name.h oper.h path.h pcharstr.ps ppath.ps prfont.ps ps2image.ps pstoppm.ps quit.ps scanchar.h sstorei.h state.h statusd.ps std.h store.h stream.c stream.h string_.h traceop.ps utrace.c vmsmath.h zarith.c zarray.c zchar.c zcolor.c zcontrol.c zdevice.c zdict.c zfile.c zfont.c zgeneric.c zgstate.c zht.c zmath.c zmatrix.c zmisc.c zpacked.c zpaint.c zpath.c zpath2.c zrelbit.c zstack.c zstring.c ztype.c zvmem.c

Misha Brukman brukman at cs.uiuc.edu
Mon Mar 1 19:42:07 PST 2004


Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs:

Fontmap added (r1.1.2.1)
LICENSE.TXT added (r1.2.2.1)
Makefile added (r1.2.2.1)
alloc.h added (r1.1.2.1)
alphabet.ps added (r1.1.2.1)
ansi2knr.c added (r1.1.2.1)
arch.h added (r1.1.2.1)
bdftops.ps added (r1.1.2.1)
cframe_.h added (r1.1.2.1)
cheq.ps added (r1.1.2.1)
chess.ps added (r1.1.2.1)
copyleft.c added (r1.1.2.1)
copyleft.ps added (r1.1.2.1)
decrypt.ps added (r1.1.2.1)
dict.h added (r1.1.2.1)
dosstore.h added (r1.1.2.1)
empty.ps added (r1.1.2.1)
errors.h added (r1.1.2.1)
escher.ps added (r1.1.2.1)
estack.h added (r1.1.2.1)
fcutils.ps added (r1.1.2.1)
font.h added (r1.1.2.1)
gdevbj10.c added (r1.1.2.1)
gdevdjet.c added (r1.1.2.1)
gdevega.h added (r1.1.2.1)
gdevmd10.h added (r1.1.2.1)
gdevmem.c added (r1.1.2.1)
gdevprn.c added (r1.1.2.1)
gdevprn.h added (r1.1.2.1)
gdevs.c added (r1.1.2.1)
gdevs.h added (r1.1.2.1)
gdevsnfb.c added (r1.1.2.1)
gdevsun.c added (r1.1.2.1)
gdevvga.h added (r1.1.2.1)
gdevx.c added (r1.1.2.1)
gdevx.h added (r1.1.2.1)
genarch added (r1.1.2.1)
genarch.c added (r1.1.2.1)
gfonts.ps added (r1.1.2.1)
ghost.h added (r1.1.2.1)
ghost.ps added (r1.1.2.1)
ghost2.ps added (r1.1.2.1)
golfer.ps added (r1.1.2.1)
gp_unix.c added (r1.1.2.1)
gp_vms.c added (r1.1.2.1)
gs.c added (r1.1.2.1)
gs.h added (r1.1.2.1)
gschar.c added (r1.1.2.1)
gschar.h added (r1.1.2.1)
gscolor.c added (r1.1.2.1)
gsconfig added (r1.1.2.1)
gscoord.c added (r1.1.2.1)
gscoord.h added (r1.1.2.1)
gsdevice.c added (r1.1.2.1)
gserrors.h added (r1.1.2.1)
gsfile.c added (r1.1.2.1)
gsfont.c added (r1.1.2.1)
gsfont.h added (r1.1.2.1)
gsim2out.c added (r1.1.2.1)
gsimage.c added (r1.1.2.1)
gsline.c added (r1.1.2.1)
gsmain.c added (r1.1.2.1)
gsmatrix.c added (r1.1.2.1)
gsmatrix.h added (r1.1.2.1)
gsmisc.c added (r1.1.2.1)
gspaint.c added (r1.1.2.1)
gspaint.h added (r1.1.2.1)
gspath.c added (r1.1.2.1)
gspath.h added (r1.1.2.1)
gspath2.c added (r1.1.2.1)
gsstate.c added (r1.1.2.1)
gsstate.h added (r1.1.2.1)
gstype1.c added (r1.1.2.1)
gstype1.h added (r1.1.2.1)
gt.c added (r1.1.2.1)
gvirtmem.c added (r1.1.2.1)
gvirtmem.h added (r1.1.2.1)
gx.h added (r1.1.2.1)
gxarith.h added (r1.1.2.1)
gxbitmap.h added (r1.1.2.1)
gxcache.c added (r1.1.2.1)
gxchar.h added (r1.1.2.1)
gxcolor.c added (r1.1.2.1)
gxdevice.h added (r1.1.2.1)
gxdevmem.h added (r1.1.2.1)
gxdither.c added (r1.1.2.1)
gxdraw.c added (r1.1.2.1)
gxfdir.h added (r1.1.2.1)
gxfill.c added (r1.1.2.1)
gxfixed.h added (r1.1.2.1)
gxfont.h added (r1.1.2.1)
gxfont1.h added (r1.1.2.1)
gxht.c added (r1.1.2.1)
gximage.h added (r1.1.2.1)
gxmatrix.h added (r1.1.2.1)
gxpath.c added (r1.1.2.1)
gxpath.h added (r1.1.2.1)
gxpath2.c added (r1.1.2.1)
gxstroke.c added (r1.1.2.1)
gxtype1.h added (r1.1.2.1)
gzcolor.h added (r1.1.2.1)
gzdevice.h added (r1.1.2.1)
gzht.h added (r1.1.2.1)
gzline.h added (r1.1.2.1)
gzpath.h added (r1.1.2.1)
gzstate.h added (r1.1.2.1)
ialloc.c added (r1.2.2.1)
idebug.c added (r1.1.2.1)
idict.c added (r1.1.2.1)
iinit.c added (r1.1.2.1)
iname.c added (r1.1.2.1)
interp.c added (r1.1.2.1)
iscan.c added (r1.1.2.1)
iutil.c added (r1.1.2.1)
lines.ps added (r1.1.2.1)
malloc_.h added (r1.1.2.1)
math_.h added (r1.1.2.1)
memory_.h added (r1.1.2.1)
name.h added (r1.1.2.1)
oper.h added (r1.1.2.1)
path.h added (r1.1.2.1)
pcharstr.ps added (r1.1.2.1)
ppath.ps added (r1.1.2.1)
prfont.ps added (r1.1.2.1)
ps2image.ps added (r1.1.2.1)
pstoppm.ps added (r1.1.2.1)
quit.ps added (r1.1.2.1)
scanchar.h added (r1.1.2.1)
sstorei.h added (r1.1.2.1)
state.h added (r1.1.2.1)
statusd.ps added (r1.1.2.1)
std.h added (r1.1.2.1)
store.h added (r1.1.2.1)
stream.c added (r1.1.2.1)
stream.h added (r1.1.2.1)
string_.h added (r1.1.2.1)
traceop.ps added (r1.1.2.1)
utrace.c added (r1.1.2.1)
vmsmath.h added (r1.1.2.1)
zarith.c added (r1.1.2.1)
zarray.c added (r1.1.2.1)
zchar.c added (r1.1.2.1)
zcolor.c added (r1.1.2.1)
zcontrol.c added (r1.1.2.1)
zdevice.c added (r1.1.2.1)
zdict.c added (r1.1.2.1)
zfile.c added (r1.1.2.1)
zfont.c added (r1.1.2.1)
zgeneric.c added (r1.1.2.1)
zgstate.c added (r1.1.2.1)
zht.c added (r1.1.2.1)
zmath.c added (r1.1.2.1)
zmatrix.c added (r1.1.2.1)
zmisc.c added (r1.1.2.1)
zpacked.c added (r1.1.2.1)
zpaint.c added (r1.1.2.1)
zpath.c added (r1.1.2.1)
zpath2.c added (r1.1.2.1)
zrelbit.c added (r1.1.2.1)
zstack.c added (r1.1.2.1)
zstring.c added (r1.1.2.1)
ztype.c added (r1.1.2.1)
zvmem.c added (r1.1.2.1)

---
Log message:

Merge from trunk

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

Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Fontmap
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Fontmap:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Fontmap	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,272 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % ----------------------------------------------------------------
+ 
+ % This file is a catalog of fonts known to Ghostscript.  Any font to be
+ % converted from BDF or Hershey to Ghostscript format, and any font
+ % that is to be loaded automatically when named, must be in this catalog.
+ 
+ % Each font has an entry consisting of five items:
+ %
+ %	- The name by which the font is known inside Ghostscript
+ %	(a Ghostscript literal name).  This is used to find the file
+ %	from which a font of a given name should be loaded.
+ %
+ %	- The name of the Ghostscript font file (a Ghostscript string).
+ %	The filename should include the extension, which (by convention)
+ %	is `.gsf'.
+ %
+ %	- The encoding to be used with the font (a Ghostscript literal name).
+ %	This is used only when converting the font.  Currently, the only
+ %	defined encodings are `/StandardEncoding' and `/SymbolEncoding'.
+ %	If the font or the conversion program specifies the encoding itself,
+ %	the encoding should be `null' (not `/null').
+ %
+ %	- The uniqueID of the font (an integer).  This is used to identify
+ %	to identify distinct fonts within the Ghostscript font machinery.
+ %	Since some P*stScr*pt programs assume that adding a small integer
+ %	to a uniqueID produces a new, distinct, unused uniqueID,
+ %	the uniqueID values in this file are all multiples of 10.
+ %	To avoid some conflicts with Adobe's numbering scheme, the uniqueID
+ %	values in this file all lie between 4200000 and 4299999.
+ %	The uniqueID is also used only when converting the font.
+ %       The algorithm for computing the UniqueID is given below.
+ %
+ %	- A terminating semicolon.
+ 
+ % Because of limitations in the MS-DOS environment, Ghostscript font
+ % file names must be no more than 8 characters long, must consist only
+ % of LOWER CASE letters, digits, and underscores, and must start with a
+ % letter.  Font names, on the other hand, need only obey the syntax of
+ % names in the Ghostscript language, which is much more liberal.
+ 
+ % The following table is actually a Ghostscript data structure.
+ % If you add new entries, be sure to copy the punctuation accurately.
+ 
+ 
+ % 
+ % A UniqueID for a Ghostscript font looks like:
+ % 
+ % 4TTWVE0
+ % 
+ % where TT is a two-digit number representing the typeface,
+ % W represents the weight (normal, bold, ...),
+ % V represents the variant (normal, italic, oblique, ...), and
+ % E represents the expansion (normal, condensed, ...).
+ % This scheme will not work forever.  As soon there are more 99
+ % typefaces, or more than 9 weights or variants, we will have to do
+ % something else. But it suffices for the near future.
+ % 
+ % The filename for a font is constructed in a somewhat similar way:
+ % 
+ % FTTWVVVE.gsf
+ % 
+ % where F is the foundry, TT a two-letter abbreviation for the
+ % typeface, and W, V, and E the weight, variant, and expansion.  Since a
+ % font can have multiple variants, we allocate three letters to that
+ % (for example, Lucida Regular Sans Typewriter Italic).  If a font has
+ % four variants, you're on your own.  If a font does have multiple
+ % variants, it's best to add the expansion letter `r', so that it is
+ % clear which letters are variants and which the expansion.
+ % 
+ % This scheme is very close to the one proposed in `Filenames for
+ % fonts', to be published in the first 1990 issue of TUGboat (the
+ % journal of the TeX Users Group).
+ % 
+ % In the following tables, we made no attempt to be exhaustive. 
+ % Instead, we have simply allocated entries for those things that we needed
+ % for the fonts that we are actually distributing.
+ % 
+ %
+ % foundries:
+ % ----------------------------------------------------------------
+ % b = Bitstream
+ % p = Adobe (`p' for PostScript)
+ % 
+ % 
+ % 
+ % typefaces:
+ % id   name			  filename prefix
+ % ----------------------------------------------------------------
+ % 08 = Avant Garde		= pag		(Adobe)
+ % 11 = Bookman			= pbk		(Adobe)
+ % 01 = Charter			= bch		(Bitstream)
+ % 02 = Courier			= pcr		(Adobe)
+ % 03 = Helvetica		= phv		(Adobe)
+ % 04 = New Century Schoolbook	= pnc		(Adobe)
+ % 09 = Palatino			= ppl		(Adobe)
+ % 05 = Symbol			= psy		(Adobe)
+ % 06 = Times			= ptm		(Adobe)
+ % 00 = Ugly			= ugly		(public domain)
+ % 07 = Zapf Chancery		= zc		(public domain)
+ % 10 = Zapf Dingbats		= pzd		(Adobe)
+ %
+ % 90 = Hershey Gothic English	= hrge
+ % 91 = Hershey Gothic Italian	= hrit
+ % 92 = Hershey Gothic German	= hrgr
+ % 93 = Hershey Greek		= hrgk
+ % 94 = Hershey Plain		= hrpl
+ % 95 = Hershey Script		= hrsc
+ % 96 = Hershey Symbol		= hrsy
+ % 
+ % 
+ % weights:
+ % 0 = normal			= r
+ % 1 = bold			= b
+ % 2 = book			= k
+ % 3 = demi			= d
+ % 4 = light			= l
+ % 
+ % 
+ % variants:
+ % 0 = normal			= r (omitted when the weight is normal)
+ % 1 = italic			= i
+ % 2 = oblique			= o
+ %
+ % 
+ % expansions:
+ % 0 = normal			= r (omitted when the weight and variant
+ %                                    are normal)
+ % 1 = narrow			= n
+ % 
+ % 
+ 
+ 
+ % 
+ % A homemade font.
+  
+ /Ugly				(uglyr.gsf)	/StandardEncoding 4000000 ;
+ 
+ 
+ % Fonts converted from bitmaps.
+ 
+ /AvantGarde-Book		(pagk.gsf)	/StandardEncoding 4082000 ;
+ /AvantGarde-BookOblique		(pagko.gsf)	/StandardEncoding 4082200 ;
+ /AvantGarde-Demi		(pagd.gsf)	/StandardEncoding 4083000 ;
+ /AvantGarde-DemiOblique		(pagdo.gsf)	/StandardEncoding 4083200 ;
+ 
+ /Bookman-Light			(pbkl.gsf)    /StandardEncoding 4114000 ;
+ /Bookman-LightItalic		(pbkli.gsf)	/StandardEncoding 4114100 ;
+ /Bookman-Demi			(pbkd.gsf)	/StandardEncoding 4113000 ;
+ /Bookman-DemiItalic		(pbkdi.gsf)	/StandardEncoding 4113100 ;
+ 
+ /Charter-Roman			(bchr.gsf)	/StandardEncoding 4010000 ;
+ /Charter-Italic			(bchri.gsf)	/StandardEncoding 4010100 ;
+ /Charter-Bold			(bchb.gsf)	/StandardEncoding 4011000 ;
+ /Charter-BoldItalic		(bchbi.gsf)	/StandardEncoding 4011100 ;
+ 
+ /Courier			(pcrr.gsf)	/StandardEncoding 4020000 ;
+ /Courier-Oblique		(pcrro.gsf)	/StandardEncoding 4020200 ;
+ /Courier-Bold			(pcrb.gsf)	/StandardEncoding 4021000 ;
+ /Courier-BoldOblique		(pcrbo.gsf)	/StandardEncoding 4021200 ;
+ 
+ /Helvetica			(phvr.gsf)	/StandardEncoding 4030000 ;
+ /Helvetica-Oblique		(phvro.gsf)	/StandardEncoding 4030200 ;
+ /Helvetica-Narrow		(phvrrn.gsf)	/StandardEncoding 4030310 ;
+ /Helvetica-Bold			(phvb.gsf)	/StandardEncoding 4031000 ;
+ /Helvetica-BoldOblique		(phvbo.gsf)	/StandardEncoding 4031200 ;
+ 
+ /NewCenturySchlbk-Roman		(pncr.gsf)	/StandardEncoding 4040000 ;
+ /NewCenturySchlbk-Italic	(pncri.gsf)	/StandardEncoding 4040100 ;
+ /NewCenturySchlbk-Bold		(pncb.gsf)	/StandardEncoding 4041000 ;
+ /NewCenturySchlbk-BoldItalic	(pncbi.gsf)	/StandardEncoding 4041100 ;
+ 
+ /Palatino-Roman			(pplr.gsf)	/StandardEncoding 4090000 ;
+ /Palatino-Italic		(pplri.gsf)	/StandardEncoding 4090100 ;
+ /Palatino-Bold			(pplb.gsf)	/StandardEncoding 4091000 ;
+ /Palatino-BoldItalic		(pplbi.gsf)	/StandardEncoding 4091100 ;
+ 
+ /Symbol				(psyr.gsf)	/SymbolEncoding   4050000 ;
+ 
+ /Times-Roman			(ptmr.gsf)	/StandardEncoding 4060000 ;
+ /Times-Italic			(ptmri.gsf)	/StandardEncoding 4060100 ;
+ /Times-Bold			(ptmb.gsf)	/StandardEncoding 4061000 ;
+ /Times-BoldItalic		(ptmbi.gsf)	/StandardEncoding 4061100 ;
+ 
+ /ZapfChancery			(zcr.gsf)	/StandardEncoding 4070000 ;
+ /ZapfChancery-Oblique		(zcro.gsf)	/StandardEncoding 4070200 ;
+ /ZapfChancery-Bold		(zcb.gsf)	/StandardEncoding 4071000 ;
+ 
+ /ZapfDingbats			(pzdr.gsf)	/StandardEncoding 4100000 ;
+ 
+ 
+ % 
+ % 
+ % Fonts converted from Hershey outlines.
+ % The UniqueID's and filenames are constructed differently for
+ % these than for the ones above, because of the strange way that the Hershey
+ % fonts were constructed.  The scheme for these looks like:
+ % 
+ % 42TTXY0
+ % 
+ % TT = typeface, X = ``class'', Y = variation
+ % 
+ % The typeface numbers are given above.
+ % 
+ % class:
+ % 0 = normal			= r
+ % 1 = simplex			= s
+ % 2 = complex			= c
+ % 3 = triplex			= t
+ % 
+ % variation:
+ % 0 = normal			(omitted)
+ % 1 = oblique			= o
+ % 2 = italic			= i
+ % 3 = bold			= b
+ % 4 = bold oblique		= bo
+ % 5 = bold italic		= bi
+ % 
+ 
+ /Hershey-Gothic-English		(hrge_r.gsf)	/StandardEncoding 4290000 ;
+ /Hershey-Gothic-English-Bold	(hrge_rb.gsf)	/StandardEncoding 4290030 ;
+ /Hershey-Gothic-English-Oblique	(hrge_ro.gsf)	/StandardEncoding 4290010 ;
+ 
+ /Hershey-Gothic-German		(hrgr_r.gsf)	/StandardEncoding 4291000 ;
+ /Hershey-Gothic-German-Bold	(hrgr_rb.gsf)	/StandardEncoding 4291030 ;
+ /Hershey-Gothic-German-Oblique	(hrgr_ro.gsf)	/StandardEncoding 4291010 ;
+ 
+ /Hershey-Gothic-Italian		(hrit_r.gsf)	/StandardEncoding 4292000 ; 
+ /Hershey-Gothic-Italian-Bold	(hrit_rb.gsf)	/StandardEncoding 4292030 ;
+ /Hershey-Gothic-Italian-Oblique	(hrit_ro.gsf)	/StandardEncoding 4292010 ;
+ 
+ /Hershey-Greek-Complex		(hrgk_c.gsf)	/StandardEncoding 4293200 ;
+ /Hershey-Greek-Simplex		(hrgk_s.gsf)	/StandardEncoding 4293100 ;
+ 
+ /Hershey-Plain			(hrpl_r.gsf)	/StandardEncoding 4294000 ;
+ /Hershey-Plain-Bold		(hrpl_rb.gsf)	/StandardEncoding 4294030 ;
+ /Hershey-Plain-Oblique		(hrpl_ro.gsf)	/StandardEncoding 4294010 ;
+ /Hershey-Plain-Simplex		(hrpl_s.gsf)	/StandardEncoding 4294100 ;
+ /Hershey-Plain-Simplex-Bold	(hrpl_sb.gsf)	/StandardEncoding 4294130 ;
+ /Hershey-Plain-Simplex-Bold-Oblique (hrpl_sbo.gsf) /StandardEncoding 4294140 ;
+ /Hershey-Plain-Simplex-Oblique	(hrpl_so.gsf)	/StandardEncoding 4294110 ;
+ /Hershey-Plain-Triplex		(hrpl_t.gsf)	/StandardEncoding 4294300 ;
+ /Hershey-Plain-Triplex-Italic	(hrpl_ti.gsf)	/StandardEncoding 4294320 ;
+ /Hershey-Plain-Triplex-Bold	(hrpl_tb.gsf)	/StandardEncoding 4294330 ;
+ /Hershey-Plain-Triplex-Bold-Italic (hrpl_tbi.gsf) /StandardEncoding 4294350 ;
+ 
+ /Hershey-Script-Complex		(hrsc_c.gsf)	/StandardEncoding 4295200 ;
+ /Hershey-Script-Complex-Bold	(hrsc_cb.gsf)	/StandardEncoding 4295230 ;
+ /Hershey-Script-Complex-Oblique	(hrsc_co.gsf)   /StandardEncoding 4295210 ;
+ /Hershey-Script-Simplex		(hrsc_s.gsf)	/StandardEncoding 4295100 ;
+ /Hershey-Script-Simplex-Bold	(hrsc_sb.gsf)	/StandardEncoding 4295130 ;
+ /Hershey-Script-Simplex-Oblique	(hrsc_so.gsf)	/StandardEncoding 4295110 ;
+ 
+ /Hershey-Symbol			(hrsy_r.gsf)	/SymbolEncoding   4296000 ;


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/LICENSE.TXT
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/LICENSE.TXT:1.2.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/LICENSE.TXT	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,274 ----
+ gs - Part of the Malloc Benchmark Suite
+ -------------------------------------------------------------------------------
+ This is a *modified* version of GhostScript (gs).  The Makefile has been
+ replaced with one used for the LLVM test suite, and source files have been
+ tweaked to compile correctly on Linux.  Some unnecessary source files have been
+ removed.
+ 
+ The program may also have other modifications made by
+ ftp://ftp.cs.colorado.edu/pub/cs/misc/malloc-benchmarks.
+ 
+ All files are licensed under the following license:
+ 
+   Aladdin Free Public License
+   (Version 9, September 18, 2000)
+ 
+ Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 Aladdin Enterprises,
+ Menlo Park, California, U.S.A. All rights reserved.
+ 
+     *NOTE:* This License is not the same as any of the GNU Licenses
+     <http://www.gnu.org/copyleft/gpl.html> published by the Free
+     Software Foundation <http://www.gnu.org/>. Its terms are
+     substantially different from those of the GNU Licenses. If you are
+     familiar with the GNU Licenses, please read this license with extra
+     care. 
+ 
+ Aladdin Enterprises hereby grants to anyone the permission to apply this
+ License to their own work, as long as the entire License (including the
+ above notices and this paragraph) is copied with no changes, additions,
+ or deletions except for changing the first paragraph of Section 0 to
+ include a suitable description of the work to which the license is being
+ applied and of the person or entity that holds the copyright in the
+ work, and, if the License is being applied to a work created in a
+ country other than the United States, replacing the first paragraph of
+ Section 6 with an appropriate reference to the laws of the appropriate
+ country.
+ 
+ This License is not an Open Source license: among other things, it
+ places restrictions on distribution of the Program, specifically
+ including sale of the Program. While Aladdin Enterprises respects and
+ supports the philosophy of the Open Source Definition, and shares the
+ desire of the GNU project to keep licensed software freely
+ redistributable in both source and object form, we feel that Open Source
+ licenses unfairly prevent developers of useful software from being
+ compensated proportionately when others profit financially from their
+ work. This License attempts to ensure that those who receive,
+ redistribute, and contribute to the licensed Program according to the
+ Open Source and Free Software philosophies have the right to do so,
+ while retaining for the developer(s) of the Program the power to make
+ those who use the Program to enhance the value of commercial products
+ pay for the privilege of doing so.
+ 
+ 
+     0. Subject Matter
+ 
+ This License applies to the computer program known as "AFPL
+ Ghostscript." The "Program", below, refers to such program. The Program
+ is a copyrighted work whose copyright is held by artofcode LLC, located
+ in Benicia, California (the "Licensor"). Please note that AFPL
+ Ghostscript is neither the program known as "GNU Ghostscript" nor the
+ version of Ghostscript available for commercial licensing from Artifex
+ Software Inc.
+ 
+ A "work based on the Program" means either the Program or any derivative
+ work of the Program, as defined in the United States Copyright Act of
+ 1976, such as a translation or a modification.
+ 
+ * BY MODIFYING OR DISTRIBUTING THE PROGRAM (OR ANY WORK BASED ON THE
+ PROGRAM), YOU INDICATE YOUR ACCEPTANCE OF THIS LICENSE TO DO SO, AND ALL
+ ITS TERMS AND CONDITIONS FOR COPYING, DISTRIBUTING OR MODIFYING THE
+ PROGRAM OR WORKS BASED ON IT. NOTHING OTHER THAN THIS LICENSE GRANTS YOU
+ PERMISSION TO MODIFY OR DISTRIBUTE THE PROGRAM OR ITS DERIVATIVE WORKS.
+ THESE ACTIONS ARE PROHIBITED BY LAW. IF YOU DO NOT ACCEPT THESE TERMS
+ AND CONDITIONS, DO NOT MODIFY OR DISTRIBUTE THE PROGRAM. *
+ 
+ 
+     1. Licenses.
+ 
+ Licensor hereby grants you the following rights, provided that you
+ comply with all of the restrictions set forth in this License and
+ provided, further, that you distribute an unmodified copy of this
+ License with the Program:
+ 
+ (a)
+     You may copy and distribute literal (i.e., verbatim) copies of the
+     Program's source code as you receive it throughout the world, in any
+     medium. 
+ (b)
+     You may modify the Program, create works based on the Program and
+     distribute copies of such throughout the world, in any medium. 
+ 
+ 
+     2. Restrictions.
+ 
+ This license is subject to the following restrictions:
+ 
+ (a)
+     Distribution of the Program or any work based on the Program by a
+     commercial organization to any third party is prohibited if any
+     payment is made in connection with such distribution, whether
+     directly (as in payment for a copy of the Program) or indirectly (as
+     in payment for some service related to the Program, or payment for
+     some product or service that includes a copy of the Program "without
+     charge"; these are only examples, and not an exhaustive enumeration
+     of prohibited activities). The following methods of distribution
+     involving payment shall not in and of themselves be a violation of
+     this restriction:
+ 
+     (i)
+         Posting the Program on a public access information storage and
+         retrieval service for which a fee is received for retrieving
+         information (such as an on-line service), provided that the fee
+         is not content-dependent (i.e., the fee would be the same for
+         retrieving the same volume of information consisting of random
+         data) and that access to the service and to the Program is
+         available independent of any other product or service. An
+         example of a service that does not fall under this section is an
+         on-line service that is operated by a company and that is only
+         available to customers of that company. (This is not an
+         exhaustive enumeration.) 
+     (ii)
+         Distributing the Program on removable computer-readable media,
+         provided that the files containing the Program are reproduced
+         entirely and verbatim on such media, that all information on
+         such media be redistributable for non-commercial purposes
+         without charge, and that such media are distributed by
+         themselves (except for accompanying documentation) independent
+         of any other product or service. Examples of such media include
+         CD-ROM, magnetic tape, and optical storage media. (This is not
+         intended to be an exhaustive list.) An example of a distribution
+         that does not fall under this section is a CD-ROM included in a
+         book or magazine. (This is not an exhaustive enumeration.) 
+ 
+ (b)
+     Activities other than copying, distribution and modification of the
+     Program are not subject to this License and they are outside its
+     scope. Functional use (running) of the Program is not restricted,
+     and any output produced through the use of the Program is subject to
+     this license only if its contents constitute a work based on the
+     Program (independent of having been made by running the Program). 
+ (c)
+     You must meet all of the following conditions with respect to any
+     work that you distribute or publish that in whole or in part
+     contains or is derived from the Program or any part thereof ("the
+     Work"):
+ 
+     (i)
+         If you have modified the Program, you must cause the Work to
+         carry prominent notices stating that you have modified the
+         Program's files and the date of any change. In each source file
+         that you have modified, you must include a prominent notice that
+         you have modified the file, including your name, your e-mail
+         address (if any), and the date and purpose of the change; 
+     (ii)
+         You must cause the Work to be licensed as a whole and at no
+         charge to all third parties under the terms of this License; 
+     (iii)
+         If the Work normally reads commands interactively when run, you
+         must cause it, at each time the Work commences operation, to
+         print or display an announcement including an appropriate
+         copyright notice and a notice that there is no warranty (or
+         else, saying that you provide a warranty). Such notice must also
+         state that users may redistribute the Work only under the
+         conditions of this License and tell the user how to view the
+         copy of this License included with the Work. (Exceptions: if the
+         Program is interactive but normally prints or displays such an
+         announcement only at the request of a user, such as in an "About
+         box", the Work is required to print or display the notice only
+         under the same circumstances; if the Program itself is
+         interactive but does not normally print such an announcement,
+         the Work is not required to print an announcement.); 
+     (iv)
+         You must accompany the Work with the complete corresponding
+         machine-readable source code, delivered on a medium customarily
+         used for software interchange. The source code for a work means
+         the preferred form of the work for making modifications to it.
+         For an executable work, complete source code means all the
+         source code for all modules it contains, plus any associated
+         interface definition files, plus the scripts used to control
+         compilation and installation of the executable code. If you
+         distribute with the Work any component that is normally
+         distributed (in either source or binary form) with the major
+         components (compiler, kernel, and so on) of the operating system
+         on which the executable runs, you must also distribute the
+         source code of that component if you have it and are allowed to
+         do so; 
+     (v)
+         If you distribute any written or printed material at all with
+         the Work, such material must include either a written copy of
+         this License, or a prominent written indication that the Work is
+         covered by this License and written instructions for printing
+         and/or displaying the copy of the License on the distribution
+         medium; 
+     (vi)
+         You may not impose any further restrictions on the recipient's
+         exercise of the rights granted herein. 
+ 
+ If distribution of executable or object code is made by offering the
+ equivalent ability to copy from a designated place, then offering
+ equivalent ability to copy the source code from the same place counts as
+ distribution of the source code, even though third parties are not
+ compelled to copy the source code along with the object code.
+ 
+ 
+       3. Reservation of Rights.
+ 
+ No rights are granted to the Program except as expressly set forth
+ herein. You may not copy, modify, sublicense, or distribute the Program
+ except as expressly provided under this License. Any attempt otherwise
+ to copy, modify, sublicense or distribute the Program is void, and will
+ automatically terminate your rights under this License. However, parties
+ who have received copies, or rights, from you under this License will
+ not have their licenses terminated so long as such parties remain in
+ full compliance.
+ 
+ 
+       4. Other Restrictions.
+ 
+ If the distribution and/or use of the Program is restricted in certain
+ countries for any reason, Licensor may add an explicit geographical
+ distribution limitation excluding those countries, so that distribution
+ is permitted only in or among countries not thus excluded. In such case,
+ this License incorporates the limitation as if written in the body of
+ this License.
+ 
+ 
+       5. Limitations.
+ 
+ * THE PROGRAM IS PROVIDED TO YOU "AS IS," WITHOUT WARRANTY. THERE IS NO
+ WARRANTY FOR THE PROGRAM, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
+ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE
+ ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
+ YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+ NECESSARY SERVICING, REPAIR OR CORRECTION. *
+ 
+ * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL LICENSOR, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
+ PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS
+ OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
+ THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. *
+ 
+ 
+       6. General.
+ 
+ This License is governed by the laws of the State of California, U.S.A.,
+ excluding choice of law rules.
+ 
+ If any part of this License is found to be in conflict with the law,
+ that part shall be interpreted in its broadest meaning consistent with
+ the law, and no other parts of the License shall be affected.
+ 
+ For United States Government users, the Program is provided with
+ *RESTRICTED RIGHTS*. If you are a unit or agency of the United States
+ Government or are acquiring the Program for any such unit or agency, the
+ following apply:
+ 
+     If the unit or agency is the Department of Defense ("DOD"), the
+     Program and its documentation are classified as "commercial computer
+     software" and "commercial computer software documentation"
+     respectively and, pursuant to DFAR Section 227.7202, the Government
+     is acquiring the Program and its documentation in accordance with
+     the terms of this License. If the unit or agency is other than DOD,
+     the Program and its documentation are classified as "commercial
+     computer software" and "commercial computer software documentation"
+     respectively and, pursuant to FAR Section 12.212, the Government is
+     acquiring the Program and its documentation in accordance with the
+     terms of this License. 
+ 
+ Please see individiual files for additional copyright information.
+ 


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Makefile
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Makefile:1.2.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/Makefile	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,36 ----
+ LEVEL = ../../../../../..
+ PROG = gs
+ LIBS += -lm
+ LDFLAGS += -lm
+ CPPFLAGS += -DNOMEMOPT -DGS_LIB_DEFAULT=\"$(shell pwd):$(shell pwd)/fonts\"
+ 
+ #
+ # This is to work around a bug where having a function prototype that is
+ # static and a function defintion that is not static get generated into 2
+ # functions.
+ #
+ CPPFLAGS += -DNOPRIVATE
+ 
+ Source = gs.c gsmain.c gp_unix.c utrace.c
+ 
+ Source +=  ialloc.c idebug.c idict.c iinit.c iname.c \
+            interp.c iscan.c iutil.c stream.c \
+            zarith.c zarray.c zcontrol.c zdict.c zfile.c \
+            zgeneric.c zmath.c zmisc.c zpacked.c zrelbit.c \
+            zstack.c zstring.c ztype.c zvmem.c \
+            zchar.c zcolor.c zfont.c zdevice.c zgstate.c \
+            zht.c zmatrix.c zpaint.c zpath.c zpath2.c
+ 
+ Source += gschar.c gscolor.c gscoord.c gsdevice.c \
+           gsfile.c gsfont.c gsimage.c gsim2out.c \
+           gsline.c gsmatrix.c gsmisc.c \
+           gspaint.c gspath.c gspath2.c gsstate.c gstype1.c \
+           gxcache.c gxcolor.c gxdither.c gxdraw.c gxfill.c \
+           gxht.c gxpath.c gxpath2.c gxstroke.c \
+           gdevmem.c gdevs.c
+ 
+ #Source += gdevx.c
+ 
+ RUN_OPTIONS = -DNODISPLAY $(BUILD_SRC_DIR)/INPUT/large.ps
+ 
+ include ../../../Makefile.multisrc


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/alloc.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/alloc.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/alloc.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,47 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* alloc.h */
+ /* Interface to GhostScript memory allocator */
+ 
+ /* Ordinary allocator interface */
+ void	alloc_init(P3(proc_alloc_t, proc_free_t, uint));
+ char	*alloc(P3(uint num_elts, uint elt_size, char *client_name));
+ void	alloc_free(P4(char *data, uint num_elts, uint elt_size, char *client_name));
+ void	alloc_status(P2(long *, long *));
+ 
+ /* Dynamic allocation */
+ /* Note that these procedures use byte * rather than char * */
+ /****** SOME OF THESE PROCEDURES ARE OBSOLETE. ******/
+ #define alloc_dynamic(ne, esize, cname) (byte *)(alloc(ne, esize, cname))
+ byte	*alloc_grow(P5(byte *data, uint old_num, uint new_num, uint elt_size, char *client_name));
+ byte	*alloc_shrink(P5(byte *data, uint old_num, uint new_num, uint elt_size, char *client_name));
+ 
+ /* Store checking / change saving */
+ /****** THIS INTERFACE HAS NO EFFECT YET.  DON'T USE IT. ******/
+ int alloc_save_change(P2(char *, uint));	/* <0 if can't alloc */
+ 
+ /* Save and restore state */
+ /****** THIS INTERFACE IS NOT IMPLEMENTED YET.  DON'T USE IT. ******/
+ typedef struct alloc_save_s alloc_save;
+ alloc_save *alloc_save_state(P0());	/* 0 if can't alloc save block */
+ int alloc_save_level(P0());
+ int alloc_is_since_save(P2(char *, alloc_save *));
+ int alloc_restore_state_check(P1(alloc_save *));  /* 0 if OK, <0 if not */
+ void alloc_restore_state(P1(alloc_save *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/alphabet.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/alphabet.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/alphabet.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,13 ----
+ (Times-Roman) findfont 10 scalefont setfont
+ currentfont 4 scalefont setfont
+ 0 500 moveto
+ gsave ( !"#$%&'\(\)*+,-./) show grestore
+ 0 -60 rmoveto
+ gsave (001122334456789<=>:;?@) show grestore
+ 0 -60 rmoveto
+ gsave (ABCDEFGHIJKLMNOPQRSTUVWXYZ) show grestore
+ 0 -60 rmoveto
+ gsave ([[\\\\]]^^__`{|}~) show grestore
+ 0 -60 rmoveto
+ gsave (abcdefghijklmnopqrstuvwxyz) show grestore
+ showpage


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ansi2knr.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ansi2knr.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ansi2knr.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,264 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* ansi2knr.c */
+ /* Convert ANSI function declarations to K&R syntax */
+ #include <stdio.h>
+ #include <ctype.h>
+ #include "string_.h"
+ #include "malloc_.h"
+ 
+ /* Usage:
+ 	ansi2knr input_file output_file
+  * If no output_file is supplied, output goes to stdout.
+  * There are no error messages.
+  *
+  * ansi2knr recognizes functions by seeing a non-keyword identifier
+  * at the left margin, followed by a left parenthesis,
+  * with a right parenthesis as the last character on the line.
+  * It will recognize a multi-line header if the last character
+  * on each line but the last is a left parenthesis or comma.
+  * These algorithms ignore whitespace and comments, except that
+  * the function name must be the first thing on the line.
+  * The following constructs will confuse it:
+ 	- Any other construct that starts at the left margin and
+ 	    follows the above syntax (such as a macro or function call).
+ 	- Macros that tinker with the syntax of the function header.
+  */
+ 
+ /* Scanning macros */
+ #define isidchar(ch) (isalnum(ch) || (ch) == '_')
+ 
+ main(argc, argv)
+     int argc;
+     char *argv[];
+ {	FILE *in, *out;
+ #define bufsize 500			/* arbitrary size */
+ 	char buf[bufsize];
+ 	char *line;
+ 	switch ( argc )
+ 	   {
+ 	default:
+ 		printf("Usage: ansi2knr input_file [output_file]\n");
+ 		exit(0);
+ 	case 2:
+ 		out = stdout; break;
+ 	case 3:
+ 		out = fopen(argv[2], "w");
+ 		if ( out == NULL )
+ 		   {	fprintf(stderr, "Cannot open %s\n", argv[2]);
+ 			exit(1);
+ 		   }
+ 	   }
+ 	in = fopen(argv[1], "r");
+ 	if ( in == NULL )
+ 	   {	fprintf(stderr, "Cannot open %s\n", argv[1]);
+ 		exit(1);
+ 	   }
+ 	fprintf(out, "#line 1 \"%s\"\n", argv[1]);
+ 	line = buf;
+ 	while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
+ 	   {	switch ( test1(buf) )
+ 		   {
+ 		case 1:			/* a function */
+ 			convert1(buf, out);
+ 			break;
+ 		case -1:		/* maybe the start of a function */
+ 			line = buf + strlen(buf);
+ 			continue;
+ 		default:		/* not a function */
+ 			fputs(buf, out);
+ 			break;
+ 		   }
+ 		line = buf;
+ 	   }
+ 	if ( line != buf ) fputs(buf, out);
+ 	fclose(out);
+ 	fclose(in);
+ 	return 0;
+ }
+ 
+ /* Skip over space and comments, in either direction. */
+ char *
+ skipspace(p, dir)
+     register char *p;
+     register int dir;			/* 1 for forward, -1 for backward */
+ {	for ( ; ; )
+ 	   {	while ( isspace(*p) ) p += dir;
+ 		if ( !(*p == '/' && p[dir] == '*') ) break;
+ 		p += dir;  p += dir;
+ 		while ( !(*p == '*' && p[dir] == '/') )
+ 		   {	if ( *p == 0 ) return p;	/* multi-line comment?? */
+ 			p += dir;
+ 		   }
+ 		p += dir;  p += dir;
+ 	   }
+ 	return p;
+ }
+ 
+ /*
+  * Test whether the string in buf is a function definition.
+  * The string may contain and/or end with a newline.
+  * Return as follows:
+  *	0 - definitely not a function definition;
+  *	1 - definitely a function definition;
+  *	-1 - may be the beginning of a function definition,
+  *		append another line and look again.
+  */
+ test1(buf)
+     char *buf;
+ {	register char *p = buf;
+ 	char *bend;
+ 	char *endfn;
+ 	int contin;
+ 	if ( !isalpha(*p) )
+ 		return 0;		/* no name at left margin */
+ 	bend = skipspace(buf + strlen(buf) - 1, -1);
+ 	switch ( *bend )
+ 	   {
+ 	case ')': contin = 1; break;
+ 	case '(':
+ 	case ',': contin = -1; break;
+ 	default: return 0;		/* not a function */
+ 	   }
+ 	while ( isidchar(*p) ) p++;
+ 	endfn = p;
+ 	p = skipspace(p, 1);
+ 	if ( *p++ != '(' )
+ 		return 0;		/* not a function */
+ 	p = skipspace(p, 1);
+ 	if ( *p == ')' )
+ 		return 0;		/* no parameters */
+ 	/* Check that the apparent function name isn't a keyword. */
+ 	/* We only need to check for keywords that could be followed */
+ 	/* by a left parenthesis (which, unfortunately, is most of them). */
+ 	   {	static char *words[] =
+ 		   {	"asm", "auto", "case", "char", "const", "double",
+ 			"extern", "float", "for", "if", "int", "long",
+ 			"register", "return", "short", "signed", "sizeof",
+ 			"static", "switch", "typedef", "unsigned",
+ 			"void", "volatile", "while", 0
+ 		   };
+ 		char **key = words;
+ 		char *kp;
+ 		int len = endfn - buf;
+ 		while ( (kp = *key) != 0 )
+ 		   {	if ( strlen(kp) == len && !strncmp(kp, buf, len) )
+ 				return 0;	/* name is a keyword */
+ 			key++;
+ 		   }
+ 	   }
+ 	return contin;
+ }
+ 
+ convert1(buf, out)
+     char *buf;
+     FILE *out;
+ {	char *endfn = strchr(buf, '(') + 1;
+ 	register char *p;
+ 	char **breaks;
+ 	unsigned num_breaks = 2;	/* for testing */
+ 	char **btop;
+ 	char **bp;
+ 	char **ap;
+ top:	p = endfn;
+ 	breaks = (char **)malloc(sizeof(char **) * num_breaks * 2);
+ 	if ( breaks == 0 )
+ 	   {	/* Couldn't allocate break table, give up */
+ 		fprintf(stderr, "Unable to allocate break table!\n");
+ 		fputs(buf, out);
+ 		return -1;
+ 	   }
+ 	btop = breaks + num_breaks * 2 - 2;
+ 	bp = breaks;
+ 	/* Parse the argument list */
+ 	do
+ 	   {	int level = 0;
+ 		char *end = NULL;
+ 		if ( bp >= btop )
+ 		   {	/* Filled up break table. */
+ 			/* Allocate a bigger one and start over. */
+ 			free((char *)breaks);
+ 			num_breaks <<= 1;
+ 			goto top;
+ 		   }
+ 		*bp++ = p;
+ 		/* Find the end of the argument */
+ 		for ( ; end == NULL; p++ )
+ 		   {	switch(*p)
+ 			   {
+ 			case ',': if ( !level ) end = p; break;
+ 			case '(': level++; break;
+ 			case ')': if ( --level < 0 ) end = p; break;
+ 			case '/': p = skipspace(p, 1) - 1; break;
+ 			default: ;
+ 			   }
+ 		   }
+ 		p--;			/* back up over terminator */
+ 		/* Find the name being declared. */
+ 		/* This is complicated because of procedure and */
+ 		/* array modifiers. */
+ 		for ( ; ; )
+ 		   {	p = skipspace(p - 1, -1);
+ 			switch ( *p )
+ 			   {
+ 			case ']':	/* skip array dimension(s) */
+ 			case ')':	/* skip procedure args OR name */
+ 			   {	int level = 1;
+ 				while ( level )
+ 				 switch ( *--p )
+ 				   {
+ 				case ']': case ')': level++; break;
+ 				case '[': case '(': level--; break;
+ 				case '/': p = skipspace(p, -1) + 1; break;
+ 				default: ;
+ 				   }
+ 			   }
+ 				if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
+ 				   {	/* We found the name being declared */
+ 					while ( !isalpha(*p) )
+ 						p = skipspace(p, 1) + 1;
+ 					goto found;
+ 				   }
+ 				break;
+ 			default: goto found;
+ 			   }
+ 		   }
+ found:		while ( isidchar(*p) ) p--;
+ 		*bp++ = p+1;
+ 		p = end;
+ 	   }
+ 	while ( *p++ == ',' );
+ 	*bp = p;
+ 	/* Put out the function name */
+ 	p = buf;
+ 	while ( p != endfn ) putc(*p, out), p++;
+ 	/* Put out the declaration */
+ 	for ( ap = breaks+1; ap < bp; ap += 2 )
+ 	   {	p = *ap;
+ 		while ( isidchar(*p) ) putc(*p, out), p++;
+ 		if ( ap < bp - 1 ) fputs(", ", out);
+ 	   }
+ 	fputs(")  ", out);
+ 	/* Put out the argument declarations */
+ 	for ( ap = breaks+2; ap <= bp; ap += 2 ) (*ap)[-1] = ';';
+ 	fputs(breaks[0], out);
+ 	free((char *)breaks);
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/arch.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/arch.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/arch.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,2 ----
+ #define big_endian 0
+ #define ints_are_short 0


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/bdftops.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/bdftops.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/bdftops.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,466 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % bdftops.ps
+ % Convert a BDF file to a Ghostscript font.
+ 
+ % Ghostscript fonts are in the same format as Adobe Type 1 fonts,
+ % except that they do not use eexec encryption.
+ % See gfonts.ps for more information.
+ 
+ /envBDF 75 dict def
+ envBDF begin
+ 
+ % Define whether to write out the CharStrings in binary or in hex.
+ % Binary takes less space on the file, but isn't guaranteed portable.
+    /binary false def
+ 
+ % Define lenIV (the number of initial random bytes in the encoded outlines).
+ % This should be zero, but we set it to 4 for compatibility with PostScript.
+    /lenIV 4 def
+ 
+ % Define the character sequences used to fill in some undefined entries
+ % in the standard encoding.
+    mark
+      (fraction) [/slash]
+      (quotesingle) [/quoteright]
+      (quotedblleft) [/quotedbl]
+      (guillemotleft) [/less /less]
+      (guilsinglleft) [/less]
+      (guilsinglright) [/greater]
+      (fi) [/f /i]
+      (fl) [/f /l]
+      (endash) [/hyphen /hyphen]
+      (periodcentered) [/asterisk]
+      (bullet) [/asterisk]
+      (quotesinglbase) [/quoteright]
+      (quotedblbase) [/quotedbl]
+      (quotedblright) [/quotedbl]
+      (guillemotright) [/greater /greater]
+      (ellipsis) [/period /period /period]
+      (emdash) [/hyphen /hyphen /hyphen]
+      (AE) [/A /E]
+      (OE) [/O /E]
+      (ae) [/a /e]
+      (oe) [/o /e]
+      (germandbls) [/s /s]
+    counttomark 2 idiv dup dict begin
+    { def } repeat
+    pop currentdict end /composites exch def
+ % Note the characters that must be defined as subroutines.
+    96 dict begin
+      0 composites
+       { exch pop
+          { dup currentdict exch known
+ 	    { pop }
+ 	    { 1 index def 1 add }
+ 	   ifelse
+ 	 }
+ 	forall
+       }
+      forall
+      currentdict
+    end /subrchars exch def
+ 
+ % Load the utility procedures.
+    (fcutils.ps) run
+ 
+ % Define the Type 1 opcodes we care about.
+    /c_callsubr 10 def
+    /c_return 11 def
+    /c_escape 12 def
+      /ce_sbw 7 def
+      /ce_setcurrentpoint 33 def
+    /c_hsbw 13 def
+    /c_endchar 14 def
+ 
+ % Define a buffer for reading the BDF file.
+    /buffer 400 string def
+ 
+ % Read a line from the BDF file into the buffer.
+ % Define /keyword as the first word on the line.
+ % Define /args as the remainder of the line.
+ % If the keyword is equal to commentword, skip the line.
+ % (If commentword is equal to a space, never skip.)
+    /commentword ( ) def
+    /nextline
+     { bdfile buffer readline not
+        { (Premature EOF\n) print stop } if
+       ( ) search
+        { /keyword exch def pop }
+        { /keyword exch def () }
+       ifelse
+       /args exch def
+       keyword commentword eq { nextline } if
+     } bind def
+ 
+ % Get an integer argument from args.
+    /iarg		% iarg -> int
+     { args ( ) search
+        { cvi exch pop exch }
+        { cvi () }
+       ifelse  /args exch def
+     } bind def
+ 
+ % Convert the remainder of args into a string.
+    /remarg		% remarg -> string
+     { args copystring
+     } bind def
+ 
+ % Get a string argument that occupies the remainder of args.
+    /sarg		% sarg -> string
+     { args (") anchorsearch
+        { pop /args exch def } { pop } ifelse
+       args args length 1 sub get (") 0 get eq
+        { args 0 args length 1 sub getinterval /args exch def } if
+       args copystring
+     } bind def
+ 
+ % Check that the keyword is the expected one.
+    /checkline		% (EXPECTED-KEYWORD) checkline ->
+     { dup keyword ne
+        { (Expected ) print =
+          (Line=) print keyword print ( ) print args print (\n) print stop
+        } if
+       pop
+     } bind def
+ 
+ % Read a line and check its keyword.
+    /getline		% (EXPECTED-KEYWORD) getline ->
+     { nextline checkline
+     } bind def
+ 
+ % Define some utilities for writing the output file.
+    /wtstring 100 string def
+    /ws {psfile exch writestring} bind def
+    /wl {ws (\n) ws} bind def
+    /wt {wtstring cvs ws ( ) ws} bind def
+    /wo {psfile exch write==only ( ) ws} bind def
+ 
+ % Encrypt and write a hex string for Subrs or CharStrings.
+ % Note that this smashes the string being written.
+    /wx
+     { 4330 exch dup type1encrypt exch pop
+       binary
+        { dup length wo (_R ) ws ws
+        }
+        { (<) ws
+          % Some systems choke on very long lines, so
+ 	 % we break up the hexstring into chunks of 50 characters.
+ 	  { dup length 25 le {exit} if
+ 	    dup 0 25 getinterval psfile exch writehexstring (\n) ws
+ 	    dup length 25 sub 25 exch getinterval
+ 	  } loop
+ 	 psfile exch writehexstring (>) ws
+        } ifelse
+     } bind def
+ % Write a character definition.
+    /wcdef
+     { (/) ws exch ws ( ) ws wx ( _D) wl
+     } bind def
+ 
+ % The main program.
+    /bdftops		% infilename outfilename mapfilename bdftops ->
+     { /mapname exch def
+       /psname exch def
+       /bdfname exch def
+       gsave		% so we can set the CTM to the font matrix
+ 
+ %  Open the input files.  We don't open the output file until
+ %  we've done a minimal validity check on the input.
+       bdfname (r) file /bdfile exch def
+       mapname findlibfile not
+         { (bdftops: Can't find map file ) print print (!\n) print stop }
+       if
+       /mapfile exch def
+ 
+ %  Check for the STARTFONT.
+       (STARTFONT) getline
+       args (2.1) ne { (Not version 2.1\n) print stop } if
+ 
+ %  Look up the output file name in the font map.
+       mapfile psname fontmapfind
+       /uniqueID exch def
+       /encoding exch def
+       /fontname exch def
+ 
+ %  Now open the output file.
+       psname (w) file /psfile exch def
+ 
+ %  Put out a header compatible with the Adobe "standard".
+       (%!FontType1-1.0: ) ws fontname wt (000.000) wl
+ 
+ %  Copy the leading comments, up to FONT.
+       (% This is a font description converted from ) ws
+         bdfname ws (.) wl
+       true
+       { nextline
+         keyword (COMMENT) ne {exit} if
+ 	{ (% Here are the leading comments from the BDF file:\n%) wl
+ 	} if false
+ 	(%) ws remarg wl
+       } loop pop
+       /commentword (COMMENT) def	% do skip comments from now on
+ 
+ %  Read and process the FONT, SIZE, and FONTBOUNDINGBOX.
+       % If we cared about FONT, we'd use it here.  If the BDF files
+       % from MIT had PostScript names rather than X names, we would
+       % care; but what's there is unusable, so we discard FONT.
+       (FONT) checkline
+       (SIZE) getline
+         /pointsize iarg def   /xres iarg def   /yres iarg def
+       (FONTBOUNDINGBOX) getline
+         /fbbw iarg def   /fbbh iarg def   /fbbxo iarg def   /fbbyo iarg def
+ 	/fraster fbbw 7 add 8 idiv def
+       nextline
+ 
+ % Allocate the buffers for the bitmap and the outline,
+ % according to the font bounding box.
+       /bits fraster fbbh mul 200 max 65535 min string def
+       /outline bits length 6 mul 65535 min string def
+ 
+ %  The Type 1 font machinery really only work with a 1000 unit
+ %  character coordinate system.  Set this up here.
+ 	% Compute the factor to make the X entry in the FontMatrix
+ 	% come out at exactly 0.001.
+ 	/fontscale   72 pointsize div xres div 1000 mul   def
+ 
+ %  Read and process the properties.  We only care about a few of them.
+       /pcount 0 def
+       keyword (STARTPROPERTIES) eq
+        { iarg
+           { nextline
+ 	    keyword (COPYRIGHT) eq
+ 	    keyword (FULL_NAME) eq or
+ 	    keyword (FAMILY_NAME) eq or
+ 	    keyword (WEIGHT_NAME) eq or
+ 	     { keyword cvn sarg def
+ 	       /pcount pcount 1 add def
+ 	     } if
+ 	  } repeat
+          (ENDPROPERTIES) getline
+ 	 nextline
+        } if
+ 
+ %  Compute and set the eventual FontMatrix.
+       [ 0.001 0 0 0.001 xres mul yres div 0 0 ] setmatrix
+ 
+ %  Read and process the header for the bitmaps.
+       (CHARS) checkline
+         /ccount iarg def
+ 
+ %  Initialize the character subroutine table.
+       /subrs subrchars length array def
+       /subrcount 0 def
+       /charstrings ccount composites length add dict def
+ 
+ %  Read and process the bitmap data.  This reads the remainder of the file.
+       ccount -1 1
+        { (STARTCHAR) getline
+            /charname remarg def
+ 	 (/) print charname bits cvs print
+ 	   10 mod 1 eq { (\n) print flush } if
+ 	 (ENCODING) getline		% Ignore, assume StandardEncoding
+ 	 (SWIDTH) getline
+ 	   /swx iarg pointsize mul 1000 div xres mul 72 div def
+ 	   /swy iarg pointsize mul 1000 div xres mul 72 div def
+ 	 (DWIDTH) getline		% Ignore, use SWIDTH instead
+ 	 (BBX) getline
+ 	   /bbw iarg def  /bbh iarg def  /bbox iarg def  /bboy iarg def
+ 	 nextline
+ 	 keyword (ATTRIBUTES) eq
+ 	  { nextline
+ 	  } if
+ 	 (BITMAP) checkline
+ 
+ %  Read the bits for this character.
+ 	 bbw 7 add 8 idiv /raster exch def
+ % The bitmap handed to type1imagepath must have the correct height,
+ % because type1imagepath uses this to compute the scale factor,
+ % so we have to clear the unused parts of it.
+ 	 bits dup 0 1 raster fbbh mul 1 sub
+ 	  { 0 put dup } for
+ 	 pop pop
+ 	 raster fbbh bbh sub mul   raster   raster fbbh 1 sub mul
+ 	  { bits exch raster getinterval
+ 	    bdfile buffer readline not
+ 	     { (EOF in bitmap\n) print stop } if
+ 	    exch readhexstring pop pop pop
+ 	  } for
+ 	 (ENDCHAR) getline
+ 
+ %  Compute the font entry, converting the bitmap to an outline.
+ 	 bits 0 raster fbbh mul getinterval	% the bitmap image
+ 	 bbw   fbbh				% bitmap width & height
+ 	 swx   swy				% width x & y
+ 	 bbox neg   bboy neg			% origin x & y
+ 	 	% Account for lenIV when converting the outline.
+ 	 outline  lenIV  outline length lenIV sub  getinterval
+ 	 type1imagepath
+ 	 length lenIV add
+ 	 outline exch 0 exch getinterval
+ % Check whether this character must be a subroutine.
+ % If so, strip off the initial [h]sbw, replace the endchar by a return,
+ % and put the charstring in the Subrs array.
+ 	 subrchars charname known
+ 	  { /charstr exch def lenIV
+ 	     { dup charstr exch get
+ 	       dup c_hsbw eq { pop exit } if
+ 	       dup c_escape eq
+ 	        { pop 1 add dup charstr exch get
+ 		  ce_sbw eq { exit } if
+ 		  (Invalid CharString!\n) print stop
+ 		} if
+ 	       dup 247 lt
+ 	        { pop 1 }
+ 		{ 255 eq { 5 } { 2 } ifelse }
+ 	       ifelse add
+ 	     } loop
+ 	    1 add /charend exch def
+ 	    charstr charstr length 1 sub c_return put
+ 	    subrs   subrchars charname get
+ 	      charstr   charend lenIV sub   dup charstr length exch sub
+ 	        getinterval copystring
+ 	    put
+ 	    charstr charend subrchars charname get 139 add put
+ 	    charstr charend 1 add c_callsubr put
+ 	    charstr charend 2 add c_endchar put
+ 	    /subrcount subrcount 1 add def
+ 	    charstr 0 charend 3 add getinterval
+ 	  }
+ 	 if
+ 	 copystring
+ 	 charname exch charstrings 3 1 roll put
+        } for
+       (ENDFONT) getline
+ 
+ %  Synthesize missing characters out of available ones.
+ %  For fixed-width fonts, only do this in the 1-for-1 case.
+       composites
+        { 1 index charstrings exch known
+           { pop pop }
+ 	  { dup true		%%%%%% fixedwidth
+ 	     { dup length 1 eq }
+ 	     { true }
+ 	    ifelse
+ 	    exch { charstrings exch known and } forall
+ 	     { (/) print 1 index bits cvs print
+ 	       0 get charstrings exch get copystring
+ 	       charstrings 3 1 roll put
+ 	     }
+ 	     { pop pop }
+ 	    ifelse
+ 	  }
+ 	 ifelse
+        }
+       forall flush
+ 
+ %  Write out the creation of the font dictionary and FontInfo.
+       pcount 0 gt
+        { (11 dict begin) wl
+ 	 (/FontInfo ) ws pcount wo (dict dup begin) wl
+ 	 currentdict /COPYRIGHT known
+ 	  { (/Notice ) ws COPYRIGHT wo (readonly def) wl } if
+ 	 currentdict /FULL_NAME known
+ 	  { (/FullName ) ws FULL_NAME wo (readonly def) wl } if
+ 	 currentdict /FAMILY_NAME known
+ 	  { (/FamilyName ) ws FAMILY_NAME wo (readonly def) wl } if
+ 	 currentdict /WEIGHT_NAME known
+ 	  { (/Weight ) ws WEIGHT_NAME wo (readonly def) wl } if
+ 	 (end readonly def) wl
+        }
+        { (10 dict begin) wl
+        }
+       ifelse
+ 
+ %  Write out the other fixed entries in the font dictionary.
+       (/FontName ) ws fontname wo (def) wl
+       (/PaintType 0 def) wl
+       (/FontType 1 def) wl
+       (/FontMatrix [ ) ws
+         matrix currentmatrix {wt} forall
+ 	(] readonly def) wl
+       (/Encoding ) ws encoding wt (def) wl
+       fontscale
+       (/FontBBox { ) ws
+ 	dup fbbxo mul wt   dup fbbyo mul wt
+ 	dup fbbxo fbbw add mul wt   dup fbbyo fbbh add mul wt
+ 	(} readonly def) wl
+       pop
+       (/UniqueID ) ws uniqueID wo (def) wl	% uniqueID is an integer
+       (currentdict end) wl
+ 
+ %  The rest of the file could be in eexec form, but we don't see any point
+ %  in doing this, because we aren't attempting to conceal it from anyone.
+ 
+ %  Create and initialize the Private dictionary.
+       (dup /Private 9 dict dup begin) wl
+       (/_D {readonly def} readonly def) wl
+       (/_P {readonly put} readonly def) wl
+       (/_R {string currentfile exch readstring pop} readonly def) wl
+       (/BlueValues [] def) wl
+       (/lenIV ) ws lenIV wo (def) wl
+       (/MinFeature {16 16} def) wl
+       (/password 5839 def) wl
+       (/UniqueID ) ws uniqueID wo (def) wl
+ 
+ %  Write the Subrs entries, if any.
+       subrcount 0 gt
+        { (/Subrs ) ws subrs length wo (array) wl
+          0 1 subrs length 1 sub
+ 	  { dup subrs exch get dup null ne
+ 	     { (dup ) ws exch wo wx ( _P) wl }
+ 	     { pop pop }
+ 	    ifelse
+ 	  } for
+          (_D) wl
+        }
+       if
+ 
+ %  Write all the CharStrings entries.
+       (2 index /CharStrings ) ws charstrings length 1 add wo
+         (dict dup begin) wl
+       charstrings { wcdef } forall
+ 
+ %  Write the CharStrings entry for .notdef.
+       outline lenIV <8b8b0d0e> putinterval	% 0 0 hsbw endchar
+       (.notdef) outline 0 lenIV 4 add getinterval wcdef
+ 
+ %  Wrap up the private part of the font.
+       (end) wl		% CharStrings
+       (end) wl		% Private
+       (readonly put) wl		% CharStrings
+       (readonly put) wl		% Private
+ 
+ %  Write the other standard entries in the font dictionary.
+       (dup begin) wl
+       (end) wl
+ 
+ %  Terminate the output, and close the files.
+       (dup /FontName get exch definefont pop) wl
+       bdfile closefile
+       psfile closefile
+       grestore
+     } bind def
+ end
+ 
+ % Enter the main program in the current dictionary.
+ /bdftops
+  { envBDF begin   (Fontmap) bdftops end
+  } bind def


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/cframe_.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/cframe_.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/cframe_.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,45 ----
+ /*
+  * LLVM - http://llvm.cs.uiuc.edu
+  *
+  * Changes:
+  *  1) 2/18/2004
+  *     Modified cstack_top_frame() macro for UNIX so that it returns an
+  *     incorrect but correctly typed return value.
+  */
+ 
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* cframe_.h */
+ /* System-dependent definitions for C stack frame format */
+ 
+ /* cstack_top_frame(a_jmp_buf) returns a pointer which can be */
+ /* handed to stack_next_frame to give the top frame on a stack. */
+ /* cstack_next_frame(a_frame_ptr) gives the next frame pointer. */
+ #ifdef VMS
+ #  define cstack_top_frame(buf)		/* buf is a jmp_buf */\
+ 	(char *)&buf
+ #  define cstack_next_frame(fptr)\
+ 	*((char **)(fptr) + 12)
+ #else					/* generic Unix */
+ #  define cstack_top_frame(buf)		/* buf is a jmp_buf */\
+ 	(char *)&(buf[0])
+ #  define cstack_next_frame(fptr)\
+ 	*((char **)(fptr) + 3)
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/cheq.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/cheq.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/cheq.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,945 ----
+ %!PS-AdobeFont-1.0: Cheq 001.000
+ %%CreationDate: Wed May 24 10:41:05 1989
+ %%VMusage: 23317 29750
+ %% Adobe is licensing this font software "Cheq" to you royalty-free for your 
+ %% use and not for sale to others.  This font software is provided as is and 
+ %% Adobe disclaims all warranties, including merchantability and fitness for 
+ %% a particular purpose. Any and all copies of this software must contain 
+ %% this notice intact.  Design (D) 1989 John S. Renner, Adobe Systems, 
+ %% Inc.  
+ 11 dict begin
+ /FontInfo 10 dict dup begin
+ /version (001.000) readonly def
+ /Notice (Copyright (c) 1989 Adobe Systems Incorporated.  All rights reserved.) readonly def
+ /Copyright ( Adobe is licensing this font software "Cheq" to you
+  royalty-free for your use and not for sale to others.  This
+  font software is provided as is and Adobe disclaims all
+  warranties, including merchantability and fitness for a
+  particular purpose.
+  Any and all copies of this software must contain this notice
+  intact.
+ 
+  Design (D) 1989 John S. Renner, Adobe Systems, Inc.
+  ) readonly def
+ /FullName (Cheq) readonly def
+ /FamilyName (Cheq) readonly def
+ /Weight (Medium) readonly def
+ /ItalicAngle 0 def
+ /isFixedPitch true def
+ /UnderlinePosition -100 def
+ /UnderlineThickness 50 def
+ end readonly def
+ /FontName /Cheq def
+ /Encoding 256 array
+ 0 1 255 {1 index exch /.notdef put} for
+                 %% Encoding below refers to Macintosh keyboard.
+                 %% You may want to re-encode for your needs.
+                 %%   some entries are an attempt to accommodate
+                 %%   the German/Russian spelling mnemonics,
+                 %%   except for "B" which remains for Bishop,
+                 %%   and not for Bauer (the pawn).
+ dup 120 /BSquare put    % x
+ dup 32 /space put       % space
+ dup 66 /BBishop put     % shift-b
+ dup 68 /BQueen put      % shift-d
+ dup 75 /BKing put       % shift-k
+ dup 76 /BBishop put     % shift-l
+ dup 78 /BKnight put     % shift-n
+ dup 80 /BPawn put       % shift-p
+ dup 81 /BQueen put      % shift-q
+ dup 82 /BRook put       % shift-r
+ dup 83 /BKnight put     % shift-s
+ dup 84 /BRook put       % shift-t
+ dup 98 /WBishop put     % b
+ dup 100 /WQueen put     % d
+ dup 107 /WKing put      % k
+ dup 108 /WBishop put    % l
+ dup 110 /WKnight put    % n
+ dup 112 /WPawn put      % p
+ dup 113 /WQueen put     % q
+ dup 114 /WRook put      % r
+ dup 115 /WKnight put    % s
+ dup 116 /WRook put      % t
+ dup 245 /BBishopOnBlack put     % shift-option-b
+ dup 235 /BQueenOnBlack put      % shift-option-d
+ dup 240 /BKingOnBlack put       % shift-option-k
+ dup 241 /BBishopOnBlack put     % shift-option-l
+ dup 246 /BKnightOnBlack put     % shift-option-n
+ dup 184 /BPawnOnBlack put       % shift-option-p
+ dup 206 /BQueenOnBlack put      % shift-option-q
+ dup 229 /BRookOnBlack put       % shift-option-r
+ dup 234 /BKnightOnBlack put     % shift-option-s
+ dup 230 /BRookOnBlack put       % shift-option-t
+ dup 186 /WBishopOnBlack put     % option-b
+ dup 182 /WQueenOnBlack put      % option-d
+ dup 251 /WKingOnBlack put       % option-k
+ dup 194 /WBishopOnBlack put     % option-l
+ dup 181 /WKnightOnBlack put     % option-m
+ dup 185 /WPawnOnBlack put       % option-p
+ dup 207 /WQueenOnBlack put      % option-q
+ dup 168 /WRookOnBlack put       % option-r
+ dup 167 /WKnightOnBlack put     % option-s
+ dup 160 /WRookOnBlack put       % option-t
+ dup 47  /left put               % slash
+ dup 92  /right put              % backslash
+ dup 95  /top put                % underscore
+ dup 45  /bottom put             % hyphen/minus
+ def
+ /PaintType 0 def
+ /FontType 1 def
+ /FontMatrix [0.001 0 0 0.001 0 0] readonly def
+ /UniqueID 23368 def
+ /FontBBox{-50 -150 1050 950}readonly def
+ currentdict end
+ currentfile eexec
+ 06ba7b33fcf5ae0f0b258ced9b9688e8a87f93db8efdacd17ec2401f2e7dac03
+ bf5515b9e42d78a8037b743d280529fc7630d62bd4c75492c78fd28b2c2aba67
+ 9cc93d471b097ea30e29f7c89735dd88b4c3e9cb32e14ef50432a6ab37870a14
+ af81e471af496fa0e292e1e8168461acf6191017048deb62dd5fd7c784ba88aa
+ a921563b3143218981a38441910687a3202a5135e58ce2ecdf9c2d521c6df45b
+ aab245f99427574c148904e2a60104e97e6b05bfd9be9a086246a797a03dab25
+ 948bf8e7996f70ffd6471eef9faeada641e245d63c4964a38500b4754836131f
+ 86fc61b1de2e0b53ad441b1446fedcd2c533d44c69631a545c98d4c552e5f0b2
+ 27b40aa0443f7f88e1d6e5bd206ed737fffbe94e8bf001e3481cca5a45735979
+ e41ea918a7c0ca5e26ab946df29d27b5ec2671d8e0d7d31b114c29e48ccd3e8d
+ 7bc69903aeb804fc25aa2dda700de6ede9fc025f0db1aa478b53fa21ed455ec1
+ 98c7a20020a077a67b743f563cc4c4e59c2d8253bc8c3ea62d4a870f53b2515c
+ 8b63b857664ab5f0ad71eb89d34decf825e81c10c3a7e676ddddd182cd6ff6da
+ 631d2051ccb078bea7b2ffab7dc23ca08b337ecc454a8f743a71512149244b00
+ 72670c8978396cefa735113500de6cec50ab91084340db0ba24a01672dc3a3a5
+ e860df42ef02350778cb8e77b5533227aa2f79cbed414f760d92cd071fb5db1b
+ 669ef0196c6e95a530c8112a8a3ac716fb913a8a1332a590b46d2e267b97b1be
+ 0e0ba7e4e8c90f1d37b8c1836fbdc93121c5758a31d3ef4650adc41f253ba07a
+ ab0dc45d90e8936672b1a47307903dbcbf8e15b70c862d25c57c6e2727f6674b
+ c47ff5eae01e0fe7d182742ac456f986d0eb460f4f7fc2693e37899a04b3684e
+ fd57e9b235b339017c36b1ef22f9659a0c7743e663e831be7faa602cff221701
+ 85b13653ad5269a88da74ed803beb08bc40f0bfcfd7cbc49531756b41171c22d
+ aae8ff9a454f9d68df7f4b23409634346d8e26ac2109391398ed37705e2e063a
+ 065a871b78b2b0d4c74b6e4e42877a4450b1974474dc19437e9e1d8a6ff2a374
+ 0e399857e4f67056577a19f7e26542fae9a75f1e07ed1869c504625d701fdbea
+ 392b4b2e83ea3c179991f5dded833a74df4d277fdd119f69e8209be9394473f3
+ 6d6383a762a518d04812f29ec4bb71f451882e9f89a52114215b31b225db3da5
+ eb453e7f4f40861963d6412855582128dcd1677d94df95442aba41d3cdf32f0c
+ f1a6eace61e491f64152a57410902642145aca0104350bd8b19441072da5e142
+ 758ef9a1f6c6e0fe47335113843443a07c68606510af206677e764dc0e319ff0
+ 93d0fef01274205b370422182765a40ac3d23f4c326a732282c455a0eb737ac4
+ 11673164b7b35e42cb4be5dd4be49958b2c61a5bcc5a332b917d5525c0680a14
+ b7c700339112eb47015e80cadfd5a6484af9201f57f6e15b70c0964ea5365173
+ ba78aec0d5a7414a4636090b9eef9d71fa424c47fb191bfaeea8d1d29beebbe2
+ fc78ea4a1edb5c325bba25851e72146eab86a69e57b6a4a31bc7a4cad9f8910d
+ 3394c3a92e5189b3447df2fc1a5add98fb8e4ad616685beb6778fe7d444b5ef3
+ f4847419c0013e6689e40860aaf46d77f172b86be22630674ac7d37354098a7b
+ 08add07f1c48dc3dfd56716c3e126f674690d504fc771beaf5e12e9a32f2a17b
+ 1f753b50c16bb45e2db812bb8e179f1641147da41ac30d08238141315c211f57
+ fe8f9c86a087208ebd350f3d1381187a19850d4c2dc0428889c7776047f69574
+ 4ac1f676453ea360e0d5b18fdf2b2ac8f9e72369e221f447f0eb55bc80460149
+ 9e5e501c359e1656ab1bc4699569566ba8bee1463746ca84c51ce83cc98adcde
+ 48f109d71339d0293ed3104a84287b15c3fc4ae425754f5fd66bec0c9f6e27b6
+ ea6dbfdbdbdb3c3aaf935969d635a71a61fb4bd8a8384571c4671c98da20d1fd
+ accbcdcdd1cca1f44bdd6ea4827ebcf41ea97147921d6894eff290d1bda74208
+ 38e9c0453e9f9e6d522dcc5667c1b44f57d60be5239c5e58f4b1e16672608a3f
+ 68f1b7c3d11f609ed4fe10ab359a5b5a7a9da15b44273fd38c303dad6832ace0
+ 81e7e85a836e4bd7e9f9149276be282442ae3ce0fa74d29a9b4e56a99aa06f2a
+ be39c7f4755745f07d29f9a4522a1a43f11f60c31538ea1a37ca793376ecdb2f
+ 9dee32abb3fb035ad68e1b24d97ac3004508b514f33b86b6e19ab578c1a891ec
+ 6a2e2f9cb6f784f2c1372978706102bd273bb721cddb3fa2659ff4485119cc94
+ 2e140051600bb66d0ae6db27205fc9c9e1c6f07a4eb6cda7adec4d86bfbf0748
+ 45dd09d9178745f790ef5f5679840deff1cc38810e49066d41743db0b6a087bc
+ 93307d009dd566c4cc13ed3b634b7f60fd6a7e9fb2774eda2b106d2960dfe979
+ c76d0fe4689ce8f4490c76c1064861624d909d678379f9602c2b9df3b0f9abcf
+ dab614aec38e22bf064950094d9201c6afa52cc5fc7779b279ef41231546f13d
+ f1ef498eae5c445f7691f96ebabef21e7f2d1ee2eedd9846c20b067a73aa2159
+ a116bd056e733b00a847a9dcc82ce288f3037b76be87412ab5c0f86dc3959ab5
+ 85223a2465a11d0bc9b5d93805c5e4466081109f175fae62f82c5012ef4a2c7c
+ 23ff8004c8704103f0dc1589270f8282f9d5a0f51408379ace784d0af862b548
+ 1c11650e865e17af7e04df20a4049295e93d32f22c1cc3c39a8626fa343d1f18
+ a3495bc7dcab911cff66d60d29e1b45a7f16a477b83cf18c523c288c91adc74f
+ e6b3a91445a68313118abd7bd8a0a1ce9290f868f583a3ff80db71381eeb2de8
+ e80b4d8d2cf70bcdafc08788ba8cd6cb2b6fd739ef809c3cb2ad1ded30e14240
+ a7db077e83d18c867e22ba60a57ee2d825c2f7c8b9054d09d6049255a30c67d7
+ 3d01bca101e4e93d2e82e14a86f331b501736cdcac5f562d16f190aeecb5fe39
+ 7b434555d2b8a2bd4d363cdd4a19e69c6bf2e7856e3c9214b0931d392ae644b9
+ bec489e739e7e091e0dea23212e398e9ae3194d52f42afb75079a63f9c39f205
+ 73acb5dc43426f3657575930d5c2a053f7fd5b43f2d011ad74070c1ebdd52aa9
+ 70961253b0715079e17a8339f7d48c9821bad9b4ea2ea0e03e19fefca01f36c8
+ bb91586e2ded2b2fd7512bc9e6787340d78d6d308e8fcafc751707f243fb30f2
+ 5479cf7e89801c62ba25ff7548892e1e224878aeb4cb1f05287cb7febe450986
+ 5d8f2f6469bba902a8f7f0892a954d7ab83e600ceb2dc127239d570428fe9008
+ ba45c4f6b1734a4019122ccea228571be3dee9302bbb7aff9f4ff06290422f91
+ 97f61416b4b19c2cf8225cb54dd3e8090c74abbe1080301cf19d61faebaee2db
+ 9e5c3931c102eab99c20676b1920913273aaf753ba60d87773ca7215562fb612
+ 5f246db99d0b1381f716a7690efe7ab2b54c072853bb28705d12dc35b3722ff6
+ 11675754ee99e7323b2389024b7112be202194e142285227bf08270b560fcf34
+ 2d16392b6dd428e30a10e0d87977a5e6b035063b3f43f4fcaa21b30c90a194cc
+ 5569a0c060b081a054de4bee53914c2bba4e3376b4a44ca48b58e18be2f84a62
+ 5039ec6f2ef3a6cd1d31d5eb6692420d89306f2e6a712d3f3220e2937f9c4e41
+ 33cdae5b6d2a09e0a141fb41d58d5ae2111e74501fe591bd3697d6592db2b425
+ 0ca00f66be5069fc5800e04fd4c4dc1c86f723c02684b7c353f90c4cffa5fd92
+ 8ee3d10b9b259048c67c3bbfe026185e8a5e8b097390dac73faeedd924ea3d24
+ cf82c27494b4f0d7abb77821408175187ce0e81ee5d672000d1dfdb089864ead
+ 599f8392cb7a14624c0624d8b1116645ecede619b1d864332d521b0124de044f
+ e576158176364601a6192366bfe9c3ca0491c91e53d21845b63b54ed4d1f37c1
+ 8214248152c57a2bfdf8499abb15e1b9dc565456e5765edab49357464a2597c0
+ e4c987620bb512fa33b6c3f643f94e89d83b5778cf56e0cdf6c1721f58c4d3b2
+ dc13d5372a854d1b4f0415d37e96f6ba8cc5685413ba4481f2fc489484461d6f
+ 5e081b04a478b0a09139a26ab2944deb0ea32a61f1e787d90cb55ca1c88bbfcd
+ 37233d2cc2f7deea0112a9ea83ede40232d5d97e4447e02dc450d0c944bd746c
+ 8d33b0bf6a190614c016bc96dc7b58835bb0daeeeed1b306326a4c516ef39a43
+ 4e59f1d5e469678ddfb649bfb3ae3726c2a50e680701812e57f5f11056d3b6a4
+ df4be50aa1edab57e5df5f5fa7af30f9fe9627b01871e88637ab68e7d7d9aef6
+ 7920bdfa66b77bcccbaa2f09cb59496e96a4f7cdd7986e6a1fac884a9c729771
+ a3c7ce311151e93138e3e02bab11bdd4b1fc2e7073b5a35bb8601ad01da624d8
+ 2f578fefdd7f81db5ccf4e4eeabba67aac9b5e38a63ce7c1e591dccc86ccd17c
+ f978e4fa9ba685854464de478f113a9be8d6575cbed7d32723a879628b9f977c
+ 42d4771fe17fa0a4cb918b6565dda1c28f7219851e917806cf7105efe42a9a94
+ a76536077b3a9732c01dea56b938803a43f521faa3ab493383ddafd8b159f00e
+ 87dcd4dd42de5bd113ea2ff055a2153bbb1fcf3b51a85fa18191ff143948de0b
+ cf606706cba9afc5db85c4911fd1fe2377f68514a3485b40b91c1aa46f526485
+ ca9720dd285b3abad88fe5d9ff2afc628caddd01b044161f6c18ec243028b727
+ b2aa343385c848560c52d6fb81791f3a2ff66fcadd3ea41691a2073ef984229f
+ 07355f8a6a37a9489494fe02c233c4506f440043b4062755f0cf7ff4b32bc154
+ dd96fc84a35f0f989a1c668a945a8032980f073469b84002a85bebf6ef17fa30
+ d332c88ef5235cddf6a66addac6d66d1f8944d9fdf9e33740c319979ca36a0d2
+ 02e72221f5fa890d1b88734bf6504ff40a4777b27fab35ae19a46338f9542851
+ ab50034d1a515fd8aa550bd7074b283b2206acf1c13da6d3a9430b1dc5463b95
+ b631f28aa62edf5d9b273ba803e72145bf0dfae33223132539b0346c9de97ed2
+ 7e553e095c97f9b3a14da699c383840456823419906b5f4be20337e537e0e8ad
+ 557795a68d1fd3e6f770b2cceadcf493d19d688e2e80f83d8dbaa95ece47f6a3
+ 5c028455cff81071c06eeb830496722a588204cbf52d18544b9ad755e21afb16
+ 7e27bd39aba20041bad3a99c66d6c16e67fee8ed79712f2a0a788c51e8f26d73
+ 54585dee498403b734f56cc3015e2a88a23dc6890f942690ee717ac457a1592a
+ ba7b038bf3f0e6f1e056879cf8d23660d8eb5db01951f0ef32ad2e6e8af7e06f
+ b81e7e945f45dfe64a264ffa6e8d9f0b03d2ff2ebe450e8b6d4969e49d0f5e1b
+ 080eec0d7f9ec42dd64d2f2629db0769590fe62871df28a350379426cea16b52
+ db14a5e5c23d13da4084723b9346011ac33caa39886424c31899460a5f35f405
+ 363e69085db6e55b069ded255dd172fe3df0b0d31a0053e234b3e2ec44f433a6
+ 7a638f9a55a445412fcf8c6ff4d01fdcf6e012ed305beb3fa0b1752441c56e51
+ c30b82300e0b98ff032e3bc4e27d6485741e27a07ea8a131bd7e697e28854ef8
+ c58801a100ba86d94ebc1213cb54a81083367f385d028644f213bc18eb70734e
+ 8de376d680e8b71b530a5f235fb14d7f3d3059862cbb7ea9b6bc2d827bf71744
+ 87226be663ce0a9feb4f248e28b71649355bde7febf2b8cce5f674f6afea22cf
+ f42e98405fd872dc2afadb1d8b1630265913cd5452c7b6bfe516624c16e6133c
+ 3b0152abf170701b5600882b3a4c2fabe4c9794a4bb48c3e2d9a4c03744662b8
+ 0ffa2ac877f5a0db47d26d97bece9f04220d7a19f7abae2346016a359f183271
+ 1a022c704e4bb9bf7215089e7979cefb7fd438fce318f3a900385d6162aaf8d6
+ 23f50ebd7b7de89e426631b59b1fdc688f36fc81ff8621e7adbc3b1aad6c2d19
+ b9995b873acdce08661a25f30f551144e88bf163db7739c67fe4f26ed01fb8fa
+ 9e0a8628ac2338778249c101bcb667f8e7d37f97fa68a680ebe80421ff943a33
+ ddb2dd16c13f82c7100d6d4ca8fea5283518cc9004a9cf1e6b590bd8b9795599
+ eb091c682528dcc8890bc45517ee013e146f6e2d37e4b20f007c47fbba8d600a
+ 63288701ae7e57cb2905f5b71557f2d1599f1d5eda80f59896199e2aa744dd56
+ 74af44b9b87886ff41240188c6753248d30b7f1aec5520c18589120615e458f0
+ 65e158f2015098676e62329cbfb76bd5bacbe510ab5cd1df00c4b750eab9bc05
+ b2a6d05a17ff8f198ddc48abe338e5aa4280080f5256bca57289511d5206dc65
+ d77507048626e2483fd6239bd14d81b4e6ee321c957332629f004710adda7007
+ 04307317a3daa98a28ae9a788c025aba2e667f28e567678f7dd8e1ab1732e74c
+ 886e342da3330094619b2a0fb6adb7189c0be350c4052e24ac09c307b4de27de
+ 88b13f8c3690f42ffc6f9b3a16ea9fd3aad6d2529d507de80a66fb2974f96f5a
+ 6ec51c306f3253a03720e45cdeff9d70d1383ef21e36f9d9a8236fb90504eecc
+ 5cf90d24debe60c8c45e12ed3f6a61c29788d1c5cd7cada5a2f09dd01bfd1a4e
+ f57202691b773a337533dcaf80ed4dadcbbbaccd19765eff4d7316860502a30c
+ b422ebaf5d9b9bb9634abd56a40c0e5d05b1e8b76710abf46d8ae3be97ac19b0
+ 31f01237a0bf80b474cbfec8b863141298ddcc4bbe702d5cc574d64d21921615
+ 755553007b7a3e031ece5e2797d72e381c49f4c3976594f863660c1529b461fb
+ bbd4da0d101d5f1b7e3f00a0e0611758619f0624fffef8c234c224de122ba669
+ 2621eee9b5edc20b8071453f3773c076ff8025824aaf89ad9d17024b7bbd3db3
+ 477635edfff2293a9d9e5d7553bf5fdf6eed19a04bca31837facd884f5fa0735
+ b2f244ecc17773995d753c3ec1f81fcf46b9c7fc35b6d8c073fe3700a2924c4a
+ 673fafc2fc4bb02ec5d7e864176d5c87c5348c3b2a8d5c583196fdf8cf6108a0
+ 0b0381d126076f5ff5283d05b97b0a21091be3f73860f72b69b3a4dbd19372ae
+ b661219c6fc715f06d226bf54805fe97a1b03a69f6818a561a3c789ee6db3af6
+ 8fe31b152e9c8813a880c08295cb6e6167a145b4ab25e97855f7e058d02fa8ef
+ 0f828432b6e9436ab01c7c6a320a33d542ca5e5446d08ebd597d8dd49ed5f83a
+ b9803bb48daaf7bdf9a0457e4247eb2fc41a96c19e562a5513494350acec5ed4
+ 75d010b13951fd6c1ff7ffdacc977e1f22da9d11636bd77d80c7742bec079523
+ fb7036b4c65f16330cbb06bb4441ba6d9695d57f376a7faef1c5c051b0485d08
+ 25cf232eb12683489e97e46c1addae9f5147ae117c5744fc975eb90821791157
+ 110fd856d1bd00c7f9bc1040ae0d83b1ddf572d7d958c1af16549c7c9a498007
+ 002bc771b5286ba7af2ae748c03e5885407d7a5b56aa55e1d86e583fbbd9b88f
+ 3fce64f8aeb894babf7521ad50dc5608d04765ca71b0a97ea4d4f67fda9efb5f
+ 1d67b0fba08ddb711f63e52304e098f871ec1c7e9d58b2b2e58c887122e1fab6
+ d3d4b391f3253170ace505c35c4877d32c9c36506cde3ae243d1de6aa33f5e18
+ fd129165278045b075c43bcf0ced8580a81d702ba464102bdd123a6c2b2310cb
+ c2236427fb40b0f16dbcf46c31019d5beed1e6034949377fd5f7cd57bc04479a
+ 8b53083904c373a63a4a09c60eca4229aff9209449eb78d245ad1cbf3d831867
+ 7d60c285af422f15d6cab2efe202a00c5f21635ba36b4bfb92bc54557de1c092
+ 7a3645afb9dc24dc97030dfffb5606c8db3dc60e35bc6a0086aae19ace912bfb
+ c12f209036c0d43f1aa6500f94ba24a0c4db2309a26f0960fe1426f4239d4551
+ fc9a87d4add8c89cf7c5e40a181396b68043e0b9321caad83cc8a2a71b51c2ca
+ 3efe240e26ddcb4d64eb6fdcb0b59ec196361f7897a2a16b25bfc5513129bb27
+ 24023176e04983e273b0780533fea226cedeff949967b1b9aa9815ba9e1cccda
+ bdf873229770b6d02b5bc81a2cdca77d93ebc04b79595d1eff2afd3d6ced3489
+ b9d273766dfae70b459d5b94b1182cd11bd4beb370c4ef4d5c551063fec1ddb9
+ 8761995d160323356be08008e366649a771b54b5bf40f822ba6dfe66dcaa7caa
+ 4ea1ee4ff8fca8aed14a2966baa5d3db25d0d2cb4062a06061adbb7b2a35b2df
+ 5dc202bafbfeccae75c27aea6c7230320412c30a993e056d6288935160ef1ed2
+ c9f6cfa3119948d4b63e5708cc6923dcd520d8a45a1fbbb34567f322d7a8676b
+ 8fc31fca3c42b5a5528b5151127a445f34f897175f317579593251a920f0b4f6
+ a0d85e4aabf120ed28263706965ae8564bf9fdca5fbff9721299b212d7562335
+ f12569804a23475ae1f5ca757b91ea476efb0da9baadfa85b1c33f6e4ff91e1d
+ 1863aca97bb5b63a07e76a2e0d9d88718871f4e9ff325aa7c5fcfcf40dbeeb1b
+ 82536677ec6ed3e57fc50270ef1067354719a1b2026927e52d0e3e69521d8e8a
+ a0186da08d4cbf91f7cb7701ffe8f63ad558fe50e1a19550d6f769068b96f7a4
+ 7bf99f865c8b6d0de4c4b3a24c9deaf648c462cdd4892a544430ac0ff0932695
+ 8a9df434c065161b1adfb008cc3cd949c055fb8a99c7712789321628f72a498c
+ 646096ad2f24620366f20fa7516c2535df0d3745143b62424254dd79e2f14d07
+ ac4e4f623b95dfc1e3dc8a980451f248d55cf6b0257c95f72915c53e710cc7e4
+ c770c7176434d40d1e2f6ac378dee3d56599be2e75dbb80b68aa0cb1a9b05640
+ 2eb87374757ebcd800ee8166a7c14344d534ec43c679f19a3faf0831f6ac06c5
+ 418d0cc5bd0202c8fb9ea4a4bbeec84746782b34f0cdf595537108c04fb2c4f0
+ f734dfc1ab7b6e448c5466e596f550709be51ea4ad3d2e1809406081f24bedc2
+ afe6b2f0dc106177f0f23e50a68087b935681700a73687311c047b7a3b959e94
+ f1d66a5b9d363b07946af750f7c23c88ac57abe52753eee2ca1738ced53e343c
+ d7147f4e518e410268717ea1d47f935e68e37f1393f4643295cf9fe6bb6a8e4f
+ 24eb7d36e5a73e95668dd0484b43dc7fa7a2e1a4771439af53b8292d4dd9ba0f
+ 87090fa3fc1412e99fbbd9293d622389feab98221d1d17783f4e98f438807085
+ f1c5248b0d6cc84306cdd2d6b4b49859030ecca03a3bc135fd0e2e0c4dbce468
+ b2fb4d3149b24460809e7a40e7733fc69ff9e1f5034bdbbcf54b02de9ba72d97
+ 3e02f2391c4ffaad4155684839c9a1ad84259f7e0e0870b443f6065a9e6ba2f2
+ 5d2b7ed4ff02b658fd881882183a92a619e23b78e368deeac7731942c86e792f
+ 575e124aba8bc9eb8f1ff27baa023b354cb58a1b4b7bca7ace708aa264079a54
+ 8a7291a7aa9ce597599c436314f0ce6bd9a91f7d7d6f5fc74311e3a43bca381f
+ 84343da850a3b97a8b8647428fb3d7675a8c747a364af6733b624c37e119408e
+ 2b8dbcd0ebf1128d3d622fb12811f6fa86734714fdacd66f22fbbed86e0eef19
+ 8165412707a465ab93c043d6ace1453d51a027eea5aee64dc20e6b1677bf0c51
+ 6d988d4c2dea53fd3220ae68b7ba8ec9b4a9e12740610db32c86ff6f9dbbc4be
+ c895877b4a50136972e64c5cec736350fcc746b9a35d227e861a84ea1b7a991d
+ df9923afa67b38558210e59584be3bc822be7b00f0b676d52860aff3fca1c731
+ 29ba85e325b7c525bedf73fd53f8cca733dc99afb00c7d35203ec104ab6ef99a
+ 303c5320a7ae6961e7ad96e49801de1aadfb9a49a4e4938ec5c9866a2a073255
+ 3a0ca67cd73514e1925cc131a6201522d44caacaed554b6dce99a30ca2fcfbb8
+ 00b9b263fa2680d678a94aa745d1628c8722384af1a6ffa490b18e3d34d21ddd
+ 6fb6a7d01123c8071d7325e30c1d0d29c069f00c2b3e6c2c337e4c19c151c5c9
+ 780d3e2b9fb69473e31406af3d3894edf3d56b15719b27bfbd18bf14e245b809
+ f29ecae8d0d23194e99d15e3b3cfe3c6dadfffbf9f33c139f814ba96aaafab3d
+ 7de097d6ec31f1bae09529750e5a124b1df043b0fcb630631fdcee4fc7238b1e
+ 08a3a34498bf112ef7a8c543720cbaa77200a40b1cf72b5a6a05d66a0ed37d68
+ 22533e12b1393da9c1edaad4f2299558c82506af548eaf465c76ed43926797c0
+ 8c127e349a26c21006cde478eaffe17c59d981f045ae488880e427626ef9c073
+ d5c9145af6f127bc9f127f0a859836c56b9f40b6ecc446e137e9d9fff367226e
+ 73ca9add9ea28abad05f87cac5643bc07e91b82e0b35b36626444dfc50a6dafc
+ c37d6306d441ade0b998c7c98dc259e40d974a22d8900263f9421d506386ac95
+ c1c00fef532fe5641f4cacd814ceb9cffceb23a219841e9e1b6c465ac9fcf270
+ 5408cd925a37ee97c64894e02c73d0df87b382622c074734a1e2370aa4a2642c
+ 1fd382156fd054f3a5e2f66a623e396cf56f44273eccb27b5d11170338d4cf27
+ 3f61f8effe3e52b90bd1c49dc15e8416f3f1f839b2a5d900ec8a33b3bd8c3ead
+ 6f51f1d68dd4e4202021adb52ce62191f848273c485a5f88dc1c09952bd38ad9
+ 4d0d9c08cac17187e36c4bef849ea1b5eae2c15ba8a299e9fb3e8d7353fbafa3
+ 0d7af0f616bd16a11d8e98b7c5f39155b2c8bc3a360c89961ab212a8520db33f
+ 763c7caead9ed5815351fcc2026a35646336a498ff3bfc6a074e90f0395ff802
+ 48c1a6b403c1e57eca7068453f149eb8c5a6c1bd980a0215d90b9825372d8d3b
+ 3fe32871eb3b517ed6e20e30477c0433de4d2cec73f7d7773210a10c4932e909
+ eff2f2f83896892eb69f7d27014b55aca65dcc5e8bc62046fcb80a2a24a52165
+ 77e8ae37ef099a4dab23cd5979017ad30872aa6e94b2bf4e4d7f495f2eceb4f0
+ b6d258f94077d191f62dd3f96f94ab43f4ec19a0c1182c13a8ba469601ff148a
+ 57e007c07b6d305e3bacb2bc0a6708a1b17bef4ea41982a321240ef969390985
+ d83828feea903855db4ed66f678dc7c5d6ab49070c4079106163e37cd1144057
+ c781dfd270ee40e3c13b5d74f52324f85c84e55f750298ad9f145759c26b4528
+ 8e707897bbb2aed1037f30d37109a784174cfd5b0aa698c1e79f25d09c603628
+ e23a3abc8d6ee13777f7f5f9e27cf34b97598d3d5bfa96d2499e91e2fa7c505e
+ 3227f8217212bec21eb2f31622a28d292429ab899aaa92ea40a4ca1033217f4a
+ ef6666c16305389f149449a44a0adec2899fe892fba9d88b635668becd219657
+ 02d4b8792bdf922e4342dd5d6d27dd7392a427f153ff35552140a01d7dbb14b7
+ 57da81569ced971af93e59ec7a6927843ece2a555a58532c4a5c0c5aa2d27405
+ 72cab4d7f7b59b45fba1c9f61115ee87574e374554d2ea0c7bc7ef0a07843e37
+ cfc76c2baf0bbc7d58a95b70f7ad9d2c2c1cbacc6f5190e4392fc5598792e623
+ 4f89f3b28442b8d37e3cc2c612b29f960005e68198ccdc8805d2887d9e9fab27
+ 70299a4eae741dca4c983967bb2275ab152a58299a35457759619c6dc3b25eab
+ 68fa0ed545b09833bc269e15456c018ed4494d2c8529f176a03b340fb3d39c45
+ 726f023eaf1cbb5a0c776e2a65b77db5a17e47f75c0debec46166e3ad2804efc
+ 2e41259900f9cbf3dde0d6b1ee4f16964e1f3df0c332021504140bb87e68694d
+ f8046216bc50fb9d7c68a5870ca8ef17d8d543dcc872a32d6421c5b30d561efb
+ e55607c7e21669fb949aee071954491d5ed28c97304eedb5941fc51aec6b7d4c
+ fb4efd4d49610ca7779e0c384e3435e4e9ad4346616667794b925d638355d76e
+ a0130cc84045ef68a6f45a9839d642faec80a9b817474fa8ecf3176570bcb441
+ e9b7450ea2d3f2d5586db80b4218d41c3f256ab8d7bed7e59458b91872f91ceb
+ fcfad2965a08a73861fa7388dd75cac1924c202b26387b6129e5ba5830b9e88a
+ 497c7e94c61c286ae8f4d596fee7c17ba5635b829029ff837c7d4c084df29bd1
+ b318d69d487a679988ebc1751d7c944b83b6b44824cf91246fc75de3d8a2b092
+ d1946b845f3f5ebb0b9b043215188cfe3a4f34fb4fd0d6dd89af38c49d8309f1
+ b95e43c6e5a48a4684dd826e526d8bfd8318447b57aa8c210753b55039c057a4
+ 4a35faf9efa90f25e9c5336ac001e71374dd7e45588759e4c0a2689d82870948
+ 68f456a56dac56b2f0f60a1b7bd307ef18d7d86a3d0fb8e4599524341d8c57cc
+ 3f20e4840cf87c11929718d250faeb37a28a5c230e9aac9abd7f0339d4128c54
+ eb3cc09e4ec9eda06a4687cdf21d1f117e63aba8fe5079e879eb3d1309d24761
+ 32dd8f3ed3ec6a3ecefbbd5eddeab99521bd87f39f20b19ed0cbee4fbadb108a
+ 8a25aef0f277ec0c2d49f30afed6975967c513a0772d8a1176d3a4e0a7768321
+ 2c85b1cd14ac7825d029b02cdecca22e891f3579ff5ef8304e74cf3dccdcb3a7
+ 254134118665dfbdff5427c0471b7d7c2b64118d995734a9cb4495bd347cac39
+ 8805fe76a5973959645a471df1bf99cd333f8a68815706fc4e365de7b496160a
+ 4aba0c061e8509a1b39fd0f2582f813d21daa11c35a5350036dd993e83ef6c41
+ dd17d079fcdc56e9bc4b1c0afd6eb855c7d347612938431ae72bceb78aab6efa
+ 5ccb731cc337171d3e591140e9ec3436bb12ff9b39ee8631de4a6934bce1a4db
+ b61aae9a226e38b0db3afd189165d90812e6a8e74490e080d2d79eb010b96bc1
+ 548062cf654b1b627b7a8faec8f496cb6898635e123651996d2cb52afd58c014
+ ab44719499d2eccbb5378666d6a0b14f8c336226b55f8e4fe55c975c84eda8b3
+ cb66b0e4372f23966d4a1ec8e7e2333acd6f7a18423ab867dd5572e30ee1028c
+ 8a172ab879715601ccc59e4431f3a1923fa3c5f79e1ef8ba28b54ff006bc380c
+ db98623bbf0604a247e87888a62fb03473a98e06c9879f158484d243b72b4d3e
+ 04573192531beffc3202c5740209da69deeefa077d9497e9c5d2309b941d8397
+ 2d9f88eab63fe121bd4658a3bc09677772f7f63d27ee5374adf60c1cb4f37a43
+ 355567a8649aa36d60bb14b0ed70932de29a7ec4910b836fcf8662adf5d80f49
+ 362ed0e804b459be1c5315d4070b61bb6d1296a5a8b2516b11dcb8dfd0bbb426
+ c5897ae6a20b531f8f251cc12bb52ae6406ddf28d77784229ce474b8b72b4329
+ 97073759a48cc211b122ac6e29e089d75b81a983c4c9aee019e5cf78a4c77bca
+ b335eebd138ba85807b57bbd7321283d1cc1793721189de7062dcae2c3533402
+ 06426a9edf0844911997187917ba23fe1d0718acd5c4d4ad8c2819de24db6ef2
+ b2cb9701789ded9938eb436641d998078216ebdb97c418428e99b6abdef04853
+ bc270a8bd461065d26efea3434e7d3b52eccd21e07f526881b3ea123e3c2329a
+ 056ed88fb4089b69abb3746877771817f2fe9bb6728a7eb3fd2e64761463ac3d
+ 669ad3d8928451303c7d645910521533282982bca604677f2bb2988b10f7b848
+ 2114cf7557798ce13952dea8adc2c68397f100a0ce55f5b790c6b8ead46fe7e3
+ 6e958c634bf76423a7a87c9448e0824f142d0a64ba8215e8cbc0da34e79d8589
+ cc9baa0f29410ca4162c027383eb8260a8705f7f1c2c7676aeec54c4e0c42b08
+ 5b66dda1c9f7984877dc5219fa062d884266438b49c4a9aa6a1c469440c75a4b
+ ae1f5362b78a3c9f74181f0f28b0354af3c84affd618a156a3aad277065fc6cb
+ ffcae5406758d4add98169fe89d3e21f9d39e00d018da20350599a441b786cfe
+ 74a43b7bc4659b5904b02ea88638622bb0096ac3b47af0476594fd3ca6753f65
+ 357d504941120a2aa326d006e5a69c6b806d3a0e928b926e253dc81ae13b1dfe
+ f4ddc4709ff15ecd4bd41b88d8ac189096ed4c56465d3dc7b76ad19f222f7397
+ 52426640589f5c13136131d42b814a8c40d6597572e6766dced40ecc45059318
+ 5cce8f0121abe54423c3b28e103a8660df4fbb1b95aa2ef9a9cb0a1253c49a94
+ f32be151957c11ab2c0d522f57b245edb047eafed062c59ed0a6b82687caa7c9
+ 9b203a1c30ec063b4905ae31f0118f800c6c3f7759cdb6b3f043af3243b8ba8c
+ cc383e27aaba6334a74868e3f85d9a4fed0550257ef85cdbe8ecb69e7a5d7dc9
+ 3bfc2ccfc997e74ca7714fd25ddffb54650d15417471c95360ce43693abeeb42
+ 5804a13f77d03cc1b53084ffdab17f068e4f0c506cf6343b928251165853f6c7
+ d337f6c3bd8aa64c57156ccc69050130f1206cbaff5f2202b8a17630d41b7b62
+ 0c4c276f8c6e76a9228b1756aaa31b87598b29d2bc5a268b45ee3720261cab35
+ e5997e262ccbd3c464aa67d0074f1c4b04c786ee08c05d643e01acf498be936c
+ d83bf1800d6f30a4b5d7a08c15fb036d4e053e436c9260891534cbc3c8eda536
+ 2cdeccbc03a423e0f2e508ab719f6bf7c274d8ee7740b79b13a505102acdd25c
+ 50637a1c6b75840b12e6dc77e1befb1b6e4f3877cf2e1c2ddc399e0098093d39
+ c8951f6e32c75fd6ca02d74451fdf614a55007b0bd7b920aab1cbf2de7eb072a
+ 4d57fd5734e35cbbf8b5693fa3a09e5842d938b609110d33b63dfa6c31bfb1d0
+ 7696ee850223891791a68294433e6b9d733eef2683785694539e5c9d34d5963e
+ 22672ae0f47061e450c62df0596aa5742d7d720906e6d8b6002ba1b01a8f0732
+ 5aa66cb81ec1a2009f72790ffbbf58a0d6838a934c41aa1e9d34edb183e4715d
+ e1025b0a03a2b4d3083d5dc24bf1656751ff0d50ed96d3d03ba155a1de7ba075
+ cb09c98ac1f7d7565fa3b826d89c02b966b978fd33ca5a42cb96345f356ee8dd
+ d392b5a04cc3333002d469e6e1efde17df13d5d2037545694b428a6a3706e769
+ 6d31cd8cf72cf7245865818fb45979507b876a83aa961312a92bfd0fea3f0037
+ a3025364dba8603907e6f3641a4823a1bbc556638b27133a0071790fb8fcbd0e
+ abcb83a258007bd8e2fa723b72fc36ede7e4745e67f5ecd38db6278901e4559a
+ efb6761215e98f2dec27a53eb6a5090030c74c57d1d1b1a29f0a578ce26e4682
+ bdd7854c35cf5690514eac890d2dddabf2b6aa6b66304abc6b9f012d4c70bfb3
+ a3ba42cb4bdd4f3550172055a44dda0cec627935ad8d96aa1048ca98256417a8
+ c56462c7ac76f1f7977d51a5a65c2ad9bc3115a0728235fcb438f18cf370e880
+ 684c90971014482b2ca100d46d3a3de6a16b75c1d8e9c4949985b753c4256ef2
+ 49aaa058a2d4795774325e21f92fd0350dd2ff1a3ea9f8f0e9142a4757b7e926
+ 8c8ada143c295cb86a21afdb5260b4afb8e3bb4a0902b9d4fe09e3b0a187f7d4
+ bd129264d0f121a3e0ca622bee85bfef35a039f29ff88131ebd4ac4ee473773d
+ b5c0a258efc4a51dc8582089314ded2ae3d39c42f5a733585c5b32343e23681a
+ 2c5207e7b8c1477e09a3f131ae893172b7d2ff21d7bd5e67e1fdce06450b5406
+ 0b163a8c31674c8d6749d270a15117df4a221fe98463eaddadb4c8c8c8638439
+ bc34c47fae4ca32e13579ce1fd6d5448bf23fa791905adab3e42aeed0b5bb6c1
+ 1f541b58bc1355288c4557b690ab27616f462fea63bd490e1c481338e9d7d68f
+ daf78b3fed65606463aea70d124b4757f47db307487a0360d2a422dd6aeee042
+ 27a9f57f734e233a4153fb652c06ee776a4c64991cf2d3e69c90ec4e797273a3
+ d1339ddbed5e2810f5b54aa0b611ca5f1565c3cea89bfdd721151f01d625f07d
+ 0c551db5db902aa5fb2027c8e5513f2000bb5d5e33bd99132536d3e65fb52c4c
+ 424688691e4801e9d00f29a61dd7493228a9a3c137bb298257714ef0ee4f9f16
+ 87f0fafa42a93bf619817a73f292ff65941ac480bb3f9e4a5612a98e24a5373c
+ 30b5e0a5b5d4b55221199eb4f5a6f70b7330a182c3c195229155f9d3ed4d7fd2
+ f08cef3911f7ab70cf3d7d4b7dc302623b383a236f3f7c985ab4828709ba1d4c
+ c2a0e4daca3ece4c41e53a853c98e7e840c59614a88fe1227be49c38154f024d
+ 83c4f0339c7f1afdee7b6d58c003359d1bc4f460468448222c26258d81b1844d
+ 40283e5db7bb6baa955d9effbbe88f9981bd204a79da80206033a5d3c0c1b8f5
+ 00ec8a79f2472396493eae9ebeafd1662b941db3c23e3e820c7e8f85988a2a53
+ 7d955f18d7869632f498be0d6f5a81fe7e6727d8e6d0fc88cafa99839629c1cf
+ b7ac3cf2b21c43da3f07a3cc1798909400e840f4f48bcd3e76be4f94d9f38ee7
+ f480e76021b36b9306c16a51ec9bba0c6f9b98248f17d49dddfde34226e33622
+ c94655b5afa1c372d4463bc68155803096a36b6cffb7cf261100a46c0ce8bae0
+ 9fd42e392888bc3431bc9212de09437d3b7ff15fff9320fe11b2a16adf4f8350
+ 564725a52e4183b11b06166e8ca561d4913fa14603baff5169b44ab1f9085d2f
+ 0111e4c3b9f6f72f92b61a915f4b6aff97b5163c5e131f1e0083a00f45e5eb57
+ 3b5de28f5e51e6484af6eece850985170fae9a91040fd860faf7b6be1fa851f8
+ 2740f3f32906c221796fef28187ada916dfebc65e327533b83a9a63d164d8b2e
+ 6a6d834bb6390399d564c91c1b998ec5f992d280ba2538098b91cbfb09379f9d
+ c35deb26723693e7ce021f80792262a4d2f6e0f9a4df9f5286705c04f982ec57
+ f10d2ac027d949cc4b62304d987640a6bda12acc60644983811ae225a0869ee5
+ d5d92ec5ca8571b372033c63c402b0c671c63c3677d129837e6e75528351562e
+ bc2f6fba03df82eb600e57094c370d1dc844143b30b7d5dd0f7e20b4dabf379c
+ 6a2e401a6023773c8b85ee50e1949476341338f3477113e8deea7096b8255aa4
+ 1fc4bb718842713425c6385227e6fb1ccf1f3fe89cd7f7f153a8132be0fcf7ff
+ 5e30259022e09ab8a3932cc33d1cb4f6d3e299adf4c15ed0be59df30c1d5ed5b
+ 471ac14fc7b10192ce7d55a412628142ba12ff9b39dff0cc18176e9693ecfcf4
+ 452838dd87cc9059f1aff608182b12d37ad5c13ad77ada2114f1cae0951a4d58
+ 725b18973e4c5c3ce7d4454aab91090409fee42d3ccf5d09cd768712e2a73b6a
+ 4c134b390e0209773af69e875de4f7903b65f8ac253eefa28de825e83ff35b5e
+ 7357ae7de5445bc6e2022b3d4c161f3697b2ee9650552271020b06f802f5a418
+ d20dd1def4368956c713a197321b545625093fab4cb41413f88b6ed006c8fd54
+ 296ec46e4834ced1987ce6739f21631e0b79de38542248c7afb9e08a9e8f68fd
+ 243f7cfb11767e9e4647972dbead5ec136764ad4120e1431b38e2566c0c0bb81
+ 6117d1d5b188935ba2924653feb532cc4f900f7e81e2e6278a753fcd50fd04c7
+ 3b0edd77747e070c2bd18ceeea2eae31dbaa343678b28b05b037c7b6e604d048
+ 394b1e694d23096040a5e709eca5a8755a2f15df09c607843d8abdca62b82e42
+ 5d0dcfe5bec63ffabe011e9aae3322228a26b0358d7c6a740cf91c526d847b84
+ 87c084b7f813f6870a27535b9f727253a9c41f502ddefdc210d7367371a8a1ca
+ 6dd58d8a7234bd5457772728fccb21f82b1b5d1d8c538661c92fdab651e02e56
+ 766e16d58fb6ec299dd0fab458a79ec777eefe57ef9919b5f966c7de075c87b0
+ f624e4900d476b49ff754e3029607cac879c150f12b548cd78aa6a6fcf0dabee
+ 40412bc17072ea2e951b2268eb3777a619a250fa18c1f25a0db6f5b8895565d1
+ 5ca1a6f296c7a95aea09063c817468ad8c76694f2025db959a3f476c0235f3cd
+ 2dc07f725c862e3cc9ecad251596061eeb04156fe89cf21589f6e11082bf3c5b
+ 8d61dfbdbe592a120402983939b99c7d38b4cd32429237421594e21a21841a6a
+ e3756576fc0b063ea6a439f193e4f1dd48edb446da9ae6dbc55f0983f0a5445b
+ 1223abb431e6bb1683c0d07d33e42ff9c37b2d16a0fbc52ea27f53937ebb52f5
+ bc7493f84915b1e4b8f5c05441cd09f43e0e5418cc9d82f31ad35a5a69f32289
+ df6f52bca5f1fc74b2625a42185cbf40350779c94b75a4b9f551f30439acd9d8
+ 3f9b79c46694b87fa60ea3af78ab05a65df0fbd2491d8a33710137a2e7fa7559
+ 39941651fe072f868f92b80792a40673a91776b083156f36bec4a3120d0ddb82
+ 9296dcb0f5d70028c9838788b84b6d9a84a12dd167eb1afafede886c6e9e9d21
+ 4ef74aef4a070cc6ca07a88629d15241be5d62e4975b55c734cdbdf872471c4c
+ 9bc047036203d37cff7a98848b58e6ebc04412dabba494d4bf25ad9e4b4ef4b4
+ ee155539af0c4b9aa1b8b8195375f6d5444a7ba34c0586405946b2492652ddd3
+ d3e034add236bfa5a8612e8d453736ecef2fca9d8cada78698cbe62f7a7d9611
+ f4bf3e04813a874d0e5bab4de5e3c72a98f38457dfbc0852557f6fb9e376e7c7
+ 1d3a0c9492e439cfecfdac766b7b5c3b59c29b3239726e2d6f672352a15d2aa4
+ 14d150814d18468a2558a8b86d2642c2b83db6b296b5a943ef70eaf987be7ee7
+ de41f5cd1b1280aaf49289de4f4865f6c1a3a303e77b80a9263b142cf080ab87
+ 8fb6ebcb18a9701ea271a21b287bb8436d780dbcb0f20cb1bf949f080680a92b
+ ea81f980230b41311c8f30e9e25f325c92c2fd4006211444a31f80c86919f8f0
+ 890e6c1ca1ff51741d0634ce4818c9c2f0c553e5e8a17ffa5b834fa7672fe319
+ 75c0731a3f73a51585f5815419d05a7b10a7e24abdfae5078f7f8f5b34581bac
+ 224f8d63b4283dbc34a2a1573b5f69eeb158c93e844403f3bd4e7a3b3a4e1e8a
+ ac0878ec2eb7c1b7e1c9e6780233608d46b7c801c6c0c83eb67b5d080f4af67a
+ 7b0ce2d1a392ece3e3a0b71f7f37ee8c333ac76bf8ccadbbe158caa15c6a2429
+ 9b350ae180c2ce885d870be5d8378fbc05643de7c8da7171ec14c923c59fa500
+ 4d4fca2d8f85e7ba1aa642c8a214ff8bce3b9f62ef6a4a88c8129bebdcbfe426
+ 808e6d59b712b2aa3d7edee5e45bfa7aec02429796717995785614d69721ed40
+ c9c5a56c5b10e5fb4d5e30d02371ee0b7c7b67d8c7a9fe60b2b9cc7ff4efac5f
+ 523fd88267950ec3d0640347966f43bd326def79b20ddf0421551168a43c8791
+ 627a6ee25d3d8a1200c504226211219c690f3e708465da2317bc25baa1e9efd7
+ 78c9daef857ecbec0449bc16dad92f9f054d68cb91de65caac086e95605ef628
+ 702bcb7e8dfe538d683263bef330c0d900bbf6f62fdaf663d6d1346274006ba0
+ e321644c01e752faa7793efbeede43a7b83173f7f167f3d6fe970acb6646917f
+ d36bb285e6d96ff1fcfc668ae4d185d868c898f3964fda9f0463eb6f83d2cec9
+ ed861f5027330eefe13163560908a7129990799e21a1e83e814c7df4dfe15365
+ ff29765bd346019d69809f425c453ce0a3948fdf3565b83332e47cd65c73467f
+ efb2bf3791994d3172dcff4f82a8d7ae4f9fd53664d180d930dd20aa1001a935
+ e61e9410667536058ec3fd7b97aabd163f8de60a45794196df0cee18e8c56276
+ 25217e4002862b3241a017e7b497ba015662ed624d48749b783f69b204792a35
+ 1212fcf465faa1d4d5905a68f5f17e25ea35b3bb33498162e88f3b0e44d0b2e5
+ 756156eaf47340a82db8a28fce1e0b26e104295e94ac9aa330a5292167d153dd
+ cdc91e47e273eeff554fd652213148655557763b3aef2797df0ab81b202d53ec
+ 76f5f57865cd1835f7f94515efd2335b966b9e81c76335a29414e4372bc6f186
+ 7140b735589bac9c6a9203b83919f44ee6c51e805a5bed6d7ffb66c44ccfe988
+ 59c87bc52021a819b52b850573c5fff13bf7cb9c11f23387d486eee0afca0052
+ 334f4858f1643f6163936a27c472b8dafcd6e14d3bf3f91eecd70bb7856ef444
+ 9cc49c7b9788c6c095e968b2c59923dde8ed1628c62eebcd5f32681ced0dccd0
+ 8e1e61a074c1a78d340c3d873c1eddc97df7051e3d3feb313e054934d4f8696e
+ 8d617c28f03d817a40572e3630f050091c8738fd3e40c231abe958a9f5868b3a
+ 3c9120fcfd2dbc319a91289cba50898b43a409cbb612c040d2f33d43ad9d759a
+ 4cce86ef8dd46945e33caf837a0a7ecfb6b5900204662c56c9cc1b943427074e
+ a3a81765d85dbe3ad77bf5c1162900b5f1ef594285ce655ca2a15ca431afcbc4
+ 6007c144597fbe8ca9638756b3ce61ffa44d524266d2d4c6d6b7a7273625c55d
+ 56c00242b0ff2a150297e504b9fef2b0b478531e1cc7e1c14ab647dac9feb0c5
+ b7b3b20dbfc4285db7745ebb9a3039b230282cdf2a19c1afc822775f3a8026d7
+ d793498b915d792bbda081d45f89d9af12967de9e4f4e3779650d7c2dc3cf1dc
+ d91b8debee82d3d4fbcca89dd4e129a73968660b457da664d1cec437e17680bb
+ 7094ab35e4f77fdcf34b40b84b76f8b7750346b1e2f133686110e9f1de217d4f
+ 8eb81f8d1be2e871ce57632c635189116b9a0a7deaf78d9d6d85178a4f1edef5
+ e30c05971c0d6746dd2e1104281b6148217916a8fcb3944217a35b1a98390849
+ 68cebde7f17a14ccb58bfc1b5440b5d8c75ada3f1a581db2cf6bba553cc32e52
+ 0b3c5f0a9f7cc12e549f3c65798f74123c5556c9e0173254c1eeb1e094e0d8ef
+ 35ea280b388b3d393dc9b84e6400abf8493017c5de85bc0c23ac61919a053262
+ 9a05cf198df82d4f2fb5d6b837fa75bab14bc34c1b46b9ddc4deb67ef4444152
+ c280be46a9f0aeb0fdd5e90e8bfa5449bae9315ab5184a01d4753af4286ceb79
+ 09dbef7f742f7a488c93ed0024ee725686ba71296a18e04aa758742844d37648
+ 5541087952778948eff1a7521fe37a8ab311c7a7e818841c1d39751430a7b656
+ 0453c931b40d6d15915b79a73bd0d06893c0cfa0517e76cd9bd87673f7e7fdc0
+ 317e639f78ba7baaa5f1b43bb52788807b2461e95cd8193414724d954ea066e4
+ 63f578d9ac9a67822057b4e61241b8b5c8f3ce019c767ea2b84fec80ee642ab5
+ 9af04e1490b930da33cee816e91a7ec3756343129efc90f36468b8286566fdd7
+ 3f94d19bbe2076959797ddd83a7b901741578486b79d8102942f71f70c72b2f7
+ 359de20293952d3fd821f6a164487ac420dbf4374463889ca97198ade2827ad7
+ d08bcc071bf2e455b4703891e0ddd950b5f2a11ab246cd2e4bd5401721b8e9b1
+ 702b439fdc8f1ba1a4ed9ef30a18eb514ec61d3fee9e20822a84c3ea225e5652
+ 65eeb21129e3e950d1143cfb759f8ac5e097a42fbd4807034c2b375598b6c439
+ a2e90d007a1995738c61217224cbb54be3ad5aab1fc60d9f9414146b0cacc853
+ 4a57c5aa095ac953a6c4f5c16f001cf51c9586a3e67e2abbbd304e5abd9fe25f
+ ad3d2ad2c8b193113bdca6d5cbe2ce54fbc7f7f8feccff8eb98fb09dd1e2b7ae
+ b2db85d4a4aa399585edfcd485ca6bbde307e546e39856f24d3ce215a5ca1bc1
+ b6aba3df0bce9bfb7ada72b6a9e1d73ffeb9dcdbbbb0861651ff71373d040f9a
+ 43bb1797bd93db1948fb3a28cb446a04f52c3c8ff33ab4a9d87708e0bb86efc2
+ db4e9459f7213ad59a61d9d7790d346d7036d36a8aa2599241d59b8130b8a37b
+ 0242a2b59220eae2c2b7a1b169b1729da75fb682f0d612c007372135fab5afb2
+ a6c05076f0f08c198a8178e84b9943ec3c8321e0d5ffdb4e07004e2d17a8fe28
+ 632cb2949c1fe77b543318c7b107212b363f9ac881c7b868255952cf50cb9504
+ 9dfdb8d429d7a0f3337db9da3e48be60d69999be3df1093303c88f2bfc2982e5
+ 5e8b7004b75d5658f681fe30bfb471863a318d7d0fb496ceec4429bf71d9f07f
+ 32c5af99df3e6fa0095b096a3ac03c9b8009471cae3cdbf81cb21baaca707ba3
+ f0bd970b52a4844cfc81cd66da5930686163303bb503cf72f7bbbb6f47b14785
+ f6c40dc6518227a76bdfc5f7788fbb79978b6de3cf37e0e4f8b284bf249fd602
+ d5ef47d169eb36137bddb00ba693ab9974d37347e9f8f0eb9f06f87d515cbf4d
+ 003396ecfcf3305e83ea35edd75e05b2b363111f45fbc056cd13d1cee1e96797
+ adab632023d85dbbc2fa22e057c031a84f69448fac91d804e40e3d8861b30469
+ 2fd221c7d77e7742ff66aa06be2e20150f6ba142e6c2ce640291d2374b849eac
+ f6b4b970ec408a84c72aa94de175618cb50e0f0813b179066d3e41e644fcc92f
+ 97558fd8523d73986daa8e1a598b5a151fa10ba8b0795d9dd932948ceb56fa1a
+ 3b6a96166bdfb663301bdb0a3d559a7e398c117e425e9c9b809995e757c4423e
+ ee52c0271a7ed1fdeba6ff0c18fc199b3d73b8441d7d64b4bcd2231375412415
+ 85e7c8ce647a5b45e0f1378d7948ec1b69d676ead40dd592947249b4fbf8b75c
+ 36631914cb78d3bc5cf506520d6f9c1cb2e9aaf47a213b804496242a77e7b160
+ 1be264e885bb92abbd28ca502653a98b811c244cd92de8d9b95a46457f7e0390
+ 0ac1f0f5f458f5052d069d7320cd09e76aebfae3b0a6676e4de1742acf1e2fa2
+ d5369d5670e30c7bb46abc78f1bb601f1b652ddd740261811cda6d6215be2a58
+ cf2c798f9a47abf9b59fc32046e927c413de487117ab003c4da86f1ef4a2a92c
+ 5d1ba48d463b11fc9a455a56010bac81b71212e818f15b498882338b83053bfc
+ f2126947a623eec40ec7348718f95aca261e8de0f35b8cbd5f9412659725a2c4
+ 9f29bc32e865636e1ef039b0efc8443db058159aaf304477fe7c2dabfc81b3d4
+ 35499d35a59eb97061292996fa65c5a1c1b4762d31046dfe2dd4a33e3f8e390c
+ 922447ce8ff34f911e68000e98d0a94e9c84ea366eca151a3b9ba00d021367f2
+ 03bc330c1ce0f955231ba61a54c655d8dd7b271a0eedd56a844bc77181f724d2
+ 42e49d31778f9fdeaf240c096ee364c1e9945fec04d9b2b3cd256c70390f8f00
+ aa80d6608d747053bfb92005c8b204abfd262dc7f7d015f4b966d7831e4a506e
+ 87cdc738974049daee1e1c945fa916b7d8a04885c7be53d7191ed6839fb61409
+ 9a9798c718a6e2d96c362b5ae30d79c432279ef0b7c8e1a53e7e7e7be0074459
+ f4941bc1b6f3efb8a8a3df0f0c2fbbfadfc1f48fed0a1c9aad6a08a50bd7582b
+ cee2ddb5be2a5ce078cc8e8beb8119bd78e320d6890bc7dcb10aeb7b5562b9ee
+ 7e3c2d1a6b38fbf551cc5a3b60054d4718fbb6c396753ec4c76f99b5ac70d9e8
+ 29d607bebc0fbfeb7d33e6c876f0f1ae24e25393d501aa2a5b18a393975da2f1
+ 0e048f2043c45126643b6827d80f45c649f44580845f0e8e8e1a04e743364248
+ cbc3891cb409f801a153bb47c4672976c62caf5d87c2bf547d3ba11abdbda794
+ 6ac66599f6819bfcc0f6ee2bd9d94562322edb6b87a3767f30d82bad0e023b88
+ 602eed6dcd0b9e387e586aeefdc3a2ccdb482604f556ef16193355c437e382b5
+ 0b87aa275f70bafdd7d5fdab98635e4110030e18f7ddf58c3978c7967df99427
+ 592988661029f55423765dcea061f1ae72f3aeaae59400cf30f6104614e62825
+ 9ba0d0151dcb3f28aa6ff41f16ac640b01ba51627f923386c33013bdae4aea54
+ eaeeeeef8da3109e8866aa8aab18217a1a1f890d10df396a74bd0e1057a2dedd
+ 7986109646d103f44f1581821446c1f8cf0b3bb5ef8bf04b27938a6ebfcd5001
+ c67de72985041253e4df6d5ab6048002bf1d16753cee57e3fd8414e43c2ff7f2
+ b46e54c389c058073f7affacc5140294666f06e2ad2eae8a41add24dff1a32d7
+ 3c94032b739009b75cf1b8771764f48d1c57033e9ee582144e4af8255ee0d7b3
+ ea36a8208a72147db694e21b144c29f0d07e4af8c01fda6c109ca8612a1a6fad
+ 3d2308b8b6b064f2dab4203724b76c0ad3df3f6e03eb5ec4f42739173e2bd19f
+ 8cd09a5b79a6b1d6851af6e5c47545e4273d0be5f0147d68c3af68f59bbbd05a
+ b913d069a61831cfaf101c2f2174aa0f1c3daa7a73074611624db7ebf1f5643e
+ 2c5bb1da08b0e1418733d28d0da8f543e438076eea37da310b2f4e049d7d3a64
+ 2db23c12150dddd516ad182b31e7549fb791e28cb54b37655d95b3c23c879ed0
+ c6956040b8c5bc89cbb2a8473df767ca889a2e1240b735313254e9294dc91e31
+ b3ed5faa6f7b4267f70524bf8e81c0aebdd63dc94ffa5742b20acc20ec097eec
+ 40f28ea5744a3ee3910dcaae093b74e694dce05ac03ed910eccb4133fba37d0e
+ 99953a6a3e290725d5ee4c10d03bd7f254ba2a4d1bf25e6b98de5c940f6f5303
+ 2cb0d0f029f0985b418b1f07af698bbc601329f9fe9978e5038e749f5872f2eb
+ 5572d9225f688d3e9c228f8c793e227bd5a9a28d0d5ce6cae9bb7a8372ff7519
+ e40e2bab027992d8ba49458b42abc954fbfce21141a270468b9fdee484a7ebff
+ 64cf291404eca8486b14d0a5614604d5b80f8eef6eca462f6e672d72908cc3f8
+ 57550b516fab7e03c4d74245f2fe2c35df1535196170e9653be1b5cdb555cb60
+ 2d46549c63987b12a4cb569223c13d255ecb9300ba7a38686eab1c0b4484671c
+ 3523cab620c1d5670d4bc9e59d23bf85e9bb2f57764031e1840437832ed96e79
+ 4ecb47cb9b8c8f45a922179f111895947ebcd3fe38d2e54eed036ec309f28af4
+ 1d9964639cab6eeadd23691b8da7affa00b364817cbb5a2f1100bf653ae568e4
+ 6cee6fd265e715618c4270e482e5162d85cc1125c7f7218aaf555f518373057b
+ 75e49bd4a6f0903e0c3345337e00a2c6e1ec2d30162aa033016253af30b9ddd8
+ c16dbb6e053ff3ce4c5b052f3f00daccf580a0ab2244670597e8dbfd66f3f088
+ a51db45be935a2f8042e2dff5424e3804cd135f96cc59da82cfcb7216e7f719b
+ a361f655f268616942e7b79bba5d73683ad747440c75e9d07569d8aa38824a46
+ b20d8b3bb3e86297d45632d310abb735d92e2ecd158cefcb4a98c93bb3f13c0a
+ 36af62f165ea7f5eede9cc125600127618e35d12f3bf700e58cae49b05e22c79
+ e591171df2f348d5455eb23b1513521bdbb0eb06d5bcb69b982190e63e28eb39
+ 7da07c06e388ea6229223ee4f14a9c384dfdc2ba0d8f9ff3c5fe852d0d662628
+ d103f681fa2b56421d40944ad0d0e750c84b8e6ff963f5f37b2e3116082662bc
+ 59e3614531463a63ca3caa4af5fa82add2ba8ec478c04cec24104b3e608d0fb4
+ 611bc75b97c00d1729e8650a636a36861e8f7e6429c8ca0d2f566e73611a114a
+ 8b8e9f96300bcafde0cf2324243e77fff438811aa9882989a8bd09c385609a4d
+ dcb6209312d4529ad9bc0969a05b91e42492cba53b5249a102662e6edac95704
+ 271d5502666bc5255d35aa2f20e77729e8ab3987b82521bebd459fee449f240c
+ 6b1d52790b5ea81f4a4cdadb65d89bff4399fce28a200917fffef754fe24b734
+ 13186717c09a7579cc44b7946d1838026896e2ccc45f41f5b1354f3de87292be
+ 7e6a7e66626b69c59cb697684023f79f832fee404e3a83bed6aa7376239c326d
+ 4c30ce5b557e8670fe2ca161d3d28515a89e9d378c6f2b479a93be0584a26d3e
+ c35e7a54c2f25589da8f4c0577e177da9564d0a704e1559046299345d7c9f68c
+ 3ecd1a372bace2ac0321805c103ac438985078a4766b0daf8590e683db158636
+ ce4b7c3ea542584d1df38d2d8f0cdb679bd0b5c82423d902ef6f1fcfd746324b
+ 50128d13ee0f5ac9957188c08b0eb413328ca4f8080d7beaab16cc3aacd51a8f
+ 03839492b671138f3960de304ffb63286fe91486319e92ad8493045516b4636a
+ 8e178794903a2252eef2e90806740071b9817742f87e074af21c498fa3f21dbb
+ e1b8e3c8146d7973d10dbb2708d5024eba4f333669bccc0a29312420c0dc7138
+ 463b986f41d8c25950d7ef64a99ffe90f6a3520939de3d0e516a4dc7be23bea4
+ 74f3fd1c2f2ad8d7ce4c327ffa20710e2bf6c5f815693a5b4025605314f715a3
+ 9ef8f5a86b7f260c8a6c345840443bc02d700d46bff7ce8667032a952d4063e7
+ 0dda03de1244830f0ccaadc7062abc6ff41ddc4ed9ca12488904ebed85608c97
+ 5d0e302df6ebd6c22a5e213d21019ca37446a679eac1bbe0de6317005f955de8
+ 6b2a301f0c903915981e74f2ef18c4671bec9f12c2595d7f51788d54009c46ea
+ e3e1af39badc71cef60d590ca95e47a8f1c53274a7e02c50e21c8bea2001dbf8
+ 5d787235e5f31bac2d4d489136d9491c83001256948fdcd34eb2da295a775fae
+ 9e9fccbd0830a99cdc497bdb8cf2adc6bdbb7ff8c150f306e5875378457e79c0
+ 1a01ff998cc41965862136b37e22ef4d3aa1234bb3419bdc71a43d45f10f879b
+ 925fe4aa3b48c736f989898c68d3fefcee68ce151a55590d4b1a5312a2558be5
+ 6066657d53fc820e84fcb162f67de282b513f80d182931c323959377f16c483b
+ fb0b65b28215a0dc15dacc09b82551f9a04cba42cdad1dd1aa8871c534e0413b
+ 5e1dbdd772e4b0eafb21e01a245bfc273b2f8ad00d518dbc35d0ed6ff463c68d
+ 00165563ec93b156cc00e7f945a8705726c752907283e71ae5bc8e1dd61ca3d6
+ dea7fec8928d460243534d16dba851dd77e3176eed0d7b8284718a891a0e8091
+ e8525ca038e4a358ba3fbd2089ad33bc7821bf753dbaa23c1708cd6c80fd8e04
+ 919a230b790ba7e65e2e6c99c6254ce61b1f23466843a12a87d0bb46993d114f
+ 2cfa18545e813e0f0bcd42fb41ca0bb3843f5324d9f68825c520beb38e34c1aa
+ da4aa7c3e03c55fa023b2f4b4d3ae618a14b2b3555de7f2a55a644f2035fa18b
+ 787abdf31401eef648529e4bd15d9b8e3e3ff5eed76afa2112a32716ca12e39b
+ 08f6053b68c42944648bbfc34d02af7e6bd35d21127f9fa0a79406f7c2b6d278
+ 62103da11c6e1cb34512af560b3af2300882fa769716e84a435a9c6cefdcb0be
+ e0ce3c9fd5531cd4d66ea9f663889660385423c905663cbbe9bb46838799f9b2
+ 1d0485547700339b458c605f15f65030e4ab270ae1500e30a133ce0ddefa2190
+ 23d55a16daf62c8c788432c3b9813865a25edaaa731831ff905bd900434f2d69
+ 2f8880b60a14c12e99c74bb7550da6b5ce8d2228ac4b44cc7432b1dc58c96e4d
+ 1f4390a3b6dcba3569110f0d5f98f77289d27feb69b656257aa14edc8bb3c00d
+ 2da9a4cbbab69bf6ce190c1270be5fc5efc49df45c0b376f081dcfecd80b12e6
+ cced2edb8423294bf8886bdba31002f5c673c0ec8772585640feea2a6e17f385
+ 1cfb1639e697548a5bd849e688ba187bc1b261c60e67cc84a4e5920fb753d5ca
+ 5db41f5bca801c9cf1daf7b88c866d8c18c117ec29aa7087fc08ac4518eb94f6
+ c761bdfae10843c4e6f279d7ffdc2eb36fe38f777745dd255415a9b2bd9c5b7c
+ efc7fbebefb52686382f76cfa9b6af9241d1573bcb8e1e7d2243f621380ea522
+ a30c94f1b19e21e9f2e4ce61d1597e45aad5e4180b1d7069b7f9f2e9490722f0
+ 73f8c7dfb9c8f7514d97d18a2f4ad6a49985f7f4d6447bd439a6ed01e198440d
+ 4b30845005396d3c346450902f88e470141d2cd45b253f8a7fb94342be3f8dfa
+ 0fb042e016ce042d04f903e36519b2750136b94c1978a66b660e3c79a698abb2
+ d7340e9097fc4bd724050ad42cec80696352c3c6e82558361b6421084a509a0c
+ 40eaddcee7050ca7c43726daacab25ed87ad4c04bfd64047f24d7c8230cba804
+ 948d06cd0c1aa4fdba32b51f268dc4730b8d65c8b50a4bf0b2a9b43ece574336
+ bd1cd5af9a1994f3709aa64583a2cd451e3a787307a84a7a159d34c2dd276b9d
+ a351f2751918509502ae9bc0590450916a99ed8b3778d1afed341f0584589c94
+ f0dcca7db60869ff3f91493e636c35194d1dc1a396a48bd1f7e724c6ec46db60
+ 0a4a38ab1535ff3da2c64000dbbe240236143c66cf63742f621896406fcfcd43
+ c4822c4d1c80e2f7722fea857c98180318338e1009afcbd10d5b65ecc2796a8c
+ 14457624bad811cfe85533418fd87f901ae8b760df86e190e0682da9156b7476
+ d6b0f81ba0c303e4dcf6607893de4f15b6ff0de435efcf8398dd55f416502d46
+ 99baaf44e39a29dc7d7c01332922934bb5fc9e5dadf4688f7a997ef9d8deaad3
+ 035640e40af15329b528ef163ecd867d31d008aae735f7a9498eaf20c4804f27
+ a1ced03d39d4ca49791493e0e570e6fa9796e1f9fc79f3f74db5c1ccfa3c53b0
+ 182c636df0377c95d1d560da832244fdd446df61ed5cb36a2c5336cd59f63d0e
+ df7efd374fee9b2d35dc757ad2922bcf7441bb44167fa4c1e47ce46bb63a787a
+ 90b9377fd9e42548091bae3db4a20bba6c4471dcb335b9b043c318577c96af23
+ d046572134d38c2b38fdff6e5eda47689ef58ac2bcc0159d31355d7d063c4bb9
+ 5cf7a615ba26328a3173163f081c01aef825343386df17f0226890e536fe35c4
+ 1792b5115f3c92561da144315039f3f03d7eb6f450bb94931ea74ac6455dfe65
+ b7c4b4993417f69ee10db426fc86681a697e7dc9abd96b7eac6b9a243cb6bc41
+ f38340628ccf7bb442c089beffaa2ef864a31a736bff274ef95ce0cc2a77f695
+ edadda05bc61825f4657bc14e579dcf1d05791a1b079cdccf6def41f026d4aeb
+ 44604cd93e788fde233afd4d26aa71b111e2024e3b271d0e703022f52f635e5a
+ 371c892ac55cb627caa3f36c14745b5fdf230211e076965f29ce80b102bd0b57
+ a0322849da6cf05aa33b10384e32aee2ee65674e554eeac8cc9074b5d71c7988
+ 929b350b98950f6704c9448f2fdc0e4cd8c2f650be4a1ab53fced3c25a7bee82
+ f35fae1c3bfe26407db5e7aceab1cc4b6dc4da552f5cd79ee8d5f068b1fff665
+ e6fa41e77db2a0629507bfc547493051d4942405b0f01eb5deaf18dd9ade3631
+ 184ef75891ce7a1fafda1380d47e55767dd7d3c88baab501cbe0a87352716873
+ 8137bfb1a91b6c98b52dbadbee01a113655dcb67359a2314099b2866b3261773
+ 392aebd266a8fb6a11c04f40b345b4382ed8d2a25eabcf4ece87af1900c891aa
+ bd5a30cde2f1a0d3be3e5ce534299632521430f12084948a6ae70b75517ff665
+ 62e9268f2a454f3a10d7e5710f87ab29b96801b4fa815ce8a8acce2ea4404cba
+ 5ff8b3a56c64ef081a75d664a6206fa341c605683b17d01abbcda227ef3c55a2
+ 3c56c79194138ea19d3cf3be55ddb73f45d00c4c681b667b8eda54a174968018
+ 5a5d990820dc716000a49c13d583bc06cff6a8f0f95ba7bb84e8d8673aef8817
+ 793f4981e1a4f4378958d7388db7ea6c9d1863d153a536a70a229a240aff8194
+ e8ac2dcd2ea751a22d00784c7045c2c9d23e5fb214bc817b60425fc3e8a48f31
+ e6e8a9342cc134e95c4e59026d9abdfc49900411c4a5d972027ffb7e1662a19c
+ 56eeb69c9e67040399fd3913ade537cce040b8180c8c9e323a7d6b1e0c7d12f1
+ 52b135e2e4b589ce34338eff6bd405f1bb1d7ff5c2d7c221bcf320d672fcb97c
+ 0bcf0649e70bc0f85b0c7462816a69f038e97fd614d97f82cb01d144c0743126
+ e8b4b7a34995fbd9d870a22e9ef270926e0fb1f345e3f70f258a45f3c3af6036
+ af94b49a7695dfffaba8d00d7c92687ef96b5f268b5ca004d10e38ee997df62a
+ cc19ee6387baeff268359df4880fe6a31bd113b4e10464365f31f7a1dd16bf3b
+ 5fa72f13f53b1a0d61f7ae2e001b475ac61066bed04fcfbaa0dc7aac8dd693f4
+ 15eed8a4c33b7ae5d845a61c63d382a0b952b0672cccae58110544e7a7329441
+ 0bb1b2f7283a052228b7da6f5094202c0ed8eb09dbdf2ce10fa5c55cd44a35e7
+ 085258438bd77317fd7f990c408f4ad2ac594bf9d3f335e505cb3c024381c1bb
+ 2fb22bac693761ca67bb1b8942103892402f006015466d5cb35492e507018581
+ 4ff9733b61051f2a0c71269d06af3c2a58bd5449a65a42d008a139c7beaa45ed
+ 220a233174b00e35c77ee5a5e2995511f17a2eacd575007e666c2e57761e8385
+ dba2ef66791e676bdfdc06efac4fbb27ab2ac285295b5ae013026e1bb7938a13
+ e1fb9d071ae6f9fe3eb0f3b382695382783fa00c461d622a50ffe6b4651cd059
+ c5cf8a359a5a2222b2ae48acea4f258460c8f69283f7e4554d37b18b691815ad
+ faab55eabbc37c18ea30eaaf5991d7e06574d94e9b87e631806c1d94ff0b7d78
+ 701743409efb366d7c405a11819f5472ffcb3f595ec7bf6146d8570caa949cab
+ 15327fb424c04827148f1793c7041740ce61b521bdb5144e26bfa74be5adb8ca
+ b319e3ddd345b30662422673bbbbd23d30e71f6375c29bcd1ec632652f181c68
+ efbc2026dae64875e32d6c7d8412c9724b72011f8a6615f972e5d4bd4f92d308
+ ef8bb44cd603d22639fcdea9601ac016efd1284e4f899c1f977272926ff61d89
+ 89fea615693c7ad528befdc4277c2a50f335299cd065418407a0d3698ec60244
+ dc7266dbda3270547e90eff22c65e2676a9fae32c088da780b75ea2ddd2bb617
+ 2eb6b68c19b0435652f8d5d2690a15747d6ee5180654fbee72f84a3051dcd4a4
+ eb767370a85995016bac53ab3c0ee44a2e405903e8f6f33c36bf8feb48410d83
+ cf3a04681cb878490415f09229bee9ca1d73da791c2c71313cb951713c5e450c
+ 8482216a71f86f8a541122bea18446797554323764998165bac81b3096796faf
+ 8538bf83af476e0bbabfa0813feed0dc578814b387a0473badf2da98a5f1a129
+ b1385b2e4c9ab79424548e922b91cf56cb3f7a0dca6f4f04ac1ce5d4681d4062
+ dc238c93ece3cb0f6c3523d07115a0c7c018a73490d5cdbb1985165ac41b14fe
+ de1352571c132e47e16915b04c85e16e57a07fd5aea653ad9491019970546d19
+ 3caf494886d2c197c8a39bb5ca92348b18ed84814a6fca4b9e07271c13598990
+ 08c821cf8044a71b89ee6b7c7581e5be5f0167f7f6c39f1e4eae183ac9a5b9da
+ 9f71945962b981055d138d93acdafe0ff2162eb6e320a55fb6783e4755624762
+ 0326c12ae49da52f315f90646fa82072fc772a557b777ffbf2cc54c2c2f76b7f
+ 09531e2890dce9f26157181c69e8fb98d1de277ea3ef5a9653198ca06524ff00
+ 248413ef8662efd204a4163e39b86c3d7a27f1e81052713179c5a39fea89b5e5
+ 5f7ddf87911339a827bdef19ab239624e7c0617ec03e0a6fb4fa29fe6e0b05fa
+ c50a614158995dfed1235c3b39fa966d848633c5a740632d285edce385929d15
+ 0d389b43f47da2171ca336cded4a0851470cc086c04a466e4cf03fddb92f9c20
+ 1f7c732e4a8077527ba27743f9dd4e207b97a1f7cd53778a99f64b092d66f4f9
+ 1b6a3455a72666386fbc9dd06631a041ae1c63452b5a0480fa75e9a5eeedb8d2
+ 7bd88740e3d38d5e954d622aacf4342f536ca534cab1e34d352f706b06e04630
+ 169bc810621d52699cedb96d4796ae1cc28fee4ba7e2223e77faafb9160e3571
+ c013b910f1c61fe188625f318ffcc0a10f614d5716e806f14326aad495ea90a4
+ 4f7bcf589dba538895d4d3da8b5871eeea731f956594bf088a9c4a67794cf661
+ ffb389ca93696eb5fb9589aa2c19f43cfeb41cac18b736775017ad51339e5ccf
+ de061c17b697242189fe127db52d26407b204a664a4d4ef5428ca588f07d5b3e
+ 8d19ad7d2437cdafa87353498a304838433dd2b372b15ed83e7969a11f793b58
+ 40c2d5161aa2f7398f754e2ab2721cfa51915c1795bfdc775012050ac793768b
+ 960744ec1b1e34a02bd28a03660e0da853be50177e0a22fe9e8355cebf20ee28
+ 332ac812ab318ab5a391fe54f18fb88d9effdbabffc20ca9a16d9ef29ea37b8d
+ 5a10f7d36fb1e102528c65f9535683cbe3e31a5d5d1274ec5c7e57042b9b5126
+ 38015154d7080dc6068f4a5cad76cd02ccce389db91c27d9eeaaeb619569a4da
+ f8c6375fd2e2876111e6d481192007eb92f84674583ff8d706e922d31e97178d
+ 1a0e968e64ceb0a703df1e3de767135b655e569c6fa83e1713b15532205a736f
+ cc3899b0df69a87d53a2f065f69988b35cbd395427bc6e6b688cc3d4a11bf0f4
+ 311b75cfab9955f347a91c8f3245c8fb5555075e8a3d529f33aedba49aaec0c6
+ 04a19a7bc5ed45f2f09c7548f6f59b933e96350221fb10d2e654e52f508060ac
+ b0082531fc830e5f4b059731a81ac8e36a2ad89735ecec3d1c30aea57af5d4da
+ a8769c1801f817e4f29c2214ec66d58c3918a9f233133120541f4938c0c8ab6a
+ e2dbf3b0deeb140cb17070d75a64e4b41a169534dd99ad8ee635779da4b131be
+ e1165e25aa26a2127fdcab0738d769117d8c4b7ee4dcf2caff4e126fa83dd96d
+ 0373bfcda5e1a920756329ff21cd4445ebda128a491860b193a4d97d5605acb9
+ 9610029edc11f240a776c45f55997f7d94e5346e1a94d9d8c9ce272d16331f42
+ e6158bd248136122b06bf617d6e51977f2ef2ca94fbfbec1ed369ed566da0a3f
+ 0011484eea81b59772c52834f41208c87b06bcd4dda705404082ccd6280fe7c5
+ 72e8e5f7279d16bdb543488fdcdbc01e3781c3f2f1343c805c2f5d3b3b5ef19f
+ ebc207585693f4ad3b5333260b10a3fd73ae4c496d62bd0abf05f089a89ab658
+ aadceec15421d25fbe0c5df76884133b05214e327cf0f6b872bd93160f69435c
+ fb012578b281d2d38ba93de5d992574e0ee2f0dad835146f4cec5373b1213fa3
+ c8198b7dfbf455d73a7cc6fd50c37b7adcfb6d5c6b5be7c66bbcfe1f58245626
+ 96a7369a9d01fd31b358cdd12738bc129f571396931b3d14e65866e5881e92c0
+ c57ce463d9af9663b21a4c47fe605cd91d220a72d57c5f5217031634e59a7fdc
+ 784d90821ad69adf1bff61844e9f87bb12576a97d6a658daff1c8dfc6815df7e
+ 8dc35d4dde5b42c440259bda1f8112756a956aeb85e59da6b13030837403d79b
+ 726b4cea02e999a2bfdfe58428731cfaddba5504de48dbfc609d7989ebe36b0e
+ b4eaa7e5c3f285d51f3898d1b2e8d3e653374014629b506b8b3fc0bcdab045e0
+ 8a43aa4513e2355dcc5ac7a703c31dcaa61f24213832aca3bbc7e342d7ad27f3
+ 4152ae1fe6f4e28eba9245faf38fc3266cd5ae400635942efd22f0ff9dca428f
+ ce3a8d7d19b8eaa5b36f4e0057b37f83f1b10a83b5d1aab002d6d63bec695e6c
+ 2b46ffa670650aa4f2dc3578114987faa786de2d6db7e6e6872282d0a86e1b82
+ 1cfb6be029aebf854dac8c88f35dab7cdd4a9ed0077dc7ba7c39a34df81662c3
+ 3a5f558328bd31934517e79a53563d330b41105a5329d1fa7053820da39a811d
+ 74c4a92a9ee3f923a26d86c59a8908b9a042e1981da48642ff2298a9b05a5878
+ 5566e7be4c0aa5e34759faaefc41dfbbfc3af607411349681b5030e287d0b577
+ a3eafa4753e746f1d71fd7a6915f7708cd60d15ecc6ce797ba3798a93265a03a
+ 874a07745af0df81363002f3aadd88cb95d5fbb6c45fb044e4ce9e09502003d8
+ 7c4bef2b82b63f91910a0d4ead2f1ea8c8ba01dffbfade76731a8690dd289a7b
+ 71ed0c03819641772101c6bf4c433ccc585d18f93f26fa41fdffe0ef8294296a
+ b9172a28f500fe5b75eef97ee0165ba4a878084ae651784d5de65f5b65cc479b
+ 04116a57611681eba68c09f82efec26ae0c60ac40424bb0fdc8b987b75875464
+ f59dd2e0b62dba0b3fd820cb03f00c2f7babbdf5e24267b9038b45966cb2ff3b
+ 115ca8b0af271afd2b574a0153eebd04a87ab4b418c6a554682b3d2b5420d0e2
+ e23e16ceb4953105df0355be7f31c233af2c0153858030f9fb16e7e9b4795718
+ 7b436b9788c463c7e8d8ab67a6cad843d27dce5caefedc3a76ec535ec979093e
+ 723ca8bd8d0234e1f39973064946c79b93fc892e7b24cefce88d099b821a69c7
+ 7324c9ccf28db4b97f844fdcca54012b142a6f560426674c19839f5d776b29c4
+ 424979e3a16e398e7a792a5e92a7eee5727b6d033e3f305e204ce370dfe40997
+ b7a84f7eb97795b9e243c8fd58ea4cc7371d9ad3949f1c8e9c174cb9af2b0c28
+ 633cfbce09b4a380aa29e9199e055d891e3d89d5589c5e83e8aa7770220551d1
+ b10a88550cf10372add5884010c25359e45c821611a71adeeff841d5d8068918
+ 68f204fcb9f4c9493c8d91cc039baeb898efc4b5eec85623bfc6fdbf5bce605f
+ 5c7c618e19ac01c68961d702b17d16d31368a0b7c3bc46c5b6da34a546e31b5b
+ c9ed437ae5209c91433d0e8df0021e606294a22edc3a02ece80bbd267bc3a1e4
+ 1ce2f5272f1db7002aac2a8d7dc2a649c8316662a941f6baf7fb8ee7e86922c2
+ 75588ff6af85f540bbcc5a380d86e81a37bf88a3c57a8deaed33d274e87720be
+ 2d99585c5029538b2fee86082598a139ec39ca4e061c137f1ff59cfc69120c28
+ 3e654ecb7cc48649900801bb329736c7bf21b07ffba69534036cb85dc5f29396
+ 9ab322e19804863da9c5f0860ebadc5228badb80cfd4e9f31bc0052430e0f3cc
+ 0b63b1cff9fa9f4467d43262d4f63eeae49ff8d1560ec55a06a3a92fdcf158bd
+ 5089f8b188d3095666d4aa9679ffebc6786940132d259d42e7153760de7b6adc
+ d3e6056db55f124726cb20d0ac763b67c727e9789979882578ef2ae32c8d0a9e
+ 2e2947f7ba52cf89944a36cd2f2e5dc4a02656202cb49ba081569584a335be14
+ 9cb5bd5b785123b7cd202158ba98a831edc01d6a461ba2641c07150d3f55b292
+ bcf9c69d619746c9fc9d444a6132c5fc9ed2228bef99ca5c7e6dc772f194a1e7
+ 7a54a8d99c5e665422be3f13bd4e104e69ad02a479ac3c9ff61bb2e74dfa9735
+ e80a744cc4d4674c5b33e674eec87362da4012b98ed0e7f05d75073897a40bc8
+ d66140db1a850483fdd4606b3110ab5d7a6bb6229a6df028e8c8c62538a85884
+ 0abd25dcc84bfe9d13fe4ef567165eb72e0e246826cc67d0f35bcec135c2d4f7
+ 433f278e9948eb91b30f0c11de38e1c9b7484c5e3970b09d37334df686c704b7
+ 77fe267a0ce2ad7a5887e5dff00640e3f619dfcab32fbc28192876018f4fa492
+ b2ed5983a9a1325acc22366a8c5c94412d26b75eee6a2bd08d3d2d9247d0673b
+ 59e680ad1d3432849a695c8910b686533f3bd7d64c3fa3e9ccd76475b4e2d079
+ 0b9e58f792d619b0cc48defcf09cd6855293975b75e38847041662a1899686b7
+ 74d2bbeaeab5431d53aa8c380a57703a21c1306472c4420d33076c25a2bd2710
+ cd7cbe3616afe747a410e03387ff9c5951a89c8818af2879d95d74c5c0734c5a
+ c84218c219a639ad2e8329e55f6d339c03c64452aaab6608a0829f6979a745ac
+ d351cdc8b67f351549aa6df608197e0eb65718f47b5513bbfbad13a5e32adcd4
+ e7869dcfd53b918282c5916f756f6e8eac46cf58f5e9de2d073a4bdd54a54d0b
+ f2f4a61432c62430c1f9eb783018d1c7be62df2514f562f3a285e9584819c8da
+ 91e15749bd71197cd549ef0f89638f560f42a3e02a9dc69a93da820d3748b983
+ b1409f29e499401bd76037e195f9c50895b1034089d2bf6fa736591ef5cad597
+ 836512b623f94e85907d7706b8e3c0686b93432e3d3bf7f42c98de62ad150fdf
+ ee1569f3d3b8aad8fe31f00fed1c767736e9dc189d1ef18979d1725538b060bb
+ 2dac78c707f717a0ecf9bb9f222ef8aff9fda74c4f07ea07b6f52d8b3bc3f02d
+ 763abd9b9bb4305f4707fcd03750e033d502e9e69bbc3db91f4fc1ab9356f1e8
+ b66649370d6e1099250e0638d0b5688bfff1bb8dc7ea038a7163502eee800e53
+ a1bda9971e2ac70b7489492bafa8ef42dfe4851f9f1cc7c2c95a40ab25db455c
+ 12b42cb94aebc3b1b3d7cabdbef637205ec1dec48bf04fe2c86c3f41ff127108
+ 9d8e5c37f7d406d743962f7fe013149b4c1291d9573a544f2bc8e2fea78fb276
+ c5ea8cd6583182ee34fcd8ccdc4dbb7273f848b2c2005dae6e43f99086dd21b1
+ 0756bb1258696753248513daeaff92bfeaae1eabe8c063491a5fd6c00e1f445c
+ cc1ec75c816d6d27e62bc657ed551328c3b85afcd1ca9b09d00373f0053ff68c
+ 97605c183bf8c30a2bfed48a3245ef6b584398f62024642832c88f24a24d3a01
+ be6f512b9c3623843d388c792bc4add0805343713d7535f6a1d03d4a2fce724a
+ b91c4977150914ad0a34fef0addb71980c0a764375d91b86e9f379c438562dcf
+ 11686d0794d26b07d4c59febaff8a93c43946d987e6c4b6ad650c932cd595fa5
+ a2b46b2802463c70449af8e61fa30c6e83c748a33be7d81476376064716e3197
+ f8703d525f95c6a2ddae5b66a9561d8b1440915286c30c345f599ac82fdd1a12
+ a5be554ec240b610383f34d85a1ed94466ee7c0cd5cc1676570a73ac9c6d80df
+ f71c2b487882da466f9a08a2cd963653dc67957514976be58d40a12e9ff9962e
+ 3407c304c750f81a7bfb458a44dcd8a04f8742c8d7ad67b9bc8e4fb9bd425abe
+ af4a2714d56d23dd7fe79d99c5d935b2b97d82415e55f326135fcf51db7e4a81
+ 8e6177e53ce48a628514e93ad45782277eeb78f5dbb51908db22e74825d31478
+ f4a9f5ecd373d6f4fda7b89dcc1d124c3d09265a8835ef1b36c31cb078b4de28
+ 3435ae9df3477504a90b52a788093f0ee924d382b380295faba3c35f56b8f46b
+ 0bfbe880af354d949dc30f0869b9ccb3f194782f4f784c37b79f575ed5dbb38a
+ d3819a668e204d528f6d6e05ba0a45371f7656c6d1be0aff866f9fa6a8ce5654
+ fa485ab31cf114a531b1b674371119eb36ccba3350c58ec35af3c410c393f0a5
+ d6c2149856ddaf28ed279ef64a66a77297f131a9981ca618b5941f28af7ee370
+ 30a59da5e4175b5806a786d4981081b31d306b96f4c7a54e024ea32b8892b12b
+ 6161f3c880242602476dff9070e24a364d40e9a5fde87b26535e9f892c778c50
+ 98e10efa0b5b661971a3a018028789a71b363c7a62ed0944b0c2cbba0c79e4bb
+ 9f7a05b1dc1fcc278e2546201c9d23ba42d67d68d1f4614b3735cbd6f50dc46f
+ 8172cb5d3b6d099e43499c2c0b14c58aecacf63b00a58204f99026dc45994d28
+ 6de59019e2275322d4ce46ebe5ed630489886160a2bf9a7099abb49a864a6e0b
+ a9446b97ed62b61926520d26201f31a803e4bbd8c9bf89d154f3005950dd5721
+ e7d1ccd7982ca0beca6a8cd2dcae488fd9edea9f09ecacc6b430ad9e644bfd94
+ f43177ef3eaca6f2b22ed5c1f61657102792f438a6a8bcc721cf54d445ae5973
+ ed53eef181537f66fe15498f408fce30eb7348a97857391ab7532865f48f7240
+ 5040adf2af45da7b6f5b03d8a37a94a2647936865b470ecd43dc0d4d72269950
+ f0a668b72e6001519f6934380b80a2758686d4f99a618fc4bb61abbb58eddd87
+ 7bc4f0aabd28d596fb613ccffb0f26a75e53a7c7fd432754422538424fdbd636
+ be60414dbede5fa639eeca055c7d0d0f80a121c24f3b2402f98ac91dea0d06de
+ 0e1faab1c2e4ce5172a48a417c210c2ee4619edcadc89c4b69aec28c8b2efb81
+ e37a006366876e99eaa815b69837baa67778e5e359fd316570fb52880a9ca629
+ 97dd0dbf406138783d84792cf7616dbf2c7a31825aa33670c6bdec650ca2698c
+ 5c8546a3966159d66473b07c4c99f2d48c95238ad5352a1cb2f06afdd953475a
+ 4e5dda657bb5f5f834b29b30fc9d9aee7f4d8797dcee9a35cfeb066d8317fb4a
+ 41924f4a2e65cea7cb1fa8114e9e31c4be6847b0547b9712df4cdcf490709df9
+ e76cb3fd933b03b8b7c786790c6ed880458500a3c66ae48306a3dacce3fc1663
+ b0d7e2850a7d9d22c4e2b183ec58bfbf818b4fb7717ae53cf58d9b52020c02af
+ 1686682b215aae195d6c82abf3d27a82a28b2a580a79c88ea264b478196848b3
+ f8789685914564daec64c7798d8ceca706aecdbdf57ad457eb1b5058dd8d081b
+ b125ecd5b6c8cd541f4fe62c9c48a708df183f53b8ee3d1226bb909492ba6878
+ e837627727fa290c2e9296f29991a366a2977ef4ee9c1b9a4635b424b78b0a92
+ eea383038fd13201bf9724313c7bef7f3f86a6b854375077625cfd5c90de6f49
+ c8f7a0da7c5f31b611ecabb893e90a470ca1bfced8b4b34c757869d0778a4934
+ 2a73cf77653d660d6815e3fe282d9d172522f351c58ee095b7dcdf3196b59c39
+ 20309447c3dc2e1679ca39c9efc65b587f0e4c879c8542869bee1ef90f562fb8
+ 02323011b77fd8e079009aabd0011f382de66d9cd74a581b8810251482c985ec
+ af0ca59367f51819c4532af37a5bd5926744b46a03f43da0560bd0eead27310e
+ 3a3e522593a807ad4b8f800960f78894cb757e82f3476a2724d0ae623f5460f1
+ 67bf93d0b305322dca45e038a56b299c7ed6dff66fd747bfa55947b9ecb485db
+ 681af9d82546e9096ae4d6172dcf0aff907642ef8d57ea3f84921041b8a29c94
+ d5a8e867bb5d85576e08324ed1c18b9384fb2c0f5fa5aa87f48d4f2f6f2ed3ac
+ 0cdadc949455fce9165d5e5f5bc4bf4d6314ae8ab1708d2774f95a808ac809fe
+ 565d77765add2900affc
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ cleartomark


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/chess.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/chess.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/chess.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,101 ----
+ %!PS-Adobe-2.1
+ %%% HOW TO USE:  from Unix, "cat Cheq Example | lpr -Pprintername "
+ %%Title: Cheq.cheqtxtx
+ %%Creator: Glenn Reid and still.ps (V 1.0d release 10 edit 08)
+ %%BoundingBox: (atend)
+ %%Pages: (atend)
+ %%DocumentProcSets: Adobe_distill 0.95
+ %%EndComments
+ %%BeginProcSet: Adobe_distill 0.95
+ /PROLOGUE 30 40 add dict def
+  % 30 procedure entries + room for 40 cached font dictionaries
+  PROLOGUE begin
+  /clip { } def    % causes problems. remove if "clip" is needed
+  /bdef { bind def } bind def    /ldef { load def } bdef
+  /T { moveto show } bdef        /A { moveto ashow } bdef
+  /W { moveto widthshow } bdef   /AW { moveto awidthshow } bdef
+  /f /fill ldef                  /R { { rlineto } repeat } bdef
+  /r /rlineto ldef               /L { { lineto } repeat } bdef
+  /m /moveto ldef                /l { moveto lineto stroke } bdef
+  /x { 0 rlineto } bdef          /y { 0 exch rlineto } bdef
+  /c /curveto ldef               /cp /closepath ldef
+  /s /stroke ldef                /w /setlinewidth ldef
+  /g /setgray ldef               /j /setlinejoin ldef
+  /d /setdash ldef               /F /setfont ldef
+  /C /setcmykcolor where { /setcmykcolor get }{ %ifelse
+    { %def
+      1 sub 3 { 3 index add neg dup 0 lt { pop 0 } if 3 1 roll } repeat
+      setrgbcolor
+    } bind
+  } ifelse def
+  /MF { findfont exch makefont setfont } bdef
+  /DF { findfont exch scalefont setfont currentfont def } bdef
+  /BEGINPAGE { pop /pagesave save def } bdef
+  /ENDPAGE { pop pagesave restore showpage } def
+  /REMAP { %def
+    FontDirectory 2 index known { pop pop pop } { %ifelse
+      findfont dup length dict begin
+        { 1 index /FID ne {def}{pop pop} ifelse } forall
+        exch dup length 0 gt { /Encoding exch def }{ pop } ifelse
+      currentdict end definefont pop
+    } ifelse
+  } bdef
+  /RECODE { %def
+     3 -1 roll 1 index findfont /Encoding get 256 array copy exch
+     0 exch { %forall
+      dup type/nametype eq
+        { 3 {2 index} repeat put pop 1 add }{ exch pop }ifelse
+     } forall pop 3 1 roll REMAP
+  } bdef
+  end %PROLOGUE
+ %%EndProcSet: Adobe_distill 0.95
+ %%EndProlog
+ %%BeginSetup
+ PROLOGUE begin
+ 
+ %%EndSetup
+ %%Page: 1 1
+ %%PageFonts: (atend)
+ %%PageBoundingBox: (atend)
+ 
+ 
+ %%%%%% Following line added by Aladdin Enterprises:
+ %%%%%%   load the font explicitly so it doesn't have to be in Fontmap.
+ (cheq.ps) run
+ 
+ 
+ 1 BEGINPAGE
+ 1 1 1 0 C
+ /F1 12 /Times-Roman DF
+ (Cheq \(gift of Adobe Systems\) "Chequed Board")
+ 72 756 T
+ (p. 1)
+ 558 756 T
+ /F2 30 /Cheq DF
+ 
+ 
+ %%%%%% Following line added by Aladdin Enterprises:
+ %%%%%%   scale up and relocate the image.
+ 0 -800 translate 2 2 scale
+ 
+ 
+ ( ________) 72 714 T
+ (/R\366B\316K\365N\345\\) 72 684 T
+ (/\270P\270P\270P\270P\\) 72 654 T
+ (/ x x x x\\) 72 624 T
+ (/x xQ\360 x \\) 72 594 T
+ (/ x x x x\\) 72 564 T
+ (/x x \317kx \\) 72 534 T
+ (/p\271p\271p\271p\271\\) 72 504 T
+ (/\250n\272q\373b\265r\\) 72 474 T	%%%%%% 277??
+ ( --------) 72 444 T
+ 2 ENDPAGE
+ %%PageTrailer
+ %%PageFonts: Times-Roman Cheq 
+ %%PageBoundingBox: 20 20 576 756 
+ %%Trailer
+ end %PROLOGUE
+ %%Pages: 1 
+ %%BoundingBox: 20 20 576 756 
+ %%DocumentFonts: Times-Roman Cheq 
+ %%EOF


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/copyleft.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/copyleft.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/copyleft.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,18 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/copyleft.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/copyleft.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/copyleft.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,18 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/decrypt.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/decrypt.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/decrypt.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,12 ----
+ % Decrypt an eexec-encoded file.
+ 
+ (t.in) (r) file /in exch def
+ (t.out) (w) file /out exch def
+ 256 string /buf exch def
+ 55665		% eexec encryption seed
+  { in buf readhexstring /more exch def
+    dup type1decrypt out exch writestring
+    more not { exit } if
+  } loop
+ in closefile
+ out closefile


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/dict.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/dict.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/dict.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,72 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* dict.h */
+ /* Interfaces for GhostScript dictionary package */
+ 
+ /* Define the maximum size of a dictionary */
+ extern uint dict_max_size;
+ 
+ /* Create a dictionary */
+ extern int dict_create(P2(uint maxlength, ref *dict));
+ 
+ /* Return a pointer to a ref that holds the access attributes */
+ /* for a dictionary. */
+ extern ref *dict_access_ref(P1(ref *dict));
+ #define check_dict_read(dict) check_read(*dict_access_ref(&dict))
+ #define check_dict_write(dict) check_write(*dict_access_ref(&dict))
+ 
+ /* Look up in a stack of dictionaries.  Store a pointer to the value slot */
+ /* where found, or to the (value) slot for inserting. */
+ /* Return 1 if found, 0 if not and there is room for a new entry, */
+ /* or e_dictfull if the dictionary is full and the key is missing. */
+ /* The caller is responsible for ensuring key is not a null. */
+ /* Note that pdbot <= pdtop, and the search starts at pdtop. */
+ extern int dict_lookup(P4(ref *pdbot, ref *pdtop, ref *key, ref **ppvalue));
+ /* Look up in just one dictionary. */
+ #define dict_find(dict,key,ppvalue) dict_lookup(dict,dict,key,ppvalue)
+ 
+ /* Enter a key-value pair in a dictionary. */
+ /* Return 0 or e_dictfull. */
+ extern int dict_put(P3(ref *dict, ref *key, ref *pvalue));
+ 
+ /* Return the number of elements in a dictionary. */
+ extern uint dict_length(P1(ref *dict));
+ 
+ /* Return the capacity of a dictionary. */
+ extern uint dict_maxlength(P1(ref *dict));
+ 
+ /* Copy one dictionary into another. */
+ /* Return 0 or e_dictfull. */
+ extern int dict_copy(P2(ref *dfrom, ref *dto));
+ 
+ /* Grow or shrink a dictionary. */
+ /* Return 0 or e_dictfull. */
+ extern int dict_resize(P2(ref *dict, uint newmaxlength));
+ 
+ /* Prepare to enumerate a dictionary. */
+ /* Return an integer suitable for the first call to dict_next. */
+ extern int dict_first(P1(ref *dict));
+ 
+ /* Enumerate the next element of a dictionary. */
+ /* index is initially the result of a call on dict_first. */
+ /* Either store a key and value at eltp[0] and eltp[1] */
+ /* and return an updated index, or return -1 */
+ /* to signal that there are no more elements in the dictionary. */
+ extern int dict_next(P3(ref *dict, int index, ref *eltp));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/dosstore.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/dosstore.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/dosstore.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,62 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* dosstore.h */
+ /* Fast assignment macros for MS-DOS machines only */
+ 
+ /* See sstorei.h for a discussion of the purpose of the following. */
+ /* This is in a file of its own so that non-DOS compilers */
+ /* don't encounter the pragma directive. */
+ 
+ #pragma inline
+ #ifdef FOR80386				/* use 32-bit moves */
+ /* 66h is the operand size prefix */
+ #  define s_store_b(pto,ito,pfrom,ifrom)\
+    {	asm les bx,dword ptr pfrom;\
+ 	asm db 66h; asm mov ax,es:[bx+((ifrom)*8)];\
+ 	asm db 66h; asm mov cx,es:[bx+((ifrom)*8)+4];\
+ 	asm les bx,dword ptr pto;\
+ 	asm db 66h; asm mov es:[bx+((ito)*8)],ax;\
+ 	asm db 66h; asm mov es:[bx+((ito)*8)+4],cx;\
+    }
+ #  define s_store_r(pboth,ito,ifrom)\
+    {	asm les bx,dword ptr pboth;\
+ 	asm db 66h; asm mov ax,es:[bx+((ifrom)*8)];\
+ 	asm db 66h; asm mov cx,es:[bx+((ifrom)*8)+4];\
+ 	asm db 66h; asm mov es:[bx+((ito)*8)],ax;\
+ 	asm db 66h; asm mov es:[bx+((ito)*8)+4],cx;\
+    }
+ #else
+ #  define s_store_b(pto,ito,pfrom,ifrom)\
+    {	asm les bx,dword ptr pfrom;\
+ 	asm mov ax,es:[bx+((ifrom)*8)]; asm mov cx,es:[bx+((ifrom)*8)+2];\
+ 	asm mov dx,es:[bx+((ifrom)*8)+4]; asm push es:[bx+((ifrom)*8)+6];\
+ 	asm les bx,dword ptr pto;\
+ 	asm mov es:[bx+((ito)*8)],ax; asm mov es:[bx+((ito)*8)+2],cx;\
+ 	asm mov es:[bx+((ito)*8)+4],dx; asm pop es:[bx+((ito)*8)+6];\
+    }
+ #  define s_store_r(pboth,ito,ifrom)\
+    {	asm les bx,dword ptr pboth;\
+ 	asm mov ax,es:[bx+((ifrom)*8)]; asm mov cx,es:[bx+((ifrom)*8)+2];\
+ 	asm mov es:[bx+((ito)*8)],ax; asm mov es:[bx+((ito)*8)+2],cx;\
+ 	asm mov ax,es:[bx+((ifrom)*8)+4]; asm mov cx,es:[bx+((ifrom)*8)+6];\
+ 	asm mov es:[bx+((ito)*8)+4],ax; asm mov es:[bx+((ito)*8)+6],cx;\
+    }
+ #endif
+ #define s_store_i(pto,pfrom) s_store_b(pto,0,pfrom,0)




Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/errors.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/errors.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/errors.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,105 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* errors.h */
+ /* Define error codes for GhostScript */
+ 
+ /* A procedure that may return an error always returns */
+ /* a non-negative value (zero, unless otherwise noted) for success, */
+ /* or negative for failure. */
+ /* We use ints rather than an enum to avoid a lot of casting. */
+ 
+ /* The following peculiar structure allows us to include this file */
+ /* wherever error code definitions are needed, and use the same file */
+ /* to generate the table of error names by setting INCLUDE_ERROR_NAMES. */
+ 
+ typedef struct {
+ 	int code;
+ 	char *name;
+ } error_name;
+ 
+ #		ifdef INCLUDE_ERROR_NAMES	/* ****** */
+ 
+ /* Define the error name table */
+ error_name gs_error_names[] = {
+ #define _e_(code,name) {code,name},
+ 
+ #		else			/* ****** */
+ 
+ extern error_name gs_error_names[];
+ #  define _e_(code,name)
+ 
+ #endif					/* ****** */
+ 
+ #define e_dictfull (-2)
+   _e_(e_dictfull, "dictfull")
+ #define e_dictstackoverflow (-3)
+   _e_(e_dictstackoverflow, "dictstackoverflow")
+ #define e_dictstackunderflow (-4)
+   _e_(e_dictstackunderflow, "dictstackunderflow")
+ #define e_execstackoverflow (-5)
+   _e_(e_execstackoverflow, "execstackoverflow")
+ #define e_interrupt (-6)
+   _e_(e_interrupt, "interrupt")
+ #define e_invalidaccess (-7)
+   _e_(e_invalidaccess, "invalidaccess")
+ #define e_invalidexit (-8)
+   _e_(e_invalidexit, "invalidexit")
+ #define e_invalidfileaccess (-9)
+   _e_(e_invalidfileaccess, "invalidfileaccess")
+ #define e_invalidfont (-10)
+   _e_(e_invalidfont, "invalidfont")
+ #define e_invalidrestore (-11)
+   _e_(e_invalidrestore, "invalidrestore")
+ #define e_ioerror (-12)
+   _e_(e_ioerror, "ioerror")
+ #define e_limitcheck (-13)
+   _e_(e_limitcheck, "limitcheck")
+ #define e_nocurrentpoint (-14)
+   _e_(e_nocurrentpoint, "nocurrentpoint")
+ #define e_rangecheck (-15)
+   _e_(e_rangecheck, "rangecheck")
+ #define e_stackoverflow (-16)
+   _e_(e_stackoverflow, "stackoverflow")
+ #define e_stackunderflow (-17)
+   _e_(e_stackunderflow, "stackunderflow")
+ #define e_syntaxerror (-18)
+   _e_(e_syntaxerror, "syntaxerror")
+ #define e_timeout (-19)
+   _e_(e_timeout, "timeout")
+ #define e_typecheck (-20)
+   _e_(e_typecheck, "typecheck")
+ #define e_undefined (-21)
+   _e_(e_undefined, "undefined")
+ #define e_undefinedfilename (-22)
+   _e_(e_undefinedfilename, "undefinedfilename")
+ #define e_undefinedresult (-23)
+   _e_(e_undefinedresult, "undefinedresult")
+ #define e_unmatchedmark (-24)
+   _e_(e_unmatchedmark, "unmatchedmark")
+ #define e_VMerror (-25)
+   _e_(e_VMerror, "VMerror")
+ 
+ #		ifdef INCLUDE_ERROR_NAMES	/* ****** */
+ 
+ /* End of error name table */
+   { 0, (char *)0 }
+ };
+ 
+ #		endif			/* ****** */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/escher.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/escher.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/escher.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,379 ----
+ %!
+ % If you're concerned that the cpu in your PostScript printer will atrophy
+ % from disuse, here is another Escher-like contribution to to keep it busy
+ % for a while.  It uses PostScript color commands, but will still work on
+ % a monochrome printer (but isn't very pretty in black & white).
+ % 
+ % The butterflies are arranged in a hexagonal grid (wallpaper group p6),
+ % and the moveto, lineto, curveto commands used to render the tesselation
+ % are redefined so as to impose a nonlinear transform that shrinks the
+ % infinite plane to an ellipse.  This is a sleazy way to mimic Escher's
+ % "circle limit" sorts of things. 
+ %
+ % The butterfly permimeter was made by imposing all the symmetry constraints
+ % on a path, and then that path was filled in using Adobe Illustrator
+ %
+ % The routines Xform and next_color are easy to change if you want to hack
+ % with them. The code was written to sacrifice efficiency for readability.
+ %
+ % Bob Wallis
+ %
+ % UUCP {sun,pyramid,cae780,apple}!weitek!wallis
+ 
+ %statusdict begin waittimeout 6000 lt	% if you have a slow printer, you
+ %   {0 60 6000 setdefaulttimeouts}	% might need to uncomment this
+ %if end
+ 
+ /nlayers 1 def		% 1 takes about 10 minutes on a LW+; 2 takes 4x longer
+ /warp 1 def		% 1 -> ellipsoidal distortion; 0 -> flat Euclidean
+ /inch {72 mul} def 
+ 
+ /x4 152 def /y4 205.6 def		% 6 fold rotation center of bfly
+ /x12 387.20 def /y12 403.84 def		% 3 fold center of bfly
+ 
+ /dx x4 x12 sub def			% [dx,dy] = distance between the
+ /dy y4 y12 sub def			% two fixed points above
+ 
+ /Dm dx dup mul  dy dup mul 		% magnitude of basis vectors of
+     add sqrt 3 sqrt mul 		% parallelogram lattice
+ def					% = |dx,dy| * sqrt(3)
+ 
+ /Da dy dx atan 30 add def
+ /D1x Dm Da cos mul def			% [D1x, D1y] = basis vector vector #1
+ /D1y Dm Da sin mul def			% = [Dm,0] exp(j30)
+ 
+ /Da dy dx atan 30 sub def
+ /D2x Dm Da cos mul def			% [D2x, D2y] = basis vector vector #2
+ /D2y Dm Da sin mul def			% = [Dm,0] exp(-j30)
+  
+ /m { moveto} def
+ /L {lineto} def
+ /S {stroke} def
+ /c {curveto} def
+ /f {closepath fill} def
+ /F {closepath fill} def
+ /g { setgray} def
+ 
+ /FillStroke {				% fill interior & stroke black border
+ 	closepath gsave fill grestore 0 setgray stroke
+ } def
+ 
+ %
+ % Description of 1 butterfly
+ %
+ /body {
+ 	314.96 280.19 m
+ 	383.4 261.71 445.11 243.23 513.52 224.68 c
+ 	463.68 256.59 490.26 328.83 446.99 360.76 c
+ 	423.71 347.32 397.08 339.7 367.07 337.9 c
+ 	388.93 358.28 414.14 372.84 442.73 381.58 c
+ 	426.68 398.18 394.07 389.7 387.2 403.84 c
+ 	371.52 404.96 362.56 372.48 340.16 366.88 c
+ 	346.88 396.01 346.88 425.12 340.16 454.24 c
+ 	326.72 427.35 320 400.48 320 373.6 c
+ 	270.71 352.1 221.44 411.23 168.88 384.02 c
+ 	189.04 388.03 202.48 380.4 212.57 366.95 c
+ 	216.72 350.85 209.23 341.46 190.1 338.79 c
+ 	177.34 343.57 167.94 354.17 161.9 370.59 c
+ 	176.06 305.52 132.02 274.05 152 205.6 c
+ 	201.29 257.12 250.56 234.72 299.84 279.52 c
+ 	288.64 266.08 284.16 252.64 286.4 239.2 c
+ 	298.27 223.97 310.15 222.18 322.02 233.82 c
+ 	328.62 249.28 328.51 264.74 314.96 280.19 c
+ 	FillStroke
+ } def
+ 
+ /eyes {
+ 	294.8125 238.3246 m
+ 	296.9115 238.3246 298.6132 242.7964 298.6132 248.3125 c
+ 	298.6132 253.8286 296.9115 258.3004 294.8125 258.3004 c
+ 	292.7135 258.3004 291.0118 253.8286 291.0118 248.3125 c
+ 	291.0118 242.7964 292.7135 238.3246 294.8125 238.3246 c
+ 	closepath gsave 1 g fill grestore 0 g S
+ 	
+ 	319.5 241.1782 m
+ 	321.7455 241.1782 323.5659 245.4917 323.5659 250.8125 c
+ 	323.5659 256.1333 321.7455 260.4468 319.5 260.4468 c
+ 	317.2545 260.4468 315.4341 256.1333 315.4341 250.8125 c
+ 	315.4341 245.4917 317.2545 241.1782 319.5 241.1782 c
+ 	closepath gsave 1 g fill grestore 0 g S
+ 	0 g
+ 	296.875 242.0939 m
+ 	297.4608 242.0939 297.9356 243.479 297.9356 245.1875 c
+ 	297.9356 246.896 297.4608 248.2811 296.875 248.2811 c
+ 	296.2892 248.2811 295.8143 246.896 295.8143 245.1875 c
+ 	295.8143 243.479 296.2892 242.0939 296.875 242.0939 c
+ 	f
+ 	0 g
+ 	318.5 243.7707 m
+ 	319.281 243.7707 319.9142 245.0766 319.9142 246.6875 c
+ 	319.9142 248.2984 319.281 249.6043 318.5 249.6043 c
+ 	317.719 249.6043 317.0858 248.2984 317.0858 246.6875 c
+ 	317.0858 245.0766 317.719 243.7707 318.5 243.7707 c
+ 	f
+ } def	
+ 
+ /stripes {
+ 	292 289 m
+ 	252 294 241 295 213 279 c
+ 	185 263 175 252 159 222 c
+ 	S
+ 	285 313 m
+ 	239 326 226 325 206 315 c
+ 	186 305 164 278 161 267 c
+ 	S
+ 	298 353 m
+ 	262 342 251 339 237 355 c
+ 	223 371 213 380 201 383 c
+ 	S
+ 	330 288 m
+ 	384 293 385 292 418 280 c
+ 	451 268 452 264 473 247 c
+ 	S
+ 	342 306 m
+ 	381 311 386 317 410 311 c
+ 	434 305 460 287 474 262 c
+ 	S
+ 	345 321 m
+ 	352 357 359 367 379 377 c
+ 	399 387 409 385 426 382 c
+ 	S
+ 	327.75 367.75 m
+ 	336.5 392.25 333.682 403.348 335.25 415.5 c
+ 	S
+ 	320 364.75 m
+ 	322 361.75 323.5 360.5 326.25 360 c
+ 	329 359.5 332 360.5 334 362.75 c
+ 	S
+ 	316.25 356.5 m
+ 	318.75 353.25 320 353 323.25 352.25 c
+ 	326.5 351.5 329 352 331.5 353.25 c
+ 	S
+ 	312.5 349 m
+ 	316.75 345.5 318.25 344.5 321.25 343.75 c
+ 	324.25 343 327 344 329.75 346 c
+ 	S
+ 	310.75 340.75 m
+ 	314.25 336.5 316.25 335.25 320 335.25 c
+ 	323.75 335.25 327 336.5 329.25 338 c
+ 	S
+ 	308.5 332 m
+ 	311.75 328.5 312.5 327.25 317 327 c
+ 	321.5 326.75 325.75 328.25 327.75 329.75 c
+ 	S
+ 	305 322 m
+ 	309.5 317.75 310.75 317 315 316.5 c
+ 	319.25 316 322.25 318 324.75 320 c
+ 	S
+ 	302.25 311 m
+ 	307 307.5 307.75 306.25 312.75 306 c
+ 	317.75 305.75 320 307.25 323.75 309.5 c
+ 	S
+ 	301.25 298.25 m
+ 	304.5 292.75 305.25 292 308.25 292 c
+ 	311.25 292 313.75 293.75 315.75 295.75 c
+ 	S
+ } def
+ /nostrils {
+ 	0 g
+ 	304.062 227.775 m
+ 	304.599 227.775 305.034 228.883 305.034 230.25 c
+ 	305.034 231.616 304.599 232.724 304.062 232.724 c
+ 	303.525 232.724 303.09 231.616 303.09 230.25 c
+ 	303.09 228.883 303.525 227.775 304.062 227.775 c
+ 	f
+ 	304.062 230.25 m
+ 	F
+ 	309.562 228.275 m
+ 	310.099 228.275 310.534 229.383 310.534 230.75 c
+ 	310.534 232.116 310.099 233.224 309.562 233.224 c
+ 	309.025 233.224 308.59 232.116 308.59 230.75 c
+ 	308.59 229.383 309.025 228.275 309.562 228.275 c
+ 	f
+ } def
+ /thorax
+ {
+ 	327.5 300 m
+ 	316.5 283 315.5 275.5 308 277.5 c
+ 	294 311.5 299 313.5 304 334 c
+ 	309 354.5 315.5 362 322.5 372 c
+ 	329.5 382 327.5 376.5 331 376 c
+ 	334.5 375.5 339.1367 379.1109 339 369 c
+ 	338.5 332 333.4999 324.5 330.5 311.5 c
+ 	0 g S
+ } def
+ /spots {
+ 	next_color
+ 	192 242.201 m
+ 	202.1535 242.201 210.3848 251.0655 210.3848 262 c
+ 	210.3848 272.9345 202.1535 281.799 192 281.799 c
+ 	181.8465 281.799 173.6152 272.9345 173.6152 262 c
+ 	173.6152 251.0655 181.8465 242.201 192 242.201 c
+ 	FillStroke
+ 	next_color
+ 	447.5 250.2365 m
+ 	459.6061 250.2365 469.4203 257.5181 469.4203 266.5 c
+ 	469.4203 275.4819 459.6061 282.7635 447.5 282.7635 c
+ 	435.3939 282.7635 425.5797 275.4819 425.5797 266.5 c
+ 	425.5797 257.5181 435.3939 250.2365 447.5 250.2365 c
+ 	FillStroke
+ 	next_color
+ 	401 369.1005 m
+ 	409.5914 369.1005 416.5563 373.5327 416.5563 379 c
+ 	416.5563 384.4673 409.5914 388.8995 401 388.8995 c
+ 	392.4086 388.8995 385.4436 384.4673 385.4436 379 c
+ 	385.4436 373.5327 392.4086 369.1005 401 369.1005 c
+ 	FillStroke
+ 	next_color
+ 	249 348.2721 m
+ 	261.4966 348.2721 271.6274 353.9707 271.6274 361 c
+ 	271.6274 368.0293 261.4966 373.7279 249 373.7279 c
+ 	236.5034 373.7279 226.3726 368.0293 226.3726 361 c
+ 	226.3726 353.9707 236.5034 348.2721 249 348.2721 c
+ 	FillStroke
+ } def				
+ 
+ /ncolor 6 def
+ /cidx 0 def
+ 
+ /next_color {
+ 	cidx ncolor div		% hue
+ 	.75			% saturation (change these if you like)
+ 	.8			% lightness
+ 	sethsbcolor
+ 	/cidx cidx 1 add ncolor mod def
+ } def
+ 
+ /cidx 0 def
+ 
+ /max_r2 	 	% radius^2 for center of outermost ring of butterflies
+  Dm nlayers mul 1.05 mul dup mul 
+ def
+ 
+ /max_radius max_r2 sqrt def
+ /max_radius_inv 1 max_radius div def
+ /Dm_inv 1 Dm div def
+ 
+ %
+ % Ellipsoidal distortion, maps "nlayers" concentric rings of cells into
+ % an ellipse centered on page
+ 
+ % D  			length of 1 basis vector separating hexagonal cells
+ % z0			center of 6-fold rotation = origin of shrink xform
+ % z' = (z - z0)/D 				new coord system
+ % |z'| = sqrt(x^2 + [(8.5/11)*y]^2)		aspect ratio of paper
+ % z" = z' * a/M(|z'|)	shrink by "a/M(|z|)" 	as fcn of radius
+ 
+ % At the max radius, we want the shrunk ellipse to be "W" units wide so it
+ % just fits our output format - solve for scale factor "a"
+ 
+ % zmax = n+0.5  		for n layers of cells
+ % zmax * [a/M(zmax)] = W	1/2 width of output on paper
+ % a = M(zmax)*W/zmax		solve for "a"
+ 
+ %/M{dup mul 1 add sqrt}bind def	% M(u) = sqrt(1+|u|^2) = one possible shrink
+ /M { 1.5 add } bind def		% M(u) = (1.5+|u|)     = another possible one
+ /W 3.8 inch def 		% 1/2 width of ellipse
+ /zmax 0.5 nlayers add def	% radius at last layer of hexagons
+ /a zmax M W mul zmax div def	% a = M(zmax)*W/zmax
+ 
+ /Xform {						% [x0,y0] = ctr ellipse
+ 	Matrix transform
+ 	/y exch def
+ 	/x exch def
+ 	/z x dup mul y .773 mul dup mul add sqrt def	% ellipse radius
+ 	/Scale a z M div def				% z=a/M(|z|)
+ 	x Scale mul x0 add 				% magnify back up
+ 	y Scale mul y0 add 				% [x0+x*s, y0+y*s]
+ } def
+ 
+ 
+ /Helvetica findfont 8 scalefont setfont 
+ 4.25 inch 0.5 inch moveto 
+ (RHW) stringwidth pop -0.5 mul 0 rmoveto
+ (RHW) show				% autograph
+ 
+ warp 1 eq {				% redefine commands to use Xform
+ 	/moveto { Xform //moveto} def
+ 	/lineto { Xform //lineto} def
+ 	/curveto { 
+ 		Xform 6 -2 roll
+ 		Xform 6 -2 roll
+ 		Xform 6 -2 roll
+ 		//curveto 
+ 	} def
+ }if
+ 
+ 
+ /bfly {				% paint 1 butterfly
+ 	next_color body
+ 	1 setgray eyes
+ 	stripes
+ 	0 setgray nostrils
+ 	0.5 setgray thorax next_color
+ 	spots
+ }  def
+ 
+ /x0 x4 def		% center
+ /y0 y4 def
+ 
+ /T1matrix 			% xlate to center of image
+   x0 neg  y0 neg  matrix translate 
+ def
+ 
+ /Smatrix 			% scale so that 1 basis vector = 1.0
+   Dm_inv dup matrix scale 
+ def
+ 
+ /HexCell {			% 6 butterflys rotated about center of
+ 	/cidx 0 def		% 6 fold symmetry
+ 	/color 0 def
+ 	/T2matrix dx dy matrix translate def
+ 	0 60 300 {
+ 		/angle exch def
+ 		/Rmatrix angle matrix rotate def
+ 		/Matrix 	% translate, rotate, scale - used by Xform
+ 		  T1matrix Rmatrix matrix concatmatrix
+ 		  T2matrix matrix concatmatrix 
+ 		  Smatrix matrix concatmatrix 
+ 		def
+ 		gsave 
+ 		warp 0 eq 	% then may use usual PostScript machinery
+ 		{		% else using Xform
+ 			x0 y0 translate angle rotate 
+ 			.5 dup scale
+ 			dx x0 sub dy y0 sub translate
+ 		} if		
+ 		bfly 
+ 		next_color
+ 		grestore
+ 	} for
+ } def
+ 
+ 
+ %320 x4 sub 240 y4 sub translate 
+ 4.25 inch x4 sub 5.5 inch y4 sub translate
+ 
+ 
+ 0 setlinewidth
+ /N 2 def
+ N neg 1 N {
+ 	/i exch def					% translate to
+ 	N neg 1 N {					% i*D1 + j*D2
+ 		/j exch def				% and draw HexCell
+ 		gsave
+ 		/dx i D1x mul j D2x mul add def		% translate HexCell by
+ 		/dy i D1y mul j D2y mul add def		% [dx,dy]
+ 		/r2 dx dup mul dy dup mul add def	% r^2 = |dx,dy|^2
+ 		r2 max_r2 lt				% inside radius?
+ 		{ 					% yes
+ 		1 r2 max_r2 div sub sqrt 2 div 
+ 		setlinewidth				% make skinnier lines
+ 		HexCell					% 6 butterflies
+ 		}
+ 		if
+ 		grestore
+ 	} for
+ } for
+ 
+ showpage


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/estack.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/estack.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/estack.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,58 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* estack.h */
+ /* Definitions for execution stack operators for GhostScript */
+ 
+ /* Import the execution stack */
+ extern ref estack[];
+ extern ref *esp;	/* points to current top element of stack */
+ extern ref *estop;	/* points to end of stack */
+ 
+ /* The execution stack is used for three purposes: */
+ /*	- Procedures being executed are held here.  They always have */
+ /* type = t_array or type = t_packedarray, with a_executable set. */
+ /*	- if, ifelse, etc. push arguments to be executed here. */
+ /* They may be any kind of object whatever. */
+ /*	- for, repeat, loop, forall, pathforall, run, and stopped */
+ /* mark the stack by pushing an object with type = t_null, */
+ /* attrs = a_executable, and value.index = 0 for loops, 1 for run/stopped. */
+ /* (Null objects can't ever appear on the stack otherwise: */
+ /* if a control operator pushes one, it gets popped immediately.) */
+ /* The loop operators also push whatever state they need, */
+ /* followed by an operator object that handles continuing the loop. */
+ 
+ /* Macro for marking the execution stack */
+ #define mark_estack(idx)\
+   (++esp, make_tav(esp, t_null, a_executable, index, idx))
+ 
+ /* Macro for pushing an operator on the execution stack */
+ /* to represent a continuation procedure */
+ #define push_op_estack(proc)\
+   (++esp, make_tasv(esp, t_operator, a_executable, 0, opproc, proc))
+ 
+ /* Macro to ensure enough room on the execution stack */
+ #define check_estack(n)\
+   if ( esp + (n) > estop ) return e_execstackoverflow
+ 
+ /* Define the various kinds of execution stack marks. */
+ #define es_other 0			/* internal use */
+ #define es_show 1			/* show operators */
+ #define es_for 2			/* iteration operators */
+ #define es_stopped 3			/* stopped operator */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/fcutils.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/fcutils.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/fcutils.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,46 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % fcutils.ps
+ % Font conversion utilities for Ghostscript.
+ 
+ % Look up the output file name in the font map;
+ %   close the map file.
+ % <mapfile:file> <psfilename:string> fontmapfind ->
+ %   <fontname:name> <encoding:name|null> <uniqueid:int>
+ /fontmapfind
+  { /.psname exch def
+    /.mapfile exch def
+    { .mapfile token not		% font name
+       { (File name ) print .psname print
+         ( not found in mapping file.\n) print stop
+       } if
+      .mapfile token pop		% file name for comparison
+      .mapfile token pop		% encoding name or null
+      .mapfile token pop		% unique id
+      { .mapfile token pop /; cvx eq { exit } if } loop	% stuff up to ;
+      3 -1 roll .psname eq
+       { exit }
+       { pop pop pop }
+      ifelse
+    } loop
+    .mapfile closefile
+    (Mapping ) print .psname print ( to ) print 2 index =only
+    (\n) print flush
+  } bind def


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/font.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/font.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/font.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,39 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* font.h */
+ /* Internal font representation for GhostScript */
+ 
+ /* The external definition of fonts is given in the PostScript manual, */
+ /* pp. 91-93. */
+ 
+ /* The structure given below is 'client data' from the viewpoint */
+ /* of the library.  t_fontID objects point directly to a gs_font.  */
+ 
+ typedef struct font_data_s {
+ 	ref dict;			/* font dictionary object */
+ 	ref BuildChar;
+ 	ref Encoding;
+ 	ref CharStrings;
+ 	ref Subrs;			/* from Private dictionary */
+ 	gs_type1_data type1_data;
+ } font_data;
+ 
+ /* The current font in the graphics state */
+ #define ifont (igs->font)


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevbj10.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevbj10.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevbj10.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,129 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevbj10.c */
+ /* Canon Bubble Jet BJ-10e printer driver for GhostScript */
+ #define GS_PRN_DEVICE gs_bj10_device
+ #define DEVICE_NAME "bj10"
+ #define PAGE_WIDTH_10THS 80L		/* 8" */
+ #define PAGE_HEIGHT_10THS 105L		/* 10.5" */
+ #define X_DPI 360			/* pixels per inch */
+ #define Y_DPI 360			/* pixels per inch */
+ #define PRN_OPEN gdev_prn_open
+ #define PRN_CLOSE gdev_prn_close
+ #define PRN_OUTPUT_PAGE bj10_output_page
+ #define DRIVER				/* see gdevprn.h */
+ #include "gdevprn.h"
+ 
+ /* Send the page to the printer. */
+ private int
+ bj10_output_page(gx_device *dev)
+ {	int code = gdev_prn_open_printer(dev);
+ 	if ( code < 0 ) return code;
+ 
+ 	/* print the accumulated page description */
+ 	bj10_print_page(prn_dev, prn_dev->file);
+ 
+ 	gdev_prn_close_printer(dev);
+ 	return 0;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Send the page to the printer. */
+ private int
+ bj10_print_page(gx_device_printer *pdev, FILE *prn_stream)
+ {	int line_size = mem_bytes_per_scan_line(&pdev->mem);
+ 	byte *in = (byte *)gs_malloc(1, 48*line_size, "bj10_print_page(in)");
+ 	byte *out = (byte *)gs_malloc(1, 48*line_size, "bj10_print_page(out)");
+ 	char *cmp = gs_malloc(1, 18, "bj10_print_page(cmp)");
+ 	int lnum;
+ 
+ 	if ( in == 0 || out == 0 || cmp == 0 )
+ 		return -1;
+ 	memset((char *)cmp, 0, 18);
+ 
+ 	/* I don't know how to initialize the printer -- */
+ 	/* \033@ doesn't work. */
+ 
+ 	/* Linewidth for 48 pixel lines */
+ 	fprintf(prn_stream, "\033A%c\033\002", 8);
+ 
+ 	/* Print lines with 48 pixel height of graphics */
+ 	for ( lnum = 0; lnum < pdev->height; lnum += 48 )
+ 	   {	byte *inp = in;
+ 		byte *outp = out;
+ 		byte *in_end = in + line_size;
+ 		byte *out_beg = out;
+ 		byte *out_end = out + 6*LINE_WIDTH;
+ 		int count;
+ 
+ 		mem_copy_scan_lines(&pdev->mem, lnum, inp, line_size*48);
+ 
+ 		while ( inp < in_end )
+ 		   {	int i;
+ 			for ( i = 0; i < 6; i++, outp++ )
+ 				gdev_prn_transpose_8x8(inp + 8*i*line_size,
+ 							line_size, outp, 6);
+ 			inp++;
+ 			outp += 42;
+ 		   }
+ 
+ 		/* Remove trailing 0s. */
+ 		while ( out_end - 6 >= out )
+ 		   {	if ( memcmp(cmp, (char *)out_end-6, 6) != 0 )
+ 				break;
+ 			out_end -= 6;
+ 		   }
+ 
+ 		/* Remove leading 0s. */
+ 		while ( out_beg + 18 <= out_end )
+ 		   {	if( memcmp(cmp, (char *)out_beg, 18) != 0 )
+ 				break;
+ 			out_beg += 18;
+ 		   }
+ 
+ 		/* Transfer the bits */
+ 		count = (out_end - out_beg) / 6;
+ 		if ( count > 0 )
+ 		   {    if ( out_beg > out )
+ 			   {	putc(033, prn_stream);
+ 				putc('d', prn_stream);	/* displace to right */
+ 				putc( ((out_beg - out) / 18) & 0x0ff, prn_stream);
+ 				putc( ((out_beg - out) / 18) >> 8, prn_stream);
+ 			   }
+ 			putc(033, prn_stream);
+ 			putc('*', prn_stream);
+ 			putc(48, prn_stream);
+ 			putc(count & 0xff, prn_stream);
+ 			putc(count >> 8, prn_stream);
+ 			fwrite((char *)out_beg, 1, 6*count, prn_stream);
+ 		   }
+ 		putc(015, prn_stream);
+ 		putc(012, prn_stream);
+ 	   }
+ 
+ 	/* Reinitialize the printer ?? */
+ 	putc(014, prn_stream);	/* form feed */
+ 
+ 	gs_free(in, 1, 48*line_size, "bj10_print_page(in)");
+ 	gs_free(out, 1, 48*line_size, "bj10_print_page(out)");
+ 	gs_free(cmp, 1, 18, "bj10_print_page(cmp)");
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevdjet.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevdjet.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevdjet.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,228 ----
+ /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevdjet.c */
+ /* H-P DeskJet/LaserJet driver for GhostScript */
+ 
+ /* Define whether we are writing to a DeskJet (which can do bitmap */
+ /* compression) or a LaserJet (which can't). */
+ /* Normally this is defined in the compiler command line -- */
+ /* see the DeskJet and LaserJet entries in gdevs.mak. */
+ #ifndef LASER
+ #  define LASER 0
+ #endif
+ 
+ #if LASER
+ #  define GS_PRN_DEVICE gs_laserjet_device
+ #  define DEVICE_NAME "laserjet"
+ #else
+ #  define GS_PRN_DEVICE gs_deskjet_device
+ #  define DEVICE_NAME "deskjet"
+ #endif
+ #define PAGE_WIDTH_10THS 80		/* not quite a full page */
+ #define PAGE_HEIGHT_10THS 105		/* ditto */
+ /* Normally we set up at 300 DPI; however, on MS-DOS systems with */
+ /* virtual memory disabled, we can't do more than 60 DPI */
+ /* because the maximum buffer is only 64K. */
+ #define X_DPI 300
+ #define Y_DPI 300
+ #ifdef __MSDOS__
+ #  if !VMEM_SPACE
+ #    undef X_DPI
+ #    define X_DPI 60
+ #    undef Y_DPI
+ #    define Y_DPI 60
+ #  endif
+ #endif
+ #define PRN_OPEN gdev_prn_open
+ #define PRN_CLOSE gdev_prn_close
+ #define PRN_OUTPUT_PAGE djet_output_page
+ #define DRIVER				/* see gdevprn.h */
+ #include "gdevprn.h"
+ 
+ /* Forward references */
+ private int djet_print_page(P2(gx_device_printer *, FILE *));
+ 
+ /* Send the page to the printer. */
+ private int
+ djet_output_page(gx_device *dev)
+ {	int code = gdev_prn_open_printer(dev);
+ 	if ( code < 0 ) return code;
+ 
+ 	/* print the accumulated page description */
+ 	djet_print_page(prn_dev, prn_dev->file);
+ 
+ 	gdev_prn_close_printer(dev);
+ 	return 0;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Send the page to the printer.  For the DeskJet, compress each scan line, */
+ /* since computer-to-printer communication time is often a bottleneck. */
+ private int
+ djet_print_page(gx_device_printer *pdev, FILE *prn_stream)
+ {	char data[LINE_SIZE + 4];
+ 
+ #define escape_print(str) fprintf(prn_stream, str, 27)
+ #define escape_print_1(str,arg) fprintf(prn_stream, str, 27, arg)
+ 
+ 	/* ends raster graphics to set raster graphics resolution */
+ 	escape_print("%c*rB");
+ 
+ 	/* set raster graphics resolution -- 75 or 300 dpi */
+ #if X_DPI == 300
+ 	escape_print("%c*t300R");
+ #else
+ 	escape_print("%c*t75R");
+ #endif
+ 
+ 	/* move to top left of page */
+ 	escape_print("%c*p0x0Y");
+ 
+ 	/* start raster graphics */
+ 	escape_print("%c*r0A");
+ 
+ 	/* select the most compressed mode available */
+ #if !LASER				/* LaserJet can't handle it */
+ 	escape_print("%c*b2M");
+ #endif
+ 
+ 	/* Send each scan line in turn */
+ 	   {	int lnum;
+ 		int line_size = mem_bytes_per_scan_line(&pdev->mem);
+ 		int num_blank_lines = 0;
+ 		for ( lnum = 0; lnum < pdev->height; lnum++ )
+ 		   {	char *end_data = data + LINE_SIZE;
+ 			mem_copy_scan_lines(&pdev->mem, lnum,
+ 					    (byte *)data, line_size);
+ 			/* Mask off 1-bits beyond LINE_WIDTH. */
+ #if (LINE_WIDTH & 7)
+ 			end_data[-1] &= (byte)(0xff00 >> (LINE_WIDTH & 7));
+ #endif
+ 			/* Remove trailing 0s. */
+ 			while ( end_data > data && end_data[-1] == 0 )
+ 				end_data--;
+ 			if ( end_data == data )
+ 			   {	/* Blank line */
+ 				num_blank_lines++;
+ 			   }
+ 			else
+ 			   {
+ #if LASER				/* no compression */
+ 				char *out_data = data;
+ 				int out_count = end_data - data;
+ #else
+ 				char out_data[LINE_SIZE + LINE_SIZE / 127 + 1];
+ 				int out_count =
+ 				  compress_row(data, end_data, out_data);
+ #endif
+ 
+ 				/* Skip blank lines if any */
+ 				if ( num_blank_lines > 0 )
+ 				   {	/* move down from current position */
+ 					escape_print_1("%c*p+%dY",
+ 						       num_blank_lines);
+ 					num_blank_lines = 0;
+ 				   }
+ 
+ 				/* transfer raster graphics */
+ 				escape_print_1("%c*b%dW", out_count);
+ 
+ 				/* send the row */
+ 				fwrite(out_data, sizeof(char),
+ 				       out_count, prn_stream);
+ 			   }
+ 		   }
+ 	}
+ 
+ 	/* end raster graphics */
+ 	escape_print("%c*rB");
+ 
+ 	/* eject page */
+ 	escape_print("%c&l0H");
+ 
+ 	return 0;
+ }
+ 
+ #if !LASER
+ 
+ /* Row compression routine for the HP DeskJet. */
+ /* Compresses data from row up to end_row, storing the result */
+ /* starting at compressed.  Returns the number of bytes stored. */
+ /* Runs of K<=127 literal bytes are encoded as K-1 followed by */
+ /* the bytes; runs of 2<=K<=127 identical bytes are encoded as */
+ /* 257-K followed by the byte. */
+ /* In the worst case, the result is N+(N/127)+1 bytes long, */
+ /* where N is the original byte count (end_row - row). */
+ int
+ compress_row(char *row, char *end_row, char *compressed)
+ {	register char *i_exam = row; /* byte being examined in the row to compress */
+ 	char *stop_exam = end_row - 4; /* stop scanning for similar bytes here */
+ 	register char *cptr = compressed; /* output pointer into compressed bytes */
+ 
+ 	while ( i_exam < end_row )
+ 	   {	/* Search ahead in the input looking for a run */
+ 		/* of at least 4 identical bytes. */
+ 		char *i_compr = i_exam;
+ 		char *i_next;		/* end of run */
+ 		char byte_value;
+ 		while ( i_exam <= stop_exam &&
+ 			((byte_value = *i_exam) != i_exam[1] ||
+ 			 byte_value != i_exam[2] ||
+ 			 byte_value != i_exam[3]) )
+ 		  i_exam++;
+ 
+ 		/* Find out how long the run is */
+ 		if ( i_exam > stop_exam )	/* no run */
+ 			i_next = i_exam = end_row;
+ 		else
+ 		   {	i_next = i_exam + 4;
+ 			while ( i_next < end_row && *i_next == byte_value )
+ 				i_next++;
+ 		   }
+ 
+ 		/* Now [i_compr..i_exam) should be encoded as dissimilar, */
+ 		/* and [i_exam..i_next) should be encoded as similar. */
+ 		/* Note that either of these ranges may be empty. */
+ 
+ 		while ( i_compr < i_exam )
+ 		   {	/* Encode up to 127 dissimilar bytes */
+ 			int count = i_exam - i_compr;
+ 			if ( count > 127 ) count = 127;
+ 			*cptr++ = count - 1;
+ 			while ( count > 0 )
+ 			   {	*cptr++ = *i_compr++;
+ 				count--;
+ 			   }
+ 		   }
+ 
+ 		while ( i_exam < i_next )
+ 		   {	/* Encode up to 127 similar bytes */
+ 			int count = i_next - i_exam;
+ 			if ( count > 127 ) count = 127;
+ 			*cptr++ = 1 - count;
+ 			*cptr++ = byte_value;
+ 			i_exam += count;
+ 		   }
+ 	   }
+ 	return (cptr - compressed);
+ }
+ 
+ #endif					/* !LASER */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevega.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevega.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevega.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,29 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevega.h */
+ /* Parameters for EGA driver for Ghostscript */
+ /* This file must precede gdevpcfb.h. */
+ 
+ #define DEVICE_STRUCT_NAME gs_ega_device
+ #define DEVICE_NAME "ega"
+ #define FB_RASTER 80
+ #define SCREEN_HEIGHT 350
+ #define SCREEN_ASPECT_RATIO (48.0/35.0)
+ #define VIDEO_MODE 0x10


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevmd10.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevmd10.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevmd10.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,29 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevega.h */
+ /* Parameters for EIZO MDB-10 driver for Ghostscript */
+ /* This file must precede gdevpcfb.h. */
+ 
+ #define DEVICE_STRUCT_NAME gs_mdb10_device
+ #define DEVICE_NAME "mdb10"
+ #define FB_RASTER 128
+ #define SCREEN_HEIGHT 768
+ #define SCREEN_ASPECT_RATIO 1.0
+ #define VIDEO_MODE 0x37


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevmem.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevmem.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevmem.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,885 ----
+ /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevmem.c */
+ /* "Memory" (stored bitmap) device for Ghostscript library. */
+ #include "memory_.h"
+ #include "gs.h"
+ #include "arch.h"
+ #include "gxbitmap.h"
+ #include "gsmatrix.h"			/* for gxdevice.h */
+ #include "gxdevice.h"
+ #include "gxdevmem.h"
+ 
+ typedef struct gx_device_s gx_device;
+ 
+ /*
+    The obvious representation for a "memory" device is simply a
+    contiguous bitmap stored in something like the PostScript
+    representation, i.e., each scan line (in left-to-right order), padded
+    to a byte or word boundary, followed immediately by the next one.
+    Unfortunately, we can't use this representation, for two reasons:
+ 
+ 	- On PCs with segmented architectures, there is no way to
+ 	  obtain a contiguous block of storage larger than 64K bytes,
+ 	  which isn't big enough for a full-screen bitmap, even in
+ 	  monochrome.
+ 
+ 	- The representation of strings in the Ghostscript
+ 	  interpreter limits the size of a string to 64K-1 bytes,
+ 	  which means we can't simply use a string for the contents
+ 	  of a memory device.
+ 
+    We get around the former problem by representing a memory device
+    as an array of strings: each string holds one scan line.
+    We get around the latter problem by making the client read out the
+    contents of a memory device bitmap in pieces.
+ */
+ 
+ /* ------ Generic macros ------ */
+ 
+ /* Macro for declaring the essential device procedures. */
+ #define declare_mem_map_procs(map_rgb_color, map_color_rgb)\
+   private dev_proc_map_rgb_color(map_rgb_color);\
+   private dev_proc_map_color_rgb(map_color_rgb)
+ #define declare_mem_procs(copy_mono, copy_color, fill_rectangle)\
+   private dev_proc_copy_mono(copy_mono);\
+   private dev_proc_copy_color(copy_color);\
+   private dev_proc_fill_rectangle(fill_rectangle)
+ 
+ /* Macro for generating the procedure record in the device descriptor */
+ #define mem_procs(map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle)\
+ {	mem_open,\
+ 	mem_get_initial_matrix,\
+ 	gx_default_sync_output,\
+ 	gx_default_output_page,\
+ 	gx_default_close_device,\
+ 	map_rgb_color,			/* differs */\
+ 	map_color_rgb,			/* differs */\
+ 	fill_rectangle,			/* differs */\
+ 	gx_default_tile_rectangle,\
+ 	copy_mono,			/* differs */\
+ 	copy_color,			/* differs */\
+ 	gx_default_draw_line,\
+ 	gx_default_fill_trapezoid,\
+ 	gx_default_tile_trapezoid\
+ }
+ 
+ /* Macro for generating the device descriptor */
+ /* The "& 15" in max_value is bogus, to keep certain compilers */
+ /* from complaining about a left shift by 32. */
+ #define max_value(depth) (depth > 8 ? 255 : (1 << (depth & 15)) - 1)
+ #define mem_device(name, depth, procs)\
+ {	sizeof(gx_device_memory),\
+ 	&procs,			/* differs */\
+ 	name,			/* differs */\
+ 	0, 0,			/* x and y extent (filled in) */\
+ 	1, 1,			/* density (irrelevant) */\
+ 	(depth > 1),		/* has_color */\
+ 	max_value(depth),	/* max_rgb */\
+ 	depth,			/* depth differs */\
+ 	0,			/* not open yet */\
+ 	identity_matrix_body,	/* initial matrix (filled in) */\
+ 	0,			/* raster (filled in) */\
+ 	(byte *)0,		/* base (filled in) */\
+ 	(byte **)0,		/* line_ptrs (filled in by 'open') */\
+ 	mem_no_fault_proc,	/* default bring_in_proc */\
+ 	0,			/* invert (filled in for mono) */\
+ 	0, (byte *)0		/* palette (filled in for color) */\
+ }
+ 
+ /* Macro for casting gx_device argument */
+ #define mdev ((gx_device_memory *)dev)
+ 
+ /* Macro for rectangle arguments (x,y,w,h) */
+ #define check_rect()\
+ 	if ( w <= 0 || h <= 0 ) return 0;\
+ 	if ( x < 0 || x > mdev->width - w || y < 0 || y > mdev->height - h )\
+ 		return -1
+ 
+ /* Macros for processing bitmaps in the largest possible chunks. */
+ /* Since bits within a byte are always stored big-endian, */
+ /* we can only use chunks larger than a byte on big-endian machines. */
+ /* Note that we use type uint for register variables holding a chunk: */
+ /* for this reason, we only use larger chunks if !ints_are_short. */
+ #if !big_endian || ints_are_short
+ #  define log2_chunk_bits 3
+ #  define chunk byte
+ #else
+ #  define log2_chunk_bits 5
+ #  define chunk ulong
+ #endif
+ /* Now generic macros defined in terms of the above. */
+ #define chunk_bits (1<<log2_chunk_bits)
+ #define chunk_bytes (chunk_bits/8)
+ #define chunk_bit_mask (chunk_bits-1)
+ #define chunk_hi_bit ((chunk)1<<(chunk_bits-1))
+ #define chunk_all_bits ((chunk_hi_bit<<1)-1)
+ #define chunk_hi_bits(n) (chunk_all_bits-(chunk_all_bits>>(n)))
+ 
+ /* Macros for scan line access. */
+ /* x_to_byte is different for each number of bits per pixel. */
+ /* Note that these macros depend on the definition of scan_chunk: */
+ /* each procedure that uses the scanning macros should #define */
+ /* (not typedef) scan_chunk as either chunk or byte. */
+ #define scan_chunk_bytes sizeof(scan_chunk)
+ #define log2_scan_chunk_bytes (scan_chunk_bytes >> 1)	/* works for 1,2,4 */
+ #define declare_scan_line(line,ptr)\
+ 	byte **line; register scan_chunk *ptr
+ #define declare_scan_ptr(line,ptr,offset)\
+ 	byte **line; scan_chunk *ptr; int offset
+ #define setup_scan_ptr(line,ptr,offset)\
+ 	ptr = (scan_chunk *)((*line) + (offset))
+ #define setup_scan(line,ptr,offset)\
+ 	line = mdev->line_ptrs + (y);\
+ 	setup_scan_ptr(line,ptr,offset)
+ #define next_scan_line(line,ptr,offset)\
+ 	++line; setup_scan_ptr(line,ptr,offset)
+ #define setup_rect(line,ptr,offset)\
+ 	offset = x_to_byte(x) & -scan_chunk_bytes;\
+ 	setup_scan(line,ptr,offset)
+ 
+ /* ------ Generic code ------ */
+ 
+ /* Compute the size of the bitmap storage, */
+ /* including the space for the scan line index. */
+ /* Note that scan lines are padded to a multiple of 4 bytes. */
+ ulong
+ gx_device_memory_bitmap_size(gx_device_memory *dev)
+ {	unsigned raster =
+ 		((mdev->width * mdev->bits_per_color_pixel + 31) >> 5) << 2;
+ 	mdev->raster = raster;
+ 	return (ulong)mdev->height * (raster + sizeof(byte *));
+ }
+ 
+ /* 'Open' the memory device by creating the index table if needed. */
+ private int
+ mem_open(gx_device *dev)
+ {
+ #ifdef __MSDOS__			/* ****** NOTA BENE ****** */
+ #  include <dos.h>
+ #  define make_huge_ptr(ptr)\
+     ((byte huge *)MK_FP(FP_SEG(ptr), 0) + FP_OFF(ptr))
+ 	byte huge *scan_line = make_huge_ptr(mdev->base);
+ #else					/* ****** ****** */
+ 	byte *scan_line = mdev->base;
+ #endif					/* ****** ****** */
+ 	byte **pptr = (byte **)(scan_line + (ulong)mdev->height * mdev->raster);
+ 	byte **pend = pptr + mdev->height;
+ 	mdev->line_ptrs = pptr;
+ 	while ( pptr != pend )
+ 	   {	*pptr++ = (byte *)scan_line;
+ 		scan_line += mdev->raster;
+ 	   }	
+ 	return 0;
+ }
+ 
+ /* Return the initial transformation matrix */
+ void
+ mem_get_initial_matrix(gx_device *dev, gs_matrix *pmat)
+ {	*pmat = mdev->initial_matrix;
+ }
+ 
+ /* Test whether a device is a memory device */
+ int
+ gs_device_is_memory(gx_device *dev)
+ {	/* We can't just compare the procs, or even an individual proc, */
+ 	/* because we might be tracing.  Compare the device name, */
+ 	/* and hope for the best. */
+ 	char *name = dev->name;
+ 	int i;
+ 	for ( i = 0; i < 6; i++ )
+ 	  if ( name[i] != "image("[i] ) return 0;
+ 	return 1;
+ }
+ 
+ /* Compute the number of data bytes per scan line. */
+ /* Note that this does not include the padding. */
+ int
+ mem_bytes_per_scan_line(gx_device_memory *dev)
+ {	return (dev->width * dev->bits_per_color_pixel + 7) >> 3;
+ }
+ 
+ /* Copy one or more scan lines to a client. */
+ #undef scan_chunk
+ #define scan_chunk byte
+ int
+ mem_copy_scan_lines(gx_device_memory *dev, int start_y, byte *str, uint size)
+ {	declare_scan_ptr(src_line, src, offset);
+ 	uint bytes_per_line = mem_bytes_per_scan_line(dev);
+ 	byte *dest = str;
+ 	int y = start_y;
+ 	uint count = min(size / bytes_per_line, dev->height - y);
+ 	while ( (*dev->bring_in_proc)(dev, 0, y, bytes_per_line, count, 0) < 0 )
+ 	   {	/* We can only split in Y, not in X. */
+ 		uint part = count >> 1;
+ 		uint part_size = part * bytes_per_line;
+ 		mem_copy_scan_lines(dev, y, dest, part_size);
+ 		dest += part_size;
+ 		y += part;
+ 		count -= part;
+ 	   }
+ 	setup_scan(src_line, src, 0);
+ 	while ( count-- != 0 )
+ 	   {	memcpy(dest, src, bytes_per_line);
+ 		next_scan_line(src_line, src, 0);
+ 		dest += bytes_per_line;
+ 		y++;
+ 	   }
+ 	return y - start_y;
+ }
+ 
+ /* ------ Page fault recovery ------ */
+ 
+ /* Default (no-fault) bring_in_proc */
+ private int
+ mem_no_fault_proc(gx_device_memory *dev,
+   int x, int y, int w, int h, int writing)
+ {	return 0;
+ }
+ 
+ /* Recover from bring_in_proc failure in fill_rectangle */
+ #define check_fault_fill(byte_x, byte_count)\
+   if ( mdev->bring_in_proc != mem_no_fault_proc )\
+    {	int fault = (*mdev->bring_in_proc)(mdev, byte_x, y, byte_count, h, 1);\
+ 	if ( fault < 0 )\
+ 		return mem_fill_recover(dev, x, y, w, h, color, fault);\
+    }
+ private int
+ mem_fill_recover(gx_device *dev, int x, int y, int w, int h,
+   gx_color_index color, int fault)
+ {	int nx = x, nw = w, ny = y, nh = h;
+ 	switch ( fault )
+ 	   {
+ 	case mem_fault_split_X:
+ 		nx += (nw >>= 1), w -= nw;
+ 		break;
+ 	case mem_fault_split_Y:
+ 		ny += (nh >>= 1), h -= nh;
+ 		break;
+ 	default:
+ 		return fault;
+ 	   }
+ 	(*dev->procs->fill_rectangle)(dev, x, y, w, h, color);
+ 	return (*dev->procs->fill_rectangle)(dev, nx, ny, nw, nh, color);
+ }
+ 
+ /* Recover from bring_in_proc failure in copy_mono */
+ #define check_fault_copy_mono(byte_x, byte_count)\
+   if ( mdev->bring_in_proc != mem_no_fault_proc )\
+    {	int fault = (*mdev->bring_in_proc)(mdev, byte_x, y, byte_count, h, 1);\
+ 	if ( fault < 0 )\
+ 		return mem_copy_mono_recover(dev, base, sourcex, raster,\
+ 				x, y, w, h, zero, one, fault);\
+    }
+ private int
+ mem_copy_mono_recover(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one,
+   int fault)
+ {	int nx = x, nw = w, ny = y, nh = h;
+ 	switch ( fault )
+ 	   {
+ 	case mem_fault_split_X:
+ 		nx += (nw >>= 1), w -= nw;
+ 		break;
+ 	case mem_fault_split_Y:
+ 		ny += (nh >>= 1), h -= nh;
+ 		break;
+ 	default:
+ 		return fault;
+ 	   }
+ 	(*dev->procs->copy_mono)(dev, base, sourcex, raster,
+ 				 x, y, w, h, zero, one);
+ 	return (*dev->procs->copy_mono)(dev, base, sourcex, raster,
+ 					nx, ny, nw, nh, zero, one);
+ }
+ 
+ /* Recover from bring_in_proc failure in copy_color */
+ #define check_fault_copy_color(byte_x, byte_count)\
+   if ( mdev->bring_in_proc != mem_no_fault_proc )\
+    {	int fault = (*mdev->bring_in_proc)(mdev, byte_x, y, byte_count, h, 1);\
+ 	if ( fault < 0 )\
+ 		return mem_copy_color_recover(dev, base, sourcex, raster,\
+ 				x, y, w, h, fault);\
+    }
+ private int
+ mem_copy_color_recover(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, int fault)
+ {	int nx = x, nw = w, ny = y, nh = h;
+ 	switch ( fault )
+ 	   {
+ 	case mem_fault_split_X:
+ 		nx += (nw >>= 1), w -= nw;
+ 		break;
+ 	case mem_fault_split_Y:
+ 		ny += (nh >>= 1), h -= nh;
+ 		break;
+ 	default:
+ 		return fault;
+ 	   }
+ 	(*dev->procs->copy_color)(dev, base, sourcex, raster,
+ 				 x, y, w, h);
+ 	return (*dev->procs->copy_color)(dev, base, sourcex, raster,
+ 					 nx, ny, nw, nh);
+ }
+ 
+ /* ------ Monochrome ------ */
+ 
+ /* Procedures */
+ declare_mem_procs(mem_mono_copy_mono, mem_mono_copy_color, mem_mono_fill_rectangle);
+ 
+ /* The device descriptor. */
+ private gx_device_procs mem_mono_procs =
+   mem_procs(gx_default_map_rgb_color, gx_default_map_color_rgb,
+     mem_mono_copy_mono, mem_mono_copy_color, mem_mono_fill_rectangle);
+ 
+ /* The instance is public. */
+ gx_device_memory mem_mono_device =
+   mem_device("image(mono)", 1, mem_mono_procs);
+ 
+ /* Convert x coordinate to byte offset in scan line. */
+ #define x_to_byte(x) ((x) >> 3)
+ 
+ /* Fill a rectangle with a color. */
+ #undef scan_chunk
+ #define scan_chunk chunk
+ private int
+ mem_mono_fill_rectangle(gx_device *dev, int x, int y, int w, int h,
+   gx_color_index color)
+ {	uint bit;
+ 	chunk right_mask;
+ 	byte fill;
+ 	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_fill(x >> 3, ((x + w + 7) >> 3) - (x >> 3));
+ 	check_rect();
+ 	setup_rect(dest_line, dest, offset);
+ #define write_loop(stat)\
+  { int line_count = h;\
+    declare_scan_line(ptr_line, ptr);\
+    ptr_line = dest_line;\
+    setup_scan_ptr(ptr_line, ptr, offset);\
+    do { stat; next_scan_line(ptr_line, ptr, offset); }\
+    while ( --line_count );\
+  }
+ #define write_partial(msk)\
+    if ( fill ) write_loop(*ptr |= msk)\
+    else write_loop(*ptr &= ~msk)
+ 	switch ( color )
+ 	   {
+ 	case 0: fill = mdev->invert; break;
+ 	case 1: fill = ~mdev->invert; break;
+ 	case gx_no_color_index: return 0;		/* transparent */
+ 	default: return -1;		/* invalid */
+ 	   }
+ 	bit = x & chunk_bit_mask;
+ 	if ( bit + w <= chunk_bits )
+ 	   {	/* Only one word */
+ 		right_mask = chunk_hi_bits(w) >> bit;
+ 	   }
+ 	else
+ 	   {	int byte_count;
+ 		if ( bit )
+ 		   {	chunk mask = chunk_all_bits >> bit;
+ 			write_partial(mask);
+ 			offset += chunk_bytes;
+ 			w += bit - chunk_bits;
+ 		   }
+ 		right_mask = chunk_hi_bits(w & chunk_bit_mask);
+ 		if ( (byte_count = (w >> 3) & -chunk_bytes) != 0 )
+ 		   {	write_loop(memset(ptr, fill, byte_count));
+ 			offset += byte_count;
+ 		   }
+ 	   }
+ 	if ( right_mask )
+ 		write_partial(right_mask);
+ 	return 0;
+ }
+ 
+ /* Copy a monochrome bitmap. */
+ #undef scan_chunk
+ #define scan_chunk chunk
+ private int
+ mem_mono_copy_mono(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	chunk *line;
+ 	int sleft, dleft;
+ 	uint mask, rmask;
+ 	uint invert, zmask, omask;
+ 	declare_scan_ptr(dest_line, dest, offset);
+ #define izero (int)zero
+ #define ione (int)one
+ 	if ( ione == izero )		/* vacuous case */
+ 		return mem_mono_fill_rectangle(dev, x, y, w, h, zero);
+ 	check_fault_copy_mono(x >> 3, ((x + w + 7) >> 3) - (x >> 3));
+ 	check_rect();
+ 	setup_rect(dest_line, dest, offset);
+ 	line = (chunk *)base + (sourcex >> log2_chunk_bits);
+ 	sleft = chunk_bits - (sourcex & chunk_bit_mask);
+ 	dleft = chunk_bits - (x & chunk_bit_mask);
+ 	mask = chunk_all_bits >> (chunk_bits - dleft);
+ 	if ( w < dleft )
+ 		mask -= mask >> w;
+ 	else
+ 		rmask = chunk_hi_bits((w - dleft) & chunk_bit_mask);
+ /* Macros for writing partial chunks. */
+ /* bits has already been inverted by xor'ing with invert. */
+ #define write_chunk_masked(ptr, bits, mask)\
+   *ptr = ((bits | ~mask | zmask) & *ptr | (bits & mask & omask))
+ #define write_chunk(ptr, bits)\
+   *ptr = ((bits | zmask) & *ptr | (bits & omask))
+ 	if ( mdev->invert )
+ 	   {	if ( izero != (int)gx_no_color_index ) zero ^= 1;
+ 		if ( ione != (int)gx_no_color_index ) one ^= 1;
+ 	   }
+ 	invert = (izero == 1 || ione == 0 ? -1 : 0);
+ 	zmask = (izero == 0 || ione == 0 ? 0 : -1);
+ 	omask = (izero == 1 || ione == 1 ? -1 : 0);
+ #undef izero
+ #undef ione
+ 	if ( sleft == dleft )		/* optimize the aligned case */
+ 	   {	w -= dleft;
+ 		while ( --h >= 0 )
+ 		   {	register chunk *bptr = line;
+ 			int count = w;
+ 			register chunk *optr = dest;
+ 			register uint bits = *bptr ^ invert;	/* first partial chunk */
+ 			write_chunk_masked(optr, bits, mask);
+ 			/* Do full chunks. */
+ 			while ( (count -= chunk_bits) >= 0 )
+ 			   {	bits = *++bptr ^ invert;
+ 				++optr;
+ 				write_chunk(optr, bits);
+ 			   }
+ 			/* Do last chunk */
+ 			if ( count > -chunk_bits )
+ 			   {	bits = *++bptr ^ invert;
+ 				++optr;
+ 				write_chunk_masked(optr, bits, rmask);
+ 			   }
+ 			next_scan_line(dest_line, dest, offset);
+ 			line = (chunk *)((byte *)line + raster);
+ 		   }
+ 	   }
+ 	else
+ 	   {	int skew = (sleft - dleft) & chunk_bit_mask;
+ 		int cskew = chunk_bits - skew;
+ 		while ( --h >= 0 )
+ 		   {	chunk *bptr = line;
+ 			int count = w;
+ 			chunk *optr = dest;
+ 			register int bits;
+ 			/* Do the first partial chunk */
+ 			if ( sleft >= dleft )
+ 			   {	bits = *bptr >> skew;
+ 			   }
+ 			else /* ( sleft < dleft ) */
+ 			   {	bits = *bptr++ << cskew;
+ 				if ( count > sleft )
+ 					bits += *bptr >> skew;
+ 			   }
+ 			bits ^= invert;
+ 			write_chunk_masked(optr, bits, mask);
+ 			count -= dleft;
+ 			optr++;
+ 			/* Do full chunks. */
+ 			while ( count >= chunk_bits )
+ 			   {	bits = *bptr++ << cskew;
+ 				bits += *bptr >> skew;
+ 				bits ^= invert;
+ 				write_chunk(optr, bits);
+ 				count -= chunk_bits;
+ 				optr++;
+ 			   }
+ 			/* Do last chunk */
+ 			if ( count > 0 )
+ 			   {	bits = *bptr++ << cskew;
+ 				if ( count > skew ) bits += *bptr >> skew;
+ 				bits ^= invert;
+ 				write_chunk_masked(optr, bits, rmask);
+ 			   }
+ 			next_scan_line(dest_line, dest, offset);
+ 			line = (chunk *)((byte *)line + raster);
+ 		   }
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a "color" bitmap.  Since "color" is the same as monochrome, */
+ /* this just reduces to copying a monochrome bitmap. */
+ private int
+ mem_mono_copy_color(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h)
+ {	return mem_mono_copy_mono(dev, base, sourcex, raster, x, y, w, h,
+ 	  (gx_color_index)0, (gx_color_index)1);
+ }
+ 
+ /* ------ Color (mapped or true) ------ */
+ 
+ /* Copy a rectangle of bytes from a source to a destination. */
+ #undef scan_chunk
+ #define scan_chunk byte
+ private int
+ copy_byte_rect(gx_device *dev, byte *source, int sraster,
+   int offset, int y, int w, int h)
+ {	declare_scan_line(dest_line, dest);
+ 	setup_scan(dest_line, dest, offset);
+ 	while ( h-- > 0 )
+ 	   {	memcpy(dest, source, w);
+ 		source += sraster;
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* ------ Mapped 8-bit color ------ */
+ 
+ /* Procedures */
+ declare_mem_map_procs(mem_mapped_map_rgb_color, mem_mapped_map_color_rgb);
+ declare_mem_procs(mem_mapped_copy_mono, mem_mapped_copy_color, mem_mapped_fill_rectangle);
+ 
+ /* The device descriptor. */
+ private gx_device_procs mem_mapped_procs =
+   mem_procs(mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
+     mem_mapped_copy_mono, mem_mapped_copy_color, mem_mapped_fill_rectangle);
+ 
+ /* The instance is public. */
+ gx_device_memory mem_mapped_color_device =
+   mem_device("image(8)", 8, mem_mapped_procs);
+ 
+ /* Convert x coordinate to byte offset in scan line. */
+ #undef x_to_byte
+ #define x_to_byte(x) (x)
+ 
+ /* Map a r-g-b color to a color index. */
+ /* This requires searching the palette. */
+ private gx_color_index
+ mem_mapped_map_rgb_color(gx_device *dev, ushort r, ushort g, ushort b)
+ {	register byte *pptr = mdev->palette;
+ 	int cnt = mdev->palette_size;
+ 	byte *which;
+ 	int best = 256*3;
+ 	while ( cnt-- > 0 )
+ 	   {	register int diff = *pptr - r;
+ 		if ( diff < 0 ) diff = -diff;
+ 		if ( diff < best )	/* quick rejection */
+ 		   {	int dg = pptr[1] - g;
+ 			if ( dg < 0 ) dg = -dg;
+ 			if ( (diff += dg) < best )	/* quick rejection */
+ 			   {	int db = pptr[2] - b;
+ 				if ( db < 0 ) db = -db;
+ 				if ( (diff += db) < best )
+ 					which = pptr, best = diff;
+ 			   }
+ 		   }
+ 		pptr += 3;
+ 	   }
+ 	return (gx_color_index)((which - mdev->palette) / 3);
+ }
+ 
+ /* Map a color index to a r-g-b color. */
+ private int
+ mem_mapped_map_color_rgb(gx_device *dev, gx_color_index color, ushort *prgb)
+ {	byte *pptr = mdev->palette + (int)color * 3;
+ 	prgb[0] = pptr[0];
+ 	prgb[1] = pptr[1];
+ 	prgb[2] = pptr[2];
+ 	return 0;
+ }
+ 
+ /* Fill a rectangle with a color. */
+ private int
+ mem_mapped_fill_rectangle(gx_device *dev,
+   int x, int y, int w, int h, gx_color_index color)
+ {	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_fill(x, w);
+ 	setup_rect(dest_line, dest, offset);
+ 	while ( h-- > 0 )
+ 	   {	memset(dest, (byte)color, w);
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a monochrome bitmap. */
+ private int
+ mem_mapped_copy_mono(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	byte *line;
+ 	int first_bit;
+ 	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_copy_mono(x, w);
+ 	setup_rect(dest_line, dest, offset);
+ 	line = base + (sourcex >> 3);
+ 	first_bit = 0x80 >> (sourcex & 7);
+ 	while ( h-- > 0 )
+ 	   {	register byte *pptr = dest;
+ 		byte *sptr = line;
+ 		register int sbyte = *sptr++;
+ 		register int bit = first_bit;
+ 		int count = w;
+ 		do
+ 		   {	if ( sbyte & bit )
+ 			   {	if ( one != gx_no_color_index )
+ 				  *pptr = (byte)one;
+ 			   }
+ 			else
+ 			   {	if ( zero != gx_no_color_index )
+ 				  *pptr = (byte)zero;
+ 			   }
+ 			if ( (bit >>= 1) == 0 )
+ 				bit = 0x80, sbyte = *sptr++;
+ 			pptr++;
+ 		   }
+ 		while ( --count > 0 );
+ 		line += raster;
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a color bitmap. */
+ private int
+ mem_mapped_copy_color(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h)
+ {	check_fault_copy_color(x, w);
+ 	check_rect();
+ 	return copy_byte_rect(dev, base + x_to_byte(sourcex), raster,
+ 		x_to_byte(x), y, x_to_byte(w), h);
+ }
+ 
+ /* ------ True (24- or 32-bit) color ------ */
+ 
+ /* Procedures */
+ declare_mem_map_procs(mem_true_map_rgb_color, mem_true_map_color_rgb);
+ 
+ /* The device descriptor. */
+ #define mem_true_procs(copy_mono, copy_color, fill_rectangle)\
+   mem_procs(mem_true_map_rgb_color, mem_true_map_color_rgb,\
+     copy_mono, copy_color, fill_rectangle)
+ 
+ /* The instance is public. */
+ #define mem_true_color_device(name, depth, procs)\
+ {	sizeof(gx_device_memory),\
+ 	&procs,				/* differs */\
+ 	name,				/* differs */\
+ 	0, 0,			/* x and y extent (filled in) */\
+ 	1, 1,			/* density (irrelevant) */\
+ 	1, 255, depth,			/* depth differs */\
+ 	0,			/* not open yet */\
+ 	identity_matrix_body,	/* initial matrix (filled in) */\
+ 	0,			/* raster (filled in) */\
+ 	(byte *)0,		/* base (filled in) */\
+ 	(byte **)0,		/* line_ptrs (filled in by 'open') */\
+ 	mem_no_fault_proc,	/* default bring_in_proc */\
+ 	0,			/* invert (unused) */\
+ 	0, (byte *)0		/* palette (unused) */\
+ }
+ 
+ /* We want the bytes of a color always to be in the order -,r,g,b, */
+ /* but we want to manipulate colors as longs.  This requires careful */
+ /* handling to be byte-order independent. */
+ #define color_byte(cx,i) (((byte *)&(cx))[i])
+ 
+ /* Map a r-g-b color to a color index. */
+ private gx_color_index
+ mem_true_map_rgb_color(gx_device *dev, ushort r, ushort g, ushort b)
+ {	gx_color_index color = 0;
+ 	color_byte(color, 1) = r;
+ 	color_byte(color, 2) = g;
+ 	color_byte(color, 3) = b;
+ 	return color;
+ }
+ 
+ /* Map a color index to a r-g-b color. */
+ private int
+ mem_true_map_color_rgb(gx_device *dev, gx_color_index color, ushort *prgb)
+ {	prgb[0] = color_byte(color, 1);
+ 	prgb[1] = color_byte(color, 2);
+ 	prgb[2] = color_byte(color, 3);
+ 	return 0;
+ }
+ 
+ /* ------ 24-bit color ------ */
+ /* 24-bit takes less space than 32-bit, but is slower. */
+ 
+ /* Procedures */
+ declare_mem_procs(mem_true24_copy_mono, mem_true24_copy_color, mem_true24_fill_rectangle);
+ 
+ /* The device descriptor. */
+ private gx_device_procs mem_true24_procs =
+   mem_true_procs(mem_true24_copy_mono, mem_true24_copy_color,
+     mem_true24_fill_rectangle);
+ gx_device_memory mem_true24_color_device =
+   mem_device("image(24)", 24, mem_true24_procs);
+ 
+ /* Convert x coordinate to byte offset in scan line. */
+ #undef x_to_byte
+ #define x_to_byte(x) ((x) * 3)
+ 
+ /* Unpack a color into its bytes. */
+ #define declare_unpack_color(r, g, b, color)\
+ 	byte r = color_byte(color, 1);\
+ 	byte g = color_byte(color, 2);\
+ 	byte b = color_byte(color, 3)
+ #define put3(ptr, r, g, b)\
+ 	*ptr++ = r, *ptr++ = g, *ptr++ = b
+ 
+ /* Fill a rectangle with a color. */
+ private int
+ mem_true24_fill_rectangle(gx_device *dev,
+   int x, int y, int w, int h, gx_color_index color)
+ {	declare_unpack_color(r, g, b, color);
+ 	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_fill(x * 3, w * 3);
+ 	setup_rect(dest_line, dest, offset);
+ 	while ( h-- > 0 )
+ 	   {	register int cnt = w;
+ 		register byte *pptr = dest;
+ 		do { put3(pptr, r, g, b); } while ( --cnt > 0 );
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a monochrome bitmap. */
+ private int
+ mem_true24_copy_mono(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	byte *line;
+ 	int first_bit;
+ 	declare_unpack_color(r0, g0, b0, zero);
+ 	declare_unpack_color(r1, g1, b1, one);
+ 	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_copy_mono(x * 3, w * 3);
+ 	setup_rect(dest_line, dest, offset);
+ 	line = base + (sourcex >> 3);
+ 	first_bit = 0x80 >> (sourcex & 7);
+ 	while ( h-- > 0 )
+ 	   {	register byte *pptr = dest;
+ 		byte *sptr = line;
+ 		register int sbyte = *sptr++;
+ 		register int bit = first_bit;
+ 		int count = w;
+ 		do
+ 		   {	if ( sbyte & bit )
+ 			   {	if ( one != gx_no_color_index )
+ 				  put3(pptr, r1, g1, b1);
+ 			   }
+ 			else
+ 			   {	if ( zero != gx_no_color_index )
+ 				  put3(pptr, r0, g0, b0);
+ 			   }
+ 			if ( (bit >>= 1) == 0 )
+ 				bit = 0x80, sbyte = *sptr++;
+ 		   }
+ 		while ( --count > 0 );
+ 		line += raster;
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a color bitmap. */
+ private int
+ mem_true24_copy_color(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h)
+ {	check_fault_copy_color(x * 3, w * 3);
+ 	check_rect();
+ 	return copy_byte_rect(dev, base + x_to_byte(sourcex), raster,
+ 		x_to_byte(x), y, x_to_byte(w), h);
+ }
+ 
+ /* ------ 32-bit color ------ */
+ 
+ /* Procedures */
+ declare_mem_procs(mem_true32_copy_mono, mem_true32_copy_color, mem_true32_fill_rectangle);
+ 
+ /* The device descriptor. */
+ private gx_device_procs mem_true32_procs =
+   mem_true_procs(mem_true32_copy_mono, mem_true32_copy_color,
+     mem_true32_fill_rectangle);
+ gx_device_memory mem_true32_color_device =
+   mem_device("image(32)", 32, mem_true32_procs);
+ 
+ /* Convert x coordinate to byte offset in scan line. */
+ #undef x_to_byte
+ #define x_to_byte(x) ((x) << 2)
+ 
+ /* Fill a rectangle with a color. */
+ private int
+ mem_true32_fill_rectangle(gx_device *dev,
+   int x, int y, int w, int h, gx_color_index color)
+ {	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_fill(x << 2, w << 2);
+ 	setup_rect(dest_line, dest, offset);
+ 	while ( h-- > 0 )
+ 	   {	gx_color_index *pptr = (gx_color_index *)dest;
+ 		int cnt = w;
+ 		do { *pptr++ = color; } while ( --cnt > 0 );
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a monochrome bitmap. */
+ private int
+ mem_true32_copy_mono(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	byte *line;
+ 	int first_bit;
+ 	declare_scan_ptr(dest_line, dest, offset);
+ 	check_fault_copy_mono(x << 2, w << 2);
+ 	setup_rect(dest_line, dest, offset);
+ 	line = base + (sourcex >> 3);
+ 	first_bit = 0x80 >> (sourcex & 7);
+ 	while ( h-- > 0 )
+ 	   {	register gx_color_index *pptr = (gx_color_index *)dest;
+ 		byte *sptr = line;
+ 		register int sbyte = *sptr++;
+ 		register int bit = first_bit;
+ 		int count = w;
+ 		do
+ 		   {	if ( sbyte & bit )
+ 			   {	if ( one != gx_no_color_index )
+ 				  *pptr = one;
+ 			   }
+ 			else
+ 			   {	if ( zero != gx_no_color_index )
+ 				  *pptr = zero;
+ 			   }
+ 			if ( (bit >>= 1) == 0 )
+ 				bit = 0x80, sbyte = *sptr++;
+ 			pptr++;
+ 		   }
+ 		while ( --count > 0 );
+ 		line += raster;
+ 		next_scan_line(dest_line, dest, offset);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a color bitmap. */
+ private int
+ mem_true32_copy_color(gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h)
+ {	check_fault_copy_color(x << 2, w << 2);
+ 	check_rect();
+ 	return copy_byte_rect(dev, base + x_to_byte(sourcex), raster,
+ 		x_to_byte(x), y, x_to_byte(w), h);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevprn.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevprn.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevprn.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,205 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevprn.c */
+ /* Generic printer support for Ghostscript */
+ #include "gdevprn.h"
+ 
+ /* ------ Virtual memory buffer support ------ */
+ 
+ /* Bring-in procedure.  The first argument is &prn_dev->mem, */
+ /* from which we have to find &prn_dev->vmem. */
+ private int
+ prn_bring_in_rect(gx_device_memory *mdev, int x, int y, int w, int h,
+   int writing)
+ {	/* "mdev + 1" because vmem follows mem in the device_printer struct */
+ 	return vmem_bring_in_rect((gx_vmem *)(mdev + 1), x, y, w, h, writing);
+ }
+ 
+ /* Generic initialization for the printer device. */
+ /* Specific devices may wish to extend this. */
+ int
+ gdev_prn_open(gx_device *dev)
+ {	ulong space;
+ 	byte *base;
+ 	prn_dev->mem = mem_mono_device;
+ 	/* In the initial implementation, */
+ 	/* we buffer the entire page in memory. */
+ 	prn_dev->mem.width = dev->width;
+ 	prn_dev->mem.height = dev->height;
+ 	if ( prn_dev->vmem_space )	/* only allocate pointer table */
+ 		space = dev->height * sizeof(byte **);
+ 	else				/* allocate entire buffer */
+ 	   {	space = gx_device_memory_bitmap_size(&prn_dev->mem);
+ 		if ( space > (uint)(-4) ) return -1;	/* can't allocate */
+ 	   }
+ 	base = (byte *)gs_malloc((uint)space, 1, "printer buffer");
+ 	if ( base == 0 ) return -1;
+ 	prn_dev->mem.base = base;
+ 	if ( (*prn_dev->mem.procs->open_device)((gx_device *)&prn_dev->mem) < 0 )
+ 		return -1;
+ 	if ( prn_dev->vmem_space )
+ 	   {	int line_size = (prn_dev->width + 7) >> 3;
+ 		prn_dev->mem.bring_in_proc = prn_bring_in_rect;
+ 		vmem_init(&prn_dev->vmem, (char **)prn_dev->mem.line_ptrs,
+ 		  line_size, prn_dev->height, 0,
+ 		  (int)(prn_dev->x_pixels_per_inch / 8 * line_size),
+ 		  max(prn_dev->vmem_space, line_size + 4),
+ 		  gs_malloc, gs_free);
+ 	   }
+ 	printf("Printing in memory, please be patient.\n");
+ 	return 0;
+ }
+ 
+ /* Generic closing for the printer device. */
+ /* Specific devices may wish to extend this. */
+ int
+ gdev_prn_close(gx_device *dev)
+ {	return ( prn_dev->vmem_space ? vmem_close(&prn_dev->vmem) : 0 );
+ }
+ 
+ /* Map a r-g-b "color" to a printer color: 0 = white, 1 = black. */
+ gx_color_index
+ gdev_prn_map_rgb_color(gx_device *dev, ushort r, ushort g, ushort b)
+ {	return ((r | g | b) ? 0 : 1);
+ }
+ 
+ /* Map the printer color back to black or white */
+ int
+ gdev_prn_map_color_rgb(gx_device *dev, gx_color_index color, ushort *prgb)
+ {	prgb[0] = prgb[1] = prgb[2] = (color ? 0 : 1);
+ 	return 0;
+ }
+ 
+ /* Delegate the painting operations to the memory device. */
+ int
+ gdev_prn_fill_rectangle(gx_device *dev, int x, int y, int w, int h,
+   gx_color_index color)
+ {	return (*prn_dev->mem.procs->fill_rectangle)
+ 	  ((gx_device *)&prn_dev->mem, x, y, w, h, color);
+ }
+ int
+ gdev_prn_copy_mono(gx_device *dev, byte *data,
+   int dx, int raster, int x, int y, int w, int h,
+   gx_color_index zero, gx_color_index one)
+ {	return (*prn_dev->mem.procs->copy_mono)
+ 	  ((gx_device *)&prn_dev->mem, data, dx, raster, x, y, w, h, zero, one);
+ }
+ int
+ gdev_prn_copy_color(gx_device *dev, byte *data,
+   int dx, int raster, int x, int y, int w, int h)
+ {	return (*prn_dev->mem.procs->copy_color)
+ 	  ((gx_device *)&prn_dev->mem, data, dx, raster, x, y, w, h);
+ }
+ 
+ /* ------ Driver services ------ */
+ 
+ /* Open the printer device. */
+ int
+ gdev_prn_open_printer(gx_device *dev)
+ {	if ( prn_dev->write_to_prn )
+ 	   {
+ #ifdef __MSDOS__
+ 		int fno = fileno(stdprn);
+ 		int ctrl = ioctl(fno, 0);
+ 		ioctl(fno, 1, (ctrl | 0x20) & 0xff); /* no ^Z intervention! */
+ 		prn_dev->file = stdprn;
+ 		printf("Printing from memory to printer.\n");
+ #else
+ 		printf("Can't print directly from memory to printer yet.\n");
+ #endif
+ 	   }
+ 	else
+ 	   {	char *fname = prn_dev->fname;
+ 		strcpy(fname, SCRATCH_TEMPLATE);
+ 		mktemp(fname);
+ 		prn_dev->file = fopen(fname, "wb+");
+ 		if ( prn_dev->file == NULL )
+ 		   {	eprintf1("could not open the printer file %s!\n", fname);
+ 			return -1;
+ 		   }
+ 		printf("Printing from memory to file %s.\n", fname);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Transpose an 8 x 8 block of bits.  line_size is the raster of */
+ /* the input data.  dist is the distance between output bytes. */
+ /* Not all printers need this, but some of the common ones do. */
+ void
+ gdev_prn_transpose_8x8(byte *inp, register int line_size, byte *outp,
+   register int dist)
+ {	byte *inp4 = inp + (line_size << 2);
+ 	register ushort ae = ((ushort)*inp << 8) + *inp4;
+ 	register ushort bf = ((ushort)*(inp += line_size) << 8) +
+ 						*(inp4 += line_size);
+ 	register ushort cg = ((ushort)*(inp += line_size) << 8) +
+ 						*(inp4 += line_size);
+ 	register ushort dh = ((ushort)inp[line_size] << 8) +
+ 						inp4[line_size];
+ 	register ushort temp;
+ 
+ /* Transpose blocks of 4 x 4 */
+ #define transpose4(r)\
+   r = (r & 0xf00f) + ((r & 0x0f00) >> 4) + ((r & 0x00f0) << 4)
+ 	transpose4(ae);
+ 	transpose4(bf);
+ 	transpose4(cg);
+ 	transpose4(dh);
+ 
+ /* Transpose blocks of 2 x 2 */
+ #define transpose(r,s,mask,shift)\
+   temp = s;\
+   s = (s & mask) + ((r & mask) << shift);\
+   r = (r & ~mask) + ((temp >> shift) & mask)
+ 	transpose(ae, cg, 0x3333, 2);
+ 	transpose(bf, dh, 0x3333, 2);
+ 
+ /* Transpose blocks of 1 x 1 */
+ 	transpose(ae, bf, 0x5555, 1);
+ 	transpose(cg, dh, 0x5555, 1);
+ 
+ 	*outp = ae >> 8;
+ 	outp += dist;
+ 	*outp = bf >> 8;
+ 	outp += dist;
+ 	*outp = cg >> 8;
+ 	outp += dist;
+ 	*outp = dh >> 8;
+ 	outp += dist;
+ 	*outp = (byte)ae;		/* low-order byte */
+ 	outp += dist;
+ 	*outp = (byte)bf;		/* ditto */
+ 	outp += dist;
+ 	*outp = (byte)cg;		/* ditto */
+ 	outp += dist;
+ 	*outp = (byte)dh;		/* ditto */
+ }
+ 
+ /* Flush the printer output from the scratch file, */
+ /* and close the printer device. */
+ int
+ gdev_prn_close_printer(gx_device *dev)
+ {	if ( !prn_dev->write_to_prn )
+ 	   {	fclose(prn_dev->file);
+ 		printf("To print the page, copy the file %s to the printer\n",
+ 			prn_dev->fname);
+ 	   }
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevprn.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevprn.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevprn.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,166 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevprn.h */
+ /* Common header file for memory-buffered black-and-white printers */
+ 
+ /*
+  * This header file is actually used in two different ways.
+  * gdevprn.c includes it without defining DRIVER.
+  * The individual drivers include it with DRIVER defined.
+  * When DRIVER is defined, this file generates actual data structures.
+  *
+  * >>>>>> NOTE: in addition to DRIVER, the printer driver must #define <<<<<<
+  * >>>>>> the following before #include'ing this file: <<<<<<
+  * >>>>>> GS_PRN_DEVICE, DEVICE_NAME, <<<<<<
+  * >>>>>> PAGE_WIDTH_10THS, PAGE_HEIGHT_10THS, X_DPI, Y_DPI, <<<<<<
+  * >>>>>> PRN_OPEN, PRN_CLOSE, PRN_OUTPUT_PAGE. <<<<<<
+  */
+ 
+ #ifdef __MSDOS__
+ #  include <io.h>			/* for ioctl */
+ #endif
+ #include "string_.h"
+ #include "gs.h"
+ #include "gxbitmap.h"
+ #include "gsmatrix.h"			/* for gxdevice.h */
+ #include "gxdevice.h"
+ #include "gxdevmem.h"
+ #include "gvirtmem.h"
+ 
+ typedef struct gx_device_s gx_device;
+ 
+ /****** ENABLE OR DISABLE VIRTUAL MEMORY ******/
+ #ifdef __MSDOS__
+ #  define VMEM_SPACE 20000
+ #else
+ #  define VMEM_SPACE 0
+ #endif
+ 
+ /****** ENABLE OR DISABLE DIRECT WRITING TO PRINTER ******/
+ #ifdef __MSDOS__
+ #  define WRITE_TO_PRN 1
+ #else
+ #  define WRITE_TO_PRN 0
+ #endif
+ 
+ /* Define the scratch file name template for mktemp */
+ #ifdef __MSDOS__
+ #  define SCRATCH_TEMPLATE "_temp_XXXXXX"
+ #else
+ #  define SCRATCH_TEMPLATE "/tmp/prn_XXXXXX"
+ #endif
+ 
+ /* See gxdevice.h for the definitions of the procedures. */
+ 
+ gx_color_index
+   gdev_prn_map_rgb_color(P4(gx_device *, ushort, ushort, ushort));
+ 
+ int gdev_prn_map_color_rgb(P3(gx_device *, gx_color_index, ushort *));
+ 
+ int
+   gdev_prn_fill_rectangle(P6(gx_device *, int, int, int, int,
+     gx_color_index)),
+   gdev_prn_copy_mono(P10(gx_device *, byte *, int, int, int, int, int, int,
+     gx_color_index, gx_color_index)),
+   gdev_prn_copy_color(P8(gx_device *, byte *, int, int, int, int, int, int));
+ 
+ /* The device descriptor */
+ typedef struct gx_device_printer_s gx_device_printer;
+ struct gx_device_printer_s {
+ 	gx_device_common;
+ 	/* The following two items must be set before calling */
+ 	/* the device open routine. */
+ 	long vmem_space;		/* amount of space for vmem */
+ 	int write_to_prn;	/* if true, write directly to printer */
+ 	gx_device_memory mem;		/* buffer */
+ 	gx_vmem vmem;			/* virtual memory instance */
+ 	char fname[30];			/* scratch file name, */
+ 					/* strlen(SCRATCH_TEMPLATE)+1 */
+ 	FILE *file;			/* scratch file */
+ };
+ 
+ /* Macro for casting gx_device argument */
+ #define prn_dev ((gx_device_printer *)dev)
+ 
+ /* Common procedures defined in gdevprn.c */
+ int gdev_prn_open(P1(gx_device *));
+ int gdev_prn_close(P1(gx_device *));
+ int gdev_prn_open_printer(P1(gx_device *));
+ void gdev_prn_transpose_8x8(P4(byte *, int, byte *, int));
+ int gdev_prn_close_printer(P1(gx_device *));
+ 
+ /****** The remainder of this file is only included in the ******/
+ /****** actual driver, not in gdevprn.c. ******/
+ 
+ #ifdef DRIVER
+ 
+ /* Device-specific procedures. */
+ /* The first two aren't declared private, because they might actually be */
+ /* the generic procedures gdev_prn_open or gdev_prn_close. */
+ int PRN_OPEN(P1(gx_device *));
+ int PRN_CLOSE(P1(gx_device *));
+ private int PRN_OUTPUT_PAGE(P1(gx_device *));
+ 
+ /* Computed parameters */
+ /*
+  * The following should be
+  *	#define LINE_WIDTH ((int)(PAGE_WIDTH_INCHES*X_DPI))
+  * but some compilers (the Ultrix 3.X pcc compiler and the HPUX compiler)
+  * can't cast a computed float to an int.  That's why we specify
+  * the page height and width in inches/10 instead of inches.
+  */
+ #define LINE_WIDTH (PAGE_WIDTH_10THS * X_DPI / 10)
+ #define PAGE_HEIGHT (PAGE_HEIGHT_10THS * Y_DPI / 10)
+ #define LINE_SIZE ((LINE_WIDTH + 7) / 8)
+ 
+ static gx_device_procs prn_procs = {
+ 	PRN_OPEN,
+ 	gx_default_get_initial_matrix,
+ 	gx_default_sync_output,
+ 	PRN_OUTPUT_PAGE,
+ 	PRN_CLOSE,
+ 	gdev_prn_map_rgb_color,
+ 	gdev_prn_map_color_rgb,
+ 	gdev_prn_fill_rectangle,
+ 	gx_default_tile_rectangle,
+ 	gdev_prn_copy_mono,
+ 	gdev_prn_copy_color,
+ 	gx_default_draw_line,
+ 	gx_default_fill_trapezoid,
+ 	gx_default_tile_trapezoid
+ };
+ 
+ gx_device_printer GS_PRN_DEVICE = {
+ 	sizeof(gx_device_printer),
+ 	&prn_procs,
+ 	DEVICE_NAME,
+ 	LINE_WIDTH,	/* width */
+ 	PAGE_HEIGHT,	/* height */
+ 	X_DPI,
+ 	Y_DPI,
+ 	0,		/* set for BLACK and WHITE device */
+ 	1,		/* rgb_max_value */
+ 	1,		/* bits per color pixel */
+ 	0,		/* not initialized yet */
+ 	VMEM_SPACE,
+ 	WRITE_TO_PRN
+ };
+ 
+ #endif					/* ifdef DRIVER */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevs.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevs.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevs.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,54 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevs.c */
+ /* Installed device table for Ghostscript */
+ /* We don't really need the definition of gx_device, because we only */
+ /* declare pointers to devices, but some compilers seem to want it.... */
+ #include "gs.h"
+ #include "gsmatrix.h"			/* for gxdevice.h */
+ #include "gxbitmap.h"
+ #include "gxdevice.h"
+ 
+ typedef struct gx_device_s gx_device;
+ 
+ /*
+  * The Ghostscript makefile generates the file gdevs.h, which consists of
+  * lines of the form
+  *	d(gs_xxx_device)
+  * for each installed device.  We include this file twice, once to declare
+  * the devices as extern, and once to generate the table of pointers.
+  */
+ 
+ #define d(dev) extern gx_device dev;
+ #include "gdevs.h"
+ #undef d
+ 
+ gx_device *gx_device_list[] = {
+ #define d(dev) &dev,
+ #include "gdevs.h"
+ #undef d
+ 	0
+ };
+ 
+ /* Some C compilers insist on having executable code in every file, so: */
+ private void
+ gdevs_dummy()
+ {
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevs.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevs.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevs.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1 ----
+ 


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevsnfb.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevsnfb.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevsnfb.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,117 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevsnfb.c */
+ /* Sony News frame buffer driver for GhostScript */
+ 
+ #define GS_PRN_DEVICE gs_sonyfb_device
+ #define DEVICE_NAME "sonyfb"
+ 
+ #define PAGE_WIDTH_10THS	(102.4)
+ #define PAGE_HEIGHT_10THS	(103.2)
+ 
+ #define X_DPI 100
+ #define Y_DPI 100
+ 
+ #define PRN_OPEN	sonyfb_prn_open
+ #define PRN_CLOSE	sonyfb_prn_close
+ #define PRN_OUTPUT_PAGE	sonyfb_output_page
+ 
+ #define DRIVER				/* see gdevprn.h */
+ #include "gdevprn.h"
+ /*#include <sys/types.h> problems with ushort! */
+ typedef	char *	caddr_t;
+ typedef	long	off_t;
+ #include <sys/uio.h>
+ #include <newsiop/framebuf.h>
+ 
+ private int fb_file = -1;
+ sPrimRect prect;
+ 
+ private int
+ sonyfb_prn_open(gx_device *dev)
+ {
+   sScrType stype;
+ 
+   if(fb_file < 0)
+     if((fb_file = open("/dev/fb", 2)) < 0)
+       perror("open failed");
+     else
+       if(ioctl(fb_file, FBIOCGETSCRTYPE, &stype) < 0)
+ 	perror("ioctl failed");
+       else
+ 	prect.rect = stype.visiblerect;
+ 
+   return gdev_prn_open(dev);
+ }
+ 
+ private int
+ sonyfb_prn_close(gx_device *dev)
+ {
+   if(fb_file >= 0)
+     {
+       close(fb_file);
+       fb_file = -1;
+     }
+   return gdev_prn_close(dev);
+ }
+ 
+ #define FRAME_WIDTH	1024
+ 
+ /* Send the page to the printer. */
+ private int
+ sonyfb_output_page(gx_device *dev)
+ {
+   int l, i, byte_width, height;
+   unsigned char *bm, *fbs, *fb;
+ 
+   byte_width = (dev->width + 7) / 8;
+   height = dev->height;
+   bm	 = (typeof(bm))prn_dev->mem.base;
+ 
+   prect.refPoint.x = 0;
+   prect.refPoint.y = 0;
+   prect.ptnRect = prect.rect;
+   
+   prect.ptnBM.type  = BM_MEM;
+   prect.ptnBM.depth = 1;
+   prect.ptnBM.width = (byte_width + 1) / 2;
+   prect.ptnBM.rect.origin.x = 0;
+   prect.ptnBM.rect.origin.y = 0;
+   prect.ptnBM.rect.extent.x = byte_width * 8; /* width in 16bit words */
+   prect.ptnBM.rect.extent.y = height;
+   prect.ptnBM.base = (typeof(prect.ptnBM.base))bm;
+   
+   prect.fore_color = 1;
+   prect.aux_color = 0;
+   prect.planemask = FB_PLANEALL;
+   prect.transp = 0;
+   prect.func = BF_S;
+   prect.clip = prect.rect;
+   prect.drawBM.type  = BM_FB;
+   prect.drawBM.depth = 1;
+   prect.drawBM.width = (prect.rect.extent.x + 15) / 16;
+   prect.drawBM.rect = prect.rect;
+   prect.drawBM.base = 0;
+   
+   if(ioctl(fb_file, FBIOCRECTANGLE, &prect) < 0)
+     perror("rect ioctl failed");
+ 
+   return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevsun.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevsun.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevsun.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,227 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevsun.c */
+ /* (monochrome) SunView driver for GhostScript library */
+ #include <suntool/sunview.h>
+ #include <suntool/canvas.h>
+ #include <stdio.h>
+ /* Hack to get around the fact that something in the SunView library */
+ /* defines uint and ushort.... */
+ #  define uint _uint
+ #  define ushort _ushort
+ #include "gx.h"			/* for gx_bitmap; includes std.h */
+ #  undef _uint
+ #  undef _ushort
+ #include "gsmatrix.h"			/* needed for gxdevice.h */
+ #include "gxdevice.h"
+ typedef struct gx_device_s gx_device;
+ 
+ #ifndef DEFAULT_DPI
+ #  define DEFAULT_DPI 75		/* Sun standard monitor */
+ #endif
+ 
+ /* Procedures */
+ int sun_open(P1(gx_device *));
+ int sun_close(P1(gx_device *));
+ int sun_sync(P1(gx_device *));
+ int sun_fill_rectangle(P6(gx_device *, int, int, int, int, gx_color_index));
+ int sun_copy_mono(P10(gx_device *, byte *, int, int, int, int, int, int,
+   gx_color_index, gx_color_index));
+ int sun_copy_color(P8(gx_device *, byte *, int, int, int, int, int, int));
+ int sun_draw_line(P6(gx_device *, int, int, int, int, gx_color_index));
+ 
+ /* The device descriptor */
+ private gx_device_procs sun_procs = {
+ 	sun_open,
+ 	gx_default_get_initial_matrix,
+ 	sun_sync,
+ 	gx_default_output_page,
+ 	sun_close,
+ 	gx_default_map_rgb_color,
+ 	gx_default_map_color_rgb,
+ 	sun_fill_rectangle,
+ 	gx_default_tile_rectangle,
+ 	sun_copy_mono,
+ 	sun_copy_color,
+ 	sun_draw_line,
+ 	gx_default_fill_trapezoid,
+ 	gx_default_tile_trapezoid
+ };
+ 
+ /* Define the SunView device */
+ typedef struct gx_device_sun {
+ 	gx_device_common;
+ 	Frame frame;
+ 	Canvas canvas;
+ 	Pixwin *pw;
+ 	struct mpr_data mpr;
+ 	Pixrect	pr;
+ } gx_device_sun;
+ 
+ /* The instance is public. */
+ gx_device_sun gs_sunview_device = {
+ 	sizeof(gx_device_sun),
+ 	&sun_procs,
+ 	"sunview",
+  	(int)(8.5*DEFAULT_DPI), (int)(11*DEFAULT_DPI),	/* x and y extent */
+  	DEFAULT_DPI, DEFAULT_DPI,	/* x and y density */
+ 		/* Following parameters are initialized for monochrome */
+ 	0,			/* has color */
+ 	1,			/* max r-g-b value */
+ 	1,			/* bits per color pixel */
+  	0,			/* connection not initialized */
+ 		/* End of monochrome/color parameters */
+ };
+ 
+ #define x_device gs_sunview_device	/* just an abbreviation */
+ 
+ /* Macro for casting gx_device argument */
+ #define xdev ((gx_device_sun *)dev)
+ 
+ /* Macro to validate arguments */
+ #define check_rect()\
+ 	if ( w <= 0 || h <= 0 ) return 0;\
+ 	if ( x < 0 || x > xdev->width - w || y < 0 || y > xdev->height - h )\
+ 		return -1
+ 
+ void
+ sun_window_create(int *argc_ptr, char **argv)
+ {
+ 	x_device.frame =
+ 		window_create(NULL, FRAME, FRAME_LABEL, "ghostscript",
+ 					FRAME_ARGC_PTR_ARGV, argc_ptr, argv, 0);
+ }
+ 
+ int
+ sun_open(register gx_device *dev)
+ {
+ #ifdef gs_DEBUG
+ if ( gs_debug['X'] )
+ 	{ extern int _Xdebug;
+ 	  _Xdebug = 1;
+ 	}
+ #endif
+ 	if (xdev->frame == (Frame)0)
+ 	    xdev->frame =
+ 		window_create(NULL, FRAME, FRAME_LABEL, "ghostscript", 0);
+ 	xdev->canvas = window_create(xdev->frame, CANVAS,
+ 			CANVAS_AUTO_EXPAND,		FALSE,
+ 			CANVAS_AUTO_SHRINK,		FALSE,
+ 			CANVAS_WIDTH,			xdev->width,
+ 			CANVAS_HEIGHT,			xdev->height,
+ 			WIN_VERTICAL_SCROLLBAR,		scrollbar_create(0),
+ 			WIN_HORIZONTAL_SCROLLBAR,	scrollbar_create(0),
+ 			0);
+ 	xdev->pw = canvas_pixwin(xdev->canvas);
+ 	window_set(xdev->frame, WIN_SHOW, TRUE, 0);
+ 	(void) notify_do_dispatch();
+ 	(void) notify_dispatch();
+ 	return 0;
+ }
+ 
+ /* Close the device. */
+ int
+ sun_close(gx_device *dev)
+ {	window_destroy(xdev->frame);
+ 	xdev->frame = (Frame)0;
+ 	xdev->canvas = (Canvas)0;
+ 	xdev->pw = (Pixwin *)0;
+ 	return 0;
+ }
+ 
+ /* Synchronize the display with the commands already given */
+ int
+ sun_sync(register gx_device *dev)
+ {	(void) notify_dispatch();
+ 	return 0;
+ }
+ 
+ /* Fill a rectangle with a color. */
+ int
+ sun_fill_rectangle(register gx_device *dev,
+   int x, int y, int w, int h, gx_color_index color)
+ {	check_rect();
+ 	if ( color != gx_no_color_index )
+ 		pw_write(xdev->pw, x, y, w, h, (color ? PIX_CLR : PIX_SET),
+ 			(Pixrect *)0, 0, 0);
+ 	(void) notify_dispatch();
+ 	return 0;
+ }
+ 
+ /* Copy a monochrome bitmap. */
+ int
+ sun_copy_mono(register gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	static int optab[3][3] = {
+ 		PIX_DST,	PIX_SRC|PIX_DST, PIX_NOT(PIX_SRC)&PIX_DST,
+ 		PIX_NOT(PIX_SRC)|PIX_DST, PIX_SET,	PIX_NOT(PIX_SRC),
+ 		PIX_SRC&PIX_DST,	PIX_SRC,	PIX_CLR,
+ 	};
+ 	int op;
+ 	register int i;
+ 	extern struct pixrectops mem_ops;
+ 
+ 	check_rect();
+ 	if ((op = optab[zero+1][one+1]) == PIX_DST)
+ 		return 0;
+ 	xdev->pr.pr_ops = &mem_ops;
+ 	xdev->pr.pr_width = w + sourcex + 8;
+ 	xdev->pr.pr_height = h;
+ 	xdev->pr.pr_depth = 1;
+ 	xdev->pr.pr_data = (caddr_t)&(xdev->mpr);
+ 	if ((raster & 1) == 0) {
+ 		xdev->mpr.md_linebytes = raster;
+ 		xdev->mpr.md_image = (short *)((int)base & ~1);
+ 		pw_write(xdev->pw, x, y, w, h, op, &(xdev->pr), 
+ 			((int)base & 1) ? sourcex + 8 : sourcex, 0);
+ 	} else {
+ 		xdev->pr.pr_height = 1;
+ 		for (i = 0; i < h; i++) {
+ 			xdev->mpr.md_linebytes = raster;
+ 			xdev->mpr.md_image = (short *)((int)base & ~1);
+ 			pw_write(xdev->pw, x, y, w, 1, op, &(xdev->pr), 
+ 				((int)base & 1) ? sourcex + 8 : sourcex, 0);
+ 			base += raster;
+ 			y++;
+ 		}
+ 	}
+ 	(void) notify_dispatch();
+ 	return 0;
+ }
+ 
+ /* Copy a "color" bitmap.  Since "color" is the same as monochrome, */
+ /* this just reduces to copying a monochrome bitmap. */
+ int
+ sun_copy_color(register gx_device *dev, byte *base, int sourcex, int raster,
+   int x, int y, int w, int h)
+ {	return sun_copy_mono(dev, base, sourcex, raster, x, y, w, h,
+ 	  (gx_color_index)0, (gx_color_index)1);
+ }
+ 
+ /* Draw a line */
+ int
+ sun_draw_line(register gx_device *dev,
+   int x0, int y0, int x1, int y1, gx_color_index color)
+ {	if ( color != gx_no_color_index )
+ 		pw_vector(xdev->pw, x0, y0, x1, y1,
+ 			  (color ? PIX_CLR : PIX_SET), 0);
+ 	(void) notify_dispatch();
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevvga.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevvga.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevvga.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,29 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevvga.h */
+ /* Parameters for VGA driver for Ghostscript */
+ /* This file must precede gdevpcfb.h. */
+ 
+ #define DEVICE_STRUCT_NAME gs_vga_device
+ #define DEVICE_NAME "vga"
+ #define FB_RASTER 80
+ #define SCREEN_HEIGHT 480
+ #define SCREEN_ASPECT_RATIO 1.0
+ #define VIDEO_MODE 0x12


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevx.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevx.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevx.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,997 ----
+ /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevx.c */
+ /* X Windows driver for GhostScript library */
+ /* The X include files include <sys/types.h>, which, on some machines */
+ /* at least, define byte, uint, ushort, and ulong, which std.h also defines. */
+ /* We have to shuffle the order of includes to make this all work. */
+ /* First we arrange things so that std.h defines _byte, _uint, _ushort, */
+ /* and _ulong instead of (our own) byte, uint, ushort, and ulong. */
+ #  define byte _byte
+ #  define uint _uint
+ #  define ushort _ushort
+ #  define ulong _ulong
+ #include "gx.h"			/* for gx_bitmap; includes std.h */
+ #include "malloc_.h"
+ #include "memory_.h"
+ #include "gsmatrix.h"			/* needed for gxdevice.h */
+ #include "gxbitmap.h"
+ #include "gxdevice.h"
+ #  undef byte
+ #  undef uint
+ #  undef ushort
+ #  undef ulong
+ /* Now we can include the X files. */
+ #include "gdevx.h"
+ 
+ typedef struct gx_device_s gx_device;
+ 
+ /* Flags for patching around bugs in the X library */
+ #define use_XPutImage 1
+ #define use_XSetTile 1
+ 
+ /* Define whether to use a backing pixmap to handle expose events. */
+ /* Note that this is a variable rather than a #define. */
+ /* Note also that it is consulted each time we open an X device. */
+ private int use_backing = 1;
+ 
+ /* Define the maximum size of the temporary pixmap for copy_mono */
+ /* that we are willing to leave lying around in the server */
+ /* between uses.  (Assume 32-bit ints here!) */
+ private int max_temp_pixmap = 20000;
+ 
+ /* Forward references */
+ private int set_tile(P2(gx_device *, gx_bitmap *));
+ private void free_cp(P1(gx_device *));
+ /* Screen updating machinery */
+ #define update_init(dev)\
+   ((gx_device_X *)(dev))->up_area = 0,\
+   ((gx_device_X *)(dev))->up_count = 0
+ #define update_flush(dev)\
+   if ( ((gx_device_X *)(dev))->up_area != 0 ) update_do_flush(dev)
+ private void update_do_flush(P1(gx_device *));
+ private void update_add(P5(gx_device *, int, int, int, int));
+ 
+ /* Procedures */
+ 
+ int x_open(P1(gx_device *));
+ 
+ int x_close(P1(gx_device *));
+ 
+ gx_color_index x_map_rgb_color(P4(gx_device *, _ushort, _ushort, _ushort));
+ 
+ int x_map_color_rgb(P3(gx_device *, gx_color_index, _ushort *));
+ 
+ int x_sync(P1(gx_device *));
+ 
+ int x_fill_rectangle(P6(gx_device *, int, int, int, int, gx_color_index));
+ 
+ int x_tile_rectangle(P8(gx_device *, gx_bitmap *, int, int, int, int, gx_color_index, gx_color_index));
+ 
+ int x_copy_mono(P10(gx_device *, _byte *, int, int, int, int, int, int, gx_color_index, gx_color_index));
+ 
+ int x_copy_color(P8(gx_device *, _byte *, int, int, int, int, int, int));
+ 
+ int x_draw_line(P6(gx_device *, int, int, int, int, gx_color_index));
+ 
+ int x_fill_trapezoid(P8(gx_device *, int, int, int, int, int, int, gx_color_index));
+ 
+ int x_tile_trapezoid(P10(gx_device *, gx_bitmap *, int, int, int, int, int, int, gx_color_index, gx_color_index));
+ 
+ /* The device descriptor */
+ private gx_device_procs x_procs = {
+ 	x_open,
+ 	gx_default_get_initial_matrix,
+ 	x_sync,
+ 	gx_default_output_page,
+ 	x_close,
+ 	x_map_rgb_color,
+ 	x_map_color_rgb,
+ 	x_fill_rectangle,
+ 	x_tile_rectangle,
+ 	x_copy_mono,
+ 	x_copy_color,
+ 	x_draw_line,
+ 	x_fill_trapezoid,
+ 	x_tile_trapezoid
+ };
+ 
+ /* Define default window parameters */
+ 
+ #define PROGRAM_NAME "Ghostscript"
+ 
+ #define ARG_BORDER_WIDTH "borderWidth"
+ #define DEFAULT_BORDER_WIDTH 1
+ 
+ #define ARG_BORDER_COLOR "borderColor"
+ #define DEFAULT_BORDER_COLOR  (xdev->colors[0]) /* That's black. */
+ 
+ #define ARG_GEOMETRY "geometry"
+ #define DEFAULT_GEOMETRY "612x792+0+0"
+ 
+ #define DEFAULT_X_POSITION 0
+ #define DEFAULT_Y_POSITION 0
+ 
+ #define ARG_X_RESOLUTION "xResolution"
+ #define DEFAULT_X_RESOLUTION 72
+ #define ARG_Y_RESOLUTION "yResolution"
+ #define DEFAULT_Y_RESOLUTION 72
+ 
+ /* The page width and height are defined in a slightly peculiar */
+ /* way so that <resolution> * DEFAULT_{WIDTH|HEIGHT}_INCHES will work. */
+ #define DEFAULT_WIDTH_INCHES 85/10	/* no parentheses! */
+ #define DEFAULT_HEIGHT_INCHES 11
+ 
+ /* Define a rectangle structure for update bookkeeping */
+ typedef struct rect_s {
+   int xo, yo, xe, ye;
+ } rect;
+ 
+ /* Define the X Windows device */
+ typedef struct gx_device_X_s {
+ 	gx_device_common;
+ 
+ 	/* An XImage object for writing bitmap images to the screen */
+ 	XImage image;
+ 
+ 	/* Global X state */
+ 	Display *dpy;
+ 	Screen *scr;
+ 	int depth;
+ 	Visual *vis;
+ 	Colormap cmap;
+ 	Window win;
+ 	GC gc;
+ 
+ 	/* A backing pixmap so X will handle exposure automatically */
+ 	Pixmap bpixmap;			/* 0 if use_backing is false, */
+ 					/* or if it can't be allocated */
+ 	rect update;		/* region needing updating */
+ 	long up_area;		/* total area of update */
+ 				/* (always 0 if no backing pixmap) */
+ 	int up_count;		/* # of updates since flush */
+ 	Pixmap dest;		/* bpixmap if non-0, else win */
+ 	unsigned long accum_color; /* 'or' of all device colors used so far */
+ 
+ 	/* An intermediate pixmap for the stencil case of copy_mono */
+ 	struct {
+ 	  Pixmap pixmap;
+ 	  GC gc;
+ 	  int raster, height;
+ 	} cp;
+ 
+ 	/* Structure for dealing with the halftone tile. */
+ 	/* Later this might become a multi-element cache. */
+ 	struct {
+ 	  Pixmap pixmap;
+ 	  Pixmap no_pixmap;	/* kludge to get around X bug */
+ 	  int width, height, raster;
+ 	  _byte *bits;
+ 	  int bits_size;
+ 	  gx_color_index fore_c, back_c;
+ 	} ht;
+ 
+ 	/* Cache the fill style from the GC */
+ 	int fill_style;
+ 
+ #define set_fill_style(style)\
+   if ( xdev->fill_style != style )\
+     XSetFillStyle(xdev->dpy, xdev->gc, (xdev->fill_style = style))
+ #define set_function(func)\
+   XSetFunction(xdev->dpy, xdev->gc, func) /* don't bother to cache */
+ 
+ 	/* Map color indices to X pixel values */
+ 	unsigned long colors[8];
+ #define black colors[0]
+ #define white colors[7]
+ 	gx_color_index back_color, fore_color;
+ 
+ #define set_back_color(color)\
+   if ( xdev->back_color != color )\
+    { unsigned long dev_color = xdev->colors[xdev->back_color = color];\
+      xdev->accum_color |= dev_color;\
+      XSetBackground(xdev->dpy, xdev->gc, dev_color);\
+    }
+ #define set_fore_color(color)\
+   if ( xdev->fore_color != color )\
+    { unsigned long dev_color = xdev->colors[xdev->fore_color = color];\
+      xdev->accum_color |= dev_color;\
+      XSetForeground(xdev->dpy, xdev->gc, dev_color);\
+    }
+ 
+ } gx_device_X;
+ 
+ /* The instance is public. */
+ gx_device_X gs_x11_device = {
+ 	sizeof(gx_device_X),
+ 	&x_procs,
+ 	"x11",
+ 	DEFAULT_WIDTH_INCHES, DEFAULT_HEIGHT_INCHES,	/* x and y extent */
+ 	DEFAULT_X_RESOLUTION, DEFAULT_Y_RESOLUTION,	/* x and y density */
+ 		/* Following parameters are initialized for monochrome */
+ 	0,			/* has color */
+ 	1,			/* max r-g-b value */
+ 	1,			/* bits per color pixel */
+ 		/* End of monochrome/color parameters */
+ 	0,			/* connection not initialized */
+ 	{ /* image */
+ 	  0, 0,			/* width, height */
+ 	  0, XYBitmap, NULL,	/* xoffset, format, data */
+ 	  LSBFirst, 8,    	/* byte-order, bitmap-unit */
+ 	  MSBFirst, 8, 1,	/* bitmap-bit-order, bitmap-pad, depth */
+ 	  0, 1,			/* bytes_per_line, bits_per_pixel */
+ 	  0, 0, 0,		/* red_mask, green_mask, blue_mask */
+ 	  NULL,			/* *obdata */
+ 	   { NULL,			/* *(*create_image)() */
+ 	     NULL,			/* (*destroy_image)() */
+ 	     NULL,			/* (*get_pixel)() */
+ 	     NULL,			/* (*put_pixel)() */
+ 	     NULL,			/* *(*sub_image)() */
+ 	     NULL			/* (*add_pixel)() */
+ 	   },
+ 	},
+ 	NULL, NULL, 0, NULL,	/* dpy, scr, depth_all_ones, vis */
+ 				/* (connection not initialized) */
+ 	(Colormap)None,		/* cmap */
+ 	(Window)None,		/* win */
+ 	NULL,			/* gc */
+ 	(Pixmap)0,		/* bpixmap */
+ 	 { 0, 0, 0, 0 }, 0, 0,	/* update, up_area, up_count */
+ 	(Pixmap)0,		/* dest */
+ 	0,			/* accum_color */
+ 	 { /* cp */
+ 	   (Pixmap)0,		/* pixmap */
+ 	   NULL,		/* gc */
+ 	   -1, -1		/* raster, height */
+ 	 },
+ 	 { /* ht */
+ 	   (Pixmap)None,		/* pixmap */
+ 	   (Pixmap)None,		/* no_pixmap */
+ 	   0, 0, 0,			/* width, height, raster */
+ 	   NULL, 1 			/* bits, bits_size */
+ 	 },
+ 	FillSolid,		/* fill_style */
+ 	{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* colors[8] */
+ 	0, 0			/* back_color, fore_color */
+ 
+ };
+ /* Macro for casting gx_device argument */
+ #define xdev ((gx_device_X *)dev)
+ 
+ /* Macro to validate and coerce arguments */
+ #define check_rect()\
+ 	if ( x + w > xdev->width ) w = xdev->width - x;\
+ 	if ( y + h > xdev->height ) h = xdev->height - y;\
+ 	if ( w <= 0 || h <= 0 ) return 0;\
+ 	if ( x < 0 || y < 0 ) return -1
+ 
+ #if !use_XPutImage
+ /* XPutImage doesn't work, do it ourselves. */
+ #  undef XPutImage
+ private void alt_put_image();
+ #  define XPutImage(dpy,win,gc,im,sx,sy,x,y,w,h)\
+     alt_put_image(dev,dpy,win,gc,im,sx,sy,x,y,w,h)
+ #endif
+ 
+ 
+ /* Open the X device */
+ int
+ x_open(register gx_device *dev)
+ {	Screen *scr;
+ 	XSizeHints sizehints;
+ 	int border_width;
+ 	char *x_resolution_str, *y_resolution_str;
+ 	char *border_width_str, *border_color_str;
+ 	unsigned long border_color;
+ 	char *geometry;
+ 	XColor screen_color, exact_color;
+ 	XSetWindowAttributes xswa;
+ 	XEvent event;
+ #ifdef DEBUG
+ if ( gs_debug['X'] )
+ 	{ extern int _Xdebug;
+ 	  _Xdebug = 1;
+ 	}
+ #endif
+ 	if ( !(xdev->dpy = XOpenDisplay(NULL)) )
+ 	  { eprintf1("gs: Cannot open X display `%s'.\n",
+ 		     getenv("DISPLAY"));
+ 	    exit(1);
+ 	  }
+ 	scr = DefaultScreenOfDisplay(xdev->dpy);
+ 	xdev->scr = scr;
+ 	xdev->depth = DefaultDepthOfScreen(scr);
+ 	xdev->vis = DefaultVisualOfScreen(scr);
+ 	xdev->cmap = DefaultColormapOfScreen(scr);
+ 	xdev->black = BlackPixelOfScreen(scr);
+ 	xdev->white = WhitePixelOfScreen(scr);
+ 
+ 	/* Figure out the resolution of our screen; 25.4 is the
+ 	 * number of millimeters in an inch.  The only reason for
+ 	 * allowing the user to specify the resolution is that
+ 	 * X servers commonly lie about it (and about the screen size).
+ 	 */
+ 
+ 	x_resolution_str = XGetDefault(xdev->dpy, PROGRAM_NAME,
+ 				       ARG_X_RESOLUTION);
+ 	y_resolution_str = XGetDefault(xdev->dpy, PROGRAM_NAME,
+ 				       ARG_Y_RESOLUTION);
+ 	xdev->x_pixels_per_inch =
+ 	  (x_resolution_str == NULL ?
+ 	   25.4 * WidthOfScreen(scr) / WidthMMOfScreen(scr) :
+ 	   atoi(x_resolution_str));
+ 	xdev->y_pixels_per_inch =
+ 	  (y_resolution_str == NULL ?
+ 	   25.4 * HeightOfScreen(scr) / HeightMMOfScreen(scr) :
+ 	   atoi(y_resolution_str));
+ 
+ 	/* Figure out monochrome vs. color */
+ 	switch ( xdev->vis->class )
+ 	  {
+ 	  case StaticGray:
+ 	  case GrayScale:
+ 	    xdev->has_color = 0;
+ 	    { int i;
+ 	      for ( i = 1; i < 7; i++ ) xdev->colors[i] = xdev->white;
+ 	    }
+ 	    break;
+ 	  default:		/* color */
+ 	    xdev->has_color = 1;
+ 	    /* Just do primary colors for now */
+ 	    { XColor xc;
+ 	      int i;
+ 	      for ( i = 1; i < 7; i++ )
+ 		{ xc.red = (i & 4 ? ~(_ushort)0 : 0);
+ 		  xc.green = (i & 2 ? ~(_ushort)0 : 0);
+ 		  xc.blue = (i & 1 ? ~(_ushort)0 : 0);
+ 		  XAllocColor(xdev->dpy, xdev->cmap, &xc);
+ 		  xdev->colors[i] = xc.pixel;
+ 		}
+ 	    }
+ 	  }
+ 	xdev->ht.pixmap = (Pixmap)0;
+ 	xdev->ht.bits = 0;
+ 	xdev->fill_style = FillSolid;
+ 
+ 	/* Get defaults from the database. */
+ 	border_width_str = XGetDefault(xdev->dpy, PROGRAM_NAME,
+ 				       ARG_BORDER_WIDTH);
+ 
+ 	border_width = (border_width_str == NULL ? DEFAULT_BORDER_WIDTH :
+ 			atoi(border_width_str));
+ 
+ 	border_color_str = XGetDefault(xdev->dpy, PROGRAM_NAME,
+ 				       ARG_BORDER_COLOR);
+ 
+ 	border_color = (border_color_str == NULL ||
+ 			 !XAllocNamedColor(xdev->dpy, xdev->cmap, 
+ 					   border_color_str, 
+ 					   &screen_color, &exact_color) ?
+ 			DEFAULT_BORDER_COLOR :
+ 			screen_color.pixel);
+ 
+ 	sizehints.x = DEFAULT_X_POSITION;
+ 	sizehints.y = DEFAULT_Y_POSITION;
+ 	sizehints.width = xdev->x_pixels_per_inch * DEFAULT_WIDTH_INCHES;
+ 	sizehints.height = xdev->y_pixels_per_inch * DEFAULT_HEIGHT_INCHES;
+ 	sizehints.flags = 0;
+ 
+ 	geometry = XGetDefault(xdev->dpy, PROGRAM_NAME, ARG_GEOMETRY);
+ 
+ 	if (geometry != NULL)
+ 	   {	/*
+ 		 * Note that border_width must be set first.  We can't use
+ 		 * scr, because that is a Screen*, and XGeometry wants
+ 		 * the screen number.
+ 		 */
+ 		int bitmask = XGeometry(xdev->dpy, DefaultScreen(xdev->dpy),
+ 					geometry, DEFAULT_GEOMETRY,
+ 					border_width,
+ 					1, 1, /* ``Font'' width and height. */
+ 					0, 0, /* Interior padding. */
+ 					&sizehints.x, &sizehints.y,
+ 					&sizehints.width, &sizehints.height);
+ 
+ 		if (bitmask & (XValue | YValue))
+ 			sizehints.flags |= USPosition;
+ 
+ 		if (bitmask & (WidthValue | HeightValue))
+ 			sizehints.flags |= USSize;
+ 	   }
+ 
+ 	xdev->width = sizehints.width;
+ 	xdev->height = sizehints.height;
+ 
+ 	xswa.event_mask = ExposureMask;
+ 	xswa.background_pixel = xdev->black;
+ 	xswa.border_pixel = border_color;
+ 	xdev->win = XCreateWindow(xdev->dpy, RootWindowOfScreen(scr),
+ 				  sizehints.x, sizehints.y, /* upper left */
+ 				  sizehints.width, sizehints.height,
+ 				  border_width,
+ 				  xdev->depth,
+ 				  InputOutput, /* class */
+ 				  xdev->vis, /* visual */
+ 				  CWEventMask | CWBackPixel | CWBorderPixel,
+ 				  &xswa);
+ 	if ( use_backing )
+ 	  xdev->bpixmap =
+ 		XCreatePixmap(xdev->dpy, xdev->win,
+ 			      xdev->width, xdev->height,
+ 			      xdev->depth);
+ 	else
+ 	  xdev->bpixmap = (Pixmap)0;
+ 	xdev->dest = (xdev->bpixmap != (Pixmap)0 ?
+ 		      xdev->bpixmap : (Pixmap)xdev->win);
+ 	xdev->accum_color = 0;
+ 	update_init(dev);
+ 
+ 	XChangeProperty(xdev->dpy, xdev->win, XA_WM_NAME, XA_STRING, 8,
+ 			PropModeReplace, (unsigned char *)PROGRAM_NAME,
+ 			strlen(PROGRAM_NAME));
+ 	XSetNormalHints(xdev->dpy, xdev->win, &sizehints);
+ 
+ 	/* Set up a graphics context */
+ 	xdev->gc = XCreateGC(xdev->dpy, xdev->win, 0, NULL);
+ 	XSetFunction(xdev->dpy, xdev->gc, GXcopy);
+ 	XSetLineAttributes(xdev->dpy, xdev->gc, 0,
+ 			   LineSolid, CapButt, JoinMiter);
+ 
+ 	/* Clear the background pixmap to avoid initializing with garbage. */
+ 	if ( xdev->bpixmap != (Pixmap)0 )
+ 	  { XSetWindowBackgroundPixmap(xdev->dpy, xdev->win, xdev->bpixmap);
+ 	    XSetForeground(xdev->dpy, xdev->gc, xdev->white);
+ 	    XFillRectangle(xdev->dpy, xdev->bpixmap, xdev->gc,
+ 			   0, 0, xdev->width, xdev->height);
+ 	  }
+ 
+ 	/* Initialize foreground and background colors */
+ 	xdev->back_color = 7;
+ 	XSetBackground(xdev->dpy, xdev->gc, xdev->white);
+ 	xdev->fore_color = 0;
+ 	XSetForeground(xdev->dpy, xdev->gc, xdev->black);
+ 
+ 	/* Make the window appear. */
+ 	XMapWindow(xdev->dpy, xdev->win);
+ 
+ 	/* Before anything else, do a flush and wait for */
+ 	/* an exposure event. */
+ 	XFlush(xdev->dpy);
+ 	XNextEvent(xdev->dpy, &event);
+ 
+ 	xdev->ht.no_pixmap = XCreatePixmap(xdev->dpy, xdev->win, 1, 1,
+ 					   xdev->depth);
+ 
+ 	XSync(xdev->dpy, 0);
+ 	return 0;
+ }
+ 
+ /* Close the device.  NOT SURE WHAT TO DO HERE YET. */
+ int
+ x_close(gx_device *dev)
+ {	return 0;
+ }
+ 
+ /* Map a color.  The "device colors" are just r,g,b packed together. */
+ gx_color_index
+ x_map_rgb_color(register gx_device *dev, _ushort r, _ushort g, _ushort b)
+ {	return (r << 2) + (g << 1) + b;
+ }
+ 
+ 
+ /* Map a "device color" back to r-g-b. */
+ int
+ x_map_color_rgb(register gx_device *dev, gx_color_index color, _ushort *prgb)
+ {	prgb[0] = (color >> 2) & 1;
+ 	prgb[1] = (color >> 1) & 1;
+ 	prgb[2] = color & 1;
+ 	return 0;
+ }
+ 
+ /* Synchronize the display with the commands already given */
+ int
+ x_sync(register gx_device *dev)
+ {	update_flush(dev);
+ 	XSync(xdev->dpy, 0);
+ 	return 0;
+ }
+ 
+ /* Fill a rectangle with a color. */
+ int
+ x_fill_rectangle(register gx_device *dev,
+   int x, int y, int w, int h, gx_color_index color)
+ {	check_rect();
+ 	set_fill_style(FillSolid);
+ 	set_fore_color(color);
+ 	set_function(GXcopy);
+ 	XFillRectangle(xdev->dpy, xdev->dest, xdev->gc, x, y, w, h);
+ 	if ( xdev->bpixmap != (Pixmap)0 )
+ 	 { update_add(dev, x, y, w, h);
+ 	 }
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+ 	printf("[F] fill (%d,%d):(%d,%d) %ld\n",
+ 	       x, y, w, h, (long)color);
+ #endif
+ 	return 0;
+ }
+ 
+ /* Tile a rectangle. */
+ int
+ x_tile_rectangle(register gx_device *dev, gx_bitmap *tile,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	check_rect();
+ 
+ 	/* Check for a colored tile.  We should implement this */
+ 	/* properly someday, since X can handle it. */
+ 
+ 	if ( one == gx_no_color_index && zero == gx_no_color_index )
+ 		return -1;
+ 
+ 	/* 
+ 	 * Remember, an X tile is already filled with particular
+ 	 * pixel values (i.e., colors).  Therefore if we are changing
+ 	 * fore/background color, we must invalidate the tile (using
+ 	 * the same technique as in set_tile).  This problem only
+ 	 * bites when using grayscale -- you may want to change
+ 	 * fg/bg but use the same halftone screen.
+ 	 */
+ 	if ( (zero != xdev->ht.back_c) || (one != xdev->ht.fore_c) )
+ 	  if ( xdev->ht.bits ) *xdev->ht.bits = ~*tile->data;
+ 
+ 	set_back_color(zero);
+ 	set_fore_color(one);
+ 	set_function(GXcopy);
+ 	if ( !set_tile(dev, tile) )
+ 	 { /* Bad news.  Fall back to the default algorithm. */
+ 	   set_fill_style(FillSolid);
+ 	   return gx_default_tile_rectangle(dev, tile, x, y, w, h, zero, one);
+ 	 }
+ 	else
+ 	  { /* Use the tile to fill the rectangle */
+ 	    XFillRectangle(xdev->dpy, xdev->dest, xdev->gc, x, y, w, h);
+ 	    if ( xdev->bpixmap != (Pixmap)0 )
+ 	     { update_add(dev, x, y, w, h);
+ 	     }
+ 	  }
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+ 	printf("[F] tile (%d,%d):(%d,%d) %ld,%ld\n",
+ 	       x, y, w, h, (long)zero, (long)one);
+ #endif
+ 	return 0;
+ }
+ 
+ /* Set up with a specified tile. */
+ /* Return false if we can't do it for some reason. */
+ private int
+ set_tile(register gx_device *dev, register gx_bitmap *tile)
+ {
+ #ifdef DEBUG
+ if ( gs_debug['T'] )
+ 	return 0;
+ #endif
+ 	/* Set up the tile Pixmap */
+ 	if ( tile->width != xdev->ht.width ||
+ 	     tile->height != xdev->ht.height ||
+ 	     xdev->ht.pixmap == (Pixmap)0
+ 	   )
+ 	  { if ( xdev->ht.pixmap != (Pixmap)0 )
+ 	      XFreePixmap(xdev->dpy, xdev->ht.pixmap);
+ 	    if ( xdev->ht.bits )
+ 	      { free(xdev->ht.bits);
+ 		xdev->ht.bits = 0;
+ 	      }
+ 	    xdev->ht.pixmap = XCreatePixmap(xdev->dpy, xdev->win,
+ 					    tile->width, tile->height,
+ 					    xdev->depth);
+ 	    if ( xdev->ht.pixmap == (Pixmap)0 )
+ 	      return 0;
+ 	    xdev->ht.bits_size = tile->raster * tile->height;
+ 	    xdev->ht.bits = (_byte *)malloc(xdev->ht.bits_size);
+ 	    if ( xdev->ht.bits == 0 )
+ 	      { XFreePixmap(xdev->dpy, xdev->ht.pixmap);
+ 		xdev->ht.pixmap = (Pixmap)0;
+ 		return 0;
+ 	      }
+ 	    xdev->ht.width = tile->width, xdev->ht.height = tile->height;
+ 	    xdev->ht.raster = tile->raster;
+ 	    *xdev->ht.bits = ~*tile->data; /* force copying */
+ 	  }
+ 	xdev->ht.fore_c = xdev->fore_color;
+ 	xdev->ht.back_c = xdev->back_color;
+ 	/* Copy the tile into the Pixmap if needed */
+ 	if ( memcmp(xdev->ht.bits, tile->data, xdev->ht.bits_size) )
+ 	  { memcpy(xdev->ht.bits, tile->data, xdev->ht.bits_size);
+ 	    xdev->image.data = (char *)tile->data;
+ 	    xdev->image.width = tile->width;
+ 	    xdev->image.height = tile->height;
+ 	    xdev->image.bytes_per_line = tile->raster;
+ 	    xdev->image.format = XYBitmap;
+ 	    set_fill_style(FillSolid);
+ #ifdef DEBUG
+ if ( gs_debug['H'] )
+ 	    { int i;
+ 	      printf("[H] 0x%x: width=%d height=%d raster=%d\n",
+ 		     tile->data, tile->width, tile->height, tile->raster);
+ 	      for ( i = 0; i < tile->raster * tile->height; i++ )
+ 		printf(" %02x", tile->data[i]);
+ 	      printf("\n");
+ 	    }
+ #endif
+ 	    XSetTile(xdev->dpy, xdev->gc, xdev->ht.no_pixmap); /* *** X bug *** */
+ 	    XPutImage(xdev->dpy, xdev->ht.pixmap, xdev->gc, &xdev->image,
+ 		      0, 0, 0, 0, tile->width, tile->height);
+ 	    XSetTile(xdev->dpy, xdev->gc, xdev->ht.pixmap);
+ 	  }
+ 	set_fill_style(FillTiled);
+ 	return use_XSetTile;
+ }
+ 
+ /* Copy a monochrome bitmap. */
+ int
+ x_copy_mono(register gx_device *dev, _byte *base, int sourcex, int raster,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ /*
+  * X doesn't readily support the simple operation of writing a color
+  * through a mask.  The plot is the following: 
+  *  If neither color is gx_no_color_index ("transparent"),
+  *	use XPutImage with the "copy" function as usual.
+  *  If the color is 0 or bitwise-includes every color written to date
+  *    (a special optimization for writing black/white on color displays),
+  *	use XPutImage with an appropriate Boolean function.
+  *  Otherwise, do the following complicated stuff:
+  *	Create pixmap of depth 1 if necessary.
+  *	If foreground color is "transparent" then
+  *	  invert the raster data (using GXcopyInverted in XPutImage).
+  *	Use XPutImage to copy the raster image to the newly
+  *	  created Pixmap.
+  *	Install the Pixmap as the clip_mask in the X GC and
+  *	  tweak the clip origin.
+  *	Do an XFillRectangle, fill style=solid, specifying a
+  *	  rectangle the same size as the original raster data.
+  *	De-install the clip_mask.
+  */
+ {	int function = GXcopy;
+ 	unsigned long
+ 	  bc = xdev->colors[zero],
+ 	  fc = xdev->colors[one];
+ 	
+ 	check_rect();
+ 
+ 	xdev->image.width = raster << 3;
+ 	xdev->image.height = h;
+ 	xdev->image.data = (char *)base;
+ 	xdev->image.bytes_per_line = raster;
+ 	set_fill_style(FillSolid);
+ 
+ 	/* Check for null, easy 1-color, hard 1-color, and 2-color cases. */
+ 	if ( zero != gx_no_color_index )
+ 	  { if ( one != gx_no_color_index )
+ 	      { /* Simply replace existing bits with what's in the image */
+ 	      }
+ 	    else if ( bc == 0 )
+ 	      function = GXand,
+ 	      fc = xdev->accum_color;
+ 	    else if ( !(~bc & xdev->accum_color) )
+ 	      function = GXorInverted,
+ 	      fc = bc, bc = 0;
+ 	    else
+ 	      goto hard;
+ 	  }
+ 	else
+ 	  { if ( one == gx_no_color_index ) /* no-op */
+ 	      return 0;
+ 	    else if ( fc == 0 )
+ 	      function = GXandInverted,
+ 	      bc = 0, fc = xdev->accum_color;
+ 	    else if ( !(~fc & xdev->accum_color) )
+ 	      function = GXor,
+ 	      bc = 0;
+ 	    else
+ 	      goto hard;
+ 	  }
+ 	xdev->image.format = XYBitmap;
+ 	set_function(function);
+ 	XSetBackground(xdev->dpy, xdev->gc, bc);
+ 	XSetForeground(xdev->dpy, xdev->gc, fc);
+ 	xdev->back_color = xdev->fore_color = gx_no_color_index;
+ 	xdev->accum_color |= fc | bc;
+ 	XPutImage(xdev->dpy, xdev->dest, xdev->gc, &xdev->image,
+ 		  sourcex, 0, x, y, w, h);
+ 
+ 	goto out;
+ 
+ hard:	/* Handle the hard 1-color case. */
+ 	if ( raster > xdev->cp.raster || h > xdev->cp.height )
+ 	  { /* Must allocate a new pixmap and GC. */
+ 	    /* Release the old ones first. */
+ 	    free_cp(dev);
+ 
+ 	    /* Create the clipping pixmap, depth must be 1. */
+ 	    xdev->cp.pixmap =
+ 	      XCreatePixmap(xdev->dpy, xdev->win, raster << 3, h, 1);
+ 	    if ( xdev->cp.pixmap == (Pixmap)0 )
+ 	      {	dprintf("x_copy_mono: can't allocate pixmap\n");
+ 		exit(1);
+ 	      }
+ 	    xdev->cp.gc = XCreateGC(xdev->dpy, xdev->cp.pixmap, 0, 0);
+ 	    if ( xdev->cp.gc == (GC)0 )
+ 	      {	dprintf("x_copy_mono: can't allocate GC\n");
+ 		exit(1);
+ 	      }
+ 	    xdev->cp.raster = raster;
+ 	    xdev->cp.height = h;
+ 	  }
+ 
+ 	/* Initialize static mask image params */
+ 	xdev->image.format = ZPixmap;
+ 
+ 	/* Select function based on fg/bg transparency. */
+ 	if ( one == gx_no_color_index )
+ 	  { XSetFunction(xdev->dpy, xdev->cp.gc, GXcopyInverted);
+ 	    XPutImage(xdev->dpy, xdev->cp.pixmap, xdev->cp.gc,
+ 		      &xdev->image, sourcex, 0, 0, 0, w, h);
+ 	    /* Reset function in stencil gc */
+ 	    XSetFunction(xdev->dpy, xdev->cp.gc, GXcopy);
+ 	    set_fore_color(zero);
+ 	  }
+ 	else
+ 	  { XPutImage(xdev->dpy, xdev->cp.pixmap, xdev->cp.gc,
+ 		      &xdev->image, sourcex, 0, 0, 0, w, h);
+ 	    set_fore_color(one);
+ 	  }
+ 
+ 	/* Install as clipmask. */
+ 	XSetClipMask(xdev->dpy, xdev->gc, xdev->cp.pixmap);
+ 	XSetClipOrigin(xdev->dpy, xdev->gc, x, y);
+ 
+ 	/*
+ 	 * Draw a solid rectangle through the raster clip mask.
+ 	 * Note fill style is guaranteed to be solid from above.
+ 	 */
+ 	XFillRectangle(xdev->dpy, xdev->dest, xdev->gc, x, y, w, h);
+ 
+ 	/* Tidy up.  Free the pixmap if it's big. */
+ 	XSetClipMask(xdev->dpy, xdev->gc, None);
+ 	if ( raster * h > max_temp_pixmap )
+ 	  free_cp(dev);
+ 
+ out:	if ( xdev->bpixmap != (Pixmap)0 )
+ 	  { /* We wrote to the pixmap, so update the display now. */
+ 	    update_add(dev, x, y, w, h);
+ 	  }
+ 
+ 	return 0;
+ }
+ 
+ /* Internal routine to free the GC and pixmap used for copying. */
+ private void
+ free_cp(register gx_device *dev)
+ {	if ( xdev->cp.gc != NULL )
+ 	   {	XFreeGC(xdev->dpy, xdev->cp.gc);
+ 		xdev->cp.gc = NULL;
+ 	   }
+ 	if ( xdev->cp.pixmap != (Pixmap)0 )
+ 	   {	XFreePixmap(xdev->dpy, xdev->cp.pixmap);
+ 		xdev->cp.pixmap = (Pixmap)0;
+ 	   }
+ 	xdev->cp.raster = -1;	/* mark as unallocated */
+ }
+ 
+ /* Copy a "color" bitmap.  Since "color" is the same as monochrome, */
+ /* this just reduces to copying a monochrome bitmap. */
+ /****** THIS ROUTINE IS COMPLETELY WRONG, SINCE WE DO SUPPORT COLOR. ******/
+ /* Fortunately, no one uses it at the moment. */
+ int
+ x_copy_color(register gx_device *dev, _byte *base, int sourcex, int raster,
+   int x, int y, int w, int h)
+ {	return x_copy_mono(dev, base, sourcex, raster, x, y, w, h, (gx_color_index)0, (gx_color_index)7);
+ }
+ 
+ /* Draw a line */
+ int
+ x_draw_line(register gx_device *dev,
+   int x0, int y0, int x1, int y1, gx_color_index color)
+ {	set_fore_color(color);
+ 	set_fill_style(FillSolid);
+ 	set_function(GXcopy);
+ 	XDrawLine(xdev->dpy, xdev->dest, xdev->gc, x0, y0, x1, y1);
+ 	if ( xdev->bpixmap != (Pixmap)0 )
+ 	 { int x = x0, y = y0, w = x1 - x0, h = y1 - y0;
+ 	   if ( w < 0 ) x = x1, w = - w;
+ 	   if ( h < 0 ) y = y1, h = - h;
+ 	   update_add(dev, x, y, w+1, h+1);
+ 	 }
+ 	return 0;
+ }
+ 
+ /* Define a common macro for setting up a trapezoid. */
+ #define setup_trapezoid()\
+ 	XPoint vlist[4];\
+ 	XPoint *pv = vlist + 1;\
+ 	vlist[0].x = x0, vlist[0].y = y0;\
+ 	if ( w0 )\
+ 	  pv->x = x0 + w0, pv->y = y0, pv++;\
+ 	pv->x = x1 + w1, pv->y = y1, pv++;\
+ 	if ( w1 )\
+ 	  pv->x = x1, pv->y = y1, pv++
+ #define vcount (pv - vlist)
+ /* Define a common macro for finishing a trapezoid. */
+ #define finish_trapezoid()\
+ 	set_function(GXcopy);\
+ 	XFillPolygon(xdev->dpy, xdev->dest, xdev->gc,\
+ 		     vlist, vcount, Convex, CoordModeOrigin);\
+ 	if ( xdev->bpixmap != (Pixmap)0 )\
+ 	 { int xl = x0, xr = x0 + w0;\
+ 	   if ( x1 < xl ) xl = x1;\
+ 	   if ( x1 + w1 > xr ) xr = x1 + w1;\
+ 	   update_add(dev, xl, y0, xr - xl, y1 - y0);\
+ 	 }
+ 
+ /* Fill a trapezoid */
+ int
+ x_fill_trapezoid(register gx_device *dev,
+   int x0, int y0, int w0, int x1, int y1, int w1, gx_color_index color)
+ {	setup_trapezoid();
+ 	set_fore_color(color);
+ 	set_fill_style(FillSolid);
+ 	finish_trapezoid();
+ 	return 0;
+ }
+ 
+ /* Tile a trapezoid */
+ int
+ x_tile_trapezoid(register gx_device *dev, gx_bitmap *tile,
+   int x0, int y0, int w0, int x1, int y1, int w1,
+   gx_color_index zero, gx_color_index one)
+ {
+ 	/* Check for a colored tile.  We should implement this */
+ 	/* properly someday, since X can handle it. */
+ 
+ 	if ( one == gx_no_color_index && zero == gx_no_color_index )
+ 	  return -1;
+ 	/* See x_tile_rectangle for the significance of the following. */
+ 	if ( (zero != xdev->ht.back_c) || (one != xdev->ht.fore_c) )
+ 	  if ( xdev->ht.bits ) *xdev->ht.bits = ~*tile->data;
+ 
+ 	{ setup_trapezoid();
+ 	  set_back_color(zero);
+ 	  set_fore_color(one);
+ 	  if ( !set_tile(dev, tile) )
+ 	   { set_fill_style(FillSolid);
+ 	     return gx_default_tile_trapezoid(dev, tile,
+ 	       x0, y0, w0, x1, y1, w1, zero, one);
+ 	   }
+ 	  /* Use the tile to fill the trapezoid */
+ 	  finish_trapezoid();
+ 	 }
+ 	return 0;
+ }
+ 
+ /* ------ Screen update procedures ------ */
+ 
+ /* Flush updates to the screen if needed. */
+ private void
+ update_do_flush(register gx_device *dev)
+ {	int xo = xdev->update.xo, yo = xdev->update.yo;
+ 	set_function(GXcopy);
+ 	XCopyArea(xdev->dpy, xdev->bpixmap, xdev->win, xdev->gc,
+ 		  xo, yo, xdev->update.xe - xo, xdev->update.ye - yo,
+ 		  xo, yo);
+ 	update_init(dev);
+ }
+ 
+ /* Add a region to be updated. */
+ /* This is only called if xdev->bpixmap != 0. */
+ private void
+ update_add(register gx_device *dev, int xo, int yo, int w, int h)
+ {	int xe = xo + w, ye = yo + h;
+ 	long new_area = (long)w * h;
+ 	++xdev->up_count;
+ 	if ( xdev->up_area != 0 )
+ 	  { /* See whether adding this rectangle */
+ 	    /* would result in too much being copied unnecessarily. */
+ 	    long old_area = xdev->up_area;
+ 	    long new_up_area;
+ 	    rect u;
+ 	    u.xo = min(xo, xdev->update.xo);
+ 	    u.yo = min(yo, xdev->update.yo);
+ 	    u.xe = max(xe, xdev->update.xe);
+ 	    u.ye = max(ye, xdev->update.ye);
+ 	    new_up_area = (long)(u.xe - u.xo) * (u.ye - u.yo);
+ 	    if ( new_up_area > 100 &&
+ 		old_area + new_area < new_up_area * 2 / 3 ||
+ 		xdev->up_count >= 200
+ 		)
+ 	      update_do_flush(dev);
+ 	    else
+ 	      { xdev->update = u;
+ 		xdev->up_area = new_up_area;
+ 		return;
+ 	      }
+ 	  }
+ 	xdev->update.xo = xo;
+ 	xdev->update.yo = yo;
+ 	xdev->update.xe = xe;
+ 	xdev->update.ye = ye;
+ 	xdev->up_area = new_area;
+ }
+ 
+ /* ------ Internal procedures ------ */
+ 
+ /* Substitute for XPutImage using XFillRectangle. */
+ /* This is a total hack to get around an apparent bug */
+ /* in the X server.  It only works with the specific */
+ /* parameters (bit/byte order, padding) used above. */
+ private void
+ alt_put_image(gx_device *dev, Display *dpy, Drawable win, GC gc,
+   XImage *pi, int sx, int sy, int dx, int dy, unsigned w, unsigned h)
+ {	int raster = pi->bytes_per_line;
+ 	_byte *data = (_byte *)pi->data + sy * raster + (sx >> 3);
+ 	int init_mask = 0x80 >> (sx & 7);
+ 	int invert;
+ 	int yi;
+ #define nrects 40
+ 	XRectangle rects[nrects];
+ 	XRectangle *rp = rects;
+ 	if ( xdev->fore_color != gx_no_color_index )
+ 	  { if ( xdev->back_color != gx_no_color_index )
+ 	      { XSetForeground(dpy, gc, xdev->colors[xdev->back_color]);
+ 		XFillRectangle(dpy, win, gc, dx, dy, w, h);
+ 	      }
+ 	    XSetForeground(dpy, gc, xdev->colors[xdev->fore_color]);
+ 	    invert = 0;
+ 	  }
+ 	else if ( xdev->back_color != gx_no_color_index )
+ 	  { XSetForeground(dpy, gc, xdev->colors[xdev->back_color]);
+ 	    invert = 0xff;
+ 	  }
+ 	else
+ 	  return;
+ 	for ( yi = 0; yi < h; yi++, data += raster )
+ 	  { register int mask = init_mask;
+ 	    register _byte *dp = data;
+ 	    register int xi = 0;
+ 	    while ( xi < w )
+ 	      { if ( (*dp ^ invert) & mask )
+ 		  { int xleft = xi;
+ 		    if ( rp == &rects[nrects] )
+ 		      { XFillRectangles(dpy, win, gc, rects, nrects);
+ 			rp = rects;
+ 		      }
+ 		    /* Scan over a run of 1-bits */
+ 		    rp->x = dx + xi, rp->y = dy + yi;
+ 		    do
+ 		      { if ( !(mask >>= 1) ) mask = 0x80, dp++;
+ 			xi++;
+ 		      }
+ 		    while ( xi < w && (*dp & mask) );
+ 		    rp->width = xi - xleft, rp->height = 1;
+ 		    rp++;
+ 		  }
+ 		else
+ 		  { if ( !(mask >>= 1) ) mask = 0x80, dp++;
+ 		    xi++;
+ 		  }
+ 	      }
+ 	  }
+ 	XFillRectangles(dpy, win, gc, rects, rp - rects);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevx.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevx.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gdevx.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,89 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gdevx.h */
+ /* Header for including X library calls in Ghostscript X11 driver */
+ 
+ #ifdef VMS
+ 
+ #  ifdef __GNUC__
+ 
+ /*   Names of external functions which contain upper case letters are
+  *   modified by the VMS GNU C compiler to prevent confusion between
+  *   names such as XOpen and xopen.  GNU C does this by translating a
+  *   name like XOpen into xopen_aaaaaaaax with "aaaaaaaa" a hexadecimal
+  *   string.  However, this causes problems when we link against the
+  *   X library which doesn't contain a routine named xopen_aaaaaaaax.
+  *   So, we use #define's to map all X routine names to lower case.
+  *   (Note that routines like BlackPixelOfScreen, which are [for VMS]
+  *   preprocessor macros, do not appear here.)
+  */
+ 
+ /*
+  * The names redefined here are those which the current Ghostscript X11
+  * driver happens to use: this list may grow in the future.
+  */
+ 
+ #    define XAllocColor			xalloccolor
+ #    define XAllocNamedColor		xallocnamedcolor
+ #    define XChangeProperty		xchangeproperty
+ #    define XCloseDisplay		xclosedisplay
+ #    define XCopyArea			xcopyarea
+ #    define XCreateGC			xcreategc
+ #    define XCreatePixmap		xcreatepixmap
+ #    define XCreateWindow		xcreatewindow
+ #    define XDisplayString		xdisplaystring
+ #    define XDrawLine			xdrawline
+ #    define XFillPolygon		xfillpolygon
+ #    define XFillRectangles		xfillrectangles
+ #    define XFillRectangle		xfillrectangle
+ #    define XFlush			xflush
+ #    define XFreeGC			xfreegc
+ #    define XFreePixmap			xfreepixmap
+ #    define XGeometry			xgeometry
+ #    define XGetDefault			xgetdefault
+ #    define XMapWindow			xmapwindow
+ #    define XNextEvent			xnextevent
+ #    define XOpenDisplay		xopendisplay
+ #    define XPutImage			xputimage
+ #    define XSetBackground		xsetbackground
+ #    define XSetClipMask		xsetclipmask
+ #    define XSetClipOrigin		xsetcliporigin
+ #    define XSetFillStyle		xsetfillstyle
+ #    define XSetForeground		xsetforeground
+ #    define XSetFunction		xsetfunction
+ #    define XSetLineAttributes		xsetlineattributes
+ #    define XSetNormalHints		xsetnormalhints
+ #    define XSetTile			xsettile
+ #    define XSetWindowBackgroundPixmap	xsetwindowbackgroundpixmap
+ #    define XSync			xsync
+ 
+ #  endif				/* ifdef __GNUC__ */
+ 
+ #  include <decw$include/Xlib.h>
+ #  include <decw$include/Xatom.h>
+ #  include <decw$include/Xutil.h>
+ 
+ #else					/* !ifdef VMS */
+ 
+ #  include <X11/Xlib.h>
+ #  include <X11/Xatom.h>
+ #  include <X11/Xutil.h>
+ 
+ #endif					/* VMS */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/genarch


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/genarch.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/genarch.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/genarch.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,24 ----
+ /* genarch.c */
+ /* Generate a header file (arch.h) with parameters */
+ /* reflecting the machine architecture. */
+ 
+ #include <stdio.h>
+ 
+ /* We should write the result on stdout, but the Turbo C 'make' */
+ /* can't handle output redirection (sigh). */
+ 
+ main(argc, argv)
+     int argc;
+     char *argv[];
+ {	long one = 1;
+ 	int v16 = 1 << 16;
+ 	FILE *f = fopen("arch.h", "w");
+ 	if ( f == NULL )
+ 	   {	fprintf(stderr, "genarch.c: can't open arch.h for writing\n");
+ 		exit(1);
+ 	   }
+ 	fprintf(f, "#define big_endian %d\n", 1 - *(char *)&one);
+ 	fprintf(f, "#define ints_are_short %d\n", v16 == 0);
+ 	fclose(f);
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gfonts.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gfonts.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gfonts.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,183 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % Font initialization for Ghostscript.  Despite anything claimed below,
+ % Ghostscript fonts are actually in the same format as Adobe Type 1 fonts,
+ % except that the external form customarily does not use eexec encryption.
+ % Someday there will be GNU documentation that describes this format.
+ % Until then, you'll have to either get a copy of Adobe's book, or read
+ % the Ghostscript code.  The interpreter for Type 1 fonts, which reveals
+ % most of their structure, is in the file gstype1.c.
+ 
+ % Define the default font.
+ /defaultfontname /Ugly def
+ 
+ % Internal procedure to load the font name -> font file name map
+ % if it isn't loaded already, and push it on the stack.
+ /Fontmap
+  { /FontFileMap where
+     { /FontFileMap get }
+     { (Fontmap) findlibfile not
+        { (Can't find ) print print (!\n) print stop }
+       if
+ 
+       FontDirectory maxlength dict exch
+       2 dict begin
+         mark exch 2 index exch
+ 	/;
+ 	 { % The stack contains a mark, the dictionary, the font name,
+ 	   % the file name, and additional information about the font.
+ 	   counttomark 3 sub { pop } repeat put
+ 	   1 index
+ 	 } bind def
+ 	run
+       end
+       pop pop		% pop the mark and the copy of the dictionary
+       userdict exch /FontFileMap exch put
+       FontFileMap
+      }
+    ifelse
+  } bind def
+ 
+ % Define findfont so it tries to load a font if it's not found.
+ /findfont
+  {
+ 	% If the key is a string, convert it to a name for lookup.
+ 	dup type /stringtype eq { cvn } if
+ 
+ 	% If the font isn't in FontDirectory already, load it.
+ 	dup FontDirectory exch known not
+ 	 { dup		% save the font name on the stack
+ 
+ 	   % Push the font name -> font file name map on the stack,
+ 	   % loading it if necessary.
+ 	   Fontmap
+ 
+ 	   % Read the file name from the map.
+ 	   % (The stack contains the font name and the font file map.)
+ 	   1 index known not
+ 	    { (Substituting ) print defaultfontname cvx =only
+ 	      ( for ) print == flush
+ 	      pop defaultfontname
+ 	    }
+ 	    { FontFileMap exch get
+ 
+ 	      % If we can't find the file, substitute for the font.
+ 	      dup findlibfile
+ 	       { (Loading font file ) print exch print (... ) print flush
+ 	         mark exch run cleartomark		% run can take a file
+ 		 (done.\n) print flush
+ 	       }
+ 	       { pop 1 index defaultfontname eq
+ 		  { (Can't find default font!\n) print
+ 		    pop pop /NullFont
+ 		  }
+ 		  { (Can't find font file ) print print
+ 		    (, substituting ) print defaultfontname cvx =only
+ 		    (.\n) print flush
+ 		    pop defaultfontname
+ 		  }
+ 		 ifelse
+ 	       }
+ 	      ifelse
+ 	    }
+ 	   ifelse
+ 
+ 	 } if
+ 
+ 	% Get the font from the augmented FontDirectory.
+ 	% Check for the possibility that we haven't loaded
+ 	% the default font yet.
+ 	dup FontDirectory exch known not
+ 	 { findfont }
+ 	 { FontDirectory exch get }
+ 	ifelse
+ 
+  } bind def
+ 
+ % Here is a reference implementation of addcharpath for "type 7" paths
+ % (the type formerly used by Ghostscript).  We include this for backward
+ % compatibility because Ghostscript's format has changed.
+ /addcharpath		% <string> <pathtype> ->
+  { pop		% don't bother to check the pathtype
+     { moveto 3 -1 roll pop { rlineto } 3 1 roll } exch
+    % In the loop, the top element of the stack is the remaining part
+    % of the string, and the next element is the moveto/rlineto procedure.
+     { dup length 0 eq { exit } if
+       dup 0 get
+       dup 16#88 eq
+       { pop exch pop
+          { moveto 3 -1 roll pop { rlineto } 3 1 roll } exch
+ 	1
+       }
+       { dup 16 ge
+         { dup 15 and 0 ne
+ 	   { % xx
+ 	     dup -4 bitshift 8 sub   exch 15 and 8 sub   1
+ 	   }
+ 	   { % x0
+ 	     -4 bitshift 8 sub   1 index 1 get 128 sub   2
+ 	   }
+ 	  ifelse
+ 	}
+ 	{ dup 15 and 0 ne
+ 	   { % 0x
+ 	     8 sub   1 index 1 get 128 sub exch   2
+ 	   }
+ 	   { % 00
+ 	     pop   dup 1 get 128 sub   1 index 2 get 128 sub   3
+ 	   }
+ 	  ifelse
+ 	}
+ 	ifelse
+ 	3 1 roll		% now: proc string nbytes dx dy
+ 	0.25 mul exch 0.25 mul exch
+ 	4 index exec
+       }
+       ifelse
+       dup 2 index length exch sub getinterval
+     } loop
+    pop pop
+  }
+ bind def
+ 
+ 
+ % The CharStrings for a Ghostscript font are a dictionary in which
+ % the key is the character name, and the value is a compressed
+ % representation of a path, as produced by type1imagepath.
+ % For detailed information, see the book
+ % "Adobe Type 1 Font Format", published by Adobe Systems Inc.
+ 
+ % Here is the BuildChar implementation
+ % for Type 1 (Ghostscript standard) fonts.
+ % The name Type1BuildChar is known to the interpreter.
+ 
+ /Type1BuildChar
+  { exch begin
+     Encoding exch get
+     dup CharStrings exch known not
+      { (Substituting .notdef for ) print = flush /.notdef } if
+     CharStrings exch get
+     PaintType 0 ne
+      { 1 setmiterlimit 1 setlinejoin 1 setlinecap
+        StrokeWidth setlinewidth }
+     if
+     type1addpath	% does a fill or stroke
+    end
+  } bind def


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,121 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* ghost.h */
+ /* Common definitions for GhostScript */
+ #include "gx.h"
+ 
+ /* The typedef for object references */
+ typedef struct ref_s ref;
+ 
+ /* Operator procedure.  Returns an error code or 0 for success. */
+ /* We would like to define */
+ /*	typedef int op_proc_p(P1(ref *));	*/
+ /* but the standard Unix C compiler can't handle a typedef with a */
+ /* procedure type, so we have to work around it.... */
+ #define op_proc_(proc) int proc(P1(ref *))
+ typedef int (*op_proc_p)(P1(ref *));
+ 
+ /*
+  * Object types.  This should be an enum, but there is no way
+  * to declare an enum a subrange of byte rather than int....
+  */
+ #define t_array 0			/* value.refs, uses size */
+ #define t_boolean 1			/* value.index */
+ #define t_dictionary 2			/* value.pdict */
+ #define t_file 3			/* value.pfile, also uses size */
+ #define t_fontID 4			/* value.pfont */
+ #define t_integer 5			/* value.intval */
+ #define t_mark 6			/* (no value) */
+ #define t_name 7			/* value.pname */
+ #define t_null 8			/* (no value) */
+ #define t_operator 9			/* value.opproc, also uses size */
+ #define t_packedarray 10		/* value.refs, uses size */
+ #define t_real 11			/* value.realval */
+ #define t_save 12			/* value.psave */
+ #define t_string 13			/* value.bytes, uses size */
+ /*
+  * The following are extensions to the PostScript type set.
+  * When adding new types, be sure to edit the table in ghost.ps
+  * (type and ==only operators), the printing routine in idebug.c,
+  * and also type_print_strings below.
+  */
+ #define t_color 14			/* value.pcolor */
+ #define t_device 15			/* value.pdevice */
+ #define t_next_index 16		/* *** change this if adding types *** */
+ /*
+  * The interpreter uses types starting at t_next_index for representing
+  * a few high-frequency operators.
+  * Since there are no operations specifically on operators,
+  * there is no need for any operators to check specifically for these
+  * types.  The r_btype macro takes care of the conversion when required.
+  *
+  * Define the type names for debugging printout.
+  * All names must be the same length, so that columns will line up.
+  */
+ #define type_print_strings\
+   "arry","bool","dict","file","font","int ","mark","name","null","oper",\
+   "pary","real","save","str ","colr","devc"
+ 
+ /* Object attributes */
+ #define a_executable 1			/* must be 1 or 2 */
+ #define a_subrange 0x8000		/* subarray or substring */
+ #define a_write 0x100			/* must be >= 0x100 */
+ #define a_read 0x200			/* must be >= 0x100 */
+ #define a_execute 2			/* must be 1 or 2 */
+ #define a_all (a_write+a_read+a_execute)
+ /* Define the attribute names for debugging printout. */
+ #define attr_print_string "xe......wr?????s"
+ 
+ /* Abstract types */
+ typedef struct dict_s dict;
+ typedef struct name_s name;
+ 
+ /* Object reference */
+ struct ref_s {
+ 	union v {			/* name the union to keep gdb happy */
+ 		long intval;
+ 		ushort index;		/* for enumerated things */
+ 		float realval;
+ 		byte *bytes;
+ 		struct ref_s *refs;
+ 		name *pname;
+ 		dict *pdict;
+ 		op_proc_p opproc;
+ 		struct file_entry_s *pfile;
+ 		struct gs_font_s *pfont;
+ 		struct gs_color_s *pcolor;
+ 		struct gx_device_s *pdevice;
+ 		struct vm_save_s *psave;
+ 	} value;
+ /* type_attrs is a single element for fast dispatching in the interpreter */
+ #define r_type(rp) (((rp)->type_attrs & 0xff) >> 2)
+ #define r_has_type(rp,typ) (((rp)->type_attrs & 0xfc) == ((typ) << 2))
+ #define r_set_type(rp,typ) ((rp)->type_attrs = (typ) << 2)
+ #define r_btype(rp) (r_type(rp) >= t_next_index ? t_operator : r_type(rp))
+ #define r_type_xe(rp) ((rp)->type_attrs & 0xff)
+ #define r_attrs(rp) ((rp)->type_attrs)	/* reading only */
+ #define r_has_attrs(rp,mask) !(~r_attrs(rp) & (mask))
+ #define r_set_attrs(rp,mask) ((rp)->type_attrs |= (mask))
+ #define r_clear_attrs(rp,mask) ((rp)->type_attrs &= ~(mask))
+ #define r_set_type_attrs(rp,typ,mask) ((rp)->type_attrs = ((typ) << 2) + (mask))
+ #define null_type_attrs (t_null << 2)
+ 	ushort type_attrs;
+ 	ushort size;
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,631 ----
+ %    Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % Initialization file for Ghostscript.
+ % When this is run, systemdict is still writable.
+ 
+ % Acquire the debugging flags.
+ currentdict /DEBUG known   /DEBUG exch def
+   /VMDEBUG
+     DEBUG {{vmstatus pop (      ) cvs print pop ( ) print
+             systemdict length (      ) cvs print (\n) print flush}}
+ 	  {{}} ifelse
+   def
+ currentdict /NODISPLAY known   not /DISPLAYING exch def
+ currentdict /NOBIND known { /bind { } def } if
+ currentdict /NOCACHE known   /NOCACHE exch def
+ currentdict /QUIET known   /QUIET exch def
+ 
+ %************************** Disable save and restore
+ /save {gsave null} bind def
+ /restore {pop grestore} bind def
+ 
+ % Acquire systemdict and userdict.
+ % Note that the dictionary stack only has 1 element at this point!
+ /systemdict currentdict def
+ /userdict 200 dict def
+ userdict begin		% 2 elements now
+ systemdict begin
+ 
+ VMDEBUG
+ 
+ % Define true and false.
+ /true 0 0 eq def
+ /false 0 1 eq def
+ 
+ % Define predefined procedures substituting for operators,
+ % in alphabetical order.
+ /[	/mark load def
+ /] 	{counttomark array astore exch pop} bind def
+ /abs	{dup 0 lt {neg} if} bind def
+ /cleardictstack
+ 	{countdictstack 2 sub {end} repeat} bind def
+ /.copypage /copypage load def
+ /copypage
+ 	{.copypage
+ 	 (>>copypage, press <return> to continue<<\n) .confirm} bind def
+ /defaultmatrix
+ 	{currentdevice exch deviceparams pop pop
+ 	 counttomark 1 add 1 roll cleartomark} bind def
+ /.echo /echo load def
+ /.echo.mode true def
+ /echo	{dup /.echo.mode exch def .echo} bind def
+ /eexec	{55665 exch type1decryptfile
+ 	 % eexec sections have 4 garbage characters at the beginning.
+ 	 % We should detect binary vs. hex encoding here.
+ 	   4 {dup read pop pop} repeat
+ 	 cvx systemdict begin stopped end
+ 	 $error /newerror get and {handleerror} if} bind def
+ /executive
+ 	{{prompt (%statementedit) (r) file
+ 	 dup bytesavailable 0 lt
+ 	  {(%stdin) (r) file bytesavailable 0 lt {closefile exit} if}
+ 	 if cvx execute} loop} bind def
+ /framedevice			% dummy definition
+ 	{(Warning: framedevice is not implemented.\n) print flush
+ 	 pop pop pop setmatrix initclip} bind def
+ /handleerror
+ 	{errordict /handleerror get exec} bind def
+ /identmatrix
+ 	{{1.0 0.0 0.0 1.0 0.0 0.0} cvlit exch copy} bind def
+ /initgraphics
+ 	{initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin
+ 	 {} 0 setdash 0 setgray 10 setmiterlimit} bind def
+ /initmatrix
+ 	{.tempmatrix defaultmatrix setmatrix} bind def
+ %.nulldevice does all of nulldevice except initclip and initmatrix.
+ /nulldevice
+ 	{.nulldevice initclip initmatrix} bind def
+ /matrix	{6 array identmatrix} bind def
+ /prompt	{flush flushpage
+ 	 (GS) print count 0 ne
+ 	  {(<) print count =only}
+ 	 if (>) print flush} bind def
+ /pstack	{0 1 count 3 sub {index ==} for} bind def
+ /run	{dup type /filetype eq { true } { findlibfile } ifelse
+ 	  {cvx execute}
+ 	  {(r) file}		% let the error happen
+ 	 ifelse} bind def
+ %.setgray is the same as setgray without the transfer function.
+ /setgray
+ 	{currenttransfer exec .setgray} bind def
+ /showpage
+ 	{.copypage (>>showpage, press <return> to continue<<\n) .confirm
+ 	 erasepage initgraphics} bind def
+ /stack	{0 1 count 3 sub {index =} for} bind def
+ /start	{ QUIET not
+ 	  {(Ghostscript ) print version print
+ 	   (  Copyright (C) 1990 Aladdin Enterprises,\n) print
+ 	   (   Menlo Park, CA.  All rights reserved.\n) print
+ 	   (Distributed by Free Software Foundation, Inc.\n) print
+ 	   (Ghostscript comes with NO WARRANTY: see the file COPYING for details.\n) print
+ 	   flush
+ 	  } if
+ 	  executive
+ 	} def
+ %.typenumber is a non-standard operator.
+ /type	{.typenumber
+ 		{arraytype booleantype dicttype filetype fonttype
+ 		 integertype marktype nametype nulltype operatortype
+ 		 packedarraytype realtype savetype stringtype
+ 		 colortype devicetype}
+ 	 exch get} def
+ /version
+ 	(2.1.1) def
+ 
+ % Provide semi-fake but usable definitions for
+ % the color PostScript extensions (except for colorimage,
+ % which is actually implemented as an operator).
+ /setcmykcolor {
+ 	1 exch sub dup dup		% C, M, Y, S, S, S
+ 	6 -1 roll 1 exch sub mul	% M, Y, S, S, red
+ 	exch 5 -1 roll 1 exch sub mul	% Y, S, red, green
+ 	4 -2 roll exch 1 exch sub mul	% red, green, blue
+ 	setrgbcolor
+ } bind def
+ /currentcmykcolor {
+ 	currentrgbcolor 0
+ } bind def
+ /setcolortransfer {
+ 	settransfer pop pop pop
+ } bind def
+ /currentcolortransfer {
+ 	{} dup dup currenttransfer
+ } bind def
+ /setblackgeneration {
+ 	pop
+ } bind def
+ /currentblackgeneration {
+ 	{}
+ } bind def
+ /setundercolorremoval {
+ 	pop
+ } bind def
+ /currentundercolorremoval {
+ 	{}
+ } bind def
+ /setcolorscreen {
+ 	setscreen 9 {pop} repeat
+ } bind def
+ /currentcolorscreen {
+ 	currentscreen 3 copy 6 copy
+ } bind def
+ 
+ % Define some additional built-in procedures (beyond the ones defined by
+ % the PostScript Language Reference Manual).
+ /concatprocs
+ 	{ exch cvlit exch cvlit		% proc1 proc2
+ 	  dup length 2 index length add array	% proc1 proc2 newproc
+ 	  dup 0 4 index putinterval
+ 	  dup 3 index length 3 index putinterval
+ 	  exch pop exch pop cvx
+ 	} bind def
+ /concatstrings
+ 	{ 1 index length 1 index length add string
+ 	  2 index 1 index copy pop
+ 	  dup 3 index length 3 index length getinterval
+ 	  2 index exch copy pop
+ 	  exch pop exch pop
+ 	} bind def
+ /copystring
+ 	{ dup length string copy } bind def
+ /defaultdevice
+ 	{ 0 getdevice } bind def
+ /finddevice
+ 	{ systemdict /devicedict get exch get } bind def
+ /rgbcolor
+ 	{ gsave setrgbcolor currentgscolor grestore } bind def
+ %.setdevice does all of setdevice except initclip and initmatrix.
+ /setdevice
+ 	{ .setdevice initclip initmatrix } bind def
+ 
+ % Define auxiliary procedures needed for the above.
+ /.confirm
+ 	{DISPLAYING
+ 	  {% Print a message and wait for the user to type something.
+ 	   % If the user just types a newline, flush it.
+ 	   print flush
+ 	   .echo.mode false echo
+ 	     (%stdin) (r) file dup read
+ 	     {dup (\n) 0 get eq {pop pop} {unread} ifelse} {pop} ifelse
+ 	   echo}
+ 	  {pop} ifelse} bind def
+ /.identmatrix		% a read-only identity matrix
+ 	matrix readonly def
+ /.tempmatrix		% a temporary matrix
+ 	matrix def
+ 
+ % If the interpreter includes the Level 2 functions,
+ % load the initialization file for them.
+ systemdict /uappend known		% pick any one
+  { (ghost2.ps) run }
+ if
+ 
+ % Define the procedure used by the C executive for executing user input,
+ % and also by the run operator.
+ % This is called with a procedure or file on the operand stack.
+ /execute
+ 	{stopped $error /newerror get and {handleerror} if} bind def
+ 
+ % Create the error handling machinery.
+ % The interpreter knows the name ErrorNames.
+ {/unknown /dictfull /dictstackoverflow /dictstackunderflow
+  /execstackoverflow /interrupt /invalidaccess /invalidexit
+  /invalidfileaccess /invalidfont /invalidrestore /ioerror
+  /limitcheck /nocurrentpoint /rangecheck /stackoverflow
+  /stackunderflow /syntaxerror /timeout /typecheck
+  /undefined /undefinedfilename /undefinedresult /unmatchedmark
+  /VMerror
+ } cvlit readonly
+ dup length 2 add dict		% ErrorNames, handleerror
+ /errordict exch def
+ errordict begin
+   /ErrorNames exch def
+   { $error /.inerror get { = flush quit } if	% detect error recursion
+     $error /.inerror true put
+     countdictstack array dictstack
+     $error begin
+       /newerror true def
+       /dstack exch def
+       /errorname exch def
+       /command exch def
+       countexecstack array execstack /estack exch def
+       count array astore /ostack exch def
+       ostack aload pop
+     end
+     $error /.inerror false put
+     stop
+   } bind
+   ErrorNames
+    { [ 1 index 3 index /exec load ] cvx def
+    } forall
+   pop
+   /handleerror
+    { (Error: ) print
+      $error begin
+        errorname ==only
+        ( in ) print
+        /command load ==
+        (  ostack:) print
+          ostack {( ) print =only} forall
+        (\n  estack: ) print
+          estack {( ) print =only} forall
+        (\n  dstack:) print
+          dstack {dup ( ) print length =only (/) print maxlength =only} forall
+        (\n) print
+        /newerror false def
+        flush
+      end
+    } bind def
+ end
+ /$error 7 dict def		% newerror, .inerror, errorname, command,
+ 				% 3 stacks
+ $error begin
+   /newerror false def
+   /.inerror false def
+ end
+ 
+ % Define the =[only] procedures.  Also define =print, which is used
+ % by LaserPrep even though it isn't documented anywhere.
+ /=	{=only (\n) print} bind def
+ /=print	{=} bind def
+ /.dict 16 dict dup
+ begin def
+   /.buf 128 string def
+   /.cvp {.buf cvs .p} bind def
+   /.print
+ 	{dup type .dict exch known
+ 	 {dup type exec} {.buf cvs print} ifelse
+ 	} bind def
+   /stringtype
+ 	{dup rcheck not {pop (--nostringval--)} if print} bind def
+   /nametype
+ 	{dup length .buf length gt
+ 	 {dup length string}
+ 	 {.buf}
+ 	ifelse cvs print} bind def
+ {0 begin .print end} bind dup 0 .dict put
+ end
+ /=only exch def
+ 
+ % Define the [write]==[only] procedures.
+ /==	{==only (\n) print} bind def
+ /==only	{(%stdout) (w) file exch write==only} bind def
+ /write==
+ 	{2 copy write==only pop (\n) writestring} bind def
+ /.dict 17 dict dup
+ begin def
+   /.buf 128 string def
+   /.cvp {.buf cvs .p} bind def
+ % /.f {the_output_file} def
+   /.nop {(-) .p type .cvp (-) .p} bind def
+   /.p {.f exch writestring} bind def
+   /.p1 {.f exch write} bind def
+   /.print
+ 	{dup type .dict exch known
+ 	 {dup type exec} {.nop} ifelse
+ 	} bind def
+   /integertype /.cvp load def
+   /realtype /.cvp load def
+   /booleantype /.cvp load def
+   /nametype
+ 	{dup xcheck not {(/) .p} if
+ 	 dup length .buf length gt
+ 	  {dup length string}
+ 	  {.buf}
+ 	 ifelse cvs .p} bind def
+   /arraytype
+ 	{dup rcheck
+ 	  {dup xcheck {(})({)} {(])([)} ifelse .p
+ 	   exch () exch
+ 	   {exch .p .print ( )} forall pop .p}
+ 	  {.nop}
+ 	 ifelse} bind def
+   /operatortype
+   	{(--) .p .cvp (--) .p} bind def
+   /packedarraytype /arraytype load def
+   /stringtype
+ 	{dup rcheck
+ 	  {(\() .p
+ 	   {/.ch exch def
+ 	    .ch 32 lt .ch 127 ge or
+ 	    {(\\) .p .ch 8#1000 add 8 .buf cvrs 1 3 getinterval .p}
+ 	    {.ch 40 eq .ch 41 eq or .ch 92 eq or
+ 	     {(\\) .p} if
+ 	     .ch .p1}
+ 	    ifelse}
+ 	   forall (\)) .p}
+ 	  {.nop}
+ 	 ifelse} bind def
+ {0 begin exch /.f exch def .print end} bind dup 0 .dict put
+ end
+ /write==only exch def
+ 
+ VMDEBUG
+ 
+ % Define the font directory.
+ % Make it big to leave room for transformed fonts.
+ /FontDirectory 100 dict def
+ 
+ % Define the standard encoding vector.
+ /StandardEncoding {
+ % \00x
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+ % \04x
+     /space /exclam /quotedbl /numbersign
+ 	/dollar /percent /ampersand /quoteright
+     /parenleft /parenright /asterisk /plus
+ 	/comma /hyphen /period /slash
+     /zero /one /two /three
+ 	/four /five /six /seven
+     /eight /nine /colon /semicolon
+ 	/less /equal /greater /question
+ % \10x
+     /at /A /B /C /D /E /F /G
+     /H /I /J /K /L /M /N /O
+     /P /Q /R /S /T /U /V /W
+     /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
+ % \14x
+     /quoteleft /a /b /c /d /e /f /g
+     /h /i /j /k /l /m /n /o
+     /p /q /r /s /t /u /v /w
+     /x /y /z /braceleft /bar /braceright /asciitilde /.notdef
+ % \20x
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+ % \24x
+     /.notdef /exclamdown /cent /sterling
+ 	/fraction /yen /florin /section
+     /currency /quotesingle /quotedblleft /guillemotleft
+ 	/guilsinglleft /guilsinglright /fi /fl
+     /.notdef /endash /dagger /daggerdbl
+ 	/periodcentered /.notdef /paragraph /bullet
+     /quotesinglbase /quotedblbase /quotedblright /guillemotright
+ 	/ellipsis /perthousand /.notdef /questiondown
+ % \30x
+     /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent
+     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
+     /emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+ % \34x
+     /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef
+     /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef
+     /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef
+     /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef
+ } cvlit readonly def
+ 
+ % Define the ISO Latin-1 encoding vector.
+ % The first half is the same as the standard encoding.
+ /ISOLatin1Encoding
+ StandardEncoding 256 array copy
+ dup 128 128 getinterval
+ %****** NOTE: the following are missing in the Adobe documentation,
+ %****** but appear in the displayed table:
+ %****** macron at 225, dieresis at 230, cedilla at 233, space at 240.
+ % \20x
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
+     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
+ % \24x
+     /space /exclamdown /cent /sterling
+ 	/currency /yen /brokenbar /section
+     /dieresis /copyright /ordfeminine /guillemotleft
+ 	/logicalnot /hyphen /registered /macron
+     /degree /plusminus /twosuperior /threesuperior
+ 	/acute /mu /paragraph /periodcentered
+     /cedilla /onesuperior /ordmasculine /guillemotright
+ 	/onequarter /onehalf /threequarters /questiondown
+ % \30x
+     /Agrave /Aacute /Acircumflex /Atilde
+ 	/Adieresis /Aring /AE /Ccedilla
+     /Egrave /Eacute /Ecircumflex /Edieresis
+ 	/Igrave /Iacute /Icircumflex /Idieresis
+     /Eth /Ntilde /Ograve /Oacute
+ 	/Ocircumflex /Otilde /Odieresis /multiply
+     /Oslash /Ugrave /Uacute /Ucircumflex
+ 	/Udieresis /Yacute /Thorn /germandbls
+ % \34x
+     /agrave /aacute /acircumflex /atilde
+ 	/adieresis /aring /ae /ccedilla
+     /egrave /eacute /ecircumflex /edieresis
+ 	/igrave /iacute /icircumflex /idieresis
+     /eth /ntilde /ograve /oacute
+ 	/ocircumflex /otilde /odieresis /divide
+     /oslash /ugrave /uacute /ucircumflex
+ 	/udieresis /yacute /thorn /ydieresis
+ 129 -1 roll astore pop readonly def
+ 
+ % Define the Symbol encoding vector.
+ /SymbolEncoding {
+ % \000
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+ % \040
+     /space /exclam /universal /numbersign
+ 	/existential /percent /ampersand /suchthat
+     /parenleft /parenright /asteriskmath /plus
+ 	/comma /minus /period /slash
+     /zero /one /two /three
+ 	/four /five /six /seven
+     /eight /nine /colon /semicolon
+ 	/less /equal /greater /question
+ % \100
+     /congruent /Alpha /Beta /Chi
+ 	/Delta /Epsilon /Phi /Gamma
+     /Eta /Iota /theta1 /Kappa
+ 	/Lambda /Mu /Nu /Omicron
+     /Pi /Theta /Rho /Sigma
+ 	/Tau /Upsilon /sigma1 /Omega
+     /Xi /Psi /Zeta /bracketleft
+ 	/therefore /bracketright /perpendicular /underscore
+ % \140
+     /radicalex /alpha /beta /chi
+ 	/delta /epsilon /phi /gamma
+     /eta /iota /phi1 /kappa
+ 	/lambda /mu /nu /omicron
+     /pi /theta /rho /sigma
+ 	/tau /upsilon /omega1 /omega
+     /xi /psi /zeta /braceleft
+ 	/bar /braceright /similar /.notdef
+ % \200
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
+ % \240
+     /.notdef /Upsilon1 /minute /lessequal
+ 	/fraction /infinity /florin /club
+     /diamond /heart /spade /arrowboth
+ 	/arrowleft /arrowup /arrowright /arrowdown
+     /degree /plusminus /second /greaterequal
+ 	/multiply /proportional /partialdiff /bullet
+     /divide /notequal /equivalence /approxequal
+ 	/ellipsis /arrowvertex /arrowhorizex /carriagereturn
+ % \300
+     /aleph /Ifraktur /Rfraktur /weierstrass
+ 	/circlemultiply /circleplus /emptyset /intersection
+     /union /propersuperset /reflexsuperset /notsubset
+ 	/propersubset /reflexsubset /element /notelement
+     /angle /gradient /registerserif /copyrightserif
+ 	/trademarkserif /product /radical /dotmath
+     /logicalnot /logicaland /logicalor /arrowdblboth
+ 	/arrowdblleft /arrowdblup /arrowdblright /arrowdbldown
+ % \340
+     /lozenge /angleleft /registersans /copyrightsans
+ 	/trademarksans /summation /parenlefttp /parenleftex
+     /parenleftbt /bracketlefttp /bracketleftex /bracketleftbt
+ 	/bracelefttp /braceleftmid /braceleftbt /braceex
+     /.notdef /angleright /integral /integraltp
+ 	/integralex /integralbt /parenrighttp /parenrightex
+     /parenrightbt /bracketrighttp /bracketrightex /bracketrightbt
+ 	/bracerighttp /bracerightmid /bracerightbt /.notdef
+ } cvlit readonly def
+ 
+ % Construct a dictionary of all available devices.
+ mark
+ 	% Loop until the getdevice gets a rangecheck.
+   0 { {dup getdevice exch 1 add} loop} stopped pop
+   pop 1 add dict /devicedict exch def
+   devicedict begin
+     counttomark {dup devicename cvn exch def} repeat
+   end
+ pop		% pop the mark
+ $error /newerror false put		% remove error indication
+ 
+ % Define statusdict, for the benefit of programs
+ % that think they are running on a LaserWriter or similar printer.
+ (statusd.ps) run
+ 
+ % Establish a default upper limit in the character cache,
+ % namely, 10 times the average expected character size.
+ mark
+  cachestatus 5 index 10 mul 2 index 1 max idiv		% bmax, cmax
+   mark exch dup 10 idiv exch setcacheparams
+ cleartomark
+ % Conditionally disable the character cache.
+ NOCACHE { 1 setcachelimit } if
+ 	
+ VMDEBUG
+ 
+ % Create a null font.  This is the initial font.
+ 8 dict dup begin
+   /FontMatrix [ 1 0 0 1 0 0 ] def
+   /PaintType 0 def
+   /FontType 3 def
+   /FontName () def
+   /Encoding StandardEncoding def
+   /FontBBox { 0 0 0 0 } def
+   /BuildChar { pop pop 0 0 setcharwidth } bind def
+ end
+ /NullFont exch definefont setfont
+ 
+ % Load the standard font environment.
+ (gfonts.ps) run
+ 
+ % Close up systemdict.
+ end
+ % We should make systemdict readonly; however, statusd.ps adds new entries
+ % to systemdict.  Maybe dictionaries should have an "add-only" mode....
+ %%%%%% systemdict readonly pop
+ 
+ % Establish a default environment.
+ DISPLAYING
+  { defaultdevice
+    systemdict /DEVICEWIDTH known systemdict /DEVICEHEIGHT known or
+     { matrix deviceparams
+       exch /DEVICEWIDTH where
+        { pop pop DEVICEWIDTH }
+       if
+       exch /DEVICEHEIGHT where
+        { pop pop DEVICEHEIGHT
+          % Replace the Y translation if the Y axis is inverted
+ 	 2 index 5 get 0 gt
+ 	  { 2 index 5 2 index put
+ 	  }
+ 	 if
+        }
+       if
+       defaultdevice 4 1 roll makedevice
+       counttomark 1 add 1 roll cleartomark
+     }
+    if setdevice
+  }
+  { nulldevice
+  }
+ ifelse
+ 1 setflat		% initgraphics doesn't set this
+ { } settransfer		% ditto
+ % The following 'ordered dither' spot function was contributed by
+ % Gregg Townsend.  Thanks, Gregg!
+   72 72 dtransform abs exch abs min	% min(|dpi x|,|dpi y|)
+   16.001 div 0			% not 16: avoids rounding problems
+    { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
+ 	0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
+ 	CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
+ 	3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
+ 	FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
+ 	01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
+ 	C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
+ 	31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
+ 	F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
+ 	0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
+ 	CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
+ 	3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
+ 	FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
+ 	02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
+ 	C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
+ 	32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
+ 	F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
+    > exch get 256 div } bind setscreen
+ initgraphics
+ DISPLAYING
+  { erasepage
+  } if
+ 
+ VMDEBUG
+ 
+ % The interpreter will run the initial procedure (start).


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost2.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost2.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ghost2.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,109 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % Initialization file for Ghostscript Level 2 functions.
+ % When this is run, systemdict is still writable.
+ 
+ % Define the rectangle procedures in terms of .rectappend.
+ /rectclip
+ 	{ newpath .rectappend clip newpath } bind def
+ /rectfill
+ 	{ gsave newpath .rectappend fill grestore } bind def
+ /rectstroke
+ 	{ gsave newpath .rectappend stroke grestore } bind def
+ 
+ % Define the user path procedures in terms of uappend.
+ /ucache
+ 	{ } def
+ /ueofill
+ 	{ gsave newpath uappend eofill grestore } bind def
+ /ufill
+ 	{ gsave newpath uappend fill grestore } bind def
+ /upath
+ 	{ [ exch {/ucache cvx} if pathbbox /setbbox cvx
+ 	  {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx}
+ 	  pathforall ] cvx
+ 	} bind def
+ %****** Implement .ismatrix: push true/false if top is matrix
+ /ustroke
+ 	{ .ismatrix gsave newpath
+ 	  {exch uappend concat} {uappend} ifelse
+ 	  stroke grestore
+ 	} bind def
+ /ustrokepath
+ 	{ .ismatrix newpath
+ 	  {exch uappend //.tempmatrix currentmatrix exch concat
+ 	   strokepath setmatrix}
+ 	  {uappend strokepath} ifelse
+ 	} bind def
+ % Dummy definitions for cache control operators
+ /ucachestatus
+ 	{ mark 0 0 0 0 0 } bind def
+ /setucacheparams
+ 	{ cleartomark } bind def
+ 
+ % Initialize the system name table
+ {
+ % 0
+ 	/abs /add /aload /anchorsearch /and
+ 	/arc /arcn /arct /arcto /array
+ 	/ashow /astore /awidthshow /begin /bind
+ 	/bitshift /ceiling /charpath /clear /cleartomark
+ % 20
+ 	/clip /clippath /closepath /concat /concatmatrix
+ 	/copy /count /counttomark /currentcmykcolor /currentdash
+ 	/currentdict /currentfile /currentfont /currentgray /currentgstate
+ 	/currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
+ % 40
+ 	/currentpoint /currentrgbcolor /currentshared /curveto /cvi
+ 	/cvlit /cvn /cvr /cvrs /cvs
+ 	/cvx /def /defineusername /dict /div
+ 	/dtransform /dup /end /eoclip /eofill
+ % 60
+ 	% ... 160 more
+ % 220
+ 	/makepattern /setcolor /setcolorspace /setglobal /setpagedevice
+ 	/setpattern //null //null //null //null
+ 	//null //null //null //null //null
+ 	//null //null //null //null //null
+ % 240
+ 	//null //null //null //null //null
+ 	//null //null //null //null //null
+ 	//null //null //null //null //null
+ 	//null /= /== /ISOLatin1Encoding /StandardEncoding
+ % 260
+ 	/[ /] /atan /banddevice /bytesavailable
+ 	/cachestatus /closefile /colorimage /condition /copypage
+ 	/cos /countdictstack /countexecstack /cshow /currentblackgeneration
+ 	/currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
+ % 280
+ 	/currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
+ 	/currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
+ 	/definefont /deletefile /detach /deviceinfo /dictstack
+ 	/echo /erasepage /errordict /execstack /executeonly
+ % 300
+ 	% ... 76 more
+ % 376
+ 	/A /B /C /D /E /F /G /H /I /J /K /L /M
+ 	/N /O /P /Q /R /S /T /U /V /W /X /Y /Z
+ 	/a /b /c /d /e /f /g /h /i /j /k /l /m
+ 	/n /o /p /q /r /s /t /u /v /w /x /y /z
+ % 428
+ 	% ... 50 more
+ } cvlit readonly /SystemNames exch def


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/golfer.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/golfer.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/golfer.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,1398 ----
+ %!PS-Adobe-2.0 EPSF-1.2
+ %%Creator:Adobe Illustrator(TM) 1.0b2-
+ %%Title:golfer art+
+ %%CreationDate:1/6/87 9:32 AM
+ %%DocumentFonts:Helvetica-Bold
+ %%BoundingBox:7 31 577 726
+ %%TemplateBox:0 -48 576 672
+ %%EndComments
+ 100 dict begin
+ /q{bind def}bind def
+ /Q{load def}q
+ /x{exch def}q
+ /X/def Q
+ /g{/_g x/p{_g setgray}X}q
+ /G{/_G x/P{_G setgray}X}q
+ /k{/_b x/_g x/_r x/p{_r _g _b setrgbcolor}X}q
+ /K{/_B x/_G x/_R x/P{_R _G _B setrgbcolor}X}q
+ /d/setdash Q
+ /i/setflat Q
+ /j/setlinejoin Q
+ /J/setlinecap Q
+ /M/setmiterlimit Q
+ /w/setlinewidth Q
+ /_C{.25 sub round .25 add}q
+ /_c{transform _C exch _C exch itransform}q
+ /c{_c curveto}q
+ /C/c Q
+ /v{currentpoint 6 2 roll _c curveto}q
+ /V/v Q
+ /y{_c 2 copy curveto}q
+ /Y/y Q
+ /l{_c lineto}q
+ /L/l Q
+ /m{_c moveto}q
+ /_e[]X
+ /_E{_e length 0 ne{gsave 1 g 0 G 1 i 0 J 0 j .5 w 10 M[]0 d
+ /Helvetica-Bold 24 0 0 1 z
+ [0.966 0.259 -0.259 0.966
+ _e 0 get _e 2 get add 2 div _e 1 get _e 3 get add 2 div]a
+ (ERROR: can't fill a path)t T grestore}if}q
+ /n/newpath Q
+ /N/newpath Q
+ /F{p{fill}stopped{/_e[pathbbox]X n _E}if}q
+ /f{closepath F}q
+ /S{P stroke}q
+ /s{closepath S}q
+ /B{gsave F grestore S}q
+ /b{closepath B}q
+ /u{}q
+ /U{}q
+ /_s/ashow Q
+ /_S{(?)exch{2 copy 0 exch put pop dup true charpath currentpoint _m setmatrix
+ stroke _M setmatrix moveto 3 copy pop rmoveto}forall pop pop pop n}q
+ /_A{_a moveto _t exch 0 exch}q
+ /_L{0 _l neg translate _M currentmatrix pop}q
+ /_w{dup stringwidth exch 3 -1 roll length 1 sub _t mul add exch}q
+ /_z[{0 0}bind{dup _w exch neg 2 div exch neg 2 div}bind
+ {dup _w exch neg exch neg}bind]X
+ /z{_z exch get/_a x/_t x/_l x exch findfont exch scalefont setfont}q
+ /_d{matrix currentmatrix X}q
+ /_D{/_m _d gsave concat/_M _d}q
+ /e{_D p/t{_A _s _L}X}q
+ /r{_D P/t{_A _S _L}X}q
+ /a{_D/t{dup p _A _s P _A _S _L}X}q
+ /o{_D/t{pop _L}X}q
+ /T{grestore}q
+ /Z{findfont begin currentdict dup length dict begin
+ {1 index/FID ne{X}{pop pop}ifelse}forall/FontName exch X dup length 0 ne
+ {/Encoding Encoding 256 array copy X 0 exch{dup type/nametype eq
+ {Encoding 2 index 2 index put pop 1 add}{exch pop}ifelse}forall}if pop
+ currentdict dup end end/FontName get exch definefont pop}q
+ n
+ %%EndProlog
+ u
+ 0.9 g
+ 0 G
+ 1 i
+ 0 J
+ 0 j
+ 1 w
+ 10 M
+ []0 d
+ %%Note:
+ 15.815 40.248 m
+ 567.815 40.002 L
+ 567.748 716.565 L
+ 15.998 716.81 L
+ 15.815 40.248 L
+ b
+ U
+ 1 g
+ 285.313 40 m
+ 567.688 40.125 L
+ 567.812 78.375 L
+ 285.312 78.25 L
+ 285.313 40 L
+ b
+ 0 g
+ 175.5 163 m
+ 180.007 163 173.738 169.081 171.75 168.75 c
+ 174.75 169.25 176.25 169.5 174.5 171.25 C
+ 178 171.25 176.349 173.783 175 176.75 c
+ 173.75 179.5 170.75 182.25 168.25 182 C
+ 165.5 181.25 167.622 182.838 165.25 186 c
+ 164.5 187 164.75 187.5 161.75 186.75 c
+ 158.75 186 163.25 190 156.75 190 c
+ 150.25 190 148.5 189 145.5 186 c
+ 142.5 183 139.75 183.75 139.5 182.5 c
+ 139.25 181.25 139.5 176.75 138.75 175.5 c
+ 138 174.25 136.75 174.25 136.25 178 c
+ 135.75 181.75 140.25 182.25 134 187 C
+ 135.75 190.75 134.5 191.75 131 193.5 C
+ 131 200 129.202 203.364 119.5 208.5 c
+ 115.25 210.75 107 212.75 104.75 208.75 c
+ 102.5 204.75 103 206.5 96.5 205.75 c
+ 90 205 87.25 202.5 86.5 197.75 c
+ 85.75 193 82.75 195 79 194.75 c
+ 75.25 194.5 77 192.75 77.25 191.75 c
+ 77.5 190.75 75.25 192.5 71.5 192 c
+ 67.75 191.5 64.25 185.5 69.5 180.75 c
+ 74.75 176 66.5 180.75 64.25 182.25 c
+ 62 183.75 60.5 181.75 61 180.25 c
+ 61.5 178.75 58.75 180.75 57.5 180.75 c
+ 56.25 180.75 51.008 180.188 52 172.25 c
+ 52.25 170.25 51.5 170.5 49.75 169.25 c
+ 48 168 45.75 164.25 48.5 158.75 c
+ 51.25 153.25 49 150 48 145.5 c
+ 47 141 48 138.25 51.25 137.25 c
+ 54.5 136.25 54 133.791 54 130.75 C
+ 57 130.5 59 129.25 58.75 124.5 C
+ 62.25 124.5 61.75 126.75 62.5 130 c
+ 63.25 133.25 65.75 129 66.25 127 c
+ 66.75 125 67.5 125 72 125 C
+ 74.75 116.25 74.75 120.5 75.25 117.25 C
+ 80 117.5 79.5 116.75 83.25 113.75 c
+ 87 110.75 88.25 115.5 92 118.5 c
+ 95.75 121.5 94.25 122.75 96.25 118.75 c
+ 98.25 114.75 98.5 119 101.5 119.25 c
+ 104.5 119.5 101 115.75 105.25 114.5 c
+ 109.5 113.25 105 113.75 103.5 111.25 c
+ 102 108.75 95 103.5 101.75 101.5 c
+ 108.5 99.5 103.5 99.75 94.75 99.5 c
+ 86 99.25 73.75 87.5 97.25 73.25 C
+ 117.25 53.25 117.25 53.5 v
+ 117.25 53.75 175.25 163 175.5 163 c
+ f
+ 1 J
+ 0.2 w
+ 389.709 210.076 m
+ 511.826 210.076 l
+ S
+ 394.709 212.461 m
+ 516.826 212.461 l
+ S
+ 415.459 215.112 m
+ 537.576 215.112 l
+ S
+ 399.709 217.762 m
+ 521.826 217.762 l
+ S
+ 402.459 222.799 m
+ 524.576 222.799 l
+ S
+ 402.709 225.45 m
+ 524.826 225.45 l
+ S
+ 392.959 227.851 m
+ 515.076 227.851 l
+ S
+ 400.691 232.856 m
+ 522.809 232.856 l
+ S
+ 388.191 235.241 m
+ 510.309 235.241 l
+ S
+ 393.941 237.892 m
+ 516.059 237.892 l
+ S
+ 393.441 240.292 m
+ 515.559 240.292 l
+ S
+ 396.191 242.928 m
+ 518.309 242.928 l
+ S
+ 386.441 245.579 m
+ 508.559 245.579 l
+ S
+ 393.191 248.23 m
+ 515.309 248.23 l
+ S
+ 414.191 250.631 m
+ 536.309 250.631 l
+ S
+ 397.95 252.973 m
+ 520.067 252.973 l
+ S
+ 398.7 255.358 m
+ 520.817 255.358 l
+ S
+ 400.7 258.009 m
+ 522.817 258.009 l
+ S
+ 384.45 260.659 m
+ 506.567 260.659 l
+ S
+ 380.7 265.696 m
+ 502.817 265.696 l
+ S
+ 379.95 268.347 m
+ 502.067 268.347 l
+ S
+ 386.7 270.748 m
+ 508.817 270.748 l
+ S
+ 394.433 275.752 m
+ 516.55 275.752 l
+ S
+ 381.933 278.138 m
+ 504.05 278.138 l
+ S
+ 379.433 280.789 m
+ 501.55 280.789 l
+ S
+ 383.183 283.189 m
+ 505.3 283.189 l
+ S
+ 370.433 285.825 m
+ 492.55 285.825 l
+ S
+ 382.433 288.476 m
+ 504.55 288.476 l
+ S
+ 356.183 291.127 m
+ 478.3 291.127 l
+ S
+ 372.433 293.277 m
+ 494.55 293.277 l
+ S
+ 361.866 296.006 m
+ 483.984 296.006 l
+ S
+ 365.616 298.406 m
+ 487.734 298.406 l
+ S
+ 366.866 301.042 m
+ 488.984 301.042 l
+ S
+ 346.866 303.693 m
+ 468.984 303.693 l
+ S
+ 338.616 306.344 m
+ 460.734 306.344 l
+ S
+ 330.866 308.494 m
+ 452.984 308.494 l
+ S
+ 301.575 344.342 m
+ 423.692 344.342 l
+ S
+ 314.075 346.728 m
+ 436.192 346.728 l
+ S
+ 318.325 349.378 m
+ 440.442 349.378 l
+ S
+ 312.075 352.029 m
+ 434.192 352.029 l
+ S
+ 327.325 357.065 m
+ 449.442 357.065 l
+ S
+ 327.575 359.716 m
+ 449.692 359.716 l
+ S
+ 317.825 362.117 m
+ 439.942 362.117 l
+ S
+ 335.558 367.122 m
+ 457.675 367.122 l
+ S
+ 313.058 369.507 m
+ 435.175 369.507 l
+ S
+ 318.808 372.158 m
+ 440.925 372.158 l
+ S
+ 317.579 404.674 m
+ 439.696 404.674 l
+ S
+ 322.312 409.179 m
+ 444.429 409.179 l
+ S
+ 323.812 412.065 m
+ 445.929 412.065 l
+ S
+ 329.562 414.715 m
+ 451.679 414.715 l
+ S
+ 329.062 417.116 m
+ 451.179 417.116 l
+ S
+ 331.812 419.752 m
+ 453.929 419.752 l
+ S
+ 322.062 422.402 m
+ 444.179 422.402 l
+ S
+ 328.812 425.053 m
+ 450.929 425.053 l
+ S
+ 349.812 427.454 m
+ 471.929 427.454 l
+ S
+ 333.571 429.796 m
+ 455.688 429.796 l
+ S
+ 334.321 432.182 m
+ 456.438 432.182 l
+ S
+ 336.321 434.832 m
+ 458.438 434.832 l
+ S
+ 320.071 437.483 m
+ 442.188 437.483 l
+ S
+ 316.321 442.519 m
+ 438.438 442.519 l
+ S
+ 315.571 445.17 m
+ 437.688 445.17 l
+ S
+ 322.321 447.571 m
+ 444.438 447.571 l
+ S
+ 330.054 452.576 m
+ 452.171 452.576 l
+ S
+ 317.554 454.961 m
+ 439.671 454.961 l
+ S
+ 315.054 457.612 m
+ 437.171 457.612 l
+ S
+ 318.804 460.012 m
+ 440.921 460.012 l
+ S
+ 306.054 462.648 m
+ 428.171 462.648 l
+ S
+ 300.054 465.299 m
+ 422.171 465.299 l
+ S
+ 291.804 467.95 m
+ 413.921 467.95 l
+ S
+ 308.054 470.101 m
+ 430.171 470.101 l
+ S
+ 260.834 543.511 m
+ 382.951 543.511 l
+ S
+ 246.066 548.016 m
+ 368.184 548.016 l
+ S
+ 256.066 550.901 m
+ 378.184 550.901 l
+ S
+ 253.566 553.552 m
+ 375.684 553.552 l
+ S
+ 230.316 555.952 m
+ 352.434 555.952 l
+ S
+ 244.566 558.588 m
+ 366.684 558.588 l
+ S
+ 238.566 561.239 m
+ 360.684 561.239 l
+ S
+ 230.316 563.89 m
+ 352.434 563.89 l
+ S
+ 216.566 565.541 m
+ 338.684 565.541 l
+ S
+ 104.443 572.01 m
+ 226.575 572.209 l
+ S
+ 98.682 567.48 m
+ 220.814 567.68 l
+ S
+ 91.688 565.11 m
+ 213.82 565.31 l
+ S
+ 97.192 561.955 m
+ 219.324 562.155 l
+ S
+ 73.943 559.517 m
+ 196.075 559.717 l
+ S
+ 88.199 556.904 m
+ 210.331 557.103 l
+ S
+ 82.203 554.243 m
+ 204.335 554.443 l
+ S
+ 73.956 551.578 m
+ 196.088 551.778 l
+ S
+ 73.707 549.405 m
+ 195.839 549.605 l
+ S
+ 85.302 539.953 m
+ 207.434 540.152 l
+ S
+ 79.541 535.423 m
+ 201.673 535.623 l
+ S
+ 72.547 533.053 m
+ 194.679 533.253 l
+ S
+ 78.051 529.898 m
+ 200.183 530.098 l
+ S
+ 54.802 527.46 m
+ 176.934 527.66 l
+ S
+ 69.058 524.847 m
+ 191.19 525.046 l
+ S
+ 63.061 522.186 m
+ 185.194 522.385 l
+ S
+ 54.815 519.521 m
+ 176.947 519.721 l
+ S
+ 54.566 517.348 m
+ 176.698 517.547 l
+ S
+ u
+ 189.475 196.879 m
+ 311.592 196.879 l
+ S
+ 176.975 199.265 m
+ 299.092 199.265 l
+ S
+ 174.475 201.916 m
+ 296.592 201.916 l
+ S
+ 178.225 204.316 m
+ 300.342 204.316 l
+ S
+ 165.475 206.952 m
+ 287.592 206.952 l
+ S
+ 177.475 209.603 m
+ 299.592 209.603 l
+ S
+ 155.725 212.254 m
+ 277.842 212.254 l
+ S
+ 167.475 214.404 m
+ 289.592 214.404 l
+ S
+ 156.908 217.133 m
+ 279.026 217.133 l
+ S
+ 144.658 219.533 m
+ 266.776 219.533 l
+ S
+ 161.908 222.169 m
+ 284.026 222.169 l
+ S
+ 153.908 224.82 m
+ 276.026 224.82 l
+ S
+ 163.658 226.971 m
+ 285.776 226.971 l
+ S
+ 152.408 229.121 m
+ 274.526 229.121 l
+ S
+ 145.925 233.316 m
+ 268.042 233.316 l
+ S
+ 157.675 235.466 m
+ 279.792 235.466 l
+ S
+ 147.108 238.195 m
+ 269.226 238.195 l
+ S
+ 134.858 240.595 m
+ 256.976 240.595 l
+ S
+ 137.608 243.231 m
+ 259.726 243.231 l
+ S
+ 144.108 245.882 m
+ 266.226 245.882 l
+ S
+ 153.858 248.033 m
+ 275.976 248.033 l
+ S
+ 155.108 231.183 m
+ 277.226 231.183 l
+ S
+ 103.425 247.816 m
+ 225.542 247.816 l
+ S
+ 100.175 249.966 m
+ 222.292 249.966 l
+ S
+ 89.608 252.695 m
+ 211.726 252.695 l
+ S
+ 77.358 255.095 m
+ 199.476 255.095 l
+ S
+ U
+ u
+ 1 g
+ 0 J
+ 1 w
+ 120.001 389.999 m
+ 170.811 344.713 248.714 349.191 294.001 400.001 c
+ 339.287 450.811 334.809 528.714 283.999 574.001 c
+ 233.189 619.287 155.286 614.809 109.999 563.999 c
+ 64.713 513.189 69.191 435.286 120.001 389.999 c
+ f
+ 202 482 m
+ F
+ U
+ u
+ 258 302 m
+ 306.6 267.759 373.759 279.4 408 328 c
+ 442.241 376.6 430.6 443.759 382 478 c
+ 333.4 512.241 266.241 500.6 232 452 c
+ 197.759 403.4 209.4 336.241 258 302 c
+ f
+ 320 390 m
+ F
+ U
+ u
+ 196 376 m
+ 252.332 345.072 323.072 365.668 354 422 c
+ 384.928 478.332 364.332 549.072 308 580 c
+ 251.668 610.928 180.928 590.332 150 534 c
+ 119.072 477.668 139.668 406.928 196 376 c
+ f
+ 252 478 m
+ F
+ U
+ u
+ 106 257 m
+ 170.064 231.595 242.595 262.936 268 327 c
+ 293.405 391.064 262.064 463.595 198 489 c
+ 133.936 514.405 61.405 483.064 36 419 c
+ 10.595 354.936 41.936 282.405 106 257 c
+ f
+ 152 373 m
+ F
+ U
+ u
+ 366.001 122 m
+ 415.706 97.7 475.7 118.296 500 168.001 c
+ 524.3 217.706 503.704 277.7 453.999 302 c
+ 404.294 326.3 344.3 305.704 320 255.999 c
+ 295.7 206.294 316.296 146.3 366.001 122 c
+ f
+ 410 212 m
+ F
+ U
+ u
+ 227.999 198 m
+ 267.763 185.85 309.849 208.236 322 247.999 c
+ 334.15 287.763 311.764 329.849 272.001 342 c
+ 232.237 354.15 190.151 331.764 178 292.001 c
+ 165.85 252.237 188.236 210.151 227.999 198 c
+ f
+ 250 270 m
+ F
+ U
+ 0 g
+ 15.75 71.25 m
+ 24.25 82.75 24.75 84.75 27.75 82.25 c
+ 30.75 79.75 31.75 81.25 32.75 82.75 c
+ 33.75 84.25 30.75 86.75 35.75 88.75 c
+ 40.75 90.75 41.25 91.75 43.25 89.75 c
+ 45.25 87.75 39.25 89.25 50.25 88.75 c
+ 61.25 88.25 70.25 81.75 74.25 75.25 c
+ 78.25 68.75 77.75 67.25 75.25 63.25 c
+ 72.75 59.25 68.25 56.75 72.25 57.25 c
+ 76.25 57.75 75.75 60.75 77.75 56.75 c
+ 79.75 52.75 80.25 51.25 79.25 49.25 c
+ 78.25 47.25 74.25 46.75 81.25 46.25 c
+ 88.25 45.75 91.75 37.557 91.75 40.25 c
+ 15.752 40.248 l
+ 15.75 71.25 l
+ f
+ 340.75 55.5 m
+ F
+ u
+ u
+ 3 w
+ 280.774 44.223 m
+ 567.893 44.223 l
+ S
+ 280.774 48.728 m
+ 567.893 48.728 l
+ S
+ 280.774 53.734 m
+ 567.893 53.734 l
+ S
+ U
+ u
+ 280.774 58.739 m
+ 567.893 58.739 l
+ S
+ 280.774 63.245 m
+ 567.893 63.245 l
+ S
+ 280.774 68.251 m
+ 567.893 68.251 l
+ S
+ U
+ u
+ 280.774 73.257 m
+ 567.893 73.257 l
+ S
+ 280.774 78.263 m
+ 567.893 78.263 l
+ S
+ U
+ U
+ 0.8 g
+ 0.2 w
+ 243 252 m
+ 323 235 l
+ 346 273 l
+ 368 248 l
+ 376 247 376 248 V
+ 377 174 380.5 121 330.5 40 C
+ 90.5 40 91.5 40 V
+ 138.5 129 163 162 214 200 C
+ 236 229 234.527 240.11 238 254 c
+ 240 262 243 252 y
+ b
+ 0.5 g
+ 359.5 485 m
+ 389.267 485 402.5 486.25 415.75 489 c
+ 429 491.75 435 493.25 439 493.5 c
+ 443 493.75 490.398 537.797 502.5 562 c
+ 507 571 514.5 577 517.5 579.5 c
+ 520.5 582 501.5 591 y
+ 428 512 428 512.5 v
+ 428 513 356.5 510 356 509.5 c
+ 355.5 509 351 488 y
+ 359 485 359.5 485 v
+ b
+ 0.7 g
+ 370 496.5 m
+ 368 480.5 365.5 472.5 364.5 471.5 C
+ 329.5 476.5 l
+ 323.5 489.5 l
+ 370 496.5 l
+ b
+ 0.5 g
+ 352.75 494 m
+ 380 493.25 399.626 496.75 407.5 499 c
+ 418 502 424.586 497.135 432.75 505.5 c
+ 453 526.25 473.5 544.5 496.5 586.5 C
+ 473.5 590 473.5 590.5 V
+ 456 571.5 443 563.5 434 558 c
+ 425 552.5 416 544 408.5 534.5 C
+ 399 533 379.5 537.5 364 537.5 c
+ 348.5 537.5 352.75 494 y
+ b
+ 1 g
+ 500 583 m
+ 500.5 577.098 517 573.5 520.5 572 c
+ 524 570.5 526.353 568.989 526.5 579 c
+ 526.675 590.992 541 586 539 624 C
+ 538.5 624 506 628 y
+ 499.958 583.498 500 583 v
+ b
+ 0 g
+ 1 J
+ 3 w
+ 562 629 m
+ 343 645 217 644 77 601 C
+ 52 576 L
+ 59.5 562 80.132 560.877 87 589 c
+ 89.513 599.292 87 597 101 601 c
+ 108.323 603.092 265 654 561 617 C
+ 562 629 l
+ f
+ 1 G
+ 0 J
+ 0.7 w
+ 305 634 m
+ 391.5 636.5 415 635 473 632 c
+ S
+ 0.5 w
+ 213 626.5 m
+ 153.5 619 125.925 611.699 90.75 602.5 c
+ 78.654 599.337 82.567 597.884 82.5 592 c
+ 82.395 582.717 73.75 571 59 572.5 c
+ S
+ 1 g
+ 0 G
+ 1 w
+ 73 595.25 m
+ 79.25 592.5 76.25 574.75 57.25 580 C
+ 73 595.25 l
+ f
+ 0.5 g
+ 0.2 w
+ 312 574.25 m
+ 311.25 570.5 310.687 571.687 306.187 569.187 C
+ 307.687 564.187 311.106 565.66 304.5 561.5 c
+ 302.594 560.299 305.598 556.561 305.75 555.5 c
+ 306.038 553.485 304.629 548.098 297 548.5 c
+ 292.25 548.75 255.5 536 y
+ 229.5 608.5 l
+ 224 650 224.5 650 v
+ 248.101 650 273.345 678.918 298 655.5 c
+ 324.857 629.99 316.981 613.501 316.75 612.875 c
+ 313.346 603.644 313.238 604.937 314.75 597.375 c
+ 316.88 586.725 317.016 588.834 318.625 584.75 C
+ 320.25 581.875 318.625 580.375 y
+ 316.689 578.236 313.081 579.809 310.375 579 c
+ 307.013 577.994 312 574.25 y
+ B
+ 0 g
+ 0.5 w
+ 288.5 456 m
+ S
+ 0.2 w
+ 211 511 m
+ 194.5 518.5 187 520.5 170.5 500 C
+ 154.5 498.5 149.5 501 131.5 479.5 C
+ 151 477.5 140 475 161 460 c
+ 182 445 190.5 436.5 212 461 C
+ 224.5 458 229 454.5 238.5 447 C
+ 238 446.5 237 500.5 y
+ 211 511 l
+ f
+ 1 g
+ 207.5 526.5 m
+ 206 514.5 204 506 236 490.5 C
+ 242.5 509.5 l
+ 207.5 526.5 l
+ b
+ 0 g
+ 1 w
+ 294.464 627.589 m
+ 288.571 618.522 284.821 617.313 280 615.5 c
+ 275.179 613.686 271.429 605.224 277.857 587.089 C
+ 274.107 586.485 275.179 585.88 275.714 582.858 C
+ 271.429 599.179 270.357 606.433 259.643 609.455 c
+ 248.929 612.477 245.714 589.507 247.321 566.537 C
+ 228.572 554.448 L
+ 224.639 578.851 235.956 576.38 212.5 600.992 c
+ 194.17 620.226 195.893 654.791 225.357 658.418 C
+ 223.214 667.485 233.929 678.97 259.107 677.761 c
+ 284.286 676.552 281.071 667.485 Y
+ 302.5 667.485 334.964 665.942 301.429 614.895 C
+ 306.25 639.679 303.571 643.306 296.607 646.933 C
+ 299.286 634.239 294.464 627.589 y
+ f
+ 0.7 g
+ 0.2 w
+ 207.5 524.5 m
+ 214.75 519.25 241.5 509 y
+ 239 504.5 l
+ 232 503 214.5 508.75 206.75 519 C
+ 207 522.5 207.5 524.5 y
+ b
+ 1 g
+ 298 546.5 m
+ 272.625 574.625 248.5 596 195.5 568.5 C
+ 196.26 524.417 214.492 504.333 239.5 510.5 C
+ 298 546.5 l
+ b
+ 0.8 g
+ 351.5 542 m
+ 367 540 L
+ 358.5 509.5 357 489.5 357 482 C
+ 323.5 482.5 295.5 485.5 284.5 477.5 c
+ 298.5 468.5 l
+ 299 457 l
+ 270.5 451 l
+ 238.5 483.5 l
+ 241 513.5 l
+ 250.5 538 252.5 547.5 282.5 550 C
+ 306.251 550 334.454 541.702 343.687 542.187 C
+ 342.576 538.175 346.737 538.055 351.5 542 c
+ b
+ 0 g
+ 1 w
+ 333.25 484.75 m
+ 343.25 458.25 371.5 466 349 418.5 C
+ 359 348.5 378 357 363 336 C
+ 358.5 333 359 333 v
+ 359.5 333 353 328 359 327.5 c
+ 365 327 371 316.5 373.5 253.5 C
+ 381 245.5 l
+ 371 221 371 220.5 V
+ 360.5 247 358 253 351 261.5 C
+ 340 238 331.5 220.5 328.5 211.5 C
+ 301 229.5 265 250 232.5 244.5 C
+ 247.5 287 246 299.5 275 320.5 C
+ 270 331.5 268.689 334.634 265.75 336.25 c
+ 255.75 341.75 261.891 340.771 251 375 c
+ 247.5 386 249.5 384 255.5 399 C
+ 252.5 397 253.5 401 253.5 402.5 c
+ 253.5 404 252.057 400.023 251 402.5 c
+ 235 440 219.5 489.5 249.5 534 C
+ 238.5 503.5 242.102 477.13 260 463 c
+ 269.5 455.5 278.75 453.25 291 457.25 C
+ 297.5 461 299.549 465.787 282 476.75 C
+ 292.5 487.5 333.25 484.75 y
+ f
+ 457.25 576.25 m
+ 454.936 574.233 453.51 595.217 479.25 583 C
+ 495.651 573.321 495.931 560.263 482.5 560.5 C
+ 486.25 566 491.682 565.465 478.5 575 c
+ 463.444 585.891 460.318 578.924 457.25 576.25 c
+ f
+ 1 g
+ 460.75 581.5 m
+ 463.387 583.699 467.528 583.937 470.5 583.375 c
+ 473.752 582.76 473.75 581.75 Y
+ 461.735 583.841 458.891 579.95 460.75 581.5 c
+ f
+ 0 g
+ 310.393 647.785 m
+ 329.089 651.66 328.75 623.692 320.178 607.976 C
+ 319.107 621.274 316.428 636.386 310.536 635.782 c
+ 304.643 635.177 310.393 647.785 y
+ f
+ 284.286 663.858 m
+ 286.964 677.157 280.536 689.246 281.071 689.246 C
+ 289.107 677.761 288.036 665.672 y
+ 284.286 663.858 l
+ f
+ 0.2 w
+ 274.643 683.201 m
+ 278.929 678.97 280 668.694 279.464 665.672 c
+ S
+ 276.25 686.224 m
+ 284.393 677.036 283.75 662.045 y
+ S
+ 1 w
+ 297.679 661.44 m
+ 312.602 661.44 312.143 677.157 310.536 680.784 C
+ 308.929 672.321 305.179 666.276 292.857 664.463 C
+ 297.679 661.44 l
+ f
+ 0.2 w
+ 295 661.44 m
+ 298.75 666.276 302.5 675.343 294.464 683.201 c
+ S
+ 300.357 681.992 m
+ 304.265 669.255 303.814 670.807 292.321 656.604 c
+ S
+ 311.821 649.078 m
+ 321.464 649.078 330.571 646.66 329.5 627.921 c
+ S
+ 307.536 650.892 m
+ 316.268 651.33 319.057 653.025 326.821 646.056 c
+ 330.446 642.802 331.1 637.618 331.107 637.593 c
+ S
+ 304.643 665.067 m
+ 305.629 663.874 321.031 667.072 321.304 651.569 c
+ S
+ 0.5 w
+ 311.071 639.679 m
+ 317.893 638.968 312.696 617.332 v
+ S
+ 1 w
+ 313.375 612.875 m
+ 315.455 614.262 313.5 617.375 297.125 615.375 C
+ 310.375 616.625 311.875 611.875 313.375 612.875 c
+ f
+ 1 g
+ 308.5 604.875 m
+ 309.833 600.875 309.125 601.25 307.375 599 C
+ 302.25 600.625 303.25 599.875 299 602.5 C
+ 304.25 604.75 308.375 605.25 308.5 604.875 c
+ f
+ 0 g
+ 307.5 604.437 m
+ 305.463 602.811 305.481 601.49 307.375 598.937 C
+ 309.261 601.307 309.489 602.172 308.562 605.062 C
+ 308.562 604.937 308.191 604.989 307.5 604.437 c
+ f
+ 0.2 w
+ 305.625 583.75 m
+ 304.687 582.562 306.5 579.375 308.875 579.75 c
+ S
+ 1 w
+ 311.125 574.5 m
+ 310.25 573.898 310 573.437 304.937 569.312 C
+ 306.229 564.611 308.063 564.014 308.312 564.562 C
+ 309.775 566.476 307.663 569.565 306.687 569.75 C
+ 311.812 571.75 311.625 572.5 312 574.25 C
+ 311.687 574.75 311.176 574.535 311.125 574.5 c
+ f
+ 298.625 603 m
+ 302 600.437 304.294 599.524 307.812 598.937 c
+ 308.187 598.875 308.562 598.5 308.687 597.875 c
+ S
+ 297.5 602.25 m
+ 299.939 602.851 307.687 603.062 311.75 607.812 C
+ 307.812 606 297.011 602.129 297.5 602.25 c
+ f
+ 213.5 576.125 m
+ 218.674 549.92 230.862 532.355 245.5 526.5 C
+ 243.75 514.5 209.75 494.25 195.5 568.5 C
+ 203.75 572.25 213.347 576.901 213.5 576.125 c
+ f
+ 0.2 w
+ 343.375 541.75 m
+ 333.375 534.75 318.25 525.5 312 521.25 c
+ S
+ 351.562 541.937 m
+ 337.936 530.579 327.2 525.581 313.25 517.75 c
+ S
+ 0.3 w
+ 312.75 495 m
+ 291.75 483.5 276.25 476 274.25 466 c
+ S
+ 0.5 w
+ 229 580.75 m
+ 235.5 571 241.25 554.75 245.75 528 c
+ S
+ 1 w
+ 235 581 m
+ 246 555.75 246.75 537.75 245.75 526 C
+ 252.125 560.5 243.75 567.75 239.75 581.5 C
+ 240 581.5 237 581.75 235 581 C
+ f
+ 0.7 g
+ 0.2 w
+ 248.625 580.5 m
+ 253.169 564.605 256.75 553.75 250.25 535.75 C
+ 257.5 552.75 259.125 558.937 252.875 579.687 C
+ 251.029 580.149 248.517 580.879 248.625 580.5 c
+ b
+ 0 g
+ 1 w
+ 258.25 577.75 m
+ 262.047 567.879 262.5 552.5 259.25 544.25 C
+ 267.75 548.25 275 549.75 278.25 549.75 C
+ 281.75 555.25 282.75 556.75 279.5 565.25 C
+ 270.06 573.13 257.909 578.635 258.25 577.75 c
+ f
+ 207.5 524.5 m
+ F
+ 207.25 514.75 m
+ 207.185 514.86 228.75 497.5 238 500.75 C
+ 236 494.5 l
+ 225 498 213.924 503.454 207.25 514.75 c
+ f
+ 1 g
+ 0.2 w
+ 191 516 m
+ 175.472 497.418 168.5 492 171.5 453 C
+ 185 443.5 189 443.5 200 450.5 C
+ 186.5 469.5 182 491 198.5 515.5 C
+ 194.5 516 191.339 516.406 191 516 c
+ b
+ 201 515 m
+ 194 499 187 484 203.5 453 C
+ 206.5 455 211.5 460.5 212 461 C
+ 203.5 480.5 193.5 501.5 206 510.5 C
+ 205 499.5 210.5 490.5 232.5 473.5 C
+ 232.5 483 231.5 482.5 233 492 C
+ 221 498 210 505 208 512.5 C
+ 201 515 l
+ b
+ 0 g
+ 1 G
+ 0.5 w
+ 268 442.5 m
+ 253.5 402.5 l
+ S
+ 269.5 435.5 m
+ 258.5 407 258.5 407.5 v
+ S
+ 0.5 G
+ 0.4 w
+ 293.5 480.5 m
+ 297.5 463.5 298.5 460.5 289 445.5 c
+ S
+ 1 G
+ 1 J
+ 0.3 w
+ 349.125 418.125 m
+ 338.393 403.978 348.387 416.158 341.625 408.875 c
+ S
+ u
+ 1 g
+ 0 G
+ 0 J
+ 0.2 w
+ 336.038 340.015 m
+ 338.267 329.694 L
+ 342.937 338.843 L
+ 340.707 349.164 L
+ 336.038 340.015 L
+ b
+ 339.487 339.429 m
+ B
+ U
+ u
+ 328.791 340.569 m
+ 331.562 330.38 L
+ 335.743 339.762 L
+ 332.972 349.952 L
+ 328.791 340.569 L
+ b
+ 332.267 340.166 m
+ B
+ U
+ u
+ 321.758 340.67 m
+ 325.133 330.664 L
+ 328.746 340.28 L
+ 325.37 350.286 L
+ 321.758 340.67 L
+ b
+ 325.252 340.475 m
+ B
+ U
+ u
+ 314.504 340.97 m
+ 317.88 330.964 L
+ 321.492 340.58 L
+ 318.117 350.586 L
+ 314.504 340.97 L
+ b
+ 317.998 340.775 m
+ B
+ U
+ u
+ u
+ 307.24 340.468 m
+ 311.982 331.033 L
+ 314.214 341.059 L
+ 309.473 350.494 L
+ 307.24 340.468 L
+ b
+ 310.727 340.764 m
+ B
+ U
+ u
+ 300.016 339.751 m
+ 304.757 330.316 L
+ 306.99 340.342 L
+ 302.249 349.777 L
+ 300.016 339.751 L
+ b
+ 303.503 340.047 m
+ B
+ U
+ U
+ u
+ u
+ 292.985 339.2 m
+ 298.349 330.104 L
+ 299.903 340.258 L
+ 294.54 349.353 L
+ 292.985 339.2 L
+ b
+ 296.444 339.729 m
+ B
+ U
+ u
+ 285.826 338 m
+ 291.189 328.904 L
+ 292.744 339.057 L
+ 287.38 348.153 L
+ 285.826 338 L
+ b
+ 289.285 338.529 m
+ B
+ U
+ U
+ u
+ 278.742 336.229 m
+ 285.413 328.042 L
+ 285.423 338.314 L
+ 278.753 346.501 L
+ 278.742 336.229 L
+ b
+ 282.083 337.272 m
+ B
+ U
+ u
+ 272.228 332.392 m
+ 279.743 324.974 L
+ 278.644 335.186 L
+ 271.13 342.604 L
+ 272.228 332.392 L
+ b
+ 275.437 333.789 m
+ B
+ U
+ 0 g
+ 1 G
+ 1 w
+ 266.25 335.5 m
+ 276.25 351.5 284.659 350 343 350 c
+ 364 350 363 336 y
+ S
+ 271 321 m
+ 294 332 309 335 362 324 c
+ S
+ u
+ 1 g
+ 0 G
+ 0.2 w
+ 350.823 325.912 m
+ 364.33 322.302 L
+ 361.658 347.078 L
+ 348.151 350.689 L
+ 350.823 325.912 L
+ b
+ 356.24 336.495 m
+ B
+ U
+ 0 g
+ 1 w
+ 274 347.5 m
+ 281.5 351.5 280.229 357.581 311 338 c
+ 316.5 334.5 322.5 338 351 357.5 C
+ 282 360 l
+ 274 347.5 l
+ f
+ 1 G
+ 0.5 w
+ 269.25 355.75 m
+ 277.75 353.25 284.25 352.5 288.75 349.75 c
+ S
+ 353.25 358.25 m
+ 347.25 354 345.5 353.5 339.75 349.5 c
+ S
+ 0.3 w
+ 355.25 272.75 m
+ 359.75 281.5 361.25 285 363.25 290.75 c
+ S
+ 0.5 G
+ 0.5 w
+ 354 219 m
+ 339 195 327 176 317 166 c
+ S
+ 323 197 m
+ 310 150 308 135 235 48 c
+ S
+ 1 w
+ 241 241.5 m
+ 232 227.5 215.231 198.443 215 198 c
+ 192.581 155 178 110 164 71 c
+ S
+ 0 G
+ 0.2 w
+ 265.394 600.822 m
+ 263.576 606.114 262.122 612.994 253.035 607.173 C
+ 250.126 603.468 249.763 601.704 249.763 596.589 c
+ 249.763 591.473 254.307 592.179 257.76 587.24 c
+ 261.213 582.301 266.484 579.302 267.029 588.475 c
+ S
+ 0.3 g
+ 260.668 605.409 m
+ 262.486 601.352 261.94 599.941 257.578 597.824 c
+ 253.216 595.707 257.76 591.473 260.305 592.355 c
+ 262.849 593.237 263.394 592.532 264.303 591.65 c
+ 265.212 590.768 266.666 591.826 264.667 594.119 c
+ 262.667 596.413 259.759 593.943 261.032 597.471 c
+ 262.304 600.999 260.668 605.409 y
+ b
+ 0 g
+ 257.578 606.644 m
+ 254.125 605.056 251.58 604.174 251.58 598.177 c
+ 251.58 592.179 258.487 590.415 259.214 588.651 c
+ S
+ u
+ 1 g
+ 257.397 584.594 m
+ 258.601 581.671 262.019 580.25 265.03 581.419 c
+ 268.041 582.588 269.506 585.905 268.302 588.827 c
+ 267.097 591.75 263.679 593.172 260.668 592.003 c
+ 257.657 590.833 256.192 587.516 257.397 584.594 c
+ b
+ 262.849 586.711 m
+ B
+ U
+ u
+ 0.2 g
+ 1 w
+ 258.487 586.358 m
+ 263.213 582.477 L
+ 267.211 587.063 L
+ 262.486 590.944 L
+ 258.487 586.358 L
+ f
+ 262.849 586.711 m
+ F
+ U
+ 0 g
+ 309.25 579.875 m
+ 310.75 580.5 313.25 583.125 314.625 581 c
+ F
+ 1 g
+ 307.964 565.926 m
+ 307.88 566.015 306.794 566.513 307.22 566.682 c
+ 307.647 566.851 307.68 566.599 307.935 566.639 C
+ 307.924 566.13 307.971 566.31 307.964 565.926 c
+ f
+ 510 104 m
+ 509.564 104.895 511.5 89 495.5 74.5 C
+ 495.5 68 l
+ 506 79 518.582 86.358 510 104 c
+ f
+ 0 g
+ 0.2 w
+ 403.75 534.25 m
+ 413.25 533.75 415.75 534.25 417.75 534.75 c
+ S
+ 1 G
+ 0.3 w
+ 538.5 629 m
+ 542 625 547.5 620 y
+ S
+ 548.75 629.25 m
+ 552.25 625.25 557.75 620.25 y
+ S
+ 0 G
+ 0.2 w
+ 518.5 587.5 m
+ 522.5 586 526 587.5 527 587.5 c
+ S
+ 514 617.5 m
+ 518 614 518.5 611.5 520 607.5 c
+ S
+ 528.25 613.75 m
+ 533.25 615.25 532.5 615.5 538.25 614.25 c
+ S
+ 1 g
+ 538 637.5 m
+ 537.25 618 533 617.5 531.25 617.5 c
+ 529.5 617.5 528.235 615.255 528.5 622.5 c
+ 529.25 643 528.775 643.326 534.25 642.75 c
+ 539 642.25 539 642.25 540.5 630.75 C
+ 538 631 l
+ 538 629 538 631.25 v
+ 538 633.5 538 637.5 Y
+ b
+ 0.7 g
+ 507.5 650.75 m
+ 510 648.5 510.25 645.75 511.75 643.25 c
+ 513.25 640.75 508.5 638.25 508.5 638 c
+ 508.5 637.75 507.5 650.75 y
+ b
+ 1 g
+ 529.25 639.25 m
+ 528.5 643 527 642.75 524 642.75 c
+ 521 642.75 519.75 644 519.5 632.25 C
+ 519.75 638 519.75 641 v
+ 519.75 644 518.75 644.25 515.25 644.25 c
+ 511.75 644.25 511.75 646 509.25 641.25 c
+ 506.75 636.5 505.75 633.25 506 633.25 c
+ 506.25 633.25 509.75 628.25 Y
+ 511.5 620.25 512.75 619.75 515.5 619.5 c
+ 518.25 619.25 520.25 618.25 519.5 623.5 C
+ 521 618.25 521 617.75 524.75 617 c
+ 528.5 616.25 528.5 618.25 528.5 622.5 c
+ 528.5 626.75 529.25 639.25 y
+ b
+ 507.75 636.75 m
+ 512.687 638.231 515.604 641 515.25 641 C
+ 517.839 637.469 517.494 629.281 508.75 625.5 C
+ 508.75 625.25 502 635 502.25 634.75 c
+ 502.5 634.5 507.75 636.75 y
+ b
+ 493.5 571.5 m
+ 495.171 563.425 503.634 565.498 503.5 576.25 c
+ 503.25 596.25 515.75 586.25 509 636.75 c
+ 508.301 641.977 510 650.75 506.5 651.5 c
+ 501.514 652.568 500.436 652.26 499.25 644.75 c
+ 498.5 640 496.5 646.25 496 648.5 c
+ 495.5 650.75 493.75 651 490.75 650.25 c
+ 487.75 649.5 488.253 648.665 487.5 645.5 c
+ 486.194 640.013 486.75 641.75 484.5 645.5 c
+ 482.39 649.016 481.306 648.011 477.5 647.25 c
+ 475 646.75 474.784 644.479 475.25 640.75 c
+ 475.5 638.75 474 642.25 472.5 644.5 c
+ 471 646.75 469.25 645.5 466.5 645.5 c
+ 463.75 645.5 463.25 641.003 463.5 635.5 c
+ 463.511 635.25 463 626.25 y
+ 449.75 627.25 l
+ 459.25 618.5 465.606 612.863 468.25 597 c
+ 468.75 594 468 592.25 470 592.75 C
+ 459.719 593.497 459.195 585.398 461 586 c
+ 466.25 587.75 471.75 589.25 476.75 587 c
+ 481.75 584.75 486.25 584.25 489.5 586.25 C
+ 490.25 582.75 492 578.75 493.5 571.5 c
+ b
+ 0 g
+ 486.25 592.5 m
+ 489 595.25 492.117 593.078 492.25 592.75 c
+ 494.972 586.028 477 591.75 467.25 593 c
+ S
+ 0.4 w
+ 470 592.75 m
+ 474.25 595.75 475 596 481.5 595.75 c
+ S
+ 1 J
+ 2.5 w
+ 477.75 630 m
+ 478.5 620.75 l
+ S
+ 479.25 617.5 m
+ 480 610.5 l
+ S
+ 480.25 607.75 m
+ 481 600.25 481 600.5 v
+ S
+ 487.5 631.75 m
+ 487.75 623.5 l
+ S
+ 487.75 620.75 m
+ 487.75 612.5 l
+ S
+ 488 609.25 m
+ 488.25 609.25 487.75 602.5 y
+ S
+ 498 630.75 m
+ 497.25 623.75 l
+ S
+ 496.75 620.75 m
+ 495.5 612.5 l
+ S
+ 495.25 609.5 m
+ 493.75 602 l
+ S
+ 0 J
+ 0.2 w
+ 465.5 637.25 m
+ 464.5 629.75 461.25 628.75 464.75 617 c
+ S
+ 0.5 w
+ 502 589.25 m
+ 503.25 585 503.5 583.25 503.5 577 c
+ S
+ 1 g
+ 1 w
+ 521.949 86.694 m
+ 521.637 87.353 523.021 75.657 511.583 64.988 C
+ 511.583 60.205 l
+ 519.089 68.299 528.083 73.713 521.949 86.694 c
+ f
+ 553.457 99.673 m
+ 553.091 100.449 554.713 86.67 541.309 74.1 C
+ 541.309 68.465 l
+ 550.105 78.001 560.646 84.379 553.457 99.673 c
+ f
+ 482.74 95.04 m
+ 482.429 95.699 483.812 84.003 472.375 73.334 C
+ 472.375 68.551 l
+ 479.881 76.645 488.875 82.059 482.74 95.04 c
+ f
+ 450.924 87.63 m
+ 450.69 88.028 451.731 80.968 443.129 74.528 C
+ 443.129 71.641 l
+ 448.774 76.527 455.538 79.795 450.924 87.63 c
+ f
+ 0 g
+ 308 61.5 m
+ N
+ 3 w
+ 16.002 40.373 m
+ 568.002 40.127 L
+ 567.748 716.565 L
+ S
+ u
+ 15.815 40.248 m
+ 567.815 40.002 L
+ 567.748 716.565 L
+ 15.998 716.81 L
+ 15.815 40.248 L
+ s
+ U
+ %%Trailer
+ _E end
+ showpage


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gp_unix.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gp_unix.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gp_unix.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,91 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gp_unix.c */
+ /* Unix-specific routines for Ghostscript */
+ #include "string_.h"
+ #include "gx.h"
+ #include <time.h>
+ #include <sys/time.h>
+ 
+ /* Do platform-dependent initialization */
+ void
+ gp_init()
+ {
+ }
+ 
+ /* Read the current date (in days since Jan. 1, 1980) */
+ /* and time (in milliseconds since midnight). */
+ void
+ gs_get_clock(long *pdt)
+ {	long secs_since_1980;
+ 	struct timeval tp;
+ 	struct timezone tzp;
+ 	struct tm *tm, *localtime();
+ 
+ 	if ( gettimeofday(&tp, &tzp) == -1 )
+ 	   {	perror("Ghostscript: gettimeofday failed:");
+ 		exit(-1);
+ 	   }
+ 
+ 	/* tp.tv_sec is #secs since Jan 1, 1970 */
+ 
+ 	/* subtract off number of seconds in 10 years */
+ 	/* leap seconds are not accounted for */
+ 	secs_since_1980 = tp.tv_sec - (long)(60 * 60 * 24 * 365.25 * 10);
+  
+ 	/* adjust for timezone */
+ 	secs_since_1980 -= (tzp.tz_minuteswest * 60);
+ 
+ 	/* adjust for daylight savings time - assume dst offset is 1 hour */
+ 	tm = localtime(&(tp.tv_sec));
+ 	if ( tm->tm_isdst )
+ 		secs_since_1980 += (60 * 60);
+ 
+ 	/* divide secs by #secs/day to get #days (integer division truncates) */
+ 	pdt[0] = secs_since_1980 / (60 * 60 * 24);
+ 	/* modulo + microsecs/1000 gives number of millisecs since midnight */
+ 	pdt[1] = (secs_since_1980 % (60 * 60 * 24)) * 1000 + tp.tv_usec / 1000;
+ #ifdef DEBUG_CLOCK
+ 	printf("tp.tv_sec = %d  tp.tv_usec = %d  pdt[0] = %ld  pdt[1] = %ld\n",
+ 		tp.tv_sec, tp.tv_usec, pdt[0], pdt[1]);
+ #endif
+ }
+ 
+ /* ------ File name syntax ------ */
+ 
+ /* Define the character used for separating file names in a list. */
+ char gp_file_name_list_separator = ':';
+ 
+ /* Answer whether a file name contains a directory/device specification, */
+ /* i.e. is absolute (not directory- or device-relative). */
+ int
+ gp_file_name_is_absolute(char *fname, uint len)
+ {	/* A file name is absolute if it starts with a /. */
+ 	return ( len >= 1 && *fname == '/' );
+ }
+ 
+ /* Answer the string to be used for combining a directory/device prefix */
+ /* with a base file name.  The file name is known to not be absolute. */
+ char *
+ gp_file_name_concat_string(char *prefix, uint plen, char *fname, uint len)
+ {	if ( plen > 0 && prefix[plen - 1] == '/' )
+ 		return "";
+ 	return "/";
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gp_vms.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gp_vms.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gp_vms.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,100 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gp_vms.c */
+ /* VAX/VMS specific routines for Ghostscript */
+ #include "gx.h"
+ 
+ /* Do platform-dependent interpreter initialization */
+ void
+ gp_init()
+ {
+ }
+ 
+ /* Read the current date (in days since Jan. 1, 1980) */
+ /* and time (in milliseconds since midnight). */
+ void
+ gs_get_clock(long *pdt)
+ {	struct {unsigned long int _l0, _l1;} binary_date;
+         long lib$day(), sys$bintim();
+ 	long days, days0, seconds;
+ 	char *jan_1_1980 = "1-JAN-1980";
+ 	char *midnight   = "00:00:00.00";
+ 	struct { unsigned short  dsc$w_length;
+ 		 unsigned char   dsc$b_dtype;
+ 		 unsigned char   dsc$b_class;
+ 		 char           *dsc$a_pointer;} str_desc;
+ 
+ 	/* Get days from system zero date (November 17, 1858) to present. */
+ 	(void) lib$day (&days0);
+ 
+ 	/* For those interested, Wednesday, November 17, 1858 is the base
+ 	   of the Modified Julian Day system adopted by the Smithsonian
+ 	   Astrophysical Observatory in 1957 for satellite tracking.  (The
+ 	   year 1858 preceded the oldest star catalog in use at the
+ 	   observatory.)  VMS uses quadword time stamps which are offsets
+ 	   in 100 nanosecond units from November 17, 1858.  With a 63-bit
+ 	   absolute time representation (sign bit must be clear), VMS will
+ 	   have no trouble with time until 31-JUL-31086 02:48:05.47. */
+ 
+ 	/* Convert January 1, 1980 into a binary absolute time */
+ 	str_desc.dsc$w_length  = strlen(jan_1_1980);
+ 	str_desc.dsc$a_pointer = jan_1_1980;
+ 	(void) sys$bintim (&str_desc, &binary_date);
+ 
+ 	/* Now get days from system zero date to January 1, 1980 */
+ 	(void) lib$day (&days, &binary_date);
+ 
+ 	/* Now compute number of days since January 1, 1980 */
+ 	pdt[0] = 1 + days0 - days;
+ 
+ 	/* Convert midnight into a binary delta time */
+ 	str_desc.dsc$w_length  = strlen(midnight);
+ 	str_desc.dsc$a_pointer = midnight;
+ 	(void)  sys$bintim (&str_desc, &binary_date);
+ 
+ 	/* Now get number 10 millisecond time units since midnight */
+ 	(void) lib$day (&days, &binary_date, &seconds);
+ 	pdt[1] = 10 * seconds;
+ }
+ 
+ /* ------ File name syntax ------ */
+ 
+ /* Define the character used for separating file names in a list. */
+ char gp_file_name_list_separator = ';';
+ 
+ /* Answer whether a file name contains a directory/device specification, */
+ /* i.e. is absolute (not directory- or device-relative). */
+ int
+ gp_file_name_is_absolute(char *fname, uint len)
+ {	/****** THIS NEEDS TO BE WRITTEN ******/
+ 	return 0;
+ }
+ 
+ /* Answer the string to be used for combining a directory/device prefix */
+ /* with a base file name.  The file name is known to not be absolute. */
+ char *
+ gp_file_name_concat_string(char *prefix, uint plen, char *fname, uint len)
+ {	/****** THIS NEEDS TO BE CHECKED ******/
+ 	if ( plen > 0 )
+ 	  switch ( prefix[plen - 1] )
+ 	   {	case ':': case ']': return "";
+ 	   };
+ 	return ":";
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gs.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gs.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gs.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,289 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gs.c */
+ /* Driver program for GhostScript */
+ #include <stdio.h>
+ #include "string_.h"
+ #include "ghost.h"
+ #include "alloc.h"
+ #include "store.h"
+ #include "stream.h"
+ 
+ /* Library routines not declared in a standard header */
+ extern char *getenv(P1(const char *));
+ 
+ /* Exported data */
+ uint memory_chunk_size = 20000;
+ /* File name search paths */
+ char **gs_lib_paths;
+ private int gs_lib_count;
+ private char *gs_lib_env_path;
+ private char *gs_lib_default_path = GS_LIB_DEFAULT;	/* defined in the makefile */
+ 
+ /* Imported data */
+ extern ref *osbot, *osp, *esp;
+ extern ref estack[];
+ 
+ /* Forward references */
+ private void init1(), init2();
+ private void set_lib_paths();
+ private void run_file(P2(char *file_name, int user_errors));
+ private void debug_dump_stack(P1(int code));
+ 
+ /* Parameters set by swproc */
+ private int user_errors;
+ private int quiet;
+ 
+ main(int argc, char *argv[])
+ {	int num_files;
+ 	int code;
+ 	int swproc(P2(char, char *));
+ 	void argproc(P2(char *, int));
+ 
+ #ifdef BWGC
+ 	{
+ 	    extern gc_init();
+ 	    gc_init();
+ 	}
+ #endif BWGC
+ 	
+ 	/* Initialize the file search paths */
+ 	gs_lib_env_path = 0;
+ 	   {	char *lib = getenv("GS_LIB");
+ 		if ( lib != 0 ) 
+ 		   {	int len = strlen(lib);
+ 			gs_lib_env_path = gs_malloc(len + 1, 1, "GS_LIB");
+ 			strcpy(gs_lib_env_path, lib);
+ 		   }
+ 	   }
+ 	gs_lib_paths =
+ 		(char **)gs_malloc(argc + 2, sizeof(char *), "-I array");
+ 	gs_lib_count = 0;
+ 	set_lib_paths();
+ 	/* Execute files named in the command line, */
+ 	/* processing options along the way. */
+ 	/* Wait until the first file name (or the end */
+ 	/* of the line) to finish initialization. */
+ 	quiet = 0;
+ 	user_errors = 1;
+ 	num_files = gs_main(argc, argv, "GS.MAP", swproc, argproc);
+ 	if ( num_files == 0 )
+ 	   {	init2();
+ 	   }
+ /*
+ 	code = interpret_string("start");
+ */
+ 	code = 0;
+ 	zflush((ref *)0);	/* flush stdout */
+ 	zflushpage((ref *)0);	/* force display update */
+ 	if ( code < 0 )
+ 		debug_dump_stack(code);
+ 	gs_exit((code == 0 ? 0 : 2));
+ }
+ 
+ /* Process switches */
+ int
+ swproc(char sw, char *arg)
+ {	switch ( sw )
+ 	   {
+ 	default:
+ 		return -1;
+ 	case 'I':			/* specify search path */
+ 		gs_lib_paths[gs_lib_count] = arg;
+ 		gs_lib_count++;
+ 		set_lib_paths();
+ 		break;
+ 	case 'q':			/* quiet startup */
+ 	   {	ref vnull;
+ 		quiet = 1;
+ 		init1();
+ 		make_null(&vnull);
+ 		initial_enter_name("QUIET", &vnull);
+ 	   }	break;
+ 	case 'D':			/* define name */
+ 	case 'd':
+ 	case 'S':			/* define name as string */
+ 	case 's':
+ 	   {	char *eqp = strchr(arg, '=');
+ 		ref value;
+ 		/* Initialize the object memory, scanner, and */
+ 		/* name table now if needed. */
+ 		init1();
+ 		if ( eqp == NULL )
+ 		   {	make_null(&value);
+ 		   }
+ 		else if ( eqp == arg )
+ 		   {	printf("Usage: -dname, -dname=token, -sname=string");
+ 			gs_exit(1);
+ 		   }
+ 		else
+ 		   {	int code;
+ 			*eqp++ = 0;	/* delimit name */
+ 			if ( sw == 'D' || sw == 'd' )
+ 			   {	stream astream;
+ 				sread_string(&astream,
+ 					     (byte *)eqp, strlen(eqp));
+ 				code = scan_token(&astream, 0, &value);
+ 				if ( code )
+ 				   {	printf("-dname= must be followed by a valid token");
+ 					gs_exit(1);
+ 				   }
+ 			   }
+ 			else
+ 			   {	int len = strlen(eqp);
+ 				char *str = gs_malloc((uint)len, 1, "-s");
+ 				if ( str == 0 )
+ 				   {	dprintf("Out of memory!\n");
+ 					gs_exit(1);
+ 				   }
+ 				strcpy(str, eqp);
+ 				make_tasv(&value, t_string, a_read+a_execute,
+ 					  len, bytes, (byte *)str);
+ 			   }
+ 		   }
+ 		/* Enter the name in systemdict */
+ 		initial_enter_name(arg, &value);
+ 		break;
+ 	   }
+ 	case 'w':			/* define device width */
+ 	case 'h':			/* define device height */
+ 	   {	stream astream;
+ 		ref value;
+ 		int code;
+ 		init1();
+ 		sread_string(&astream, (byte *)arg, strlen(arg));
+ 		code = scan_token(&astream, 0, &value);
+ 		if ( code || (r_type(&value) != t_integer && r_type(&value) != t_real) )
+ 		   {	printf("-w and -h must be followed by a number\n");
+ 			gs_exit(1);
+ 		   }
+ 		initial_enter_name((sw == 'w' ? "DEVICEWIDTH" : "DEVICEHEIGHT"), &value);
+ 		break;
+ 	   }
+ 	case 'E':			/* suppress normal error handling */
+ 		user_errors = 0;
+ 		break;
+ 	case 'M':			/* set memory allocation increment */
+ 	   {	unsigned msize = 0;
+ 		sscanf(arg, "%d", &msize);
+ 		if ( msize <= 0 || msize >= 64 )
+ 		   {	printf("-M must be between 1 and 64");
+ 			gs_exit(1);
+ 		   }
+ 		memory_chunk_size = msize << 10;
+ 	   }
+ 		break;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Process file names */
+ void
+ argproc(char *arg, int index)
+ {	char line[200];
+ 	int code;
+ 	/* Finish initialization */
+ 	init2();
+ 	strcpy(line, "{(");
+ 	strcat(line, arg);
+ 	strcat(line, ")run}execute");
+ 	code = interpret_string(line);
+ 	zflushpage((ref *)0); /* force display update */
+ 	if ( code ) debug_dump_stack(code), gs_exit(1);
+ }
+ 
+ /* Interpret a (C) string. */
+ int
+ interpret_string(char *str)
+ {	ref stref;
+ 	make_tasv(&stref, t_string, a_executable + a_read + a_execute,
+ 		  strlen(str), bytes, (byte *)str);
+ 	return interpret(&stref, user_errors);
+ }
+ 
+ private int init1_done = 0, init2_done = 0;
+ private void
+ init1()
+ {	if ( !init1_done )
+ 	   {	alloc_init(gs_malloc, gs_free, memory_chunk_size);
+ 		name_init();
+ 		obj_init();		/* requires name_init */
+ 		scan_init();		/* ditto */
+ 		init1_done = 1;
+ 	   }
+ }
+ private void
+ init2()
+ {	init1();
+ 	if ( !init2_done )
+ 	   {	gs_init();
+ 		zfile_init();
+ 		zfont_init();
+ 		zmath_init();
+ 		zmatrix_init();
+ 		interp_init(1);		/* requires obj_init */
+ 		op_init();		/* requires obj_init, scan_init */
+ 		/* Execute the standard initialization file. */
+ 		run_file("ghost.ps", user_errors);
+ 		init2_done = 1;
+ 	   }
+    }
+ 
+ /* Complete the list of library search paths. */
+ private void
+ set_lib_paths()
+ {	char **ppath = &gs_lib_paths[gs_lib_count];
+ 	if ( gs_lib_env_path != 0 ) *ppath++ = gs_lib_env_path;
+ 	if ( gs_lib_default_path != 0 ) *ppath++ = gs_lib_default_path;
+ 	*ppath = 0;
+ }
+ 
+ /* Open and execute a file */
+ private void
+ run_file(char *file_name, int user_errors)
+ {	ref initial_file;
+ 	int code;
+ 	if ( lib_file_open(file_name, strlen(file_name), &initial_file) < 0 )
+ 	   {	eprintf1("Can't find file %s (from command line)\n", file_name);
+ 		gs_exit(1);
+ 	   }
+ 	if ( !quiet )
+ 	   {	printf("Reading %s... ", file_name);
+ 		fflush(stdout);
+ 	   }
+ 	r_set_attrs(&initial_file, a_execute + a_executable);
+ 	code = interpret(&initial_file, user_errors);
+ 	if ( code < 0 )
+ 		debug_dump_stack(code), gs_exit(1);
+ 	if ( !quiet )
+ 	   {	printf("%s read.\n", file_name);
+ 		fflush(stdout);
+ 	   }
+ }
+ 
+ /* Debugging code */
+ /* Dump the stacks after interpretation */
+ private void
+ debug_dump_stack(int code)
+ {	zflush(osp);	/* force out buffered output */
+ 	printf("\nInterp returns %d\n", code);
+ 	debug_dump_refs(osbot, osp + 1, "ostack");
+ 	debug_dump_refs(estack, esp + 1, "estack");
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gs.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gs.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gs.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,56 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gs.h */
+ /* Common definitions for GhostScript library */
+ #include <stdio.h>
+ #include "std.h"
+ 
+ /* Representation of a point. */
+ typedef struct gs_point_s {
+ 	float x, y;
+ } gs_point;
+ typedef struct gs_int_point_s {
+ 	int x, y;
+ } gs_int_point;
+ /* Representation of a rectangle. */
+ /* Note that rectangles are half-open, i.e.: their width is */
+ /* q.x-p.x and their height is q.y-p.y; they include the points */
+ /* (x,y) such that p.x<=x<q.x and p.y<=y<q.y. */
+ typedef struct gs_rect_s {
+ 	gs_point p, q;			/* origin point, corner point */
+ } gs_rect;
+ typedef struct gs_int_rect_s {
+ 	gs_int_point p, q;
+ } gs_int_rect;
+ 
+ /* So many routines use the graphics state */
+ /* that we may as well declare the abstract type here. */
+ typedef struct gs_state_s gs_state;
+ 
+ /* A number of interfaces involve user-specified allocation */
+ /* and deallocation procedures, so we define the structure here. */
+ typedef struct {
+ 	proc_alloc_t alloc;
+ 	proc_free_t free;
+ } gs_memory_procs;
+ /* We define our own versions of malloc and free that conform */
+ /* to the types proc_alloc_t and proc_free_t: */
+ char *gs_malloc(P3(uint, uint, char *));
+ void gs_free(P4(char *, uint, uint, char *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gschar.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gschar.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:22 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gschar.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,651 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gschar.c */
+ /* Character writing operators for GhostScript library */
+ #include "gx.h"
+ #include "memory_.h"
+ #include "string_.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"			/* ditto */
+ #include "gxarith.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"			/* must precede gzdevice */
+ #include "gzdevice.h"			/* must precede gxchar */
+ #include "gxdevmem.h"
+ #include "gxchar.h"
+ #include "gxfont.h"
+ #include "gzpath.h"
+ #include "gzcolor.h"
+ 
+ /* Exported size of enumerator */
+ int gs_show_enum_sizeof = sizeof(gs_show_enum);
+ 
+ /* Forward declarations */
+ private int continue_show(P1(gs_show_enum *));
+ private int continue_show_update(P1(gs_show_enum *));
+ private int continue_stringwidth(P1(gs_show_enum *));
+ private int continue_stringwidth_update(P1(gs_show_enum *));
+ private int show_setup(P3(gs_show_enum *, gs_state *, char *));
+ private int stringwidth_setup(P3(gs_show_enum *, gs_state *, char *));
+ 
+ /* Print the ctm if debugging */
+ #define print_ctm(s,pgs)\
+   printf("[p]%sctm=[%g %g %g %g %g %g]\n", s,\
+ 	 pgs->ctm.xx, pgs->ctm.xy, pgs->ctm.yx, pgs->ctm.yy,\
+ 	 pgs->ctm.tx, pgs->ctm.ty)
+ 
+ /* ------ String writing operators ------ */
+ 
+ /* Setup macros for show operators */
+ #define setup_show()\
+   penum->size = strlen(str)
+ #define setup_show_n()\
+   penum->size = size
+ #define setup_a()\
+   penum->add = 1, penum->ax = ax, penum->ay = ay,\
+   penum->slow_show = 1
+ #define setup_width()\
+   penum->chr = chr, penum->cx = cx, penum->cy = cy,\
+   penum->slow_show = 1
+ #define no_chr 0x100
+ 
+ /* show[_n] */
+ int
+ gs_show_init(register gs_show_enum *penum,
+   gs_state *pgs, char *str)
+ {	setup_show();
+ 	penum->slow_show = 0;
+ 	return show_setup(penum, pgs, str);
+ }
+ int
+ gs_show_n_init(register gs_show_enum *penum,
+   gs_state *pgs, char *str, uint size)
+ {	setup_show_n();
+ 	penum->slow_show = 0;
+ 	return show_setup(penum, pgs, str);
+ }
+ 
+ /* ashow[_n] */
+ int
+ gs_ashow_init(register gs_show_enum *penum,
+   gs_state *pgs, floatp ax, floatp ay, char *str)
+ {	int code;
+ 	setup_show();
+ 	code = show_setup(penum, pgs, str);
+ 	setup_a();
+ 	return code;
+ }
+ int
+ gs_ashow_n_init(register gs_show_enum *penum,
+   gs_state *pgs, floatp ax, floatp ay, char *str, uint size)
+ {	int code;
+ 	setup_show_n();
+ 	code = show_setup(penum, pgs, str);
+ 	setup_a();
+ 	return code;
+ }
+ 
+ /* widthshow[_n] */
+ int
+ gs_widthshow_init(register gs_show_enum *penum,
+   gs_state *pgs, floatp cx, floatp cy, char chr, char *str)
+ {	int code;
+ 	setup_show();
+ 	code = show_setup(penum, pgs, str);
+ 	setup_width();
+ 	return code;
+ }
+ int
+ gs_widthshow_n_init(register gs_show_enum *penum,
+   gs_state *pgs, floatp cx, floatp cy, char chr, char *str, uint size)
+ {	int code;
+ 	setup_show_n();
+ 	code = show_setup(penum, pgs, str);
+ 	setup_width();
+ 	return code;
+ }
+ 
+ /* awidthshow[_n] */
+ int
+ gs_awidthshow_init(register gs_show_enum *penum,
+   gs_state *pgs, floatp cx, floatp cy, char chr, floatp ax, floatp ay,
+   char *str)
+ {	int code;
+ 	setup_show();
+ 	code = show_setup(penum, pgs, str);
+ 	setup_a();
+ 	setup_width();
+ 	return code;
+ }
+ int
+ gs_awidthshow_n_init(register gs_show_enum *penum,
+   gs_state *pgs, floatp cx, floatp cy, char chr, floatp ax, floatp ay,
+   char *str, uint size)
+ {	int code;
+ 	setup_show_n();
+ 	code = show_setup(penum, pgs, str);
+ 	setup_a();
+ 	setup_width();
+ 	return code;
+ }
+ 
+ /* kshow[_n] */
+ int
+ gs_kshow_init(register gs_show_enum *penum,
+   gs_state *pgs, char *str)
+ {	int code;
+ 	setup_show();
+ 	code = show_setup(penum, pgs, str);
+ 	penum->do_kern = penum->slow_show = 1;
+ 	return code;
+ }
+ int
+ gs_kshow_n_init(register gs_show_enum *penum,
+   gs_state *pgs, char *str, uint size)
+ {	int code;
+ 	setup_show_n();
+ 	code = show_setup(penum, pgs, str);
+ 	penum->do_kern = penum->slow_show = 1;
+ 	return code;
+ }
+ 
+ /* ------ Related operators ------ */
+ 
+ /* stringwidth[_n] */
+ int
+ gs_stringwidth_init(gs_show_enum *penum, gs_state *pgs, char *str)
+ {	setup_show();
+ 	return stringwidth_setup(penum, pgs, str);
+ }
+ int
+ gs_stringwidth_n_init(gs_show_enum *penum, gs_state *pgs, char *str, uint size)
+ {	setup_show_n();
+ 	return stringwidth_setup(penum, pgs, str);
+ }
+ 
+ /* Common code for stringwidth[_n] */
+ private int
+ stringwidth_setup(gs_show_enum *penum, gs_state *pgs, char *str)
+ {	int code = show_setup(penum, pgs, str);
+ 	gs_fixed_point pt;
+ 	if ( code < 0 ) return_error(code);
+ 	penum->continue_proc = continue_stringwidth;
+ 	/* Do an extra gsave and suppress output */
+ 	if ( (code = gs_gsave(pgs)) < 0 ) return code;
+ 	gx_device_no_output(pgs);
+ 	/* If there is no current point, move to (0,0) */
+ 	if ( gx_path_current_point(pgs->path, &pt) < 0 )
+ 		gx_path_add_point(pgs->path, pgs->ctm.tx_fixed, pgs->ctm.ty_fixed);
+ 	return 0;
+ }
+ 
+ /* charpath[_n] */
+ int
+ gs_charpath_init(gs_show_enum *penum, gs_state *pgs,
+   char *str, int bool)
+ {	int code;
+ 	setup_show();
+ 	code = show_setup(penum, pgs, str);
+ 	penum->charpath_flag = (bool ? 2 : 1);
+ 	penum->can_cache = 0;
+ 	return code;
+ }
+ int
+ gs_charpath_n_init(gs_show_enum *penum, gs_state *pgs,
+   char *str, uint size, int bool)
+ {	int code;
+ 	setup_show_n();
+ 	code = show_setup(penum, pgs, str);
+ 	penum->charpath_flag = (bool ? 2 : 1);
+ 	penum->can_cache = 0;
+ 	return code;
+ }
+ 
+ /* ------ Width/cache operators ------ */
+ 
+ /* setcachedevice */
+ int
+ gs_setcachedevice(register gs_show_enum *penum,
+   floatp wx, floatp wy, floatp llx, floatp lly, floatp urx, floatp ury)
+ {	int code = gs_setcharwidth(penum, wx, wy);	/* default is don't cache */
+ 	gs_state *pgs = penum->pgs;
+ 	if ( code < 0 ) return code;
+ 	/* See if we want to cache this character. */
+ 	if ( pgs->in_cachedevice )		/* no recursion! */
+ 		return 0;
+ 	pgs->in_cachedevice = 1;	/* disable color/gray/image operators */
+ 	/* We can only use the cache if ctm is unchanged */
+ 	/* (aside from a possible translation), */
+ 	/* and if the extent of the box is non-negative. */
+ 	if ( !penum->can_cache || !pgs->char_tm_valid ||
+ 	     llx > urx || lly > ury
+ 	   )
+ 		return 0;
+ 	   {	gs_font_dir *dir = pgs->font->dir;
+ 		gs_fixed_point cbox_ll, cbox_ur, cdim;
+ 		long iwidth, iheight;
+ 		cached_char *cc;
+ 		gs_distance_transform2fixed(&pgs->ctm, llx, lly, &cbox_ll);
+ 		gs_distance_transform2fixed(&pgs->ctm, urx, ury, &cbox_ur);
+ 		cdim.x = cbox_ur.x - cbox_ll.x;
+ 		cdim.y = cbox_ur.y - cbox_ll.y;
+ 		if ( cdim.x < 0 ) cdim.x = -cdim.x;
+ 		if ( cdim.y < 0 ) cdim.y = -cdim.y;
+ #ifdef DEBUG
+ if ( gs_debug['k'] )
+    {	printf("[k]cbox=[%g %g %g %g]\n",
+ 	  fixed2float(cbox_ll.x), fixed2float(cbox_ll.y),
+ 	  fixed2float(cbox_ur.x), fixed2float(cbox_ur.y));
+ 	print_ctm("  ", pgs);
+    }
+ #endif
+ 		iwidth = fixed2long(cdim.x) + 2;
+ 		iheight = fixed2long(cdim.y) + 2;
+ 		if (	iwidth != (ushort)iwidth ||
+ 			iheight != (ushort)iheight
+ 		   )
+ 		  return 0;		/* much too big */
+ 		if ( !penum->dev_cache_set )
+ 		   {	/* Set up the memory device for the character cache */
+ 			device *dev = &penum->dev_cache_dev;
+ 			penum->dev_cache_info = mem_mono_device;
+ 			dev->info = (gx_device *)&penum->dev_cache_info;
+ 			dev->is_band_device = 0;
+ 			dev->white = 1;
+ 			dev->black = 1;
+ 			penum->dev_cache_set = 1;
+ 		   }
+ 		if ( (cc = gx_alloc_char_bits(dir,
+ 					(gx_device_memory *)&penum->dev_cache_info,
+ 					(ushort)iwidth,
+ 					(ushort)iheight)) == 0 )
+ 		  return 0;		/* too big for cache */
+ 		/* The mins handle transposed coordinate systems.... */
+ 		/* Round the offsets to avoid artifacts later. */
+ 		cc->offset.x = fixed_rounded(-min(cbox_ll.x, cbox_ur.x));
+ 		cc->offset.y = fixed_rounded(-min(cbox_ll.y, cbox_ur.y));
+ 		gx_color_render(pgs->color, pgs->dev_color, pgs);
+ 		if ( !color_is_pure(pgs->dev_color) )	/* can't use cache */
+ 		   {	gx_unalloc_cached_char(dir, cc);
+ 			return code;
+ 		   }
+ 		if ( (code = gs_gsave(pgs)) < 0 )
+ 		   {	gx_unalloc_cached_char(dir, cc);
+ 			return code;
+ 		   }
+ 		/* Nothing can go wrong now.... */
+ 		penum->cc = cc;
+ 		cc->code = gs_show_current_char(penum);
+ 		cc->wxy = penum->wxy;
+ 		/* Install the device */
+ 		pgs->device = &penum->dev_cache_dev;
+ 		pgs->device_is_shared = 1;	/* don't deallocate */
+ 		/* Adjust the translation in the graphics context */
+ 		/* so that the character lines up with the cache. */
+ 		gs_translate_to_fixed(pgs, cc->offset.x, cc->offset.y);
+ 		/* Reset the clipping path to match the metrics. */
+ 		if ( (code = gx_clip_to_rectangle(pgs, (fixed)0, (fixed)0, int2fixed(iwidth), int2fixed(iheight))) < 0 )
+ 		  return code;
+ 		/* Set the color to black. */
+ 		pgs->in_cachedevice = 0;
+ 		gs_setgray(pgs, 0.0);
+ 		pgs->in_cachedevice = 1;
+ 	   }
+ 	penum->width_set = sws_cache;
+ 	return 0;
+ }
+ 
+ /* setcharwidth */
+ int
+ gs_setcharwidth(register gs_show_enum *penum, floatp wx, floatp wy)
+ {	if ( penum->width_set != sws_none )
+ 		return_error(gs_error_undefined);
+ 	gs_distance_transform2fixed(&penum->pgs->ctm, wx, wy, &penum->wxy);
+ 	penum->width_set = sws_no_cache;
+ 	return 0;
+ }
+ 
+ /* ------ Enumerator ------ */
+ 
+ /* Do the next step of a show (or stringwidth) operation */
+ int
+ gs_show_next(gs_show_enum *penum)
+ {	return (*penum->continue_proc)(penum);
+ }
+ 
+ /* Continuation procedures for show (all varieties) */
+ #define show_fast_move(wxy, pgs)\
+   gx_path_add_relative_point_inline(pgs->path, wxy.x, wxy.y)
+ private int show_update(P1(register gs_show_enum *penum));
+ private int show_move(P1(register gs_show_enum *penum));
+ private int show_proceed(P1(register gs_show_enum *penum));
+ private int
+ continue_show_update(register gs_show_enum *penum)
+ {	int code = show_update(penum);
+ 	if ( code < 0 ) return code;
+ 	code = show_move(penum);
+ 	if ( code != 0 ) return code;
+ 	return show_proceed(penum);
+ }
+ private int
+ continue_show(register gs_show_enum *penum)
+ {	return show_proceed(penum);
+ }
+ /* Update position for show */
+ private int
+ show_update(register gs_show_enum *penum)
+ {	register gs_state *pgs = penum->pgs;
+ 	/* Update position for last character */
+ 	switch ( penum->width_set )
+ 	   {
+ 	case sws_none:
+ 		return_error(gs_error_undefinedresult);	/* WRONG */
+ 	case sws_cache:
+ 	   {	/* Finish installing the cache entry. */
+ 		cached_char *cc = penum->cc;
+ 		int code;
+ 		gx_add_cached_char(pgs->font->dir, cc, gx_lookup_fm_pair(pgs));
+ 		gs_grestore(pgs);
+ 		/* Copy the bits to the screen. */
+ 		penum->color_loaded = 0;	/* force gx_color_render */
+ 		code = gx_copy_cached_char(penum, cc);
+ 		if ( code < 0 ) return code;
+ 	   }
+ 	case sws_no_cache: ;
+ 	   }
+ 	gs_grestore(pgs);
+ 	return 0;
+ }
+ /* Move to next character for show */
+ private int
+ show_move(register gs_show_enum *penum)
+ {	register gs_state *pgs = penum->pgs;
+ 	if ( penum->add )
+ 		gs_rmoveto(pgs, penum->ax, penum->ay);
+ 	if ( penum->str[penum->index - 1] == penum->chr )
+ 		gs_rmoveto(pgs, penum->cx, penum->cy);
+ 	/* wxy is in device coordinates */
+ 	   {	int code = show_fast_move(penum->wxy, pgs);
+ 		if ( code < 0 ) return code;
+ 	   }
+ 	/* Check for kerning, but not on the last character. */
+ 	if ( penum->do_kern && penum->index < penum->size )
+ 	   {	penum->continue_proc = continue_show;
+ 		return gs_show_kern;
+ 	   }
+ 	return 0;
+ }
+ /* Process next character for show */
+ private int
+ show_proceed(register gs_show_enum *penum)
+ {	register gs_state *pgs = penum->pgs;
+ 	byte *str = penum->str;
+ 	uint index;
+ 	cached_fm_pair *pair = 0;
+ 	byte chr;
+ 	int code;
+ 	penum->color_loaded = 0;
+ more:	/* Proceed to next character */
+ 	if ( penum->can_cache )
+ 	   {	/* Loop with cache */
+ 		if ( pair == 0 )
+ 			pair = gx_lookup_fm_pair(pgs);
+ 		while ( (index = penum->index++) != penum->size )
+ 		   {	cached_char *cc;
+ 			chr = str[index];
+ 			cc = gx_lookup_cached_char(pgs, pair, chr);
+ 			if ( cc == 0 ) goto no_cache;
+ 			/* Character is in cache. */
+ 			code = gx_copy_cached_char(penum, cc);
+ 			if ( code < 0 ) return code;
+ 			else if ( code > 0 ) goto no_cache;
+ 			if ( penum->slow_show )
+ 			   {	penum->wxy = cc->wxy;
+ 				code = show_move(penum);
+ 			   }
+ 			else
+ 				code = show_fast_move(cc->wxy, pgs);
+ 			if ( code ) return code;
+ 		   }
+ 		/* All done. */
+ 		return 0;
+ 	   }
+ 	else
+ 	   {	/* Can't use cache */
+ 		if ( (index = penum->index++) == penum->size )
+ 		  {	/* All done. */
+ 			return 0;
+ 		  }
+ 		chr = str[index];
+ 	   }
+ no_cache:
+ 	/* Character is not cached, client must render it. */
+ 	if ( (code = gs_gsave(pgs)) < 0 ) return code;
+ 	/* Set the charpath flag in the graphics context if necessary, */
+ 	/* so that fill and stroke will add to the path */
+ 	/* rather than having their usual effect. */
+ 	pgs->in_charpath = penum->charpath_flag;
+ 	   {	gs_fixed_point cpt;
+ 		gx_path *ppath = pgs->path;
+ 		if ( (code = gx_path_current_point_inline(ppath, &cpt)) < 0 ) return code;
+ 		if ( !gx_path_is_void(ppath) && !penum->charpath_flag )
+ 		   {	gs_newpath(pgs);
+ 			gx_path_add_point(ppath, cpt.x, cpt.y);
+ 		   }
+ 		gs_setmatrix(pgs, &pgs->char_tm);
+ 		gs_translate_to_fixed(pgs, cpt.x, cpt.y);
+ 		/* Round the current translation in the graphics state. */
+ 		/* This helps prevent rounding artifacts later. */
+ 		pgs->ctm.tx_fixed = fixed_rounded(pgs->ctm.tx_fixed);
+ 		pgs->ctm.tx = fixed2float(pgs->ctm.tx_fixed);
+ 		pgs->ctm.ty_fixed = fixed_rounded(pgs->ctm.ty_fixed);
+ 		pgs->ctm.ty = fixed2float(pgs->ctm.ty_fixed);
+ 	   }
+ 	penum->width_set = sws_none;
+ 	penum->continue_proc = continue_show_update;
+ 	/* Try using the build procedure in the font. */
+ 	/* < 0 means error, 0 means success, 1 means failure. */
+ 	   {	gs_font *font = pgs->font;
+ 		code = (*font->build_char_proc)(penum, pgs, font, chr, font->build_char_data);
+ 		if ( code < 0 ) return code;
+ 		if ( code == 0 )
+ 		   {	code = show_update(penum);
+ 			if ( code < 0 ) return code;
+ 			penum->color_loaded = 0;
+ 			code = show_move(penum);
+ 			if ( code ) return code;
+ 			goto more;
+ 		   }
+ 	   }
+ 	return gs_show_render;
+ }
+ 
+ /* Continuation procedures for stringwidth */
+ private int stringwidth_update(P1(register gs_show_enum *penum));
+ private int stringwidth_move(P1(register gs_show_enum *penum));
+ private int stringwidth_proceed(P1(register gs_show_enum *penum));
+ private int
+ continue_stringwidth_update(register gs_show_enum *penum)
+ {	int code = stringwidth_update(penum);
+ 	if ( code < 0 ) return code;
+ 	code = stringwidth_move(penum);
+ 	if ( code != 0 ) return code;
+ 	return stringwidth_proceed(penum);
+ }
+ private int
+ continue_stringwidth(register gs_show_enum *penum)
+ {	return stringwidth_proceed(penum);
+ }
+ /* Update position for stringwidth */
+ private int
+ stringwidth_update(register gs_show_enum *penum)
+ {	register gs_state *pgs = penum->pgs;
+ 	/* Update position for last character */
+ 	switch ( penum->width_set )
+ 	   {
+ 	case sws_none:
+ 		return_error(gs_error_undefinedresult);	/* WRONG */
+ 	case sws_cache:
+ 	   {	/* Finish installing the cache entry. */
+ 		gx_add_cached_char(pgs->font->dir, penum->cc, gx_lookup_fm_pair(pgs));
+ 		gs_grestore(pgs);
+ 	   }
+ 	case sws_no_cache: ;
+ 	   }
+ 	gs_grestore(pgs);
+ 	return 0;
+ }
+ /* Move to next character for stringwidth */
+ private int
+ stringwidth_move(register gs_show_enum *penum)
+ {	/* wxy is in device coordinates */
+ 	return show_fast_move(penum->wxy, penum->pgs);
+ }
+ /* Process next character for stringwidth */
+ private int
+ stringwidth_proceed(register gs_show_enum *penum)
+ {	register gs_state *pgs = penum->pgs;
+ 	byte *str = penum->str;
+ 	uint index;
+ 	cached_fm_pair *pair = 0;
+ 	byte chr;
+ 	int code;
+ more:	/* Proceed to next character */
+ 	if ( (index = penum->index++) == penum->size )
+ 	  { /* All done.  Since this was a stringwidth, */
+ 	    /* save the accumulated width before returning, */
+ 	    /* and undo the extra gsave. */
+ 	    gs_point end_pt, start_pt;
+ 	    gs_currentpoint(pgs, &end_pt);
+ 	    gs_grestore(pgs);
+ 	    /* Handle the case where there was no current point */
+ 	    /* at the start of the stringwidth. */
+ 	    if ( gs_currentpoint(pgs, &start_pt) == gs_error_nocurrentpoint )
+ 	      start_pt.x = 0, start_pt.y = 0;
+ 	    penum->width.x = end_pt.x - start_pt.x;
+ 	    penum->width.y = end_pt.y - start_pt.y;
+ 	    return 0;
+ 	  }
+ 	chr = str[index];
+ 	if ( penum->can_cache )		/* Check cache first */
+ 	   {	cached_char *cc;
+ 		if ( pair == 0 )
+ 			pair = gx_lookup_fm_pair(pgs);
+ 		cc = gx_lookup_cached_char(pgs, pair, chr);
+ 		if ( cc != 0 )
+ 		   {	/* Character is in cache. */
+ 			penum->wxy = cc->wxy;
+ 			penum->width_set = sws_no_cache;
+ 			code = stringwidth_move(penum);
+ 			if ( code ) return code;
+ 			goto more;
+ 		   }
+ 	   }
+ 	/* Character is not cached, client must render it. */
+ 	if ( (code = gs_gsave(pgs)) < 0 ) return code;
+ 	   {	gs_fixed_point cpt;
+ 		if ( (code = gx_path_current_point_inline(pgs->path, &cpt)) < 0 ) return code;
+ 		gs_setmatrix(pgs, &pgs->char_tm);
+ 		gs_translate_to_fixed(pgs, cpt.x, cpt.y);
+ 	   }
+ 	penum->width_set = sws_none;
+ 	penum->continue_proc = continue_stringwidth_update;
+ 	/* Try using the build procedure in the font. */
+ 	/* < 0 means error, 0 means success, 1 means failure. */
+ 	   {	gs_font *font = pgs->font;
+ 		code = (*font->build_char_proc)(penum, pgs, font, chr, font->build_char_data);
+ 		if ( code < 0 ) return code;
+ 		if ( code == 0 )
+ 		   {	code = stringwidth_update(penum);
+ 			if ( code < 0 ) return code;
+ 			code = stringwidth_move(penum);
+ 			if ( code ) return code;
+ 			goto more;
+ 		   }
+ 	   }
+ 	return gs_show_render;
+ }
+ 
+ /* Return the current character for rendering. */
+ byte
+ gs_show_current_char(gs_show_enum *penum)
+ {	return penum->str[penum->index - 1];
+ }
+ 
+ /* Return the just-displayed character for kerning. */
+ byte
+ gs_kshow_previous_char(gs_show_enum *penum)
+ {	return penum->str[penum->index - 1];
+ }
+ 
+ /* Return the about-to-be-displayed character for kerning. */
+ byte
+ gs_kshow_next_char(gs_show_enum *penum)
+ {	return penum->str[penum->index];
+ }
+ 
+ /* Return the accumulated width for stringwidth. */
+ void
+ gs_show_width(gs_show_enum *penum, gs_point *ppt)
+ {	*ppt = penum->width;
+ }
+ 
+ /* Return the charpath flag. */
+ int
+ gs_show_in_charpath(gs_show_enum *penum)
+ {	return penum->charpath_flag;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Initialize a show enumerator */
+ private int
+ show_setup(register gs_show_enum *penum, gs_state *pgs, char *str)
+ {	int code;
+ 	penum->pgs = pgs;
+ 	penum->str = (byte *)str;	/* avoid signed chars */
+ 	penum->chr = no_chr;
+ 	penum->add = 0;
+ 	penum->do_kern = 0;
+ 	penum->charpath_flag = 0;
+ 	penum->dev_cache_set = 0;
+ 	penum->index = 0;
+ 	penum->continue_proc = continue_show;
+ 	if ( !pgs->char_tm_valid )
+ 	   {	/* Compute combined transformation */
+ 		gs_make_identity(&pgs->char_tm);	/* make sure type */
+ 					/* fields are set in char_tm! */
+ 		code = gs_matrix_multiply(&pgs->font->matrix,
+ 					  &ctm_only(pgs), &pgs->char_tm);
+ 		if ( code < 0 ) return code;
+ 		pgs->char_tm_valid = 1;
+ 	   }
+ 	if ( penum->can_cache =	/* no skewing or non-rectangular rotation */
+ 		(is_fzero2(pgs->char_tm.xy, pgs->char_tm.yx) ||
+ 		 is_fzero2(pgs->char_tm.xx, pgs->char_tm.yy)) )
+ 	   {	gs_fixed_rect cbox;
+ 		gx_cpath_box_for_check(pgs->clip_path, &cbox);
+ 		penum->cxmin = fixed2int_ceiling(cbox.p.x);
+ 		penum->cymin = fixed2int_ceiling(cbox.p.y);
+ 		penum->cxmax = fixed2int(cbox.q.x);
+ 		penum->cymax = fixed2int(cbox.q.y);
+ 	   }
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gschar.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gschar.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gschar.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,75 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gschar.h */
+ /* Character operations for GhostScript library */
+ 
+ /* String display, like image display, uses an enumeration structure */
+ /* to keep track of what's going on (aka 'poor man's callback'). */
+ typedef struct gs_show_enum_s gs_show_enum;
+ extern int gs_show_enum_sizeof;
+ 
+ /* The routines all come in two versions, */
+ /* one that uses the C convention of null-terminated strings, */
+ /* and one that supplies a length. */
+ int	gs_show_init(P3(gs_show_enum *, gs_state *, char *)),
+ 	gs_show_n_init(P4(gs_show_enum *, gs_state *, char *, uint)),
+ 	gs_ashow_init(P5(gs_show_enum *, gs_state *, floatp, floatp, char *)),
+ 	gs_ashow_n_init(P6(gs_show_enum *, gs_state *, floatp, floatp, char *, uint)),
+ 	gs_widthshow_init(P6(gs_show_enum *, gs_state *, floatp, floatp, char, char *)),
+ 	gs_widthshow_n_init(P7(gs_show_enum *, gs_state *, floatp, floatp, char, char *, uint)),
+ 	gs_awidthshow_init(P8(gs_show_enum *, gs_state *, floatp, floatp, char, floatp, floatp, char *)),
+ 	gs_awidthshow_n_init(P9(gs_show_enum *, gs_state *, floatp, floatp, char, floatp, floatp, char *, uint)),
+ 	gs_kshow_init(P3(gs_show_enum *, gs_state *, char *)),
+ 	gs_kshow_n_init(P4(gs_show_enum *, gs_state *, char *, uint)),
+ 	gs_stringwidth_init(P3(gs_show_enum *, gs_state *, char *)),
+ 	gs_stringwidth_n_init(P4(gs_show_enum *, gs_state *, char *, uint)),
+ 	gs_charpath_init(P4(gs_show_enum *, gs_state *, char *, int)),
+ 	gs_charpath_n_init(P5(gs_show_enum *, gs_state *, char *, uint, int));
+ 
+ /* After setting up the enumeration, all the string-related routines */
+ /* work the same way.  The client calls gs_show_next until it returns */
+ /* a zero (successful completion) or negative (error) value. */
+ /* Other values indicate the following situations: */
+ 
+ 	/* The client must render a character: obtain the code from */
+ 	/* gs_show_current_char, do whatever is necessary, and then */
+ 	/* call gs_show_next again. */
+ #define gs_show_render 1
+ 
+ 	/* The client has asked to intervene between characters (kshow). */
+ 	/* Obtain the previous and next codes from gs_kshow_previous_char */
+ 	/* and gs_kshow_next_char, do whatever is necessary, and then */
+ 	/* call gs_show_next again. */
+ #define gs_show_kern 2
+ 
+ int	gs_show_next(P1(gs_show_enum *));
+ byte	gs_show_current_char(P1(gs_show_enum *)),
+ 	gs_kshow_previous_char(P1(gs_show_enum *)),
+ 	gs_kshow_next_char(P1(gs_show_enum *));
+ void	gs_show_width(P2(gs_show_enum *, gs_point *));	/* cumulative width */
+ int	gs_show_in_charpath(P1(gs_show_enum *));	/* return charpath flag */
+ 
+ /* Convert an image to an outline encoding. */
+ int	gs_type1imagepath(P10(gs_state *, byte *, int, int,
+ 			      floatp, floatp, floatp, floatp, byte *, uint));
+ 
+ /* Font cache operators */
+ int	gs_setcachedevice(P7(gs_show_enum *, floatp, floatp, floatp, floatp, floatp, floatp));
+ int	gs_setcharwidth(P3(gs_show_enum *, floatp, floatp));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscolor.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscolor.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscolor.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,335 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gscolor.c */
+ /* Color and halftone operators for GhostScript library */
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"			/* ditto */
+ #include "gxmatrix.h"			/* for gzstate.h */
+ #include "gxdevice.h"			/* for gx_color_index */
+ #include "gzstate.h"
+ #include "gzcolor.h"
+ #include "gzht.h"
+ 
+ /* Exported values */
+ int gs_screen_enum_sizeof = sizeof(gs_screen_enum);
+ int gs_color_sizeof = sizeof(gs_color);
+ 
+ /* Forward declarations */
+ private int check_unit(P2(floatp, float *));
+ private int tri_param(P4(floatp, floatp, floatp, color_param [3]));
+ private void tri_return(P4(color_param, color_param, color_param, float [3]));
+ /* Imported from gxcolor.c */
+ void	gx_color_from_hsb(P4(gs_color *, color_param, color_param, color_param)),
+ 	gx_color_from_rgb(P1(gs_color *)),
+ 	gx_color_to_hsb(P2(gs_color *, color_param [3])),
+ 	gx_sort_ht_order(P2(ht_bit *, uint));
+ 
+ /* setgray */
+ int
+ gs_setgray(gs_state *pgs, floatp gray)
+ {	float fgray;
+ 	int code;
+ 	gs_color *pcolor = pgs->color;
+ 	if ( pgs->in_cachedevice ) return_error(gs_error_undefined);
+ 	code = check_unit(gray, &fgray);
+ 	if ( !code )
+ 	   {	pcolor->luminance = max_color_param * fgray;
+ 		pcolor->red = pcolor->green = pcolor->blue =
+ 		  pcolor->luminance;
+ 		pcolor->is_gray = pcolor->luminance_set = 1;
+ 	   }
+ 	return code;
+ }
+ 
+ /* currentgray */
+ float
+ gs_currentgray(gs_state *pgs)
+ {	return (float)(color_luminance(pgs->color) / (float)max_color_param);
+ }
+ 
+ /* setgscolor */
+ int
+ gs_setgscolor(gs_state *pgs, gs_color *pcolor)
+ {	if ( pgs->in_cachedevice ) return_error(gs_error_undefined);
+ 	*pgs->color = *pcolor;
+ 	return 0;
+ }
+ 
+ /* currentgscolor */
+ int
+ gs_currentgscolor(gs_state *pgs, gs_color *pcolor)
+ {	*pcolor = *pgs->color;
+ 	return 0;
+ }
+ 
+ /* sethsbcolor */
+ int
+ gs_sethsbcolor(gs_state *pgs, floatp h, floatp s, floatp b)
+ {	color_param params[3];
+ 	int code;
+ 	if ( pgs->in_cachedevice ) return_error(gs_error_undefined);
+ 	code = tri_param(h, s, b, params);
+ 	if ( !code )
+ 	   {	gx_color_from_hsb(pgs->color, params[0], params[1], params[2]);
+ 	   }
+ 	return code;
+ }
+ 
+ /* currenthsbcolor */
+ int
+ gs_currenthsbcolor(gs_state *pgs, float pr3[3])
+ {	color_param hsb[3];
+ 	gx_color_to_hsb(pgs->color, hsb);
+ 	tri_return(hsb[0], hsb[1], hsb[2], pr3);
+ 	return 0;
+ }
+ 
+ /* setrgbcolor */
+ int
+ gs_setrgbcolor(gs_state *pgs, floatp r, floatp g, floatp b)
+ {	color_param params[3];
+ 	int code;
+ 	if ( pgs->in_cachedevice ) return_error(gs_error_undefined);
+ 	code = tri_param(r, g, b, params);
+ 	if ( !code )
+ 	   {	gs_color *pcolor = pgs->color;
+ 		pcolor->red = params[0];
+ 		pcolor->green = params[1];
+ 		pcolor->blue = params[2];
+ 		gx_color_from_rgb(pcolor);
+ 	   }
+ 	return code;
+ }
+ 
+ /* currentrgbcolor */
+ int
+ gs_currentrgbcolor(gs_state *pgs, float pr3[3])
+ {	gs_color *pcolor = pgs->color;
+ 	tri_return(pcolor->red, pcolor->green, pcolor->blue, pr3);
+ 	return 0;
+ }
+ /* A special entry for makeimagedevice, for converting the palette. */
+ int
+ gs_colorrgb(gs_color *pcolor, float pr3[3])
+ {	tri_return(pcolor->red, pcolor->green, pcolor->blue, pr3);
+ 	return 0;
+ }
+ 
+ /* setscreen */
+ int
+ gs_setscreen(gs_state *pgs,
+   floatp freq, floatp angle, float (*proc)(P2(floatp, floatp)))
+ {	gs_screen_enum senum;
+ 	gs_point pt;
+ 	int code = gs_screen_init(&senum, pgs, freq, angle);
+ 	if ( code < 0 ) return code;
+ 	while ( (code = gs_screen_currentpoint(&senum, &pt)) == 0 )
+ 		if ( (code = gs_screen_next(&senum, (*proc)(pt.x, pt.y))) < 0 )
+ 			return code;
+ 	if ( code < 0 ) return code;
+ 	pgs->ht_proc = proc;
+ 	return 0;
+ }
+ 
+ /* currentscreen */
+ int
+ gs_currentscreen(gs_state *pgs,
+   float *pfreq, float *pangle, float (**pproc)(P2(floatp, floatp)))
+ {	halftone *pht = pgs->halftone;
+ 	*pfreq = pht->frequency;
+ 	*pangle = pht->angle;
+ 	*pproc = pgs->ht_proc;
+ 	return 0;
+ }
+ 
+ /* ------ Halftone sampling ------ */
+ 
+ /* Set up for halftone sampling */
+ int
+ gs_screen_init(gs_screen_enum *penum, gs_state *pgs,
+   floatp freq, floatp angle)
+ {	int cwidth, cheight;
+ 	int code;
+ 	ht_bit *order;
+ 	if ( freq < 0 ) return_error(gs_error_rangecheck);
+ 	/* Convert the frequency to cell width and height */
+ 	   {	float cell_size = 72.0 / freq;
+ 		gs_point pcwh;
+ 		gs_matrix imat;
+ 		int dev_w, dev_h;
+ 		gs_deviceparams(gs_currentdevice(pgs), &imat, &dev_w, &dev_h);
+ 		if ( (code = gs_distance_transform(cell_size, cell_size,
+ 						   &imat, &pcwh)) < 0
+ 		    ) return code;
+ 		/* It isn't clear to me whether we should round the */
+ 		/* width and height, truncate them, or do something */
+ 		/* more complicated.  All the problems arise from devices */
+ 		/* whose X and Y resolutions aren't the same: */
+ 		/* the halftone model isn't really designed for this. */
+ 		/* For the moment, truncate and hope for the best. */
+ #define abs_round(z) (z < 0 ? -(int)(z) : (int)(z))
+ /*#define abs_round(z) (z < 0 ? -(int)(z - 0.5) : (int)(z + 0.5))*/
+ 		cwidth = abs_round(pcwh.x);
+ 		cheight = abs_round(pcwh.y);
+ #undef abs_round
+ 	   }
+ 	if ( cwidth == 0 ) cwidth = 1;
+ 	if ( cheight == 0 ) cheight = 1;
+ 	if ( cwidth > max_ushort / cheight )
+ 		return_error(gs_error_rangecheck);
+ 	order = (ht_bit *)gs_malloc(cwidth * cheight, sizeof(ht_bit),
+ 				    "halftone samples");
+ 	if ( order == 0 ) return_error(gs_error_VMerror);
+ 	penum->freq = freq;
+ 	penum->angle = angle;
+ 	penum->order = order;
+ 	penum->width = cwidth;
+ 	penum->height = cheight;
+ 	penum->x = penum->y = 0;
+ 	penum->pgs = pgs;
+ 	/* The transformation matrix must include normalization to the */
+ 	/* interval (-1..1), and rotation by the negative of the angle. */
+ 	   {	float xscale = 2.0 / cwidth;
+ 		float yscale = 2.0 / cheight;
+ 		gs_matrix mat;
+ 		gs_make_identity(&mat);
+ 		mat.xx = xscale;
+ 		mat.yy = yscale;
+ 		mat.tx = xscale * 0.5 - 1.0;
+ 		mat.ty = yscale * 0.5 - 1.0;
+ 		if ( (code = gs_matrix_rotate(&mat, -angle, &penum->mat)) < 0 )
+ 			return code;
+ #ifdef DEBUG
+ if ( gs_debug['h'] )
+ 	printf("[h]Screen: w=%d h=%d [%f %f %f %f %f %f]\n",
+ 		cwidth, cheight, penum->mat.xx, penum->mat.xy,
+ 		penum->mat.yx, penum->mat.yy, penum->mat.tx, penum->mat.ty);
+ #endif
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Report current point for sampling */
+ private int gx_screen_finish(P1(gs_screen_enum *));
+ int
+ gs_screen_currentpoint(gs_screen_enum *penum, gs_point *ppt)
+ {	gs_point pt;
+ 	int code;
+ 	if ( penum->y >= penum->height )	/* all done */
+ 		return gx_screen_finish(penum);
+ 	if ( (code = gs_point_transform((floatp)penum->x, (floatp)penum->y, &penum->mat, &pt)) < 0 )
+ 		return code;
+ 	if ( pt.x < -1.0 ) pt.x += 2.0;
+ 	else if ( pt.x > 1.0 ) pt.x -= 2.0;
+ 	if ( pt.y < -1.0 ) pt.y += 2.0;
+ 	else if ( pt.y > 1.0 ) pt.y -= 2.0;
+ 	*ppt = pt;
+ 	return 0;
+ }
+ 
+ /* Record next halftone sample */
+ int
+ gs_screen_next(gs_screen_enum *penum, floatp value)
+ {	ushort sample;
+ 	ht_bit *order = penum->order;
+ 	if ( value < -1.0 || value > 1.0 )
+ 	  return_error(gs_error_rangecheck);
+ 	sample = (ushort)(value * (float)(int)(max_ushort >> 1)) +
+ 		   (max_ushort >> 1);
+ #ifdef DEBUG
+ if ( gs_debug['h'] )
+    {	gs_point pt;
+ 	gs_screen_currentpoint(penum, &pt);
+ 	printf("[h]sample x=%d y=%d (%f,%f): %f -> %u\n",
+ 		penum->x, penum->y, pt.x, pt.y, value, sample);
+    }
+ #endif
+ 	order[penum->y * penum->width + penum->x].mask = sample;
+ 	if ( ++(penum->x) >= penum->width )
+ 		penum->x = 0, ++(penum->y);
+ 	return 0;
+ }
+ 
+ /* All points have been sampled. */
+ /* Finish constructing the halftone. */
+ private int
+ gx_screen_finish(gs_screen_enum *penum)
+ {	ht_bit *order = penum->order;
+ 	uint size = penum->width * penum->height;
+ 	uint i;
+ 	int code;
+ 	halftone *pht;
+ 	/* Label each element with its ordinal position. */
+ 	for ( i = 0; i < size; i++ )
+ 		order[i].offset = i;
+ 	/* Sort the samples in increasing order by value. */
+ 	gx_sort_ht_order(order, size);
+ 	/* Set up the actual halftone description. */
+ 	code = gx_ht_construct_order(penum->order, penum->width, penum->height);
+ 	if ( code < 0 ) return code;
+ 	pht = penum->pgs->halftone;
+ 	pht->frequency = penum->freq;
+ 	pht->angle = penum->angle;
+ 	pht->width = penum->width;
+ 	pht->height = penum->height;
+ 	pht->order = penum->order;
+ 	pht->order_size = pht->width * pht->height;
+ 	return 1;			/* all done */
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Force a parameter into the range [0..1]. */
+ private int
+ check_unit(floatp fval, float *pp)
+ {	if ( fval < 0.0 )
+ 		*pp = 0.0;
+ 	else if ( fval > 1.0 )
+ 		*pp = 1.0;
+ 	else
+ 		*pp = fval;
+ 	return 0;
+ }
+ 
+ /* Get 3 real parameters in the range [0..1], */
+ /* and convert them to color_params. */
+ /* If any of them are invalid, none of the return values are set. */
+ private int
+ tri_param(floatp p1, floatp p2, floatp p3, color_param pq3[3])
+ {	int code;
+ 	float f1, f2, f3;
+ 	if (	(code = check_unit(p1, &f1)) < 0 ||
+ 		(code = check_unit(p2, &f2)) < 0 ||
+ 		(code = check_unit(p3, &f3)) < 0
+ 	   ) return code;
+ 	pq3[0] = f1 * max_color_param;
+ 	pq3[1] = f2 * max_color_param;
+ 	pq3[2] = f3 * max_color_param;
+ 	return 0;
+ }
+ 
+ /* Convert 3 color_params to reals */
+ private void
+ tri_return(color_param p1, color_param p2, color_param p3, float pr3[3])
+ {	pr3[0] = p1 / (float)max_color_param;
+ 	pr3[1] = p2 / (float)max_color_param;
+ 	pr3[2] = p3 / (float)max_color_param;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsconfig
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsconfig:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsconfig	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,7 ----
+ #!/bin/sh
+ rm -f gdevs.h
+ echo >gdevs.h
+ for dev in $*
+ do
+ 	echo d\(gs_${dev}_device\) >>gdevs.h
+ done


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscoord.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscoord.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscoord.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,210 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gscoord.c */
+ /* Coordinate system operators for GhostScript library */
+ #include "math_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"			/* requires gsstate */
+ #include "gscoord.h"			/* requires gsmatrix, gsstate */
+ 
+ /* Forward declarations */
+ #ifdef DEBUG
+ private void trace_ctm(P1(gs_state *));
+ private void trace_matrix(P1(gs_matrix *));
+ #endif
+ 
+ /* Macro for ensuring ctm_inverse is valid */
+ #ifdef DEBUG
+ #define print_inverse(pgs)\
+ if ( gs_debug['x'] )\
+ 	printf("[x]Inverting:\n"), trace_ctm(pgs), trace_matrix(&pgs->ctm_inverse)
+ #else
+ #define print_inverse(pgs) 0
+ #endif
+ #define ensure_inverse_valid(pgs)\
+ 	if ( !pgs->inverse_valid )\
+ 	   {	int code = gs_matrix_invert(&ctm_only(pgs), &pgs->ctm_inverse);\
+ 		print_inverse(pgs);\
+ 		if ( code < 0 ) return code;\
+ 		pgs->inverse_valid = 1;\
+ 	   }
+ 
+ /* Macro for updating fixed version of ctm */
+ #define update_ctm(pgs)\
+ 	pgs->ctm.tx_fixed = float2fixed(pgs->ctm.tx),\
+ 	pgs->ctm.ty_fixed = float2fixed(pgs->ctm.ty),\
+ 	pgs->inverse_valid = 0
+ 
+ /* ------ Coordinate system definition ------ */
+ 
+ int
+ gs_initmatrix(gs_state *pgs)
+ {	gx_device *dev = pgs->device->info;
+ 	(*dev->procs->get_initial_matrix)(dev, &ctm_only(pgs));
+ 	update_ctm(pgs);
+ 	pgs->char_tm_valid = 0;
+ #ifdef DEBUG
+ if ( gs_debug['x'] )
+ 	printf("[x]initmatrix:\n"), trace_ctm(pgs);
+ #endif
+ 	return 0;
+ }
+ 
+ int
+ gs_defaultmatrix(gs_state *pgs, gs_matrix *pmat)
+ {	gx_device *dev = pgs->device->info;
+ 	(*dev->procs->get_initial_matrix)(dev, pmat);
+ 	return 0;
+ }
+ 
+ int
+ gs_currentmatrix(gs_state *pgs, gs_matrix *pmat)
+ {	*pmat = ctm_only(pgs);
+ 	return 0;
+ }
+ 
+ int
+ gs_setmatrix(gs_state *pgs, gs_matrix *pmat)
+ {	ctm_only(pgs) = *pmat;
+ 	update_ctm(pgs);
+ 	pgs->char_tm_valid = 0;
+ #ifdef DEBUG
+ if ( gs_debug['x'] )
+ 	printf("[x]setmatrix:\n"), trace_ctm(pgs);
+ #endif
+ 	return 0;
+ }
+ 
+ int
+ gs_translate(gs_state *pgs, floatp dx, floatp dy)
+ {	gs_point pt;
+ 	int code;
+ 	if ( (code = gs_distance_transform(dx, dy, &ctm_only(pgs), &pt)) < 0 )
+ 		return code;
+ 	pgs->ctm.tx += pt.x;
+ 	pgs->ctm.ty += pt.y;
+ 	update_ctm(pgs);		/* leaves char_tm valid */
+ #ifdef DEBUG
+ if ( gs_debug['x'] )
+ 	printf("[x]translate: %f %f -> %f %f\n",
+ 		dx, dy, pt.x, pt.y),
+ 	trace_ctm(pgs);
+ #endif
+ 	return 0;
+ }
+ 
+ int
+ gs_scale(gs_state *pgs, floatp sx, floatp sy)
+ {	pgs->ctm.xx *= sx;
+ 	pgs->ctm.xy *= sx;
+ 	pgs->ctm.yx *= sy;
+ 	pgs->ctm.yy *= sy;
+ 	pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
+ #ifdef DEBUG
+ if ( gs_debug['x'] )
+ 	printf("[x]scale: %f %f\n", sx, sy), trace_ctm(pgs);
+ #endif
+ 	return 0;
+ }
+ 
+ int
+ gs_rotate(gs_state *pgs, floatp ang)
+ {	int code = gs_matrix_rotate(&ctm_only(pgs), ang, &ctm_only(pgs));
+ 	pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
+ #ifdef DEBUG
+ if ( gs_debug['x'] )
+ 	printf("[x]rotate: %f\n", ang), trace_ctm(pgs);
+ #endif
+ 	return code;
+ }
+ 
+ int
+ gs_concat(gs_state *pgs, gs_matrix *pmat)
+ {	int code = gs_matrix_multiply(pmat, &ctm_only(pgs), &ctm_only(pgs));
+ 	update_ctm(pgs);
+ 	pgs->char_tm_valid = 0;
+ #ifdef DEBUG
+ if ( gs_debug['x'] )
+ 	printf("[x]concat:\n"), trace_matrix(pmat), trace_ctm(pgs);
+ #endif
+ 	return code;
+ }
+ 
+ /* ------ Coordinate transformation ------ */
+ 
+ int
+ gs_transform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
+ {	return gs_point_transform(x, y, &ctm_only(pgs), pt);
+ }
+ 
+ int
+ gs_dtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
+ {	return gs_distance_transform(dx, dy, &ctm_only(pgs), pt);
+ }
+ 
+ int
+ gs_itransform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
+ {	ensure_inverse_valid(pgs);
+ 	return gs_point_transform((float)x, (float)y, &pgs->ctm_inverse, pt);
+ }
+ 
+ int
+ gs_idtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
+ {	ensure_inverse_valid(pgs);
+ 	return gs_distance_transform((float)dx, (float)dy, &pgs->ctm_inverse, pt);
+ }
+ 
+ /* ------ For internal use only ------ */
+ 
+ /* Set the translation to a given fixed value, */
+ /* and mark char_tm as valid. */
+ /* Used by gschar.c to prepare for a BuildChar procedure. */
+ int
+ gs_translate_to_fixed(register gs_state *pgs, fixed px, fixed py)
+ {	pgs->ctm.tx = fixed2float(pgs->ctm.tx_fixed = px);
+ 	pgs->ctm.ty = fixed2float(pgs->ctm.ty_fixed = py);
+ 	pgs->inverse_valid = 0;
+ 	pgs->char_tm_valid = 1;
+ 	return 0;
+ }
+ 
+ /* ------ Debugging printout ------ */
+ 
+ #ifdef DEBUG
+ 
+ /* Print a matrix */
+ private void
+ trace_ctm(gs_state *pgs)
+ {	gs_matrix_fixed *pmat = &pgs->ctm;
+ 	trace_matrix((gs_matrix *)pmat);
+ 	printf("\t\tt_fixed: [%6g %6g]\n",
+ 		fixed2float(pmat->tx_fixed), fixed2float(pmat->ty_fixed));
+ }
+ private void
+ trace_matrix(register gs_matrix *pmat)
+ {	printf("\t[%6g %6g %6g %6g %6g %6g]\n",
+ 		pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
+ }
+ 
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscoord.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscoord.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gscoord.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,38 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gscoord.h */
+ /* Coordinate system operators for GhostScript library */
+ /* Requires gsmatrix.h and gsstate.h */
+ 
+ /* Coordinate system modification */
+ int	gs_initmatrix(P1(gs_state *)),
+ 	gs_defaultmatrix(P2(gs_state *, gs_matrix *)),
+ 	gs_currentmatrix(P2(gs_state *, gs_matrix *)),
+ 	gs_setmatrix(P2(gs_state *, gs_matrix *)),
+ 	gs_translate(P3(gs_state *, floatp, floatp)),
+ 	gs_scale(P3(gs_state *, floatp, floatp)),
+ 	gs_rotate(P2(gs_state *, floatp)),
+ 	gs_concat(P2(gs_state *, gs_matrix *));
+ 
+ /* Coordinate transformation */
+ int	gs_transform(P4(gs_state *, floatp, floatp, gs_point *)),
+ 	gs_dtransform(P4(gs_state *, floatp, floatp, gs_point *)),
+ 	gs_itransform(P4(gs_state *, floatp, floatp, gs_point *)),
+ 	gs_idtransform(P4(gs_state *, floatp, floatp, gs_point *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsdevice.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsdevice.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsdevice.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,599 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsdevice.c */
+ /* Device operators for GhostScript library */
+ #include "math_.h"			/* for fabs */
+ #include "memory_.h"			/* for memcpy */
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"			/* ditto */
+ #include "gxmatrix.h"			/* for gzstate.h */
+ #include "gxbitmap.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"
+ #include "gxdevmem.h"
+ 
+ /* Import the device list from gdevs.c */
+ extern gx_device *gx_device_list[];
+ 
+ /* Device definitions */
+ /* Following defines the null device */
+ private dev_proc_fill_rectangle(null_fill_rectangle);
+ private dev_proc_tile_rectangle(null_tile_rectangle);
+ private dev_proc_copy_mono(null_copy_mono);
+ private dev_proc_copy_color(null_copy_color);
+ private dev_proc_draw_line(null_draw_line);
+ private dev_proc_fill_trapezoid(null_fill_trapezoid);
+ private dev_proc_tile_trapezoid(null_tile_trapezoid);
+ 
+ private gx_device_procs null_procs = {
+ 	gx_default_open_device,
+ 	gx_default_get_initial_matrix,
+ 	gx_default_sync_output,
+ 	gx_default_output_page,
+ 	gx_default_close_device,
+ 	gx_default_map_rgb_color,
+ 	gx_default_map_color_rgb,
+ 	null_fill_rectangle,
+ 	null_tile_rectangle,
+ 	null_copy_mono,
+ 	null_copy_color,
+ 	null_draw_line,
+ 	null_fill_trapezoid,
+ 	null_tile_trapezoid
+ };
+ private gx_device null_device = {
+ 	sizeof(device),
+ 	&null_procs,
+ 	"null",
+ 	0x3fff, 0x3fff,			/* 0, 0, */
+ 	1, 1,
+ 	0, 1, 1, 1
+ };
+ 
+ /* The null device */
+ gx_device *gx_device_null_p = &null_device;
+ 
+ /* Flush buffered output to the device */
+ int
+ gs_flushpage(gs_state *pgs)
+ {	gx_device *dev = pgs->device->info;
+ 	return (*dev->procs->sync_output)(dev);
+ }
+ 
+ /* Make the device output the accumulated page description */
+ int
+ gs_copypage(gs_state *pgs)
+ {	gx_device *dev = pgs->device->info;
+ 	return (*dev->procs->output_page)(dev);
+ }
+ 
+ /* Copy scan lines from an image device */
+ int
+ gs_copyscanlines(gx_device *dev, int start_y, byte *data, uint size,
+   int *plines_copied, uint *pbytes_copied)
+ {	int count;
+ 	if ( !gs_device_is_memory(dev) ) return_error(gs_error_undefined);
+ 	count = mem_copy_scan_lines((gx_device_memory *)dev,
+ 			start_y, data, size);
+ 	if ( plines_copied != NULL )
+ 		*plines_copied = count;
+ 	if ( pbytes_copied != NULL )
+ 		*pbytes_copied = count *
+ 			mem_bytes_per_scan_line((gx_device_memory *)dev);
+ 	return 0;
+ }
+ 
+ /* Get the current device from the graphics state */
+ gx_device *
+ gs_currentdevice(gs_state *pgs)
+ {	return pgs->device->info;
+ }
+ 
+ /* Get the name of a device */
+ char *
+ gs_devicename(gx_device *dev)
+ {	return dev->name;
+ }
+ 
+ /* Read out the current device parameters */
+ void
+ gs_deviceparams(gx_device *dev, gs_matrix *pmat, int *pwidth, int *pheight)
+ {	(*dev->procs->get_initial_matrix)(dev, pmat);
+ 	*pwidth = dev->width;
+ 	*pheight = dev->height;
+ }
+ 
+ /* Get the N'th device from the known device list */
+ gx_device *
+ gs_getdevice(int index)
+ {	int i;
+ 	for ( i = 0; gx_device_list[i] != 0; i++ )
+ 	   {	if ( i == index ) return gx_device_list[i];
+ 	   }
+ 	return 0;			/* index out of range */
+ }
+ 
+ /* Make a device by cloning an existing one */
+ int
+ gs_makedevice(gx_device **pnew_dev, gx_device *dev, gs_matrix *pmat,
+   uint width, uint height, proc_alloc_t palloc)
+ {	register gx_device *new_dev;
+ 	new_dev = (gx_device *)(*palloc)(1, dev->params_size, "gs_makedevice");
+ 	if ( new_dev == 0 ) return_error(gs_error_VMerror);
+ 	if ( width <= 0 || height <= 0 ) return_error(gs_error_rangecheck);
+ 	memcpy(new_dev, dev, dev->params_size);
+ 	new_dev->width = width;
+ 	new_dev->height = height;
+ 	new_dev->is_open = 0;
+ 	*pnew_dev = new_dev;
+ 	return 0;
+ }
+ 
+ /* Make a memory (image) device. */
+ /* If num_colors = -24 or -32, this is a true-color device; */
+ /* otherwise, num_colors is the number of colors in the palette. */
+ int
+ gs_makeimagedevice(gx_device **pnew_dev, gs_matrix *pmat,
+   uint width, uint height, float *colors, int num_colors, proc_alloc_t palloc)
+ {	gx_device_memory *old_dev = &mem_mapped_color_device;
+ 	register gx_device_memory *new_dev;
+ 	byte *bits;
+ 	int palette_size = num_colors;
+ 	int pcount;
+ 	int bits_per_pixel;
+ 	ulong bitmap_size;
+ 	int white = -1, black = -1;
+ 	byte palette[256 * 3];
+ 	int has_color;
+ 	if ( width <= 0 || height <= 0 ) return_error(gs_error_rangecheck);
+ 	/************** TEMPORARY LIMITATION: **************/
+ 	/*** only 1-, 8-, 24-, and 32-bit are supported. ***/
+ 	switch ( num_colors )
+ 	   {
+ 	case 2:
+ 		bits_per_pixel = 1; old_dev = &mem_mono_device;
+ 		break;
+ 	case 4:		/*** bits_per_pixel = 2; break; ***/
+ 	case 16:	/*** bits_per_pixel = 4; break; ***/
+ 		return_error(gs_error_rangecheck);
+ 	case 256:
+ 		bits_per_pixel = 8; break;
+ 	case -24:
+ 		bits_per_pixel = 24; old_dev = &mem_true24_color_device;
+ 		palette_size = 0; break;
+ 	case -32:
+ 		bits_per_pixel = 32; old_dev = &mem_true32_color_device;
+ 		palette_size = 0; break;
+ 	default:
+ 		return_error(gs_error_rangecheck);
+ 	   }
+ 	pcount = palette_size * 3;
+ 	/* Check to make sure the palette contains white and black. */
+ 	if ( bits_per_pixel <= 8 )
+ 	   {	float *p;
+ 		byte *q;
+ 		int i;
+ 		has_color = 0;
+ 		for ( i = 0, p = colors, q = palette;
+ 		      i < pcount; i++, p++, q++
+ 		    )
+ 		   {	if ( *p < -0.001 || *p > 1.001 )
+ 				return_error(gs_error_rangecheck);
+ 			*q = (*p * 255) + 0.5;
+ 			if ( i % 3 == 2 )
+ 			   {
+ 				if ( *q == q[-1] && *q == q[-2] )
+ 				   {	if ( *q == 0 ) black = i - 2;
+ 					else if ( *q == 255 ) white = i - 2;
+ 				   }
+ 				else
+ 					has_color = 1;
+ 			   }
+ 		   }
+ 		if ( white < 0 || black < 0 )
+ 			return_error(gs_error_rangecheck);
+ 	   }
+ 	else
+ 		has_color = 1;
+ 	new_dev = (gx_device_memory *)(*palloc)(1, old_dev->params_size, "gs_makeimagedevice(device)");
+ 	if ( new_dev == 0 ) return_error(gs_error_VMerror);
+ 	*new_dev = *old_dev;
+ 	new_dev->initial_matrix = *pmat;
+ 	new_dev->width = width;
+ 	new_dev->height = height;
+ 	new_dev->has_color = has_color;
+ 	new_dev->bits_per_color_pixel = bits_per_pixel;
+ 	bitmap_size = gx_device_memory_bitmap_size(new_dev);
+ 	if ( bitmap_size > max_uint )	/* can't allocate it! */
+ 		return_error(gs_error_limitcheck);
+ 	bits = (byte *)(*palloc)(1, (uint)bitmap_size + pcount,
+ 				 "gs_makeimagedevice(bits)");
+ 	if ( bits == 0 ) return_error(gs_error_VMerror);
+ 	new_dev->base = bits;
+ 	new_dev->invert = (black == 0 ? 0 : -1);
+ 	new_dev->palette_size = palette_size;
+ 	new_dev->palette = bits + bitmap_size;
+ 	memcpy(new_dev->palette, palette, pcount);
+ 	new_dev->is_open = 0;
+ 	*pnew_dev = (gx_device *)new_dev;
+ 	return 0;
+ }
+ 
+ /* Set the device in the graphics state */
+ int
+ gs_setdevice(gs_state *pgs, gx_device *dev)
+ {	register device *pdev = pgs->device;
+ 	int was_open = dev->is_open;
+ 	int code;
+ 	/* Initialize the device */
+ 	if ( !was_open )
+ 	   {	code = (*dev->procs->open_device)(dev);
+ 		if ( code < 0 ) return code;
+ 		dev->is_open = 1;
+ 	   }
+ 	/* Compute device white and black codes */
+ 	pdev->black = (*dev->procs->map_rgb_color)(dev, 0, 0, 0);
+ 	pdev->white = (*dev->procs->map_rgb_color)(dev, dev->max_rgb_value, dev->max_rgb_value, dev->max_rgb_value);
+ 	pdev->info = dev;
+ 	if (	(code = gs_initmatrix(pgs)) < 0 ||
+ 		(code = gs_initclip(pgs)) < 0
+ 	   )
+ 		return code;
+ 	if ( !was_open )
+ 		if ( (code = gs_erasepage(pgs)) < 0 )
+ 			return code;
+ 	return 0;
+ }
+ 
+ /* Select the null device.  This is just a convenience. */
+ void
+ gs_nulldevice(gs_state *pgs)
+ {	gs_setdevice(pgs, gx_device_null_p);
+ }
+ 
+ /* Install enough of a null device to suppress graphics output */
+ /* during the execution of stringwidth. */
+ void
+ gx_device_no_output(gs_state *pgs)
+ {	pgs->device->info = &null_device;
+ }
+ 
+ /* Dummy device procedures */
+ private int
+ null_fill_rectangle(gx_device *dev, int x, int y, int w, int h,
+   gx_color_index color)
+ {	return 0;
+ }
+ private int
+ null_tile_rectangle(gx_device *dev, gx_bitmap *tile,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	return 0;
+ }
+ private int
+ null_copy_mono(gx_device *dev, byte *data,
+   int dx, int raster, int x, int y, int w, int h,
+   gx_color_index zero, gx_color_index one)
+ {	return 0;
+ }
+ private int
+ null_copy_color(gx_device *dev, byte *data,
+   int dx, int raster, int x, int y, int w, int h)
+ {	return 0;
+ }
+ private int
+ null_draw_line(gx_device *dev, int x0, int y0, int x1, int y1,
+   gx_color_index color)
+ {	return 0;
+ }
+ private int
+ null_fill_trapezoid(gx_device *dev,
+   int x0, int y0, int w0, int x1, int y1, int w1, gx_color_index color)
+ {	return 0;
+ }
+ private int
+ null_tile_trapezoid(gx_device *dev, gx_bitmap *tile,
+   int x0, int y0, int w0, int x1, int y1, int w1,
+   gx_color_index color0, gx_color_index color1)
+ {	return 0;
+ }
+ 
+ /* Default device open, matrix, sync, output, close, and map procedures. */
+ int
+ gx_default_open_device(gx_device *dev)
+ {	return 0;
+ }
+ void
+ gx_default_get_initial_matrix(register gx_device *dev, register gs_matrix *pmat)
+ {	pmat->xx = dev->x_pixels_per_inch / 72.0;
+ 	pmat->xy = 0;
+ 	pmat->yx = 0;
+ 	pmat->yy = dev->y_pixels_per_inch / -72.0;
+ 	pmat->tx = 0;
+ 	pmat->ty = dev->height;
+ }
+ int
+ gx_default_sync_output(gx_device *dev)
+ {	return 0;
+ }
+ int
+ gx_default_output_page(gx_device *dev)
+ {	return (*dev->procs->sync_output)(dev);
+ }
+ int
+ gx_default_close_device(gx_device *dev)
+ {	return 0;
+ }
+ gx_color_index
+ gx_default_map_rgb_color(gx_device *dev, ushort r, ushort g, ushort b)
+ {	return (gx_color_index)max(max(r, g), b);
+ }
+ int
+ gx_default_map_color_rgb(gx_device *dev, gx_color_index color, ushort *prgb)
+ {	prgb[0] = prgb[1] = prgb[2] = (ushort)color;
+ 	return 0;
+ }
+ 
+ #ifdef DEBUG
+ 
+ /* ------ Tracing 'device' ------*/
+ 
+ /* To avoid unpleasant interactions with makedevice, */
+ /* the tracing 'device' uses an external linked list to keep track of */
+ /* the real procedures that were replaced in the procedure vector. */
+ 
+ typedef struct trace_record_s trace_record;
+ struct trace_record_s {
+ 	trace_record *next;
+ 	gx_device_procs *tprocs;
+ 	gx_device_procs procs;
+ };
+ 
+ private gx_device *trace_cache_device = NULL;
+ private gx_device_procs *trace_cache_procs;
+ private trace_record *trace_list = NULL;
+ 
+ #define rprocs\
+ 	(dev == trace_cache_device ? trace_cache_procs :\
+ 	 trace_find_procs(dev))
+ 
+ /* Procedure structure */
+ private dev_proc_open_device(trace_open_device);
+ private dev_proc_get_initial_matrix(trace_get_initial_matrix);
+ private dev_proc_sync_output(trace_sync_output);
+ private dev_proc_output_page(trace_output_page);
+ private dev_proc_close_device(trace_close_device);
+ private dev_proc_map_rgb_color(trace_map_rgb_color);
+ private dev_proc_map_color_rgb(trace_map_color_rgb);
+ private dev_proc_fill_rectangle(trace_fill_rectangle);
+ private dev_proc_tile_rectangle(trace_tile_rectangle);
+ private dev_proc_copy_mono(trace_copy_mono);
+ private dev_proc_copy_color(trace_copy_color);
+ private dev_proc_draw_line(trace_draw_line);
+ private dev_proc_fill_trapezoid(trace_fill_trapezoid);
+ private dev_proc_tile_trapezoid(trace_tile_trapezoid);
+ 
+ private gx_device_procs trace_procs = {
+ 	trace_open_device,
+ 	trace_get_initial_matrix,
+ 	trace_sync_output,
+ 	trace_output_page,
+ 	trace_close_device,
+ 	trace_map_rgb_color,
+ 	trace_map_color_rgb,
+ 	trace_fill_rectangle,
+ 	trace_tile_rectangle,
+ 	trace_copy_mono,
+ 	trace_copy_color,
+ 	trace_draw_line,
+ 	trace_fill_trapezoid,
+ 	trace_tile_trapezoid
+ };
+ 
+ /* Find the real procedures for a traced device */
+ private gx_device_procs *
+ trace_find_procs(gx_device *tdev)
+ {	gx_device_procs *tprocs = tdev->procs;
+ 	register trace_record *tp = trace_list;
+ 	while ( tp != NULL )
+ 	   {	if ( tp->tprocs == tprocs )
+ 		   {	trace_cache_device = tdev;
+ 			return (trace_cache_procs = &tp->procs);
+ 		   }
+ 		tp = tp->next;
+ 	   }
+ 	dprintf("Traced procedures not found!\n");
+ 	exit(1);
+ }
+ 
+ /* Trace a device. */
+ gx_device *
+ gs_trace_device(gx_device *rdev)
+ {	trace_record *tp;
+ 	if ( rdev->procs->open_device == trace_procs.open_device )
+ 		return rdev;		/* already traced */
+ 	tp = (trace_record *)gs_malloc(1, sizeof(trace_record), 
+ 				       "gs_trace_device");
+ 	if ( tp == 0 ) return 0;
+ 	tp->next = trace_list;
+ 	tp->tprocs = rdev->procs;
+ 	tp->procs = *rdev->procs;
+ 	trace_list = tp;
+ 	*rdev->procs = trace_procs;
+ 	return rdev;
+ }
+ 
+ /* Utilities */
+ private int
+ trace_print_code(int result)
+ {	if ( result == 0 )
+ 		printf(";\n");
+ 	else
+ 		printf(";	/* = %d */\n", result);
+ 	return result;
+ }
+ private void
+ trace_print_tile(gx_bitmap *tile)
+ {	int i;
+ 	printf("\t{ static byte data = { 0x%x", tile->data[0]);
+ 	for ( i = 1; i < tile->raster * tile->height; i++ )
+ 		printf(", 0x%x", tile->data[i]);
+ 	printf(" };\n\t  static gx_bitmap tile = { &data, %d, %d, %d };\n",
+ 		tile->raster, tile->width, tile->height);
+ }
+ 
+ /* Procedures */
+ private int
+ trace_open_device(gx_device *dev)
+ {	int result = (*rprocs->open_device)(dev);
+ if ( gs_debug['v'] )
+ 	printf("[v]\topen_device(dev)"),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private void
+ trace_get_initial_matrix(gx_device *dev, gs_matrix *pmat)
+ {	(*rprocs->get_initial_matrix)(dev, pmat);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tget_initial_matrix(dev) = (%6g, %6g, %6g, %6g, %6g, %6g);\n",
+ 		pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
+ }
+ private int
+ trace_sync_output(gx_device *dev)
+ {	int result = (*rprocs->sync_output)(dev);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tsync_output(dev)"),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_output_page(gx_device *dev)
+ {	int result = (*rprocs->output_page)(dev);
+ if ( gs_debug['v'] )
+ 	printf("[v]\toutput_page(dev)"),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_close_device(gx_device *dev)
+ {	int result = (*rprocs->close_device)(dev);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tclose_device(dev)"),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private gx_color_index
+ trace_map_rgb_color(gx_device *dev, ushort r, ushort g, ushort b)
+ {	gx_color_index result = (*rprocs->map_rgb_color)(dev, r, g, b);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tmap_rgb_color(dev, %u, %u, %u) /*= %ld */;\n", r, g, b, (long)result);
+ 	return result;
+ }
+ private int
+ trace_map_color_rgb(gx_device *dev, gx_color_index color, ushort *prgb)
+ {	int result = (*rprocs->map_color_rgb)(dev, color, prgb);
+ if ( gs_debug['v'] )
+ 	printf("\t{ ushort rgb[3]; T(map_color_rgb)(dev, %ld, rgb /* %u, %u, %u */); }",
+ 		(long)color, prgb[0], prgb[1], prgb[2]),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_fill_rectangle(gx_device *dev, int x, int y, int w, int h,
+   gx_color_index color)
+ {	int result = (*rprocs->fill_rectangle)(dev, x, y, w, h, color);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tfill_rectangle(dev, %d, %d, %d, %d, %ld)", x, y, w, h, (long)color),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_tile_rectangle(gx_device *dev, gx_bitmap *tile,
+   int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
+ {	int result = (*rprocs->tile_rectangle)(dev, tile,
+ 		x, y, w, h, zero, one);
+ if ( gs_debug['v'] )
+    {	trace_print_tile(tile);
+ 	printf("\t  T(tile_rectangle)(dev, &tile, %d, %d, %d, %d, %ld, %ld);\n\t}",
+ 		x, y, w, h, (long)zero, (long)one);
+ 	trace_print_code(result);
+    }
+ 	return result;
+ }
+ private int
+ trace_copy_mono(gx_device *dev, byte *data,
+   int dx, int raster, int x, int y, int w, int h,
+   gx_color_index zero, gx_color_index one)
+ {	int result = (*rprocs->copy_mono)(dev, data,
+ 		dx, raster, x, y, w, h, zero, one);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tcopy_mono(dev, data, %d, %d, %d, %d, %d, %d, %ld, %ld)",
+ 		dx, raster, x, y, w, h, (long)zero, (long)one),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_copy_color(gx_device *dev, byte *data,
+   int dx, int raster, int x, int y, int w, int h)
+ {	int result = (*rprocs->copy_color)(dev, data,
+ 		dx, raster, x, y, w, h);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tcopy_color(dev, data, %d, %d, %d, %d, %d, %d)",
+ 		dx, raster, x, y, w, h),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_draw_line(gx_device *dev, int x0, int y0, int x1, int y1,
+   gx_color_index color)
+ {	int result = (*rprocs->draw_line)(dev, x0, y0, x1, y1, color);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tdraw_line(dev, %d, %d, %d, %d, %ld)",
+ 		x0, y0, x1, y1, (long)color),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_fill_trapezoid(gx_device *dev,
+   int x0, int y0, int w0, int x1, int y1, int w1, gx_color_index color)
+ {	int result = (*rprocs->fill_trapezoid)(dev,
+ 		x0, y0, w0, x1, y1, w1, color);
+ if ( gs_debug['v'] )
+ 	printf("[v]\tfill_trapezoid(dev, %d, %d, %d, %d, %d, %d, %ld)",
+ 		x0, y0, w0, x1, y1, w1, (long)color),
+ 	  trace_print_code(result);
+ 	return result;
+ }
+ private int
+ trace_tile_trapezoid(gx_device *dev, gx_bitmap *tile,
+   int x0, int y0, int w0, int x1, int y1, int w1,
+   gx_color_index color0, gx_color_index color1)
+ {	int result = (*rprocs->tile_trapezoid)(dev, tile,
+ 		x0, y0, w0, x1, y1, w1, color0, color1);
+ if ( gs_debug['v'] )
+    {	trace_print_tile(tile);
+ 	printf("[v]\ttile_trapezoid(dev, %d, %d, %d, %d, %d, %d, %ld, %ld)",
+ 		x0, y0, w0, x1, y1, w1, (long)color0, (long)color1);
+ 	trace_print_code(result);
+    }
+ 	return result;
+ }
+ 
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gserrors.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gserrors.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gserrors.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,35 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gserrors.h */
+ /* Error codes for GhostScript library */
+ 
+ /* A procedure that may return an error always returns */
+ /* a non-negative value (zero, unless otherwise noted) for success, */
+ /* or negative for failure. */
+ /* We use ints rather than an enum to avoid a lot of casting. */
+ 
+ #define gs_error_invalidfont (-10)
+ #define gs_error_ioerror (-12)
+ #define gs_error_limitcheck (-13)
+ #define gs_error_nocurrentpoint (-14)
+ #define gs_error_rangecheck (-15)
+ #define gs_error_undefined (-21)
+ #define gs_error_undefinedresult (-23)
+ #define gs_error_VMerror (-25)


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfile.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfile.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfile.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,135 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsfile.c */
+ /* Bitmap file writing routines for GhostScript library */
+ #include "memory_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gsmatrix.h"			/* for gxdevice.h */
+ #include "gxdevice.h"
+ #include "gxdevmem.h"
+ 
+ /* Dump the contents of a memory device in PPM format. */
+ int
+ gs_writeppmfile(gx_device_memory *md, FILE *file)
+ {	int raster = mem_bytes_per_scan_line(md);
+ 	int height = md->height;
+ 	int depth = md->bits_per_color_pixel;
+ 	uint rsize = raster * 3;	/* * 3 just for mapped color */
+ 	byte *row = (byte *)gs_malloc(rsize, 1, "ppm file buffer");
+ 	char *header;
+ 	int y;
+ 	int code = 0;			/* return code */
+ 	if ( row == 0 )			/* can't allocate row buffer */
+ 		return_error(gs_error_VMerror);
+ 
+ 	/* A PPM file consists of: magic number, comment, */
+ 	/* width, height, maxvalue, (r,g,b).... */
+ 
+ 	/* Dispatch on the type of the device -- 1-bit mono, */
+ 	/* 8-bit (gray scale or color), 24- or 32-bit true color. */
+ 
+ 	switch ( depth )
+ 	   {
+ 	case 1:
+ 	  header = "P4\n# Ghostscript 1 bit mono image dump\n%d %d\n";
+ 	  break;
+ 
+ 	case 8:
+ 	  header = (md->has_color ?
+ 	    "P6\n# Ghostscript 8 bit mapped color image dump\n%d %d\n255\n" :
+ 	    "P5\n# Ghostscript 8 bit gray scale image dump\n%d %d\n255\n");
+ 	  break;
+ 
+ 	case 24:
+ 	  header = "P6\n# Ghostscript 24 bit color image dump\n%d %d\n255\n";
+ 	  break;
+ 
+ 	case 32:
+ 	  header = "P6\n# Ghostscript 32 bit color image dump\n%d %d\n255\n";
+ 	  break;
+ 
+ 	default:			/* shouldn't happen! */
+ 	  code = gs_error_undefinedresult;
+ 	  goto done;
+ 	   }
+ 
+ 	/* Write the header. */
+ 	fprintf(file, header, md->width, height);
+ 
+ 	/* Dump the contents of the image. */
+ 	for ( y = 0; y < height; y++ )
+ 	   {	int count;
+ 		register byte *from, *to, *end;
+ 		mem_copy_scan_lines(md, y, row, raster);
+ 		switch ( depth )
+ 		   {
+ 		case 8:
+ 		   {	/* Mapped color, consult the map. */
+ 			if ( md->has_color )
+ 			   {	/* Map color */
+ 				byte *palette = md->palette;
+ 				from = row + raster + raster;
+ 				memcpy(from, row, raster);
+ 				to = row;
+ 				end = from + raster;
+ 				while ( from < end )
+ 				   {	register byte *cp = palette + (int)*from++ * 3;
+ 					*to++ = *cp++;	/* red */
+ 					*to++ = *cp++;	/* green */
+ 					*to++ = *cp++;	/* blue */
+ 				   }
+ 				count = raster * 3;
+ 			   }
+ 			else
+ 			   {	/* Map gray scale */
+ 				register byte *palette = md->palette;
+ 				from = to = row, end = row + raster;
+ 				while ( from < end )
+ 					*to++ = palette[(int)*from++ * 3];
+ 				count = raster;
+ 			   }
+ 		   }
+ 			break;
+ 		case 32:
+ 		   {	/* This case is different, because we must skip */
+ 			/* every fourth byte. */
+ 			from = to = row, end = row + raster;
+ 			while ( from < end )
+ 			   {	from++;		/* skip unused byte */
+ 				*to++ = *from++;	/* red */
+ 				*to++ = *from++;	/* green */
+ 				*to++ = *from++;	/* blue */
+ 			   }
+ 			count = to - row;
+ 		   }
+ 			break;
+ 		default:
+ 			count = raster;
+ 		   }
+ 		if ( fwrite(row, 1, count, file) < count )
+ 		   {	code = gs_error_ioerror;
+ 			goto done;
+ 		   }
+ 	   }
+ 
+ done:	gs_free((char *)row, rsize, 1, "ppm file buffer");
+ 	return code;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfont.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfont.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfont.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,226 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsfont.c */
+ /* Font operators for GhostScript library */
+ #include "gx.h"
+ #include "memory_.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"			/* must precede gxdevice */
+ #include "gxdevice.h"			/* must precede gxfont */
+ #include "gschar.h"
+ #include "gxfont.h"
+ #include "gxfdir.h"
+ 
+ /* Size of cache structures */
+ extern int cached_char_sizeof;
+ extern int cached_fm_pair_sizeof;
+ 
+ /* Allocate a font directory */
+ gs_font_dir *
+ gs_font_dir_alloc(proc_alloc_t palloc, proc_free_t pfree)
+ {	return gs_font_dir_alloc_limits(palloc, pfree,
+ 		10,			/* smax - # of scaled fonts */
+ 		20000,			/* bmax - space for cached chars */
+ 		20,			/* mmax - # of cached font/matrix pairs */
+ 		500,			/* cmax - # of cached chars */
+ 		100);			/* blimit/upper - max size of a single cached char */
+ }
+ gs_font_dir *
+ gs_font_dir_alloc_limits(proc_alloc_t palloc, proc_free_t pfree,
+   uint smax, uint bmax, uint mmax, uint cmax, uint upper)
+ {	register gs_font_dir *pdir = (gs_font_dir *)(*palloc)(1, sizeof(gs_font_dir), "font_dir_alloc(dir)");
+ 	byte *bdata;
+ 	struct cached_fm_pair_s *mdata;
+ 	struct cached_char_s *cdata;
+ 	if ( pdir == 0 ) return 0;
+ 	bdata = (byte *)(*palloc)(bmax, 1, "font_dir_alloc(bdata)");
+ 	mdata = (struct cached_fm_pair_s *)(*palloc)(mmax, cached_fm_pair_sizeof, "font_dir_alloc(mdata)");
+ 	cdata = (struct cached_char_s *)(*palloc)(cmax, cached_char_sizeof, "font_dir_alloc(cdata)");
+ 	if ( bdata == 0 || mdata == 0 || cdata == 0 )
+ 	   {	if ( cdata != 0 ) (*pfree)((char *)cdata, cmax, cached_char_sizeof, "font_dir_alloc(cdata)");
+ 		if ( mdata != 0 ) (*pfree)((char *)mdata, mmax, cached_fm_pair_sizeof, "font_dir_alloc(mdata)");
+ 		if ( bdata != 0 ) (*pfree)((char *)bdata, bmax, 1, "font_dir_alloc(bdata)");
+ 		(*pfree)((char *)pdir, 1, sizeof(gs_font_dir), "font_dir_alloc(dir)");
+ 		return 0;
+ 	   }
+ 	memset((char *)pdir, 0, sizeof(gs_font_dir));	/* easiest to clear everything first */
+ 	pdir->alloc = palloc;
+ 	pdir->free = pfree;
+ 	pdir->smax = smax;
+ 	pdir->bmax = bmax;
+ 	pdir->mmax = mmax;
+ 	pdir->cmax = cmax;
+ 	pdir->lower = upper / 10;
+ 	pdir->upper = upper;
+ 	pdir->bdata = bdata;
+ 	pdir->mdata = mdata;
+ 	pdir->cdata = cdata;
+ 	return pdir;
+ }
+ 
+ /* Macro for linking an element at the head of a chain */
+ #define link_first(first, elt)\
+   if ( (elt->next = first) != NULL ) first->prev = elt;\
+   elt->prev = 0;\
+   first = elt
+ 
+ /* scalefont */
+ int
+ gs_scalefont(gs_font_dir *pdir, gs_font *pfont, floatp scale,
+   gs_font **ppfont, gs_font **pdfont)
+ {	gs_matrix mat;
+ 	gs_make_scaling(scale, scale, &mat);
+ 	return gs_makefont(pdir, pfont, &mat, ppfont, pdfont);
+ }
+ 
+ /* makefont */
+ int
+ gs_makefont(gs_font_dir *pdir, gs_font *pfont, gs_matrix *pmat,
+   gs_font **ppfont, gs_font **pdfont)
+ {	int code;
+ 	gs_font *prev = 0, *pf_out = pdir->scaled_fonts;
+ 	gs_matrix newmat;
+ 	*pdfont = 0;
+ 	gs_make_identity(&newmat);	/* fill in tags */
+ 	if ( (code = gs_matrix_multiply(&pfont->matrix, pmat, &newmat)) < 0 )
+ 	  return code;
+ 	/* Check for the font already being in the scaled font cache. */
+ 	/* Only attempt to share fonts if the current font has */
+ 	/* a real unique_id (i.e., not -1). */
+ #ifdef DEBUG
+ if ( gs_debug['m'] )
+    {	printf("[m]unique_id=%ld, font_type=%d,\n",
+ 	  pfont->unique_id, pfont->font_type);
+ 	printf("[m]  ctm=[%g %g %g %g %g %g]\n",
+ 	  pmat->xx, pmat->xy, pmat->yx, pmat->yy,
+ 	  pmat->tx, pmat->ty);
+    }
+ #endif
+ 	if ( pfont->unique_id != -1 )
+ 	  for ( ; pf_out != 0; prev = pf_out, pf_out = pf_out->next )
+ 		if (	pf_out->unique_id == pfont->unique_id &&
+ 			pf_out->font_type == pfont->font_type &&
+ 			pf_out->matrix.xx == newmat.xx &&
+ 			pf_out->matrix.xy == newmat.xy &&
+ 			pf_out->matrix.yx == newmat.yx &&
+ 			pf_out->matrix.yy == newmat.yy
+ 		   )
+ 		   {	*ppfont = pf_out;
+ #ifdef DEBUG
+ if ( gs_debug['m'] )
+ 			printf("[m]found font=%lx\n", (ulong)pf_out);
+ #endif
+ 			return 0;
+ 		   }
+ 	pf_out = (gs_font *)(*pdir->alloc)(1, sizeof(gs_font), "gs_makefont");
+ 	if ( !pf_out ) return_error(gs_error_VMerror);
+ 	*pf_out = *pfont;
+ 	pf_out->matrix = newmat;
+ 	if ( pdir->ssize == pdir->smax )
+ 	  { /* Must discard a cached scaled font. */
+ 	    /* Scan for the oldest font if we didn't already. */
+ 	    if ( !prev )
+ 	      for ( prev = pdir->scaled_fonts;
+ 		    prev->next != 0;
+ 		    prev = prev->next
+ 		  ) ;
+ #ifdef DEBUG
+ if ( gs_debug['m'] )
+ 		printf("[m]discarding font %lx\n", (ulong)prev);
+ #endif
+ 	    *pdfont = prev;
+ 	    prev->prev->next = 0;
+ 	  }
+ 	else
+ 	  pdir->ssize++;
+ 	link_first(pdir->scaled_fonts, pf_out);
+ 	pf_out->base = pfont->base;
+ 	pf_out->dir = pdir;
+ 	*ppfont = pf_out;
+ #ifdef DEBUG
+ if ( gs_debug['m'] )
+ 	printf("[m]new font=%lx\n", (ulong)pf_out);
+ #endif
+ 	return 1;
+ }
+ 
+ /* setfont */
+ int
+ gs_setfont(gs_state *pgs, gs_font *pfont)
+ {	pgs->font = pfont;
+ 	pgs->char_tm_valid = 0;
+ 	return 0;
+ }
+ 
+ /* currentfont */
+ gs_font *
+ gs_currentfont(gs_state *pgs)
+ {	return pgs->font;
+ }
+ 
+ /* cachestatus */
+ void
+ gs_cachestatus(register gs_font_dir *pdir, register uint pstat[7])
+ {	pstat[0] = pdir->bsize;
+ 	pstat[1] = pdir->bmax;
+ 	pstat[2] = pdir->msize;
+ 	pstat[3] = pdir->mmax;
+ 	pstat[4] = pdir->csize;
+ 	pstat[5] = pdir->cmax;
+ 	pstat[6] = pdir->upper;
+ }
+ 
+ /* setcachelimit */
+ int
+ gs_setcachelimit(gs_font_dir *pdir, uint size)
+ {	pdir->upper = size;
+ 	return 0;
+ }
+ 
+ /* setcacheparams */
+ int
+ gs_setcachelower(gs_font_dir *pdir, uint size)
+ {	pdir->lower = size;
+ 	return 0;
+ }
+ int
+ gs_setcacheupper(gs_font_dir *pdir, uint size)
+ {	pdir->upper = size;
+ 	return 0;
+ }
+ 
+ /* currentcacheparams */
+ uint
+ gs_currentcachelower(gs_font_dir *pdir)
+ {	return pdir->lower;
+ }
+ uint
+ gs_currentcacheupper(gs_font_dir *pdir)
+ {	return pdir->upper;
+ }
+ 
+ /* Dummy (ineffective) BuildChar procedure */
+ int
+ gs_no_build_char_proc(struct gs_show_enum_s *penum, gs_state *pgs,
+   gs_font *pfont, int chr, char *data)
+ {	return 1;			/* failure, but not error */
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfont.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfont.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsfont.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,57 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsfont.h */
+ /* Font operations for GhostScript library */
+ /* Requires gsmatrix.h */
+ 
+ /* A 'font directory' object (to avoid making fonts global). */
+ /* 'directory' is something of a misnomer: this structure */
+ /* actually just keeps track of the scaled font and */
+ /* rendered character caches. */
+ typedef struct gs_font_dir_s gs_font_dir;
+ 
+ /* Font objects */
+ typedef struct gs_font_s gs_font;
+ 
+ /* Initialization */
+ /* These procedures return 0 if they fail. */
+ gs_font_dir	*gs_font_dir_alloc(P2(proc_alloc_t, proc_free_t));
+ gs_font_dir	*gs_font_dir_alloc_limits(P7(proc_alloc_t, proc_free_t,
+ 			uint /*smax*/, uint /*bmax*/, uint /*mmax*/,
+ 			uint /*cmax*/, uint /*upper*/));
+ 
+ /* Font manipulations */
+ /* gs_scalefont and gs_makefont return 0 if the scaled font */
+ /* was already in the cache, 1 if a new font was created. */
+ /* The second gs_font ** argument returns a font discarded */
+ /* from the cache (or 0) in the latter case.  This is for */
+ /* the benefit of reference-counted clients. */
+ int	gs_scalefont(P5(gs_font_dir *, gs_font *, floatp, gs_font **, gs_font **));
+ int	gs_makefont(P5(gs_font_dir *, gs_font *, gs_matrix *, gs_font **, gs_font **));
+ int	gs_setfont(P2(gs_state *, gs_font *));
+ gs_font *	gs_currentfont(P1(gs_state *));
+ 
+ /* Font cache parameter operations */
+ void	gs_cachestatus(P2(gs_font_dir *, uint [7]));
+ int	gs_setcachelimit(P2(gs_font_dir *, uint));
+ uint	gs_currentcachelower(P1(gs_font_dir *));
+ int	gs_setcachelower(P2(gs_font_dir *, uint));
+ uint	gs_currentcacheupper(P1(gs_font_dir *));
+ int	gs_setcacheupper(P2(gs_font_dir *, uint));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsim2out.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsim2out.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsim2out.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,400 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsim2out.c */
+ /* Image to outline conversion for GhostScript library */
+ #include "gx.h"
+ #include "memory_.h"
+ #include "gserrors.h"
+ #include "gsmatrix.h"
+ #include "gsstate.h"
+ #include "gscoord.h"
+ #include "gxfixed.h"
+ #include "gxtype1.h"
+ 
+ /*
+  * Convert a bitmap image to an outline (path) representation.
+  * The outline representation is in Adobe Type 1 CharString format.
+  * See ghost.doc for more details.
+  */
+ 
+ /* Define the state of the conversion process. */
+ typedef struct {
+ 	/* The following are set at the beginning of the conversion. */
+ 	gs_matrix ifm;			/* inverse of (CTM */
+ 					/* scaled by width/height * 4). */
+ 	byte *limit;			/* stop output here */
+ 	int ox, oy;			/* X/Y pixel offset of char origin */
+ 	/* The following are updated dynamically. */
+ 	byte *next;			/* next byte goes here */
+ 	int px, py;			/* X/Y position at start of run */
+ 	int cpx, cpy;			/* px/py in character coordinates */
+ 	int dx, dy;			/* X/Y increment of current run */
+ 	int count;			/* # of steps in current run */
+ } status;
+ 
+ /* Define the scaling for the path tracer. */
+ #define outline_scale 4
+ 
+ /* Forward declarations */
+ private int round_coord(P1(floatp));
+ private int put_int(P2(status *, int));
+ private void fill_cells(P4(byte *, byte *, int, int));
+ private int trace_cells(P4(byte *, int, int, status *));
+ 
+ /*
+  * gs_type1imagepath encodes an image into a byte string supplied
+  * by the caller.  If the string is not big enough, the procedure
+  * returns gs_error_limitcheck.  Otherwise, the procedure returns
+  * the actual number of bytes of data stored.
+  */
+ int
+ gs_type1imagepath(gs_state *pgs, byte *data, int width, int height,
+   floatp wx, floatp wy, floatp origin_x, floatp origin_y,
+   byte *str, uint maxlen)
+ {	uint csize;
+ 	byte *cells;
+ 	status stat;
+ 	status *out = &stat;
+ 	int lsbx;
+ 	int iwx, iwy, ilsbx, ilsby;
+ 	int code;
+ 	/* Construct the coordinate transformation. */
+ 	   {	float hsc = height * outline_scale;
+ 		gs_matrix mat;
+ 		gs_currentmatrix(pgs, &stat.ifm);
+ #ifdef DEBUG
+ if ( gs_debug['0'] )
+ 		printf("[0]ctm=[%g %g %g %g %g %g]\n",
+ 			stat.ifm.xx, stat.ifm.xy, stat.ifm.yx, stat.ifm.yy,
+ 			stat.ifm.tx, stat.ifm.ty);
+ #endif
+ 		if (	(code = gs_make_scaling(hsc, hsc, &mat)) < 0 ||
+ 			(code = gs_matrix_multiply(&mat, &stat.ifm, &stat.ifm)) < 0 ||
+ 			(code = gs_matrix_invert(&stat.ifm, &stat.ifm)) < 0
+ 		   )
+ 			return code;
+ 	   }
+ 	/* Allocate and fill in the cell matrix. */
+ 	csize = (width + 2) * (height + 2);
+ 	cells = (byte *)gs_malloc(csize, 1, "gsim2out cells");
+ 	if ( cells == 0 ) return_error(gs_error_VMerror);
+ 	fill_cells(cells, data, width, height);
+ 	/* Initialize the rest of the state. */
+ 	stat.next = str;
+ 	stat.limit = str + maxlen;
+ 	/* Determine the left side bearing by looking for */
+ 	/* the leftmost column with any 1-bits. */
+ 	for ( lsbx = 0; lsbx < width; lsbx++ )
+ 	   {	int y;
+ 		for ( y = 1; y <= height; y++ )
+ 		  if ( cells[y * (width + 2) + lsbx + 1] ) goto xit;
+ 	   }
+ xit:	/* Encode the origin, width, and side bearing. */
+ 	   {	gs_point opt, wpt, lsbpt;
+ 		if (	(code = gs_distance_transform(origin_x * outline_scale,
+ 						      origin_y * outline_scale,
+ 						      &stat.ifm, &opt)) < 0 ||
+ 			(code = gs_distance_transform(wx * outline_scale,
+ 						      wy * outline_scale,
+ 						      &stat.ifm, &wpt)) < 0 ||
+ 			(code = gs_distance_transform((lsbx - origin_x) *
+ 						       outline_scale, (floatp)0,
+ 						      &stat.ifm, &lsbpt)) < 0
+ 		   )
+ 			return code;
+ 		stat.ox = round_coord(opt.x);
+ 		stat.oy = round_coord(opt.y);
+ 		iwx = round_coord(wpt.x);
+ 		iwy = round_coord(wpt.y);
+ 		ilsbx = round_coord(lsbpt.x);
+ 		ilsby = round_coord(lsbpt.y);
+ #ifdef DEBUG
+ if ( gs_debug['0'] )
+ 	   {	int cy, cx;
+ 		byte *cp = data;
+ 		printf("[0]w=%d h=%d oxy=(%g,%g) wxy=(%g,%g)\n",
+ 			width, height, origin_x, origin_y, wx, wy);
+ 		printf("   io=(%d,%d) iw=(%d,%d) ilsb=(%d,%d)\n",
+ 			stat.ox, stat.oy, iwx, iwy, ilsbx, ilsby);
+ 		for ( cy = 0; cy < height; cy++ )
+ 		   {	printf("[0]%3d ", cy);
+ 			for ( cx = 0; cx < width; cx += 8 )
+ 				printf("%02x", (int)*cp++);
+ 			putchar('\n');
+ 		   }
+ 	   }
+ #endif
+ 		if ( (code = put_int(out, ilsbx)) < 0 ) return code;
+ 		if ( iwy != 0 || ilsby != 0 )
+ 		   {	if (	(code = put_int(out, ilsby)) < 0 ||
+ 				(code = put_int(out, iwx)) < 0 ||
+ 				(code = put_int(out, iwy)) < 0
+ 			   )
+ 				return code;
+ 			if ( stat.next + 2 > stat.limit )
+ 				return_error(gs_error_limitcheck);
+ 			*stat.next++ = (byte)c_escape;
+ 			*stat.next++ = (byte)ce_sbw;
+ 		   }
+ 		else
+ 		   {	if ( (code = put_int(out, iwx)) < 0 ) return code;
+ 			if ( stat.next + 1 > stat.limit )
+ 				return_error(gs_error_limitcheck);
+ 			*stat.next++ = (byte)c_hsbw;
+ 		   }
+ 	   }
+ 	/* Since all further movements are relative, we can account */
+ 	/* for the origin by simply setting px/py to the lsb, */
+ 	/* and cpx/cpy to the lsb plus the origin. */
+ 	stat.px = (lsbx * outline_scale);
+ 	stat.py = (int)(origin_y * outline_scale);
+ 	stat.cpx = ilsbx + stat.ox;
+ 	stat.cpy = ilsby + stat.oy;
+ 	/* Trace the outline of the cells. */
+ 	code = trace_cells(cells, width, height, out);
+ 	gs_free((char *)cells, csize, 1, "gsim2out cells");
+ 	if ( code < 0 ) return code;
+ 	if ( stat.next >= stat.limit ) return_error(gs_error_limitcheck);
+ 	*stat.next++ = (byte)c_endchar;
+ 	return stat.next - str;
+ }
+ 
+ /* Fill the cell matrix with the image being traced. */
+ /* The cell matrix has a row and column of zero padding on each side, */
+ /* so we don't have to check for boundary conditions all the time. */
+ /* Note that the image data are in PostScript / Ghostscript standard */
+ /* order (left to right, top row first), but the cells are stored */
+ /* bottom row first. */
+ private void
+ fill_cells(byte *cells, byte *data, int width, int height)
+ {	int y;
+ 	byte *dptr = data - 1;
+ 	byte *cptr = cells + (width + 2) * height + 1;
+ 	memset(cells, 0, (width + 2) * (height + 2));
+ 	for ( y = 0; y < height; y++ )
+ 	   {	register int mask = 0;
+ 		register int b;
+ 		register int x;
+ 		for ( x = 0; x < width; x++, mask >>= 1, cptr++ )
+ 		   {	if ( mask == 0 ) mask = 0x80, b = *++dptr;
+ 			if ( b & mask ) *cptr = 1;
+ 		   }
+ 		cptr -= width * 2 + 2;	/* back up 1 row */
+ 	   }
+ }
+ 
+ /* Trace the cells to form an outline.  The trace goes in clockwise */
+ /* order, always starting by going west along a bottom edge. */
+ /* All the subsidiary routines return 0 on success, */
+ /* -1 if the output buffer overflowed. */
+ private int trace_from(P3(status *, byte *, int));
+ private int add_dxdy(P4(status *, int, int, int));
+ #define add_deltas(s, dx, dy, n)\
+   if ( (code = add_dxdy(s, dx, dy, n)) < 0 ) return code
+ private int put_dxdy(P4(status *, int, int, int));
+ #define put_deltas(s, dx, dy, moving)\
+   if ( (code = put_dxdy(s, dx, dy, moving)) < 0 ) return code
+ private int
+ trace_cells(byte *cells, int width, int height, register status *out)
+ {	byte *cptr;
+ 	int code;
+ 	for ( cptr = cells + (width + 2) * (height + 1) - 2;
+ 	      cptr >= cells;  cptr--
+ 	    )
+ 	   {	if ( *cptr == 1 && cptr[-(width+2)] == 0 )
+ 		   {	/* Found a starting point */
+ 			int x = (cptr-cells) % (width+2) - 1;
+ 			int y = (cptr-cells) / (width+2) - 1;
+ 			put_deltas(out,
+ 				   x * outline_scale + 1 - out->px,
+ 				   y * outline_scale - out->py,
+ 				   1);
+ 			out->count = 0;
+ 			if ( (code = trace_from(out, cptr, width)) < 0 )
+ 				return code;
+ 			if ( out->next >= out->limit )
+ 				return_error(gs_error_limitcheck);
+ 			*out->next++ = (byte)c_closepath;
+ 		   }
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Trace a path */
+ private int
+ trace_from(register status *out, byte *cptr, int width)
+ {	typedef enum {			/* must be in this order */
+ 		north = 0, east = 1, south = 2, west = 3
+ 	} direction;
+ 	direction dir;
+ 	int w2 = width + 2;		/* actual width of cell rows */
+ 	int part;			/* how far along edge we are */
+ 	int code;
+ 	/* Movement tables */
+ 	typedef struct {
+ 		short tx, ty;		/* relative index of first cell */
+ 					/* to test (counter-clockwise move) */
+ 		short dx, dy;		/* continue in same direction */
+ 	   } dir_descr;
+ 	static dir_descr nesw[4+1] =
+ 	   {	/* Going north (along a western edge) */
+ 		   { -1, 1,   0, 1 },
+ 		/* Going east (along a northern edge) */
+ 			{ 1, 1,   1, 0 },
+ 		/* Going south (along an eastern edge) */
+ 		   { 1, -1,   0, -1 },
+ 		/* Going west (along a southern edge) */
+ 		   { -1, -1,   -1, 0 },
+ 		/* An extra copy of north */
+ 		   { -1, 1,   0, 1 }
+ 	   };
+ 	for ( dir = west, part = 1; ; )
+ 	   {	register dir_descr *pd = &nesw[(int)dir];
+ 		int dx = pd->dx, dy = pd->dy;
+ 		int delta;
+ 		if ( dir == west )
+ 		   {	/* This is the only case that has to check */
+ 			/* for the end of a subpath. */
+ 			if ( *cptr == 2 ) return 0;
+ 			*cptr = 2;
+ 		   }
+ 		delta = pd->ty * w2 + pd->tx;
+ 		if ( cptr[delta] )	/* go counter-clockwise */
+ 		   {	cptr += delta;
+ 			add_deltas(out, dx, dy, 1 - part);
+ 			add_deltas(out, pd->tx, pd->ty, outline_scale - 1);
+ 			dir = (direction)(((int)dir - 1) & 3);
+ 			part = outline_scale - 1;
+ 			continue;
+ 		   }
+ 		delta = dy * w2 + dx;
+ 		if ( !cptr[delta] )	/* go clockwise */
+ 		   {	add_deltas(out, dx, dy, outline_scale - 1 - part);
+ 			add_deltas(out, dx + pd[1].dx, dy + pd[1].dy, 1);
+ 			dir = (direction)(((int)dir + 1) & 3);
+ 			part = 1;
+ 			continue;
+ 		   }
+ 		cptr += delta;		/* go in same direction */
+ 		add_deltas(out, dx, dy, outline_scale);
+ 	   }
+ }
+ 
+ /* Add a (dx, dy) pair to the path being formed. */
+ /* Accumulate successive segments in the same direction. */
+ private int
+ add_dxdy(register status *out, int dx, int dy, int count)
+ {	int code;
+ 	if ( count != 0 )
+ 	   {	if ( dx == out->dx && dy == out->dy )
+ 			out->count += count;
+ 		else
+ 		   {	if ( out->count != 0 )
+ 				put_deltas(out, out->dx * out->count,
+ 					   out->dy * out->count, 0);
+ 			out->dx = dx, out->dy = dy;
+ 			out->count = count;
+ 		   }
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Encode a (dx, dy) pair onto the path. */
+ /* If there isn't enough space, return -1. */
+ private int
+ put_dxdy(register status *out, int dx, int dy, int moving)
+ {	int code;
+ 	/* We do the arithmetic in the 1/4-pixel coordinate system, */
+ 	/* and then transform the result, to avoid accumulating */
+ 	/* rounding errors. */
+ 	int npx = out->px + dx, npy = out->py + dy;
+ 	gs_point npt;
+ 	int ncpx, ncpy;
+ 	int cdx, cdy;
+ 	gs_distance_transform((floatp)npx, (floatp)npy, &out->ifm, &npt);
+ 	ncpx = round_coord(npt.x);
+ 	ncpy = round_coord(npt.y);
+ 	cdx = ncpx - out->cpx;
+ 	cdy = ncpy - out->cpy;
+ #ifdef DEBUG
+ if ( gs_debug['0'] )
+ 	printf("[0]  pxy=(%d,%d)+(%d,%d)  cpxy=(%d,%d)+(%d,%d)\n",
+ 		out->px, out->py, dx, dy, out->cpx, out->cpy, cdx, cdy);
+ #endif
+ 	if ( cdx != 0 || cdy == 0 )	/* encode dx if needed */
+ 	  if ( (code = put_int(out, cdx)) < 0 ) return code;
+ 	if ( cdy != 0 )			/* encode dy if needed */
+ 	  if ( (code = put_int(out, cdy)) < 0 ) return code;
+ 	if ( out->next == out->limit ) return_error(gs_error_limitcheck);
+ 	*out->next++ = (byte)
+ 		(cdy == 0 ?		/* use hmove/lineto */
+ 			(moving ? c_hmoveto : c_hlineto) :
+ 		cdx == 0 ?		/* use vmove/lineto */
+ 			(moving ? c_vmoveto : c_vlineto) :
+ 		(moving ? c_rmoveto : c_rlineto));
+ 	out->px = npx, out->py = npy;
+ 	out->cpx = ncpx, out->cpy = ncpy;
+ 	return 0;
+ }
+ 
+ /* Round a floating point coordinate.  If it is out of range, */
+ /* return a limiting value. */
+ private int
+ round_coord(floatp v)
+ {	long c = (long)(v + 0.5);
+ 	return( c > 0x7fff ? 0x7fff :
+ 		c < -0x7fff ? -0x7fff :
+ 		(int)c );
+ }
+ /* Encode a single number in Type 1 representation. */
+ private int
+ put_int(status *out, register int v)
+ {
+ #define min_enc_num1 ((c_min_num - c_max_num1) / 2)
+ #define max_enc_num1 ((c_max_num1 - c_min_num) / 2)
+ #define min_enc_num2 (max_enc_num1 + 1)
+ #define max_enc_num2 (min_enc_num2 + (c_max_num2 - c_max_num1) * 256 - 1)
+ #define min_enc_num3 (-max_enc_num2)
+ #define max_enc_num3 (-min_enc_num2)
+ 	register byte *ptr = out->next;
+ 	if ( ptr + 5 > out->limit )	/* conservative test is faster */
+ 		return_error(gs_error_limitcheck);
+ 	if ( v >= min_enc_num1 && v <= max_enc_num1 )
+ 		*ptr++ = v - min_enc_num1 + c_min_num;
+ 	else if ( v >= min_enc_num2 && v <= max_enc_num2 )
+ 	   {	v -= min_enc_num2;
+ 		*ptr++ = (v >> 8) + c_max_num1+1;
+ 		*ptr++ = v & 0xff;
+ 	   }
+ 	else if ( v >= min_enc_num3 && v <= max_enc_num3 )
+ 	   {	v = -(v - max_enc_num3);
+ 		*ptr++ = (v >> 8) + c_max_num2+1;
+ 		*ptr++ = v & 0xff;
+ 	   }
+ 	else
+ 	   {	*ptr++ = c_max_num3+1;
+ 		*ptr++ = ((long)v >> 24) & 0xff;
+ 		*ptr++ = ((long)v >> 16) & 0xff;
+ 		*ptr++ = (v >> 8) & 0xff;
+ 		*ptr++ = v & 0xff;
+ 	   }
+ 	out->next = ptr;
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsimage.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsimage.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsimage.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,736 ----
+ /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsimage.c */
+ /* Image procedures for GhostScript library */
+ #include "gx.h"
+ #include "arch.h"
+ #include "memory_.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxarith.h"
+ #include "gxmatrix.h"
+ #include "gspaint.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"			/* requires gsstate.h */
+ #include "gzcolor.h"			/* requires gxdevice.h */
+ #include "gzpath.h"
+ #include "gximage.h"
+ 
+ /* Exported size of enumerator */
+ int gs_image_enum_sizeof = sizeof(gs_image_enum);
+ 
+ /* Forward declarations */
+ private int image_init(P10(gs_image_enum *, int, int, int, int, int,
+   gs_matrix *, gs_state *, gx_color_index, gx_color_index));
+ /* Procedures for unpacking the input data into 8 bits/sample. */
+ private void image_unpack_0(iunpack_proc_args);
+ private void image_unpack_0_spread(iunpack_proc_args);
+ private void image_unpack_1(iunpack_proc_args);
+ private void image_unpack_1_spread(iunpack_proc_args);
+ private void image_unpack_2(iunpack_proc_args);
+ private void image_unpack_3(iunpack_proc_args);
+ private void image_unpack_3_spread(iunpack_proc_args);
+ /* The image_render procedures work on fully expanded, complete rows. */
+ /* These take a height argument, which is an integer > 0; */
+ /* they return a negative code, or the number of */
+ /* rows actually processed (which may be less than the height). */
+ private int image_render_skip(irender_proc_args);
+ private int image_render_direct(irender_proc_args);
+ private int image_render_mono(irender_proc_args);
+ private int image_render_color(irender_proc_args);
+ 
+ /* Start processing an image */
+ int
+ gs_image_init(gs_image_enum *penum, gs_state *pgs,
+   int width, int height, int bps, int spp, gs_matrix *pmat)
+ {	int log2_bps, spread;
+ 	if ( pgs->in_cachedevice ) return_error(gs_error_undefined);
+ 	switch ( bps )
+ 	   {
+ 	case 1: case 2: case 4:
+ 		log2_bps = bps >> 1;	/* works for 1, 2, 4 */
+ 		break;
+ 	case 8:
+ 		log2_bps = 3;
+ 		break;
+ 	default:
+ 		return_error(gs_error_rangecheck);
+ 	   }
+ 	switch ( spp )
+ 	   {
+ 	case 1: case 3: case 4:
+ 		spread = 1; break;
+ 	case -3: case -4:
+ 		spp = -spp; spread = spp; break;
+ 	default:
+ 		return_error(gs_error_rangecheck);
+ 	   }
+ 	return image_init(penum, width, height, log2_bps, spp, spread,
+ 			  pmat, pgs, pgs->device->black, pgs->device->white);
+ }
+ 
+ /* Start processing a masked image */
+ int
+ gs_imagemask_init(gs_image_enum *penum, gs_state *pgs,
+   int width, int height, int invert, gs_matrix *pmat)
+ {	gx_color_index color0, color1;
+ 	gx_color_render(pgs->color, pgs->dev_color, pgs);
+ 	/* The following is wrong for halftones, but */
+ 	/* it doesn't matter, because color0 and color1 */
+ 	/* won't be used if the color isn't pure. */
+ 	if ( invert )
+ 		color0 = gx_no_color_index,
+ 		color1 = pgs->dev_color->color1;
+ 	else
+ 		color0 = pgs->dev_color->color1,
+ 		color1 = gx_no_color_index;
+ 	return image_init(penum, width, height, 0, 1, 1,
+ 			  pmat, pgs, color0, color1);
+ }
+ 
+ /* Common setup for image and imagemask. */
+ /* Note that the mask tables depend on the end-orientation of the CPU. */
+ /* We can't simply define them as byte arrays, because */
+ /* they might not wind up properly long- or short-aligned. */
+ #define map4tox(a,b,c,d)\
+ 	0, a, b, a+b, c, a+c, b+c, a+b+c,\
+ 	d, a+d, b+d, a+b+d, c+d, a+c+d, b+c+d, a+b+c+d
+ #if big_endian
+ private unsigned long map_4_to_32[16] =
+    {	map4tox(0xffL, 0xff00L, 0xff0000L, 0xff000000L)	};
+ private unsigned short map_4_to_16[16] =
+    {	map4tox(0x55, 0xaa, 0x5500, 0xaa00)	};
+ #else					/* !big_endian */
+ private unsigned long map_4_to_32[16] =
+    {	map4tox(0xff000000L, 0xff0000L, 0xff00L, 0xffL)	};
+ private unsigned short map_4_to_16[16] =
+    {	map4tox(0x5500, 0xaa00, 0x55, 0xaa)	};
+ #endif
+ private int
+ image_init(register gs_image_enum *penum, int width, int height,
+   int log2_bps, int spp, int spread, gs_matrix *pmat, gs_state *pgs,
+   gx_color_index color0, gx_color_index color1)
+ {	int code;
+ 	gs_matrix mat;
+ 	uint bsize = (width + 8) * spp;	/* round up, +1 for end-of-run byte */
+ 	byte *buffer;
+ 	fixed mtx, mty;
+ 	if ( width <= 0 || height < 0 )
+ 		return_error(gs_error_undefinedresult);
+ 	if ( height == 0 ) return 0;	/* empty image */
+ 	if (	(code = gs_matrix_invert(pmat, &mat)) < 0 ||
+ 		(code = gs_matrix_multiply(&mat, &ctm_only(pgs), &mat)) < 0
+ 	   )	return code;
+ 	buffer = (byte *)gs_malloc(1, bsize, "image buffer");
+ 	if ( buffer == 0 ) return_error(gs_error_VMerror);
+ 	penum->width = width;
+ 	penum->height = height;
+ 	penum->log2_bps = log2_bps;
+ 	penum->spp = spp;
+ 	penum->spread = spread;
+ 	penum->fxx = float2fixed(mat.xx);
+ 	penum->fyy = float2fixed(mat.yy);
+ 	if ( (penum->skewed = is_skewed(&mat)) )
+ 	   {	penum->fxy = float2fixed(mat.xy);
+ 		penum->fyx = float2fixed(mat.yx);
+ 	   }
+ 	else
+ 	   {	penum->fxy = 0;
+ 		penum->fyx = 0;
+ 	   }
+ 	penum->xcur = mtx = float2fixed(mat.tx);
+ 	penum->ycur = mty = float2fixed(mat.ty);
+ 	penum->pgs = pgs;
+ 	penum->buffer = buffer;
+ 	penum->buffer_size = bsize;
+ 	penum->bytes_per_row =
+ 		(uint)((((ulong)width << log2_bps) * spp / spread + 7) >> 3);
+ 	if ( spp == 1 )
+ 	   {	/* Initialize the color table */
+ #define chtl(i)\
+   penum->dev_colors[i].halftone_level
+ 		switch ( log2_bps )
+ 		   {
+ 		case 3:
+ 		   {	/* Yes, clearing the entire table is slow, */
+ 			/* but for 8 bit-per-sample images, it's worth it. */
+ 			register gx_device_color *pcht = &penum->dev_colors[0];
+ 			register int n = 64;
+ 			do
+ 			   {	pcht[0].halftone_level =
+ 				  pcht[1].halftone_level =
+ 				  pcht[2].halftone_level =
+ 				  pcht[3].halftone_level = -1;
+ 				pcht += 4;
+ 			   }
+ 			while ( --n > 0 );
+ 			break;
+ 		   }
+ 		case 2:
+ 			chtl(17) = chtl(2*17) = chtl(3*17) =
+ 			  chtl(4*17) = chtl(6*17) = chtl(7*17) =
+ 			  chtl(8*17) = chtl(9*17) = chtl(11*17) =
+ 			  chtl(12*17) = chtl(13*17) = chtl(14*17) = -1;
+ 			/* falls through */
+ 		case 1:
+ 			chtl(5*17) = chtl(10*17) = -1;
+ 		/* 0 doesn't need any further initialization */
+ 		   }
+ 		penum->icolor0 = color0;
+ 		chtl(0) = 0;				/* pure color */
+ 		penum->icolor1 = color1;
+ 		chtl(255) = 0;				/* pure color */
+ #undef chtl
+ 	   }
+ 	/* If all four extrema of the image fall within the clipping */
+ 	/* rectangle, clipping is never required. */
+ 	   {	gx_path *pcpath = pgs->clip_path;
+ 		fixed xmin = pcpath->cbox.p.x;
+ 		fixed ymin = pcpath->cbox.p.y;
+ 		fixed xmax = pcpath->cbox.q.x;
+ 		fixed ymax = pcpath->cbox.q.y;
+ 		fixed mdx = float2fixed(mat.xx) * width;
+ 		fixed mdy = float2fixed(mat.yy) * height;
+ 		if ( penum->skewed )
+ 		   {	mdx += float2fixed(mat.yx) * height;
+ 			mdy += float2fixed(mat.xy) * width;
+ 		   }
+ 		penum->never_clip =
+ 			(mdx < 0 ?
+ 				mtx + mdx >= xmin && mtx <= xmax :
+ 				mtx >= xmin && mtx + mdx <= xmax) &&
+ 			(mdy < 0 ?
+ 				mty + mdy >= ymin && mty <= ymax :
+ 				mty >= ymin && mty + mdy <= ymax);
+ #ifdef DEBUG
+ if ( gs_debug['b'] )
+ 	printf("[b]Image: xmin=%g ymin=%g xmax=%g ymax=%g\n",
+ 		fixed2float(xmin), fixed2float(ymin),
+ 		fixed2float(xmax), fixed2float(ymax)),
+ 	printf("     mtx=%g mty=%g mdx=%g mdy=%g never_clip=%d\n",
+ 		fixed2float(mtx), fixed2float(mty),
+ 		fixed2float(mdx), fixed2float(mdy), penum->never_clip);
+ #endif
+ 	   }
+ 	   {	static void (*procs[4])(iunpack_proc_args) = {
+ 			image_unpack_0, image_unpack_1,
+ 			image_unpack_2, image_unpack_3
+ 		   };
+ 		static void (*spread_procs[4])(iunpack_proc_args) = {
+ 			image_unpack_0_spread, image_unpack_1_spread,
+ 			image_unpack_2, image_unpack_3_spread
+ 		   };
+ 		penum->slow_loop = !penum->never_clip || penum->skewed ||
+ 			/* Use slow loop for imagemask with a halftone */
+ 			((color0 == gx_no_color_index || color1 == gx_no_color_index) && !color_is_pure(pgs->dev_color));
+ 		penum->render =
+ 			(pgs->in_charpath ? image_render_skip :
+ 			 spp > 1 ? image_render_color :
+ 			 log2_bps == 0 && !penum->slow_loop &&
+ 			 (fixed2long_rounded(mtx + width * penum->fxx) -
+ 			  fixed2long(mtx) == width) ?
+ 			   image_render_direct : image_render_mono);
+ 		/* If the image is 1-for-1 with the device, */
+ 		/* we don't want to spread the samples. */
+ 		if ( penum->render == image_render_direct )
+ 		  penum->unpack = image_unpack_3;
+ 		else if ( spread != 1 )
+ 		  penum->unpack = spread_procs[log2_bps];
+ 		else
+ 		  penum->unpack = procs[log2_bps];
+ 	   }
+ 	penum->plane_index = 0;
+ 	penum->byte_in_row = 0;
+ 	penum->y = 0;
+ #ifdef DEBUG
+ if ( gs_debug['b'] )
+ 	printf("[b]Image: w=%d h=%d %s\n   [%f %f %f %f %f %f]\n",
+ 		width, height, (penum->never_clip ? "no clip" : "must clip"),
+ 		mat.xx, mat.xy, mat.yx, mat.yy, mat.tx, mat.ty);
+ #endif
+ 	return 0;
+ }
+ 
+ /* Process the next piece of an image */
+ int
+ gs_image_next(register gs_image_enum *penum, byte *dbytes, uint dsize)
+ {	uint rsize = penum->bytes_per_row;
+ 	uint pos = penum->byte_in_row;
+ 	int width = penum->width;
+ 	uint dleft = dsize;
+ 	uint dpos = 0;
+ 	int code;
+ 	/* Accumulate separated colors, if needed */
+ 	if ( penum->plane_index == 0 )
+ 		penum->plane_size = dsize;
+ 	else if ( dsize != penum->plane_size )
+ 		return_error(gs_error_undefinedresult);
+ 	penum->planes[penum->plane_index] = dbytes;
+ 	if ( ++(penum->plane_index) != penum->spread )
+ 		return 0;
+ 	penum->plane_index = 0;
+ 	/* We've accumulated an entire set of planes. */
+ 	while ( dleft )
+ 	   {	/* Fill up a row, then display it. */
+ 		uint bcount = min(dleft, rsize - pos);
+ 		byte *bptr = penum->buffer + (pos << (3 - penum->log2_bps)) * penum->spread;
+ 		int px;
+ 		for ( px = 0; px < penum->spread; px++ )
+ 			(*penum->unpack)(penum, bptr + px, penum->planes[px] + dpos, bcount);
+ 		pos += bcount;
+ 		dpos += bcount;
+ 		dleft -= bcount;
+ 		if ( pos == rsize )	/* filled an entire row */
+ 		   {	code = (*penum->render)(penum, penum->buffer, width * penum->spp, 1);
+ 			if ( code < 0 ) goto err;
+ 			if ( ++(penum->y) == penum->height ) goto end;
+ 			pos = 0;
+ 			penum->xcur += penum->fyx;
+ 			penum->ycur += penum->fyy;
+ 		   }
+ 	   }
+ 	penum->byte_in_row = pos;
+ 	return 0;
+ end:	/* End of data */
+ 	code = 1;
+ 	/* falls through */
+ err:	/* Error, abort */
+ 	gs_free((char *)penum->buffer, penum->buffer_size, 1, "image buffer");
+ 	return code;
+ }
+ 
+ /* ------ Unpacking procedures ------ */
+ 
+ private void
+ image_unpack_0(gs_image_enum *penum, byte *bptr,
+   register byte *data, uint dsize)
+ {	register unsigned long *bufp = (unsigned long *)bptr;
+ 	int left = dsize;
+ 	while ( left-- )
+ 	   {	register unsigned b = *data++;
+ 		*bufp++ = map_4_to_32[b >> 4];
+ 		*bufp++ = map_4_to_32[b & 0xf];
+ 	   }
+ }
+ 
+ private void
+ image_unpack_0_spread(gs_image_enum *penum, register byte *bufp,
+   register byte *data, uint dsize)
+ {	register int spread = penum->spread;
+ 	int left = dsize;
+ 	while ( left-- )
+ 	   {	register unsigned b = *data++;
+ 		*bufp = -(b >> 7); bufp += spread;
+ 		*bufp = -((b >> 6) & 1); bufp += spread;
+ 		*bufp = -((b >> 5) & 1); bufp += spread;
+ 		*bufp = -((b >> 4) & 1); bufp += spread;
+ 		*bufp = -((b >> 3) & 1); bufp += spread;
+ 		*bufp = -((b >> 2) & 1); bufp += spread;
+ 		*bufp = -((b >> 1) & 1); bufp += spread;
+ 		*bufp = -(b & 1); bufp += spread;
+ 	   }
+ }
+ 
+ private void
+ image_unpack_1(gs_image_enum *penum, byte *bptr,
+   register byte *data, uint dsize)
+ {	register unsigned short *bufp = (unsigned short *)bptr;
+ 	int left = dsize;
+ 	while ( left-- )
+ 	   {	register unsigned b = *data++;
+ 		*bufp++ = map_4_to_16[b >> 4];
+ 		*bufp++ = map_4_to_16[b & 0xf];
+ 	   }
+ }
+ 
+ private void
+ image_unpack_1_spread(gs_image_enum *penum, register byte *bufp,
+   register byte *data, uint dsize)
+ {	register int spread = penum->spread;
+ 	int left = dsize;
+ 	while ( left-- )
+ 	   {	register unsigned b = *data++;
+ 		register ushort b2;
+ 		b2 = map_4_to_16[b >> 4];
+ 		*bufp = b2 >> 8; bufp += spread;
+ 		*bufp = (byte)b2; bufp += spread;
+ 		b2 = map_4_to_16[b & 0xf];
+ 		*bufp = b2 >> 8; bufp += spread;
+ 		*bufp = (byte)b2; bufp += spread;
+ 	   }
+ }
+ 
+ private void
+ image_unpack_2(gs_image_enum *penum, register byte *bufp,
+   register byte *data, uint dsize)
+ {	register int spread = penum->spread;
+ 	int left = dsize;
+ 	while ( left-- )
+ 	   {	register unsigned b = *data++;
+ 		*bufp = (b & 0xf0) + (b >> 4); bufp += spread;
+ 		b &= 0xf;
+ 		*bufp = (b << 4) + b; bufp += spread;
+ 	   }
+ }
+ 
+ private void
+ image_unpack_3(gs_image_enum *penum, byte *bufp,
+   byte *data, uint dsize)
+ {	if ( data != bufp ) memcpy(bufp, data, dsize);
+ }
+ 
+ private void
+ image_unpack_3_spread(gs_image_enum *penum, register byte *bufp,
+   register byte *data, uint dsize)
+ {	register int spread = penum->spread;
+ 	register int left = dsize;
+ 	while ( left-- )
+ 	   {	*bufp = *data++; bufp += spread;
+ 	   }
+ }
+ 
+ /* ------ Rendering procedures ------ */
+ 
+ /* Rendering procedure for ignoring an image.  We still need to iterate */
+ /* over the samples, because the procedure might have side effects. */
+ private int
+ image_render_skip(gs_image_enum *penum, byte *data, uint w, int h)
+ {	return h;
+ }
+ 
+ /* Rendering procedure for a 1-bit-per-pixel sampled image */
+ /* with no clipping, skewing, rotation, or X scaling. */
+ /* In this case a direct BitBlt is possible. */
+ private int
+ image_render_direct(gs_image_enum *penum, byte *data, uint w, int h)
+ {	fixed xt = penum->xcur;
+ 	fixed yt = penum->ycur, yn = yt + penum->fyy;
+ 	int ix = fixed2int(xt), iy = fixed2int(yt);
+ 	int ht = fixed2int(yn) - iy;
+ 	gx_device *dev = penum->pgs->device->info;
+ 	int (*proc)(P10(gx_device *, byte *, int, int, int, int, int, int, gx_color_index, gx_color_index)) = dev->procs->copy_mono;
+ 	gx_color_index zero = penum->icolor0, one = penum->icolor1;
+ 	if ( ht == 1 )
+ 	   {	/* We can do the whole thing at once. */
+ 		(*proc)(dev, data, 0, (w + 7) >> 3,
+ 			ix, iy, w, h, zero, one);
+ 		return h;
+ 	   }
+ 	else
+ 	   {	/* Do just one row. */
+ 		int dy;
+ 		if ( ht < 0 )
+ 			iy += ht, ht = -ht;
+ 		for ( dy = 0; dy < ht; dy++ )
+ 			(*proc)(dev, data, 0, (w + 7) >> 3,
+ 				ix, iy + dy, w, 1, zero, one);
+ 		return 1;
+ 	   }
+ }
+ 
+ /* Rendering procedure for the general case of displaying a */
+ /* monochrome image, dealing with multiple bit-per-sample images, */
+ /* bits not 1-for-1 with the device, clipping, and general transformations. */
+ /* This procedure handles a single scan line. */
+ private int
+ image_render_mono(gs_image_enum *penum, byte *buffer, uint w, int h)
+ {	gx_color_index zero = penum->icolor0, one = penum->icolor1;
+ 	gs_state *pgs = penum->pgs;
+ 	fixed	dxx = penum->fxx, dxy = penum->fxy,
+ 		dyx = penum->fyx, dyy = penum->fyy;
+ 	gs_fixed_rect cbox;
+ 	int skew = penum->skewed;
+ 	fixed xt = penum->xcur;
+ 	fixed ytf = penum->ycur;
+ 	fixed yn;		/* ytf + dyy, if no skew */
+ 	int yt, yb, idy, iht;
+ 	gs_color rcolor;
+ 	gx_device_color *pdevc = pgs->dev_color;
+      /* Note: image_set_gray assumes that log2_bps != 0. */
+ #define image_set_rgb(sample_value)\
+   rcolor.luminance = rcolor.red = rcolor.green = rcolor.blue =\
+     color_param_from_byte(sample_value)
+ #define image_set_gray(sample_value)\
+    { pdevc = &penum->dev_colors[sample_value];\
+      if ( pdevc->halftone_level < 0 )\
+       { image_set_rgb(sample_value);\
+         gx_color_render(&rcolor, pdevc, pgs);\
+       }\
+      else\
+        gx_color_load(pdevc, pgs);\
+    }
+ 	int xcnt = w;
+ 	fixed xl = xt;
+ 	byte *psrc = buffer;
+ 	fixed xrun = xt;		/* x at start of run */
+ 	fixed yrun = ytf;		/* y ditto */
+ 	int run = *psrc;		/* run value */
+ 	int htrun = -2;			/* halftone run value */
+ 	gx_device *dev = pgs->device->info;
+ 	int (*fill_proc)(P6(gx_device *, int, int, int, int, gx_color_index)) = dev->procs->fill_rectangle;
+ 	cbox = pgs->clip_path->bbox;	/* box is known to be up to date */
+ 	if ( !skew )
+ 	  { /* We're going to round to pixel boundaries later, */
+ 	    /* so we might as well do this for Y now. */
+ 	    yn = fixed_rounded(ytf + dyy);
+ 	    ytf = fixed_rounded(ytf);
+ 	    yt = fixed2int(ytf);
+ 	    yb = fixed2int(yn);
+ 	    iht = yb - yt;
+ 	    /* Do a quick clipping and empty check now. */
+ 	    if ( iht > 0 ) idy = 0;
+ 	    else if ( iht < 0 ) idy = iht, iht = -iht;
+ 	    else return 1;
+ 	    if ( dyy > 0 )
+ 	      { if ( ytf >= cbox.q.y || yn <= cbox.p.y ) return 1;
+ 	      }
+ 	    else
+ 	      { if ( yn >= cbox.q.y || ytf <= cbox.p.y ) return 1;
+ 	      }
+ 	  }
+ 	buffer[w] = ~buffer[w - 1];	/* force end of run */
+ #ifdef DEBUG
+ if ( gs_debug['b'] )
+ 	printf("[b]y=%d w=%d xt=%f yt=%f yb=%f\n",
+ 		penum->y, w,
+ 		fixed2float(xt), fixed2float(ytf), fixed2float(ytf + dyy));
+ #endif
+ 	rcolor.is_gray = rcolor.luminance_set = 1;
+ 	while ( xcnt-- >= 0 )	/* 1 extra iteration */
+ 				/* to handle final run */
+ 	   {	if ( *psrc++ != run )
+ 		   {	/* Fill the region between */
+ 			/* xrun and xl */
+ 			if ( penum->slow_loop )
+ 			  { /* Must use general fill */
+ 			    gx_path ipath;
+ 			    gx_path *ppath = &ipath;
+ 			    int code;
+ 			    /* Use halftone if needed. */
+ 			    /* Also handle imagemask here. */
+ 			    if ( run != htrun )
+ 			      { htrun = run;
+ 				if ( run == 0 )
+ 				  { if ( zero == gx_no_color_index ) goto trans;
+ 				  }
+ 				else if ( run == 255 )
+ 				  { if ( one == gx_no_color_index ) goto trans;
+ 				  }
+ 				image_set_gray(run);
+ 			      }
+ 			    if ( !skew )
+ 			      { /* Do the empty/clipping check */
+ 				/* before going to the trouble of */
+ 				/* building the path. */
+ 				/* In the non-skew case, we take the */
+ 				/* trouble to round the box correctly. */
+ 				/* We pre-checked Y, only do X now. */
+ 				fixed xlr = fixed_rounded(xl);
+ 				fixed xrr = fixed_rounded(xrun);
+ 				if ( xrr == xlr )
+ 				  goto trans;
+ 				if ( dxx >= 0 )
+ 				  { if ( xrr >= cbox.q.x || xlr <= cbox.p.x )
+ 				      goto trans;
+ 				  }
+ 				else
+ 				  { if ( xlr >= cbox.q.x || xrr <= cbox.p.x )
+ 				      goto trans;
+ 				  }
+ 				gx_path_init(ppath, &pgs->memory_procs);
+ 				code = gx_path_add_pgram(ppath,
+ 							 xrr, ytf, xlr, ytf,
+ 							 xlr, yn);
+ 			      }
+ 			    else
+ 			      { gx_path_init(ppath, &pgs->memory_procs);
+ 				code = gx_path_add_pgram(ppath,
+ 							 xrun, yrun, xl, ytf,
+ 							 xl + dyx, ytf + dyy);
+ 			      }
+ 			    if ( code < 0 )
+ 			      {	gx_path_release(ppath);
+ 				return code;
+ 			      }
+ 			    if ( skew )
+ 			      {	gs_fixed_rect box;
+ 				gx_path_bbox(ppath, &box);
+ #define check_clipped_or_empty(xy, label)\
+   if ( box.q.xy <= cbox.p.xy || box.p.xy >= cbox.q.xy ||\
+        fixed2int_rounded(box.p.xy) == fixed2int_rounded(box.q.xy)\
+    ) goto label
+ 				check_clipped_or_empty(x, nofill);
+ 				check_clipped_or_empty(y, nofill);
+ #undef check_clipped_or_empty
+ 			      }
+ 			    gx_fill_path(ppath, pdevc, pgs,
+ 					 gx_rule_winding_number, (fixed)0);
+ nofill:			    gx_path_release(ppath);
+ trans: ;		  }
+ 			else
+ 			   {	/* No clipping, no skew, and not */
+ 				/* imagemask with a halftone. */
+ 				gx_color_index rcx;
+ 				int xi = fixed2int_rounded(xrun);
+ 				int wi = fixed2int_rounded(xl) - xi;
+ 				if ( wi <= 0 )
+ 				   {	if ( wi == 0 ) goto mt;
+ 					xi += wi, wi = -wi;
+ 				   }
+ 				switch ( run )
+ 				   {
+ 				case 0:
+ 					rcx = zero;
+ 					goto zo;
+ 				case 255:
+ 					rcx = one;
+ zo:					if ( rcx != gx_no_color_index )
+ 					   {	(*fill_proc)(dev, xi, yt + idy, wi, iht, rcx);
+ 					   }
+ 					break;
+ 				default:
+ 					/* Use halftone if needed */
+ 					if ( run != htrun )
+ 					   {	image_set_gray(run);
+ 						htrun = run;
+ 					   }
+ 					gz_fill_rectangle(xi, yt + idy, wi, iht, pdevc, pgs);
+ 				   }
+ mt: ;			   }
+ 			xrun = xl;
+ 			yrun = ytf;
+ 			run = psrc[-1];
+ 		   }
+ 		xl += dxx;
+ 		ytf += dxy;		/* harmless if no skew */
+ 	   }
+ 	return 1;
+ }
+ 
+ /* Rendering procedure for handling color images. */
+ typedef union { struct { byte r, g, b, skip; } v; ulong all; } color_sample;
+ private int
+ image_render_color(gs_image_enum *penum, byte *buffer, uint w, int h)
+ {	gs_state *pgs = penum->pgs;
+ 	fixed	dxx = penum->fxx, dxy = penum->fxy,
+ 		dyx = penum->fyx, dyy = penum->fyy;
+ 	int skew = penum->skewed;
+ 	fixed xt = penum->xcur;
+ 	fixed ytf = penum->ycur;
+ 	int yt, idy, iht;
+ 	gs_color rcolor;
+ 	gx_device_color devc1, devc2;
+ 	gx_device_color *pdevc = &devc1, *pdevc_next = &devc2;
+ 	int spp = penum->spp;
+ 	fixed xl = xt;
+ 	byte *psrc = buffer;
+ 	fixed xrun = xt;		/* x at start of run */
+ 	fixed yrun = ytf;		/* y ditto */
+ 	color_sample run;		/* run value */
+ 	color_sample next;		/* next sample value */
+ 	byte *bufend = buffer + w;
+ 	bufend[0] = ~bufend[-spp];	/* force end of run */
+ 	if ( !skew )
+ 	   {	fixed yn = ytf + dyy;
+ 		yt = fixed2int_rounded(ytf);
+ 		iht = fixed2int_rounded(yn) - yt;
+ 		if ( iht >= 0 ) idy = 0;
+ 		else idy = iht, iht = -iht;
+ 	   }
+ #ifdef DEBUG
+ if ( gs_debug['b'] )
+ 	printf("[b]y=%d w=%d xt=%f yt=%f yb=%f\n",
+ 		penum->y, w,
+ 		fixed2float(xt), fixed2float(ytf), fixed2float(ytf + dyy));
+ #endif
+ 	run.all = 0;
+ 	next.all = 0;
+ 	rcolor.red = rcolor.green = rcolor.blue = 0;
+ 	gx_color_from_rgb(&rcolor);
+ 	gx_color_render(&rcolor, pdevc, pgs);
+ 	while ( psrc <= bufend )	/* 1 extra iteration */
+ 				/* to handle final run */
+ 	   {	if ( spp == 4 )		/* cmyk */
+ 		   {	uint black = 0xff - psrc[3];
+ 			next.v.r = (0xff - psrc[0]) * black / 0xff;
+ 			next.v.g = (0xff - psrc[1]) * black / 0xff;
+ 			next.v.b = (0xff - psrc[2]) * black / 0xff;
+ 			psrc += 4;
+ 		   }
+ 		else			/* rgb */
+ 		   {	next.v.r = psrc[0];
+ 			next.v.g = psrc[1];
+ 			next.v.b = psrc[2];
+ 			psrc += 3;
+ 		   }
+ 		if ( next.all != run.all )
+ 		   {	rcolor.red = color_param_from_byte(next.v.r);
+ 			rcolor.green = color_param_from_byte(next.v.g);
+ 			rcolor.blue = color_param_from_byte(next.v.b);
+ 			gx_color_from_rgb(&rcolor);
+ 			gx_color_render(&rcolor, pdevc_next, pgs);
+ 			/* Even though the supplied colors don't match, */
+ 			/* the device colors might. */
+ 			if ( devc1.color1 != devc2.color1 ||
+ 			     devc1.halftone_level != devc2.halftone_level ||
+ 			     (devc1.halftone_level &&
+ 			      devc1.color2 != devc2.color2) ||
+ 			     psrc > bufend	/* force end of last run */
+ 			   )
+ 			   {	/* Fill the region between */
+ 				/* xrun and xl */
+ 				gx_device_color *ptemp;
+ 				if ( penum->slow_loop )
+ 			   {	/* Must use general fill */
+ 				gx_path ipath;
+ 				gx_path *ppath = &ipath;
+ 				int code;
+ 				gx_path_init(ppath, &pgs->memory_procs);
+ 				code = gx_path_add_pgram(ppath,
+ 					xrun, yrun, xl, ytf,
+ 					xl + dyx, ytf + dyy);
+ 				if ( code < 0 )
+ 				   {	gx_path_release(ppath);
+ 					return code;
+ 				   }
+ 				gx_fill_path(ppath, pdevc, pgs,
+ 					     gx_rule_winding_number, (fixed)0);
+ 				gx_path_release(ppath);
+ 			   }
+ 				else
+ 			   {	/* No clipping, no skew. */
+ 				int xi = fixed2int_rounded(xrun);
+ 				int wi = fixed2int_rounded(xl) - xi;
+ 				if ( wi < 0 ) xi += wi, wi = -wi;
+ 				gz_fill_rectangle(xi, yt + idy, wi, iht, pdevc, pgs);
+ 			   }
+ 				xrun = xl;
+ 				yrun = ytf;
+ 				ptemp = pdevc;
+ 				pdevc = pdevc_next;
+ 				pdevc_next = ptemp;
+ 			   }
+ 			run.all = next.all;
+ 		   }
+ 		xl += dxx;
+ 		ytf += dxy;		/* harmless if no skew */
+ 	   }
+ 	return 1;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsline.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsline.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsline.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,154 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsline.c */
+ /* Line parameter operators for GhostScript library */
+ #include "math_.h"
+ #include "memory_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"			/* ditto */
+ #include "gxmatrix.h"			/* for gzstate */
+ #include "gzstate.h"
+ #include "gzline.h"
+ 
+ /* setlinewidth */
+ int
+ gs_setlinewidth(gs_state *pgs, floatp width)
+ {	if ( width < 0 ) return_error(gs_error_rangecheck);
+ 	pgs->line_params->width = width / 2;
+ 	return 0;
+ }
+ 
+ /* currentlinewidth */
+ float
+ gs_currentlinewidth(gs_state *pgs)
+ {	return (float)(pgs->line_params->width * 2);
+ }
+ 
+ /* setlinecap */
+ int
+ gs_setlinecap(gs_state *pgs, gs_line_cap cap)
+ {	pgs->line_params->cap = cap;
+ 	return 0;
+ }
+ 
+ /* currentlinecap */
+ gs_line_cap
+ gs_currentlinecap(gs_state *pgs)
+ {	return pgs->line_params->cap;
+ }
+ 
+ /* setlinejoin */
+ int
+ gs_setlinejoin(gs_state *pgs, gs_line_join join)
+ {	pgs->line_params->join = join;
+ 	return 0;
+ }
+ 
+ /* currentlinejoin */
+ gs_line_join
+ gs_currentlinejoin(gs_state *pgs)
+ {	return pgs->line_params->join;
+ }
+ 
+ /* setmiterlimit */
+ int
+ gs_setmiterlimit(gs_state *pgs, floatp limit)
+ {	if ( limit < 1.0 ) return_error(gs_error_rangecheck);
+ 	pgs->line_params->miter_limit = limit;
+ 	/* The supplied miter limit is an upper bound on */
+ 	/* 1/sin(phi/2).  We convert this to a lower bound on */
+ 	/* tan(phi).  Note that if phi > pi/2, this is negative. */
+ 	/* We use the half-angle and angle-sum formulas here */
+ 	/* to avoid the trig functions.... */
+ 	   {	double limit_sq = limit * limit;
+ 		pgs->line_params->miter_check =
+ 			(/* We need a special check for phi/2 close to pi/4 */
+ 			 limit_sq < 2.0001 && limit_sq > 1.9999 ?
+ 			 1.0e6 :
+ 			 sqrt(limit_sq - 1) * 2 / (limit_sq - 2));
+ 	   }
+ 	return 0;
+ }
+ 
+ /* currentmiterlimit */
+ float
+ gs_currentmiterlimit(gs_state *pgs)
+ {	return pgs->line_params->miter_limit;
+ }
+ 
+ /* setdash */
+ int
+ gs_setdash(gs_state *pgs, float *pattern, uint length, floatp offset)
+ {	uint n = length;
+ 	float *dfrom = pattern;
+ 	char ink = 1;
+ 	int index = 0;
+ 	float pattern_length = 0.0;
+ 	float dist_left;
+ 	dash_params *dash = &pgs->line_params->dash;
+ 	float *ppat;
+ 	/* Check the dash pattern */
+ 	while ( n-- )
+ 	   {	float elt = *dfrom++;
+ 		if ( elt < 0 ) return_error(gs_error_rangecheck);
+ 		pattern_length += elt;
+ 	   }
+ 	if ( length == 0 )		/* empty pattern */
+ 	   {	dist_left = 0.0;
+ 		ppat = 0;
+ 	   }
+ 	else
+ 	   {	if ( pattern_length == 0 )
+ 			return_error(gs_error_rangecheck);
+ 		/* Compute the initial index, ink_on, and distance left */
+ 		/* in the pattern, according to the offset. */
+ #define f_mod(a, b) ((a) - floor((a) / (b)) * (b))
+ 		dist_left = f_mod(offset, pattern_length);
+ 		while ( (dist_left -= pattern[index]) >= 0 )
+ 			ink = !ink, index++;
+ 		ppat = (float *)gs_malloc(length, sizeof(float),
+ 					  "dash pattern");
+ 		if ( ppat == 0 ) return_error(gs_error_VMerror);
+ 		memcpy(ppat, pattern, length * sizeof(float));
+ 	   }
+ 	dash->pattern = ppat;
+ 	dash->pattern_size = length;
+ 	dash->offset = offset;
+ 	dash->init_ink_on = ink;
+ 	dash->init_index = index;
+ 	dash->init_dist_left = -dist_left;
+ 	return 0;
+ }
+ 
+ /* currentdash */
+ uint
+ gs_currentdash_length(gs_state *pgs)
+ {	return pgs->line_params->dash.pattern_size;
+ }
+ int
+ gs_currentdash_pattern(gs_state *pgs, float *pattern)
+ {	memcpy(pattern, pgs->line_params->dash.pattern, pgs->line_params->dash.pattern_size * sizeof(float));
+ 	return 0;
+ }
+ float
+ gs_currentdash_offset(gs_state *pgs)
+ {	return pgs->line_params->dash.offset;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmain.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmain.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmain.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,221 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsmain.c */
+ /* Framework for GhostScript drivers */
+ #include "string_.h"
+ #include "malloc_.h"
+ #include "memory_.h"
+ #include "gx.h"
+ #include "gsmatrix.h"			/* for gxdevice.h */
+ #include "gxdevice.h"
+ #include "gxdevmem.h"
+ 
+ typedef struct gx_device_s gx_device;
+ 
+ /*
+  * This routine provides the following standard services for parsing
+  * a command line:
+  *	- setting debug flags (-Z switch) [if debugging];
+  *	- tracing (-T switch);
+  *	- passing other arguments and switches back to the caller
+  *
+  * Calling convention:
+  *	gs_main(argc, argv, map_name, switch_proc, arg_proc)
+  * Calls
+  *	switch_proc(switch_char, rest_of_arg) for switches,
+  *	arg_proc(arg, index) for non-switch args.
+  * If switch_proc returns a negative value, gs_main prints an
+  *   "unknown switch" error message and aborts.
+  * gs_main returns the number of non-switch args handed to arg_proc.
+  */
+ 
+ /* Imported data */
+ extern gx_device *gx_device_list[];
+ 
+ private long proc_reloc;	/* relocation of procedures */
+ 
+ int
+ gs_main(int argc, char *argv[], char *map_name,
+     int (*switch_proc)(P2(char, char *)),
+     void (*arg_proc)(P2(char *, int)))
+ {	int argi = 1;
+ 	FILE *mapf = NULL;
+ 	int arg_count = 0;
+ 	proc_reloc = 0;
+ 	/* Do platform-dependent initialization. */
+ 	/* We have to do this as the very first thing, */
+ 	/* because it detects attempts to run 80N86 executables (N>0) */
+ 	/* on incompatible processors. */
+ 	   {	extern void gp_init();
+ 		gp_init();		/* Platform-dependent init */
+ 	   }
+ #ifdef DEBUG
+ 	/* Reset debugging flags */
+ 	memset(gs_debug, 0, 128);
+ #endif
+ 	/* If debugging is enabled, trace the device calls. */
+ #ifdef DEBUG
+ 	   {	extern gx_device *gs_trace_device(P1(gx_device *));
+ 		extern gx_device_memory
+ 			mem_mono_device, mem_mapped_color_device,
+ 			mem_true24_color_device, mem_true32_color_device;
+ 		static gx_device_memory *mdevs[5] =
+ 		   {	&mem_mono_device, &mem_mapped_color_device,
+ 			&mem_true24_color_device, &mem_true32_color_device,
+ 			0
+ 		   };
+ 		gx_device **pdevs[3];
+ 		gx_device ***ppdev;
+ 		gx_device **pdev;
+ 		pdevs[0] = gx_device_list;
+ 		pdevs[1] = (gx_device **)mdevs;
+ 		pdevs[2] = 0;
+ 		for ( ppdev = pdevs; *ppdev != 0; ppdev++ )
+ 		 for ( pdev = *ppdev; *pdev != 0; pdev++ )
+ 		   {	gx_device *tdev = gs_trace_device(*pdev);
+ 			if ( tdev == 0 )
+ 			   {	dprintf("Can't allocate traced device!\n");
+ 				exit(1);
+ 			   }
+ 			*pdev = tdev;
+ 		   }
+ 	   }
+ #endif
+ 	for ( ; argi < argc; argi++ )
+ 	   {	char *arg = argv[argi];
+ 		if ( *arg == '-' )
+ 		   {	switch ( *++arg )
+ 			   {
+ 			default:
+ 				if ( (*switch_proc)(*arg, arg + 1) < 0 )
+ 					printf("Unknown switch %s - ignoring\n", arg - 1);
+ 				break;
+ 			case 'Z':
+ #ifdef DEBUG
+ 				/* Print the address of 'main' so that */
+ 				/* we can decipher stack traces later. */
+ 			   {	extern main();
+ 				printf("[Z]main = %lx\n", (ulong)main);
+ 			   }
+ 				if ( !arg[1] )
+ 				   {	/* No options, set all flags */
+ 					memset(gs_debug, -1, 128);
+ 				   }
+ 				else
+ 				   {	while ( *++arg )
+ 						gs_debug[*arg & 127] = -1;
+ 				   }
+ #else
+ 				printf("Not a debugging configuration, -Z switch ignored\n");
+ #endif
+ 				break;
+ 			case 'T':
+ 			if ( mapf == NULL )
+ 			   {	/* Open the map file and look up 'main' */
+ 				extern FILE *trace_open_map(P2(char *, long *));
+ 				mapf = trace_open_map(map_name, &proc_reloc);
+ 				if ( mapf == NULL )
+ 				   {	printf("Map file %s is apparently missing or malformed\n", map_name);
+ 					break;
+ 				   }
+ 				/* Print the address of 'main' so that */
+ 				/* we can decipher return addresses later. */
+ 			   {	extern main();
+ 				printf("[T]main = %lx\n", (ulong)main);
+ 			   }
+ 			   }
+ 			   {	char *delim;
+ 				char *tname;
+ 				char *targs = NULL;
+ 				int rsize = 0;
+ 				extern int trace_flush_flag;
+ 				delim = strchr(arg, ':');
+ 				if ( delim != NULL )
+ 				   {	sscanf(delim + 1, "%d", &rsize);
+ 					*delim = 0;	/* terminate name */
+ 					delim = strchr(delim + 1, ':');
+ 					if ( delim != NULL )
+ 						targs = delim + 1;
+ 				   }
+ 				tname = gs_malloc(strlen(arg) + 1, 1,
+ 						  "-T switch");
+ 				strcpy(tname, arg);
+ 				*tname = '_';
+ 				strupr(tname);
+ 				if ( trace_name(tname, mapf, targs, rsize) < 0 )
+ 					printf("%s not found\n", tname);
+ 				trace_flush_flag = 1;
+ 			   }
+ 				break;
+ 			   }
+ 		   }
+ 		else
+ 			(*arg_proc)(arg, arg_count++);
+ 	   }
+ 	return arg_count;
+ }
+ 
+ /* Close the device(s) and exit. */
+ void
+ gs_exit(int code)
+ {	gx_device **pdev = gx_device_list;
+ 	if ( code != 0 ) fflush(stderr);	/* in case of error exit */
+ 	for ( ; *pdev != 0; pdev++ )
+ 	  if ( (*pdev)->is_open )
+ 	    ((*pdev)->procs->close_device)(*pdev);
+ 	exit(code);
+ }
+ 
+ /* ------ Debugging routines ------ */
+ 
+ #ifdef DEBUG			/* ------ ------ */
+ 
+ void gs_dump_C_stack();
+ 
+ /* Log an error return */
+ int
+ gs_log_error(int err)
+ {	if ( gs_debug['e'] )
+ 	  { printf("Returning error %d:\n", err);
+ 	    gs_dump_C_stack();
+ 	  }
+ 	return err;
+ }
+ 
+ #endif				/* ------ ifdef DEBUG ------ */
+ 
+ /* Dump the C stack. */
+ /* This is actually only used for debugging. */
+ extern char *stack_top_frame();
+ extern unsigned long stack_return(P1(char *));
+ extern char *stack_next_frame(P1(char *));
+ void
+ gs_dump_C_stack()
+ {	char *nbp = stack_top_frame();
+ 	char *bp;
+ 	do
+ 	   {	bp = nbp;
+ 		printf("frame %8lx called from %8lx (%8lx)\n",
+ 			(unsigned long)bp, stack_return(bp),
+ 			stack_return(bp) - proc_reloc);
+ 		nbp = stack_next_frame(bp);
+ 	   }
+ 	while ( nbp != 0 );
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmatrix.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmatrix.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmatrix.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,293 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsmatrix.c */
+ /* Matrix operators for GhostScript library */
+ #include "math_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxarith.h"
+ #include "gxmatrix.h"
+ 
+ /* The identity matrix */
+ /* This should be private (static), but the interpreter */
+ /* has to be able to fill in the "unused" words. */
+ /*static*/ gs_matrix gs_identity_matrix =
+ 	{ identity_matrix_body };
+ 
+ /* ------ Matrix creation ------ */
+ 
+ /* Create an identity matrix */
+ void
+ gs_make_identity(gs_matrix *pmat)
+ {	*pmat = gs_identity_matrix;
+ }
+ 
+ /* Create a translation matrix */
+ int
+ gs_make_translation(floatp dx, floatp dy, register gs_matrix *pmat)
+ {	*pmat = gs_identity_matrix;
+ 	pmat->tx = dx;
+ 	pmat->ty = dy;
+ 	return 0;
+ }
+ 
+ /* Create a scaling matrix */
+ int
+ gs_make_scaling(floatp sx, floatp sy, register gs_matrix *pmat)
+ {	*pmat = gs_identity_matrix;
+ 	pmat->xx = sx;
+ 	pmat->yy = sy;
+ 	return 0;
+ }
+ 
+ /* Create a rotation matrix. */
+ /* The angle is in degrees. */
+ int
+ gs_make_rotation(floatp ang, register gs_matrix *pmat)
+ {	float theta = ang * (M_PI / 180.0);
+ 	*pmat = gs_identity_matrix;
+ 	pmat->xx = pmat->yy = cos(theta);
+ 	pmat->yx = -(pmat->xy = sin(theta));
+ 	return 0;
+ }
+ 
+ /* ------ Matrix arithmetic ------ */
+ 
+ /* Multiply two matrices.  We should check for floating exceptions, */
+ /* but for the moment it's just too awkward. */
+ /* Since this is used heavily, we check for shortcuts. */
+ int
+ gs_matrix_multiply(gs_matrix *pm1, gs_matrix *pm2, register gs_matrix *pmr)
+ {	float xx1 = pm1->xx, yy1 = pm1->yy;
+ 	float tx1 = pm1->tx, ty1 = pm1->ty;
+ 	float xx2 = pm2->xx, yy2 = pm2->yy;
+ 	float xy2 = pm2->xy, yx2 = pm2->yx;
+ 	if ( !is_skewed(pm1) )
+ 	   {	pmr->tx = tx1 * xx2 + pm2->tx;
+ 		pmr->ty = ty1 * yy2 + pm2->ty;
+ 		if ( is_fzero(xy2) )
+ 			pmr->xy = 0;
+ 		else
+ 			pmr->xy = xx1 * xy2,
+ 			pmr->ty += tx1 * xy2;
+ 		pmr->xx = xx1 * xx2;
+ 		if ( is_fzero(yx2) )
+ 			pmr->yx = 0;
+ 		else
+ 			pmr->yx = yy1 * yx2,
+ 			pmr->tx += ty1 * yx2;
+ 		pmr->yy = yy1 * yy2;
+ 	   }
+ 	else
+ 	   {	pmr->xx = xx1 * xx2 + pm1->xy * yx2;
+ 		pmr->xy = xx1 * xy2 + pm1->xy * yy2;
+ 		pmr->yy = pm1->yx * xy2 + yy1 * yy2;
+ 		pmr->yx = pm1->yx * xx2 + yy1 * yx2;
+ 		pmr->tx = tx1 * xx2 + ty1 * yx2 + pm2->tx;
+ 		pmr->ty = tx1 * xy2 + ty1 * yy2 + pm2->ty;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Invert a matrix.  Return gs_error_undefinedresult if not invertible. */
+ int
+ gs_matrix_invert(register gs_matrix *pm, register gs_matrix *pmr)
+ {	/* We have to be careful about fetch/store order, */
+ 	/* because pm might be the same as pmr. */
+ 	if ( !is_skewed(pm) )
+ 	   {	if ( is_fzero(pm->xx) || is_fzero(pm->yy) )
+ 			return_error(gs_error_undefinedresult);
+ 		pmr->tx = - (pmr->xx = 1.0 / pm->xx) * pm->tx;
+ 		pmr->xy = 0.0;
+ 		pmr->yx = 0.0;
+ 		pmr->ty = - (pmr->yy = 1.0 / pm->yy) * pm->ty;
+ 	   }
+ 	else
+ 	   {	double det = pm->xx * pm->yy - pm->xy * pm->yx;
+ 		float mxx = pm->xx, mtx = pm->tx;
+ 		if ( det == 0 ) return_error(gs_error_undefinedresult);
+ 		pmr->xx = pm->yy / det;
+ 		pmr->xy = - pm->xy / det;
+ 		pmr->yx = - pm->yx / det;
+ 		pmr->yy = mxx / det;	/* xx is already changed */
+ 		pmr->tx = - (mtx * pmr->xx + pm->ty * pmr->yx);
+ 		pmr->ty = - (mtx * pmr->xy + pm->ty * pmr->yy);	/* tx is already changed */
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Rotate a matrix, possibly in place.  The angle is in degrees. */
+ int
+ gs_matrix_rotate(register gs_matrix *pm, floatp ang, register gs_matrix *pmr)
+ {	float mxx, mxy;
+ 	int quads;
+ 	float tsin, tcos;
+ 	/* We do some special checking for multiples of 90, */
+ 	/* so we don't get any rounding errors. */
+ 	if (	ang >= -360 && ang <= 360 &&
+ 		ang == (quads = (int)ang / 90) * 90
+ 	   )
+ 	   {	int isin = 0, icos = 1, t;
+ 		quads &= 3;
+ 		while ( quads-- ) t = isin, isin = icos, icos = -t;
+ 		tsin = isin, tcos = icos;
+ 	   }
+ 	else
+ 	   {	float theta = ang * (M_PI / 180.0);
+ 		tsin = sin(theta);
+ 		tcos = cos(theta);
+ 	   }
+ 	mxx = pm->xx, mxy = pm->xy;
+ 	pmr->xx = tcos * mxx + tsin * pm->yx;
+ 	pmr->xy = tcos * mxy + tsin * pm->yy;
+ 	pmr->yx = tcos * pm->yx - tsin * mxx;
+ 	pmr->yy = tcos * pm->yy - tsin * mxy;
+ 	pmr->tx = pm->tx;
+ 	pmr->ty = pm->ty;
+ 	return 0;
+ }
+ 
+ /* ------ Coordinate transformations (floating point) ------ */
+ 
+ /* Note that all the transformation routines take separate */
+ /* x and y arguments, but return their result in a point. */
+ 
+ /* Transform a point. */
+ int
+ gs_point_transform(floatp x, floatp y, register gs_matrix *pmat,
+   register gs_point *ppt)
+ {	ppt->x = x * pmat->xx + pmat->tx;
+ 	ppt->y = y * pmat->yy + pmat->ty;
+ 	if ( !is_fzero(pmat->yx) )
+ 		ppt->x += y * pmat->yx;
+ 	if ( !is_fzero(pmat->xy) )
+ 		ppt->y += x * pmat->xy;
+ 	return 0;
+ }
+ 
+ /* Inverse-transform a point. */
+ /* Return gs_error_undefinedresult if the matrix is not invertible. */
+ int
+ gs_point_transform_inverse(floatp x, floatp y, register gs_matrix *pmat,
+   register gs_point *ppt)
+ {	if ( !is_skewed(pmat) )
+ 	   {	ppt->x = (x - pmat->tx) / pmat->xx;
+ 		ppt->y = (y - pmat->ty) / pmat->yy;
+ 		return 0;
+ 	   }
+ 	else
+ 	   {	/* There are faster ways to do this, */
+ 		/* but we won't implement one unless we have to. */
+ 		gs_matrix imat;
+ 		int code = gs_matrix_invert(pmat, &imat);
+ 		if ( code < 0 ) return code;
+ 		return gs_point_transform(x, y, &imat, ppt);
+ 	   }
+ }
+ 
+ /* Transform a distance. */
+ int
+ gs_distance_transform(floatp dx, floatp dy, register gs_matrix *pmat,
+   register gs_point *pdpt)
+ {	pdpt->x = dx * pmat->xx;
+ 	pdpt->y = dy * pmat->yy;
+ 	if ( !is_fzero(pmat->yx) )
+ 		pdpt->x += dy * pmat->yx;
+ 	if ( !is_fzero(pmat->xy) )
+ 		pdpt->y += dx * pmat->xy;
+ 	return 0;
+ }
+ 
+ /* Inverse-transform a distance. */
+ /* Return gs_error_undefinedresult if the matrix is not invertible. */
+ int
+ gs_distance_transform_inverse(floatp dx, floatp dy, register gs_matrix *pmat,
+   register gs_point *pdpt)
+ {	if ( !is_skewed(pmat) )
+ 	   {	pdpt->x = dx / pmat->xx;
+ 		pdpt->y = dy / pmat->yy;
+ 	   }
+ 	else
+ 	   {	double det = pmat->xx * pmat->yy - pmat->xy * pmat->yx;
+ 		if ( det == 0 ) return_error(gs_error_undefinedresult);
+ 		pdpt->x = (dx * pmat->yy - dy * pmat->yx) / det;
+ 		pdpt->y = (dy * pmat->xx - dx * pmat->xy) / det;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Inverse-transform a bounding box. */
+ /* Return gs_error_undefinedresult if the matrix is not invertible. */
+ int
+ gs_bbox_transform_inverse(gs_rect *pbox_in, gs_matrix *pmat,
+   gs_rect *pbox_out)
+ {	int code;
+ 	gs_point p, w, h;
+ 	float xmin, ymin, xmax, ymax;
+ 	/* We must recompute the max and min after transforming, */
+ 	/* since a rotation may be involved. */
+ 	if (	(code = gs_point_transform_inverse(pbox_in->p.x, pbox_in->p.y, pmat, &p)) < 0 ||
+ 		(code = gs_distance_transform_inverse((float)(pbox_in->q.x - pbox_in->p.x), 0.0, pmat, &w)) < 0 ||
+ 		(code = gs_distance_transform_inverse(0.0, (float)(pbox_in->q.y - pbox_in->p.y), pmat, &h)) < 0
+ 	   )
+ 		return code;
+ 	xmin = xmax = p.x;
+ 	if ( w.x < 0 )	xmin += w.x;
+ 	else		xmax += w.x;
+ 	if ( h.x < 0 )	xmin += h.x;
+ 	else		xmax += h.x;
+ 	ymin = ymax = p.y;
+ 	if ( w.y < 0 )	ymin += w.y;
+ 	else		ymax += w.y;
+ 	if ( h.y < 0 )	ymin += h.y;
+ 	else		ymax += h.y;
+ 	pbox_out->p.x = xmin, pbox_out->p.y = ymin;
+ 	pbox_out->q.x = xmax, pbox_out->q.y = ymax;
+ 	return 0;
+ }
+ 
+ /* ------ Coordinate transformations (to fixed point) ------ */
+ 
+ /* Transform a point with a fixed-point result. */
+ int
+ gs_point_transform2fixed(register gs_matrix_fixed *pmat,
+   floatp x, floatp y, gs_fixed_point *ppt)
+ {	ppt->x = float2fixed(x * pmat->xx) + pmat->tx_fixed;
+ 	ppt->y = float2fixed(y * pmat->yy) + pmat->ty_fixed;
+ 	if ( !is_fzero(pmat->yx) )
+ 		ppt->x += float2fixed(y * pmat->yx);
+ 	if ( !is_fzero(pmat->xy) )
+ 		ppt->y += float2fixed(x * pmat->xy);
+ 	return 0;
+ }
+ 
+ /* Transform a distance with a fixed-point result. */
+ int
+ gs_distance_transform2fixed(register gs_matrix_fixed *pmat,
+   floatp dx, floatp dy, gs_fixed_point *ppt)
+ {	ppt->x = float2fixed(dx * pmat->xx);
+ 	ppt->y = float2fixed(dy * pmat->yy);
+ 	if ( !is_fzero(pmat->yx) )
+ 		ppt->x += float2fixed(dy * pmat->yx);
+ 	if ( !is_fzero(pmat->xy) )
+ 		ppt->y += float2fixed(dx * pmat->xy);
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmatrix.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmatrix.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmatrix.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,64 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsmatrix.h */
+ /* Definition of matrices and matrix routines for GhostScript library */
+ 
+ /* See p. 65 of the PostScript manual for the semantics of */
+ /* transformation matrices. */
+ 
+ /* Structure for a transformation matrix. */
+ /* This is a machine-dependent hack to avoid importing */
+ /* the full definition of a GhostScript type-tagged reference. */
+ #define _matrix_body\
+ 	float xx; long _xx /*skip*/;\
+ 	float xy; long _xy /*skip*/;\
+ 	float yx; long _yx /*skip*/;\
+ 	float yy; long _yy /*skip*/;\
+ 	float tx; long _tx /*skip*/;\
+ 	float ty; long _ty /*skip*/
+ typedef struct gs_matrix_s {
+ 	_matrix_body;
+ } gs_matrix;
+ /* Macro for initializing constant matrices */
+ #define constant_matrix_body(xx, xy, yx, yy, tx, ty)\
+ 	(float)(xx),0L, (float)(xy),0L, (float)(yx),0L,\
+ 	(float)(yy),0L, (float)(tx),0L, (float)(ty),0L
+ 
+ /* The identity matrix (for structure initialization) */
+ #define identity_matrix_body\
+ 	constant_matrix_body(1, 0, 0, 1, 0, 0)
+ 
+ /* Matrix creation */
+ void	gs_make_identity(P1(gs_matrix *));
+ int	gs_make_translation(P3(floatp, floatp, gs_matrix *)),
+ 	gs_make_scaling(P3(floatp, floatp, gs_matrix *)),
+ 	gs_make_rotation(P2(floatp, gs_matrix *));
+ 
+ /* Matrix arithmetic */
+ int	gs_matrix_multiply(P3(gs_matrix *, gs_matrix *, gs_matrix *)),
+ 	gs_matrix_invert(P2(gs_matrix *, gs_matrix *)),
+ 	gs_matrix_rotate(P3(gs_matrix *, floatp, gs_matrix *));
+ 
+ /* Coordinate transformation */
+ int	gs_point_transform(P4(floatp, floatp, gs_matrix *, gs_point *)),
+ 	gs_point_transform_inverse(P4(floatp, floatp, gs_matrix *, gs_point *)),
+ 	gs_distance_transform(P4(floatp, floatp, gs_matrix *, gs_point *)),
+ 	gs_distance_transform_inverse(P4(floatp, floatp, gs_matrix *, gs_point *)),
+ 	gs_bbox_transform_inverse(P3(gs_rect *, gs_matrix *, gs_rect *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmisc.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmisc.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsmisc.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,52 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsmisc.c */
+ /* Miscellaneous utilities for GhostScript library */
+ #include "gx.h"
+ #include "malloc_.h"
+ 
+ /* Debugging flags */
+ #ifdef DEBUG
+ char gs_debug[128];
+ #endif
+ 
+ /* Versions of malloc and free compatible with GhostScript's */
+ /* model of memory management. */
+ char *
+ gs_malloc(uint num_elts, uint elt_size, char *client_name)
+ {
+ #ifdef BWGC
+     	extern char *gc_malloc();
+ 	char *ptr = gc_malloc(num_elts * elt_size);
+ #else	
+ 	char *ptr = malloc(num_elts * elt_size);
+ #endif
+ 
+ 	if ( ptr == 0 ) dprintf1("%s: malloc failed\n", client_name);
+ 	return ptr;
+ }
+ void
+ gs_free(char *ptr, uint num_elts, uint elt_size, char *client_name)
+ {
+ #ifdef IGNOREFREE
+ #else    
+     free(ptr);
+ #endif    
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspaint.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspaint.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspaint.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,155 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gspaint.c */
+ /* Painting procedures for GhostScript library */
+ #include "gx.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"			/* for gs_state */
+ #include "gspaint.h"
+ #include "gzpath.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"
+ #include "gzcolor.h"
+ #include "gximage.h"
+ 
+ /* Erase the page */
+ int
+ gs_erasepage(gs_state *pgs)
+ {	device *pdev = pgs->device;
+ 	gx_device *dev = pdev->info;
+ 	(*dev->procs->fill_rectangle)(dev, 0, 0, dev->width, dev->height, pdev->white);
+ 	return 0;
+ }
+ 
+ /* Fill using the winding number rule */
+ int
+ gs_fill(gs_state *pgs)
+ {	return gs_fill_trim(pgs, (fixed)0);
+ }
+ /* This is a hack, see gx_fill_path and gs_type1_interpret. */
+ int
+ gs_fill_trim(gs_state *pgs, fixed trim)
+ {	int code;
+ 	/* If we're inside a charpath, just merge the current path */
+ 	/* into the parent's path. */
+ 	if ( pgs->in_charpath )
+ 		code = gx_path_merge(pgs->path, pgs->saved->path);
+ 	else
+ 	   {	gx_color_render(pgs->color, pgs->dev_color, pgs);
+ 		code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
+ 				    gx_rule_winding_number, trim);
+ 	   }
+ 	if ( !code ) gs_newpath(pgs);
+ 	return code;
+ }
+ 
+ /* Fill using the even/odd rule */
+ int
+ gs_eofill(gs_state *pgs)
+ {	int code;
+ 	gx_color_render(pgs->color, pgs->dev_color, pgs);
+ 	/* If we're inside a charpath, just merge the current path */
+ 	/* into the parent's path. */
+ 	if ( pgs->in_charpath )
+ 		code = gx_path_merge(pgs->path, pgs->saved->path);
+ 	else
+ 	   {	gx_color_render(pgs->color, pgs->dev_color, pgs);
+ 		code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
+ 				    gx_rule_even_odd, (fixed)0);
+ 	   }
+ 	if ( !code ) gs_newpath(pgs);
+ 	return code;
+ }
+ 
+ /* Stroke the current path */
+ int
+ gs_stroke(gs_state *pgs)
+ {	int code;
+ 	/* If we're inside a charpath, just merge the current path */
+ 	/* into the parent's path. */
+ 	if ( pgs->in_charpath )
+ 		code = gx_path_merge(pgs->path, pgs->saved->path);
+ 	else
+ 	   {	gx_color_render(pgs->color, pgs->dev_color, pgs);
+ 		code = gx_stroke_fill(pgs->path, pgs);
+ 	   }
+ 	if ( !code ) gs_newpath(pgs);
+ 	return code;
+ }
+ 
+ /* Compute the stroked outline of the current path */
+ int
+ gs_strokepath(gs_state *pgs)
+ {	gx_path spath;
+ 	int code;
+ 	gx_path_init(&spath, &pgs->memory_procs);
+ 	code = gx_stroke_add(pgs->path, &spath, pgs);
+ 	if ( code < 0 ) return code;
+ 	gx_path_release(pgs->path);
+ 	*pgs->path = spath;
+ 	return 0;
+ }
+ 
+ /* Render a sampled image */
+ int
+ gs_colorimage(gs_state *pgs, int width, int height, int bps, int spp,
+   gs_matrix *pmat, byte *data)
+ {	gs_image_enum ienum;
+ 	int code;
+ 	if ( (code = gs_image_init(&ienum, pgs, width, height, bps, spp, pmat)) < 0 )
+ 		return code;
+ 	if ( spp > 0 )
+ 	   {	uint size =
+ 			(((uint)width * bps * spp + 7) >> 3) * (uint)height;
+ 		code = gs_image_next(&ienum, data, size);
+ 	   }
+ 	else
+ 	   {	/* Deliver the colors separately */
+ 		uint plane_size =
+ 			(((uint)width * bps + 7) >> 3) * (uint)height;
+ 		byte *plane_data = data;
+ 		int count = spp;
+ 		do
+ 		   {	code = gs_image_next(&ienum, plane_data, plane_size);
+ 			if ( code < 0 ) return code;
+ 			plane_data += plane_size;
+ 		   }
+ 		while ( ++count );
+ 	   }
+ 	return (code < 0 ? code : 0);
+ }
+ int
+ gs_image(gs_state *pgs, int width, int height, int bps,
+   gs_matrix *pmat, byte *data)
+ {	return gs_colorimage(pgs, width, height, bps, 1, pmat, data);
+ }
+ 
+ /* Render a mask */
+ int
+ gs_imagemask(gs_state *pgs, int width, int height, int invert,
+   gs_matrix *pmat, byte *data)
+ {	gs_image_enum ienum;
+ 	int code;
+ 	uint size = (((uint)width + 7) >> 3) * (uint)height;
+ 	if ( (code = gs_imagemask_init(&ienum, pgs, width, height, invert, pmat)) < 0 )
+ 		return code;
+ 	code = gs_image_next(&ienum, data, size);
+ 	return (code < 0 ? code : 0);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspaint.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspaint.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspaint.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,39 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gspaint.h */
+ /* Painting interface for GhostScript library */
+ /* Requires gsstate.h and gsmatrix.h */
+ 
+ /* Painting */
+ int	gs_erasepage(P1(gs_state *)),
+ 	gs_fill(P1(gs_state *)),
+ 	gs_eofill(P1(gs_state *)),
+ 	gs_stroke(P1(gs_state *));
+ 
+ /* Image painting */
+ int	gs_colorimage(P7(gs_state *, int, int, int, int, gs_matrix *, byte *)),
+ 	gs_image(P6(gs_state *, int, int, int, gs_matrix *, byte *)),
+ 	gs_imagemask(P6(gs_state *, int, int, int, gs_matrix *, byte *));
+ /* Enumeration-style image painting */
+ typedef struct gs_image_enum_s gs_image_enum;
+ extern int gs_image_enum_sizeof;
+ int	gs_image_init(P7(gs_image_enum *, gs_state *, int, int, int, int, gs_matrix *)),
+ 	gs_imagemask_init(P6(gs_image_enum *, gs_state *, int, int, int, gs_matrix *)),
+ 	gs_image_next(P3(gs_image_enum *, byte *, uint));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,293 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gspath.c */
+ /* Path construction routines for GhostScript library */
+ #include "math_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gxpath.h"
+ #include "gzstate.h"
+ 
+ /* Conversion parameters */
+ #define degrees_to_radians (M_PI / 180.0)
+ 
+ /* ------ Miscellaneous ------ */
+ 
+ int
+ gs_newpath(gs_state *pgs)
+ {	gx_path_release(pgs->path);
+ 	gx_path_init(pgs->path, &pgs->memory_procs);
+ 	return 0;
+ }
+ 
+ int
+ gs_closepath(gs_state *pgs)
+ {	return gx_path_close_subpath(pgs->path);
+ }
+ 
+ /* ------ Points and lines ------ */
+ 
+ int
+ gs_currentpoint(gs_state *pgs, gs_point *ppt)
+ {	gs_fixed_point pt;
+ 	int code = gx_path_current_point(pgs->path, &pt);
+ 	if ( code < 0 ) return code;
+ 	return gs_itransform(pgs, fixed2float(pt.x), fixed2float(pt.y), ppt);
+ }
+ 
+ int
+ gs_moveto(gs_state *pgs, floatp x, floatp y)
+ {	int code;
+ 	gs_fixed_point pt;
+ 	if ( (code = gs_point_transform2fixed(&pgs->ctm, x, y, &pt)) >= 0 )
+ 		code = gx_path_add_point(pgs->path, pt.x, pt.y);
+ 	return code;
+ }
+ 
+ int
+ gs_rmoveto(gs_state *pgs, floatp x, floatp y)
+ {	int code;
+ 	gs_fixed_point dpt;
+ 	if ( (code = gs_distance_transform2fixed(&pgs->ctm, x, y, &dpt)) >= 0 )
+ 		code = gx_path_add_relative_point(pgs->path, dpt.x, dpt.y);
+ 	return code;
+ }
+ 
+ int
+ gs_lineto(gs_state *pgs, floatp x, floatp y)
+ {	int code;
+ 	gs_fixed_point pt;
+ 	if ( (code = gs_point_transform2fixed(&pgs->ctm, x, y, &pt)) >= 0 )
+ 		code = gx_path_add_line(pgs->path, pt.x, pt.y);
+ 	return code;
+ }
+ 
+ int
+ gs_rlineto(gs_state *pgs, floatp x, floatp y)
+ {	gs_fixed_point cpt, dpt;
+ 	int code = gx_path_current_point(pgs->path, &cpt);
+ 	if ( code < 0 ) return code;
+ 	if ( (code = gs_distance_transform2fixed(&pgs->ctm, x, y, &dpt)) >= 0 )
+ 		code = gx_path_add_line(pgs->path, cpt.x + dpt.x, cpt.y + dpt.y);
+ 	return code;
+ }
+ 
+ /* ------ Arcs ------ */
+ 
+ /* Forward declarations */
+ private int arc_either(P7(gs_state *,
+   floatp, floatp, floatp, floatp, floatp, int));
+ private int arc_add(P8(gs_state *,
+   floatp, floatp, floatp, floatp, floatp, floatp, int));
+ 
+ int
+ gs_arc(gs_state *pgs,
+   floatp xc, floatp yc, floatp r, floatp ang1, floatp ang2)
+ {	return arc_either(pgs, xc, yc, r, ang1, ang2, 0);
+ }
+ 
+ int
+ gs_arcn(gs_state *pgs,
+   floatp xc, floatp yc, floatp r, floatp ang1, floatp ang2)
+ {	return arc_either(pgs, xc, yc, r, ang1, ang2, 1);
+ }
+ 
+ private int
+ arc_either(gs_state *pgs,
+   floatp axc, floatp ayc, floatp ar, floatp aang1, floatp aang2,
+   int clockwise)
+ {	fixed ang1 = float2fixed(aang1), ang2 = float2fixed(aang2), adiff;
+ 	float ang1r;
+ 	float x0, y0, sin0, cos0;
+ 	float x3r, y3r;
+ 	int first = 1;
+ 	int code;
+ 	if ( ar < 0 ) return_error(gs_error_rangecheck);
+ #define fixed90 int2fixed(90)
+ #define fixed360 int2fixed(360)
+ 	/* Reduce the arc to at most 360 degrees. */
+ 	if ( ang1 != ang2 )
+ 	   {	ang1 %= fixed360;
+ 		ang2 %= fixed360;
+ 		if ( clockwise )
+ 		   {	if ( ang2 >= ang1 ) ang1 += fixed360;
+ 		   }
+ 		else
+ 		   {	if ( ang2 <= ang1 ) ang2 += fixed360;
+ 		   }
+ 	   }
+ 	ang1r = fixed2float(ang1) * degrees_to_radians;
+ 	sin0 = ar * sin(ang1r), cos0 = ar * cos(ang1r);
+ 	x0 = axc + cos0, y0 = ayc + sin0;
+ 	if ( clockwise )
+ 	   {	/* Quadrant reduction */
+ 		while ( (adiff = ang2 - ang1) < -fixed90 )
+ 		   {	float w = sin0; sin0 = -cos0; cos0 = w;
+ 			x3r = axc + cos0, y3r = ayc + sin0;
+ 			/* Must cast doubles to floats explicitly */
+ 			code = arc_add(pgs, x0, y0, x3r, y3r,
+ 				(x0 + cos0),
+ 				(y0 + sin0),
+ 				first);
+ 			if ( code < 0 ) return code;
+ 			x0 = x3r, y0 = y3r;
+ 			ang1 -= fixed90;
+ 			first = 0;
+ 		   }
+ 	   }
+ 	else
+ 	   {	/* Quadrant reduction */
+ 		while ( (adiff = ang2 - ang1) > fixed90 )
+ 		   {	float w = cos0; cos0 = -sin0; sin0 = w;
+ 			x3r = axc + cos0, y3r = ayc + sin0;
+ 			/* Must cast doubles to floats explicitly */
+ 			code = arc_add(pgs, x0, y0, x3r, y3r,
+ 				(x0 + cos0),
+ 				(y0 + sin0),
+ 				first);
+ 			if ( code < 0 ) return code;
+ 			x0 = x3r, y0 = y3r;
+ 			ang1 += fixed90;
+ 			first = 0;
+ 		   }
+ 	   }
+ 	if ( adiff == 0 ) return 0;		/* exact multiple of 90 */
+ 	/* Compute the intersection of the tangents. */
+ 	   {	float trad = tan(fixed2float(adiff) * (degrees_to_radians / 2));
+ 		float ang2r = fixed2float(ang2) * degrees_to_radians;
+ 		code = arc_add(pgs, x0, y0,
+ 			(axc + ar * cos(ang2r)),
+ 			(ayc + ar * sin(ang2r)),
+ 			(x0 - trad * sin0),
+ 			(y0 + trad * cos0),
+ 			first);
+ 	   }
+ 	return code;
+ }
+ 
+ int
+ gs_arcto(gs_state *pgs,
+   floatp ax1, floatp ay1, floatp ax2, floatp ay2, floatp arad,
+   float *retxy)			/* float retxy[4] */
+ {	float xt0, yt0, xt2, yt2;
+ 	gs_point up0;
+ #define ax0 up0.x
+ #define ay0 up0.y
+ 	int code;
+ 	if ( arad < 0 )
+ 		return_error(gs_error_undefinedresult);
+ 	/* Transform the current point back into user coordinates */
+ 	if ( (code = gs_currentpoint(pgs, &up0)) < 0 ) return code;
+ 	   {	/* Now we have to compute the tangent points. */
+ 		/* Basically, the idea is to compute the tangent */
+ 		/* of the bisector by using tan(x+y) and tan(z/2) */
+ 		/* formulas, without ever using any trig. */
+ 		float dx0 = ax0 - ax1, dy0 = ay0 - ay1;
+ 		float dx2 = ax2 - ax1, dy2 = ay2 - ay1;
+ 		/* Compute the squared lengths from p1 to p0 and p2. */
+ 		double sql0 = dx0 * dx0 + dy0 * dy0;
+ 		double sql2 = dx2 * dx2 + dy2 * dy2;
+ 		/* Compute the distance from p1 to the tangent points. */
+ 		/* This is the only hairy part. */
+ 		double num = dy0 * dx2 - dy2 * dx0;
+ 		double denom = sqrt(sql0 * sql2) - (dx0 * dx2 + dy0 * dy2);
+ 		/* Check for collinear points. */
+ 		if ( fabs(num) < 1.0e-6 || fabs(denom) < 1.0e-6)
+ 		   {	gs_fixed_point pt;
+ 			code = gs_point_transform2fixed(&pgs->ctm, ax1, ay1, &pt);
+ 			if ( code >= 0 ) code = gx_path_add_line(pgs->path, pt.x, pt.y);
+ 			xt0 = xt2 = ax1;
+ 			yt0 = yt2 = ay1;
+ 		   }
+ 		else		/* not collinear */
+ 		   {	double dist = fabs(arad * num / denom);
+ 			double l0 = dist / sqrt(sql0), l2 = dist / sqrt(sql2);
+ 			xt0 = ax1 + dx0 * l0;
+ 			yt0 = ay1 + dy0 * l0;
+ 			xt2 = ax1 + dx2 * l2;
+ 			yt2 = ay1 + dy2 * l2;
+ 			code = arc_add(pgs, xt0, yt0, xt2, yt2, ax1, ay1, 1);
+ 		   }
+ 	   }
+ 	if ( retxy != 0 )
+ 	   {	retxy[0] = xt0;
+ 		retxy[1] = yt0;
+ 		retxy[2] = xt2;
+ 		retxy[3] = yt2;
+ 	   }
+ 	return code;
+ }
+ 
+ /* Internal routine for adding an arc to the path. */
+ private int
+ arc_add(gs_state *pgs,
+   floatp x0, floatp y0, floatp x3, floatp y3, floatp xt, floatp yt,
+   int first)
+ {	gx_path *path = pgs->path;
+ 	int code;
+ 	gs_fixed_point p0, p3, pt, cpt;
+ #ifdef DEBUG
+ if ( gs_debug['r'] )
+ 	printf("[r]Arc p0=(%f,%f) pt=(%f,%f) p3=(%f,%f) first=%d\n",
+ 		x0, y0, xt, yt, x3, y3, first);
+ #endif
+ 	if (	(code = gs_point_transform2fixed(&pgs->ctm, x0, y0, &p0)) < 0 ||
+ 		(code = gs_point_transform2fixed(&pgs->ctm, x3, y3, &p3)) < 0 ||
+ 		(code = gs_point_transform2fixed(&pgs->ctm, xt, yt, &pt)) < 0 ||
+ 		(first && (code = (gx_path_current_point(path, &cpt) >= 0 ?
+ 			 gx_path_add_line(path, p0.x, p0.y) :
+ 			 gx_path_add_point(path, p0.x, p0.y))) < 0)
+ 	   )
+ 		return code;
+ 	return gx_path_add_arc(path, p0.x, p0.y, p3.x, p3.y, pt.x, pt.y);
+ }
+ 
+ /* ------ Curves ------ */
+ 
+ int
+ gs_curveto(gs_state *pgs,
+   floatp x1, floatp y1, floatp x2, floatp y2, floatp x3, floatp y3)
+ {	gs_fixed_point p1, p2, p3;
+ 	int code;
+ 	if (	(code = gs_point_transform2fixed(&pgs->ctm, x1, y1, &p1)) < 0 ||
+ 		(code = gs_point_transform2fixed(&pgs->ctm, x2, y2, &p2)) < 0 ||
+ 		(code = gs_point_transform2fixed(&pgs->ctm, x3, y3, &p3)) < 0
+ 	   ) return code;
+ 	return gx_path_add_curve(pgs->path,
+ 		p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
+ }
+ 
+ int
+ gs_rcurveto(gs_state *pgs,
+   floatp dx1, floatp dy1, floatp dx2, floatp dy2, floatp dx3, floatp dy3)
+ {	gs_fixed_point pt, p1, p2, p3;
+ 	int code = gx_path_current_point(pgs->path, &pt);
+ 	if ( code < 0 ) return code;
+ 	if (	(code = gs_distance_transform2fixed(&pgs->ctm, dx1, dy1, &p1)) < 0 ||
+ 		(code = gs_distance_transform2fixed(&pgs->ctm, dx2, dy2, &p2)) < 0 ||
+ 		(code = gs_distance_transform2fixed(&pgs->ctm, dx3, dy3, &p3)) < 0
+ 	   ) return code;
+ 	return gx_path_add_curve(pgs->path,
+ 		pt.x + p1.x, pt.y + p1.y,
+ 		pt.x + p2.x, pt.y + p2.y,
+ 		pt.x + p3.x, pt.y + p3.y);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,58 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gspath.h */
+ /* Path manipulation interface for GhostScript library */
+ /* Requires gsstate.h */
+ 
+ /* Path constructors */
+ extern	int	gs_newpath(P1(gs_state *)),
+ 		gs_moveto(P3(gs_state *, floatp, floatp)),
+ 		gs_rmoveto(P3(gs_state *, floatp, floatp)),
+ 		gs_lineto(P3(gs_state *, floatp, floatp)),
+ 		gs_rlineto(P3(gs_state *, floatp, floatp)),
+ 		gs_arc(P6(gs_state *, floatp, floatp, floatp, floatp, floatp)),
+ 		gs_arcn(P6(gs_state *, floatp, floatp, floatp, floatp, floatp)),
+ 		gs_arcto(P7(gs_state *, floatp, floatp, floatp, floatp, floatp, float [4])),
+ 		gs_curveto(P7(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp)),
+ 		gs_rcurveto(P7(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp)),
+ 		gs_closepath(P1(gs_state *));
+ 
+ /* Path accessors and transformers */
+ extern	int	gs_currentpoint(P2(gs_state *, gs_point *)),
+ 		gs_pathbbox(P2(gs_state *, gs_rect *)),
+ 		gs_flattenpath(P1(gs_state *)),
+ 		gs_reversepath(P1(gs_state *)),
+ 		gs_strokepath(P1(gs_state *));
+ 
+ /* Path enumeration */
+ #define gs_pe_moveto 1
+ #define gs_pe_lineto 2
+ #define gs_pe_curveto 3
+ #define gs_pe_closepath 4
+ typedef struct gs_path_enum_s gs_path_enum;
+ extern int gs_path_enum_sizeof;
+ void	gs_path_enum_init(P2(gs_path_enum *, gs_state *));
+ int	gs_path_enum_next(P2(gs_path_enum *, gs_point [3])); /* 0 when done */
+ 
+ /* Clipping */
+ extern	int	gs_clippath(P1(gs_state *)),
+ 		gs_initclip(P1(gs_state *)),
+ 		gs_clip(P1(gs_state *)),
+ 		gs_eoclip(P1(gs_state *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath2.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath2.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gspath2.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,197 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gspath2.c */
+ /* Non-constructor path routines for GhostScript library */
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gspath.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"
+ #include "gzpath.h"
+ #include "gzdevice.h"
+ 
+ /* Forward declarations */
+ private int common_clip(P2(gs_state *, int));
+ private int set_clip_path(P3(gs_state *, gx_path *, int));
+ 
+ /* Path enumeration structure */
+ struct gs_path_enum_s {
+ 	segment *pseg;
+ 	gs_state *pgs;
+ };
+ 
+ /* Size of path enumeration structure, so clients can allocate */
+ int gs_path_enum_sizeof = sizeof(gs_path_enum);
+ 
+ /* ------ Path transformers ------ */
+ 
+ int
+ gs_flattenpath(gs_state *pgs)
+ {	gx_path fpath;
+ 	int code;
+ 	if ( !pgs->path->curve_count ) return 0;	/* no curves */
+ 	code = gx_path_flatten(pgs->path, &fpath, pgs->flatness);
+ 	if ( code < 0 ) return code;
+ 	gx_path_release(pgs->path);
+ 	*pgs->path = fpath;
+ 	return 0;
+ }
+ 
+ int
+ gs_reversepath(gs_state *pgs)
+ {	return_error(gs_error_undefined);		/* NYI */
+ }
+ 
+ /* ------ Accessors ------ */
+ 
+ int
+ gs_pathbbox(gs_state *pgs, gs_rect *pbox)
+ {	gs_fixed_rect fbox;		/* box in device coordinates */
+ 	gs_rect dbox;
+ 	int code = gx_path_bbox(pgs->path, &fbox);
+ 	if ( code < 0 ) return code;
+ 	/* Transform the result back to user coordinates. */
+ 	dbox.p.x = fixed2float(fbox.p.x);
+ 	dbox.p.y = fixed2float(fbox.p.y);
+ 	dbox.q.x = fixed2float(fbox.q.x);
+ 	dbox.q.y = fixed2float(fbox.q.y);
+ 	return gs_bbox_transform_inverse(&dbox, &ctm_only(pgs), pbox);
+ }
+ 
+ /* ------ Enumerators ------ */
+ 
+ /* Start enumerating a path */
+ void
+ gs_path_enum_init(gs_path_enum *penum, gs_state *pgs)
+ {	penum->pseg = (segment *)pgs->path->first_subpath;
+ 	penum->pgs = pgs;
+ }
+ 
+ /* Enumerate the next element of a path. */
+ /* If the path is finished, return 0; */
+ /* otherwise, return the element type. */
+ int
+ gs_path_enum_next(gs_path_enum *penum, gs_point ppts[3])
+ {	segment *pseg = penum->pseg;
+ 	gs_state *pgs = penum->pgs;
+ 	gs_point pt;
+ 	int code;
+ 	if ( pseg == 0 ) return 0;	/* finished */
+ 	penum->pseg = pseg->next;
+ 	if ( pseg->type == s_line_close )
+ 	  return gs_pe_closepath;
+ 	if ( (code = gs_itransform(pgs, fixed2float(pseg->pt.x),
+ 				   fixed2float(pseg->pt.y), &pt)) < 0 )
+ 	  return code;
+ 	switch ( pseg->type )
+ 	   {
+ 	case s_start:
+ 	     ppts[0] = pt;
+ 	     return gs_pe_moveto;
+ 	case s_line:
+ 	     ppts[0] = pt;
+ 	     return gs_pe_lineto;
+ 	case s_curve:
+ #define pcurve ((curve_segment *)pseg)
+ 	     if ( (code =
+ 		   gs_itransform(pgs, fixed2float(pcurve->p1.x),
+ 				 fixed2float(pcurve->p1.y), &ppts[0])) < 0 ||
+ 		  (code =
+ 		   gs_itransform(pgs, fixed2float(pcurve->p2.x),
+ 				 fixed2float(pcurve->p2.y), &ppts[1])) < 0 )
+ 	       return 0;
+ 	     ppts[2] = pt;
+ 	     return gs_pe_curveto;
+ #undef pcurve
+ 	default:
+ 	     dprintf1("bad type %x in gs_path_enum_next!\n", pseg->type);
+ 	     exit(1);
+ 	   }
+ }
+ 
+ /* ------ Clipping ------ */
+ 
+ int
+ gs_clippath(gs_state *pgs)
+ {	return gx_path_copy(pgs->clip_path, pgs->path);
+ }
+ 
+ int
+ gs_initclip(gs_state *pgs)
+ {	gx_device *dev = pgs->device->info;
+ 	return gx_clip_to_rectangle(pgs, (fixed)0, (fixed)0, int2fixed(dev->width), int2fixed(dev->height));
+ }
+ 
+ int
+ gs_clip(gs_state *pgs)
+ {	return common_clip(pgs, gx_rule_winding_number);
+ }
+ 
+ int
+ gs_eoclip(gs_state *pgs)
+ {	return common_clip(pgs, gx_rule_even_odd);
+ }
+ 
+ /* ------ Internal routines for clipping ------ */
+ 
+ /* Establish a rectangle as the clipping path. */
+ /* Used by initclip and by the character cache logic. */
+ int
+ gx_clip_to_rectangle(gs_state *pgs, fixed x0, fixed y0, fixed x1, fixed y1)
+ {	gx_path cpath;
+ 	gx_path *ppath = &cpath;
+ 	int code;
+ 	gx_path_init(ppath, &pgs->memory_procs);
+ 	if ( (code = gx_path_add_rectangle(ppath, x0, y0, x1, y1)) < 0 )
+ 	   {	gx_path_release(ppath);
+ 		return code;
+ 	   }
+ 	gx_path_release(pgs->clip_path);
+ 	return set_clip_path(pgs, ppath, gx_rule_winding_number);
+ }
+ 
+ /* Main clipping routine.  NOT CORRECT. */
+ private int
+ common_clip(gs_state *pgs, int rule)
+ {	gx_path cpath;
+ 	int code = gx_path_flatten(pgs->path, &cpath, pgs->flatness);
+ 	if ( !code ) code = set_clip_path(pgs, &cpath, rule);
+ 	return code;
+ }
+ /* Set the clipping path.  If it is just a rectangle, */
+ /* set the parameters for the quick clipping check. */
+ private int
+ set_clip_path(gs_state *pgs, register gx_path *ppath, int rule)
+ {	if ( !gx_path_is_rectangle(ppath, &ppath->cbox) )
+ 	   {	/* Not a rectangle, the quick check must fail */
+ 		ppath->cbox.p.x = ppath->cbox.p.y = 0;
+ 		ppath->cbox.q.x = ppath->cbox.q.y = 0;
+ 	   }
+ 	/* Update the outer bounding box as well. */
+ 	gx_path_bbox(ppath, &ppath->bbox);
+ 	*pgs->clip_path = *ppath;
+ 	pgs->clip_rule = rule;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	printf("[p]Clipping path:\n"), gx_path_print(stdout, pgs->clip_path);
+ #endif
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsstate.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsstate.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsstate.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,196 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsstate.c */
+ /* Miscellaneous graphics state operators for GhostScript library */
+ #include "gx.h"
+ #include "memory_.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"			/* for gzstate */
+ #include "gzstate.h"
+ #include "gzdevice.h"
+ #include "gzcolor.h"			/* requires gxdevice.h */
+ #include "gzht.h"
+ #include "gzline.h"
+ #include "gzpath.h"
+ 
+ /* Size of graphics state object (so clients can copy the top level) */
+ unsigned gs_state_sizeof = sizeof(gs_state);
+ 
+ /* Forward references */
+ private int alloc_state_contents(P2(gs_state *, proc_alloc_t));
+ private void free_state_contents(P1(gs_state *));
+ 
+ /* Allocate and initialize a graphics state */
+ gs_state *
+ gs_state_alloc(proc_alloc_t palloc, proc_free_t pfree)
+ {	register gs_state *pgs = (gs_state *)(*palloc)(1, sizeof(gs_state), "gs_state_alloc");
+ 	if ( pgs == 0 ) return 0;
+ 	if ( alloc_state_contents(pgs, palloc) < 0 ) return 0;
+ 	pgs->saved = 0;
+ 	pgs->memory_procs.alloc = palloc;
+ 	pgs->memory_procs.free = pfree;
+ 	/* Initialize things not covered by initgraphics */
+ 	pgs->path->first_subpath = 0;
+ 	pgs->clip_path->first_subpath = 0;
+ 	pgs->halftone->width = pgs->halftone->height =
+ 		pgs->halftone->order_size = 0;
+ 	gs_nulldevice(pgs);
+ 	gs_setflat(pgs, 1.0);
+ 	/****** What about the font and transfer function ? ******/
+ 	pgs->in_cachedevice = pgs->in_charpath = 0;
+ 	if ( gs_initgraphics(pgs) < 0 )
+ 	   {	/* Something went very wrong */
+ 		return 0;
+ 	   }
+ 	return pgs;
+ }
+ 
+ /* Free a graphics state */
+ int
+ gs_state_free(gs_state *pgs)
+ {	free_state_contents(pgs);
+ 	(*pgs->memory_procs.free)((char *)pgs, 1, sizeof(gs_state), "gs_state_free");
+ 	return 0;
+ }
+ 
+ /* Save the graphics state */
+ int
+ gs_gsave(gs_state *pgs)
+ {	gs_state *pnew = (gs_state *)(*pgs->memory_procs.alloc)(1, sizeof(gs_state), "gs_gsave");
+ 	if ( pnew == 0 ) return_error(gs_error_VMerror);
+ 	*pnew = *pgs;
+ 	if ( alloc_state_contents(pgs, pgs->memory_procs.alloc) < 0 ) return_error(gs_error_VMerror);
+ #define gcopy(element,type)\
+     *pgs->element = *pnew->element
+ 	gcopy(path, gx_path);
+ 	gcopy(clip_path, gx_path);
+ 	gcopy(line_params, line_params);
+ 	gcopy(halftone, halftone);
+ 	gcopy(color, gs_color);
+ 	gcopy(dev_color, gx_device_color);
+ 	gcopy(device, device);
+ #undef gcopy
+ 	gx_path_share(pgs->path);
+ 	gx_path_share(pgs->clip_path);
+ 	pgs->saved = pnew;
+ 	return 0;
+ }
+ 
+ /* Restore the graphics state */
+ int
+ gs_grestore(gs_state *pgs)
+ {	gs_state *saved = pgs->saved;
+ 	if ( saved == 0 ) return_error(gs_error_undefinedresult);	/* adhoc */
+ 	free_state_contents(pgs);
+ 	*pgs = *saved;
+ 	(*pgs->memory_procs.free)((char *)saved, 1, sizeof(gs_state), "gs_grestore");
+ 	return 0;
+ }
+ 
+ /* Restore to the bottommost graphics state */
+ int
+ gs_grestoreall(gs_state *pgs)
+ {	while ( gs_grestore(pgs) >= 0 ) ;
+ 	return 0;
+ }
+ 
+ /* Swap the saved pointer of the graphics state. */
+ /* This is provided only for save/restore. */
+ gs_state *
+ gs_state_swap_saved(gs_state *pgs, gs_state *new_saved)
+ {	gs_state *saved = pgs->saved;
+ 	pgs->saved = new_saved;
+ 	return saved;
+ }
+ 
+ /* Reset most of the graphics state */
+ int
+ gs_initgraphics(register gs_state *pgs)
+ {	int code;
+ 	gs_initmatrix(pgs);
+ 	if (	(code = gs_newpath(pgs)) < 0 ||
+ 		(code = gs_initclip(pgs)) < 0 ||
+ 		(code = gs_setlinewidth(pgs, 1.0)) < 0 ||
+ 		(code = gs_setlinecap(pgs, gs_cap_butt)) < 0 ||
+ 		(code = gs_setlinejoin(pgs, gs_join_miter)) < 0 ||
+ 		(code = gs_setdash(pgs, (float *)0, 0, 0.0)) < 0 ||
+ 		(code = gs_setgray(pgs, 0.0)) < 0 ||
+ 		(code = gs_setmiterlimit(pgs, 10.0)) < 0
+ 	   ) return code;
+ 	return 0;
+ }
+ 
+ /* setflat */
+ int
+ gs_setflat(gs_state *pgs, floatp flat)
+ {	if ( flat <= 0 ) return_error(gs_error_rangecheck);
+ 	pgs->flatness = flat;
+ 	return 0;
+ }
+ 
+ /* currentflat */
+ float
+ gs_currentflat(gs_state *pgs)
+ {	return pgs->flatness;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Allocate the contents of a graphics state object. */
+ /* Return -1 if the allocation fails. */
+ private int
+ alloc_state_contents(gs_state *pgs, proc_alloc_t palloc)
+ {	char *elt;
+ 	static char *cname = "(gs)alloc_state_contents";
+ #define galloc(element,type)\
+     if ( (elt = (*palloc)(1, sizeof(type), cname)) == 0 ) return -1;\
+     pgs->element = (type *)elt
+ 	galloc(path, gx_path);
+ 	galloc(clip_path, gx_path);
+ 	galloc(line_params, line_params);
+ 	galloc(halftone, halftone);
+ 	galloc(color, gs_color);
+ 	galloc(dev_color, gx_device_color);
+ 	galloc(device, device);
+ #undef galloc
+ 	pgs->device_is_shared = 0;
+ 	return 0;
+ }
+ 
+ /* Free the contents of a graphics state, but not the state itself. */
+ private void
+ free_state_contents(gs_state *pgs)
+ {	proc_free_t pfree = pgs->memory_procs.free;
+ 	static char *cname = "(gs)free_state_contents";
+ 	gx_path_release(pgs->clip_path);
+ 	gx_path_release(pgs->path);
+ #define gfree(element,type)\
+     (*pfree)((char *)pgs->element, 1, sizeof(type), cname)
+ 	if ( !pgs->device_is_shared )
+ 		gfree(device, device);
+ 	gfree(dev_color, gx_device_color);
+ 	gfree(color, gs_color);
+ 	gfree(halftone, halftone);
+ 	gfree(line_params, line_params);
+ 	gfree(clip_path, gx_path);
+ 	gfree(path, gx_path);
+ #undef gfree
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsstate.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsstate.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gsstate.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,99 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gsstate.h */
+ /* Graphics state routines for GhostScript library */
+ 
+ /* Opaque type for a graphics state */
+ /*typedef struct gs_state_s gs_state;*/	/* define in gs.h */
+ extern uint gs_state_sizeof;
+ 
+ /* Line cap values */
+ typedef enum {
+ 	gs_cap_butt = 0,
+ 	gs_cap_round = 1,
+ 	gs_cap_square = 2
+ } gs_line_cap;
+ 
+ /* Line join values */
+ typedef enum {
+ 	gs_join_miter = 0,
+ 	gs_join_round = 1,
+ 	gs_join_bevel = 2
+ } gs_line_join;
+ 
+ /* Allocation, freeing, and initialization */
+ gs_state *gs_state_alloc(P2(proc_alloc_t, proc_free_t)); /* 0 if fails */
+ int	gs_state_free(P1(gs_state *));
+ int	gs_gsave(P1(gs_state *)),
+ 	gs_grestore(P1(gs_state *)),
+ 	gs_grestoreall(P1(gs_state *));
+ gs_state *gs_state_swap_saved(P2(gs_state *, gs_state *));	/* special for save/restore */
+ int	gs_initgraphics(P1(gs_state *));
+ /* Device control */
+ typedef struct gx_device_s gx_device;
+ int	gs_flushpage(P1(gs_state *));
+ int	gs_copypage(P1(gs_state *));
+ int	gs_copyscanlines(P6(gx_device *, int, byte *, uint, int *, uint *));
+ gx_device *	gs_getdevice(P1(int));
+ int	gs_makedevice(P6(gx_device **, gx_device *, gs_matrix *, uint, uint, proc_alloc_t));
+ int	gs_makeimagedevice(P7(gx_device **, gs_matrix *, uint, uint, float *, int, proc_alloc_t));
+ void	gs_nulldevice(P1(gs_state *));
+ int	gs_setdevice(P2(gs_state *, gx_device *));
+ gx_device *	gs_currentdevice(P1(gs_state *));
+ char *	gs_devicename(P1(gx_device *));
+ void	gs_deviceparams(P4(gx_device *, gs_matrix *, int *, int *));
+ 
+ /* Line parameters and quality */
+ int	gs_setlinewidth(P2(gs_state *, floatp));
+ float	gs_currentlinewidth(P1(gs_state *));
+ int	gs_setlinecap(P2(gs_state *, gs_line_cap));
+ gs_line_cap	gs_currentlinecap(P1(gs_state *));
+ int	gs_setlinejoin(P2(gs_state *, gs_line_join));
+ gs_line_join	gs_currentlinejoin(P1(gs_state *));
+ int	gs_setmiterlimit(P2(gs_state *, floatp));
+ float	gs_currentmiterlimit(P1(gs_state *));
+ int	gs_setdash(P4(gs_state *, float *, uint, floatp));
+ uint	gs_currentdash_length(P1(gs_state *));
+ int	gs_currentdash_pattern(P2(gs_state *, float *));
+ float	gs_currentdash_offset(P1(gs_state *));
+ int	gs_setflat(P2(gs_state *, floatp));
+ float	gs_currentflat(P1(gs_state *));
+ 
+ /* Color and gray */
+ typedef struct gs_color_s gs_color;
+ extern int gs_color_sizeof;
+ int	gs_setgray(P2(gs_state *, floatp));
+ float	gs_currentgray(P1(gs_state *));
+ int	gs_setgscolor(P2(gs_state *, gs_color *)),
+ 	gs_currentgscolor(P2(gs_state *, gs_color *)),
+ 	gs_sethsbcolor(P4(gs_state *, floatp, floatp, floatp)),
+ 	gs_currenthsbcolor(P2(gs_state *, float [3])),
+ 	gs_setrgbcolor(P4(gs_state *, floatp, floatp, floatp)),
+ 	gs_currentrgbcolor(P2(gs_state *, float [3]));
+ 
+ /* Halftone screen */
+ int	gs_setscreen(P4(gs_state *, floatp, floatp, float (*)(P2(floatp, floatp))));
+ int	gs_currentscreen(P4(gs_state *, float *, float *, float (**)(P2(floatp, floatp))));
+ /* Enumeration-style screen definition */
+ typedef struct gs_screen_enum_s gs_screen_enum;
+ extern int gs_screen_enum_sizeof;
+ int	gs_screen_init(P4(gs_screen_enum *, gs_state *, floatp, floatp));
+ int	gs_screen_currentpoint(P2(gs_screen_enum *, gs_point *));
+ int	gs_screen_next(P2(gs_screen_enum *, floatp));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gstype1.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gstype1.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gstype1.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,538 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gstype1.c */
+ /* Adobe Type 1 font routines for GhostScript library */
+ #include "math_.h"
+ #include "memory_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxarith.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"			/* for gxchar */
+ #include "gxdevmem.h"			/* ditto */
+ #include "gzpath.h"
+ #include "gxchar.h"
+ #include "gxfont1.h"
+ #include "gxtype1.h"
+ 
+ /* Encrypt a string. */
+ int
+ gs_type1_encrypt(byte *dest, byte *src, uint len, crypt_state *pstate)
+ {	register crypt_state state = *pstate;
+ 	register byte *from = src;
+ 	register byte *to = dest;
+ 	register uint count = len;
+ 	while ( count )
+ 	   {	encrypt_next(*from, state, *to);
+ 		from++, to++, count--;
+ 	   }
+ 	*pstate = state;
+ 	return 0;
+ }
+ /* Decrypt a string. */
+ int
+ gs_type1_decrypt(byte *dest, byte *src, uint len, crypt_state *pstate)
+ {	register crypt_state state = *pstate;
+ 	register byte *from = src;
+ 	register byte *to = dest;
+ 	register uint count = len;
+ 	while ( count )
+ 	   {	/* If from == to, we can't use the obvious */
+ 		/*	decrypt_next(*from, state, *to);	*/
+ 		register byte ch = *from++;
+ 		decrypt_next(ch, state, *to);
+ 		to++, count--;
+ 	   }
+ 	*pstate = state;
+ 	return 0;
+ }
+ 
+ /* Define the structures for the state of a Type 1 interpreter. */
+ /* This is the interpreter state that must be saved and restored */
+ /* when calling a CharString subroutine. */
+ typedef struct {
+ 	byte *ip;
+ 	crypt_state dstate;
+ } ip_state;
+ /* Define the fixed-point coefficient structure */
+ /* for avoiding floating point. */
+ #define max_coeff_bits 11		/* max coefficient in char space */
+ typedef struct {
+ 	long xx, xy, yx, yy;
+ 	int skewed;
+ 	int shift;			/* see below */
+ 	fixed round;			/* see below */
+ } fixed_coeff;
+ /* This is the full state of the Type 1 interpreter. */
+ struct gs_type1_state_s {
+ 		/* The following are set at initialization */
+ 	gs_show_enum *penum;		/* show enumerator */
+ 	gs_state *pgs;			/* graphics state */
+ 	gs_type1_data *pdata;		/* font-specific data */
+ 	int charpath_flag;		/* 0 for show, 1 for false */
+ 					/* charpath, 2 for true charpath */
+ 	int paint_type;			/* 0 for fill, non-0 for stroke */
+ 	fixed_coeff fc;			/* cached fixed coefficients */
+ 		/* The following are updated dynamically */
+ #define ostack_size 24
+ 	fixed ostack[ostack_size];	/* the Type 1 operand stack */
+ 	int os_count;			/* # of occupied stack entries */
+ #define ipstack_size 10
+ 	ip_state ipstack[ipstack_size+1];	/* control stack */
+ 	int ips_count;			/* # of occupied entries */
+ 	int ip_skip;			/* # of bytes to skip */
+ 	gs_fixed_point lsb;		/* left side bearing */
+ 	gs_fixed_point width;		/* character width */
+ 	int seac_base;			/* base character code for seac, */
+ 					/* or -1 */
+ };
+ 
+ /* Export the size of the structure */
+ int gs_type1_state_sizeof = sizeof(gs_type1_state);
+ 
+ /* Initialize the cached matrix in a Type 1 interpreter */
+ /* from the matrix in the graphics state. */
+ int
+ gs_type1_init_matrix(register gs_type1_state *pis)
+ {	gs_matrix ctm;
+ 	int scale = -10000;
+ 	int expt, shift;
+ 	ctm = ctm_only(pis->pgs);
+ 	pis->fc.skewed = 0;
+ 	if ( !is_fzero(ctm.xx) )
+ 	   {	(void)frexp(ctm.xx, &scale);
+ 	   }
+ 	if ( !is_fzero(ctm.xy) )
+ 	   {	(void)frexp(ctm.xy, &expt);
+ 		if ( expt > scale ) scale = expt;
+ 		pis->fc.skewed = 1;
+ 	   }
+ 	if ( !is_fzero(ctm.yx) )
+ 	   {	(void)frexp(ctm.yx, &expt);
+ 		if ( expt > scale ) scale = expt;
+ 		pis->fc.skewed = 1;
+ 	   }
+ 	if ( !is_fzero(ctm.yy) )
+ 	   {	(void)frexp(ctm.yy, &expt);
+ 		if ( expt > scale ) scale = expt;
+ 	   }
+ 	scale = 31 - max_coeff_bits - scale;
+ 	pis->fc.xx = (is_fzero(ctm.xx) ? 0 : (long)ldexp(ctm.xx, scale));
+ 	pis->fc.yy = (is_fzero(ctm.yy) ? 0 : (long)ldexp(ctm.yy, scale));
+ 	if ( pis->fc.skewed )
+ 	   {	pis->fc.xy = (is_fzero(ctm.xy) ? 0 : (long)ldexp(ctm.xy, scale));
+ 		pis->fc.yx = (is_fzero(ctm.yx) ? 0 : (long)ldexp(ctm.yx, scale));
+ 	   }
+ 	else
+ 		pis->fc.xy = pis->fc.yx = 0;
+ 	shift = scale - _fixed_shift;
+ 	pis->fc.shift = shift;
+ 	pis->fc.round = (shift > 0 ? (fixed)1 << (shift - 1) : 0);
+ #ifdef DEBUG
+ if ( gs_debug['1'] )
+    {	printf("[1]ctm: [%6g %6g %6g %6g ; %6g %6g] scale=%d\n",
+ 		ctm.xx, ctm.xy, ctm.yx, ctm.yy, ctm.tx, ctm.ty, scale);
+ 	printf("   fc: [%lx %lx %lx %lx] shift=%d\n",
+ 		pis->fc.xx, pis->fc.xy, pis->fc.yx, pis->fc.yy,
+ 		pis->fc.shift);
+    }
+ #endif
+ 	return 0;
+ }
+ 
+ /* Initialize a Type 1 interpreter */
+ int
+ gs_type1_init(register gs_type1_state *pis, gs_show_enum *penum,
+   int charpath_flag, int paint_type, byte *str, gs_type1_data *pdata)
+ {	gs_state *pgs = penum->pgs;
+ 	pis->penum = penum;
+ 	pis->pgs = pgs;
+ 	pis->pdata = pdata;
+ 	pis->charpath_flag = charpath_flag;
+ 	pis->paint_type = paint_type;
+ 	pis->os_count = 0;
+ 	pis->ipstack[0].ip = str;
+ 	pis->ipstack[0].dstate = crypt_charstring_seed;
+ 	pis->ips_count = 1;
+ 	pis->ip_skip = pdata->lenIV;
+ 	pis->seac_base = -1;
+ 	gs_type1_init_matrix(pis);
+ 	/* Set the current point of the path to the origin, */
+ 	/* in anticipation of the initial [h]sbw. */
+ 	{ gx_path *ppath = pgs->path;
+ 	  ppath->position.x = pgs->ctm.tx_fixed;
+ 	  ppath->position.y = pgs->ctm.ty_fixed;
+ 	}
+ 	return 0;
+ }
+ 
+ /* Tracing for type 1 interpreter */
+ #ifdef DEBUG
+ #  define dc(str) type1_trace(cip, c, str);
+ private void
+ type1_trace(byte *cip, byte c, char *str)
+ {	if ( gs_debug['1'] )
+ 		printf("[1]%lx: %02x %s\n", (ulong)(cip - 1), c, str);
+ }
+ #else
+ #  define dc(str)
+ #endif
+ 
+ /* Continue interpreting a Type 1 CharString. */
+ /* If str != 0, it is taken as the byte string to interpret. */
+ /* Return 0 on successful completion, <0 on error, */
+ /* (code<<1)+1 for seac, or (N+1)<<1 for callothersubr(N). */
+ int
+ gs_type1_interpret(register gs_type1_state *pis, byte *str)
+ {	gs_state *pgs = pis->pgs;
+ 	gx_path *ppath = pgs->path;
+ 	gs_type1_data *pdata = pis->pdata;
+ #define clear csp = cstack - 1
+ 	fixed cstack[ostack_size];
+ #define cs0 cstack[0]
+ #define cs1 cstack[1]
+ #define cs2 cstack[2]
+ #define cs3 cstack[3]
+ #define cs4 cstack[4]
+ #define cs5 cstack[5]
+ 	register fixed *csp;
+ 	ip_state *ipsp = &pis->ipstack[pis->ips_count - 1];
+ 	int skip = pis->ip_skip;
+ 	register byte *cip;
+ 	register crypt_state state;		/* decryption state */
+ 	register int c;
+ 	int code;
+ 	fixed_coeff fc;
+ 	fixed	ftx = pgs->ctm.tx_fixed,
+ 		fty = pgs->ctm.ty_fixed;
+ 	fixed ptx = ppath->position.x, pty = ppath->position.y;
+ 	fixed x1, y1, x2, y2;
+ 
+ 	fc = pis->fc;
+ 
+ #define c_fixed(d, c)\
+   (fc.shift >= 0 ? arith_rshift(fixed2int(d) * c + fc.round, fc.shift) :\
+    (fixed2int(d) * c) << -fc.shift)
+ /****** THE FOLLOWING ARE NOT ACCURATE FOR NON-INTEGER DELTAS. ******/
+ /* This probably doesn't make any difference in practice. */
+ #define accum_x(dx)\
+     ptx += c_fixed(dx, fc.xx);\
+     if ( fc.skewed ) pty += c_fixed(dx, fc.xy)
+ #define accum_y(dy)\
+     pty += c_fixed(dy, fc.yy);\
+     if ( fc.skewed ) ptx += c_fixed(dy, fc.yx)
+ #define accum_xy(dx,dy)\
+     ptx += c_fixed(dx, fc.xx);\
+     pty += c_fixed(dy, fc.yy);\
+     if ( fc.skewed ) pty += c_fixed(dx, fc.xy), ptx += c_fixed(dy, fc.yx)
+ 
+ 	/* Copy the operand stack out of the saved state. */
+ 	if ( pis->os_count == 0 )
+ 	   {	clear;
+ 	   }
+ 	else
+ 	   {	memcpy(cstack, pis->ostack, pis->os_count * sizeof(fixed));
+ 		csp = &cstack[pis->os_count - 1];
+ 	   }
+ 
+ 	if ( str != 0 )
+ 		ipsp->ip = str;
+ itop:	cip = ipsp->ip;
+ 	state = ipsp->dstate;
+ top:	/* Skip initial random bytes */
+ 	for ( ; skip > 0; --skip )
+ 	   {	decrypt_next(*cip, state, c); ++cip;
+ 	   }
+ 	while ( 1 )
+ 	 { decrypt_next(*cip, state, c); ++cip;
+ 	   switch ( (char_command)c )
+ 	   {
+ 	case c_hstem: dc("hstem")	/* hint, ignore */
+ 		clear; break;
+ 	case c_vstem: dc("vstem")	/* hint, ignore */
+ 		clear; break;
+ 	case c_vmoveto: dc("vmoveto")
+ 		accum_y(cs0);
+ 		goto mto;
+ 	case c_rlineto: dc("rlineto")
+ 		accum_xy(cs0, cs1);
+ lto:		code = gx_path_add_line(ppath, ptx, pty);
+ moved:		if ( code < 0 ) return code;
+ pp:
+ #ifdef DEBUG
+ if ( gs_debug['1'] )
+ 		printf("[1]pt=(%g,%g)\n", fixed2float(ptx), fixed2float(pty));
+ #endif
+ 		clear; break;
+ 	case c_hlineto: dc("hlineto")
+ 		accum_x(cs0);
+ 		goto lto;
+ 	case c_vlineto: dc("vlineto")
+ 		accum_y(cs0);
+ 		goto lto;
+ 	case c_rrcurveto: dc("rrcurveto")
+ 		accum_xy(cs0, cs1);
+ 		x1 = ptx, y1 = pty;
+ 		accum_xy(cs2, cs3);
+ 		x2 = ptx, y2 = pty;
+ 		accum_xy(cs4, cs5);
+ curve:		code = gx_path_add_curve(ppath, x1, y1, x2, y2, ptx, pty);
+ 		goto moved;
+ 	case c_closepath: dc("closepath")
+ 		/* Note that this does NOT reset the current point! */
+ 		code = gx_path_close_subpath(ppath);
+ 		if ( code < 0 ) return code;
+ 		goto mto;		/* put the point where it was */
+ 	case c_callsubr: dc("callsubr")
+ 	   {	int index = fixed2int(*csp);
+ 		byte *nip;
+ 		code = (*pdata->subr_proc)(pdata, index, &nip);
+ 		if ( code < 0 ) return code;
+ 		--csp;
+ 		ipsp->ip = cip, ipsp->dstate = state;
+ 		++ipsp;
+ 		cip = nip;
+ 	   }
+ 		state = crypt_charstring_seed;
+ 		skip = pis->pdata->lenIV;
+ 		goto top;
+ 	case c_return: dc("return")
+ 		--ipsp;
+ 		goto itop;
+ 	case c_escape: dc("escape:")
+ 		decrypt_next(*cip, state, c); ++cip;
+ 		switch ( (char_extended_command)c )
+ 		   {
+ 		case ce_dotsection: dc("  dotsection")	/* hint, ignore */
+ 			clear; break;
+ 		case ce_vstem3: dc("  vstem3")		/* hint, ignore */
+ 			clear; break;
+ 		case ce_hstem3: dc("  hstem3")		/* hint, ignore */
+ 			clear; break;
+ 		case ce_seac: dc("  seac")
+ 			/* Do the accent now.  When it finishes */
+ 			/* (detected in endchar), do the base character. */
+ 			pis->seac_base = (int)(byte)fixed2int(cs3);
+ 			/* Adjust the origin of the coordinate system */
+ 			/* for the accent (endchar puts it back). */
+ 			ptx = ftx, pty = fty;
+ 			cs1 -= cs0;	 /* subtract off asb */
+ 			accum_xy(cs1, cs2);
+ 			ppath->position.x = ptx;
+ 			ppath->position.y = pty;
+ 			clear;
+ 			/* Give control back to the caller, who must */
+ 			/* re-invoke the interpreter with the seac string. */
+ 			state = crypt_charstring_seed;
+ 			skip = pis->pdata->lenIV;
+ 			return ((int)(byte)fixed2int(cs4) << 1) + 1;
+ 		case ce_sbw: dc("  sbw")
+ 			pis->lsb.x = cs0, pis->lsb.y = cs1;
+ 			pis->width.x = cs2, pis->width.y = cs3;
+ 			goto setp;
+ 		case ce_div: dc("  div")
+ 			csp[-1] = float2fixed((float)csp[-1] / (float)*csp);
+ 			--csp; break;
+ 		case ce_testadd: dc("  testadd")
+ 			/*
+ 			 * NOTE: this opcode is not documented by Adobe.
+ 			 */
+ 			if ( csp[-2] > csp[-1] ) csp[-3] += *csp;
+ 			csp -= 3; break;
+ 		case ce_callothersubr: dc("  callothersubr")
+ 		   {	int index = fixed2int(*csp);
+ 			int scount = csp - cstack;
+ 			/* Exit to caller */
+ 			ipsp->ip = cip, ipsp->dstate = state;
+ 			pis->os_count = scount;
+ 			pis->ips_count = ipsp - &pis->ipstack[0] + 1;
+ 			pis->ip_skip = 0;
+ 			if ( scount )
+ 				memcpy(pis->ostack, cstack,
+ 				       scount * sizeof(fixed));
+ 			return (index + 1) << 1;
+ 		   }
+ 		case ce_pop: dc("  pop")
+ 			++csp;
+ 			code = (*pdata->pop_proc)(pdata, csp);
+ 			if ( code < 0 ) return code;
+ 			goto pushed;
+ 		case ce_setcurrentpoint: dc("  setcurrentpoint")
+ 			ptx = ftx, pty = fty;
+ 			goto setp;
+ 		default:
+ 			return_error(gs_error_invalidfont);
+ 		   }
+ 		break;
+ 	case c_hsbw: dc("hsbw")
+ 		pis->lsb.x = cs0, pis->lsb.y = 0;
+ 		pis->width.x = cs1, pis->width.y = 0;
+ 		cs1 = 0;
+ setp:		accum_xy(cs0, cs1);
+ 		goto pp;
+ 	case c_endchar: dc("endchar")
+ 		if ( pis->seac_base >= 0 )
+ 		   {	/* We just finished the accent of a seac. */
+ 			/* Do the base character. */
+ 			int base_code = pis->seac_base;
+ 			pis->seac_base = -1;
+ 			/* Restore the coordinate system origin */
+ 			ppath->position.x = pgs->ctm.tx_fixed;
+ 			ppath->position.y = pgs->ctm.ty_fixed;
+ 			clear;
+ 			/* Give control back to the caller, who must */
+ 			/* re-invoke the interpreter with the seac string. */
+ 			state = crypt_charstring_seed;
+ 			skip = pis->pdata->lenIV;
+ 			return (base_code << 1) + 1;
+ 		   }
+ 		/* Set the current point to the character origin: */
+ 		/* the 'show' loop will take care of adding in */
+ 		/* the width we supply to setcharwidth/cachedevice. */
+ 		gx_path_add_point(ppath,
+ 				  pgs->ctm.tx_fixed, pgs->ctm.ty_fixed);
+ 		if ( pis->charpath_flag )
+ 		   {	code = gs_setcharwidth(pis->penum,
+ 					fixed2float(pis->width.x),
+ 					fixed2float(pis->width.y));
+ 			if ( code < 0 ) return code;
+ 			/* Merge the path into its parent */
+ 			code = gx_path_merge(ppath, pgs->saved->path);
+ 		   }
+ 		else
+ 		   {	gs_rect bbox;
+ 			code = gs_pathbbox(pgs, &bbox);
+ 			/* Restore the current point to where it was */
+ 			/* at the beginning of the character, so that */
+ 			/* the right thing will happen when we copy */
+ 			/* a just-cached character to the output. */
+ 			gx_path_add_point(ppath, ftx, fty);
+ 			if ( code < 0 )		/* must be a null path */
+ 			   {	bbox.p.x = bbox.p.y = bbox.q.x = bbox.q.y = 0;
+ 			   }
+ #ifdef DEBUG
+ if ( gs_debug['1'] )
+ 			printf("[1]bbox=(%g,%g),(%g,%g)\n",
+ 				bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y);
+ #endif
+ 			if ( pis->paint_type )
+ 			   {	/* Expand the bounding box to encompass */
+ 				/* the width of the stroke, plus a little */
+ 				/* to overcome rounding problems. */
+ 				float adjust = gs_currentlinewidth(pgs);
+ 				if ( adjust == 0 ) adjust = 1;
+ 				bbox.p.x -= adjust;
+ 				bbox.p.y -= adjust;
+ 				bbox.q.x += adjust;
+ 				bbox.q.y += adjust;
+ 			   }
+ 			code = gs_setcachedevice(pis->penum,
+ 					fixed2float(pis->width.x),
+ 					fixed2float(pis->width.y),
+ 					bbox.p.x, bbox.p.y,
+ 					bbox.q.x, bbox.q.y);
+ 			if ( code < 0 ) return code;
+ 			/* We've already constructed the path: */
+ 			/* translate it so it matches the cache device. */
+ 			gx_path_translate(pgs->path, pgs->ctm.tx_fixed - ftx,
+ 					  pgs->ctm.ty_fixed - fty);
+ 			if ( code < 0 ) return code;
+ 			/******
+ 			 ****** The trim parameter is a hack to make
+ 			 ****** characters come out less bold, since we
+ 			 ****** don't look at the hints.
+ 			 ******/
+ 			code = (pis->paint_type ? gs_stroke(pgs) :
+ 				gs_fill_trim(pgs, float2fixed(0.2)));
+ 		   }
+ 		return code;
+ 	case c_rmoveto: dc("rmoveto")
+ 		accum_xy(cs0, cs1);
+ mto:		code = gx_path_add_point(ppath, ptx, pty);
+ 		goto moved;
+ 	case c_hmoveto: dc("hmoveto")
+ 		accum_x(cs0);
+ 		goto mto;
+ 	case c_vhcurveto: dc("vhcurveto")
+ 		accum_y(cs0);
+ 		x1 = ptx, y1 = pty;
+ 		accum_xy(cs1, cs2);
+ 		x2 = ptx, y2 = pty;
+ 		accum_x(cs3);
+ 		goto curve;
+ 	case c_hvcurveto: dc("hvcurveto")
+ 		accum_x(cs0);
+ 		x1 = ptx, y1 = pty;
+ 		accum_xy(cs1, cs2);
+ 		x2 = ptx, y2 = pty;
+ 		accum_y(cs3);
+ 		goto curve;
+ 	/* Fill up the dispatch up to 32 */
+ 	case c_undef0: case c_undef2:
+ 	case c_undef15:
+ 	case c_undef16: case c_undef17: case c_undef18: case c_undef19:
+ 	case c_undef20: case c_undef23:
+ 	case c_undef24: case c_undef25: case c_undef26: case c_undef27:
+ 	case c_undef28: case c_undef29:
+ 		return_error(gs_error_invalidfont);
+ 	default:			/* a number */
+ 		csp++;
+ 		if ( c <= c_max_num1 )
+ 			*csp = int2fixed(c_value_num1(c));
+ 		else
+ 		   {	byte c0;
+ 			decrypt_next(*cip, state, c0); ++cip;
+ 			if ( c <= c_max_num2 )
+ 				*csp = int2fixed(c_value_num2(c, (int)c0));
+ 			else if ( c <= c_max_num3 )
+ 				*csp = int2fixed(c_value_num3(c, (int)c0));
+ 			else			/* c = 255 */
+ 			   {	byte c1, c2;
+ 				long lw;
+ 				decrypt_next(*cip, state, c1); ++cip;
+ 				decrypt_next(*cip, state, c2); ++cip;
+ 				decrypt_next(*cip, state, lw); ++cip;
+ 				lw += (long)c0 << 24;
+ 				lw += (uint)c1 << 16;
+ 				lw += (uint)c2 << 8;
+ 				*csp = int2fixed(lw);
+ 				if ( lw != fixed2int(*csp) )
+ 					return_error(gs_error_rangecheck);
+ 			   }
+ 		   }
+ pushed:
+ #ifdef DEBUG
+ if ( gs_debug['1'] )
+ 		printf("[1]%d: (%d) %f\n", (int)(csp - cstack), c, fixed2float(*csp));
+ #endif
+ 		;			/* in case no debug */
+ 	   }
+ 	 }
+ }
+ 
+ /* Pop a (fixed) number off the internal stack. */
+ /* The client uses this to get the arguments for an OtherSubr. */
+ int
+ gs_type1_pop(gs_type1_state *pis, fixed *pf)
+ {	*pf = pis->ostack[--(pis->os_count)];
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gstype1.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gstype1.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gstype1.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,43 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gstype1.h */
+ /* Client interface to Adobe Type 1 font rouines for GhostScript library */
+ 
+ /* Encrypt/decrypt procedures */
+ typedef ushort crypt_state;
+ #define crypt_charstring_seed 4330
+ int gs_type1_encrypt(P4(byte *dest, byte *src, uint len, crypt_state *));
+ int gs_type1_decrypt(P4(byte *dest, byte *src, uint len, crypt_state *));
+ 
+ /* CharString interpreter */
+ typedef struct gs_type1_state_s gs_type1_state;
+ extern int gs_type1_state_sizeof;
+ struct gs_show_enum_s;
+ struct gs_type1_data_s;
+ int gs_type1_init(P6(gs_type1_state *pis, struct gs_show_enum_s *penum,
+ 		  int charpath_flag, int paint_type,
+ 		  byte *charstring, struct gs_type1_data_s *pdata));
+ /* Continue interpreting a Type 1 CharString. */
+ /* If str != 0, it is taken as the byte string to interpret. */
+ /* Return 0 on successful completion, <0 on error, */
+ /* (code<<1)+1 for seac, or (N+1)<<1 for callothersubr(N). */
+ int gs_type1_interpret(P2(gs_type1_state *, byte *));
+ /* Pop a (fixed) number off the internal stack */
+ int gs_type1_pop(P2(gs_type1_state *, fixed *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gt.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gt.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gt.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,448 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gt.c */
+ /* Test program for GhostScript library */
+ #include "math_.h"
+ #include "gx.h"
+ #include "malloc_.h"
+ #include "memory_.h"
+ #include "gsmatrix.h"
+ #include "gsstate.h"
+ #include "gscoord.h"
+ #include "gspaint.h"
+ #include "gspath.h"
+ #include "gxdevice.h"
+ 
+ int code;
+ private void e(P2(int, char *));
+ private void ze(P2(char *, char *));
+ #define z(ptr,msg) ze((char *)(ptr), msg)
+ 
+ private long get_time();
+ 
+ /* Parameters set by swproc and argproc */
+ private int testn = 0;
+ private int use_null = 0;
+ private int show_all = 0;
+ private int repeat = 1;
+ #define max_params 2
+ private int params[max_params];
+ /* Split main and real_main so we can run under a co-linked debugger. */
+ int real_main(P2(int, char *[]));
+ main(int argc, char *argv[])
+ {	return real_main(argc, argv);
+ }
+ int
+ real_main(int argc, char *argv[])
+ {	int (*proc)(P2(gs_state *, int *));
+ 	gs_state *pgs;
+ 	float ega_scale = 350.0 / (72 * 11);
+ 	float htproc(P2(floatp, floatp));
+ 	int swproc(P2(char, char *));
+ 	void argproc(P2(char *, int));
+ 	memset(params, 0, max_params * sizeof(int));
+ 	gs_main(argc, argv, "GT.MAP", swproc, argproc);
+ 	switch ( testn )
+ 	   {
+ #define set_test(tproc)\
+ 	     { int tproc(P2(gs_state *, int *)); proc = tproc; }
+ 	case 1: set_test(test1); break;
+ 	case 2: set_test(test2); break;
+ 	case 3: set_test(test3); break;
+ 	case 4: set_test(test4); break;
+ 	case 6: set_test(test6); break;
+ 	case 99: set_test(test99); break;
+ 	case 100: set_test(test100); break;
+ 	case 101: set_test(test101); break;
+ 	default:
+ 		printf("Unknown test #%d\n", testn);
+ 		exit(1);
+ 	   }
+ 	z(pgs = gs_state_alloc(gs_malloc, gs_free), "alloc");
+ 	e(gs_setdevice(pgs, gs_getdevice(0)), "setdevice");
+ 	if ( use_null )
+ 		gx_device_no_output(pgs);	/* suppress output */
+ 	e(gs_setscreen(pgs, 10.0, 45.0, htproc), "setscreen");
+ 	e(gs_initgraphics(pgs), "initgraphics");
+ 	e(gs_erasepage(pgs), "erasepage");
+ 	   {	gs_matrix mat;
+ 		gs_make_identity(&mat);
+ 		mat.xx = ega_scale * 48 / 35;
+ 		mat.yy = -ega_scale;
+ 		mat.ty = 350;
+ 		e(gs_setmatrix(pgs, &mat), "setmatrix");
+ 	   }
+ 	   {	long time1, ttime;
+ 		int count = repeat;
+ 		time1 = get_time();
+ 		do
+ 		  { e(gs_gsave(pgs), "outer gsave");
+ 		    (*proc)(pgs, params);
+ 		    gs_copypage(pgs);
+ 		    e(gs_grestore(pgs), "outer grestore");
+ 		  }
+ 		while ( --count );
+ 		ttime = get_time() - time1;
+ 		if ( repeat == 1 )
+ 		  printf("%ld\n", ttime);
+ 		else
+ 		  printf("%ld / %d = %ld\n", ttime, repeat, ttime / repeat);
+ 	   }
+ 	getchar();		/* wait for confirmation */
+ }
+ float
+ htproc(floatp x, floatp y)
+ {	return (float)(1.0 - (x*x + y*y));
+ }
+ /* Process switches */
+ int
+ swproc(char sw, char *arg)
+ {	switch ( sw )
+ 	   {
+ 	default:
+ 		return -1;
+ 	case 'A':	/* show all steps */
+ 		show_all = 1;
+ 		break;
+ 	case 'N':	/* select null device */
+ 		use_null = 1;
+ 		break;
+ 	case 'R':	/* repeat test (for timing)  */
+ 		sscanf(arg, "%d", &repeat);
+ 		if ( repeat <= 0 )
+ 		  {	printf("Repeat count <= 0\n");
+ 			exit(1);
+ 		  }
+ 		break;
+ 	   }
+ 	return 0;
+ }
+ /* Process parameters */
+ void
+ argproc(char *arg, int index)
+ {	if ( index == 0 )
+ 	  { sscanf(arg, "%d", &testn);
+ 	  }
+ 	else if ( index <= max_params )
+ 	  sscanf(arg, "%d", &params[index - 1]);
+ 	else
+ 	  { printf("Too many arguments\n");
+ 	    exit(1);
+ 	  }
+ }
+ private void
+ e(int code, char *str)
+ {	if ( show_all ) printf("%s\n", str);
+ 	if ( code < 0 )
+ 	  { printf("Error, code=%d in %s\n", code, str);
+ 	    exit(1);
+ 	  }
+ }
+ private void
+ ze(char *ptr, char *str)
+ {	if ( show_all ) printf("%s\n", str);
+ 	if ( ptr == NULL )
+ 	  { printf("Error, result=0 in %s\n", code, str);
+ 	    exit(1);
+ 	  }
+ }
+ 
+ #define inch(n) (float)((n) * 72)
+ 
+ /* A program for testing stroking */
+ /* 1st parameter is # of degrees to rotate between strokes */
+ test99(register gs_state *pgs, int *params)
+ {	int i;
+ 	float ang = params[0];
+ 	float atot = 0;
+ 	if ( ang == 0 ) ang = 30;
+ 	gs_translate(pgs, inch(4), inch(5));
+ 	gs_scale(pgs, inch(3.5), inch(3.5));
+ 	gs_setlinewidth(pgs, 0.1);
+ 	while ( atot < 360 )
+ 	   {	gs_moveto(pgs, 0.25, 0.0);
+ 		gs_lineto(pgs, 1.0, 0.0);
+ 		gs_stroke(pgs);
+ 		gs_rotate(pgs, ang);
+ 		atot += ang;
+ 	   }
+ }
+ 
+ /* A mandala program for testing stroke speed */
+ test100(register gs_state *pgs, int *params)
+ {	int N = max(params[0], 2);
+ 	int delta, i;
+ 	float ang1 = 360.0 / N;
+ 	e(gs_translate(pgs, inch(4.25), inch(5.5)), "translate");
+ 	e(gs_scale(pgs, inch(3.5), inch(3.5)), "scale");
+ 	e(gs_setlinewidth(pgs, 0.0), "setlinewidth");
+ 	for ( delta = 1; delta <= N / 2; delta++ )
+ 	   {	float ang = ang1 * delta;
+ 		e(gs_newpath(pgs), "newpath");
+ 		for ( i = 0; i < N; i++ )
+ 		   {	e(gs_moveto(pgs, 0.0, 1.0), "moveto");
+ 			e(gs_rotate(pgs, ang), "rotate 1");
+ 			e(gs_lineto(pgs, 0.0, 1.0), "lineto");
+ 			e(gs_rotate(pgs, (float)(ang1 - ang)), "rotate 2");
+ 		   }
+ 		e(gs_stroke(pgs), "stroke");
+ 	   }
+ }
+ 
+ /* A program for testing colors */
+ test101(register gs_state *pgs, int *params)
+ {	int i, j, k;
+ 	float unit = 36.0;
+ 	for ( i = 0; i <= 4; i++ )
+ 	  for ( j = 0; j <= 4; j++ )
+ 	    for ( k = 0; k <= 4; k++ )
+ 	      { e(gs_setrgbcolor(pgs, i * 0.25, j * 0.25, k * 0.25), "setrgbcolor");
+ 		gs_newpath(pgs);
+ 		gs_moveto(pgs, (j * 5 + k + 0.1) * unit, (i + 0.1) * unit);
+ 		gs_rlineto(pgs, 0.0, unit);
+ 		gs_rlineto(pgs, unit, 0.0);
+ 		gs_rlineto(pgs, 0.0, -unit);
+ 		gs_closepath(pgs);
+ 		gs_fill(pgs);
+ 	      }
+ }
+ 
+ /* ------ Programs from the PostScript Cookbook ------ */
+ 
+ /* Program 1 from the PostScript Cookbook */
+ /* 1st parameter gives # of petals, default is 3 */
+ test1(register gs_state *pgs, int *params)
+ {	void wedge(P2(gs_state *, floatp));
+ 	int i;
+ 	int param = params[0];
+ 	int nseg = (abs(param) < 3 ? (param = 3) : abs(param));
+ 	float ang = 360.0 / nseg;
+ 	float ang2 = ang / 2;
+ 	e(gs_gsave(pgs), "gsave 1");
+ 	e(gs_translate(pgs, inch(3.75), inch(7.25)), "translate");
+ 	e(gs_scale(pgs, inch(1), inch(1)), "scale");
+ 	wedge(pgs, ang2);
+ 	e(gs_setlinewidth(pgs, 0.02), "setlinewidth");
+ 	e(gs_stroke(pgs), "stroke");
+ 	e(gs_grestore(pgs), "grestore 1");
+ 	e(gs_gsave(pgs), "gsave 2");
+ 	gs_translate(pgs, inch(4.25), inch(4.25));
+ 	gs_scale(pgs, inch(1.75), inch(1.75));
+ 	gs_setlinewidth(pgs, 0.02);
+ 	for ( i = 1; i <= nseg; i++ )
+ 	   {	gs_setgray(pgs, (float)i / param);
+ 		if ( param < 0 ) gs_rotate(pgs, -ang);
+ 		e(gs_gsave(pgs), "gsave 3");
+ 		wedge(pgs, ang2);
+ 		e(gs_gsave(pgs), "gsave 4");
+ 		gs_fill(pgs);
+ 		e(gs_grestore(pgs), "grestore 4");
+ 		gs_setgray(pgs, 0.0);
+ 		gs_stroke(pgs);
+ 		e(gs_grestore(pgs), "grestore 3");
+ 		if ( param > 0 ) gs_rotate(pgs, ang);
+ 	   }
+ 	e(gs_grestore(pgs), "grestore 2");
+ }
+ void
+ wedge(register gs_state *pgs, floatp ang)
+ {	float asin = sin(ang * M_PI / 180.0);
+ 	e(gs_moveto(pgs, 0.0, 0.0), "moveto");
+ 	e(gs_translate(pgs, 1.0, 0.0), "translate 1");
+ 	e(gs_rotate(pgs, (float)ang), "rotate");
+ 	e(gs_translate(pgs, 0.0, asin), "translate 2");
+ 	e(gs_arc(pgs, 0.0, 0.0, asin, -90.0, 90.0), "arc");
+ 	e(gs_closepath(pgs), "closepath");
+ }
+ 
+ /* Program 2 from the PostScript Cookbook */
+ /* 1st parameter specifies a rotation amount */
+ /* If 2nd parameter is non-zero, trace square in opposite direction */
+ test2(gs_state *pgs, int *params)
+ {	void centersquare(P2(gs_state *, int));
+ 	gs_matrix cmtx;
+ 	int i;
+ 	float rota = params[0];
+ 	int cw = params[1];
+ 	e(gs_gsave(pgs), "gsave 1");
+ 	e(gs_translate(pgs, inch(2.5), inch(6)), "translate 1");
+ 	e(gs_setlinewidth(pgs, 1.0 / 16), "setlinewidth 1");
+ 	if ( rota != 0 )
+ 		e(gs_rotate(pgs, rota), "rotate");
+ 	for ( i = 1; i <= 5; i++ )
+ 	   {	e(gs_gsave(pgs), "gsave 2");
+ 		e(gs_scale(pgs, i * inch(0.5), i * inch(0.5)), "scale 1");
+ 		centersquare(pgs, cw);
+ 		e(gs_stroke(pgs), "stroke 1");
+ 		e(gs_grestore(pgs), "grestore 2");
+ 	   }
+ 	e(gs_grestore(pgs), "grestore 1");
+ 	e(gs_gsave(pgs), "gsave 3");
+ 	e(gs_translate(pgs, inch(6), inch(6)), "translate 2");
+ 	e(gs_setlinewidth(pgs, 1.0), "setlinewidth 2");
+ 	e(gs_currentmatrix(pgs, &cmtx), "currentmatrix");
+ 	for ( i = 1; i <= 5; i++ )
+ 	   {	e(gs_gsave(pgs), "gsave 4");
+ 		e(gs_scale(pgs, i * inch(0.5), i * inch(0.5)), "scale 2");
+ 		centersquare(pgs, cw);
+ 		e(gs_setmatrix(pgs, &cmtx), "setmatrix");
+ 		e(gs_stroke(pgs), "stroke 2");
+ 		e(gs_grestore(pgs), "grestore 4");
+ 	   }
+ 	e(gs_grestore(pgs), "grestore 3");
+ }
+ void
+ centersquare(register gs_state *pgs, int cw)
+ {	float d = (cw ? 0.5 : -0.5);
+ 	e(gs_newpath(pgs), "newpath");
+ 	e(gs_moveto(pgs, 0.5, 0.5), "moveto");
+ 	e(gs_lineto(pgs, d, -d), "lineto 1");
+ 	e(gs_lineto(pgs, -0.5, -0.5), "lineto 2");
+ 	e(gs_lineto(pgs, -d, d), "lineto 3");
+ 	e(gs_closepath(pgs), "closepath");
+ }
+ 
+ /* Program 3 from the PostScript Cookbook */
+ test3(register gs_state *pgs, int *params)
+ {	void ellipse(P7(gs_state *, int, int, int, int, int, int));
+ 	e(gs_newpath(pgs), "newpath 1");
+ 	ellipse(pgs, 144, 400, 72, 144, 0, 360);
+ 	e(gs_stroke(pgs), "stroke 1");
+ 	e(gs_newpath(pgs), "newpath 2");
+ 	ellipse(pgs, 400, 400, 144, 36, 0, 360);
+ 	e(gs_fill(pgs), "fill 2");
+ 	e(gs_newpath(pgs), "newpath 3");
+ 	ellipse(pgs, 300, 180, 144, 72, 30, 150);
+ 	e(gs_stroke(pgs), "stroke 3");
+ 	e(gs_newpath(pgs), "newpath 4");
+ 	ellipse(pgs, 480, 150, 30, 50, 270, 90);
+ 	e(gs_fill(pgs), "fill 4");
+ }
+ void
+ ellipse(register gs_state *pgs,
+   int x, int y, int xrad, int yrad, int startangle, int endangle)
+ {	gs_matrix savematrix;
+ 	e(gs_currentmatrix(pgs, &savematrix), "currentmatrix");
+ 	e(gs_translate(pgs, (float)x, (float)y), "translate");
+ 	e(gs_scale(pgs, (float)xrad, (float)yrad), "scale");
+ 	e(gs_arc(pgs, 0.0, 0.0, 1.0, (float)startangle, (float)endangle), "arc");
+ 	e(gs_setmatrix(pgs, &savematrix), "setmatrix");
+ }
+ 
+ /* Program 4 from the PostScript Cookbook */
+ test4(register gs_state *pgs, int *params)
+ {	void arrow(P8(gs_state *, int, int, int, int, int, int, floatp));
+ 	e(gs_newpath(pgs), "newpath 1");
+ 	arrow(pgs, 318, 340, 72, 340, 10, 30, 72.0);
+ 	e(gs_fill(pgs), "fill 1");
+ 	e(gs_newpath(pgs), "newpath 2");
+ 	arrow(pgs, 382, 400, 542, 560, 72, 232, 116.0);
+ 	e(gs_setlinewidth(pgs, 3.0), "setlinewidth");
+ 	e(gs_stroke(pgs), "stroke");
+ 	e(gs_newpath(pgs), "newpath 3");
+ 	arrow(pgs, 400, 300, 400, 90, 90, 200, 200 * 1.732 / 2);
+ 	e(gs_setgray(pgs, 0.65), "setgray");
+ 	e(gs_fill(pgs), "fill 2");
+ }
+ void
+ arrow(register gs_state *pgs,
+   int tailx, int taily, int tipx, int tipy, int thickness, int headthickness,
+   floatp hl)
+ {	float ht = (float)thickness / 2;
+ 	float hht = (float)headthickness / 2;
+ 	float dx = tipx - tailx;
+ 	float dy = tipy - taily;
+ 	float al = sqrt(dx * dx + dy * dy);
+ 	float angle = atan2(dy, dx) * (180.0 / M_PI);
+ 	float base = al - hl;
+ 	gs_matrix savematrix;
+ 	e(gs_currentmatrix(pgs, &savematrix), "currentmatrix");
+ 	e(gs_translate(pgs, (float)tailx, (float)taily), "translate");
+ 	e(gs_rotate(pgs, angle), "rotate");
+ 	e(gs_moveto(pgs, 0.0, (float)-ht), "moveto");
+ 	e(gs_lineto(pgs, base, (float)-ht), "line 1");
+ 	e(gs_lineto(pgs, base, (float)-hht), "line 2");
+ 	e(gs_lineto(pgs, al, 0.0), "line 3");
+ 	e(gs_lineto(pgs, base, hht), "line 4");
+ 	e(gs_lineto(pgs, base, ht), "line 5");
+ 	e(gs_lineto(pgs, 0.0, ht), "line 6");
+ 	e(gs_closepath(pgs), "closepath");
+ 	e(gs_setmatrix(pgs, &savematrix), "setmatrix");
+ }
+ 
+ /* Program 6 from the PostScript Cookbook */
+ /* (actually, the test program for the imagemask operator */
+ /* that appears in the PostScript reference manual) */
+ /* First parameter is amount to rotate image */
+ /* If second parameter is non-zero, clip the image */
+ int ii;
+ test6(register gs_state *pgs, int *params)
+ {	gs_matrix mat;
+ 	int i6proc(P2(byte **, int *));
+ 	e(gs_translate(pgs, inch(3), inch(4)), "translate");
+ 	e(gs_scale(pgs, inch(2), inch(2)), "scale");
+ 	gs_moveto(pgs, 0.0, 0.0);
+ 	gs_lineto(pgs, 0.0, 1.0);
+ 	gs_lineto(pgs, 1.0, 1.0);
+ 	gs_lineto(pgs, 1.0, 0.0);
+ 	gs_closepath(pgs);
+ 	gs_setgray(pgs, 0.9);
+ /***	gs_fill(pgs);	***/
+ 	gs_setgray(pgs, 0.4);
+ 	/* The following is not in the original program. */
+ 	/* It is here to test clipping of images. */
+ 	if ( params[1] )
+ 	   {	e(gs_newpath(pgs), "newpath");
+ 		e(gs_moveto(pgs, 0.0, 0.0), "moveto");
+ 		e(gs_lineto(pgs, 1.0, 3.0), "line1");
+ 		e(gs_lineto(pgs, 3.0, 1.0), "line2");
+ 		e(gs_closepath(pgs), "closepath");
+ 		e(gs_clip(pgs), "clip");
+ 	   }
+ 	e(gs_rotate(pgs, (float)params[0]), "rotate");
+ 	gs_make_identity(&mat);
+ 	mat.xx = 24;
+ 	mat.yy = -23;
+ 	mat.ty = 23;
+ 	ii = 0;
+ 	e(gs_imagemask(pgs, 24, 23, 1, &mat, i6proc), "image");
+ }
+ private byte i6data[3 * 23] =
+    {	0x00,0x3b,0x00, 0x00,0x27,0x00, 0x00,0x24,0x80, 0x0e,0x49,0x40,
+ 	0x11,0x49,0x20, 0x14,0xb2,0x20, 0x3c,0xb6,0x50, 0x75,0xfe,0x88,
+ 	0x17,0xff,0x8c, 0x17,0x5f,0x14, 0x1c,0x07,0xe2, 0x38,0x03,0xc4,
+ 	0x70,0x31,0x82, 0xf8,0xed,0xfc, 0xb2,0xbb,0xc2, 0xbb,0x6f,0x84,
+ 	0x31,0xbf,0xc2, 0x18,0xea,0x3c, 0x0e,0x3e,0x00, 0x07,0xfc,0x00,
+ 	0x03,0xf8,0x00, 0x1e,0x18,0x00, 0x1f,0xf8,0x00
+    };
+ int
+ i6proc(byte **pdata, int *psize)
+ {	*pdata = &i6data[ii++ * 23];
+ 	*psize = 23;
+ 	return 0;
+ }
+ 
+ /* Read the current time (in milliseconds since midnight). */
+ private long
+ get_time()
+ {	long date_time[2];
+ 	gs_get_clock(date_time);
+ 	return date_time[0] * 86400000L + date_time[1];
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gvirtmem.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gvirtmem.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gvirtmem.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,382 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gvirtmem.c */
+ /* Software virtual memory for bitmaps for Ghostscript */
+ #include <stdio.h>
+ #include "std.h"
+ #include "memory_.h"
+ #include "string_.h"
+ #include "gvirtmem.h"
+ 
+ /* Things that aren't in stdio.h (at least on some systems) */
+ extern char *mktemp(P1(char *));
+ #ifndef SEEK_SET
+ #  define SEEK_SET 0
+ #endif
+ 
+ /* Define the scratch file name for the paging file. */
+ #ifdef __MSDOS__
+ #  define SCRATCH_TEMP "_gvm_XXXXXX"
+ #else
+ #  define SCRATCH_TEMP "/tmp/gvmem_XXXXXX"
+ #endif
+ 
+ /* Forward declarations */
+ private int vmem_get_page(P3(gx_vmem *, char **, int));
+ private int vmem_choose_page(P2(gx_vmem *, int));
+ private void vmem_read_page(P2(gx_vmem *, int));
+ private void vmem_write_page(P2(gx_vmem *, int));
+ private void vmem_annul_page(P2(gx_vmem *, int));
+ private void vmem_assign_page(P3(gx_vmem *, int, char *));
+ private FILE *vmem_file(P1(gx_vmem *));
+ private void vmem_seek(P2(gx_vmem *, int));
+ 
+ /* ------ Public interface ------ */
+ 
+ /* Initialize an instance of virtual memory */
+ int
+ vmem_init(register gx_vmem *vmem,
+   char **lines, int line_size, int num_lines, char init_value,
+   int page_size, long max_memory,
+   proc_alloc_t alloc, proc_free_t free)
+ {	char *exists;
+ 	vmem->lines = lines;
+ 	   {	int lnum;
+ 		for ( lnum = 0; lnum < num_lines; lnum++ )
+ 			lines[lnum] = NO_LINE;
+ 	   }
+ 	if ( page_size < line_size ) page_size = line_size;
+ 	vmem->line_size = line_size;
+ 	vmem->num_lines = num_lines;
+ 	vmem->init_value = init_value;
+ 	vmem->page_size = page_size / line_size * line_size;
+ 	vmem->alloc = alloc;
+ 	vmem->free = free;
+ 	vmem->file = NULL;		/* open when needed */
+ 	vmem->lines_per_page = page_size / line_size;
+ 	vmem->num_pages =
+ 		(num_lines + vmem->lines_per_page - 1) / vmem->lines_per_page;
+ 	vmem->next_file_page = 0;
+ 	vmem->num_in_memory = 0;
+ 	vmem->max_in_memory = (int)(max_memory / page_size);
+ 
+ 	/* Allocate and initialize the page existence table */
+ 	exists = (*alloc)(vmem->num_pages, 1, "vmem_init(exists)");
+ 	if ( exists == NULL )
+ 	   {	dprintf("Couldn't allocate page status table (vmem_init)\n");
+ 		exit(1);
+ 	   }
+ 	vmem->exists = exists;
+ 	memset(exists, 0, vmem->num_pages);
+ 	vmem->num_reads = 0;
+ 	vmem->num_writes = 0;
+ 
+ 	return 0;
+ }
+ 
+ /* Close the instance, deallocating the buffers and removing the */
+ /* temporary file.  This doesn't deallocate the instance itself: */
+ /* that is the client's responsibility.  The instance must be */
+ /* initialized before it can be used again. */
+ int
+ vmem_close(register gx_vmem *vmem)
+ {	proc_free_t free = vmem->free;
+ 	/* We deallocate in the reverse order of allocating, */
+ 	/* in the hope of pacifying a LIFO memory manager.... */
+ 	if ( vmem->file != NULL )
+ 	   {	fclose(vmem->file);
+ 		vmem->file = NULL;
+ 		remove(vmem->filename);
+ 		(*free)(vmem->filename, strlen(vmem->filename)+1, 1,
+ 			"vmem_close(filename)");
+ 		vmem->filename = NULL;
+ 	   }
+ 	   {	/* Deallocate the buffers in a random order, */
+ 		/* and hope for the best. */
+ 		int pnum;
+ 		for ( pnum = 0; pnum < vmem->num_pages; pnum++ )
+ 		   {	char *page = page_ptr(vmem, pnum);
+ 			if ( page != NO_LINE )
+ 				(*free)(page, 1, vmem->page_size, "vmem_close(page)");
+ 		   }
+ 	   }
+ 	(*free)(vmem->exists, vmem->num_pages, 1, "vmem_close(exists)");
+ 	return 0;
+ }
+ 
+ /* Make a page resident in memory.  Return 0 normally. */
+ /* If the page doesn't exist, then if force is true, */
+ /* allocate and clear the page and return 0; if force is false, */
+ /* do nothing and return 1. */
+ int
+ vmem_bring_in_page(register gx_vmem *vmem, char **pline, int force)
+ {	int fault;
+ 	if ( *pline != NO_LINE ) return 0;	/* false alarm */
+ 	vmem->lock_first = 0, vmem->lock_last = -1;	/* no lock */
+ 	fault = vmem_get_page(vmem, pline, force);
+ 	if ( fault < 0 )
+ 	   {	dprintf1("vmem_get_page failed in vmem_bring_in_page, lnum = %d!\n",
+ 			pline - vmem->lines);
+ 		exit(1);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Make a rectangle resident in memory.  Return 0 normally. */
+ /* If this isn't possible, return -2 to indicate to the caller */
+ /* that it should divide the rectangle along the Y axis and try again. */
+ /* (See the description of bring_in_proc in gxdevmem.h for details.) */
+ int
+ vmem_bring_in_rect(gx_vmem *vmem, int ignore_x, int lnum,
+   int ignore_w, int lcount, int writing)
+ {	char **lines = vmem->lines;
+ 	int lpp = vmem->lines_per_page;
+ 	int line_first = (lnum / lpp) * lpp;	/* first line on page */
+ 	int line_last = lnum + lcount - 1;
+ 	register char **pl = lines + line_first;
+ 	char **pl_last = lines + line_last;
+ 	/* Prevent pages from being thrown out once they're in. */
+ 	vmem->lock_first = line_first / lpp;
+ 	vmem->lock_last = line_last / lpp;
+ 	for ( ; pl <= pl_last; pl += lpp )
+ 	  if ( *pl == NO_LINE && vmem_get_page(vmem, pl, 1) != 0 )
+ 	    return -2;
+ 	return 0;
+ }
+ 
+ /* ------ Private code ------ */
+ 
+ /* Bring in a single page.  The caller has set lock_first and lock_last. */
+ private int
+ vmem_get_page(gx_vmem *vmem, char **pline, int force)
+ {	int lnum = pline - vmem->lines;
+ 	int pnum = lnum / vmem->lines_per_page;
+ 	int clear_it = 0;
+ 	char *page;
+ 	if ( !vmem->exists[pnum] )
+ 	   {	if ( !force ) return 1;
+ 		clear_it = 1;
+ 	   }
+ 	if ( vmem->num_in_memory < vmem->max_in_memory &&
+ 	     (page = (*vmem->alloc)(1, vmem->page_size, "vmem_get_page")) != NULL
+ 	   )
+ 	   {	vmem->num_in_memory++;
+ 	   }
+ 	else				/* fully allocated, or can't alloc */
+ 	   {	int purge_pnum = vmem_choose_page(vmem, pnum);
+ 		if ( purge_pnum < 0 ) return purge_pnum;
+ 		page = page_ptr(vmem, purge_pnum);
+ 		vmem_write_page(vmem, purge_pnum);
+ 		vmem_annul_page(vmem, purge_pnum);
+ 	   }
+ 	vmem_assign_page(vmem, pnum, page);
+ 	if ( clear_it )
+ 	   {	memset(page, vmem->init_value, vmem->page_size);
+ 		vmem->exists[pnum] = 1;
+ 	   }
+ 	else
+ 		vmem_read_page(vmem, pnum);
+ 	return 0;
+ }
+ 
+ /* Choose a page to purge.  This always succeeds, unless */
+ /* we are bringing in a rectangle and pages are locked. */
+ private int /* page # */
+ vmem_choose_page(register gx_vmem *vmem, int pnum)
+ {	/* Search for an allocated page, starting with the one */
+ 	/* farthest away from the one being read in. */
+ 	int bottom = 0, top = vmem->num_pages - 1;
+ 	while ( bottom <= top )
+ 	   {	if ( pnum - bottom > top - pnum )
+ 		   {	if ( page_ptr(vmem, bottom) != NO_LINE &&
+ 			     (bottom < vmem->lock_first ||
+ 			      bottom > vmem->lock_last)
+ 			   )
+ 			  return bottom;
+ 			bottom++;
+ 		   }
+ 		else
+ 		   {	if ( page_ptr(vmem, top) != NO_LINE &&
+ 			     (top < vmem->lock_first ||
+ 			      top > vmem->lock_last)
+ 			   )
+ 			  return top;
+ 			top--;
+ 		   }
+ 	   }
+ 	return -1;			/* no unlocked page */
+ }
+ 
+ /* Read a page from the disk. */
+ /* The memory page is already allocated. */
+ private void
+ vmem_read_page(register gx_vmem *vmem, int pnum)
+ {	char *page = page_ptr(vmem, pnum);
+ 	FILE *file = vmem_file(vmem);
+ 	vmem_seek(vmem, pnum);
+ 	if ( fread((void *)page, sizeof(char), vmem->page_size, file)
+ 		!= vmem->page_size )
+ 	   {	dprintf1("fread failed in vmem_read, pnum = %d!\n",
+ 			pnum);	
+ 		exit(1);
+ 	   }
+ 	vmem->num_reads++;
+ }
+ 
+ /* Write a page to the disk */
+ private void
+ vmem_write_page(register gx_vmem *vmem, int pnum)
+ {	char *page = page_ptr(vmem, pnum);
+ 	if ( page != NO_LINE )
+ 	   {	FILE *file = vmem_file(vmem);
+ 		while ( pnum > vmem->next_file_page )
+ 		   {	int count;
+ 			char value = vmem->init_value;
+ 			vmem_seek(vmem, vmem->next_file_page);
+ 			for ( count = vmem->page_size; count > 0; count-- )
+ 				putc(value, file);
+ 			vmem->next_file_page++;
+ 		   }
+ 		vmem_seek(vmem, pnum);
+ 		if ( fwrite((void *)page, sizeof(char), vmem->page_size, file)
+ 			!= vmem->page_size )
+ 		   {	dprintf1("fwrite failed in vmem_write, pnum = %d!\n",
+ 				pnum);	
+ 			exit(1);
+ 		   }
+ 		if ( pnum == vmem->next_file_page )
+ 			vmem->next_file_page++;
+ 	   }
+ 	vmem->num_writes++;
+ }
+ 
+ /* Mark a page as not in memory. */
+ private void
+ vmem_annul_page(register gx_vmem *vmem, int pnum)
+ {	int lnum = pnum * vmem->lines_per_page;
+ 	char **ppage = &vmem->lines[lnum];
+ 	int limit = min(lnum + vmem->lines_per_page, vmem->num_lines);
+ 	while ( lnum++ < limit ) *ppage = NO_LINE;
+ }
+ 
+ /* Mark a page as in memory. */
+ /* The page must have been marked not in memory before. */
+ private void
+ vmem_assign_page(register gx_vmem *vmem, int pnum, char *page)
+ {	int lnum = pnum * vmem->lines_per_page;
+ 	char **ppage = &vmem->lines[lnum];
+ 	char *line = page;
+ 	int limit = min(lnum + vmem->lines_per_page, vmem->num_lines);
+ 	while ( lnum++ < limit )
+ 		*ppage++ = line,
+ 		line += vmem->line_size;
+ }
+ 
+ /* Open the virtual memory file if needed */
+ private FILE *
+ vmem_file(gx_vmem *vmem)
+ {	FILE *file = vmem->file;
+ 	if ( file == NULL )		/* first time, open the file */
+ 	   {	char *fname = (*vmem->alloc)(strlen(SCRATCH_TEMP)+1, 1,
+ 					     "vmem_file(filename)");
+ 		if ( fname == NULL )
+ 		   {	dprintf("Can't alloc vmem temporary file name\n");
+ 			exit(1);
+ 		   }
+ 		strcpy(fname, SCRATCH_TEMP);
+ 		if ( mktemp(fname) == NULL )
+ 		   {	dprintf("Can't create vmem temporary file\n");
+ 			exit(1);
+ 		   }
+ 		file = fopen(fname, "w+b");
+ 		if ( file == NULL )
+ 		   {	dprintf1("Can't open vmem temporary file %s\n",
+ 				fname);
+ 			exit(1);
+ 		   }
+ 		vmem->file = file;
+ 		vmem->filename = fname;
+ 	   }
+ 	return file;
+ }
+ 
+ /* Seek to a given page */
+ private void
+ vmem_seek(gx_vmem *vmem, int pnum)
+ {	if ( fseek(vmem_file(vmem), (long)pnum * vmem->page_size, SEEK_SET) )
+ 	   {	dprintf1("fseek failed in vmem_seek, pnum = %d!\n",
+ 			pnum);
+ 		exit(1);
+ 	   }
+ }
+ 
+ /* ------ Test program ------ */
+ 
+ #ifdef VMDEBUG
+ 
+ #include "malloc_.h"
+ 
+ char *talloc(unsigned size, char *str)
+ {	return (char *)malloc(size);
+ }
+ void tfree(char *blk, unsigned size, char *str)
+ {	free(blk);
+ }
+ 
+ #define MY_LINE_SIZE 8
+ #define MY_NUM_LINES 14
+ #define MY_PAGE_SIZE 25
+ #define MY_MAX_MEMORY (MY_PAGE_SIZE*2)
+ gx_vmem my_vmem;			/* static so we can print it */
+ char *my_lines[MY_NUM_LINES];		/* ditto */
+ 
+ main()
+ {	/* Following may be enabled if necessary
+ 		trace(vmem_read_page, "read", NULL, 0);
+ 		trace(vmem_write_page, "write", NULL, 0);
+ 		trace(vmem_annul_page, "annul", NULL, 0);
+ 		trace(vmem_assign_page, "assign", NULL, 0);
+ 		trace(talloc, "alloc", "%d from %s", 4);
+ 		trace(tfree, "free", "%lx %d from %s", 0);
+ 	 */
+ 	vmem_init(&my_vmem, my_lines, MY_LINE_SIZE, MY_NUM_LINES, 0xbd,
+ 	  MY_PAGE_SIZE, (long)MY_MAX_MEMORY, talloc, tfree);
+ 	   {	/* Simple write/read loop test */
+ 		int lnum;
+ 		for ( lnum = 0; lnum < MY_NUM_LINES; lnum++ )
+ 		   {	if ( my_lines[lnum] == NO_LINE )
+ 				vmem_get_page(&my_vmem, &my_lines[lnum], 1);
+ 			my_lines[lnum][3] = lnum;
+ 		   }
+ 		for ( lnum = 0; lnum < MY_NUM_LINES; lnum++ )
+ 		   {	if ( my_lines[lnum] == NO_LINE )
+ 				vmem_get_page(&my_vmem, &my_lines[lnum], 1);
+ 			if ( my_lines[lnum][3] != lnum )
+ 				printf("Error: lnum=%d, data=%d\n",
+ 					lnum, my_lines[lnum][3]);
+ 		   }
+ 	   }
+ 	vmem_close(&my_vmem);
+ 	printf("Test completed, num_reads=%ld, num_writes=%ld\n",
+ 		my_vmem.num_reads, my_vmem.num_writes);
+ 	exit(0);
+ }
+ 
+ #endif					/* ifdef VMDEBUG */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gvirtmem.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gvirtmem.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gvirtmem.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,84 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gvirtmem.h */
+ /* Software virtual memory for bitmaps for Ghostscript */
+ 
+ /*
+  * This code implements a paged, software virtual memory system.
+  * It is designed for bitmaps, and specifically designed to work well
+  * with the structures that Ghostscript uses for image devices,
+  * as defined in gxdevmem.h.  This impacts the design in several ways:
+  *	- The page size is a multiple of the scan line size, which is
+  *	    a multiple of 4 bytes but not necessarily a power of 2.
+  *	- There is special provision for keeping track of pages that
+  *	    are all white.
+  *	- The page replacement algorithm is not LRU, but is a simpler
+  *	    algorithm based on beliefs about spatial locality.
+  *	- Moving pages in and out of memory updates the scan line table
+  *	    defined by gxdevmem.h.
+  *	- There is a special procedure to bring an entire rectangle
+  *	    into memory.
+  * Otherwise, the design is quite standard.  Each instance of the
+  * virtual memory system (there can be many) has its own file, page
+  * size, scan line size, page table / scan line table, and other
+  * structures.
+  */
+ 
+ /* This is the main instance structure */
+ typedef struct gx_vmem_s gx_vmem;
+ struct gx_vmem_s {
+ 	/* The following are arguments at initialization */
+ 	char **lines;			/* the page (scan line) table */
+ #define NO_LINE (char *)NULL		/* page not in memory */
+ #define page_ptr(vmem, pnum) (vmem)->lines[(pnum) * (vmem)->lines_per_page]
+ 	int line_size;			/* size of each scan line */
+ 	int num_lines;			/* number of scan lines */
+ 	char init_value;		/* initial value for new pages */
+ 	int page_size;			/* size of each page */
+ 	proc_alloc_t alloc;		/* allocation procedure */
+ 	proc_free_t free;		/* freeing procedure */
+ 	/* The following are set at initialization */
+ 	FILE *file;			/* the paging file */
+ 	char *filename;			/* save the name, for removing */
+ 					/* the file */
+ 	char *exists;			/* status of each page, */
+ 					/* 1 if it has ever been */
+ 					/* written on the disk */
+ 	int lines_per_page;		/* scan lines per page */
+ 	int num_pages;			/* total # of pages */
+ 	int lock_first, lock_last;	/* locked pages during bring_in_rect */
+ 	/* The following are updated dynamically */
+ 	int next_file_page;		/* next file page to write */
+ 	int num_in_memory;		/* number of pages in memory */
+ 	int max_in_memory;		/* max pages in memory */
+ 	/* Statistics */
+ 	long num_reads, num_writes;
+ };
+ 
+ /* Public procedures */
+ 
+ /* Initialize a virtual memory instance. */
+ int vmem_init(P9(gx_vmem *, char ** /*lines*/, int /*line_size*/,
+ 		 int /*num_lines*/, char /*init_value*/, int /*page_size*/,
+ 		 long /*max_memory*/, proc_alloc_t, proc_free_t));
+ 
+ /* Bring in a rectangle. */
+ int vmem_bring_in_rect(P6(gx_vmem *, int /*x*/, int /*y*/,
+ 			  int /*width*/, int /*height*/, int /*writing*/));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gx.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gx.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gx.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,33 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gx.h */
+ /* Common internal definitions for Ghostscript imaging library */
+ #include "gs.h"
+ 
+ /* Debugging options array */
+ extern char gs_debug[128];
+ 
+ /* Error return macro */
+ #ifdef DEBUG
+ extern int gs_log_error(P1(int));
+ #  define return_error(err) return gs_log_error(err)
+ #else
+ #  define return_error(err) return err
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxarith.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxarith.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxarith.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,40 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxarith.h */
+ /* Arithmetic macros for GhostScript library */
+ 
+ /* Optimize shifting on DOS */
+ #ifdef __MSDOS__
+ #  define fixed_rsh3(x) ((((x) >> 1) >> 1) >> 1)
+ #else
+ #  define fixed_rsh3(x) arith_rshift(x, 3)
+ #endif
+ 
+ /* Test floating point values against zero. */
+ #ifdef vax				/* not IEEE format! */
+ #  define is_fzero(f) ((f) == 0)
+ #  define is_fzero2(f1,f2) ((f1) == 0 && (f2) == 0)
+ #  define is_fneg(f) ((f) < 0)
+ #else
+ #  define _f_as_l(f) *(long *)(&(f))
+ #  define is_fzero(f) ((_f_as_l(f) << 1) == 0)	/* +0 or -0 */
+ #  define is_fzero2(f1,f2) (((_f_as_l(f1) | _f_as_l(f2)) << 1) == 0)
+ #  define is_fneg(f) ((_f_as_l(f)) < 0)	/* -0 is negative, oh well */
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxbitmap.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxbitmap.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxbitmap.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,38 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxbitmap.h */
+ /* Definitions for stored bitmaps for Ghostscript */
+ 
+ /*
+  * Structure for describing stored bitmaps.
+  * Bitmaps are stored bit-big-endian (i.e., the 2^7 bit of the first
+  * byte corresponds to x=0), as a sequence of bytes (i.e., you can't
+  * do word-oriented operations on them if you're on a little-endian
+  * platform like the Intel 80x86 or VAX).  Each scan line must start on
+  * a (32-bit) word boundary, and hence must be is padded to a word boundary,
+  * although this should rarely be of concern, since the raster and width
+  * are specified individually.  The first scan line corresponds to y=0
+  * in whatever coordinate system is relevant.
+  */
+ struct gx_bitmap_s {
+ 	byte *data;
+ 	int raster;		 /* bytes per scan line */
+ 	int width, height;
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxcache.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxcache.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxcache.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,210 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxcache.c */
+ /* Character cache routines for GhostScript library */
+ #include "gx.h"
+ #include "memory_.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gspaint.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"			/* requires gsstate.h */
+ #include "gzcolor.h"
+ #include "gzpath.h"
+ #include "gxdevmem.h"
+ #include "gxchar.h"
+ #include "gxfont.h"
+ #include "gxfdir.h"
+ 
+ /* Define the size of the cache structures */
+ int cached_char_sizeof = sizeof(cached_char);
+ int cached_fm_pair_sizeof = sizeof(cached_fm_pair);
+ 
+ /* Forward references */
+ private void zap_cache(P1(gs_font_dir *));
+ 
+ /* Allocate storage for caching a rendered character, */
+ /* and set up the memory device. */
+ /* Return the cached_char if OK, 0 if too big. */
+ cached_char *
+ gx_alloc_char_bits(gs_font_dir *dir, gx_device_memory *dev,
+   ushort iwidth, ushort iheight)
+ {	ulong isize;
+ 	cached_char *cc;
+ 	dev->width = iwidth;
+ 	dev->height = iheight;
+ 	isize = gx_device_memory_bitmap_size(dev);	/* sets raster */
+ 	if ( dev->raster != 0 && iheight > dir->upper / dev->raster )
+ 		return 0;		/* too big */
+ 	if ( dir->csize >= dir->cmax || dir->bmax - dir->bsize < isize )
+ 	   {	/* There isn't enough room.  Clear the entire cache. */
+ 		/* We'll do something better someday.... */
+ 		if ( dir->cmax == 0 || dir->bmax < isize ) return 0;
+ 		zap_cache(dir);
+ 	   }
+ 	/* Allocate the cache entry and the bits. */
+ 	cc = &dir->cdata[dir->cnext++];
+ 	cc->bits = &dir->bdata[dir->bnext];
+ 	dir->bnext += isize;
+ 	memset((char *)cc->bits, 0, (uint)isize);
+ 	cc->width = iwidth;
+ 	cc->height = iheight;
+ 	cc->raster = dev->raster;
+ 	dev->base = cc->bits;
+ 	(*dev->procs->open_device)((gx_device *)dev);	/* initialize */
+ 	dir->csize++;
+ 	dir->bsize += isize;
+ 	return cc;
+ }
+ 
+ /* Remove the just-allocated character from the cache. */
+ /* The character hasn't been added yet. */
+ void
+ gx_unalloc_cached_char(gs_font_dir *dir, cached_char *cc)
+ {	uint isize = cc->raster * cc->height;
+ 	dir->cnext--;
+ 	dir->bnext -= isize;
+ 	dir->csize--;
+ 	dir->bsize -= isize;
+ }
+ 
+ /* Look up, and if necessary add, a font/matrix pair in the cache */
+ cached_fm_pair *
+ gx_lookup_fm_pair(register gs_state *pgs)
+ {	float	mxx = pgs->char_tm.xx, mxy = pgs->char_tm.xy,
+ 		myx = pgs->char_tm.yx, myy = pgs->char_tm.yy;
+ 	gs_font *font = pgs->font;
+ 	register gs_font_dir *dir = font->dir;
+ 	register cached_fm_pair *pair = dir->mdata + dir->mnext;
+ 	int count = dir->msize;
+ 	while ( count-- )
+ 	   {	if ( pair == dir->mdata ) pair += dir->mmax;
+ 		else pair--;
+ 		if (	pair->font == font &&
+ 			pair->mxx == mxx && pair->mxy == mxy &&
+ 			pair->myx == myx && pair->myy == myy
+ 		   )
+ 		  return pair;
+ 	   }
+ 	/* Add the pair to the cache */
+ 	if ( dir->msize == dir->mmax )
+ 		zap_cache(dir);		/* crude, but it works */
+ 	dir->msize++;
+ 	pair = dir->mdata + dir->mnext;
+ 	if ( ++dir->mnext == dir->mmax ) dir->mnext = 0;
+ 	pair->font = font;
+ 	pair->mxx = mxx, pair->mxy = mxy;
+ 	pair->myx = myx, pair->myy = myy;
+ 	pair->num_chars = 0;
+ 	return pair;
+ }
+ 
+ /* Add a character to the cache */
+ void
+ gx_add_cached_char(gs_font_dir *dir, cached_char *cc, cached_fm_pair *pair)
+ {	/* Add the new character at the tail of its chain. */
+ 	cached_char **head = &dir->chars[cc->code & (gx_char_cache_modulus - 1)];
+ 	while ( *head != 0 ) head = &(*head)->next;
+ 	*head = cc;
+ 	cc->next = 0;
+ 	cc->pair = pair;
+ 	pair->num_chars++;
+ }
+ 
+ /* Look up a character in the cache. */
+ /* Return the cached_char or 0. */
+ cached_char *
+ gx_lookup_cached_char(gs_state *pgs, cached_fm_pair *pair, int ccode)
+ {	register cached_char *cc =
+ 		pgs->font->dir->chars[ccode & (gx_char_cache_modulus - 1)];
+ 	while ( cc != 0 )
+ 	   {	if ( cc->code == ccode && cc->pair == pair )
+ 		  return cc;
+ 		cc = cc->next;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Copy a cached character to the screen. */
+ /* Assume the caller has already done gx_color_render (or gx_color_load), */
+ /* and the color is not a halftone. */
+ /* Return 0 if OK, 1 if we couldn't do the operation but no error */
+ /* occurred, or a negative error code. */
+ int
+ gx_copy_cached_char(register gs_show_enum *penum, register cached_char *cc)
+ {	register gs_state *pgs = penum->pgs;
+ 	int x, y, w, h;
+ 	int code;
+ 	gs_fixed_point pt;
+ 	code = gx_path_current_point_inline(pgs->path, &pt);
+ 	if ( code < 0 ) return code;
+ 	/* Compute the device color if needed; abort if it isn't pure. */
+ 	if ( !penum->color_loaded )
+ 	   {	gx_device_color *pdevc = pgs->dev_color;
+ 		gx_color_render(pgs->color, pdevc, pgs);
+ 		if ( !color_is_pure(pdevc) )
+ 			return 1;	/* can't use cache */
+ 		penum->color_loaded = 1;
+ 	   }
+ 	/* If the character doesn't lie entirely within the */
+ 	/* quick-check clipping rectangle, we have to use */
+ 	/* the general case of image rendering. */
+ 	pt.x -= cc->offset.x;
+ 	x = fixed2int_rounded(pt.x);
+ 	pt.y -= cc->offset.y;
+ 	y = fixed2int_rounded(pt.y);
+ 	w = cc->width;
+ 	h = cc->height;
+ 	if (	x < penum->cxmin || x + w > penum->cxmax ||
+ 		y < penum->cymin || y + h > penum->cymax
+ 	   )
+ 	   {	gs_matrix mat;
+ 		mat = ctm_only(pgs);
+ 		mat.tx -= fixed2float(pt.x);
+ 		mat.ty -= fixed2float(pt.y);
+ 		code = gs_imagemask(pgs, cc->raster * 8, h, 1,
+ 				    &mat, cc->bits);
+ 	   }
+ 	else
+ 	   {	/* Just copy the bits */
+ 		gx_device *dev = pgs->device->info;
+ 		code = (*dev->procs->copy_mono)
+ 			(dev, cc->bits, 0, cc->raster,
+ 			 x, y, w, h,
+ 			 gx_no_color_index, pgs->dev_color->color1);
+ 	   }
+ 	return ( code < 0 ? code : 0 );
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Zap the cache when it overflows. */
+ /* This is inefficient and crude, but it works. */
+ private void
+ zap_cache(register gs_font_dir *dir)
+ {	dir->bsize = 0;
+ 	dir->msize = 0;
+ 	dir->csize = 0;
+ 	dir->bnext = 0;
+ 	dir->mnext = 0;
+ 	dir->cnext = 0;
+ 	memset((char *)dir->chars, 0, gx_char_cache_modulus * sizeof(cached_char *));
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxchar.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxchar.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxchar.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,94 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxchar.h */
+ /* Internal character definition for GhostScript library */
+ /* Requires gsmatrix.h, gxfixed.h, gzdevice.h */
+ #include "gschar.h"
+ 
+ /* An entry for a (font,matrix) pair in the character cache. */
+ typedef struct cached_fm_pair_s cached_fm_pair;
+ struct cached_fm_pair_s {
+ 	struct gs_font_s *font;		/* base font */
+ 	float mxx, mxy, myx, myy;	/* transformation */
+ 	int num_chars;			/* # of cached chars with this */
+ 					/* f/m pair */
+ };
+ 
+ /* A cached bitmap for an individual character. */
+ typedef struct cached_char_s cached_char;
+ struct cached_char_s {
+ 	cached_char *next;		/* next in replacement ring */
+ 	/* The code and font/matrix pair are the 'key' in the cache. */
+ 	int code;			/* character code */
+ 	cached_fm_pair *pair;		/* font/matrix pair */
+ 	/* The rest of the structure is the 'value'. */
+ 	unsigned short raster, height;	/* dimensions of bitmap */
+ 	unsigned short width;
+ 	gs_fixed_point wxy;		/* width in device coords */
+ 	gs_fixed_point offset;		/* (-llx, -lly) in device coords */
+ 	byte *bits;
+ };
+ 
+ /* An enumeration object for string display. */
+ typedef enum {
+ 	sws_none,
+ 	sws_cache,
+ 	sws_no_cache
+ } show_width_status;
+ struct gs_show_enum_s {
+ 	/* Following are set at creation time */
+ 	gs_state *pgs;
+ 	byte *str;			/* char may be signed! */
+ 	uint size;
+ 	float cx, cy;			/* for widthshow */
+ 	int chr;			/* ditto */
+ 	float ax, ay;			/* for ashow */
+ 	int add;			/* true if a[width]show */
+ 	int do_kern;			/* true if kshow */
+ 	int slow_show;			/* [a][width]show or kshow */
+ 	int charpath_flag;		/* 0 for show, 1 for false */
+ 					/* charpath, 2 for true charpath */
+ 	int can_cache;			/* true if can cache chars */
+ 	int cxmin, cymin, cxmax, cymax;	/* int version of quick-check */
+ 					/* clipping box */
+ 	/* Following are set at most once */
+ 	gx_device_memory dev_cache_info;
+ 	device dev_cache_dev;
+ 	int dev_cache_set;
+ 	/* Following are updated dynamically */
+ 	uint index;			/* index within string */
+ 	gs_fixed_point wxy;		/* for current char in device coords */
+ 	cached_char *cc;		/* being accumulated */
+ 	gs_point width;			/* total width of string, set at end */
+ 	show_width_status width_set;
+ 	int color_loaded;		/* true if have done gx_color_render */
+ 	int (*continue_proc)(P1(struct gs_show_enum_s *));	/* continuation procedure */
+ };
+ 
+ /* Cached character procedures (in gxfont.c) */
+ 	/* The following line is needed to make the GNU compiler happy.... */
+ 	struct gs_font_dir_s;
+ cached_char *	gx_alloc_char_bits(P4(struct gs_font_dir_s *,
+ 			gx_device_memory *, ushort, ushort));
+ void	gx_unalloc_cached_char(P2(struct gs_font_dir_s *, cached_char *));
+ cached_fm_pair *	gx_lookup_fm_pair(P1(gs_state *));
+ void	gx_add_cached_char(P3(struct gs_font_dir_s *, cached_char *, cached_fm_pair *));
+ cached_char *	gx_lookup_cached_char(P3(gs_state *, cached_fm_pair *, int));
+ int	gx_copy_cached_char(P2(gs_show_enum *, cached_char *));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxcolor.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxcolor.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxcolor.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,180 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxcolor.c */
+ /* Private color procedures for GhostScript library */
+ #include "gx.h"
+ #include "gxfixed.h"			/* for gxmatrix.h */
+ #include "gxmatrix.h"
+ #include "gxdevice.h"			/* for gx_color_index */
+ #include "gzcolor.h"
+ #include "gzht.h"
+ 
+ /* Define the color type (normally obtained from gsstate.h). */
+ typedef struct gs_color_s gs_color;
+ 
+ /* ------ Color conversion routines ------ */
+ 
+ /* Note: the color model conversion algorithms are taken from */
+ /* Rogers, Procedural Elements for Computer Graphics, pp. 401-403. */
+ 
+ /* Complete color specified by rgb */
+ void
+ gx_color_from_rgb(register gs_color *pcolor)
+ {	if ( pcolor->red == pcolor->green && pcolor->green == pcolor->blue )
+ 	   {	pcolor->luminance = pcolor->red;	/* pick any one */
+ 		pcolor->is_gray = pcolor->luminance_set = 1;
+ 	   }
+ 	else
+ 	   {	/* Compute luminance later */
+ 		pcolor->is_gray = pcolor->luminance_set = 0;
+ 	   }
+ }
+ 
+ /* Compute (if necessary) and return the luminance of a color. */
+ color_param
+ gx_color_luminance(register gs_color *pcolor)
+ {	if ( !pcolor->luminance_set )
+ 	   {	pcolor->luminance =
+ 			(pcolor->red * (unsigned long)lum_red_weight +
+ 			pcolor->green * (unsigned long)lum_green_weight +
+ 			pcolor->blue * (unsigned long)lum_blue_weight +
+ 			(lum_all_weights / 2))
+ 		    / lum_all_weights;
+ 		pcolor->luminance_set = 1;
+ 	   }
+ 	return pcolor->luminance;
+ }
+ 
+ /* Convert RGB to HSB */
+ void
+ gx_color_to_hsb(register gs_color *pcolor, color_param hsb[3])
+ {
+ #define rhue hsb[0]
+ #define rsat hsb[1]
+ #define rbri hsb[2]
+ 	if ( pcolor->is_gray )
+ 	   {	rhue = 0;	/* arbitrary */
+ 		rsat = 0;
+ 		rbri = pcolor->red;	/* pick any one */
+ 	   }
+ 	else
+ 	   {	/* Convert rgb to hsb */
+ 		gs_color c;
+ 		color_param V, Temp;
+ 		long diff, H;
+ 		c.red = pcolor->red;
+ 		c.green = pcolor->green;
+ 		c.blue = pcolor->blue;
+ 		V = (c.red > c.green ? c.red : c.green);
+ 		if ( c.blue > V ) V = c.blue;
+ 		Temp = (c.red > c.green ? c.green : c.red);
+ 		if ( c.blue < Temp ) Temp = c.blue;
+ 		diff = V - Temp;
+ 		if ( V == c.red )
+ 			H = (c.green - c.blue) * (long)max_color_param / diff;
+ 		else if ( V == c.green )
+ 			H = (c.blue - c.red) * (long)max_color_param / diff + 2 * max_color_param;
+ 		else /* V == c.blue */
+ 			H = (c.red - c.green) * (long)max_color_param / diff + 4 * max_color_param;
+ 		if ( H < 0 ) H += 6 * max_color_param;
+ 		rhue = H / 6;
+ 		rsat = diff * (long)max_color_param / V;
+ 		rbri = V;
+ 	   }
+ #undef rhue
+ #undef rsat
+ #undef rbri
+ }
+ 
+ /* Complete color specified by hsb */
+ void
+ gx_color_from_hsb(register gs_color *pcolor,
+   color_param hue, color_param saturation, color_param brightness)
+ {	if ( saturation == 0 )
+ 	   {	pcolor->red = pcolor->green = pcolor->blue = brightness;
+ 	   }
+ 	else
+ 	   {	/* Convert hsb to rgb */
+ 		/* The +0 in the following lines is to compensate for */
+ 		/* a bug in the UTek C compiler (sigh). */
+ 		float V = (float)(brightness + 0) / max_color_param;
+ 		float S = (float)(saturation + 0) / max_color_param;
+ #define mcp6 (max_color_param / 6 + 1)
+ 		int I = hue / mcp6;
+ 		float F = (float)(hue % mcp6) / mcp6;
+ #undef mcp6
+ 		float M = V * (1 - S);
+ 		float N = V * (1 - S * F);
+ 		float K = V * (1 - S * (1 - F));
+ 		float R, G, B;
+ 		switch ( I )
+ 		   {
+ 		default: R = V; G = K; B = M; break;
+ 		case 1: R = N; G = V; B = M; break;
+ 		case 2: R = M; G = V; B = K; break;
+ 		case 3: R = M; G = N; B = V; break;
+ 		case 4: R = K; G = M; B = V; break;
+ 		case 5: R = V; G = M; B = N; break;
+ 		   }
+ 		pcolor->red = R * max_color_param;
+ 		pcolor->green = G * max_color_param;
+ 		pcolor->blue = B * max_color_param;
+ 	   }
+ 	gx_color_from_rgb(pcolor);	/* compute luminance */
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Heapsort (algorithm 5.2.3H, Knuth vol. 2, p. 146), */
+ /* modified for 0-origin indexing. */
+ void
+ gx_sort_ht_order(ht_bit *recs, uint N)
+ {	uint l = N >> 1;
+ 	uint r = N - 1;
+ 	uint j;
+ 	ht_bit R;
+ 	if ( N <= 1 ) return;
+ #define key(m) recs[m].mask
+ #define K R.mask
+ 	while ( 1 )
+ 	   {	if ( l > 0 )
+ 			R = recs[--l];
+ 		else
+ 		   {	R = recs[r];
+ 			recs[r] = recs[0];
+ 			if ( --r == 0 )
+ 			   {	recs[0] = R;
+ 				break;
+ 			   }
+ 		   }
+ 		j = l;
+ 		while ( 1 )
+ 		   {	uint i = j;
+ 			j = j + j + 1;
+ 			if ( j < r )
+ 				if ( key(j) < key(j + 1) ) j++;
+ 			if ( j > r || K >= key(j) )
+ 			   {	recs[i] = R;
+ 				break;	/* to outer loop */
+ 			   }
+ 			recs[i] = recs[j];
+ 		   }
+ 	   }
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdevice.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdevice.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdevice.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,141 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxdevice.h */
+ /* Device description structure for GhostScript library */
+ /* Requires gsmatrix.h */
+ 
+ /* Define the structure for bitmaps (opaquely). */
+ typedef struct gx_bitmap_s gx_bitmap;
+ 
+ /* Define the type for device color indices. */
+ typedef unsigned long gx_color_index;
+ #define gx_no_color_index ((gx_color_index)(-1))	/* transparent */
+ 
+ /* See drivers.doc for documentation of the driver interface. */
+ 
+ /* Structure for device procedures */
+ typedef struct gx_device_procs_s gx_device_procs;
+ 
+ /* Structure for generic device description */
+ #define gx_device_common\
+ 	int params_size;		/* size of this structure */\
+ 	gx_device_procs *procs;\
+ 	char *name;			/* the device name */\
+ 	int width;			/* width in pixels */\
+ 	int height;			/* height in pixels */\
+ 	float x_pixels_per_inch;	/* x density */\
+ 	float y_pixels_per_inch;	/* y density */\
+ 	int has_color;			/* true if device supports color */\
+ 	unsigned short max_rgb_value;	/* max r, g, b value */\
+ 	int bits_per_color_pixel;	/* for copy_color */\
+ 	int is_open			/* true if device has been opened */
+ /* A generic device */
+ struct gx_device_s {
+ 	gx_device_common;
+ };
+ 
+ /* Definition of device procedures */
+ struct gx_device_procs_s {
+ 
+ #define dev_proc_open_device(proc)\
+   int proc(P1(struct gx_device_s *))
+ 	dev_proc_open_device((*open_device));
+ 
+ #define dev_proc_get_initial_matrix(proc)\
+   void proc(P2(struct gx_device_s *, gs_matrix *))
+ 	dev_proc_get_initial_matrix((*get_initial_matrix));
+ 
+ #define dev_proc_sync_output(proc)\
+   int proc(P1(struct gx_device_s *))
+ 	dev_proc_sync_output((*sync_output));
+ 
+ #define dev_proc_output_page(proc)\
+   int proc(P1(struct gx_device_s *))
+ 	dev_proc_output_page((*output_page));
+ 
+ #define dev_proc_close_device(proc)\
+   int proc(P1(struct gx_device_s *))
+ 	dev_proc_close_device((*close_device));
+ 
+ #define dev_proc_map_rgb_color(proc)\
+   gx_color_index proc(P4(struct gx_device_s *,\
+     unsigned short red, unsigned short green, unsigned short blue))
+ 	dev_proc_map_rgb_color((*map_rgb_color));
+ 
+ #define dev_proc_map_color_rgb(proc)\
+   int proc(P3(struct gx_device_s *,\
+     gx_color_index color, unsigned short rgb[3]))
+ 	dev_proc_map_color_rgb((*map_color_rgb));
+ 
+ #define dev_proc_fill_rectangle(proc)\
+   int proc(P6(struct gx_device_s *,\
+     int x, int y, int width, int height, gx_color_index color))
+ 	dev_proc_fill_rectangle((*fill_rectangle));
+ 
+ #define dev_proc_tile_rectangle(proc)\
+   int proc(P8(struct gx_device_s *,\
+     gx_bitmap *tile, int x, int y, int width, int height,\
+     gx_color_index color0, gx_color_index color1))
+ 	dev_proc_tile_rectangle((*tile_rectangle));
+ 
+ #define dev_proc_copy_mono(proc)\
+   int proc(P10(struct gx_device_s *,\
+     unsigned char *data, int data_x, int raster,\
+     int x, int y, int width, int height,\
+     gx_color_index color0, gx_color_index color1))
+ 	dev_proc_copy_mono((*copy_mono));
+ 
+ #define dev_proc_copy_color(proc)\
+   int proc(P8(struct gx_device_s *,\
+     unsigned char *data, int data_x, int raster,\
+     int x, int y, int width, int height))
+ 	dev_proc_copy_color((*copy_color));
+ 
+ #define dev_proc_draw_line(proc)\
+   int proc(P6(struct gx_device_s *,\
+     int x0, int y0, int x1, int y1, gx_color_index color))
+ 	dev_proc_draw_line((*draw_line));
+ 
+ #define dev_proc_fill_trapezoid(proc)\
+   int proc(P8(struct gx_device_s *,\
+     int x0, int y0, int width0, int x1, int y1, int width1,\
+     gx_color_index color))
+ 	dev_proc_fill_trapezoid((*fill_trapezoid));
+ 
+ #define dev_proc_tile_trapezoid(proc)\
+   int proc(P10(struct gx_device_s *, gx_bitmap *tile,\
+     int x0, int y0, int width0, int x1, int y1, int width1,\
+     gx_color_index color0, gx_color_index color1))
+ 	dev_proc_tile_trapezoid((*tile_trapezoid));
+ 
+ };
+ 
+ /* Default implementations of optional procedures */
+ dev_proc_open_device(gx_default_open_device);
+ dev_proc_get_initial_matrix(gx_default_get_initial_matrix);
+ dev_proc_sync_output(gx_default_sync_output);
+ dev_proc_output_page(gx_default_output_page);
+ dev_proc_close_device(gx_default_close_device);
+ dev_proc_map_rgb_color(gx_default_map_rgb_color);
+ dev_proc_map_color_rgb(gx_default_map_color_rgb);
+ dev_proc_tile_rectangle(gx_default_tile_rectangle);
+ dev_proc_draw_line(gx_default_draw_line);
+ dev_proc_fill_trapezoid(gx_default_fill_trapezoid);
+ dev_proc_tile_trapezoid(gx_default_tile_trapezoid);


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdevmem.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdevmem.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdevmem.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,88 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxdevmem.h */
+ /* "Memory" device structure for GhostScript library */
+ /* Requires gxdevice.h */
+ 
+ /* A 'memory' device -- a stored bitmap. */
+ /* There are several different kinds: monochrome, 8-bit mapped color, */
+ /* and 24- and 32-bit true color.  (24- and 32-bit are equivalent: */
+ /* 24-bit takes less space, but is slower.)  All use the same structure, */
+ /* since it's so awkward to get the effect of subclasses in C. */
+ typedef struct gx_device_memory_s gx_device_memory;
+ struct gx_device_memory_s {
+ 	gx_device_common;		/* (see gxdevice.h) */
+ 	gs_matrix initial_matrix;	/* the initial transformation */
+ 	int raster;			/* bytes per scan line, */
+ 					/* filled in by '...bitmap_size' */
+ 	byte *base;
+ 	byte **line_ptrs;		/* scan line pointers */
+ 	int (*bring_in_proc)(P6(gx_device_memory *dev,	/* (see below) */
+ 		int byte_in_line /* (x) */, int line /* (y) */,
+ 		int width, int height, int writing));
+ 	/* Following is only needed for monochrome */
+ 	int invert;			/* 0 if 1=white, -1 if 1=black */
+ 	/* Following are only needed for mapped color */
+ 	int palette_size;		/* # of entries */
+ 	byte *palette;			/* RGB triples */
+ };
+ extern gx_device_memory
+ 	mem_mono_device,
+ 	mem_mapped_color_device,
+ 	mem_true24_color_device,
+ 	mem_true32_color_device;
+ 
+ /* Memory devices may have special setup requirements. */
+ /* In particular, it may not be obvious how much space to allocate */
+ /* for the bitmap.  Here is the routine that computes this */
+ /* from the width and height in the device structure. */
+ extern ulong gx_device_memory_bitmap_size(P1(gx_device_memory *));
+ 
+ /* Test whether a device is a memory device. */
+ extern int gs_device_is_memory(P1(struct gx_device_s *));
+ 
+ /* Copy data from the bitmap to a client. */
+ /* Return the number of lines copied. */
+ extern int mem_copy_scan_lines(P4(gx_device_memory *, int /* first_line */,
+ 		byte * /* string */, uint /* string_size */));
+ 
+ /* Return the number of bytes per scan line for copy_scan_lines. */
+ extern int mem_bytes_per_scan_line(P1(gx_device_memory *));
+ 
+ /*
+  * Memory devices may page their bitmaps.  The hook for this is the
+  * bring_in_proc.  This procedure is called with the device and the
+  * rectangle parameters at the beginning of any copy, fill, draw, or tile
+  * operation (writing=1), or when copying scan lines back to a client
+  * (writing=0).  The procedure should do whatever is necessary to ensure
+  * that the relevant part of the bitmap is in memory, and then return 0.
+  * If it can't do that (i.e., if there isn't enough buffer space),
+  * it should return -1 or -2.  -1 means divide the rectangle in half
+  * in X, and try again; -2 means divide it in Y and try again.
+  * The default bring_in_proc always returns 0.
+  */
+ #define mem_fault_split_X (-1)
+ #define mem_fault_split_Y (-2)
+ 
+ /*
+  * A memory device that does not page its bitmap is guaranteed
+  * to allocate the bitmap consecutively, i.e., in the form that
+  * can serve as input to copy_mono or copy_color operations.
+  */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdither.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdither.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdither.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,284 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxdither.c */
+ 
+ /* 
+  *	Improved dithering for Ghostscript.  The underlying device imaging 
+  *	model supports dithering between two colors to generate intermediate
+  *	shades.  
+  *	
+  *	The strategy is to first see if the color is either pure white or
+  *	pure black.  In this case the problem is trivial.
+  *	
+  * 	Next, if we are on a High Quality RGB display with 8 or more
+  *	bits for each R, G and B, we simply set the color and return.
+  *
+  *	Now, if the device is black and white, or the color happens
+  *	to be achromatic, we perform simple B/W dithering.
+  *	
+  *	Otherwise, things are a bit more complicated.  If the device 
+  * 	supports N shades of each R, G and B independently, there are a total 
+  *	of N*N*N colors.  These colors form a 3-D grid in a cubical color 
+  *	space.  The following dithering technique works by locating the 
+  *	color we want in this 3-D color grid and finding the eight colors 
+  * 	that surround it.  In the case of dithering into 8 colors with 1 
+  *	bit for each red, green and blue, these eight colors will always 
+  *	be the same.
+  *
+  *	Now we consider all possible diagonal paths between the eight colors
+  *	and chose the path that runs closest to our desired color in 3-D
+  *	color space.  There are 28 such paths.  Then we find the position
+  *	on the path that is closest to out color.
+  *
+  *	The search is made more fast by always reflecting our color into
+  *	the bottom octant of the cube and comparing it to 7 paths.
+  *	After the best path and the best position on that path are found,
+  *	the results are reflected back into the original color space.
+  *
+  *	NOTE: This code has been tested for B/W and Color imaging with
+  *	1, 2, 3 and 8 bits per component.
+  *
+  *	--- original code by Paul Haeberli @ Silicon Graphics - 1990
+  *	--- extensively revised by L. Peter Deutsch, Aladdin Enterprises
+  */
+ #include "gx.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"
+ #include "gzcolor.h"
+ #include "gzht.h"
+ 
+ void gx_color_load(P2(gx_device_color *, gs_state *));
+ 
+ #define	WEIGHT1		(unsigned long)(100)	/* 1.0 			*/
+ #define	WEIGHT2		(unsigned long)(71)	/* 1/sqrt(2.0) 		*/
+ #define	WEIGHT3		(unsigned long)(62)	/* 1/sqrt(3.0)+tad 	*/
+ 
+ #define	DIAG_R		(0x1)
+ #define	DIAG_G		(0x2)
+ #define	DIAG_B		(0x4)
+ #define	DIAG_RG		(0x3)
+ #define	DIAG_GB		(0x6)
+ #define	DIAG_BR		(0x5)
+ #define	DIAG_RGB	(0x7)
+ 
+ static unsigned short lum[8] = {
+     (0*lum_blue_weight+0*lum_green_weight+0*lum_red_weight),
+     (0*lum_blue_weight+0*lum_green_weight+1*lum_red_weight),
+     (0*lum_blue_weight+1*lum_green_weight+0*lum_red_weight),
+     (0*lum_blue_weight+1*lum_green_weight+1*lum_red_weight),
+     (1*lum_blue_weight+0*lum_green_weight+0*lum_red_weight),
+     (1*lum_blue_weight+0*lum_green_weight+1*lum_red_weight),
+     (1*lum_blue_weight+1*lum_green_weight+0*lum_red_weight),
+     (1*lum_blue_weight+1*lum_green_weight+1*lum_red_weight),
+ };
+ 
+ void
+ gx_color_render(gs_color *pcolor, gx_device_color *pdevc, gs_state *pgs)
+ {	device *pdev = pgs->device;
+ 	unsigned long max_value, mulval;
+ #define divval (max_color_param_long+1)
+ 	unsigned long hsize;
+ 	gx_device *dev;
+ 
+ /* Make a special check for black and white. */
+ 	if ( pcolor->is_gray )
+ 	   {	if ( pcolor->luminance == 0 )
+ 		   {	pdevc->color2 = pdevc->color1 = pdev->black;
+ 			pdevc->halftone_level = 0; /* pure color */
+ 			return;
+ 		   }
+ 		else if ( pcolor->luminance == max_color_param )
+ 		   {	pdevc->color2 = pdevc->color1 = pdev->white;
+ 			pdevc->halftone_level = 0; /* pure color */
+ 			return;
+ 		   }
+ 	   }
+ 
+ /* get a few handy values */
+ 	dev = pdev->info;
+ 	max_value = dev->max_rgb_value;
+ 	mulval = max_value+1;
+ 
+ /* If we are on a high quality RGB display, don't bother dithering. */
+ 	if (max_value >= 255)
+ 	   {	color_param r = (pcolor->red*mulval)/divval;
+ 		color_param g = (pcolor->green*mulval)/divval;
+ 		color_param b = (pcolor->blue*mulval)/divval;
+ 		pdevc->color2 = pdevc->color1 =
+ 			(*dev->procs->map_rgb_color)(dev,r,g,b);
+ 		pdevc->halftone_level = 0;	/* pure color */
+ 		return;
+ 	   }
+ 	hsize = (unsigned)pgs->halftone->order_size;
+ 
+ /* see if we should do it in black and white */
+ 	if ( !dev->has_color || pcolor->is_gray )
+ 	   {
+ 
+ /* if bw device or gray color, use luminance of the color */
+ 		unsigned long nshades = hsize*max_value+1;
+ 		unsigned long lx = (nshades*color_luminance(pcolor))/divval;
+ 		color_param l = lx/hsize;
+ 		pdevc->halftone_level = lx%hsize;
+ 
+ /* check halftone level to see if we have to dither */
+ 		pdevc->color1 = (*dev->procs->map_rgb_color)(dev,l,l,l);
+ 		if ( pdevc->halftone_level == 0 )
+ 			pdevc->color2 = pdevc->color1;
+ 		else
+ 		   {	++l;
+ 			pdevc->color2 =
+ 				(*dev->procs->map_rgb_color)(dev,l,l,l);
+ 			gx_color_load(pdevc, pgs);
+ 		   }
+ 		return;
+ 	   }
+ 
+ /* must do real color dithering */
+    {	unsigned long want_r = pcolor->red*max_value;
+ 	unsigned long want_g = pcolor->green*max_value;
+ 	unsigned long want_b = pcolor->blue*max_value;
+ 	color_param r = want_r/max_color_param_long;
+ 	color_param g = want_g/max_color_param_long;
+ 	color_param b = want_b/max_color_param_long;
+ 	/* rem_{r,g,b} are short, so we can get away with short arithmetic. */
+ 	color_param rem_r = (color_param)want_r-(r*max_color_param);
+ 	color_param rem_g = (color_param)want_g-(g*max_color_param);
+ 	color_param rem_b = (color_param)want_b-(b*max_color_param);
+ 	int adjust_r, adjust_b, adjust_g;
+ 	unsigned short amax;
+ 	unsigned long dmax;
+ 	int axisc, diagc;
+ 	unsigned short lum_invert;
+ 	unsigned long dot1, dot2, dot3;
+ 	int level;
+ 
+ 	/* Check for no dithering required */
+ 	if ( !(rem_r | rem_g | rem_b) )
+ 	   {	pdevc->color2 = pdevc->color1 =
+ 		  (*dev->procs->map_rgb_color)(dev, r, g, b);
+ 		pdevc->halftone_level = 0;
+ 		return;
+ 	   }
+ 
+ /* flip the remainder color into the 0, 0, 0 octant */
+ 	lum_invert = 0;
+ #define half ((color_param)(max_color_param_long>>1))
+ 	if ( rem_r > half )
+ 		rem_r = max_color_param - rem_r,
+ 		  adjust_r = -1, r++, lum_invert += lum_red_weight;
+ 	else
+ 		adjust_r = 1;
+ 	if ( rem_g > half)
+ 		rem_g = max_color_param - rem_g,
+ 		  adjust_g = -1, g++, lum_invert += lum_green_weight;
+ 	else
+ 		adjust_g = 1;
+ 	if ( rem_b > half )
+ 		rem_b = max_color_param - rem_b,
+ 		  adjust_b = -1, b++, lum_invert += lum_blue_weight;
+ 	else
+ 		adjust_b = 1;
+ 	pdevc->color1 = (*dev->procs->map_rgb_color)(dev, r, g, b);
+ /* 
+  * Dot the color with each axis to find the best one of 7;
+  * find the color at the end of the axis chosen.
+  */
+ 	if ( rem_g > rem_r )
+ 	   {	if ( rem_b > rem_g )
+ 			amax = rem_b, axisc = DIAG_B;
+ 		else
+ 			amax = rem_g, axisc = DIAG_G;
+ 		if ( rem_b > rem_r )
+ 			dmax = (unsigned long)rem_g+rem_b, diagc = DIAG_GB;
+ 		else
+ 			dmax = (unsigned long)rem_r+rem_g, diagc = DIAG_RG;
+ 	   }
+ 	else
+ 	   {	if ( rem_b > rem_r )
+ 			amax = rem_b, axisc = DIAG_B;
+ 		else
+ 			amax = rem_r, axisc = DIAG_R;
+ 		if ( rem_b > rem_g )
+ 			dmax = (unsigned long)rem_b+rem_r, diagc = DIAG_BR;
+ 		else
+ 			dmax = (unsigned long)rem_r+rem_g, diagc = DIAG_RG;
+ 	   }
+ 
+ 	dot1 = amax*WEIGHT1;
+ 	dot2 = dmax*WEIGHT2;
+ 	dot3 = (ulong)rem_r+rem_g+rem_b;	/* rgb axis */
+ 	if ( dot1 > dot2 )
+ 	   {	if ( dot3*WEIGHT3 > dot1 )
+ 			diagc = DIAG_RGB,
+ 			  level = (hsize * dot3) / (3 * max_color_param_long);
+ 		else
+ 			diagc = axisc,
+ 			  level = (hsize * amax) / max_color_param_long;
+ 	   }
+ 	else
+ 	   {	if ( dot3*WEIGHT3 > dot2 )
+ 			diagc = DIAG_RGB,
+ 			  level = (hsize * dot3) / (3 * max_color_param_long);
+ 		else
+ 			level = (hsize * dmax) / (2 * max_color_param_long);
+ 	   };
+ #ifdef DEBUG
+ if ( gs_debug['c'] )
+    {	printf("[c]rgb=%x,%x,%x -->\n",
+ 		(unsigned)pcolor->red, (unsigned)pcolor->green,
+ 		(unsigned)pcolor->blue);
+ 	printf("   %x+%x,%x+%x,%x+%x; adjust=%d,%d,%d;\n",
+ 		(unsigned)r, (unsigned)rem_r, (unsigned)g, (unsigned)rem_g,
+ 		(unsigned)b, (unsigned)rem_b, adjust_r, adjust_g, adjust_b);
+    }
+ #endif
+ 
+ 	if ( (pdevc->halftone_level = level) == 0 )
+ 		pdevc->color2 = pdevc->color1;
+ 	else
+ 	   {
+ /* construct the second color, inverting back to original space if needed */
+ 		if (diagc & DIAG_R) r += adjust_r;
+ 		if (diagc & DIAG_G) g += adjust_g;
+ 		if (diagc & DIAG_B) b += adjust_b;
+ /* get the second device color, sorting by luminance */
+ 		if ( lum[diagc] < lum_invert )
+ 		   {	pdevc->color2 = pdevc->color1;
+ 			pdevc->color1 = (*dev->procs->map_rgb_color)(dev, r, g, b);
+ 			pdevc->halftone_level = level = hsize - level;
+ 		   }
+ 		else
+ 			pdevc->color2 = (*dev->procs->map_rgb_color)(dev, r, g, b);
+ 		gx_color_load(pdevc, pgs);
+ 	   }
+ 
+ #ifdef DEBUG
+ if ( gs_debug['c'] )
+    {	printf("[c]diagc=%d; color1=%lx, color2=%lx, level=%d/%d\n",
+ 		diagc, (ulong)pdevc->color1, (ulong)pdevc->color2,
+ 		level, (unsigned)hsize);
+    }
+ #endif
+ 
+    }
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdraw.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdraw.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxdraw.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,315 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxdraw.c */
+ /* Primitive drawing routines for GhostScript imaging library */
+ #include "gx.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gxbitmap.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"			/* requires gsstate.h */
+ #include "gzcolor.h"			/* requires gxdevice.h */
+ 
+ /* These routines all assume that gx_color_render has been called. */
+ 
+ /* Fill a rectangle. */
+ int
+ gz_fill_rectangle(int x, int y, int w, int h, gx_device_color *pdevc,
+   gs_state *pgs)
+ {	gx_color_index darker = pdevc->color1;
+ 	gx_color_index lighter;
+ 	gx_device *dev = pgs->device->info;
+ 	gx_bitmap *tile;
+ 	int code;
+ #ifdef DEBUG
+ if ( gs_debug['q'] )
+ 	printf("[q]x=%d y=%d w=%d h=%d  c1=%ld c2=%ld htl=%d\n",
+ 		x, y, w, h, darker, (long)pdevc->color2,
+ 		(long)pdevc->halftone_level);
+ #endif
+ 	if ( color_is_pure(pdevc) )	/* no halftoning */
+ 	   {	return (*dev->procs->fill_rectangle)(dev, x, y, w, h, darker);
+ 	   }
+ 	lighter = pdevc->color2;
+ 	tile = pdevc->tile;
+ 	/* See if the entire transfer falls within a single tile. */
+ 	/* This is worth a quick check, because tiling is slow. */
+ 	if ( w <= tile->width && h <= tile->height )
+ 	   {	int xmod = x % tile->width, ymod;
+ 		if ( xmod + w <= tile->width &&
+ 		     (ymod = y % tile->height) + h <= tile->height
+ 		   )
+ 		   {	/* Just do a copy. */
+ 			int raster = tile->raster;
+ 			byte *tdata = tile->data + ymod * raster;
+ 			return (color_is_color_halftone(pdevc) ?
+ 				(*dev->procs->copy_color)(dev, tdata,
+ 					xmod, raster, x, y, w, h) :
+ 				(*dev->procs->copy_mono)(dev, tdata,
+ 					xmod, raster, x, y, w, h,
+ 					darker, lighter));
+ 		   }
+ 	   }
+ 	/* Try to tile the rectangle primitively; */
+ 	/* if this fails, use the default implementation. */
+ 	if ( color_is_color_halftone(pdevc) )
+ 		darker = lighter = gx_no_color_index;
+ 	code = (*dev->procs->tile_rectangle)(dev, tile,
+ 		x, y, w, h, darker, lighter);
+ 	if ( code < 0 )
+ 	   {	/* Use the default implementation */
+ 		code = gx_default_tile_rectangle(dev, tile,
+ 			x, y, w, h, darker, lighter);
+ 	   }
+ 	return code;
+ }
+ 
+ /* Fill a trapezoid.  Requires: wt >= 0, wb >= 0. */
+ /* Note that the arguments are fixeds, not ints! */
+ int
+ gz_fill_trapezoid_fixed(fixed fx0, fixed fw0, fixed fy0,
+   fixed fx1, fixed fw1, fixed fh, int swap_axes,
+   gx_device_color *pdevc, gs_state *pgs)
+ {	/* For the moment, we just convert everything to ints. */
+ 	/* Later we will do the right thing with fractional pixels. */
+ 	int x0 = fixed2int(fx0);
+ 	fixed fx0r = fx0 + fw0;
+ 	int w0 = fixed2int_ceiling(fx0r) - x0;
+ 	int y0 = fixed2int(fy0);
+ 	int x1 = fixed2int(fx1);
+ 	fixed fx1r = fx1 + fw1;
+ 	int w1 = fixed2int_ceiling(fx1r) - x1;
+ 	fixed fy1 = fy0 + fh;
+ 	int y1 = fixed2int_ceiling(fy1);
+ 	int h = y1 - y0;
+ 	if ( w0 == 0 && w1 == 0 || h <= 0 ) return 0;
+ 	if ( !swap_axes && color_is_pure(pdevc) )
+ 	   {	gx_device *dev = pgs->device->info;
+ 		if ( (*dev->procs->fill_trapezoid)(dev,
+ 			x0, y0, w0, x1, y1, w1,
+ 			pdevc->color1) >= 0
+ 		   )
+ 			return 0;
+ 	   }
+ 	   {	int xl, fxl;
+ 		int dxl, dxl1, dxlf = x1 - x0;
+ 		int xr, fxr;
+ 		int dxr, dxr1, dxrf = x1 + w1 - (x0 + w0);
+ 		int y = y0;
+ 		int rxl, rxr, ry;
+ 		/* Compute integer and fractional deltas */
+ #define reduce_delta(df, d, d1, pos)\
+ 	if ( df >= 0 )\
+ 	   {	if ( df >= h )\
+ 		  d1 = (d = df / h) + 1, df -= d * h;\
+ 		else	/* save the divides */\
+ 		   {	pos();\
+ 			d = 0, d1 = 1;\
+ 		   }\
+ 	   }\
+ 	else			/* df < 0 */\
+ 	   {	if ( df <= -h )\
+ 		  d1 = (d = df / h) - 1, df = d * h - df;\
+ 		else	/* save the divides */\
+ 		  d = 0, d1 = -1, df = -df;\
+ 	   }
+ #define fill_trap_rect(x,y,w,h)\
+   if ( swap_axes ) gz_fill_rectangle(y, x, h, w, pdevc, pgs);\
+   else gz_fill_rectangle(x, y, w, h, pdevc, pgs)
+ #define pos_for_xl()			/* nothing */
+ 		reduce_delta(dxlf, dxl, dxl1, pos_for_xl);
+ #define pos_for_xr()\
+ 	if ( dxl == 0 && dxlf == 0 && dxrf == 0 )  /* detect rectangle */\
+ 	   {	fill_trap_rect(x0, y0, w0, h);\
+ 		return 0;\
+ 	   }
+ 		reduce_delta(dxrf, dxr, dxr1, pos_for_xr);
+ 		xl = x0, fxl = arith_rshift(dxlf, 1);
+ 		xr = x0 + w0, fxr = arith_rshift(dxrf, 1);
+ 		rxl = xl, rxr = xr, ry = y;
+ 		/* Do the fill */
+ 		do
+ 		   {	if ( xl != rxl || xr != rxr )	/* detect rectangles */
+ 			   {	fill_trap_rect(rxl, ry, rxr - rxl, y - ry);
+ 				rxl = xl, rxr = xr, ry = y;
+ 			   }
+ 			if ( (fxl += dxlf) >= h ) fxl -= h, xl += dxl1;
+ 			else xl += dxl;
+ 			if ( (fxr += dxrf) >= h ) fxr -= h, xr += dxr1;
+ 			else xr += dxr;
+ 		   }
+ 		while ( ++y < y1 );
+ 		if ( y != ry )
+ 		   {	fill_trap_rect(rxl, ry, rxr - rxl, y - ry);
+ 		   }
+ #undef fill_trap_rect
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Default implementation of tile_rectangle */
+ int
+ gx_default_tile_rectangle(gx_device *dev, register gx_bitmap *tile,
+   int x, int y, int w, int h, gx_color_index color0, gx_color_index color1)
+ {	/* Fill the rectangle in chunks */
+ 	int width = tile->width;
+ 	int height = tile->height;
+ 	int raster = tile->raster;
+ 	int ex = x + w, ey = y + h;
+ 	int fex = ex - width, fey = ey - height;
+ 	int irx = ((width & (width - 1)) == 0 ?	/* power of 2 */
+ 		x & (width - 1) :
+ 		x % width);
+ 	int ry = y % height;
+ 	int icw = width - irx;
+ 	int ch = height - ry;
+ 	byte *row = tile->data + ry * raster;
+ 	int (*proc_mono)(P10(gx_device *, byte *, int, int,
+ 		int, int, int, int, gx_color_index, gx_color_index));
+ 	int (*proc_color)(P8(gx_device *, byte *, int, int,
+ 		int, int, int, int));
+ 	int color_halftone =
+ 		(color0 == gx_no_color_index && color1 == gx_no_color_index);
+ 	int cx, cy;
+ 	if ( color_halftone )
+ 		proc_color = dev->procs->copy_color;
+ 	else
+ 		proc_mono = dev->procs->copy_mono;
+ #ifdef DEBUG
+ if ( gs_debug['t'] )
+    {	int ptx, pty;
+ 	byte *ptp = tile->data;
+ 	printf("[t]tile w=%d h=%d raster=%d; x=%d y=%d w=%d h=%d\n",
+ 		tile->width, tile->height, tile->raster, x, y, w, h);
+ 	for ( pty = 0; pty < tile->height; pty++ )
+ 	   {	printf("   ");
+ 		for ( ptx = 0; ptx < tile->raster; ptx++ )
+ 			printf("%3x", *ptp++);
+ 	   }
+ 	printf("\n");
+    }
+ #endif
+ 	if ( icw > w ) icw = w;
+ 	if ( ch > h ) ch = h;
+ #define real_copy_tile(sourcex, tx, tw)\
+   (color_halftone ?\
+     (*proc_color)(dev, row, sourcex, raster, tx, cy, tw, ch) :\
+     (*proc_mono)(dev, row, sourcex, raster, tx, cy, tw, ch, color0, color1))
+ #ifdef DEBUG
+ #define copy_tile(sx, tx, tw)\
+   if ( gs_debug['t'] )\
+ 	printf("   copy sx=%d x=%d y=%d w=%d h=%d\n",\
+ 		sx, tx, cy, tw, ch);\
+   real_copy_tile(sx, tx, tw)
+ #else
+ #define copy_tile(sx, tx, tw)\
+   real_copy_tile(sx, tx, tw)
+ #endif
+ 	for ( cy = y; cy < ey; )
+ 	   {	copy_tile(irx, x, icw);
+ 		cx = x + icw;
+ 		while ( cx <= fex )
+ 		   {	copy_tile(0, cx, width);
+ 			cx += width;
+ 		   }
+ 		if ( cx < ex )
+ 		   {	copy_tile(0, cx, ex - cx);
+ 		   }
+ 		cy += ch;
+ 		ch = (cy > fey ? ey - cy : height);
+ 		row = tile->data;
+ 	   }
+ #undef copy_tile
+ #undef real_copy_tile
+ 	return 0;
+ }
+ 
+ /* Draw a one-pixel-wide line. */
+ int
+ gz_draw_line_fixed(fixed ixf, fixed iyf, fixed itoxf, fixed itoyf,
+   gx_device_color *pdevc, gs_state *pgs)
+ {	int ix = fixed2int(ixf);
+ 	int iy = fixed2int(iyf);
+ 	int itox = fixed2int(itoxf);
+ 	int itoy = fixed2int(itoyf);
+ 	if ( itoy == iy )		/* horizontal line */
+ 	   {	if ( ix <= itox )
+ 			gz_fill_rectangle(ix, iy, fixed2int_ceiling(itoxf) -
+ 						ix, 1, pdevc, pgs);
+ 		else
+ 			gz_fill_rectangle(itox, iy, fixed2int_ceiling(ixf) -
+ 						itox, 1, pdevc, pgs);
+ 	   }
+ 	else
+ 	   {	gx_device *dev = pgs->device->info;
+ 		fixed h, w, tf;
+ #define fswap(a, b) tf = a, a = b, b = tf
+ 		if ( color_is_pure(pdevc) &&
+ 		    (*dev->procs->draw_line)(dev, ix, iy, itox, itoy,
+ 					     pdevc->color1) >= 0 )
+ 		  return 0;
+ 		h = itoyf - iyf;
+ 		w = itoxf - ixf;
+ #define fixed_eps (fixed)1
+ 		if ( (w < 0 ? -w : w) <= (h < 0 ? -h : h) )
+ 		   {	if ( h < 0 )
+ 				fswap(ixf, itoxf), fswap(iyf, itoyf),
+ 				h = -h;
+ 			gz_fill_trapezoid_fixed(ixf, fixed_eps, iyf,
+ 						itoxf, fixed_eps, h,
+ 						0, pdevc, pgs);
+ 		   }
+ 		else
+ 		   {	if ( w < 0 )
+ 				fswap(ixf, itoxf), fswap(iyf, itoyf),
+ 				w = -w;
+ 			gz_fill_trapezoid_fixed(iyf, fixed_eps, ixf,
+ 						itoyf, fixed_eps, w,
+ 						1, pdevc, pgs);
+ 		   }
+ #undef fixed_eps
+ #undef fswap
+ 	   }
+ 	return 0;
+ }
+ 
+ /****** STUBS ******/
+ int
+ gx_default_draw_line(gx_device *dev,
+   int x0, int y0, int x1, int y1, gx_color_index color)
+ {	return -1;
+ }
+ int
+ gx_default_fill_trapezoid(gx_device *dev,
+   int x0, int y0, int width0, int x1, int y1, int width1,
+   gx_color_index color)
+ {	return -1;
+ }
+ int
+ gx_default_tile_trapezoid(gx_device *dev, gx_bitmap *tile,
+   int x0, int y0, int width0, int x1, int y1, int width1,
+   gx_color_index color0, gx_color_index color1)
+ {	return -1;
+ }
+ int
+ gx_default_tile_trapezoid_color(gx_device *dev, gx_bitmap *tile,
+   int x0, int y0, int width0, int x1, int y1, int width1)
+ {	return -1;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfdir.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfdir.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfdir.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,50 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxfdir.h */
+ /* Font directory (font/character cache manager) definitions */
+ /* Requires gsfont.h. */
+ 
+ /* A font directory (font/character cache manager). */
+ struct gs_font_dir_s {
+ 	proc_alloc_t alloc;
+ 	proc_free_t free;
+ 	/* Font directory */
+ 	long next_id;			/* next unique ID */
+ 	/* Scaled font cache */
+ 	gs_font *scaled_fonts;		/* list of recently scaled fonts */
+ 	uint ssize, smax;
+ 	/* Character cache parameters and statistics */
+ 	uint bsize, bmax;		/* # of bytes for cached chars */
+ 	uint msize, mmax;		/* # of cached font/matrix pairs */
+ 	uint csize, cmax;		/* # of cached chars */
+ 	uint lower;			/* min size at which cached chars */
+ 					/* should be stored compressed */
+ 	uint upper;			/* max size of a single cached char */
+ 	/* Character cache */
+ #define gx_char_cache_modulus 128	/* must be power of 2 */
+ 	struct cached_char_s *chars[gx_char_cache_modulus];	/* chain heads */
+ 	byte *bdata;
+ 	uint bnext;			/* rover for allocating cached character data */
+ 	struct cached_fm_pair_s *mdata;
+ 	uint mnext;			/* rover for allocating font/matrix pairs */
+ 	struct cached_char_s *cdata;
+ 	uint cnext;			/* rover for allocating cached_chars */
+ };
+ 


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfill.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfill.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfill.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,638 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxfill.c */
+ /* Lower-level path filling procedures for GhostScript library */
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxmatrix.h"
+ #include "gxdevice.h"			/* for gx_color_index */
+ #include "gzcolor.h"
+ #include "gzpath.h"
+ #include "gzstate.h"
+ 
+ /* Define the structure for keeping track of active lines. */
+ typedef struct active_line_s {
+ 	gs_fixed_point start;		/* x,y where line starts */
+ 	gs_fixed_point end;		/* x,y where line ends */
+ #define al_dx(alp) ((alp)->end.x - (alp)->start.x)
+ #define al_dy(alp) ((alp)->end.y - (alp)->start.y)
+ 	fixed y_fast_max;		/* can do x_at_y in fixed point */
+ 					/* if y <= y_fast_max */
+ #define set_al_points(alp, startp, endp)\
+   (alp)->y_fast_max = max_fixed / (((endp).x > (startp).x ?\
+     (endp).x - (startp).x : (startp).x - (endp).x) | 1) + (startp).y,\
+   (alp)->start = startp, (alp)->end = endp
+ #define _xaty(alp, yv)\
+   ((yv) - (alp)->start.y) * al_dx(alp) / al_dy(alp)
+ #define al_x_at_y(alp, yv)\
+   ((yv) == (alp)->end.y ? (alp)->end.x :\
+    ((yv) <= (alp)->y_fast_max ? _xaty(alp, yv) :\
+     (stat(n_slow_x), (fixed)((double)_xaty(alp, yv)))) + (alp)->start.x)
+ 	fixed x_current;		/* current x position */
+ 	fixed x_next;			/* x position at end of band */
+ 	segment *pseg;			/* endpoint of this line */
+ 	int direction;			/* direction of line segment */
+ #define dir_up 1
+ #define dir_down (-1)
+ 	short tag;			/* distinguish path from clip path */
+ 	short end_mark;			/* marks lines about to end (even) */
+ 					/* or cross (odd) */
+ /* "Pending" lines (not reached in the Y ordering yet) use next and prev */
+ /* to order lines by increasing starting Y.  "Active" lines (being scanned) */
+ /* use next and prev to order lines by increasing current X, or if the */
+ /* current Xs are equal, by increasing final X. */
+ 	struct active_line_s
+ 		*prev, *next;
+ } active_line;
+ 
+ #ifdef DEBUG
+ /* Internal procedure for printing an active line */
+ private void
+ print_active_line(char *label, active_line *alp)
+ {	printf("[f]%s %lx(%d): x_current=%f x_next=%f\n",
+ 	       label, (ulong)alp, alp->tag, fixed2float(alp->x_current),
+ 	       fixed2float(alp->x_next));
+ 	printf("    start=(%f,%f) pt_end=%lx(%f,%f)\n",
+ 	       fixed2float(alp->start.x), fixed2float(alp->start.y),
+ 	       (ulong)alp->pseg,
+ 	       fixed2float(alp->end.x), fixed2float(alp->end.y));
+ 	printf("    mark=%d dir=%d prev=%lx next=%lx\n",
+ 		alp->end_mark, alp->direction,
+ 		(ulong)alp->prev, (ulong)alp->next);
+ }
+ #define print_al(label,alp)\
+   if ( gs_debug['F'] ) print_active_line(label, alp)
+ #else
+ #define print_al(label,alp) 0
+ #endif
+ 
+ /* Line list structure */
+ struct line_list_s {
+ 	active_line *area;		/* allocated area */
+ 	uint area_count;
+ 	short tag;			/* tag for lines being added */
+ 	active_line *next;		/* next allocation slot */
+ 	active_line *y_list;		/* Y-sorted list of pending lines */
+ 	active_line *y_line;		/* most recently inserted line */
+ 	active_line x_head;		/* X-sorted list of active lines */
+ #define x_list x_head.next
+ 	int no_clip;			/* true if clipping not needed */
+ };
+ typedef struct line_list_s line_list;
+ 
+ /* Forward declarations */
+ private int alloc_line_list(P2(line_list *, int));
+ private void add_y_list(P4(gx_path *, short, line_list *, gs_fixed_rect *));
+ private void add_y_line(P4(segment *, segment *, int, line_list *));
+ private void fill_loop(P6(gx_device_color *, int, line_list *,
+   gs_fixed_rect *, gs_state *, fixed));
+ private void insert_x_new(P2(active_line *, line_list *));
+ private void swap_group(P1(active_line *));
+ private void ended_line(P1(active_line *));
+ 
+ /* Statistics */
+ #ifdef DEBUG
+ #define stat(x) (x++)
+ #define statn(x,n) (x += (n))
+ private long n_fill;
+ private long n_fill_alloc;
+ private long n_y_up;
+ private long n_y_down;
+ private long n_x_step;
+ private long n_slow_x;
+ private long n_iter;
+ private long n_find_y;
+ private long n_band;
+ private long n_band_step;
+ private long n_band_fill;
+ #else
+ #define stat(x) 0
+ #define statn(x,n) 0
+ #endif
+ 
+ /* Main filling algorithm. */
+ /* Caller has done compute_draw_color. */
+ /* The trim parameter is a hack for keeping small characters */
+ /* from coming out too blurry: it specifies an amount by which to shrink */
+ /* all sides of every filled region. */
+ int
+ gx_fill_path(gx_path *ppath, gx_device_color *pdevc, gs_state *pgs,
+   int rule, fixed trim)
+ {	gx_path *cpath = pgs->clip_path;
+ 	gx_path *pfpath;
+ 	gx_path ffpath;
+ 	int code;
+ 	line_list lst;
+ 	int max_active;
+ 	/* The closepath is only needed because of the check in */
+ 	/* ended_line as to whether we are the end of a subpath. */
+ 	gx_path_close_subpath(ppath);
+ 	/* Start by flattening the path.  We should do this on-the-fly.... */
+ 	if ( !ppath->curve_count )	/* don't need to flatten */
+ 		pfpath = ppath;
+ 	else
+ 	   {	if ( (code = gx_path_flatten(ppath, &ffpath, pgs->flatness)) < 0 ) return code;
+ 		pfpath = &ffpath;
+ 	   }
+ 	/* may be 1 extra segment per subpath, for closing */
+ 	max_active = pfpath->segment_count + pfpath->subpath_count +
+ 		cpath->segment_count + cpath->subpath_count;
+ 	if ( !(code = alloc_line_list(&lst, max_active)) )
+ 	   {	gs_fixed_rect ibox;
+ 		gx_path_bbox(pfpath, &ibox);
+ 		if ( ibox.q.y <= cpath->cbox.q.y &&
+ 		     ibox.q.x <= cpath->cbox.q.x &&
+ 		     ibox.p.y >= cpath->cbox.p.y &&
+ 		     ibox.p.x >= cpath->cbox.p.x
+ 		   )
+ 		   {	/* Path lies entirely within clipping rectangle */
+ 			lst.no_clip = 1;
+ 		   }
+ 		else
+ 		   {	lst.no_clip = 0;
+ 			/* Intersect the path box and the clip bounding box */
+ #define int_box(pqxy, rel)\
+   if ( cpath->bbox.pqxy rel ibox.pqxy )\
+     ibox.pqxy = cpath->bbox.pqxy
+ 			int_box(p.x, >);
+ 			int_box(p.y, >);
+ 			int_box(q.x, <);
+ 			int_box(q.y, <);
+ #undef int_box
+ 			if ( ibox.p.x >= ibox.q.x || ibox.p.y >= ibox.q.y )
+ 			   {	/* Intersection of boxes is empty! */
+ 				goto skip;
+ 			   }
+ 			add_y_list(cpath, (short)1, &lst, &ibox);
+ 		   }
+ 		add_y_list(pfpath, (short)0, &lst, &ibox);
+ 		fill_loop(pdevc, rule, &lst, &ibox, pgs, trim);
+ skip:		gs_free((char *)lst.area, lst.area_count, sizeof(active_line), "active lines");
+ 	   }
+ 	if ( pfpath != ppath )	/* had to flatten */
+ 		gx_path_release(pfpath);
+ #ifdef DEBUG
+ if ( gs_debug['f'] || gs_debug['F'] )
+ 	   {	printf("[f]calls alloc   up   down  step slowx  iter  find  band bstep bfill\n");
+ 		printf("   %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld\n",
+ 			n_fill, n_fill_alloc, n_y_up, n_y_down,
+ 			n_x_step, n_slow_x, n_iter, n_find_y,
+ 			n_band, n_band_step, n_band_fill);
+ 	   }
+ #endif
+ 	return code;
+ }
+ 
+ /* Create a line list for a (flattened) path. */
+ /* We pass in the list size, so that we can use this to iterate */
+ /* over more than one path simultaneously (needed for clipping). */
+ private int
+ alloc_line_list(line_list *ll, int count)
+ {	ll->area_count = count;
+ 	ll->area = (active_line *)gs_malloc(count, sizeof(active_line),
+ 					    "active lines");
+ 	if ( ll->area == 0 ) return_error(gs_error_VMerror);
+ 	ll->next = ll->area;
+ 	ll->y_list = 0;
+ 	ll->y_line = 0;
+ 	stat(n_fill);
+ 	statn(n_fill_alloc, count);
+ 	return 0;
+ }
+ 
+ /* Construct a Y-sorted list of lines for a (flattened) path. */
+ /* We assume the path is non-empty.  Only include non-horizontal */
+ /* lines where one endpoint is locally Y-minimal. */
+ private void
+ add_y_list(gx_path *ppath, short tag, line_list *ll, gs_fixed_rect *pbox)
+ {	register segment *pseg = (segment *)ppath->first_subpath;
+ 	subpath *psub;
+ 	segment *plast;
+ 	int prev_dir, dir;
+ 	segment *prev;
+ 	fixed xmin = pbox->p.x, ymin = pbox->p.y;
+ 	fixed xmax = pbox->q.x, ymax = pbox->q.y;
+ 	ll->tag = tag;
+ 	while ( pseg )
+ 	   {	fixed dy;
+ 		switch ( pseg->type )
+ 		   {	/* No curves left */
+ 		case s_start:
+ 			psub = (subpath *)pseg;
+ 			plast = psub->last;
+ 			dir = 0;
+ 			break;
+ 		default:		/* s_line, _close */
+ 		   {	fixed iy = pseg->pt.y;
+ 			fixed py = prev->pt.y;
+ 			/* Lines falling entirely outside the ibox */
+ 			/* are treated as though they were horizontal, */
+ 			/* i.e., they are never put on the list. */
+ #define compute_dir(xo, xe, yo, ye)\
+   (xo > xmax && xe > xmax ? 0 :\
+    (dy = ye - yo) > 0 ? (ye <= ymin || yo >= ymax ? 0 : dir_up) :\
+    dy < 0 ? (yo <= ymin || ye >= ymax ? 0 : dir_down) :\
+    0)
+ 			dir = compute_dir(prev->pt.x, pseg->pt.x, py, iy);
+ 			if ( dir > prev_dir )
+ 			   {	if ( prev_dir )
+ 				  add_y_line(prev->prev, prev, prev_dir, ll);
+ 				if ( dir )
+ 				  add_y_line(prev, pseg, dir, ll);
+ 			   }
+ 			if ( pseg == plast )
+ 			   {	/* The beginning of a subpath is always */
+ 				/* treated like a horizontal line, */
+ 				/* so the last segment must receive */
+ 				/* special consideration. */
+ 				if ( pseg->type != s_line_close )
+ 				   {	/* "Close" an open subpath */
+ 					int cdir;
+ 					py = psub->pt.y;
+ 					cdir = compute_dir(pseg->pt.x, psub->pt.x, iy, py);
+ 					if ( cdir > dir && dir )
+ 					  add_y_line(prev, pseg, dir, ll);
+ 					if ( cdir > dir && cdir || cdir < 0 )
+ 					  add_y_line(pseg, (segment *)psub, cdir, ll);
+ 				   }
+ 				else
+ 				   {	/* Just add the closing line if needed */
+ 					if ( dir < 0 )
+ 					  add_y_line(prev, pseg, dir, ll);
+ 				   }
+ 			   }
+ 		   }
+ #undef compute_dir
+ 		   }
+ 		prev = pseg;
+ 		prev_dir = dir;
+ 		pseg = pseg->next;
+ 	   }
+ }
+ /* Internal routine to test a line segment and add it to the */
+ /* pending list if appropriate. */
+ private void
+ add_y_line(segment *prev_lp, segment *lp, int dir, line_list *ll)
+ {	gs_fixed_point this, prev;
+ 	register active_line *alp = ll->next++;
+ 	fixed y_start;
+ 	this.x = lp->pt.x;
+ 	this.y = lp->pt.y;
+ 	prev.x = prev_lp->pt.x;
+ 	prev.y = prev_lp->pt.y;
+ 	alp->tag = ll->tag;
+ 	if ( (alp->direction = dir) > 0 )
+ 	   {	/* Upward line */
+ 		y_start = prev.y;
+ 		set_al_points(alp, prev, this);
+ 		alp->pseg = lp;
+ 	   }
+ 	else
+ 	   {	/* Downward line */
+ 		y_start = this.y;
+ 		set_al_points(alp, this, prev);
+ 		alp->pseg = prev_lp;
+ 	   }
+ 	/* Insert the new line in the Y ordering */
+ 	   {	register active_line *yp = ll->y_line;
+ 		register active_line *nyp;
+ 		if ( yp == 0 )
+ 		   {	alp->next = alp->prev = 0;
+ 			ll->y_list = alp;
+ 		   }
+ 		else if ( y_start >= yp->start.y )
+ 		   {	/* Insert the new line after y_line */
+ 			while ( stat(n_y_up), (nyp = yp->next) != NULL && y_start > nyp->start.y )
+ 				yp = nyp;
+ 			alp->next = nyp;
+ 			alp->prev = yp;
+ 			yp->next = alp;
+ 			if ( nyp ) nyp->prev = alp;
+ 		   }
+ 		else
+ 		   {	/* Insert the new line before y_line */
+ 			while ( stat(n_y_down), (nyp = yp->prev) != NULL && y_start < nyp->start.y )
+ 				yp = nyp;
+ 			alp->prev = nyp;
+ 			alp->next = yp;
+ 			yp->prev = alp;
+ 			if ( nyp ) nyp->next = alp;
+ 			else ll->y_list = alp;
+ 		   }
+ 	   }
+ 	ll->y_line = alp;
+ 	print_al("add ", alp);
+ }
+ 
+ /* Find the intersection of two active lines that are known to cross. */
+ /* Only called if al_x_at_y(alp, y1) < al_x_at_y(endp, y1). */
+ private fixed
+ find_cross_y(register active_line *endp, register active_line *alp)
+ {	double edy = (double)al_dy(endp);
+ 	double ady = (double)al_dy(alp);
+ #define xprod(alp)\
+   ((double)alp->start.x * alp->end.y - (double)alp->start.y * alp->end.x)
+ #define ycross()\
+   (fixed)((xprod(endp) * ady - xprod(alp) * edy) /\
+ 	  (al_dx(alp) * edy - al_dx(endp) * ady))
+ #ifndef DEBUG
+ 	return ycross();
+ #else
+ 	fixed cross_y;
+ 	if ( al_dx(alp) * edy - al_dx(endp) * ady == 0 )
+ 	   {	printf("[f]denom == 0!\n");
+ 		gs_debug['F'] = 1;
+ 		print_al(" l1 ", endp);
+ 		print_al(" l2 ", alp);
+ 		exit(1);
+ 	   }
+ 	cross_y = ycross();
+ if ( gs_debug['F'] )
+ 	printf("[f]cross %lx %lx -> %f\n",
+ 	       (ulong)endp, (ulong)alp,
+ 	       fixed2float(cross_y));
+ 	return cross_y;
+ #endif
+ #undef xprod
+ #undef ycross
+ }
+ 
+ /* Main filling loop.  Takes lines off of y_list and adds them to */
+ /* x_list as needed. */
+ private void
+ fill_loop(gx_device_color *pdevc, int rule, line_list *ll,
+   gs_fixed_rect *pbox, gs_state *pgs, fixed trim)
+ {	active_line *yll = ll->y_list;
+ 	gs_fixed_point pmax;
+ 	fixed y;
+ 	if ( yll == 0 ) return;		/* empty list */
+ 	pmax = pbox->q;
+ 	y = yll->start.y;		/* first Y value */
+ 	ll->x_list = 0;
+ 	ll->x_head.end_mark = -4;	/* to delimit swap group */
+ 	while ( 1 )
+ 	   {	fixed y1;
+ 		int end_count;
+ 		active_line *endp, *alp, *alstop;
+ 		fixed x;
+ 		stat(n_iter);
+ 		/* Check whether we've reached the maximum y. */
+ 		if ( y >= pmax.y ) break;
+ 		/* Move newly active lines from y to x list. */
+ 		while ( yll != 0 && yll->start.y == y )
+ 		   {	active_line *ynext = yll->next;	/* insert smashes next/prev links */
+ 			insert_x_new(yll, ll);
+ 			yll = ynext;
+ 		   }
+ 		if ( ll->x_list == 0 )
+ 		   {	/* No active lines, skip to next start */
+ 			if ( yll == 0 ) break;	/* no lines left */
+ 			y = yll->start.y;
+ 			continue;
+ 		   }
+ 		/* Find the next evaluation point. */
+ 		/* Start by finding the smallest y value */
+ 		/* at which any currently active line ends */
+ 		/* (or the next to-be-active line begins). */
+ 		y1 = (yll != 0 ? yll->start.y : max_fixed);
+ 		for ( alp = ll->x_list; alp != 0; alp = alp->next )
+ 		  if ( alp->end.y < y1 ) y1 = alp->end.y;
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+    {		active_line *lp;
+ 		printf("[f]y=%f y1=%f:\n", fixed2float(y), fixed2float(y1));
+ 		for ( lp = ll->x_list; lp != 0; lp = lp->next )
+ 			printf("[f]%lx: x_current=%f\n", (ulong)lp,
+ 				fixed2float(lp->x_current));
+    }
+ #endif
+ 		/* Now look for line intersections before y1. */
+ 		/* The lines requiring attention at the end of */
+ 		/* band filling are those whose end_mark >= end_count. */
+ 		/* Each time we reset y1 downward, */
+ 		/* we increment end_count by 4 so that we don't */
+ 		/* try to swap or drop lines that haven't */
+ 		/* crossed or ended yet. */
+ 		end_count = 0;
+ 		x = min_fixed;
+ 		alstop = ll->x_list;
+ 		/* Loop invariant: x == al_x_at_y(endp, y1); */
+ 		/* for all lines alp up to alstop, */
+ 		/* alp->x_next = al_x_at_y(alp, y1). */
+ 		for ( alp = alstop; stat(n_find_y), alp != 0;
+ 		     endp = alp, alp = alp->next
+ 		    )
+ 		   {	/* Check for intersecting lines. */
+ 			fixed nx = al_x_at_y(alp, y1);
+ 			alp->x_next = nx;
+ 			if ( nx < x )
+ 			   {	/* stop at intersection */
+ 				y1 = find_cross_y(endp, alp);
+ 				while ( 1 )
+ 				   {	x = al_x_at_y(endp, y1);
+ 					nx = al_x_at_y(alp, y1);
+ 					if ( nx <= x ) break;
+ 					/* This can only result from */
+ 					/* low-order-bit inaccuracy */
+ 					/* in computing the crossing y. */
+ 					/* Bump y by 1. */
+ 					y1++;
+ 				   }
+ 				endp->x_next = x;
+ 				alp->x_next = nx;
+ 				alstop = endp;
+ 				end_count += 4;
+ 				endp->end_mark = end_count + 3;
+ 				alp->end_mark = end_count + 1;
+ 			   }
+ 			else if ( alp->end.y == y1 )	/* can't be < */
+ 			   {	alp->end_mark = end_count;
+ 			   }
+ 			else
+ 				alp->end_mark = -2;
+ 			x = nx;
+ 		   }
+ 		/* Recompute next_x for lines before the intersection. */
+ 		for ( alp = ll->x_list; alp != alstop; alp = alp->next )
+ 			alp->x_next = al_x_at_y(alp, y1);
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+    {		active_line *lp;
+ 		printf("[f]y1=%f end_count=%d\n",
+ 			fixed2float(y1), end_count);
+ 		for ( lp = ll->x_list; lp != 0; lp = lp->next )
+ 		  printf("[f]%lx: x_next=%f end_mark=%d\n",
+ 			 (ulong)lp, fixed2float(lp->x_next), lp->end_mark);
+    }
+ #endif
+ 		/* Fill a multi-trapezoid band for the active lines. */
+ 		/* Drop ended lines (with end_mark = end_count) from the */
+ 		/* list.  Reverse the order of groups of adjacent lines */
+ 		/* that intersect at y = y1: the last line of such a group */
+ 		/* has end_mark = end_count+1, the previous ones have */
+ 		/* end_mark = end_count+3. */
+ 		   {	active_line *alp = ll->x_list;
+ 			fixed height = y1 - y;
+ 			fixed xlbot, xltop;	/* as of last "outside" line */
+ 			int inside[2];
+ 			inside[0] = 0;			/* 0 for path */
+ 			inside[1] = ll->no_clip;	/* 1 for clip path */
+ 			stat(n_band);
+ 			/* rule = -1 for winding number rule, i.e. */
+ 			/* we are inside if the winding number is non-zero; */
+ 			/* rule = 1 for even-odd rule, i.e. */
+ 			/* we are inside if the winding number is odd. */
+ 			/* Clever, eh? */
+ #define inside_path_p() ((inside[0] & rule) && (inside[1] & pgs->clip_rule))
+ 			while ( alp != 0 )
+ 			   {	fixed xbot = alp->x_current;
+ 				fixed xtop = alp->x_next;
+ 				active_line *next = alp->next;
+ 				print_al("step", alp);
+ 				stat(n_band_step);
+ 				if ( inside_path_p() )
+ 				 { inside[alp->tag] += alp->direction;
+ 				   if ( !inside_path_p() )	/* about to go out */
+ 				    {	stat(n_band_fill);
+ 					gz_fill_trapezoid_fixed(xlbot + trim,
+ 					  xbot - xlbot - (trim << 1), y,
+ 					  xltop + trim,
+ 					  xtop - xltop - (trim << 1), height,
+ 					  0, pdevc, pgs);
+ 				    }
+ 				 }
+ 				else			/* outside */
+ 				   {	inside[alp->tag] += alp->direction;
+ 					if ( inside_path_p() )	/* about to go in */
+ 						xlbot = xbot, xltop = xtop;
+ 				   }
+ 				alp->x_current = xtop;
+ 				if ( alp->end_mark >= end_count )
+ 				   {	/* This line is ending here, or */
+ 					/* this is the last of an */
+ 					/* intersection group. */
+ 					switch ( alp->end_mark & 3 )
+ 					   {
+ 					/* case 3: in a group, not last */
+ 					case 1:	/* last line of a group */
+ 						swap_group(alp);
+ 						break;
+ 					case 0:	/* ending line */
+ 						ended_line(alp);
+ 					   }
+ 				   }
+ 				alp = next;
+ 			   }
+ 		   }
+ 		y = y1;
+ 	   }
+ }
+ 
+ /* Internal routine to insert a newly active line in the X ordering */
+ private void
+ insert_x_new(active_line *alp, line_list *ll)
+ {	register active_line *next;
+ 	register active_line *prev = &ll->x_head;
+ 	register fixed x = alp->start.x;
+ 	while ( stat(n_x_step), (next = prev->next) != 0 &&
+ 		  (next->x_current < x || next->x_current == x &&
+ 		   (next->start.x > alp->start.x ||
+ 		    next->end.x < alp->end.x))
+ 	       )
+ 		prev = next;
+ 	alp->next = next;
+ 	alp->prev = prev;
+ 	if ( next != 0 ) next->prev = alp;
+ 	prev->next = alp;
+ 	alp->x_current = x;
+ }
+ /* Auxiliary procedure to swap the lines of an intersection group */
+ private void
+ swap_group(active_line *alp)
+ {	/* This line is the last of the group: */
+ 	/* find the beginning of the group. */
+ 	active_line *prev;
+ 	active_line *last = alp;
+ 	active_line *first;
+ 	active_line *next = alp->next;
+ 	while ( ((prev = alp->prev)->end_mark & 3) == 3 )
+ 		alp = prev;
+ 	first = alp;
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+ 	printf("[f]swap %lx thru %lx\n", (ulong)first, (ulong)last);
+ #endif
+ 	/* Swap the group end-for-end. */
+ 	/* Start by fixing up the ends. */
+ 	prev->next = last;
+ 	if ( next != 0 )
+ 		next->prev = first;
+ 	first->prev = next;
+ 	last->next = prev;
+ 	do
+ 	   {	active_line *nlp = alp->next;
+ 		alp->next = alp->prev;
+ 		alp->prev = nlp;
+ 		alp = nlp;
+ 	   }
+ 	while ( alp != prev );
+ }
+ /* Auxiliary procedure to handle a line that just ended */
+ private void
+ ended_line(register active_line *alp)
+ {	segment *pseg = alp->pseg;
+ 	segment *next;
+ 	fixed y = pseg->pt.y;
+ 	gs_fixed_point npt;
+ 	if ( alp->direction == dir_up )
+ 	   {	/* Upward line, go forward along path */
+ 		next = pseg->next;
+ 		if ( next == 0 || next->type == s_start )
+ 			next = pseg;	/* stop here */
+ 	   }
+ 	else
+ 	   {	/* Downward line, go backward along path */
+ 		next = (pseg->type == s_start ? pseg /* stop here */ : pseg->prev);
+ 	   }
+ 	npt.y = next->pt.y;
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+ 	printf("[f]ended %lx: pseg=%lx y=%f next=%lx npt.y=%f\n",
+ 		(ulong)alp, (ulong)pseg, fixed2float(y),
+ 		(ulong)next, fixed2float(npt.y));
+ #endif
+ 	if ( npt.y <= y )
+ 	   {	/* End of a line sequence */
+ 		active_line *nlp = alp->next;
+ 		alp->prev->next = nlp;
+ 		if ( nlp ) nlp->prev = alp->prev;
+ #ifdef DEBUG
+ if ( gs_debug['F'] )
+ 		printf("[f]drop %lx\n", (ulong)alp);
+ #endif
+ 	   }
+ 	else
+ 	   {	alp->pseg = next;
+ 		npt.x = next->pt.x;
+ 		set_al_points(alp, alp->end, npt);
+ 		print_al("repl", alp);
+ 	   }
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfixed.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfixed.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfixed.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,97 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxfixed.h */
+ /* Fixed-point arithmetic for GhostScript */
+ 
+ /*
+  * Coordinates are generally represented internally by fixed-point
+  * quantities: integers lose accuracy in crucial places,
+  * and floating point arithmetic is slow.
+  */
+ typedef long fixed;
+ #define max_fixed 0x7fffffffL
+ #define min_fixed (~max_fixed)
+ /*
+  * 12 bits of fraction provides both the necessary accuracy and
+  * a sufficiently large range of coordinates.
+  */
+ #define _fixed_shift 12
+ #define _fixed_scale (1<<_fixed_shift)
+ #define _fixed_rshift(x) arith_rshift(x,_fixed_shift)
+ #define _fixed_round_v (_fixed_scale>>1)
+ #define _fixed_fraction_v (_fixed_scale-1)
+ 
+ /*
+  * Most operations can be done directly on fixed-point quantities:
+  * addition, subtraction, shifting, multiplication or division by
+  * (integer) constants; assignment, assignment with zero;
+  * comparison, comparison against zero.
+  * Multiplication and division by floats is OK if the result is
+  * explicitly cast back to fixed.
+  * Conversion to and from int and float types must be done explicitly.
+  * Note that if we are casting a fixed to a float in a context where
+  * only ratios and not actual values are involved, we don't need to take
+  * the scale factor into account: we can simply cast to float directly.
+  */
+ #define int2fixed(i) ((fixed)(i)<<_fixed_shift)
+ /*
+  * Because of the way conversions from fixed to int are defined
+  * on MS-DOS systems, the argument of fixed2int must be a variable
+  * (or at least something that has an l-value).
+  */
+ #ifdef __MSDOS__
+ /* Assume 16-bit ints, little-endian machine. */
+ #  define _fixed_hi(x) *((uint *)&(x)+1)
+ #  define _fixed_lo(x) *((uint *)&(x))
+ #  define fixed2int(x)\
+ 	((int)((_fixed_hi(x) << (16-_fixed_shift)) +\
+ 	       (_fixed_lo(x) >> _fixed_shift)))
+ #  define fixed2int_rounded(x)\
+ 	((int)((_fixed_hi(x) << (16-_fixed_shift)) +\
+ 	       (((_fixed_lo(x) >> (_fixed_shift-1))+1)>>1)))
+ #  define fixed2int_ceiling(x)\
+ 	(fixed2int(x) -\
+ 	 arith_rshift((int)-(_fixed_lo(x) & _fixed_fraction_v), _fixed_shift))
+ #else					/* use reasonable definitions */
+ #  define fixed2int(x) ((int)_fixed_rshift(x))
+ #  define fixed2int_rounded(x) ((int)_fixed_rshift((x)+_fixed_round_v))
+ #  define fixed2int_ceiling(x) ((int)_fixed_rshift((x)+_fixed_fraction_v))
+ #endif
+ /* The other definitions are more reasonable. */
+ #define fixed2long(x) ((long)_fixed_rshift(x))
+ #define fixed2long_rounded(x) ((long)_fixed_rshift((x)+_fixed_round_v))
+ #define fixed2long_ceiling(x) ((long)_fixed_rshift((x)+_fixed_fraction_v))
+ #define float2fixed(f) ((fixed)((f)*(float)_fixed_scale))
+ #define fixed2float(x) ((float)((x)*(1.0/_fixed_scale)))
+ 
+ /* Rounding and truncation on fixeds */
+ #define fixed_truncated(x) ((x)&(-1L<<_fixed_shift))
+ #define fixed_rounded(x) (((x)+_fixed_round_v)&(-1L<<_fixed_shift))
+ #define fixed_fraction(x) ((x)&_fixed_fraction_v)
+ 
+ /* A point with fixed coordinates */
+ typedef struct gs_fixed_point_s {
+ 	fixed x, y;
+ } gs_fixed_point;
+ 
+ /* A rectangle with fixed coordinates */
+ typedef struct gs_fixed_rect_s {
+ 	gs_fixed_point p, q;
+ } gs_fixed_rect;


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfont.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfont.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfont.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,45 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxfont.h */
+ /* Internal font definition for GhostScript library */
+ /* Requires gsmatrix.h, gxdevice.h */
+ #include "gsfont.h"
+ 
+ /* A font object as seen by the user. */
+ /* See pp. 91-93 of the PostScript manual for details. */
+ typedef int (*gs_proc_build_char)
+      (P5(struct gs_show_enum_s *, struct gs_state_s *, struct gs_font_s *,
+ 	 int /* char code */, char * /* build_char_data */));
+ int gs_no_build_char_proc
+      (P5(struct gs_show_enum_s *, struct gs_state_s *, struct gs_font_s *,
+ 	 int, char *));
+ struct gs_font_s {
+ 	gs_font *next, *prev;		/* chain for scaled font cache */
+ 	gs_font *base;			/* original (unscaled) base font */
+ 	gs_font_dir *dir;		/* directory where registered */
+ 	char *client_data;		/* additional client data */
+ 	gs_matrix matrix;		/* FontMatrix */
+ 	int font_type;			/* FontType */
+ 	float xmin, ymin, xmax, ymax;	/* FontBBox */
+ 	int paint_type;			/* PaintType */
+ 	long unique_id;			/* UniqueID */
+ 	gs_proc_build_char build_char_proc;	/* BuildChar */
+ 	char *build_char_data;		/* private data for BuildChar */
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfont1.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfont1.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxfont1.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,33 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxfont1.h */
+ /* Type 1 font information for GhostScript library. */
+ 
+ /* This is (part of) the client_data for a gs_font. */
+ /* Eventually there may be many other entries here, */
+ /* per the Adobe Black Book. */
+ typedef struct gs_type1_data_s gs_type1_data;
+ struct gs_type1_data_s {
+ 	int (*subr_proc)(P3(gs_type1_data *pdata,
+ 			    int index, byte **pcharstring));
+ 	int (*pop_proc)(P2(gs_type1_data *, fixed *));
+ 	char *proc_data;		/* data for subr_proc */
+ 	int lenIV;			/* # of leading garbage bytes */
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxht.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxht.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxht.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,257 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxht.c */
+ /* Halftone rendering routines for Ghostscript imaging library */
+ #include "memory_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"			/* ditto */
+ #include "gxmatrix.h"			/* for gxdevice.h */
+ #include "gxbitmap.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"
+ #include "gzcolor.h"			/* requires gxdevice.h */
+ #include "gzht.h"
+ 
+ /*
+  * We don't want to remember all the values of the halftone screen,
+  * because they would take up space proportional to P^3, where P is
+  * the number of pixels in a cell.  Instead, we pick some number N of
+  * patterns to cache.  Each cache slot covers a range of (P+1)/N
+  * different gray levels: we "slide" the contents of the slot back and
+  * forth within this range by incrementally adding and dropping 1-bits.
+  * N>=0 (obviously); N<=P+1 (likewise); also, so that we can simplify things
+  * by preallocating the bookkeeping information for the cache, we define
+  * a constant max_cached_tiles which is an a priori maximum value for N.
+  *
+  * Note that the raster for each tile must be a multiple of 32 bits,
+  * to satisfy the copy_mono device routine, even though a multiple of
+  * 16 bits would otherwise be sufficient.
+  */
+ #define max_cached_tiles 25
+ typedef struct bit_tile_s {
+ 	int level;			/* the cached gray level, i.e. */
+ 					/* the number of spots whitened, */
+ 					/* or -1 if the cache is empty */
+ 	gx_bitmap tile;			/* the currently rendered tile */
+ } bit_tile;
+ typedef struct gx_ht_cache_s {
+ 	/* The following are set when the cache is created. */
+ 	byte *bits;			/* the base of the bits */
+ 	uint bits_size;			/* the space available for bits */
+ 	/* The following are reset each time the cache is initialized */
+ 	/* for a new screen. */
+ 	ht_bit *order;			/* the cached order vector */
+ 	int num_cached;			/* actual # of cached tiles */
+ 	int levels_per_tile;		/* # of levels per cached tile */
+ 	bit_tile tiles[max_cached_tiles];	/* the cached tiles */
+ } ht_cache;
+ private ht_cache cache;
+ #define max_ht_bits 1000		/* arbitrary, maybe too small */
+ private byte cache_bits[max_ht_bits];
+ /* Bit masks for whitening vector.  We have to initialize these */
+ /* indirectly, because they are different for big- and little-endian */
+ /* machines. */
+ typedef unsigned short bit16;
+ private byte single_bits8[16*2] =
+    {	0x80,0, 0x40,0, 0x20,0, 0x10,0, 8,0, 4,0, 2,0, 1,0,
+ 	0,0x80, 0,0x40, 0,0x20, 0,0x10, 0,8, 0,4, 0,2, 0,1
+    };
+ #define single_bits ((bit16 *)single_bits8)
+ private byte mb1[2] =
+    {	0xff,0xff };
+ private byte mb2[4] =
+    {	0xaa,0xaa, 0x55,0x55 };
+ private byte mb3[6] =
+    {	0x92,0x49, 0x49,0x24, 0x24,0x92 };
+ private byte mb4[8] =
+    {	0x88,0x88, 0x44,0x44, 0x22,0x22, 0x11,0x11 };
+ private byte mb5[10] =
+    {	0x84,0x21, 0x42,0x10, 0x21,0x08, 0x10,0x84, 0x08,0x42 };
+ private byte mb6[12] =
+    {	0x82,0x08, 0x41,0x04, 0x20,0x82, 0x10,0x41, 0x08,0x20, 0x04,0x10 };
+ private byte mb7[14] =
+    {	0x81,0x02, 0x40,0x81, 0x20,0x40, 0x10,0x20, 0x08,0x10, 0x04,0x08,
+ 		0x02,0x04
+    };
+ private byte mb8[16] =
+    {	0x80,0x80, 0x40,0x40, 0x20,0x20, 0x10,0x10, 0x08,0x08, 0x04,0x04,
+ 		0x02,0x02, 0x01,0x01
+    };
+ private bit16 *multi_bits[9] =
+    {	0, (bit16 *)mb1, (bit16 *)mb2, (bit16 *)mb3, (bit16 *)mb4,
+ 	(bit16 *)mb5, (bit16 *)mb6, (bit16 *)mb7, (bit16 *)mb8
+    };
+ 
+ /* Construct the order vector.  order is an array of ht_bits: */
+ /* order[i].offset contains the index of the bit position */
+ /* that is i'th in the whitening order. */
+ int
+ gx_ht_construct_order(ht_bit *order, int width, int height)
+ {	uint i;
+ 	uint size = (uint)(width * height);
+ 	int padding = (-width) & 31;
+ 	if ( (width + padding) / 8 * height > max_ht_bits )
+ 		return_error(gs_error_limitcheck);	/* can't cache the rendering */
+ 	/* Clear the cache, to avoid confusion in case */
+ 	/* the address of a new order vector matches that of a */
+ 	/* (deallocated) old one. */
+ 	cache.order = NULL;
+ 	cache.bits = cache_bits;
+ 	cache.bits_size = max_ht_bits;
+ 	/* Convert sequential indices to */
+ 	/* byte indices and mask values. */
+ 	for ( i = 0; i < size; i++ )
+ 	   {	int pix = order[i].offset;
+ 		pix += pix / width * padding;
+ 		order[i].offset = (pix >> 4) << 1;
+ 		order[i].mask =
+ 			(width <= 8 ?
+ 			 multi_bits[width][pix & 15] :
+ 			 single_bits[pix & 15]);
+ 	   }
+ #ifdef DEBUG
+ if ( gs_debug['h'] )
+ 	   {	printf("[h]Halftone order %lx:\n", (ulong)order);
+ 		for ( i = 0; i < size; i++ )
+ 			printf("%4d: %u:%x\n", i, order[i].offset,
+ 				order[i].mask);
+ 	   }
+ #endif
+ 	return 0;
+ }
+ 
+ /* Load the device color into the halftone cache if needed. */
+ private void render_ht(P3(bit_tile *, int, halftone *));
+ private void init_ht(P2(ht_cache *, halftone *));
+ void
+ gx_color_load(register gx_device_color *pdevc, gs_state *pgs)
+ {	int level = pdevc->halftone_level;
+ 	halftone *pht;
+ 	bit_tile *bt;
+ 	if ( level == 0 ) return;	/* no halftone */
+ 	pht = pgs->halftone;
+ 	if ( cache.order != pht->order )
+ 		init_ht(&cache, pht);
+ 	bt = &cache.tiles[level / cache.levels_per_tile];
+ 	if ( bt->level != level )
+ 		render_ht(bt, level, pht);
+ 	pdevc->tile = &bt->tile;
+ }
+ 
+ /* Initialize the tile cache for a given screen. */
+ /* Cache as many different levels as will fit. */
+ private void
+ init_ht(ht_cache *pcache, halftone *pht)
+ {	int width = pht->width;
+ 	int height = pht->height;
+ 	int size = width * height;
+ 	static int up_to_16[] =
+ 		/* up_to_16[i] = 16 / i * i */
+ 		{ 0, 16, 16, 15, 16, 15, 12, 14, 16 };
+ 	int width_unit = (width <= 8 ? up_to_16[width] : width);
+ 	uint raster = ((width + 31) >> 5) << 2;
+ 	uint tile_bytes = raster * height;
+ 	int num_cached;
+ 	int i;
+ 	byte *tbits = pcache->bits;
+ 	/* Make sure num_cached is within bounds */
+ 	num_cached = max_ht_bits / tile_bytes;
+ 	if ( num_cached > size ) num_cached = size;
+ 	if ( num_cached > max_cached_tiles ) num_cached = max_cached_tiles;
+ 	for ( i = 0; i < num_cached; i++ )
+ 	   {	register bit_tile *bt = &pcache->tiles[i];
+ 		bt->level = -1;
+ 		bt->tile.data = tbits;
+ 		bt->tile.raster = raster;
+ 		bt->tile.width = width_unit;
+ 		bt->tile.height = height;
+ 		tbits += tile_bytes;
+ 	   }
+ 	pcache->order = pht->order;
+ 	pcache->num_cached = num_cached;
+ 	pcache->levels_per_tile = (size + num_cached - 1) / num_cached;
+ }
+ 
+ /*
+  * Compute and save the rendering of a given gray level
+  * with the current halftone.  The cache holds multiple tiles,
+  * where each tile covers a range of possible levels.
+  * If the tile whose range includes the desired level is already loaded,
+  * we adjust it incrementally: this saves a lot of time for
+  * the average image, where gray levels don't change abruptly.
+  * Note that we will never be asked to cache levels 0 or order_size,
+  * which correspond to black or white respectively.
+  */
+ private void
+ render_ht(bit_tile *pbt, int level /* [1..order_size-1] */, halftone *pht)
+ {	ht_bit *order = pht->order;
+ 	register ht_bit *p;
+ 	register ht_bit *endp;
+ 	register byte *bits = pbt->tile.data;
+ 	int old_level = pbt->level;
+ 	if ( old_level < 0 )
+ 	   {	/* The cache is empty.  Preload it with */
+ 		/* whichever of all-0s and all-1s will be faster. */
+ 		uint tile_bytes = pbt->tile.raster * pbt->tile.height;
+ 		if ( level >= pht->order_size >> 1 )
+ 		   {	old_level = pht->order_size;
+ 			memset(bits, 0xff, tile_bytes);
+ 		   }
+ 		else
+ 		   {	old_level = 0;
+ 			memset(bits, 0, tile_bytes);
+ 		   }
+ 	   }
+ #ifdef DEBUG
+ 	if ( level < 0 || level > pht->order_size || level == old_level )
+ 	   {	dprintf3("Error in render_ht: level=%d, old_level=%d, order_size=%d=n", level, old_level, pht->order_size);
+ 		exit(1);
+ 	   }
+ #endif
+ 	/* Note that we can use the same loop to turn bits either */
+ 	/* on or off, using xor.  We use < to compare pointers, */
+ 	/* rather than ==, because Turbo C only compares the */
+ 	/* low 16 bits for < and > but compares all 32 bits for ==. */
+ 	if ( level > old_level )
+ 		p = &order[old_level], endp = &order[level];
+ 	else
+ 		p = &order[level], endp = &order[old_level];
+ 	/* Invert bits between the two pointers */
+ 	do
+ 	   {	*(bit16 *)&bits[p->offset] ^= p->mask;
+ 	   }
+ 	while ( ++p < endp );
+ #ifdef DEBUG
+ if ( gs_debug['h'] )
+ 	   {	byte *p = bits;
+ 		int wb = pbt->tile.raster;
+ 		byte *ptr = bits + wb * pbt->tile.height;
+ 		printf("[h]Halftone cache %lx: old=%d, new=%d, w=%d(%d), h=%d(%d):\n",
+ 			(ulong)bits, old_level, level, pbt->tile.width,
+ 		        pht->width, pbt->tile.height, pht->height);
+ 		while ( p < ptr )
+ 		   {	printf(" %02x", *p++);
+ 			if ( (p - bits) % wb == 0 ) printf("\n");
+ 		   }
+ 	   }
+ #endif
+ 	pbt->level = level;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gximage.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gximage.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gximage.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,66 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gximage.h */
+ /* Internal definitions for image rendering */
+ /* Requires gzcolor.h */
+ 
+ /* Imaging state structure */
+ /* The Unix C compiler can't handle typedefs for procedure */
+ /* (as opposed to pointer-to-procedure) types, */
+ /* so we have to do it with a macro instead: */
+ #define iunpack_proc_args\
+ 	P4(gs_image_enum *, byte *, byte *, uint)
+ #define irender_proc_args\
+ 	P4(gs_image_enum *, byte *, uint, int)
+ struct gs_image_enum_s {
+ 	/* Following are set at structure initialization */
+ 	int width;
+ 	int height;
+ 	int log2_bps;			/* log2(bits per sample), [0..3] */
+ 	int spp;			/* samples per pixel, 1, 3, or 4 */
+ 	int spread;			/* spp if colors are separated, */
+ 					/* 1 otherwise */
+ 	fixed fxx, fxy, fyx, fyy;	/* fixed version of matrix */
+ 	void (*unpack)(iunpack_proc_args);
+ 	int (*render)(irender_proc_args);
+ 	gs_state *pgs;
+ 	byte *buffer;			/* for expanding to 8 bits/sample */
+ 	uint buffer_size;
+ 	uint bytes_per_row;		/* # of input bytes per row */
+ 					/* (per plane, if spp == 1 and */
+ 					/* spread > 1) */
+ 	int never_clip;			/* true if entire image fits */
+ 	int skewed;			/* true if image is skewed */
+ 					/* or rotated */
+ 	int slow_loop;			/* true if !never_clip, skewed, */
+ 					/* or imagemask with a halftone */
+ 	/* Following are updated dynamically */
+ 	byte *planes[4];		/* separated color data */
+ 	int plane_index;		/* current plane index, [0..spp) */
+ 	uint plane_size;		/* size of data in each plane */
+ 	uint byte_in_row;		/* current input byte position in row */
+ 	fixed xcur, ycur;		/* device x, y of current row */
+ 	int y;
+ 	/* Entries 0 and 255 of the following are set at initialization, */
+ 	/* other entries are updated dynamically */
+ 	gx_device_color dev_colors[256];
+ #define icolor0 dev_colors[0].color1
+ #define icolor1 dev_colors[255].color1
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxmatrix.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxmatrix.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxmatrix.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,38 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxmatrix.h */
+ /* Internal matrix routines for GhostScript library */
+ #include "gsmatrix.h"
+ 
+ /* A matrix with a cached fixed-point copy of the translation. */
+ /* This is only used by a few routines; they are responsible */
+ /* for ensuring the validity of the cache. */
+ typedef struct gs_matrix_fixed_s {
+ 	_matrix_body;
+ 	fixed tx_fixed, ty_fixed;
+ } gs_matrix_fixed;
+ 
+ /* Coordinate transformations to fixed point */
+ int	gs_point_transform2fixed(P4(gs_matrix_fixed *, floatp, floatp, gs_fixed_point *)),
+ 	gs_distance_transform2fixed(P4(gs_matrix_fixed *, floatp, floatp, gs_fixed_point *));
+ 
+ /* Macro for testing whether matrix coefficients are zero, */
+ /* for shortcuts when the matrix has no skew. */
+ #define is_skewed(pmat) !is_fzero2((pmat)->xy, (pmat)->yx)


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,399 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxpath.c */
+ /* Private path routines for GhostScript library */
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gzpath.h"
+ 
+ /* These routines all assume that all points are */
+ /* already in device coordinates, and in fixed representation. */
+ /* As usual, they return either 0 or a (negative) error code. */
+ 
+ /* Forward references */
+ private subpath *path_alloc_copy(P1(gx_path *));
+ #ifdef DEBUG
+ void gx_print_segment(P2(FILE *, segment *));
+ #endif
+ 
+ /* ------ Initialize/free paths ------ */
+ 
+ /* Initialize a path */
+ void
+ gx_path_init(register gx_path *ppath, gs_memory_procs *pprocs)
+ {	ppath->memory_procs = *pprocs;
+ 	ppath->box_last = 0;
+ 	ppath->position_valid = 0;
+ 	ppath->first_subpath = ppath->current_subpath = 0;
+ 	ppath->subpath_count = 0;
+ 	ppath->segment_count = 0;
+ 	ppath->curve_count = 0;
+ 	ppath->subpath_open = 0;
+ 	ppath->shares_segments = 0;
+ }
+ 
+ /* Release the contents of a path.  We do this in reverse order */
+ /* so as to maximize LIFO allocator behavior. */
+ void
+ gx_path_release(gx_path *ppath)
+ {	segment *pseg;
+ 	if ( ppath->first_subpath == 0 ) return;	/* empty path */
+ 	if ( ppath->shares_segments ) return;	/* segments are shared */
+ 	pseg = (segment *)ppath->current_subpath->last;
+ 	while ( pseg )
+ 	   {	segment *prev = pseg->prev;
+ 		unsigned size;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 		printf("[p]release"), gx_print_segment(stdout, pseg);
+ #endif
+ 		switch ( pseg->type )
+ 		   {
+ 		case s_start: size = sizeof(subpath); break;
+ 		case s_line:
+ 		case s_line_close: size = sizeof(line_segment); break;
+ 		case s_curve: size = sizeof(curve_segment); break;
+ 		default:
+ 			dprintf1("bad type in gx_path_release: %x!\n", pseg->type);
+ 			exit(1);
+ 		   }
+ #ifdef DEBUG
+ if ( gs_debug['A'] )
+ 		printf("[p]free %lx<%u>\n", (ulong)pseg, size);
+ #endif
+ 		(*ppath->memory_procs.free)((char *)pseg, 1, size, "gx_path_release");
+ 		pseg = prev;
+ 	   }
+ 	ppath->first_subpath = 0;	/* prevent re-release */
+ }
+ 
+ /* Mark a path as shared */
+ void
+ gx_path_share(gx_path *ppath)
+ {	if ( ppath->first_subpath ) ppath->shares_segments = 1;
+ }
+ 
+ /* ------ Incremental path building ------ */
+ 
+ /* Macro for opening the current subpath. */
+ /* ppath points to the path; psub has been set to ppath->current_subpath. */
+ #define path_open()\
+ 	if ( !ppath->subpath_open )\
+ 	   {	int code;\
+ 		if ( !ppath->position_valid )\
+ 		  return_error(gs_error_nocurrentpoint);\
+ 		code = gx_path_new_subpath(ppath);\
+ 		if ( code < 0 ) return code;\
+ 		psub = ppath->current_subpath;\
+ 	   }
+ 
+ /* Macros for allocating path segments. */
+ /* Note that they assume that ppath points to the path, */
+ /* and that psub points to the current subpath. */
+ /* We have to split the macro into two because of limitations */
+ /* on the size of a single statement (sigh). */
+ #ifdef DEBUG
+ #define p_alloc(pseg,size)\
+   if ( gs_debug['A'] ) printf("[p]%lx<%u>\n", (ulong)pseg, size)
+ #else
+ #define p_alloc(pseg,size) 0
+ #endif
+ #define path_unshare(set_psub)\
+   if(ppath->shares_segments)\
+     if(!(set_psub path_alloc_copy(ppath)))return_error(gs_error_limitcheck)
+ #define path_alloc_segment(pseg,ctype,stype,cname)\
+   path_unshare(psub=);\
+   if( !(pseg = (ctype *)(*ppath->memory_procs.alloc)(1, sizeof(ctype), cname)) )\
+     return_error(gs_error_limitcheck);\
+   p_alloc((char *)pseg, sizeof(ctype));\
+   pseg->type = stype, pseg->next = 0
+ #define path_alloc_link(pseg)\
+   { segment *prev = psub->last;\
+     prev->next = (segment *)pseg;\
+     pseg->prev = prev;\
+     psub->last = (segment *)pseg;\
+   }
+ 
+ /* Open a new subpath */
+ int
+ gx_path_new_subpath(gx_path *ppath)
+ {	subpath *psub = ppath->current_subpath;
+ 	register subpath *spp;
+ 	path_alloc_segment(spp, subpath, s_start, "gx_path_new_subpath");
+ 	spp->last = (segment *)spp;
+ 	spp->line_count = spp->curve_count = 0;
+ 	spp->closed = 0;
+ 	spp->pt = ppath->position;
+ 	ppath->subpath_open = 1;
+ 	if ( !psub )			/* first subpath */
+ 	   {	ppath->first_subpath = spp;
+ 		spp->prev = 0;
+ 	   }
+ 	else
+ 	   {	segment *prev = psub->last;
+ 		prev->next = (segment *)spp;
+ 		spp->prev = prev;
+ 	   }
+ 	ppath->current_subpath = spp;
+ 	ppath->subpath_count++;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	printf("[p]"), gx_print_segment(stdout, (segment *)spp);
+ #endif
+ 	return 0;
+ }
+ 
+ /* Add a point to the current path (moveto). */
+ int
+ gx_path_add_point(register gx_path *ppath, fixed x, fixed y)
+ {	ppath->subpath_open = 0;
+ 	ppath->position_valid = 1;
+ 	ppath->position.x = x;
+ 	ppath->position.y = y;
+ 	return 0;
+ }
+ 
+ /* Add a relative point to the current path (rmoveto). */
+ int
+ gx_path_add_relative_point(register gx_path *ppath, fixed dx, fixed dy)
+ {	if ( !ppath->position_valid )
+ 	  return_error(gs_error_nocurrentpoint);
+ 	ppath->subpath_open = 0;
+ 	ppath->position.x += dx;
+ 	ppath->position.y += dy;
+ 	return 0;
+ }
+ 
+ /* Set the segment point and the current point in the path. */
+ /* Assumes ppath points to the path. */
+ #define path_set_point(pseg, fx, fy)\
+ 	(pseg)->pt.x = ppath->position.x = (fx),\
+ 	(pseg)->pt.y = ppath->position.y = (fy)
+ 
+ /* Add a line to the current path (lineto). */
+ int
+ gx_path_add_line(gx_path *ppath, fixed x, fixed y)
+ {	subpath *psub = ppath->current_subpath;
+ 	register line_segment *lp;
+ 	path_open();
+ 	path_alloc_segment(lp, line_segment, s_line, "gx_path_add_line");
+ 	path_alloc_link(lp);
+ 	path_set_point(lp, x, y);
+ 	psub->line_count++;
+ 	ppath->segment_count++;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	printf("[p]"), gx_print_segment(stdout, (segment *)lp);
+ #endif
+ 	return 0;
+ }
+ 
+ /* Add a rectangle to the current path. */
+ /* This is a special case of adding a parallelogram. */
+ int
+ gx_path_add_rectangle(gx_path *ppath, fixed x0, fixed y0, fixed x1, fixed y1)
+ {	return gx_path_add_pgram(ppath, x0, y0, x0, y1, x1, y1);
+ }
+ 
+ /* Add a parallelogram to the current path. */
+ /* This is equivalent to an add_point, three add_lines, */
+ /* and a close_subpath. */
+ int
+ gx_path_add_pgram(gx_path *ppath,
+   fixed x0, fixed y0, fixed x1, fixed y1, fixed x2, fixed y2)
+ {	int code;
+  	if (	(code = gx_path_add_point(ppath, x0, y0)) < 0 ||
+ 		(code = gx_path_add_line(ppath, x1, y1)) < 0 ||
+ 		(code = gx_path_add_line(ppath, x2, y2)) < 0 ||
+ 		(code = gx_path_add_line(ppath, x0 + x2 - x1, y0 + y2 - y1)) < 0 ||
+ 		(code = gx_path_close_subpath(ppath)) < 0
+ 	   ) return code;
+ 	return 0;
+ }
+ 
+ /* Add a curve to the current path (curveto). */
+ int
+ gx_path_add_curve(gx_path *ppath,
+   fixed x1, fixed y1, fixed x2, fixed y2, fixed x3, fixed y3)
+ {	subpath *psub = ppath->current_subpath;
+ 	register curve_segment *lp;
+ 	path_open();
+ 	path_alloc_segment(lp, curve_segment, s_curve, "gx_path_add_curve");
+ 	path_alloc_link(lp);
+ 	lp->p1.x = x1;
+ 	lp->p1.y = y1;
+ 	lp->p2.x = x2;
+ 	lp->p2.y = y2;
+ 	path_set_point(lp, x3, y3);
+ 	psub->curve_count++;
+ 	ppath->segment_count++;
+ 	ppath->curve_count++;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	printf("[p]"), gx_print_segment(stdout, (segment *)lp);
+ #endif
+ 	return 0;
+ }
+ 
+ /* Add an approximation of an arc to the current path. */
+ /* Parameters are the initial and final points of the arc, */
+ /* and the point at which the extended tangents meet.*/
+ /* We assume that the arc is less than a semicircle. */
+ /* The arc may go either clockwise or counterclockwise. */
+ /* The approximation is a very simple one: a single curve */
+ /* whose other two control points are .55 of the way to the */
+ /* intersection of the tangents.  This appears to produce a */
+ /* very accurate circular arc: I haven't worked out the math */
+ /* to understand why. */
+ #define arc_magic 0.55
+ int
+ gx_path_add_arc(gx_path *ppath,
+   fixed x0, fixed y0, fixed x3, fixed y3, fixed xt, fixed yt)
+ {	fixed xm = (fixed)(xt * arc_magic), ym = (fixed)(yt * arc_magic);
+ 	return gx_path_add_curve(ppath,
+ 			(fixed)(x0 * (1 - arc_magic)) + xm,
+ 			(fixed)(y0 * (1 - arc_magic)) + ym,
+ 			(fixed)(x3 * (1 - arc_magic)) + xm,
+ 			(fixed)(y3 * (1 - arc_magic)) + ym,
+ 			x3, y3);
+ }
+ 
+ /* Close the current subpath. */
+ int
+ gx_path_close_subpath(gx_path *ppath)
+ {	subpath *psub = ppath->current_subpath;
+ 	register line_segment *lp;
+ 	if ( !ppath->subpath_open ) return 0;
+ 	/* If the current point is the same as the initial point, */
+ 	/* and the last segment was a s_line, change it to a s_line_close; */
+ 	/* otherwise add a s_line_close segment.  This is just a minor */
+ 	/* efficiency hack, nothing depends on it. */
+ 	if ( ppath->position.x == psub->pt.x &&
+ 	     ppath->position.y == psub->pt.y &&
+ 	     psub->last->type == s_line
+ 		)
+ 	   {	path_unshare(0 !=); /* don't set psub */
+ 		psub->last->type = s_line_close;
+ 		lp = 0;		/* (actually only needed for debugging) */
+ 	   }
+ 	else
+ 	   {	path_alloc_segment(lp, line_segment, s_line_close,
+ 				   "gx_path_close_subpath");
+ 		path_alloc_link(lp);
+ 		path_set_point(lp, psub->pt.x, psub->pt.y);
+ 		psub->line_count++;
+ 		ppath->segment_count++;
+ 	   }
+ 	psub->closed = 1;
+ 	ppath->subpath_open = 0;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	if ( lp != 0 )
+ 	  printf("[p]"), gx_print_segment(stdout, (segment *)lp);
+ #endif
+ 	return 0;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Copy the current path, because it was shared. */
+ /* Return a pointer to the current subpath, or 0. */
+ private subpath *
+ path_alloc_copy(gx_path *ppath)
+ {	gx_path path_new;
+ 	int code;
+ 	code = gx_path_copy(ppath, &path_new);
+ 	if ( code < 0 ) return 0;
+ 	*ppath = path_new;
+ 	ppath->shares_segments = 0;
+ 	return ppath->current_subpath;
+ }
+ 
+ /* ------ Debugging printout ------ */
+ 
+ #ifdef DEBUG
+ 
+ /* Print out a path with a label */
+ void
+ gx_dump_path(gx_path *ppath, char *tag)
+ {	printf("[p]Path %lx %s:\n", (ulong)ppath, tag);
+ 	gx_path_print(stdout, ppath);
+ }
+ 
+ /* Print a path */
+ void
+ gx_path_print(FILE *file, gx_path *ppath)
+ {	segment *pseg = (segment *)ppath->first_subpath;
+ 	fprintf(file, "   subpaths=%d, segments=%d, curves=%d, point=(%f,%f)\n",
+ 		ppath->subpath_count, ppath->segment_count, ppath->curve_count,
+ 		fixed2float(ppath->position.x),
+ 		fixed2float(ppath->position.y));
+ 	fprintf(file, "   box=(%f,%f),(%f,%f) last=%lx\n",
+ 		fixed2float(ppath->bbox.p.x), fixed2float(ppath->bbox.p.y),
+ 		fixed2float(ppath->bbox.q.x), fixed2float(ppath->bbox.q.y),
+ 		(ulong)ppath->box_last);
+ 	fprintf(file, "   cbox=(%f,%f),(%f,%f)\n",
+ 		fixed2float(ppath->cbox.p.x), fixed2float(ppath->cbox.p.y),
+ 		fixed2float(ppath->cbox.q.x), fixed2float(ppath->cbox.q.y));
+ 	while ( pseg )
+ 	   {	gx_print_segment(file, pseg);
+ 		pseg = pseg->next;
+ 	   }
+ }
+ void
+ gx_print_segment(FILE *file, segment *pseg)
+ {	char out[80];
+ 	sprintf(out, "   %lx<%lx,%lx>: %%s (%6g,%6g) ",
+ 		(ulong)pseg, (ulong)pseg->prev, (ulong)pseg->next,
+ 		fixed2float(pseg->pt.x), fixed2float(pseg->pt.y));
+ 	switch ( pseg->type )
+ 	   {
+ 	case s_start:
+ #define psub ((subpath *)pseg)
+ 		fprintf(file, out, "start");
+ 		fprintf(file, "#lines=%d #curves=%d last=%lx",
+ 			psub->line_count, psub->curve_count, (ulong)psub->last);
+ #undef psub
+ 		break;
+ 	case s_curve:
+ 		fprintf(file, out, "curve");
+ #define pcur ((curve_segment *)pseg)
+ 		fprintf(file, "\n\tp1=(%f,%f) p2=(%f,%f)",
+ 			fixed2float(pcur->p1.x), fixed2float(pcur->p1.y),
+ 			fixed2float(pcur->p2.x), fixed2float(pcur->p2.y));
+ #undef pcur
+ 		break;
+ 	case s_line:
+ 		fprintf(file, out, "line");
+ 		break;
+ 	case s_line_close:
+ 		fprintf(file, out, "close");
+ 		break;
+ 	default:
+ 	   {	char t[20];
+ 		sprintf(t, "type 0x%x", pseg->type);
+ 		fprintf(file, out, t);
+ 	   }
+ 	   }
+ 	fprintf(file, "\n");
+ }
+ 
+ #endif					/* DEBUG */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:23 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,71 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxpath.h */
+ /* Lower-level path routines for GhostScript library */
+ /* Requires gxfixed.h */
+ 
+ /* The routines and types in this interface all use */
+ /* device, rather than user, coordinates, and almost all */
+ /* use fixed-point, rather than floating, representation. */
+ 
+ /* Opaque type for a path */
+ typedef struct gx_path_s gx_path;
+ extern unsigned gs_path_sizeof;
+ 
+ /* Opaque type for a path enumerator */
+ typedef struct gx_path_enum_s gx_path_enum;
+ extern unsigned gx_path_enum_sizeof;
+ 
+ /* Define the two insideness rules */
+ #define gx_rule_winding_number (-1)
+ #define gx_rule_even_odd 1
+ 
+ /* Path constructors.  Note that the only procedure that involves */
+ /* a graphics state is gx_path_init. */
+ extern	void	gx_path_init(P2(gx_path *, gs_memory_procs *)),
+ 		gx_path_release(P1(gx_path *)),
+ 		gx_path_share(P1(gx_path *));
+ extern	int	gx_path_new_subpath(P1(gx_path *)),
+ 		gx_path_add_point(P3(gx_path *, fixed, fixed)),
+ 		gx_path_add_relative_point(P3(gx_path *, fixed, fixed)),
+ 		gx_path_add_line(P3(gx_path *, fixed, fixed)),
+ 		gx_path_add_rectangle(P5(gx_path *, fixed, fixed, fixed, fixed)),
+ 		gx_path_add_pgram(P7(gx_path *, fixed, fixed, fixed, fixed, fixed, fixed)),
+ 		gx_path_add_curve(P7(gx_path *, fixed, fixed, fixed, fixed, fixed, fixed)),
+ 		gx_path_add_arc(P7(gx_path *, fixed, fixed, fixed, fixed, fixed, fixed)),
+ 		gx_path_close_subpath(P1(gx_path *));
+ 
+ /* Path accessors and transformers */
+ extern	int	gx_path_current_point(P2(gx_path *, gs_fixed_point *)),
+ 		gx_path_bbox(P2(gx_path *, gs_fixed_rect *)),
+ 		gx_path_has_curves(P1(gx_path *)),
+ 		gx_path_is_void(P1(gx_path *)),
+ 		gx_path_is_rectangle(P2(gx_path *, gs_fixed_rect *)),
+ 		gx_cpath_box_for_check(P2(gx_path *, gs_fixed_rect *)),
+ 		gx_cpath_includes_rectangle(P5(gx_path *, fixed, fixed, fixed, fixed)),
+ 		gx_path_copy(P2(gx_path * /*old*/, gx_path * /*to*/)),
+ 		gx_path_flatten(P3(gx_path * /*old*/, gx_path * /*new*/, floatp)),
+ 		gx_path_merge(P2(gx_path * /*from*/, gx_path * /*to*/)),
+ 		gx_path_translate(P3(gx_path *, fixed, fixed));
+ 
+ /* Debugging routines */
+ #ifdef DEBUG
+ extern	void	gx_path_print(P2(FILE *, gx_path *));
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath2.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath2.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxpath2.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,394 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxpath2.c */
+ /* Path tracing procedures for GhostScript library */
+ #include "math_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxarith.h"
+ #include "gzpath.h"
+ 
+ /* Forward declarations */
+ private int copy_path(P3(gx_path *, gx_path *,
+   int (*)(P7(gx_path *, fixed, fixed, fixed, fixed, fixed, fixed))));
+ private int flatten_curve(P7(gx_path *,
+   fixed, fixed, fixed, fixed, fixed, fixed));
+ 
+ /* Read the current point of a path. */
+ int
+ gx_path_current_point(gx_path *ppath, gs_fixed_point *ppt)
+ {	if ( !ppath->position_valid )
+ 	  return_error(gs_error_nocurrentpoint);
+ 	/* Copying the coordinates individually */
+ 	/* is much faster on a PC, and almost as fast on other machines.... */
+ 	ppt->x = ppath->position.x, ppt->y = ppath->position.y;
+ 	return 0;
+ }
+ 
+ /* Read the bounding box of a path. */
+ int
+ gx_path_bbox(gx_path *ppath, gs_fixed_rect *pbox)
+ {	if ( ppath->first_subpath == 0 )
+ 	   {	/* The path is empty, use the current point if any. */
+ 		gx_path_current_point(ppath, &pbox->p);
+ 		return gx_path_current_point(ppath, &pbox->q);
+ 	   }
+ 	/* The stored bounding box may not be up to date. */
+ 	/* Correct it now if necessary. */
+ 	if ( ppath->box_last == ppath->current_subpath->last )
+ 	   {	/* Box is up to date */
+ 		*pbox = ppath->bbox;
+ 	   }
+ 	else
+ 	   {	gs_fixed_rect box;
+ 		register segment *pseg = ppath->box_last;
+ 		if ( pseg == 0 )	/* box is uninitialized */
+ 		   {	pseg = (segment *)ppath->first_subpath;
+ 			box.p.x = box.q.x = pseg->pt.x;
+ 			box.p.y = box.q.y = pseg->pt.y;
+ 		   }
+ 		else
+ 		   {	box = ppath->bbox;
+ 			pseg = pseg->next;
+ 		   }
+ /* Macro for adjusting the bounding box when adding a point */
+ #define adjust_bbox(pt)\
+   if ( (pt).x < box.p.x ) box.p.x = (pt).x;\
+   else if ( (pt).x > box.q.x ) box.q.x = (pt).x;\
+   if ( (pt).y < box.p.y ) box.p.y = (pt).y;\
+   else if ( (pt).y > box.q.y ) box.q.y = (pt).y
+ 		while ( pseg )
+ 		   {	switch ( pseg->type )
+ 			   {
+ 			case s_curve:
+ #define pcurve ((curve_segment *)pseg)
+ 				adjust_bbox(pcurve->p1);
+ 				adjust_bbox(pcurve->p2);
+ #undef pcurve
+ 				/* falls through */
+ 			default:
+ 				adjust_bbox(pseg->pt);
+ 			   }
+ 			pseg = pseg->next;
+ 		   }
+ #undef adjust_bbox
+ 		ppath->bbox = box;
+ 		ppath->box_last = ppath->current_subpath->last;
+ 		*pbox = box;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Test if a path has any curves. */
+ int
+ gx_path_has_curves(gx_path *ppath)
+ {	return ppath->curve_count != 0;
+ }
+ 
+ /* Test if a path has any segments. */
+ int
+ gx_path_is_void(gx_path *ppath)
+ {	return ppath->segment_count == 0;
+ }
+ 
+ /* Test if a path is a rectangle. */
+ /* If so, return its bounding box. */
+ int
+ gx_path_is_rectangle(gx_path *ppath, gs_fixed_rect *pbox)
+ {	subpath *pseg0;
+ 	if (	ppath->subpath_count == 1 &&
+ 		ppath->segment_count == 4 && ppath->curve_count == 0 &&
+ 		(pseg0 = ppath->first_subpath)->last->type == s_line_close )
+ 	   {	fixed x0 = pseg0->pt.x, y0 = pseg0->pt.y;
+ 		segment *pseg1 = pseg0->next;
+ 		segment *pseg2 = pseg1->next;
+ 		fixed x2 = pseg2->pt.x, y2 = pseg2->pt.y;
+ 		segment *pseg3 = pseg2->next;
+ 		if (	(x0 == pseg1->pt.x && pseg1->pt.y == y2 &&
+ 			 x2 == pseg3->pt.x && pseg3->pt.y == y0) ||
+ 			(x0 == pseg3->pt.x && pseg3->pt.y == y2 &&
+ 			 x2 == pseg1->pt.x && pseg1->pt.y == y0)
+ 		   )
+ 		   {	/* Path is a rectangle.  Return bounding box. */
+ 			if ( x0 < x2 )
+ 				pbox->p.x = x0, pbox->q.x = x2;
+ 			else
+ 				pbox->p.x = x2, pbox->q.x = x0;
+ 			if ( y0 < y2 )
+ 				pbox->p.y = y0, pbox->q.y = y2;
+ 			else
+ 				pbox->p.y = y2, pbox->q.y = y0;
+ 			return 1;
+ 		   }
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Return the quick-check rectangle for a clipping path. */
+ /* This only works for paths that have gone through set_clip_path. */
+ /* which is why the name is different. */
+ int
+ gx_cpath_box_for_check(register gx_path *ppath, gs_fixed_rect *pbox)
+ {	*pbox = ppath->cbox;
+ 	return 0;
+ }
+ 
+ /* Test if a clipping path includes a rectangle. */
+ /* The rectangle need not be oriented correctly, i.e. x0 > x1 is OK. */
+ /* This only works for paths that have gone through set_clip_path. */
+ /* which is why the name is different. */
+ int
+ gx_cpath_includes_rectangle(register gx_path *ppath,
+   fixed x0, fixed y0, fixed x1, fixed y1)
+ {	return
+ 		(x0 <= x1 ?
+ 			(ppath->cbox.p.x <= x0 && x1 <= ppath->cbox.q.x) :
+ 			(ppath->cbox.p.x <= x1 && x0 <= ppath->cbox.q.x)) &&
+ 		(y0 <= y1 ?
+ 			(ppath->cbox.p.y <= y0 && y1 <= ppath->cbox.q.y) :
+ 			(ppath->cbox.p.y <= y1 && y0 <= ppath->cbox.q.y));
+ }
+ 
+ /* Copy a path */
+ int
+ gx_path_copy(gx_path *ppath_old, gx_path *ppath)
+ {	return copy_path(ppath_old, ppath, gx_path_add_curve);
+ }
+ 
+ /* Merge a path into its parent (the path in the previous graphics */
+ /* context).  If ppto is not the parent of ppfrom, chaos may result! */
+ int
+ gx_path_merge(gx_path *ppfrom, gx_path *ppto)
+ {	/* If no new segments, don't release the parent. */
+ 	subpath *psfrom = ppfrom->current_subpath;
+ 	subpath *psto = ppto->current_subpath;
+ 	if ( psto != 0 && psfrom->last != psto->last )
+ 	   {	gx_path_release(ppto);
+ 	   }
+ 	*ppto = *ppfrom;
+ 	ppfrom->shares_segments = 1;
+ 	return 0;
+ }
+ 
+ /* Translate an already-constructed path (in device space). */
+ /* Don't bother to translate the cbox. */
+ int
+ gx_path_translate(gx_path *ppath, fixed dx, fixed dy)
+ {	segment *pseg;
+ #define translate_xy(pt)\
+   pt.x += dx, pt.y += dy
+ 	translate_xy(ppath->bbox.p);
+ 	translate_xy(ppath->bbox.q);
+ 	translate_xy(ppath->position);
+ 	pseg = (segment *)(ppath->first_subpath);
+ 	while ( pseg )
+ 	   {	switch ( pseg->type )
+ 		   {
+ 		case s_curve:
+ 		   {	curve_segment *pc = (curve_segment *)pseg;
+ 			translate_xy(pc->p1);
+ 			translate_xy(pc->p2);
+ 		   }
+ 		default:
+ 			translate_xy(pseg->pt);
+ 		   }
+ 		pseg = pseg->next;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Define magic quantities used for flatness checking. */
+ /* Approximate sqrt(1+t*t)*scaled_flat by (1+t*t*0.45)*scaled_flat. */
+ /* This is good to within about 10% in the range 0<=abs(t)<=1. */
+ #define sqrt_magic 0.45
+ #define sqrt1t2xf(t) ((fixed)(t * t * scaled_flat_sq) + scaled_flat)
+ private fixed scaled_flat;
+ private float scaled_flat_sq;
+ 
+ /* Flatten a path */
+ int
+ gx_path_flatten(gx_path *ppath_old, gx_path *ppath, floatp flatness)
+ {	/* See the flattening algorithm below for an explanation of */
+ 	/* the following computation. */
+ 	float ff = flatness * ((float)int2fixed(1));
+ 	scaled_flat = ff;
+ 	scaled_flat_sq = ff * sqrt_magic;
+ 	return copy_path(ppath_old, ppath, flatten_curve);
+ }
+ 
+ /* Copy a path, optionally flattening it. */
+ /* If the copy fails, free the new path. */
+ private int
+ copy_path(gx_path *ppath_old, gx_path *ppath,
+   int (*curve_proc)(P7(gx_path *, fixed, fixed, fixed, fixed, fixed, fixed)))
+ {	gx_path old;
+ 	segment *pseg;
+ 	int code;
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	gx_dump_path(ppath_old, "before copy_path");
+ #endif
+ 	old = *ppath_old;
+ 	gx_path_init(ppath, &ppath_old->memory_procs);
+ 	pseg = (segment *)(old.first_subpath);
+ 	while ( pseg )
+ 	   {	switch ( pseg->type )
+ 		   {
+ 		case s_start:
+ 			code = gx_path_add_point(ppath, pseg->pt.x, pseg->pt.y);
+ 			break;
+ 		case s_curve:
+ 		   {	curve_segment *pc = (curve_segment *)pseg;
+ 			code = (*curve_proc)(ppath,
+ 					pc->p1.x, pc->p1.y,
+ 					pc->p2.x, pc->p2.y,
+ 					pc->pt.x, pc->pt.y);
+ 			break;
+ 		   }
+ 		case s_line:
+ 			code = gx_path_add_line(ppath, pseg->pt.x, pseg->pt.y);
+ 			break;
+ 		case s_line_close:
+ 			code = gx_path_close_subpath(ppath);
+ 			break;
+ 		   }
+ 		if ( code )
+ 		   {	gx_path_release(ppath);
+ 			if ( ppath == ppath_old ) *ppath_old = old;
+ 			return code;
+ 		   }
+ 		pseg = pseg->next;
+ 	}
+ 	ppath->position = old.position;		/* restore current point */
+ #ifdef DEBUG
+ if ( gs_debug['p'] )
+ 	gx_dump_path(ppath, "after copy_path");
+ #endif
+ 	return 0;
+ }
+ /* Internal routine to flatten a curve. */
+ /* This calls itself recursively, using binary subdivision, */
+ /* until the approximation is good enough to satisfy the */
+ /* flatness requirement.  The starting point is ppath->position, */
+ /* which gets updated as line segments are added. */
+ 
+ #ifdef DEBUG
+ private void
+ print_curve_point(fixed x, fixed y)
+ {	printf("[u]\t*** x=%f, y=%f ***\n", fixed2float(x), fixed2float(y));
+ }
+ #endif
+ 
+ private int
+ flatten_curve(gx_path *ppath,
+   fixed x1, fixed y1, fixed x2, fixed y2, fixed x3, fixed y3)
+ {	fixed
+ 	  x0 = ppath->position.x,
+ 	  y0 = ppath->position.y;
+ top:
+ #ifdef DEBUG
+ if ( gs_debug['u'] )
+ 	printf("[u]x0=%f y0=%f x1=%f y1=%f\n   x2=%f y2=%f x3=%f y3=%f\n",
+ 		fixed2float(x0), fixed2float(y0), fixed2float(x1),
+ 		fixed2float(y1), fixed2float(x2), fixed2float(y2),
+ 		fixed2float(x3), fixed2float(y3));
+ #endif
+ 	   {	/* Compute the maximum distance of the curve from */
+ 		/* the line (x0,y0)->(x3,y3).  We do this conservatively */
+ 		/* by observing that the curve is enclosed by the */
+ 		/* quadrilateral of its control points, so we simply */
+ 		/* compute the distances of (x1,y1) and (x2,y2) */
+ 		/* from the line.  The distance of (xp,yp) from the line is */
+ 		/* abs(N)/sqrt(D), where N = dy*(xp-x0)-dx*(yp-y0) and */
+ 		/* D = dx*dx+dy*dy.  However, since we are only */
+ 		/* interested in whether this is greater than the flatness */
+ 		/* F, we may as well avoid the square root by testing */
+ 		/* whether N*N > D*F*F, where we can precompute F*F. */
+ 		/* Indeed, we can go further by letting t=dy/dx, and */
+ 		/* testing N1*N1 > D1*F*F, where N1=t*(xp-x0)-(yp-y0) and */
+ 		/* D1 = 1+t*t.  (If dx < dy, we swap x and y for this */
+ 		/* computation, which incidentally guarantees abs(t) <= 1.) */
+ 		/* We can even avoid doing any scaling in converting the */
+ 		/* coordinates and distances from fixed to floating: */
+ 		/* if s is the scale factor for fixed quantities, and we */
+ 		/* disregard it in converting the d, x, and y values to */
+ 		/* floating point, then we actually wind up comparing */
+ 		/* N1*N1*(s^4) > D1*(s^2)*F1, and everything will come out */
+ 		/* if we let F1 = F*F*s^2.  This explains the computation */
+ 		/* of flat_factor above. */
+ 		fixed dx3 = x3 - x0, dy3 = y3 - y0;
+ 		float t;
+ 		fixed d, dist;
+ 		if ( (dx3 < 0 ? -dx3 : dx3) >= (dy3 < 0 ? -dy3 : dy3) )
+ 		   {	if ( dx3 == 0 ) return 0;	/* degenerate */
+ 			t = (float)dy3 / (float)dx3;
+ 			d = sqrt1t2xf(t);
+ 			if ( ((dist = (fixed)(t * (x1 - x0)) - y1 + y0) < 0 ?
+ 			      -dist : dist) <= d &&
+ 			     ((dist = (fixed)(t * (x2 - x0)) - y2 + y0) < 0 ?
+ 			      -dist : dist) <= d
+ 			   )
+ 			   {	/* Curve is flat enough.  Add a line and exit. */
+ #ifdef DEBUG
+ if ( gs_debug['u'] )
+ 				print_curve_point(x3, y3);
+ #endif
+ 				return gx_path_add_line(ppath, x3, y3);
+ 			   }
+ 		   }
+ 		else
+ 		   {	t = (float)dx3 / (float)dy3;
+ 			d = sqrt1t2xf(t);
+ 			if ( ((dist = (fixed)(t * (y1 - y0)) - x1 + x0) < 0 ?
+ 			      -dist : dist) <= d &&
+ 			     ((dist = (fixed)(t * (y2 - y0)) - x2 + x0) < 0 ?
+ 			      -dist : dist) <= d
+ 			   )
+ 			   {	/* Curve is flat enough.  Add a line and exit. */
+ #ifdef DEBUG
+ if ( gs_debug['u'] )
+ 				print_curve_point(x3, y3);
+ #endif
+ 				return gx_path_add_line(ppath, x3, y3);
+ 			   }
+ 		   }
+ 	   }
+ 	/* Curve isn't flat enough.  Break into two pieces and recur. */
+ 	/* Algorithm is from "The Beta2-split: A special case of the */
+ 	/* Beta-spline Curve and Surface Representation," B. A. Barsky */
+ 	/* and A. D. DeRose, IEEE, 1985, courtesy of Crispin Goswell. */
+ #define midpoint(a,b) arith_rshift((a) +(b), 1)
+ 	   {	fixed x01 = midpoint(x0, x1), y01 = midpoint(y0, y1);
+ 		fixed x12 = midpoint(x1, x2), y12 = midpoint(y1, y2);
+ 		fixed x02 = midpoint(x01, x12), y02 = midpoint(y01, y12);
+ 		int code;
+ 		/* Update x/y1, x/y2, and x/y0 now for the second half. */
+ 		x2 = midpoint(x2, x3), y2 = midpoint(y2, y3);
+ 		x1 = midpoint(x12, x2), y1 = midpoint(y12, y2);
+ 		code = flatten_curve(
+ 			ppath,
+ 			x01, y01, x02, y02,
+ 			(x0 = midpoint(x02, x1)),
+ 			(y0 = midpoint(y02, y1)));
+ 		if ( code < 0 ) return code;
+ 	   }
+ 	goto top;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxstroke.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxstroke.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxstroke.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,598 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxstroke.c */
+ /* Path stroking procedures for GhostScript library */
+ #include "math_.h"
+ #include "gx.h"
+ #include "gserrors.h"
+ #include "gxfixed.h"
+ #include "gxarith.h"
+ #include "gxmatrix.h"
+ #include "gzstate.h"
+ #include "gzdevice.h"
+ #include "gzcolor.h"			/* requires gxdevice.h */
+ #include "gzline.h"
+ #include "gzpath.h"
+ 
+ /* stroke_add uses the following global for its path: */
+ private gx_path stroke_path_body;
+ private gx_path *stroke_path;
+ 
+ /* Structure for a partial line (passed to the drawing routine). */
+ /* Two of these are required to do joins right. */
+ /* Each endpoint includes the two ends of the cap as well, */
+ /* and the deltas for square and round cap computation. */
+ typedef struct endpoint_s {
+ 	gs_fixed_point p;		/* the end of the line */
+ 	gs_fixed_point co, ce;		/* ends of the cap */
+ 	gs_fixed_point cdelta;		/* cap_length or -cap_length */
+ } endpoint;
+ typedef struct partial_line_s {
+ 	endpoint o;			/* starting coordinate */
+ 	endpoint e;			/* ending coordinate */
+ 	gs_fixed_point width;		/* one-half line width, */
+ 					/* perpendicular (in user space) */
+ 					/* to line */
+ 	gs_fixed_point cap_length;	/* ditto, parallel to line */
+ 	int thin;			/* true if minimum-width line */
+ } partial_line;
+ 
+ /* Procedures that stroke a partial_line (the first argument). */
+ /* If both partial_lines are non-null, the procedure creates */
+ /* an appropriate join; otherwise, the procedure creates an */
+ /* end cap.  If the first int is 0, the procedure also starts with */
+ /* an appropriate cap. */
+ private int stroke_add(P4(int, partial_line *, partial_line *, gs_state *));
+ private int stroke_fill(P4(int, partial_line *, partial_line *, gs_state *));
+ 
+ /* Other forward declarations */
+ private int stroke(P3(gx_path *,
+   int (*)(P4(int, partial_line *, partial_line *, gs_state *)),
+   gs_state *));
+ private void compute_caps(P2(partial_line *, gs_state *));
+ private int add_capped(P4(gx_path *, gs_line_cap,
+   int (*)(P3(gx_path *, fixed, fixed)),
+   endpoint *));
+ 
+ /* Stroke a path for drawing or saving */
+ int
+ gx_stroke_fill(gx_path *ppath, gs_state *pgs)
+ {	int code;
+ 	stroke_path = 0;
+ 	code = stroke(ppath, stroke_fill, pgs);
+ 	if ( stroke_path )		/* set if filling needed */
+ 	  { if ( code >= 0 )
+ 	      code = gx_fill_path(stroke_path, pgs->dev_color, pgs,
+ 				  gx_rule_winding_number, (fixed)0);
+ 		gx_path_release(stroke_path);
+ 	  }
+ 	return code;
+ }
+ int
+ gx_stroke_add(gx_path *ppath, gx_path *topath, gs_state *pgs)
+ {	stroke_path = topath;
+ 	return stroke(ppath, stroke_add, pgs);
+ }
+ 
+ /* Stroke a path.  Call line_proc for each line segment. */
+ private int
+ stroke(gx_path *ppath,
+   int (*line_proc)(P4(int, partial_line *, partial_line *, gs_state *)),
+   gs_state *pgs)
+ {	subpath *psub;
+ 	int code;
+ 	dash_params *dash = &pgs->line_params->dash;
+ 	float *dashes = dash->pattern;
+ 	int dash_count = dash->pattern_size;
+ 	gx_path fpath;
+ 	int skewed = is_skewed(&pgs->ctm);
+ 	float line_width = pgs->line_params->width;
+ 	float xx = pgs->ctm.xx, yy = pgs->ctm.yy;
+ 	int always_thin;
+ 	float line_width_and_scale;
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+    {	line_params *lp = pgs->line_params;
+ 	int count = lp->dash.pattern_size;
+ 	int i;
+ 	printf("[o]half_width=%f, cap=%d, join=%d,\n",
+ 		lp->width, (int)lp->cap, (int)lp->join);
+ 	printf("   miter_limit=%f, miter_check=%f,\n",
+ 		lp->miter_limit, lp->miter_check);
+ 	printf("   dash pattern=%d", count);
+ 	for ( i = 0; i < count; i++ )
+ 		printf(",%f", lp->dash.pattern[i]);
+ 	printf(",\n   offset=%f, init(ink_on=%d, index=%d, dist_left=%f)\n",
+ 		lp->dash.offset, lp->dash.init_ink_on, lp->dash.init_index,
+ 		lp->dash.init_dist_left);
+    }
+ #endif
+ 	if ( is_fzero(line_width) )
+ 	   {	always_thin = 1;
+ 		/* Set the line_width to something non-zero -- hack! */
+ 		line_width = 0.01;
+ 	   }
+ 	else if ( skewed )
+ 		always_thin = 0;
+ 	else
+ 	   {	float xxa = xx, yya = yy;
+ 		if ( xxa < 0 ) xxa = -xxa;
+ 		if ( yya < 0 ) yya = -yya;
+ 		always_thin = (max(xxa, yya) * line_width < 0.75);
+ 	   }
+ 	if ( !always_thin )
+ 		line_width_and_scale = line_width * (float)int2fixed(1);
+ 	/* Start by flattening the path.  We should do this on-the-fly.... */
+ 	if ( !ppath->curve_count )	/* don't need to flatten */
+ 	   {	psub = ppath->first_subpath;
+ 		if ( !psub ) return 0;
+ 	   }
+ 	else
+ 	   {	if ( (code = gx_path_flatten(ppath, &fpath, pgs->flatness)) < 0 ) return code;
+ 		psub = fpath.first_subpath;
+ 	   }
+ 	while ( psub )
+ 	{	int segcount = psub->line_count;	/* no curves left */
+ 		line_segment *pline = (line_segment *)(psub->next);
+ 		fixed x = psub->pt.x;
+ 		fixed y = psub->pt.y;
+ 		partial_line pl, pl_prev, pl_first;
+ 		int first = 0;
+ #define next_line(ex, ey)\
+   (pl.o.p.x = x, pl.o.p.y = y, pl.e.p.x = (ex), pl.e.p.y = (ey),\
+    (pl.thin ? 0 : (compute_caps(&pl, pgs), 0)),\
+    (first++ == 0 ? (pl_first = pl, 0) : 0),\
+    (index++ ? (*line_proc)(index - 2, &pl_prev, &pl, pgs) : 0),\
+    pl_prev = pl, 0)
+ 		char ink_on = dash->init_ink_on;
+ 		int dash_index = dash->init_index;
+ 		float dist_left = dash->init_dist_left;
+ 		int index = 0;
+ 		while ( segcount-- )
+ 		{	fixed sx = pline->pt.x;
+ 			fixed sy = pline->pt.y;
+ 			/* Compute the width parameters in device space. */
+ 			/* We work with unscaled values, for speed. */
+ 			fixed udx, udy;
+ 			float unscaled_dist;
+ 			if ( sx == x && sy == y ) /* degenerate */
+ 			  goto no_line;
+ 			if ( !always_thin || dash_count )
+ 			   {	gs_point dpt;	/* unscaled */
+ 				udx = sx - x, udy = sy - y;
+ 				if ( skewed )
+ 				  gs_idtransform(pgs,
+ 				    (float)udx, (float)udy, &dpt);
+ 				else	/* shortcut */
+ 				   {	dpt.x = udx / xx;
+ 					dpt.y = udy / yy;
+ 				   }
+ 				unscaled_dist =
+ 				  sqrt(dpt.x * dpt.x + dpt.y * dpt.y);
+ 				if ( !always_thin )
+ 				   {	float wl = line_width_and_scale /
+ 					  unscaled_dist;
+ 					/* Construct the width vector in */
+ 					/* user space, still unscaled. */
+ 					dpt.x *= wl;
+ 					dpt.y *= wl;
+ 					/* We now compute both parallel */
+ 					/* and perpendicular half-widths, */
+ 					/* as deltas in device space. */
+ 					/* We use a fixed-point, unscaled */
+ 					/* version of gs_dtransform. */
+ 					/* The second computation folds in */
+ 					/* a 90-degree rotation counter- */
+ 					/* clockwise (in user space, */
+ 					/* before transforming). */
+ 					pl.width.x =
+ 						-(fixed)(dpt.y * xx);
+ 					pl.width.y =
+ 						(fixed)(dpt.x * yy);
+ 					if ( skewed )
+ 						pl.width.x +=
+ 						 (fixed)(dpt.x * pgs->ctm.yx),
+ 						pl.width.y -=
+ 						 (fixed)(dpt.y * pgs->ctm.xy);
+ 					pl.thin =
+ 					  ((pl.width.x < 0 ? -pl.width.x :
+ 					    pl.width.x) +
+ 					   (pl.width.y < 0 ? -pl.width.y :
+ 					    pl.width.y)) < float2fixed(0.75);
+ 					if ( pl.thin )
+ 					   {	pl.width.x = pl.width.y = 0;
+ 						pl.cap_length.x =
+ 						  pl.cap_length.y = 0;
+ 					   }
+ 					else
+ 					   {	pl.cap_length.x =
+ 						 (fixed)(dpt.x * xx);
+ 						pl.cap_length.y =
+ 						 (fixed)(dpt.y * yy);
+ 						if ( skewed )
+ 						  pl.cap_length.x +=
+ 						 (fixed)(dpt.y * pgs->ctm.yx),
+ 						  pl.cap_length.y +=
+ 						 (fixed)(dpt.x * pgs->ctm.xy);
+ 					   }
+ 				   }
+ 				else
+ 					pl.width.x = pl.width.y = 0,
+ 					pl.cap_length.x = pl.cap_length.y = 0,
+ 					pl.thin = 1;
+ 			   }
+ 			else
+ 				pl.width.x = pl.width.y = 0,
+ 				pl.cap_length.x = pl.cap_length.y = 0,
+ 				pl.thin = 1;
+ 			if ( dash_count )
+ 			   {	/* Account for dash pattern */
+ 				float dist_total =
+ 				  unscaled_dist * (1 / (float)int2fixed(1));
+ 				float dist = dist_total;
+ 				float dx = udx, dy = udy;	/* unscaled */
+ 				while ( dist > dist_left )
+ 				   {	/* We are using up the dash element */
+ 					float fraction = dist_left / dist_total;	/* unscaled-inverse */
+ 					fixed nx = x + (fixed)(dx * fraction);
+ 					fixed ny = y + (fixed)(dy * fraction);
+ 					if ( ink_on )
+ 						next_line(nx, ny);
+ 					dist -= dist_left;
+ 					if ( !(ink_on = !ink_on) )
+ 					   {	if ( index )
+ 						   {	(*line_proc)(index - 1, &pl_prev, (partial_line *)0, pgs);
+ 							index = 0;
+ 						   }
+ 					   }
+ 					if ( ++dash_index == dash_count )
+ 						dash_index = 0;
+ 					dist_left = dashes[dash_index];
+ 					x = nx, y = ny;
+ 				   }
+ 				if ( ink_on )
+ 					next_line(sx, sy);
+ 				dist_left -= dist;
+ 			   }
+ 			else
+ 				next_line(sx, sy);
+ no_line:		pline = (line_segment *)(pline->next);
+ 			x = sx, y = sy;
+ 		}
+ 		if ( index )
+ 		   {	/* If closed, join back to start, else cap */
+ 			(*line_proc)(index - 1, &pl_prev,
+ 				(psub->closed && ink_on && dash->init_ink_on ?
+ 				 &pl_first : (partial_line *)0), pgs);
+ 		   }
+ 		psub = (subpath *)pline;
+ 		if ( stroke_path == &stroke_path_body )
+ 		   {	/* Fill and release the accumulated path */
+ 			gx_fill_path(stroke_path, pgs->dev_color, pgs,
+ 				     gx_rule_winding_number, (fixed)0);
+ 			gx_path_release(stroke_path);
+ 			stroke_path = 0;
+ 		   }
+ 	}
+ 	if ( ppath->curve_count ) gx_path_release(&fpath);
+ 	return 0;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Compute the intersection of two lines.  This is a messy algorithm */
+ /* that somehow ought to be useful in more places than just here.... */
+ private void
+ line_intersect(
+     gs_fixed_point *pp1,		/* point on 1st line */
+     gs_fixed_point *pd1,		/* slope of 1st line (dx,dy) */
+     gs_fixed_point *pp2,		/* point on 2nd line */
+     gs_fixed_point *pd2,		/* slope of 2nd line */
+     gs_fixed_point *pi)			/* return intersection here */
+ {	/* We don't have to do any scaling, the factors all work out right. */
+ 	float x1 = pp1->x, y1 = pp1->y;
+ 	float u1 = pd1->x, v1 = pd1->y;
+ 	float x2 = pp2->x, y2 = pp2->y;
+ 	float u2 = pd2->x, v2 = pd2->y;
+ 	double denom = u1 * v2 - u2 * v1;
+ 	double num1 = v1 * x1 - u1 * y1;
+ 	double num2 = v2 * x2 - u2 * y2;
+ 	pi->x = (fixed)( (u1 * num2 - u2 * num1) / denom );
+ 	pi->y = (fixed)( (v1 * num2 - v2 * num1) / denom );
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+    {	printf("[o]Intersect %f,%f(%f/%f) & %f,%f(%f/%f) ->\n",
+ 		fixed2float(pp1->x), fixed2float(pp1->y),
+ 		fixed2float(pd1->x), fixed2float(pd1->y),
+ 		fixed2float(pp2->x), fixed2float(pp2->y),
+ 		fixed2float(pd2->x), fixed2float(pd2->y));
+ 	printf("	%f,%f\n",
+ 		fixed2float(pi->x), fixed2float(pi->y));
+    }
+ #endif
+ }
+ 
+ #define lix plp->o.p.x
+ #define liy plp->o.p.y
+ #define litox plp->e.p.x
+ #define litoy plp->e.p.y
+ 
+ /* Draw a line on the device. */
+ private int
+ stroke_fill(int first,
+   register partial_line *plp, partial_line *nplp, gs_state *pgs)
+ {	if ( plp->thin )
+ 	   {	/* Minimum-width line, don't have to be careful. */
+ 		/* We do have to check for the entire line being */
+ 		/* within the clipping rectangle. */
+ 		if ( gx_cpath_includes_rectangle(pgs->clip_path,
+ 				lix, liy, litox, litoy) )
+ 			return gz_draw_line_fixed(lix, liy, litox, litoy,
+ 				pgs->dev_color, pgs);
+ 		/* We didn't set up the endpoint parameters before, */
+ 		/* because the line was thin.  Do it now. */
+ 		/****** THE FOLLOWING IS A HACK. IT IS PROBABLY WRONG. ******/
+ 		plp->width.x = float2fixed(0.25);
+ 		plp->width.y = float2fixed(0.25);
+ 		plp->cap_length.x = float2fixed(0.125);
+ 		plp->cap_length.y = float2fixed(0.125);
+ 		compute_caps(plp, pgs);
+ 	   }
+ 	   {	/* General case. */
+ 		/* Construct a path and hand it to the fill algorithm. */
+ 		if ( stroke_path == 0 )
+ 		   {	/* We are rendering, and haven't run into the */
+ 			/* general case yet.  Initialize the path. */
+ 			stroke_path = &stroke_path_body;	/* set global for stroke_add */
+ 			gx_path_init(stroke_path, &pgs->memory_procs);
+ 		   }
+ 		stroke_add(first, plp, nplp, pgs);
+ 		   {	/****** PATCH ******/
+ 			if ( stroke_path == &stroke_path_body )
+ 			   {	gx_fill_path(stroke_path, pgs->dev_color, pgs,
+ 					     gx_rule_winding_number, (fixed)0);
+ 				gx_path_release(stroke_path);
+ 				stroke_path = 0;
+ 			   }
+ 		   }
+ 	   }
+ 	return 0;
+ }
+ 
+ #undef lix
+ #undef liy
+ #undef litox
+ #undef litoy
+ 
+ /* Add a segment to the path.  This handles all the complex cases. */
+ private int add_capped(P4(gx_path *, gs_line_cap, int (*)(P3(gx_path *, fixed, fixed)), endpoint *));
+ private int
+ stroke_add(int first,
+   register partial_line *plp, partial_line *nplp, gs_state *pgs)
+ {	gx_path *ppath = stroke_path;
+ 	int code;
+ 	if ( ppath == 0 ) return 0;	/****** strokepath is NYI ******/
+ 	if ( plp->thin )
+ 	   {	/* We didn't set up the endpoint parameters before, */
+ 		/* because the line was thin.  Do it now. */
+ 		compute_caps(plp, pgs);
+ 	   }
+ 	if ( (code = add_capped(ppath, (first == 0 ? pgs->line_params->cap : gs_cap_butt), gx_path_add_point, &plp->o)) < 0 )
+ 		return code;
+ 	if ( nplp == 0 )
+ 	   {	code = add_capped(ppath, pgs->line_params->cap, gx_path_add_line, &plp->e);
+ 	   }
+ 	else if ( pgs->line_params->join == gs_join_round )
+ 	   {	code = add_capped(ppath, gs_cap_round, gx_path_add_line, &plp->e);
+ 	   }
+ 	else if ( nplp->thin )		/* no join */
+ 	  {	code = add_capped(ppath, gs_cap_butt, gx_path_add_line, &plp->e);
+ 	  }
+ 	else				/* join_bevel or join_miter */
+ 	   {	gs_fixed_point jp1, jp2;
+ 		/* Set np to whichever of nplp->o.co or .ce */
+ 		/* is outside the current line, i.e., */
+ 		/* whichever is on the same side as the cap. */
+ 		float fwx = plp->width.x, fwy = plp->width.y;
+ 		float fdx = plp->e.cdelta.x, fdy = plp->e.cdelta.y;
+ 		float fnwx = nplp->width.x, fnwy = nplp->width.y;
+ 		int cside = (fdx * fwy >= fdy * fwx);
+ 		int nside = (fnwx * fwy >= fnwy * fwx);
+ 		gs_fixed_point *np = (cside == nside ? &nplp->o.ce : &nplp->o.co);
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+ 		printf("[o]e.cd-side=%d nw/side=%d\n", cside, nside);
+ #endif
+ 		/* Compute the join point. */
+ 		/* Initialize it for a bevel join. */
+ 		jp1.x = plp->e.co.x, jp1.y = plp->e.co.y;
+ 		jp2.x = plp->e.ce.x, jp2.y = plp->e.ce.y;
+ 		if ( pgs->line_params->join == gs_join_miter )
+ 		  { /* Check whether a miter join is appropriate. */
+ 		    /* Let a, b be the angles of the two lines. */
+ 		    /* We check tan(a-b) against the miter_check */
+ 		    /* by using the following formula: */
+ 		    /* If tan(a)=u1/v1 and tan(b)=u2/v2, then */
+ 		    /* tan(a-b) = (u1*v2 - u2*v1) / (u1*u2 + v1*v2). */
+ 		    /* We can do all the computations unscaled, */
+ 		    /* because we're only concerned with ratios. */
+ 		    fixed u1 = plp->e.cdelta.x, v1 = plp->e.cdelta.y;
+ 		    fixed u2 = nplp->e.cdelta.x, v2 = nplp->e.cdelta.y;
+ 		    float uf1, vf1, uf2, vf2;
+ 		    float num, denom;
+ 		    float check = pgs->line_params->miter_check;
+ 		    /* We will want either tan(pi-a+b) or tan(pi-b+a)
+ 		     * depending on the orientations of the lines.
+ 		     *
+ 		     * tan(pi - a + b) = -tan(a-b)
+ 		     * tan(pi - b + a) = tan(a-b)
+ 		     *
+ 		     * First reflect both lines so that 1st
+ 		     * line is in 1st quadrant.
+ 		     */
+ 		    if ( u1 < 0 ) u1 = -u1, u2 = -u2;
+ 		    if ( v1 < 0 ) v1 = -v1, v2 = -v2;
+ 		    uf1 = u1, vf1 = v1, uf2 = u2, vf2 = v2;
+ 		    num = uf2 * vf1 - uf1 * vf2;
+ 		    denom = uf1 * uf2 + vf1 * vf2;
+ 		    /* Now proceed based on the angle of the 2nd line */
+ 		    if ( u2 >= 0 )
+ 		      { if ( v2 >= 0 )
+ 			  { /* 1st quadrant => negative tangent */
+ 			    if ( num > 0 ) num = -num;
+ 			    if ( denom < 0 ) denom = -denom;
+ 			  }
+ 		        else
+ 			  { /* 4th quadrant => use tan(b-a) */
+ 			    num = -num;
+ 			    if ( denom < 0 ) num = -num, denom = -denom;
+ 			  }
+ 		      }
+ 		    else
+ 		      { if ( v2 >= 0 )
+ 			  { /* 2nd quadrant => use tan(a-b) */
+ 			    if ( denom < 0 ) num = -num, denom = -denom;
+ 			  }
+ 		        else
+ 			  { /* 3rd quadrant => positive tangent */
+ 			    if ( num < 0 ) num = -num;
+ 			    if ( denom < 0 ) denom = -denom;
+ 			  }
+ 		      }
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+                    {    printf("[o]Miter check: u1/v1=%f/%f, u2/v2=%f/%f,\n",
+ 			       uf1, vf1, uf2, vf2);
+                         printf("        num=%f, denom=%f, check=%f\n",
+ 			       num, denom, check);
+                    }
+ #endif
+ 		    if ( num >= 0 ?
+                         (check > 0 && num >= denom * check) :
+                         (check > 0 || num >= denom * check) )
+ 			   {	/* OK to use a miter join. */
+ 				/* Compute the intersection of */
+ 				/* the extended edge lines. */
+ 				/* Start by discovering which of */
+ 				/* plp->e.co or .ce is outside */
+ 				/* the next line.  fwx and fwy are negated */
+ 				/* because the e-line goes in the opposite */
+ 				/* direction from the o-line. */
+ 				float fndx = nplp->o.cdelta.x,
+ 					fndy = nplp->o.cdelta.y;
+ 				int noside = (fndx * fnwy >= fndy * fnwx);
+ 				int wside = (-fwx * fnwy >= -fwy * fnwx);
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+ 				printf("[o]no.cd-side=%d, w-side=%d\n",
+ 					noside, wside);
+ #endif
+ 				if ( noside == wside )
+ 					line_intersect(&plp->e.ce, &plp->e.cdelta, np, &nplp->o.cdelta, &jp2);
+ 				else
+ 					line_intersect(&plp->e.co, &plp->e.cdelta, np, &nplp->o.cdelta, &jp1);
+ 			   }
+ 		   }
+ 		if (	(code = gx_path_add_line(ppath, jp1.x, jp1.y)) < 0 ||
+ 			(code = gx_path_add_line(ppath, np->x, np->y)) < 0 ||
+ 			(code = gx_path_add_line(ppath, jp2.x, jp2.y)) < 0
+ 		   ) return code;
+ 	   }
+ 	if ( code < 0 || (code = gx_path_close_subpath(ppath)) < 0 )
+ 		return code;
+ 	return 0;
+ }
+ 
+ /* Routines for cap computations */
+ 
+ /* Compute the endpoints of the two caps of a segment. */
+ private void
+ compute_caps(register partial_line *plp, gs_state *pgs)
+ {	fixed wx2 = plp->width.x;
+ 	fixed wy2 = plp->width.y;
+ #define lx2 plp->cap_length.x
+ #define ly2 plp->cap_length.y
+ 	plp->o.co.x = plp->o.p.x - wx2, plp->o.co.y = plp->o.p.y - wy2;
+ 	plp->o.ce.x = plp->o.p.x + wx2, plp->o.ce.y = plp->o.p.y + wy2;
+ 	plp->e.co.x = plp->e.p.x + wx2, plp->e.co.y = plp->e.p.y + wy2;
+ 	plp->e.ce.x = plp->e.p.x - wx2, plp->e.ce.y = plp->e.p.y - wy2;
+ 	plp->o.cdelta.x = -lx2, plp->o.cdelta.y = -ly2;
+ 	plp->e.cdelta.x = lx2, plp->e.cdelta.y = ly2;
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+ 	printf("[o]Stroke o=(%f,%f) e=(%f,%f)\n",
+ 		fixed2float(plp->o.p.x), fixed2float(plp->o.p.y),
+ 		fixed2float(plp->e.p.x), fixed2float(plp->e.p.y)),
+ 	printf("	wxy=(%f,%f) lxy=(%f,%f)\n",
+ 		fixed2float(wx2), fixed2float(wy2),
+ 		fixed2float(lx2), fixed2float(ly2));
+ #endif
+ #undef lx2
+ #undef ly2
+ }
+ 
+ /* Add a properly capped line endpoint to the path. */
+ /* The first point may require either moveto or lineto. */
+ private int
+ add_capped(gx_path *ppath, gs_line_cap type,
+   int (*add_proc)(P3(gx_path *, fixed, fixed)), /* gx_path_add_point/line */
+   register endpoint *endp)
+ {	int code;
+ #define px endp->p.x
+ #define py endp->p.y
+ #define xo endp->co.x
+ #define yo endp->co.y
+ #define xe endp->ce.x
+ #define ye endp->ce.y
+ #define cdx endp->cdelta.x
+ #define cdy endp->cdelta.y
+ #ifdef DEBUG
+ if ( gs_debug['o'] )
+ 	printf("[o]cap: p=(%g,%g), co=(%g,%g), ce=(%g,%g), cd=(%g,%g)\n",
+ 		fixed2float(px), fixed2float(py),
+ 		fixed2float(xo), fixed2float(yo),
+ 		fixed2float(xe), fixed2float(ye),
+ 		fixed2float(cdx), fixed2float(cdy));
+ #endif
+ 	switch ( type )
+ 	   {
+ 	case gs_cap_round:
+ 	   {	fixed xm = px + cdx;
+ 		fixed ym = py + cdy;
+ 		if (	(code = (*add_proc)(ppath, xo, yo)) < 0 ||
+ 			(code = gx_path_add_arc(ppath, xo, yo, xm, ym,
+ 				xo + cdx, yo + cdy)) < 0 ||
+ 			(code = gx_path_add_arc(ppath, xm, ym, xe, ye,
+ 				xe + cdx, ye + cdy)) < 0
+ 		   ) return code;
+ 	   }
+ 		break;
+ 	case gs_cap_square:
+ 		if (	(code = (*add_proc)(ppath, xo + cdx, yo + cdy)) < 0 ||
+ 			(code = gx_path_add_line(ppath, xe + cdx, ye + cdy)) < 0
+ 		   ) return code;
+ 		break;
+ 	case gs_cap_butt:
+ 		if (	(code = (*add_proc)(ppath, xo, yo)) < 0 ||
+ 			(code = gx_path_add_line(ppath, xe, ye)) < 0
+ 		   ) return code;
+ 	   }
+ 	return code;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxtype1.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxtype1.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gxtype1.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,93 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxtype1.h */
+ /* Private Adobe Type 1 font definitions for GhostScript library */
+ #include "gstype1.h"
+ 
+ /* Define the charstring command set */
+ typedef enum {
+ 		c_undef0 = 0,
+ 	c_hstem = 1,
+ 		c_undef2 = 2,
+ 	c_vstem = 3,
+ 	c_vmoveto = 4,
+ 	c_rlineto = 5,
+ 	c_hlineto = 6,
+ 	c_vlineto = 7,
+ 	c_rrcurveto = 8,
+ 	c_closepath = 9,
+ 	c_callsubr = 10,
+ 	c_return = 11,
+ 	c_escape = 12,			/* extends the command set */
+ 	c_hsbw = 13,
+ 	c_endchar = 14,
+ 		c_undef15 = 15,
+ 		c_undef16 = 16,
+ 		c_undef17 = 17,
+ 		c_undef18 = 18,
+ 		c_undef19 = 19,
+ 		c_undef20 = 20,
+ 	c_rmoveto = 21,
+ 	c_hmoveto = 22,
+ 		c_undef23 = 23,
+ 		c_undef24 = 24,
+ 		c_undef25 = 25,
+ 		c_undef26 = 26,
+ 		c_undef27 = 27,
+ 		c_undef28 = 28,
+ 		c_undef29 = 29,
+ 	c_vhcurveto = 30,
+ 	c_hvcurveto = 31
+ } char_command;
+ typedef enum {				/* extended commands */
+ 	ce_dotsection = 0,
+ 	ce_vstem3 = 1,
+ 	ce_hstem3 = 2,
+ 	ce_seac = 6,
+ 	ce_sbw = 7,
+ 	ce_div = 12,
+ 	ce_testadd = 15,		/****** UNDOCUMENTED BY ADOBE ******/
+ 	ce_callothersubr = 16,
+ 	ce_pop = 17,
+ 	ce_setcurrentpoint = 33
+ } char_extended_command;
+ 
+ /* Define the encoding of numbers */
+ #define c_min_num 32
+ #define c_max_num1 246
+ #define c_value_num1(ch) ((int)(byte)(ch) - 139)
+ #define c_max_num2 250
+ #define c_value_num2(c1,c2)\
+   (((int)(byte)((c1) - 247) << 8) + (int)(byte)(c2) + 108)
+ #define c_max_num3 254
+ #define c_value_num3(c1,c2)\
+   -(((int)(byte)((c1) - 251) << 8) + (int)(byte)(c2) + 108)
+ /* Otherwise, the first byte is 255, followed by a 32-bit 2's complement */
+ /* number in big-endian order. */
+ 
+ /* Define the encryption parameters */
+ #define crypt_c1 ((ushort)52845)
+ #define crypt_c2 ((ushort)22719)
+ #define encrypt_next(ch, state, chvar)\
+   chvar = ((ch) ^ (state >> 8)),\
+   state = (chvar + state) * crypt_c1 + crypt_c2
+ #define decrypt_next(ch, state, chvar)\
+   chvar = ((ch) ^ (state >> 8)),\
+   state = ((ch) + state) * crypt_c1 + crypt_c2


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzcolor.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzcolor.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzcolor.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,72 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gzcolor.h */
+ /* Private definition of color representation for GhostScript */
+ 
+ /* Representation of color. */
+ /* All the color parameters are stored internally as color_params. */
+ typedef unsigned short color_param;
+ /*
+  * The following line should read:
+  *	#define max_color_param max_ushort
+  * but this seems to trigger brain-damage in a number of compilers,
+  * so instead we use a variable:
+  */
+ static const color_param max_color_param = 0xffff;
+ #define max_color_param_long 0xffffL
+ /* Expand a byte to a color_param without doing a multiply. */
+ #define color_param_from_byte(b) (((ushort)(b) << 8) + (b))
+ 
+ /* The following parameters are computed from the above, */
+ /* just before actually using the color to draw. */
+ typedef struct gx_device_color_s gx_device_color;
+ struct gx_device_color_s {
+ 	gx_color_index color1;		/* device color, or */
+ 					/* darker color for halftoning */
+ 	gx_color_index color2;		/* lighter color for halftoning */
+ 	int halftone_level;		/* number of spots to whiten */
+ 					/* when halftoning, 0 if */
+ 					/* halftoning not needed, */
+ 					/* <0 if color halftone */
+ 	struct gx_bitmap_s *tile;	/* pointer to cached halftone */
+ };
+ #define color_is_pure(pdevc)\
+   ((pdevc)->halftone_level == 0)
+ #define color_is_color_halftone(pdevc)\
+   ((pdevc)->halftone_level < 0)
+ 
+ /*typedef struct gs_color_s gs_color;*/	/* in gsstate.h */
+ struct gs_color_s {
+ 	color_param red, green, blue;		/* rgb representation */
+ 	color_param luminance;		/* computed luminance */
+ 	byte is_gray;			/* quick test for gray */
+ 					/* (red==green==blue) */
+ 	byte luminance_set;		/* true if luminance is set */
+ };
+ extern color_param gx_color_luminance(P1(struct gs_color_s *));
+ #define color_luminance(pcolor)\
+ 	((pcolor)->luminance_set ? (pcolor)->luminance :\
+ 	 gx_color_luminance(pcolor))
+ 
+ /* Color weights in 100ths, used for computing luminance. */
+ #define lum_red_weight	30
+ #define lum_green_weight	59
+ #define lum_blue_weight	11
+ #define lum_all_weights	(lum_red_weight + lum_green_weight + lum_blue_weight)


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzdevice.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzdevice.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzdevice.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,31 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gzdevice.h */
+ /* Private structures for describing devices for GhostScript */
+ /* requires gsmatrix.h */
+ #include "gxdevice.h"
+ 
+ /* Structure for a device in the graphics state */
+ typedef struct device_s {
+ 	gx_device *info;		/* points to actual device info */
+ /***	ref show_procedure;	***/
+ 	int is_band_device;		/* if true, must render in pieces */
+ 	gx_color_index white, black;	/* device color codes */
+ } device;


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzht.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzht.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzht.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,58 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gzht.h */
+ /* Private halftone representation for GhostScript */
+ 
+ /* Halftone parameter structure */
+ typedef struct halftone_s {
+ 	float frequency;
+ 	float angle;
+ 	/* Computed values */
+ 	int width;
+ 	int height;
+ 	struct ht_bit_s *order;		/* whitening order */
+ 	int order_size;
+ } halftone;
+ 
+ /*
+  * The whitening order is represented by an array stored in row order.
+  * The pixel represented by order[0] is whitened first.
+  * During sampling, order[i].mask is a normalized sample value.
+  * After sampling and sorting,
+  * order[i].offset is the byte index of the pixel in the rendering cache;
+  * order[i].mask is the mask to be or'ed into this byte and the
+  * following one.  (This is arranged so it will work properly on
+  * either big- or little-endian machines.)
+  */
+ typedef struct ht_bit_s {
+ 	ushort offset;
+ 	ushort mask;
+ } ht_bit;
+ 
+ /* Halftone enumeration structure */
+ struct gs_screen_enum_s {
+ 	float freq;
+ 	float angle;
+ 	ht_bit *order;
+ 	int width, height;
+ 	gs_matrix mat;		/* for mapping device x,y to rotated cell */
+ 	int x, y;
+ 	gs_state *pgs;
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzline.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzline.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzline.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,43 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gxline.h */
+ /* Private line parameters for GhostScript */
+ /* Requires gsstate.h */
+ 
+ /* Line parameter structures */
+ typedef struct dash_params_s {
+ 	float *pattern;
+ 	uint pattern_size;
+ 	float offset;
+ 	/* The rest of the parameters are computed from the above */
+ 	int init_ink_on;		/* true if ink is initially on */
+ 	int init_index;			/* initial index in pattern */
+ 	float init_dist_left;
+ } dash_params;
+ typedef struct line_params_s {
+ 	float width;			/* one-half line width */
+ 	gs_line_cap cap;
+ 	gs_line_join join;
+ 	float miter_limit;
+ 	float miter_check;		/* computed from miter limit, */
+ 					/* see gs_setmiterlimit and */
+ 					/* gs_stroke */
+ 	dash_params dash;
+ } line_params;


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzpath.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzpath.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzpath.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,95 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gzpath.h */
+ /* Private representation of paths for GhostScript library */
+ /* Requires gxfixed.h */
+ #include "gxpath.h"
+ 
+ /* Definition of a path segment: a segment start, a line, */
+ /* or a Bezier curve. */
+ typedef enum {
+ 	s_start,
+ 	s_line,
+ 	s_line_close,
+ 	s_curve
+ } segment_type;
+ #define segment_common\
+ 	struct segment_s *prev;\
+ 	struct segment_s *next;\
+ 	segment_type type;\
+ 	gs_fixed_point pt;		/* initial point for starts, */\
+ 					/* final point for others */
+ /* A generic segment */
+ typedef struct segment_s {
+ 	segment_common
+ } segment;
+ /* A start segment.  This serves as the head of a subpath. */
+ typedef struct {
+ 	segment_common
+ 	segment *last;			/* last segment of subpath, */
+ 					/* points back to here if empty */
+ 	int line_count;			/* # of lines */
+ 	int curve_count;		/* # of curves */
+ 	char closed;			/* true if subpath is closed */
+ } subpath;
+ /* Line segments currently have no special data. */
+ /* s_line is for ordinary lines, s_line_close is for the line */
+ /* appended by closepath. */
+ typedef struct {
+ 	segment_common
+ } line_segment;
+ /* Curve segments store the control points, not the coefficients. */
+ /* We may want to change this someday. */
+ typedef struct {
+ 	segment_common
+ 	gs_fixed_point p1, p2;
+ } curve_segment;
+ 
+ /* A path is stored as a linked list of segments, */
+ /* but each path occupies a single contiguous block of memory. */
+ struct gx_path_s {
+ 	gs_memory_procs memory_procs;
+ 	gs_fixed_rect bbox;		/* bounding box (in device space) */
+ 	segment *box_last;		/* box incorporates segments */
+ 					/* up to & including this one */
+ 	gs_fixed_rect cbox;		/* an inner clipping rectangle */
+ 					/* for a quick check */
+ 	subpath *first_subpath;
+ 	subpath *current_subpath;
+ 	int subpath_count;
+ 	int segment_count;
+ 	int curve_count;
+ 	gs_fixed_point position;	/* current position */
+ 	char position_valid;
+ 	char subpath_open;
+ 	char shares_segments;		/* if true, this path shares its */
+ 					/* segment storage with the one in */
+ 					/* the previous saved graphics state */
+ };
+ 
+ /* Macros equivalent to a few heavily used procedures. */
+ /* Be aware that these macros may evaluate arguments more than once. */
+ #define gx_path_current_point_inline(ppath,ppt)\
+  ( !ppath->position_valid ? gs_error_nocurrentpoint :\
+    ((ppt)->x = ppath->position.x, (ppt)->y = ppath->position.y, 0) )
+ #define gx_path_add_relative_point_inline(ppath,dx,dy)\
+  ( !ppath->position_valid ? gs_error_nocurrentpoint :\
+    (ppath->position.x += dx, ppath->position.y += dy,\
+     ppath->subpath_open = 0) )


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzstate.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzstate.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/gzstate.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,66 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* gzstate.h */
+ /* Private graphics state definition for GhostScript library */
+ /* Requires gxmatrix.h and gxfixed.h */
+ #include "gsstate.h"
+ 
+ /* Graphics state structure.  See pp. 59-60 of the PostScript manual. */
+ struct gs_state_s {
+ 	gs_state *saved;		/* previous state from gsave */
+ 	gs_memory_procs memory_procs;
+ /* Transformation: */
+ 	gs_matrix_fixed ctm;
+ #define ctm_only(pgs) *(gs_matrix *)&(pgs)->ctm
+ 	gs_matrix ctm_inverse;
+ 	int inverse_valid;		/* true if ctm_inverse = ctm^-1 */
+ /* Paths: */
+ 	char *path_alloc_base;
+ 	char *path_alloc_ptr;
+ 	struct gx_path_s *path;
+ 	struct gx_path_s *clip_path;
+ 	int clip_rule;
+ /* Lines: */
+ 	struct line_params_s *line_params;
+ /* Halftone screen: */
+ 	struct halftone_s *halftone;
+ 	float (*ht_proc)(P2(floatp, floatp));
+ /* Colors: */
+ 	struct gs_color_s *color;
+ 	struct gx_device_color_s *dev_color;
+ 	float (*transfer)(P1(floatp));
+ /* Font: */
+ 	struct gs_font_s *font;
+ 	gs_matrix char_tm;		/* font matrix * ctm: */
+ 					/* tx and ty are not used */
+ 	int char_tm_valid;		/* true if char_tm is valid */
+ 					/* (ignoring tx and ty, of course) */
+ 	byte in_cachedevice;		/* true after a setcachedevice */
+ 	byte in_charpath;		/* 0 if not in charpath, */
+ 					/* 1 if false charpath, */
+ 					/* 2 if true charpath */
+ 					/* (see charpath_flag in */
+ 					/* gs_show_enum_s) */
+ /* Other stuff: */
+ 	float flatness;
+ 	struct device_s *device;
+ 	int device_is_shared;		/* true if device is shared, */
+ 					/* so don't deallocate at grestore */
+ };


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ialloc.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ialloc.c:1.2.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ialloc.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,633 ----
+ /*
+  * Changes:
+  *
+  * 1) Date Unknown
+  *    It appears this file has the NOMEMOPT option added to disable memory
+  *    use optimizations.  This change was probably introduced by the
+  *    researchers from ftp://ftp.cs.colorado.edu/pub/cs/misc/malloc-benchmarks
+  */
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* ialloc.c */
+ /* Memory allocator for Ghostscript interpreter */
+ #include <stdio.h>		/* for NULL */
+ #include "std.h"
+ #include "memory_.h"
+ #include "alloc.h"
+ 
+ #ifdef DEBUG
+ extern char gs_debug[128];
+ #endif
+ 
+ /* Forward references */
+ typedef struct alloc_state_s alloc_state;
+ typedef alloc_state _ds *alloc_state_ptr;	/****** NOTE _ds ******/
+ private int alloc_add_chunk(P1(alloc_state_ptr));
+ private char *alloc_large(P3(alloc_state_ptr, uint, char *));
+ private void alloc_free_large(P3(char *, uint, char *));
+ 
+ /* Round up sizes of aligned objects. */
+ #define log2_align_mod 3		/* log2(sizeof(double)) */
+ #define align_mod (1<<log2_align_mod)
+ #define align_mask (align_mod-1)
+ #define align_round(siz) (uint)(((siz) + align_mask) & -align_mod)
+ 
+ /* Max object size for separate free list */
+ #define max_chain_size 255
+ 
+ /* Structure for a separately allocated block. */
+ typedef struct alloc_block_s alloc_block;
+ struct alloc_block_s {
+ 	alloc_block *next;
+ 	uint size;
+ 	int save_level;
+ 	alloc_state_ptr cap;
+ };
+ #define alloc_block_size align_round(sizeof(alloc_block))
+ 
+ /* Structure for a single wholesale allocation 'chunk'. */
+ typedef struct alloc_chunk_s alloc_chunk;
+ struct alloc_chunk_s {
+ 	/* Note that allocation takes place both from the bottom up */
+ 	/* (aligned objects) and from the top down (byte objects). */
+ 	byte *base;
+ 	byte *bot;			/* bottom of free area */
+ 					/* (top of aligned objects) */
+ 	byte *top;			/* top of free area */
+ 					/* (bottom of byte objects) */
+ 	byte *limit;
+ 	int save_level;			/* save level when this chunk */
+ 					/* was allocated */
+ 	alloc_chunk *next;		/* chain chunks together */
+ };
+ 
+ #define ptr_le(p1, p2)\
+   (ptr_ord_t)(p1) <= (ptr_ord_t)(p2)
+ #define ptr_lt(p1, p2)\
+   (ptr_ord_t)(p1) < (ptr_ord_t)(p2)
+ #define ptr_between(ptr, lo, hi)\
+   (ptr_le(lo, ptr) && ptr_lt(ptr, hi))
+ #define ptr_is_in_chunk(ptr, chunk)\
+   ptr_between(ptr, (chunk)->base, (chunk)->limit)
+ 
+ /* Structure for saved change chain for save/restore. */
+ /* This is a very space-inefficient implementation: */
+ /* we'll change it if the need arises. */
+ typedef struct alloc_change_s alloc_change;
+ struct alloc_change_s {
+ 	alloc_change *next;
+ 	char *where;
+ 	uint size;			/* # of bytes */
+ };
+ 
+ /* Structure for allocator state.  If we multi-thread some day, */
+ /* this might be instantiated more than once. */
+ struct alloc_state_s {
+ 	alloc_chunk current;		/* the current chunk */
+ #define cbase current.base
+ #define cbot current.bot
+ #define ctop current.top
+ #define climit current.limit
+ 	alloc_chunk *current_ptr;	/* where to put current */
+ 	uint chunk_size;		/* unit for wholesale malloc */
+ 	uint big_size;			/* min size for separate malloc */
+ 	proc_alloc_t palloc;		/* proc for malloc */
+ 	proc_free_t pfree;		/* proc for free */
+ 	/* Cumulative statistics */
+ 	long used, total;
+ 	unsigned num_chunks;
+ 	/* Chain together freed objects within a save level. */
+ 	/* We only do this for aligned objects. */
+ #define num_free_chains ((max_chain_size >> log2_align_mod) + 1)
+ 	char *free[num_free_chains];
+ 	/* Chain together any malloc'ed objects */
+ 	alloc_block *malloc_chain;
+ 	/* Keep track of saved states */
+ 	alloc_save *saved;
+ 	int save_level;
+ 	alloc_change *changes;
+ };
+ /* The only instance for now */
+ private alloc_state as_current;
+ 
+ /* Saved state of allocator */
+ /*typedef struct alloc_save_s alloc_save;*/	/* in alloc.h */
+ struct alloc_save_s {
+ 	alloc_state state;
+ 	alloc_state_ptr cap;
+ };
+ 
+ /* Debugging printout */
+ #ifdef DEBUG
+ #  define alloc_print(rtag, tag, blk, sz)\
+ 	if ( gs_debug['A'] )\
+ 	  printf("[a:%c:%c%s]%lx(%u)\n", rtag, tag,\
+ 		 client_name, (ulong)blk, sz)
+ #  define alloc_print_large(rtag, tag, blk, sz)\
+ 	if ( gs_debug['A'] | gs_debug['a'] )\
+ 	  printf("[a:%c:%c%s]%lx(%u)\n", rtag, tag,\
+ 		 client_name, (ulong)blk, sz)
+ #else
+ #  define alloc_print(rtag, tag, blk, sz)
+ #  define alloc_print_large(rtag, tag, blk, sz)
+ #endif
+ 
+ /* ------ Initialize/status ------ */
+ 
+ /* Initialize the allocator */
+ void
+ alloc_init(proc_alloc_t palloc, proc_free_t pfree, uint chunk_size)
+ {	register alloc_state_ptr ap = &as_current;
+ 	memset(ap, 0, sizeof(alloc_state));	/* do it all at once */
+ 	ap->chunk_size = chunk_size;
+ #if defined(NOMEMOPT)
+ 	ap->big_size = 8;
+ #else	
+ 	ap->big_size = chunk_size / 4;
+ #endif	
+ 	ap->palloc = palloc;
+ 	ap->pfree = pfree;
+ }
+ 
+ /* Return the status of the allocator: space used, total space. */
+ void
+ alloc_status(long *pused, long *ptotal)
+ {	register alloc_state_ptr ap = &as_current;
+ 	*pused = (ap->cbot - ap->cbase) + (ap->climit - ap->ctop) + ap->used;
+ 	*ptotal = ap->climit - ap->cbase + ap->total;
+ }
+ 
+ /* ------ Allocation and freeing ------ */
+ 
+ /* Allocate an object.  Return 0 if not enough room. */
+ char *
+ alloc(uint num_elts, uint elt_size, char *client_name)
+ {	register alloc_state_ptr ap = &as_current;
+ 	uint size = num_elts * elt_size;
+ 	uint block_size;
+ 	uint left;
+ 	if ( size >= ap->big_size )
+ 	   {	/* Large object, do a separate malloc. */
+ 		char *block = alloc_large(ap, size, client_name);
+ 		if ( block != NULL ) return block;
+ 	   }
+ 	block_size = align_round(size);
+ 	if ( block_size <= max_chain_size )
+ 	   {	/* See if we can use a freed block. */
+ 		char **fptr = &ap->free[block_size >> log2_align_mod];
+ 		char *block = *fptr;
+ 		if ( block != 0 )
+ 		   {	*fptr = *(char **)block;
+ 			alloc_print('+', '#', block, size);
+ 			return block;
+ 		   }
+ 	   }
+ 	left = ap->ctop - ap->cbot;
+ 	if ( block_size > left )
+ 	   {	if ( !alloc_add_chunk(ap) )
+ 		   {	alloc_print('+', '?', (ulong)0, size);
+ 			return 0;
+ 		   }
+ 	   }
+ 	if ( elt_size == 1 )
+ 	   {	/* Unaligned block */
+ 		ap->ctop -= size;
+ 		alloc_print('+', '>', ap->ctop, size);
+ 		return (char *)ap->ctop;
+ 	   }
+ 	else
+ 	   {	/* Aligned block */
+ 		char *block = (char *)ap->cbot;
+ 		ap->cbot += block_size;
+ 		alloc_print('+', '<', block, size);
+ 		return block;
+ 	   }
+ }
+ 
+ /* Free an object, if possible. */
+ /* Note that if a save is in effect, objects in chunks older than */
+ /* the save, and objects allocated with malloc before the save, */
+ /* must not be freed. */
+ void
+ alloc_free(char *cobj, uint num_elts, uint elt_size, char *client_name)
+ {	register alloc_state_ptr ap = &as_current;
+ 	uint size = num_elts * elt_size;
+ 	uint block_size;
+ 	if ( size >= ap->big_size )
+ 	   {	/* Object was allocated with malloc. */
+ 		alloc_free_large(cobj, size, client_name);
+ 		return;
+ 	   }
+ #define obj ((byte *)cobj)
+ 	else if ( obj == ap->ctop )
+ 	   {	/* Don't free the object if we're in a save and */
+ 		/* this object wasn't allocated since the save. */
+ 		if ( ap->save_level == 0 ||
+ 		     ap->current.save_level >= ap->save_level ||
+ 		     /* We know the current chunk is the same as */
+ 		     /* the one in as->saved->state */
+ 		     obj < ap->saved->state.ctop
+ 		   )
+ 			ap->ctop += size;
+ 		alloc_print('-', '>', obj, size);
+ 		return;
+ 	   }
+ 	else if ( obj + (block_size = align_round(size)) == ap->cbot )
+ 	   {	/* Freeing an aligned object.  Same check. */
+ 		if ( ap->save_level == 0 ||
+ 		     ap->current.save_level >= ap->save_level ||
+ 		     obj >= ap->saved->state.cbot
+ 		   )
+ 			ap->cbot = obj;
+ 		alloc_print('-', '<', obj, size);
+ 		return;
+ 	   }
+ 	else if ( !ptr_is_in_chunk(obj, &ap->current) )
+ 	   {	/* In another segment, check its save level. */
+ 		int level = ap->save_level;
+ 		alloc_chunk *cp = ap->current.next;
+ 		for ( ; ; cp = cp->next )
+ 		  { if ( cp != 0 )
+ 		      { switch ( cp->save_level - level )
+ 			  {
+ 			  case 0:
+ 			    if ( ptr_is_in_chunk(obj, cp) )
+ 			      { if ( ptr_lt(obj, cp->bot) ) goto pbf;
+ 			      else break;
+ 			      }
+ 			    else continue;
+ 			  case -1:
+ 			    /* Might be alloc'ed since the save, */
+ 			    /* or might not be aligned. */
+ 			    if ( ptr_lt(obj, ap->saved->state.cbot) )
+ 			      goto pbf;
+ 			  }
+ 		      }
+ 		    /* Older save level, not freeable. */
+ 		    alloc_print('-', '\\', obj, size);
+ 		    return;
+ 		  }
+ pbf:		/* If we get here, OK to put the block on a free list. */
+ 		;
+ 	   }
+ 	else if ( obj >= ap->cbot )	/* not aligned object, punt */
+ 	   {	alloc_print('-', '~', obj, size);
+ 		return;
+ 	   }
+ 	/* Put on a free list if small enough */
+ 	alloc_print('-', '#', obj, size);
+ 	if ( block_size <= max_chain_size && block_size >= sizeof(char **) )
+ 	   {	char **fptr = &ap->free[block_size >> log2_align_mod];
+ 		*(char **)cobj = *fptr;
+ 		*fptr = cobj;
+ 	   }
+ #undef obj
+ }
+ 
+ /* Grow an object.  This may require allocating a new copy. */
+ /* Return 0 if not enough room. */
+ byte *
+ alloc_grow(byte *obj, uint old_num, uint new_num, uint elt_size,
+   char *client_name)
+ {	register alloc_state_ptr ap = &as_current;
+ 	uint old_size = old_num * elt_size;
+ 	uint new_size = new_num * elt_size;
+ 	byte *nobj;
+ 	if ( new_size == old_size ) return obj;
+ 	if ( new_size < ap->big_size ) /* try to grow in place */
+ 	  { uint old_block_size;
+ 	    uint new_block_size;
+ 	    if ( obj == ap->ctop )
+ 	      { /* Might be able to grow in place */
+ 		uint diff = new_size - old_size;
+ 		if ( diff <= ap->ctop - ap->cbot )
+ 		  { alloc_print('>', '>', obj, new_size);
+ 		    ap->ctop -= diff;
+ 		    memcpy(ap->ctop, obj, old_size);
+ 		    return ap->ctop;
+ 		  }
+ 	      }
+ 	    old_block_size = align_round(old_size);
+ 	    new_block_size = align_round(new_size);
+ 	    if ( obj + old_block_size == ap->cbot )
+ 	      { /* Might be able to grow in place */
+ 		uint diff = new_block_size - old_block_size;
+ 		if ( diff <= ap->ctop - ap->cbot )
+ 		  { alloc_print('>', '<', obj, new_size);
+ 		    ap->cbot += diff;
+ 		    return obj;
+ 		  }
+ 	      }
+ 	  }
+ 	/* Can't grow in place.  Allocate a new object and copy. */
+ 	nobj = (byte *)alloc(new_num, elt_size, client_name);
+ 	if ( nobj == 0 ) return 0;
+ 	memcpy(nobj, obj, old_size);
+ 	alloc_free((char *)obj, old_num, elt_size, client_name);
+ 	alloc_print('>', '&', obj, new_size);
+ 	return nobj;
+ }
+ 
+ /* Shrink an object. */
+ byte *
+ alloc_shrink(byte *obj, uint old_num, uint new_num, uint elt_size,
+   char *client_name)
+ {	register alloc_state_ptr ap = &as_current;
+ 	uint old_size = old_num * elt_size;
+ 	uint new_size = new_num * elt_size;
+ 	if ( new_size == old_size ) return obj;
+ 	if ( old_size >= ap->big_size )
+ 	  { /* Allocate a new block. */
+ 	    byte *nobj = (byte *)alloc(new_num, elt_size, client_name);
+ 	    if ( nobj == 0 ) return obj; /* can't shrink, leave as is */
+ 	    memcpy(nobj, obj, new_size);
+ 	    alloc_free((char *)obj, old_num, elt_size, client_name);
+ 	    alloc_print('<', '&', obj, new_size);
+ 	    return nobj;
+ 	  }
+ 	else if ( obj == ap->ctop )
+ 	  { /* Move the object up in place. */
+ 	    /* memcpy doesn't do this properly. */
+ 	    register byte *from = obj + new_size;
+ 	    register byte *to = obj + old_size;
+ 	    while ( from > obj ) *--to = *--from;
+ 	    obj = ap->ctop = to;
+ 	  }
+ 	else
+ 	  { uint new_block_size = align_round(new_size);
+ 	    alloc_free((char *)(obj + new_block_size),
+ 		       1, align_round(old_size) - new_block_size,
+ 		       "alloc_shrink");
+ 	  }
+ 	alloc_print('<', ' ', obj, new_size);
+ 	return obj;
+ }
+ 
+ /* ------ Save and restore state ------ */
+ 
+ /*
+  * The logic for saving and restore the state is rather subtle.
+  * Both the changes to individual objects, and the overall state
+  * of the memory manager, must be saved and restored.
+  */
+ 
+ /*
+  * To save the state of the memory manager:
+  *	Save the state of the current chunk in which we are allocating.
+  *	Save the identity of the current chunk.
+  *	Save and reset the malloc chain and the orphan block chains.
+  * By doing this, we guarantee that no object older than the save
+  * can be freed.
+  *
+  * To restore the state of the memory manager:
+  *	Free all chunks newer than the save.
+  *	Free all malloc'ed blocks newer than the save.
+  *	Make current the chunk that was current at the time of the save.
+  *	Free all objects allocated in the current chunk since the save.
+  */
+ 
+ /* For saving changes to individual objects, we add an "attribute" bit
+  * that logically belongs to the slot where the descriptor is stored,
+  * not to the descriptor itself.  The bit means "the contents
+  * of this slot have been changed since the last save."
+  * To keep track of changes since the save, we associate a chain of
+  * <slot, old_contents> pairs that remembers the old contents of slots.
+  *
+  * When creating an object, if the save level is non-zero:
+  *	Set the bit in all slots.
+  *
+  * When storing into a slot, if the save level is non-zero:
+  *	If the bit isn't set, save the address and contents of the slot
+  *	  on the current contents chain.
+  *	Set the bit after storing the new value.
+  *
+  * To do a save:
+  *	Reset the bit in all slots on the contents chain, and in all
+  *	  objects created since the previous save.
+  *	Push the head of contents chain, and reset the chain to empty.
+  *
+  * To do a restore:
+  *	Check all the stacks to make sure they don't contain references
+  *	  to objects created since the save.
+  *	Restore all the slots on the contents chain.
+  *	Pop the contents chain head.
+  *	Scan the newly restored contents chain, and set the bit in all
+  *	  the slots it references.
+  *	Scan all objects created since the previous save, and set the bit
+  *	  in all the slots of each object.
+  */
+ 
+ /* Save the state. */
+ alloc_save *
+ alloc_save_state()
+ {	register alloc_state_ptr ap = &as_current;
+ 	alloc_save *save =
+ 		(alloc_save *)alloc(1, sizeof(alloc_save), "alloc_save_state");
+ 	if ( save == 0 ) return 0;
+ 	save->state = *ap;
+ 	/* Clear the free chains, to prevent old objects from being freed. */
+ 	memset(&ap->free[0], 0, num_free_chains * sizeof(char *));
+ 	ap->malloc_chain = 0;
+ 	ap->saved = save;
+ 	ap->save_level++;
+ 	ap->changes = 0;
+ 	return save;
+ }
+ 
+ /* Record a state change that must be undone for restore. */
+ int
+ alloc_save_change(char *where, uint size)
+ {	register alloc_state_ptr ap = &as_current;
+ 	register alloc_change *cp;
+ 	if ( ap->save_level == 0 ) return 0;	/* no saving */
+ 	cp = (alloc_change *)alloc(1, sizeof(alloc_change) + size,
+ 				   "alloc_save_change");
+ 	if ( cp == 0 ) return -1;
+ 	cp->next = ap->changes;
+ 	cp->where = where;
+ 	cp->size = size;
+ 	memcpy((char *)cp + sizeof(alloc_change), where, size);
+ 	ap->changes = cp;
+ 	return 0;
+ }
+ 
+ /* Return the current save level */
+ int
+ alloc_save_level()
+ {	return as_current.save_level;
+ }
+ 
+ /* Test whether a reference would be invalidated by a restore. */
+ int
+ alloc_is_since_save(char *ptr, alloc_save *save)
+ {
+ 	/* A reference can postdate a save in one of three ways: */
+ 	/*	- It is in the chunk that was current at the time */
+ 	/*	    of the save, and allocated more recently. */
+ 	/*	- It is in a chunk allocated since the save; */
+ 	/*	- It was malloc'ed since the save; */
+ 
+ 	register alloc_state_ptr ap = save->cap;
+ 
+ 	/* Check against current chunk at the time of the save */
+ 	if ( ptr_is_in_chunk(ptr, &save->state.current) )
+ 	   {	/* In the chunk, check against allocation pointers */
+ 		/* at the time of the save */
+ 		return ( (ptr_ord_t)ptr >= (ptr_ord_t)save->state.cbot &&
+ 			 (ptr_ord_t)ptr < (ptr_ord_t)save->state.ctop );
+ 	   }
+ 
+ 	/* Check against chunks allocated since the save */
+ 	   {	alloc_chunk *chunk = &ap->current;
+ 		while ( chunk->save_level > save->state.save_level )
+ 		   {	if ( ptr_is_in_chunk(ptr, chunk) ) return 1;
+ 			chunk = chunk->next;
+ 		   }
+ 	   }
+ 
+ 	/* Check the malloc chains since the save */
+ 	   {	alloc_state *asp = ap;
+ 		for ( ; asp != &save->state; asp = &asp->saved->state )
+ 		   {	alloc_block *mblk = asp->malloc_chain;
+ 			for ( ; mblk != 0; mblk = mblk->next )
+ 			  if ( alloc_block_size + (char *)mblk == ptr ) return 1;
+ 		   }
+ 	   }
+ 
+ 	/* Not in any of those places, must be OK. */
+ 	return 0;
+ }
+ 
+ /* Validate a saved state pointer. */
+ int
+ alloc_restore_state_check(alloc_save *save)
+ {	alloc_save *sprev = save->cap->saved;
+ 	while ( sprev != save )
+ 	   {	if ( sprev == 0 ) return -1;	/* not on chain */
+ 		sprev = sprev->state.saved;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Restore the state.  The client is responsible for calling */
+ /* alloc_restore_state_check first, and for ensuring that */
+ /* there are no surviving pointers for which alloc_is_since_save is true. */
+ void
+ alloc_restore_state(alloc_save *save)
+ {	register alloc_state_ptr ap = save->cap;
+ 	alloc_save *sprev;
+ 
+ 	/* Iteratively restore the state */
+ 	do
+ 	   {	sprev = ap->saved;
+ 		/* Free chunks allocated since the save. */
+ 		   {	alloc_chunk *cp = ap->current_ptr;
+ 			*cp = ap->current;	/* update in memory */
+ 		   }
+ 		/* Free blocks allocated with malloc since the save. */
+ 		/* Since we reset the chain when we did the save, */
+ 		/* we just free all the objects on the current chain. */
+ 		   {	while ( ap->malloc_chain != 0 )
+ 			   {	alloc_block *mblock = ap->malloc_chain;
+ 				ap->malloc_chain = mblock->next;
+ 				(*ap->pfree)((char *)mblock,
+ 					    1, alloc_block_size + mblock->size,
+ 					    "alloc_restore_state(malloc'ed)");
+ 			   }
+ 		   }
+ 		/* Undo changes since the save. */
+ 		   {	alloc_change *cp = ap->changes;
+ 			while ( cp )
+ 			   {	memcpy(cp->where, (char *)cp + sizeof(alloc_change), cp->size);
+ 				cp = cp->next;
+ 			   }
+ 		   }
+ 		/* Restore the allocator state. */
+ 		*ap = sprev->state;
+ 		alloc_free((char *)sprev, 1, sizeof(alloc_save),
+ 			   "alloc_restore_state");
+ 	   }
+ 	while ( sprev != save );
+ }
+ 
+ /* ------ Private routines ------ */
+ 
+ /* Allocate (with malloc) an object too large to be put in a chunk. */
+ /* Return NULL on failure. */
+ private char *
+ alloc_large(alloc_state_ptr ap, uint size, char *client_name)
+ {	alloc_block *mblock = (alloc_block *)
+ 		(*ap->palloc)(1, alloc_block_size + size, client_name);
+ 	char *block;
+ 	if ( mblock == NULL ) return NULL;
+ 	block = (char *)mblock + alloc_block_size;
+    	alloc_print_large('+', '*', block, size);
+ 	mblock->next = ap->malloc_chain;
+ 	mblock->size = size;
+ 	mblock->save_level = ap->save_level;
+ 	mblock->cap = ap;
+ 	ap->malloc_chain = mblock;
+ 	return block;
+ }
+ 
+ /* Allocate a new chunk.  Return true if successful. */
+ private int
+ alloc_add_chunk(register alloc_state_ptr ap)
+ {	char *space = (*ap->palloc)(1, ap->chunk_size, "alloc chunk");
+ #ifdef DEBUG
+ if ( gs_debug['A'] | gs_debug['a'] )
+ 	printf("[a]%lx@%u\n", (ulong)space, ap->chunk_size);
+ #endif
+ 	if ( space == NULL ) return 0;
+ 	/* Update statistics for the old chunk */
+ 	alloc_status(&ap->used, &ap->total);
+ 	ap->num_chunks++;
+ 	/* Stash the state of the old chunk */
+ 	if ( ap->current_ptr != 0 )	/* check for very first chunk */
+ 		*ap->current_ptr = ap->current;
+ 	/* Initialize the new chunk */
+ 	ap->cbase = ap->cbot = (byte *)space + align_round(sizeof(alloc_chunk));
+ 	ap->climit = ap->ctop = (byte *)(space + ap->chunk_size);
+ 	ap->current.next = ap->current_ptr;
+ 	ap->current.save_level = ap->save_level;
+ 	ap->current_ptr = (alloc_chunk *)space;
+ 	return 1;
+ }
+ 
+ /* Free a large object (allocated with malloc). */
+ private void
+ alloc_free_large(char *cobj, uint size, char *client_name)
+ {	alloc_block **prev;
+ 	alloc_block *mblock = (alloc_block *)(cobj - alloc_block_size);
+ 	alloc_state_ptr ap = mblock->cap;
+ 	if ( mblock->save_level == ap->save_level )
+ 	 for ( prev = &ap->malloc_chain; *prev != 0; prev = &mblock->next )
+ 	   {	mblock = *prev;
+ 		if ( (char *)mblock + alloc_block_size == cobj )
+ 		   {	*prev = mblock->next;
+ 			(*ap->pfree)((char *)mblock,
+ 				    1, size + alloc_block_size,
+ 				    "large object");
+ 			alloc_print_large('-', '*', cobj, size);
+ 			return;
+ 		   }
+ 	   }
+ 	alloc_print('-', '?', cobj, size);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/idebug.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/idebug.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/idebug.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,115 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* idebug.c */
+ /* Debugging support for GhostScript interpreter */
+ #include "ghost.h"
+ #include "name.h"
+ 
+ /* Forward references */
+ void debug_print_string(P2(byte *, ushort));
+ 
+ /* Print a ref */
+ void
+ debug_print_ref(ref *pref)
+ {	unsigned size = pref->size;
+ 	printf("(%x)", pref->type_attrs);
+ 	switch ( r_type(pref) )
+ 	   {
+ 	case t_array:
+ 	  printf("array(%u)0x%lx", size, (ulong)pref->value.refs); break;
+ 	case t_boolean: printf("boolean %x", pref->value.index); break;
+ 	case t_device:
+ 	  printf("device 0x%lx", (ulong)pref->value.pdevice); break;
+ 	case t_dictionary:
+ 	  printf("dict(%u/%u)0x%lx",
+ 		 dict_length(pref), dict_maxlength(pref),
+ 		 (ulong)pref->value.pdict); break;
+ 	case t_file: printf("file 0x%lx", (ulong)pref->value.pfile); break;
+ 	case t_integer: printf("int %ld", pref->value.intval); break;
+ 	case t_mark: printf("mark"); break;
+ 	case t_name:
+ 	  printf("name(0x%lx#%x)", (ulong)pref->value.pname,
+ 		 pref->value.pname->index);
+ 	  debug_print_string(pref->value.pname->string_bytes,
+ 			     pref->value.pname->string_size);
+ 	  break;
+ 	case t_null: printf("null"); break;
+ 	case t_operator:
+ 	  printf("op(%u)0x%lx", size, (ulong)pref->value.opproc); break;
+ 	case t_packedarray:
+ 	  printf("packedarray(%u)0x%lx", size, (ulong)pref->value.refs); break;
+ 	case t_real: printf("real %f", pref->value.realval); break;
+ 	case t_string:
+ 	  printf("string(%u)0x%lx", size, (ulong)pref->value.bytes); break;
+ 	default: printf("type 0x%x", r_type(pref));
+ 	   }
+ }
+ 
+ /* Print a string */
+ void
+ debug_print_string(byte *chrs, ushort len)
+ {	ushort i;
+ 	for ( i = 0; i < len; i++ )
+ 		putchar(chrs[i]);
+ }
+ 
+ /* Dump a region of memory containing refs */
+ void
+ debug_dump_refs(ref *from, ref *to, char *msg)
+ {	ref *p = from;
+ 	if ( from < to ) printf("%s:\n", msg);
+ 	while ( p < to )
+ 	   {	unsigned type = r_type(p), attrs = p->type_attrs;
+ 		unsigned btype = r_btype(p);
+ 		static char *ts[] = { type_print_strings };
+ 		static char *as = attr_print_string;
+ 		char *ap = as;
+ 		printf("0x%lx: 0x%02x ", (ulong)p, type);
+ 		if ( btype >= t_next_index )
+ 			printf("0x%02x?? ", btype);
+ 		else
+ 			printf("%s ", ts[btype]);
+ 		for ( ; *ap; ap++, attrs >>= 1 )
+ 		  if ( *ap != '.' )
+ 		    putchar(((attrs & 1) ? *ap : '-'));
+ 		printf(" 0x%04x 0x%08lx", p->size, *(ulong *)&p->value);
+ 		switch ( btype )
+ 		   {
+ 		case t_real: printf("  =  %g", p->value.realval); break;
+ 		case t_integer: printf("  =  %ld", p->value.intval); break;
+ 		default: ;
+ 		   }
+ 		printf("\n");
+ 		p++;
+ 	   }
+ }
+ 
+ /* Dump a region of memory */
+ void
+ debug_dump_bytes(byte *from, byte *to, char *msg)
+ {	byte *p = from;
+ 	if ( from < to ) printf("%s:\n", msg);
+ 	while ( p != to )
+ 	   {	byte *q = min(p + 16, to);
+ 		printf("%lx:", (ulong)p);
+ 		while ( p != q ) printf(" %02x", *p++);
+ 		printf("\n");
+ 	   }
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/idict.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/idict.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/idict.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,291 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* idict.c */
+ /* Dictionaries for Ghostscript */
+ #include "ghost.h"
+ #include "alloc.h"
+ #include "errors.h"
+ #include "name.h"
+ #include "store.h"
+ #include "dict.h"	/* interface definition */
+ 
+ /* Import the dictionary stack */
+ extern ref dstack[];
+ 
+ /* Import systemdict and userdict for the name value cache. */
+ #define systemdict (dstack[0])
+ #define userdict (dstack[1])
+ 
+ /*
+  * A dictionary is a structure of two elements (refs).
+  * The first element is a t_integer whose value says how many
+  * entries are occupied (N).  The second element is a t_array
+  * of 2N+2 elements, containing alternating keys and values.
+  * Unused entries have null as the key.  The first entry also
+  * has null as the key (to avoid a special wrap-around check).
+  * The access attributes for the dictionary are stored in
+  * the contents ref.
+  */
+ struct dict_s {
+ 	ref count;			/* t_integer */
+ 	ref contents;			/* t_array */
+ };
+ struct pair_s {
+ 	ref key;
+ 	ref value;
+ };
+ typedef struct pair_s pair;
+ #define pairs(dct) (pair *)((dct)->contents.value.refs)
+ #define npairs(dct) (((dct)->contents.size >> 1) - 1)
+ 
+ /* Define the size of the largest valid dictionary. */
+ /* This is limited by the size field of the contents ref. */
+ uint dict_max_size = max_ushort / 2 - 1;
+ 
+ /* Create a dictionary */
+ int
+ dict_create(uint size, ref *pref)
+ {	uint asize = (size == 0 ? 1 : size) + 1;
+ 	dict *pdict = (dict *)alloc(1, sizeof(dict), "dict_create");
+ 	pair *pp;
+ 	if ( pdict == 0 ) return e_VMerror;
+ 	pp = (pair *)alloc(asize, sizeof(pair), "dict_create(pairs)");
+ 	if ( pp == 0 )
+ 	   {	alloc_free((char *)pdict, 1, sizeof(dict), "dict_create");
+ 		return e_VMerror;
+ 	   }
+ 	n_store_int(&pdict->count, 0);
+ 	n_store_tasv(&pdict->contents, t_array, a_all, asize * 2,
+ 		     refs, (ref *)pp);
+ 	n_store_tav(pref, t_dictionary, a_all, pdict, pdict);
+ 	pp = pairs(pdict);
+ 	while ( asize-- )
+ 		pp->key.type_attrs = pp->value.type_attrs = null_type_attrs,
+ 		pp++;
+ 	return 0;
+    }
+ 
+ /* Return a pointer to a ref that holds the access attributes */
+ /* for a dictionary. */
+ ref *
+ dict_access_ref(ref *pdref)
+ {	return &pdref->value.pdict->contents;
+ }
+ 
+ /* Look up in a stack of dictionaries.  Store a pointer to the value slot */
+ /* where found, or to the (value) slot for inserting. */
+ /* Return 1 if found, 0 if not and there is room for a new entry, */
+ /* or e_dictfull if the dictionary is full and the key is missing. */
+ /* The caller is responsible for ensuring key is not a null. */
+ /* Note that pdbot <= pdtop, and the search starts at pdtop. */
+ int
+ dict_lookup(ref *pdbot, ref *pdtop, ref *pkey,
+   ref **ppvalue /* result is stored here */)
+ {	ref *pdref = pdtop;
+ 	uint hash;
+ 	int ktype;
+ 	name *kpname;
+ 	int full = 1;			/* gets set to 0 or e_dictfull */
+ 	/* Compute hash.  The only types we bother with are strings */
+ 	/* and names. */
+ 	switch ( r_type(pkey) )
+ 	   {
+ 	case t_name:
+ 		kpname = pkey->value.pname;
+ nh:		hash = kpname->index * 40503;
+ 		ktype = t_name; break;
+ 	case t_string:			/* convert to a name first */
+ 	   {	ref nref;
+ 		int code = name_ref(pkey->value.bytes, pkey->size, &nref, 1);
+ 		if ( code < 0 ) return code;
+ 		kpname = nref.value.pname;
+ 	   }	goto nh;
+ 	default:
+ 		hash = r_btype(pkey) * 99;	/* yech */
+ 		ktype = -1;
+ 	   }
+ 	do
+ 	   {	dict *pdict = pdref->value.pdict;
+ 		uint size = npairs(pdict);
+ 		pair *ppbot = pairs(pdict);
+ 		register pair *pp;		/* probe pointer */
+ 		int wrap = 0;
+ 		register int etype;
+ 		/* Search the dictionary */
+ #ifdef DEBUG
+ if ( gs_debug['d'] )
+ 		   {	extern void debug_print_ref(P1(ref *));
+ 			printf("[d]");
+ 			debug_print_ref(pdref);
+ 			printf(":");
+ 			debug_print_ref(pkey);
+ 			printf("->");
+ 		   }
+ #endif
+ #ifdef DEBUG
+ #  define print_found()\
+ if ( gs_debug['d'] )\
+    {	extern void debug_print_ref(P1(ref *));\
+ 	debug_print_ref(&pp->value);\
+ 	printf("; ");\
+    }
+ #else
+ #  define print_found()
+ #endif
+ 		for ( pp = ppbot + (hash % size) + 2; ; )
+ 		   {	if ( (etype = r_type(&(--pp)->key)) == ktype )
+ 			   {	/* Fast comparison if both keys are names */
+ 				if ( pp->key.value.pname == kpname )
+ 				   {	*ppvalue = &pp->value;
+ 					print_found();
+ 					return 1;
+ 				   }
+ 			   }
+ 			else if ( etype == t_null )
+ 			   {	/* We might have hit the dummy entry at */
+ 				/* the beginning, in which case we should */
+ 				/* wrap around to the end. */
+ 				if ( pp == ppbot )	/* wrap */
+ 				   {	if ( wrap++ )	/* wrapped twice */
+ 					   {	if ( full > 0 )
+ 							full = e_dictfull;
+ 						goto next_dict;
+ 					   }
+ 					pp += size + 1;
+ 				   }
+ 				else	/* key not found */
+ 					break;
+ 			   }
+ 			else
+ 			   {	if ( obj_eq(&pp->key, pkey) )
+ 				   {	*ppvalue = &pp->value;
+ 					print_found();
+ 					return 1;
+ 				   }
+ 			   }
+ 		   }
+ 		if ( full > 0 )
+ 		   {	*ppvalue = &pp->value;
+ #ifdef DEBUG
+ if ( gs_debug['d'] )
+ 			printf("0(%lx); ", (ulong)&pp->value);
+ #endif
+ 			full = 0;
+ 		   }
+ next_dict: ;
+ 	   }
+ 	while ( --pdref >= pdbot );
+ 	return full;
+ }
+ 
+ /* Enter a key-value pair in a dictionary. */
+ /* Return 0 or e_dictfull. */
+ int
+ dict_put(ref *pdref /* t_dictionary */, ref *pkey, ref *pvalue)
+ {	ref *pvslot;
+ 	if ( dict_find(pdref, pkey, &pvslot) <= 0 )	/* not found */
+ 	   {	/* Check for overflow */
+ 		dict *pdict = pdref->value.pdict;
+ 		if ( pdict->count.value.intval == npairs(pdict) )
+ 			return e_dictfull;
+ 		pdict->count.value.intval++;
+ 		pvslot[-1] = *pkey;	/* i.e. key of pair */
+ 		/* If the key is a name, update its 1-element cache. */
+ 		if ( r_type(pkey) == t_name )
+ 		   {	name *pname = pkey->value.pname;
+ 			if ( pname->pvalue == pv_no_defn &&
+ 				(pdict == systemdict.value.pdict ||
+ 				 pdict == userdict.value.pdict) )
+ 			   {	/* Initialize the cache */
+ 				pname->pvalue = pvslot;
+ 			   }
+ 			else	/* The cache is worthless */
+ 				pname->pvalue = pv_other;
+ 		   }
+ 	   }
+ 	store_i(pvslot, pvalue);
+ 	return 0;
+ }
+ 
+ /* Return the number of elements in a dictionary. */
+ uint
+ dict_length(ref *pdref /* t_dictionary */)
+ {	return (uint)(pdref->value.pdict->count.value.intval);
+ }
+ 
+ /* Return the capacity of a dictionary. */
+ uint
+ dict_maxlength(ref *pdref /* t_dictionary */)
+ {	return npairs(pdref->value.pdict);
+ }
+ 
+ /* Copy one dictionary into another. */
+ int
+ dict_copy(ref *pdrfrom /* t_dictionary */, ref *pdrto /* t_dictionary */)
+ {	dict *pdict = pdrfrom->value.pdict;
+ 	int count = npairs(pdict) + 1;	/* +1 for dummy first entry */
+ 	pair *pp = pairs(pdict);
+ 	int code;
+ 	while ( count-- )
+ 	   {	if ( r_type(&pp->key) != t_null )
+ 			if ( (code = dict_put(pdrto, &pp->key, &pp->value)) != 0 )
+ 				return code;
+ 		pp++;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Resize a dictionary */
+ int
+ dict_resize(ref *pdrfrom, uint new_size)
+ {	dict *pdict = pdrfrom->value.pdict;
+ 	ref drto;
+ 	int code;
+ 	if ( (code = dict_create(new_size, &drto)) < 0 ) return code;
+ 	dict_copy(pdrfrom, &drto);	/* can't fail */
+ 	/* Free the old dictionary */
+ 	alloc_free((char *)pdict->contents.value.refs,
+ 		   dict_maxlength(pdrfrom), sizeof(pair), "dict_resize(old)");
+ 	*pdict = *drto.value.pdict;
+ 	/* Free the new dictionary header */
+ 	alloc_free((char *)drto.value.pdict,
+ 		   1, sizeof(dict), "dict_resize(new)");
+ 	return 0;
+ }
+ 
+ /* Prepare to enumerate a dictionary. */
+ int
+ dict_first(ref *pdref)
+ {	return (int)(npairs(pdref->value.pdict) + 1);	/* +1 for dummy */
+ }
+ 
+ /* Enumerate the next element of a dictionary. */
+ int
+ dict_next(ref *pdref, int index, ref *eltp /* ref eltp[2] */)
+ {	pair *pp = pairs(pdref->value.pdict) + index;
+ 	while ( pp--, --index >= 0 )
+ 	   {	if ( r_type(&pp->key) != t_null )
+ 		   {	eltp[0] = pp->key;
+ 			eltp[1] = pp->value;
+ 			return index;
+ 		   }
+ 	   }
+ 	return -1;			/* no more elements */
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iinit.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iinit.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iinit.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,119 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* iinit.c */
+ /* Initialize internally known objects for GhostScript interpreter */
+ #include "ghost.h"
+ #include "dict.h"
+ #include "oper.h"
+ #include "store.h"
+ 
+ /* Implementation parameters */
+ #define systemdict_size 401		/* a nice prime number */
+ 
+ /* Standard dictionaries */
+ ref name_errordict;
+ extern ref dstack[];
+ #define systemdict (dstack[0])
+ /* Error names */
+ ref name_ErrorNames;
+ 
+ /* Enter a name and value into systemdict */
+ void
+ initial_enter_name(char *nstr, ref *pref)
+ {	ref nref;
+ 	name_enter(nstr, &nref);
+ 	if ( dict_put(&systemdict, &nref, pref) )
+ 		dprintf("dict_put failed!\n"), exit(1);
+ }
+ 
+ /* Enter an operator into systemdict. */
+ /* The first character of the name is a digit */
+ /* giving the minimum acceptable number of operands. */
+ void
+ initial_enter_op(char *nstr, op_proc_p proc)
+ {	ref oper;
+ 	make_tasv(&oper, t_operator, a_executable, *nstr - '0', opproc, proc);
+ 	interp_fix_op(&oper);		/* optimize if possible */
+ 	initial_enter_name(nstr + 1, &oper);
+ }
+ 
+ /* Initialize objects other than operators */
+ void
+ obj_init()
+ {
+ 	/* Initialize the standard objects */
+ 	ref vmark, vnull;
+ 	make_tv(&vmark, t_mark, intval, 0);
+ 	make_tv(&vnull, t_null, intval, 0);
+ 
+ 	/* Create the system dictionary */
+ 	dict_create(systemdict_size, &systemdict);
+ 	dstack[1] = dstack[0];		/* just during initialization */
+ 
+ 	/* Initialize the predefined names other than operators */
+ 	initial_enter_name("mark", &vmark);
+ 	initial_enter_name("null", &vnull);
+ 
+ 	/* Create other system-known names */
+ 	name_enter("errordict", &name_errordict);
+ 	name_enter("ErrorNames", &name_ErrorNames);
+ }
+ 
+ /* Initialize the operators */
+ void
+ op_init()
+ {
+ #define do_init(proc)\
+  { extern void proc(); proc(); }
+ 	/* Non-graphics-related operators */
+ 	do_init(zarith_op_init);
+ 	do_init(zarray_op_init);
+ 	do_init(zcontrol_op_init);
+ 	do_init(zdict_op_init);
+ 	do_init(zfile_op_init);
+ 	do_init(zgeneric_op_init);
+ 	do_init(zmath_op_init);
+ 	do_init(zmisc_op_init);
+ 	do_init(zpacked_op_init);
+ 	do_init(zrelbit_op_init);
+ 	do_init(zstack_op_init);
+ 	do_init(zstring_op_init);
+ 	do_init(ztype_op_init);
+ 	do_init(zvmem_op_init);
+ 	/* Graphics-related operators */
+ 	do_init(zchar_op_init);
+ 	do_init(zcolor_op_init);
+ 	do_init(zdevice_op_init);
+ 	do_init(zfont_op_init);
+ 	do_init(zgstate_op_init);
+ 	do_init(zht_op_init);
+ 	do_init(zmatrix_op_init);
+ 	do_init(zpaint_op_init);
+ 	do_init(zpath_op_init);
+ 	do_init(zpath2_op_init);
+ }
+ /* This routine is called by the individual zxxx_op_init routines. */
+ void
+ z_op_init(op_def *op_table)
+ {	op_def *def = op_table;
+ 	while ( def->name )
+ 		initial_enter_op(def->name, def->proc),
+ 		def++;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iname.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iname.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iname.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,154 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* iname.c */
+ /* Name lookup for Ghostscript interpreter */
+ #include "memory_.h"
+ #include "ghost.h"
+ #include "alloc.h"
+ #include "errors.h"
+ #include "name.h"
+ #include "store.h"
+ 
+ /* Definitions and structure for the name table. */
+ /* 1-character names are the first nt_1char_size entries. */
+ #define nt_log2_sub_size 7
+ #define nt_sub_size (1 << nt_log2_sub_size)
+ #define nt_hash_size 256		/* must be a power of 2 */
+ #define nt_1char_size 256		/* must cover a full byte */
+ typedef name name_sub_table[nt_sub_size];
+ typedef struct {
+ 	name *hash[nt_hash_size];
+ 	name *table[1 << (16 - nt_log2_sub_size)];	/* name_sub_table */
+ 	uint count;
+ } name_table;
+ #define name_index_ptr(nt, index)\
+   ((nt)->table[(index) >> nt_log2_sub_size] + ((index) & (nt_sub_size - 1)))
+ 
+ /* The one and only name table (for now). */
+ private name_table *the_nt;
+ 
+ /* Forward references */
+ private int name_alloc_sub(P1(name_table *));
+ 
+ /* Make a t_name ref out of a name * */
+ #define make_name(pref, pnm) make_tv(pref, t_name, pname, pnm)
+ 
+ /* Initialize the name table */
+ void
+ name_init()
+ {	uint i;
+ 	the_nt = (name_table *)alloc(1, sizeof(name_table), "name_init");
+ 	memset(the_nt, 0, sizeof(name_table));
+ 	for ( i = 0; i < nt_1char_size; i += nt_sub_size )
+ 	   {	the_nt->count = i;
+ 		name_alloc_sub(the_nt);
+ 	   }
+ }
+ 
+ /* Look up or enter a name in the table. */
+ /* Return 0 or an error code. */
+ /* The return may overlap the characters of the string! */
+ /* See name.h for the meaning of enterflag. */
+ int
+ name_ref(byte *ptr, uint isize, ref *pref, int enterflag)
+ {	register name **ppname;
+ 	register name *pname;
+ 	byte *cptr;
+ 	ushort size = (ushort)isize;	/* see name.h */
+ 	if ( size == 1 )
+ 	   {	pname = name_index_ptr(the_nt, *ptr);
+ 		if ( pname->string_size != 0 )
+ 		   {	make_name(pref, pname);
+ 			return 0;
+ 		   }
+ 		if ( enterflag < 0 ) return e_undefined;
+ 		pname->index = *ptr;
+ 	   }
+ 	else
+ 	   {	ushort hash = (ushort)string_hash(ptr, size);
+ 		ppname = the_nt->hash + (hash & (nt_hash_size - 1));
+ 		while ( (pname = *ppname) != 0 )
+ 		   {	if ( pname->string_size == size &&
+ 			     !memcmp(ptr, pname->string_bytes, size)
+ 			   )
+ 			   {	make_name(pref, pname);
+ 				return 0;
+ 			   }
+ 			ppname = &pname->next;
+ 		   }
+ 		/* Not in table, allocate a new entry. */
+ 		if ( enterflag < 0 ) return e_undefined;
+ 		if ( !(the_nt->count & (nt_sub_size - 1)) )
+ 		   {	int code = name_alloc_sub(the_nt);
+ 			if ( code < 0 ) return code;
+ 		   }
+ 		pname = name_index_ptr(the_nt, the_nt->count);
+ 		pname->index = the_nt->count++;
+ 		*ppname = pname;
+ 	   }
+ 	/* Name was not in the table.  Make a new entry. */
+ 	if ( enterflag )
+ 	   {	cptr = (byte *)alloc(size, 1, "name_ref(string)");
+ 		if ( cptr == 0 ) return e_VMerror;
+ 		memcpy(cptr, ptr, size);
+ 	   }
+ 	else
+ 		cptr = ptr;
+ 	pname->string_size = size;
+ 	pname->string_bytes = cptr;
+ 	pname->next = 0;
+ 	pname->pvalue = pv_no_defn;
+ 	make_name(pref, pname);
+ 	return 0;
+ }
+ 
+ /* Get the string for a name. */
+ void
+ name_string_ref(ref *pnref /* t_name */, ref *psref /* result, t_string */)
+ {	name *pname = pnref->value.pname;
+ 	make_tasv(psref, t_string, a_read+a_execute, pname->string_size,
+ 		  bytes, pname->string_bytes);
+ }
+ 
+ /* Enter a name during initialization. */
+ /* Fatal error if the entry fails. */
+ void
+ name_enter(char *str, ref *pref)
+ {	if ( name_ref((byte *)str, strlen(str), pref, 0) )
+ 		dprintf1("name_enter failed - %s", str), exit(1);
+ }
+ 
+ /* Get the name with a given index. */
+ void
+ name_index_ref(uint index, ref *pnref)
+ {	make_name(pnref, name_index_ptr(the_nt, index));
+ }
+ 
+ /* ------ Internal procedures ------ */
+ 
+ /* Allocate the next sub-table. */
+ private int
+ name_alloc_sub(name_table *nt)
+ {	name *sub = (name *)alloc(1, sizeof(name_sub_table), "name_alloc_sub");
+ 	if ( sub == 0 ) return e_VMerror;
+ 	memset(sub, 0, sizeof(name_sub_table));
+ 	nt->table[nt->count >> nt_log2_sub_size] = sub;
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/interp.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/interp.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/interp.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,530 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* interp.c */
+ /* GhostScript interpreter */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "name.h"
+ #include "dict.h"
+ #include "oper.h"
+ #include "store.h"
+ #include "sstorei.h"
+ #include "stream.h"
+ 
+ /* Forward references */
+ private int interp(P1(ref *pref));
+ private op_proc_(interp_exit);
+ 
+ /* Configuration parameters */
+ #define max_ostack 500
+ #define max_estack 150
+ #define max_dstack 20
+ 
+ /* See estack.h for a description of the execution stack. */
+ 
+ /* The logic for managing icount and iref below assumes that */
+ /* there are no control operators which pop and then push */
+ /* information on the execution stack. */
+ 
+ /* Stacks */
+ #define os_guard_under 10
+ #define os_guard_over 10
+ private ref ostack[os_guard_under+max_ostack+os_guard_over];
+ ref estack[max_estack];
+ ref dstack[max_dstack];
+ ref *osp_nargs[os_max_nargs];		/* for checking osp */
+ 
+ /* Stack pointers */
+ ref *osbot, *osp, *ostop;
+ ref *esp, *estop;
+ ref *dsp, *dstop;
+ 
+ /* The object that caused an error */
+ ref error_object;
+ 
+ /* Object related to error handling */
+ extern ref name_errordict;
+ extern ref name_ErrorNames;
+ 
+ /* Extended types.  The interpreter may replace the type of operators */
+ /* in procedures with these, to speed up the interpretation loop. */
+ #define tx_op t_next_index
+ extern int zadd(P1(ref *));
+ extern int zdup(P1(ref *));
+ extern int zexch(P1(ref *));
+ extern int zifelse(P1(ref *));
+ extern int zle(P1(ref *));
+ extern int zpop(P1(ref *));
+ extern int zsub(P1(ref *));
+ private op_proc_p special_ops[] = {
+ 	zadd, zdup, zexch, zifelse, zle, zpop, zsub
+ };
+ enum {
+ 	tx_op_add = tx_op,
+ 	tx_op_dup,
+ 	tx_op_exch,
+ 	tx_op_ifelse,
+ 	tx_op_le,
+ 	tx_op_pop,
+ 	tx_op_sub,
+ 	tx_next_op
+ };
+ #define num_special_ops ((int)tx_next_op - tx_op)
+ 
+ /* The following is a special "error" code that is used internally */
+ /* to cause the interpreter to exit. */
+ #define e_InterpreterExit (-100)
+ 
+ /* Initialize the interpreter */
+ void
+ interp_init(int ndict)
+ {	/* Initialize the guard entries on the operand stack */
+ 	/* with objects that have invalid type and attributes. */
+ 	osbot = ostack + os_guard_under;
+ 	osp = osbot - 1, ostop = osbot + (max_ostack-1);
+ 	   {	ref *op;
+ 		for ( op = ostack; op < osbot; op++ )
+ 			make_tav(op, -1, 0, index, 0);
+ 	   }
+ 	   {	int i;
+ 		for ( i = 1; i < os_max_nargs; i++ )
+ 			osp_nargs[i] = osbot + i - 1;
+ 	   }
+ 	esp = estack - 1, estop = estack + (max_estack-1);
+ 	/* Initialize the dictionary stack to the first ndict */
+ 	/* dictionaries.  ndict is a parameter because during */
+ 	/* initialization, only systemdict exists. */
+ 	dsp = dstack + ndict - 1, dstop = dstack + (max_dstack-1);
+ }
+ 
+ /* Look up an operator during initialization, */
+ /* changing its type if appropriate. */
+ void
+ interp_fix_op(ref *opref)
+ {	int i = num_special_ops;
+ 	op_proc_p proc = opref->value.opproc;
+ 	while ( --i >= 0 && proc != special_ops[i] ) ;
+ 	if ( i >= 0 ) make_tav(opref, tx_op + i, a_executable, opproc, proc);
+ }
+ 
+ /* Invoke the interpreter.  If execution completes normally, return 0. */
+ /* if an error occurs, then if user_errors is true and the error is a */
+ /* recoverable one (not an overflow condition), let the user handle it; */
+ /* otherwise, return the error code. */
+ int
+ interpret(ref *pref, int user_errors)
+ {	ref *epref = pref;
+ 	ref erref;
+ 	ref *perrordict, *pErrorNames;
+ 	int code;
+ 	/* Push a special exit procedure on the execution stack */
+ 	esp++;
+ 	make_tav(esp, t_operator, a_executable, opproc, interp_exit);
+ retry:	code = interp(epref);
+ 	if ( code == e_InterpreterExit ) return 0;
+ 	/* Adjust osp in case of operand stack underflow */
+ 	if ( osp < osbot - 1 )
+ 		osp = osbot - 1;
+ 	if ( !user_errors ) return code;
+ 	if ( dict_find(dstack, &name_errordict, &perrordict) <= 0 ||
+ 	     dict_find(perrordict, &name_ErrorNames, &pErrorNames) <= 0
+ 	   )
+ 		return code;		/* errordict or ErrorNames not found?? */
+ 	switch ( code )
+ 	   {
+ 	case e_dictstackoverflow:
+ 	case e_execstackoverflow:
+ 	case e_stackoverflow:
+ 	case e_VMerror:
+ 		return code;
+ 	   }
+ 	if ( code > -2 || -code > pErrorNames->size )
+ 		return code;		/* unknown error??? */
+ 	if ( dict_find(perrordict, &pErrorNames->value.refs[-code - 1], &epref) <= 0 )
+ 		return code;		/* error name not in errordict??? */
+ 	erref = *epref;
+ 	epref = &erref;
+ 	/* Push the error object on the operand stack */
+ 	*++osp = error_object;
+ 	goto retry;
+ }	
+ private int
+ interp_exit(ref *op)
+ {	return e_InterpreterExit;
+ }
+ 
+ /* Main interpreter. */
+ /* If execution terminates normally, return e_InterpreterExit. */
+ /* If an error occurs, leave the current object in error_object */
+ /* and return a (negative) error code. */
+ #define return_with_error(code, objp)\
+   { esp = iesp; error_object = *(objp); return code; }
+ private int
+ interp(ref *pref /* object to interpret */)
+ {	register ref *iref = pref;
+ 	register int icount = 0;	/* # of consecutive tokens at iref */
+ 	register ref *iosp = osp;	/* private copy of osp */
+ 	register ref *iesp = esp;	/* private copy of esp */
+ 	int code;
+ 	ref token;		/* token read from file or string, */
+ 				/* must be declared in this scope */
+ 	ref *ptoken = &token;		/* for s_store_i */
+ 	/* We want to recognize executable arrays here, */
+ 	/* so we push the argument on the estack and enter */
+ 	/* the loop at the bottom. */
+ 	if ( iesp >= estop ) return_with_error (e_execstackoverflow, pref);
+ 	*++iesp = *pref;
+ 	goto bot;
+ 	/* At this point, if icount > 0, iref and icount correspond */
+ 	/* to the top entry on the execution stack: icount is the */
+ 	/* count of sequential entries remaining AFTER the current one. */
+ #define store_state(ep)\
+   ( icount > 0 ? (ep->value.refs = iref + 1, ep->size = icount) : 0 )
+ #define next()\
+   if ( --icount > 0 ) { iref++; goto top; } else goto out
+ top:	/* This is the top of the interpreter cycle. */
+ 	/* iref points to the ref being interpreted. */
+ #ifdef DEBUG
+ if ( gs_debug['I'] || gs_debug['i'] && r_type(iref) == t_name )
+    {	void debug_print_ref(P1(ref *));
+ 	int edepth = iesp - estack;
+ 	char depth[10];
+ 	sprintf(depth, "%d", edepth);
+ 	printf(depth);
+ 	edepth -= strlen(depth);
+ 	do { putchar('.'); } while ( --edepth > 0 );	/* indent */
+ 	printf("%lx(%d)[%d]: ", (ulong)iref, icount, (uint)(iosp - osbot + 1));
+ 	debug_print_ref(iref);
+ 	if ( iosp >= osbot )
+ 	   {	printf(" // ");
+ 		debug_print_ref(iosp);
+ 	   }
+ 	printf("\n");
+ 	fflush(stdout);
+    }
+ #endif
+ /* Object that have attributes (arrays, dictionaries, files, and strings) */
+ /* use lit and exec; other objects use plain and plain_exec. */
+ #define lit(t) (((t) << 2) + a_execute)
+ #define exec(t) (((t) << 2) + a_execute + a_executable)
+ #define nox(t) ((t) << 2)
+ #define nox_exec(t) (((t) << 2) + a_executable)
+ #define plain(t) ((t) << 2)
+ #define plain_exec(t) (((t) << 2) + a_executable)
+ sw:	/* We have to populate enough cases of the switch statement */
+ 	/* to force the compiler to use a dispatch rather than */
+ 	/* a testing loop.  What a nuisance! */
+ 	switch ( r_type_xe(iref) )
+ 	   {
+ 	/* Access errors. */
+ 	case nox(t_array): case nox_exec(t_array):
+ 	case nox(t_dictionary): case nox_exec(t_dictionary):
+ 	case nox(t_file): case nox_exec(t_file):
+ 	case nox(t_packedarray): case nox_exec(t_packedarray):
+ 	case nox(t_string): case nox_exec(t_string):
+ 		return_with_error (e_invalidaccess, iref);
+ 	/* Literal objects.  We have to enumerate all the types. */
+ 	/* In fact, we have to include some extra plain_exec entries */
+ 	/* just to populate the switch. */
+ 	case lit(t_array):
+ 	case plain(t_boolean): case plain_exec(t_boolean):
+ 	case lit(t_dictionary):
+ 	case lit(t_file):
+ 	case plain(t_fontID): case plain_exec(t_fontID):
+ 	case plain(t_integer): case plain_exec(t_integer):
+ 	case plain(t_mark): case plain_exec(t_mark):
+ 	case plain(t_name):
+ 	case plain(t_null):
+ 	case plain(t_operator):
+ 	case lit(t_packedarray):
+ 	case plain(t_real): case plain_exec(t_real):
+ 	case plain(t_save): case plain_exec(t_save):
+ 	case lit(t_string):
+ 	case plain(t_color): case plain_exec(t_color):
+ 	case plain(t_device): case plain_exec(t_device):
+ 		break;
+ 	/* Special operators. */
+ 	case plain_exec(tx_op_add):
+ 		if ( (code = zadd(iosp)) < 0 )
+ 			return_with_error (code, iref);
+ 		iosp--;
+ 		next();
+ 	case plain_exec(tx_op_dup):
+ 		if ( iosp < osp_nargs[1] )
+ 			return_with_error (e_stackunderflow, iref);
+ 		iosp++;
+ 		s_store_r(iosp, 0, -1);
+ 		next();
+ 	case plain_exec(tx_op_exch):
+ 		if ( iosp < osp_nargs[2] )
+ 			return_with_error (e_stackunderflow, iref);
+ 		s_store_i(ptoken, iosp);
+ 		s_store_r(iosp, 0, -1);
+ 		s_store_b(iosp, -1, ptoken, 0);
+ 		next();
+ 	case plain_exec(tx_op_ifelse):
+ 		if ( r_type(iosp - 2) != t_boolean )
+ 			return_with_error (e_typecheck, iref);
+ 		if ( iesp >= estop )
+ 			return_with_error (e_execstackoverflow, iref);
+ 		store_state(iesp);
+ 		iosp -= 3;
+ 		/* Open code "up" for the array case(s) */
+ 		   {	ref *whichp =
+ 			  (iosp[1].value.index ? iosp + 2 : iosp + 3);
+ 			switch( r_type_xe(whichp) )
+ 			   {
+ 			default:
+ 				s_store_b(iesp, 1, whichp, 0);
+ 				iref = iesp + 1;
+ 				icount = 0;
+ 				goto top;
+ 			case exec(t_array): ;
+ 			case exec(t_packedarray): ;
+ 			   }
+ 			iref = whichp->value.refs;
+ 			icount = whichp->size;
+ 			if ( --icount <= 0 )	/* <= 1 more elements */
+ 			   {	if ( icount < 0 ) goto up;
+ 			   }
+ 			else
+ 			   {	iesp++;
+ 				s_store_i(iesp, whichp);
+ 			   }
+ 		   }
+ 		goto top;
+ 	case plain_exec(tx_op_le):
+ 		code = obj_compare(iosp, 2+1);
+ 		if ( code < 0 )
+ 			return_with_error (code, iref);
+ 		iosp--;
+ 		make_bool(iosp, code);
+ 		next();
+ 	case plain_exec(tx_op_pop):
+ 		if ( iosp < osp_nargs[1] )
+ 			return_with_error (e_stackunderflow, iref);
+ 		iosp--;
+ 		next();
+ 	case plain_exec(tx_op_sub):
+ 		if ( (code = zsub(iosp)) < 0 )
+ 			return_with_error (code, iref);
+ 		iosp--;
+ 		next();
+ 	/* Executable types. */
+ 	case plain_exec(t_null):
+ 		goto bot;
+ 	case plain_exec(t_operator):
+ 	   {	esp = iesp;		/* save for operator */
+ 		osp = iosp;		/* ditto */
+ 		/* Operator routines take osp as an argument. */
+ 		/* This is just a convenience, since they adjust */
+ 		/* osp themselves to reflect the results. */
+ 		/* Operators that (net) push information on the */
+ 		/* operand stack must check for overflow: */
+ 		/* this normally happens automatically through */
+ 		/* the push macro (in oper.h). */
+ 		/* Operators that do not typecheck their operands */
+ 		/* must check explicitly for stack underflow. */
+ 		code = (*iref->value.opproc)(iosp);
+ 		iosp = osp;
+ 		if ( code != 0 )
+ 		   {	/* This might be a control operator that changed */
+ 			/* esp.  Check for this specially. */
+ 			switch ( code )
+ 			   {
+ 			case o_check_estack:
+ 				/* If a control operator popped the estack, */
+ 				/* we just go to up.  If a control operator */
+ 				/* pushed something on the estack, we store */
+ 				/* the state and then go to up.  Otherwise, */
+ 				/* we can just go on. */
+ 				if ( esp > iesp ) store_state(iesp);
+ 				else if ( esp == iesp ) goto bot;
+ 				iesp = esp;
+ 				goto up;
+ 			case e_typecheck:
+ 				/* This might be an operand stack */
+ 				/* underflow: check the required # of */
+ 				/* operands now. */
+ 				if ( iosp < osbot - 1 + iref->size )
+ 					code = e_stackunderflow;
+ 				/* (falls through) */
+ 			default:
+ 				return_with_error (code, iref);
+ 			   }
+ 		   }
+ 		next();			/* just go on */
+ 	   }
+ 	case plain_exec(t_name):
+ 	   {	register ref *pvalue = iref->value.pname->pvalue;
+ 		if ( !pv_valid(pvalue) )
+ 		   {	ref *pdvalue;
+ 			if ( dict_lookup(dstack, dsp, iref, &pdvalue) <= 0 )
+ 				return_with_error (e_undefined, iref);
+ 			pvalue = pdvalue;
+ 		   }
+ 		switch ( r_type_xe(pvalue) )
+ 		   {
+ 		case exec(t_array):
+ 		case exec(t_packedarray):
+ 			/* This is an executable procedure, */
+ 			/* execute it. */
+ 			/* Save the current state on the e-stack */
+ 			store_state(iesp);
+ 			/* Push the array on the e-stack */
+ 			if ( iesp >= estop )
+ 				return_with_error (e_execstackoverflow, pvalue);
+ 			++iesp;
+ 			s_store_i(iesp, pvalue);
+ 			iref = pvalue->value.refs;
+ 			icount = pvalue->size - 1;
+ 			if ( icount <= 0 )
+ 			   {	if ( icount < 0 ) goto up;	/* empty procedure */
+ 				iesp--;		/* tail recursion */
+ 			   }
+ 			goto top;
+ 		case plain_exec(t_operator):
+ 		   {	/* Shortcut for operators. */
+ 			/* See above for the logic. */
+ 			esp = iesp;
+ 			osp = iosp;
+ 			code = (*pvalue->value.opproc)(iosp);
+ 			iosp = osp;
+ 			if ( code != 0 )
+ 			   {	switch ( code )
+ 				   {
+ 				case o_check_estack:
+ 				   {	if ( esp > iesp )
+ 					  store_state(iesp);
+ 					else if ( esp == iesp )
+ 					  goto bot;
+ 					iesp = esp;
+ 					goto up;
+ 				   }
+ 				case e_typecheck:
+ 					if ( iosp < osbot - 1 + pvalue->size )
+ 					  code = e_stackunderflow;
+ 				   }
+ 				return_with_error (code, pvalue);
+ 			   }
+ 			next();
+ 		   }
+ 		case lit(t_array):
+ 		case plain(t_boolean):
+ 		case plain(t_integer):
+ 		case lit(t_packedarray):
+ 		case plain(t_real):
+ 		case lit(t_string):
+ 			/* Just push the value */
+ 			if ( iosp >= ostop )
+ 				return_with_error (e_stackoverflow, pvalue);
+ 			++iosp;
+ 			s_store_i(iosp, pvalue);
+ 			next();
+ 		default:		/* handles other literals */
+ 			/* Not a procedure, reinterpret it. */
+ 			store_state(iesp);
+ 			icount = 0;
+ 			iref = pvalue;
+ 			goto top;
+ 		   }
+ 	   }
+ 	case exec(t_file):
+ 	   {	/* Executable file.  Read the next token and interpret it. */
+ 	   	stream *s;
+ 		code = file_check_read(iref, &s);
+ 		if ( code < 0 ) return_with_error (code, iref);
+ 		osp = iosp;		/* scan_token uses ostack */
+ 		switch ( code = scan_token(s, 0, &token) )
+ 		   {
+ 		case 0:			/* read a token */
+ 			store_state(iesp);
+ 			/* Push the file on the e-stack */
+ 			if ( iesp >= estop )
+ 				return_with_error (e_execstackoverflow, iref);
+ 			*++iesp = *iref;
+ 			iref = &token;
+ 			icount = 0;
+ 			goto top;
+ 		case 1:			/* end of file */
+ 			code = file_close(iref, s);
+ 			if ( code < 0 ) return_with_error (code, iref);
+ 			goto bot;
+ 		default:		/* error */
+ 			return_with_error (code, iref);
+ 		   }
+ 	   }
+ 	case exec(t_string):
+ 	   {	/* Executable string.  Read a token and interpret it. */
+ 		stream ss;
+ 		sread_string(&ss, iref->value.bytes, iref->size);
+ 		osp = iosp;		/* scan_token uses ostack */
+ 		switch ( code = scan_token(&ss, 1, &token) )
+ 		  {
+ 		case 0:			/* read a token */
+ 		    store_state(iesp);
+ 		    /* Push the updated string back on the e-stack */
+ 		    if ( iesp >= estop )
+ 		      return_with_error (e_execstackoverflow, iref);
+ 		    ++iesp;
+ 		    iesp->type_attrs = iref->type_attrs;
+ 		    iesp->value.bytes = ss.cptr + 1;
+ 		    iesp->size = ss.cbuf + ss.bsize - ss.cptr - 1;
+ 		    iref = &token;
+ 		    icount = 0;
+ 		    goto top;
+ 		case 1:			/* end of string */
+ 		    goto bot;
+ 		default:		/* error */
+ 		    return_with_error (code, iref);
+ 		  }
+ 	   }
+ 	   }
+ 	/* Literal type, just push it. */
+ 	if ( iosp >= ostop ) return_with_error (e_stackoverflow, iref);
+ 	++iosp;
+ 	s_store_i(iosp, iref);
+ bot:	next();
+ out:	/* At most 1 more token in the current procedure. */
+ 	/* (We already decremented icount.) */
+ 	if ( !icount )
+ 	   {	/* Pop the execution stack for tail recursion. */
+ 		iesp--;
+ 		iref++;
+ 		goto top;
+ 	   }
+ up:	/* See if there is anything left on the execution stack. */
+ 	switch ( r_type_xe(iesp) )
+ 	   {
+ 	default:
+ 		iref = iesp--;
+ 		icount = 0;
+ 		goto top;
+ 	case exec(t_array): ;
+ 	case exec(t_packedarray): ;
+ 	   }
+ 	iref = iesp->value.refs;		/* next element of array */
+ 	icount = iesp->size - 1;
+ 	if ( icount <= 0 )		/* <= 1 more elements */
+ 	   {	iesp--;			/* pop, or tail recursion */
+ 		if ( icount < 0 ) goto up;
+ 	   }
+ 	goto top;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iscan.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iscan.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iscan.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,707 ----
+ /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* iscan.c */
+ /* Token scanner for Ghostscript interpreter */
+ #include <ctype.h>
+ #include "memory_.h"
+ #include "ghost.h"
+ #include "arch.h"
+ #include "alloc.h"
+ #include "dict.h"			/* for //name lookup */
+ #include "errors.h"
+ #include "name.h"
+ #include "store.h"
+ #include "stream.h"
+ #include "scanchar.h"
+ 
+ /* Array packing flag */
+ int array_packing;
+ 
+ /* Forward references */
+ private	int	scan_hex_string(P2(stream *, ref *)),
+ 		scan_int(P4(stream *, int, long *, double *)),
+ 		scan_string(P3(stream *, int, ref *));
+ 
+ /* Import the dictionary stack for //name lookup */
+ extern ref dstack[];
+ extern ref *dsp;
+ 
+ /* Import the operand stack for accumulating procedure bodies */
+ extern ref *osp, *ostop;
+ 
+ /* Static constants */
+ private ref left_bracket;
+ private ref right_bracket;
+ private ref empty_name;
+ 
+ /* Define the character scanning table (see scanchar.h). */
+ byte scan_char_array[257];
+ 
+ /* A structure for dynamically growable objects */
+ typedef struct dynamic_area_s {
+ 	byte *base;
+ 	byte *next;
+ 	uint num_elts;
+ 	uint elt_size;
+ 	int is_dynamic;			/* false if using fixed buffer */
+ 	byte *limit;
+ } dynamic_area;
+ 
+ /* Begin a dynamic object. */
+ /* dynamic_begin returns the value of alloc_dynamic, which may be 0: */
+ /* the invoker of dynamic_begin must test the value against 0. */
+ #define dynamic_begin(pda, dnum, desize)\
+ 	((pda)->base = alloc_dynamic((pda)->num_elts = (dnum),\
+ 				     (pda)->elt_size = (desize), "scanner"),\
+ 	 (pda)->limit = (pda)->base + (dnum) * (desize),\
+ 	 (pda)->is_dynamic = 1,\
+ 	 (pda)->next = (pda)->base)
+ 
+ /* Grow a dynamic object */
+ private int
+ dynamic_grow(register dynamic_area *pda)
+ {	uint num = pda->num_elts;
+ 	uint size = num * pda->elt_size;
+ 	uint new_num;
+ 	uint pos = pda->next - pda->base;
+ 	size = (size < 10 ? 20 : size >= (max_uint >> 1) ? max_uint : size << 1);
+ 	new_num = size / pda->elt_size;
+ 	if ( pda->is_dynamic )
+ 	   {	pda->base = alloc_grow(pda->base, num, new_num, pda->elt_size, "scanner");
+ 		if ( pda->base == 0 ) return 0;
+ 		pda->num_elts = new_num;
+ 		pda->limit = pda->base + size;
+ 	   }
+ 	else
+ 	   {	byte *base = pda->base;
+ 		uint old_size = size;
+ 		if ( !dynamic_begin(pda, new_num, pda->elt_size) ) return 0;
+ 		memcpy(pda->base, base, old_size);
+ 		pda->is_dynamic = 1;
+ 	   }
+ 	pda->next = pda->base + pos;
+ 	return 1;
+ }
+ 
+ /* Get rid of an unwanted dynamic object */
+ #define dynamic_free(pda)\
+   if ( (pda)->is_dynamic )\
+     alloc_free((char *)((pda)->base), (pda)->num_elts, (pda)->elt_size, "scanner")
+ 
+ /* Initialize the scanner. */
+ void
+ scan_init()
+ {	register byte *decoder = scan_char_decoder;
+ 	/* Precompute left and right bracket and empty name tokens */
+ 	   {	name_ref((byte *)"[", 1, &left_bracket, 0);
+ 		name_ref((byte *)"]", 1, &right_bracket, 0);
+ 		name_ref((byte *)"", 0, &empty_name, 0);
+ 	   }
+ 	/* Initialize decoder array */
+ 	   {	static char stop_chars[] = "()<>[]{}/%";
+ 		static char space_chars[] = " \f\t\n\r";
+ 		register int i;
+ 		char *p;
+ 		decoder[-1] = ctype_eof;
+ 		memset(decoder, ctype_name, 256);
+ 		for ( p = space_chars; *p; p++ )
+ 		  decoder[*p] = ctype_space;
+ 		decoder[char_NULL] = decoder[char_VT] =
+ 		  decoder[char_DOS_EOF] = ctype_space;
+ 		for ( p = stop_chars; *p; p++ )
+ 		  decoder[*p] = ctype_other;
+ 		for ( i = 0; i < 10; i++ )
+ 			decoder['0' + i] = i;
+ 		for ( i = 0; i < max_radix - 10; i++ )
+ 			decoder['A' + i] = decoder['a' + i] = i + 10;
+ 	   }
+ 	array_packing = 0;
+ }
+ 
+ /* Read a token from a stream. */
+ /* Return 1 for end-of-stream, 0 if a token was read, */
+ /* or a (negative) error code. */
+ /* If the token required a terminating character (i.e., was a name or */
+ /* number) and the next character was whitespace, read and discard */
+ /* that character: see the description of the 'token' operator on */
+ /* p. 232 of the Red Book. */
+ /* from_string indicates reading from a string vs. a file, */
+ /* because \ escapes are not recognized in the former case. */
+ /* (See the footnote on p. 23 of the Red Book.) */
+ int
+ scan_token(register stream *s, int from_string, ref *pref)
+ {	ref *myref = pref;
+ 	dynamic_area proc_da;
+ 	int pstack = 0;		/* offset from proc_da.base */
+ 	int retcode = 0;
+ 	register int c;
+ 	int name_type;			/* number of /'s preceding */
+ 	int try_number;
+ 	register byte *decoder = scan_char_decoder;
+ 	/******
+ 	 ****** Newer P*stScr*pt interpreters don't use from_string.
+ 	 ******/
+ 	from_string = 0;
+ top:	c = sgetc(s);
+ #ifdef DEBUG
+ if ( gs_debug['s'] )
+ 	printf((c >= 32 && c <= 126 ? "`%c'" : "`%03o'"), c);
+ #endif
+ 	switch ( c )
+ 	   {
+ 	case ' ': case '\f': case '\t': case '\n': case '\r':
+ 	case char_NULL: case char_VT: case char_DOS_EOF:
+ 		goto top;
+ 	case '[':
+ 		*myref = left_bracket;
+ 		r_set_attrs(myref, a_executable);
+ 		break;
+ 	case ']':
+ 		*myref = right_bracket;
+ 		r_set_attrs(myref, a_executable);
+ 		break;
+ 	case '<':
+ 		retcode = scan_hex_string(s, myref);
+ 		break;
+ 	case '(':
+ 		retcode = scan_string(s, from_string, myref);
+ 		break;
+ 	case '{':
+ 		if ( pstack == 0 )
+ 		   {	/* Use the operand stack to accumulate procedures. */
+ 			myref = osp + 1;
+ 			proc_da.base = (byte *)myref;
+ 			proc_da.limit = (byte *)(ostop + 1);
+ 			proc_da.is_dynamic = 0;
+ 			proc_da.elt_size = sizeof(ref);
+ 			proc_da.num_elts = ostop - osp;
+ 		   }
+ 		if ( proc_da.limit - (byte *)myref < 2 * sizeof(ref) )
+ 		   {	proc_da.next = (byte *)myref;
+ 			if ( !dynamic_grow(&proc_da) )
+ 			  return e_VMerror;
+ 			myref = (ref *)proc_da.next;
+ 		   }
+ 		myref->size = pstack;
+ 		myref++;
+ 		pstack = (byte *)myref - proc_da.base;
+ 		goto top;
+ 	case '>':
+ 	case ')':
+ 		retcode = e_syntaxerror;
+ 		break;
+ 	case '}':
+ 		if ( pstack == 0 )
+ 		   {	retcode = e_syntaxerror;
+ 			break;	
+ 		   }
+ 		   {	ref *ref0 = (ref *)(proc_da.base + pstack);
+ 			uint size = myref - ref0;
+ 			ref *aref;
+ 			myref = ref0 - 1;
+ 			pstack = myref->size;
+ 			if ( pstack == 0 && proc_da.is_dynamic )
+ 			   {	/* Top-level procedure, shrink in place. */
+ 				memcpy(myref, ref0, size * sizeof(ref));
+ 				aref = (ref *)alloc_shrink((byte *)myref, proc_da.num_elts, size, sizeof(ref), "scanner(top proc)");
+ 				if ( aref == 0 ) return e_VMerror;
+ 				myref = pref;
+ 			   }
+ 			else
+ 			   {	/* Not top-level, or in ostack: copy it. */
+ 				aref = (ref *)alloc(size, sizeof(ref), "scanner(proc)");
+ 				if ( aref == 0 ) return e_VMerror;
+ 				memcpy(aref, ref0, size * sizeof(ref));
+ 				if ( pstack == 0 ) myref = pref;
+ 			   }
+ 			if ( array_packing )
+ 				make_tasv(myref, t_packedarray, a_executable + a_read + a_execute, size, refs, aref);
+ 			else
+ 				make_tasv(myref, t_array, a_executable + a_all, size, refs, aref);
+ 		   }
+ 		break;
+ 	case '/':
+ 		c = sgetc(s);
+ 		if ( c == '/' )
+ 		   {	name_type = 2;
+ 			c = sgetc(s);
+ 		   }
+ 		else
+ 			name_type = 1;
+ 		try_number = 0;
+ 		switch ( decoder[c] )
+ 		   {
+ 		case ctype_name:
+ 		default:
+ 			goto do_name;
+ 		case ctype_eof:
+ 			/* Empty name: bizarre but legitimate. */
+ 			*myref = empty_name;
+ 			goto have_name;
+ 		case ctype_other:
+ 			switch ( c )
+ 			   {
+ 			case '[':	/* only special as first character */
+ 				*myref = left_bracket;
+ 				goto have_name;
+ 			case ']':	/* ditto */
+ 				*myref = right_bracket;
+ 				goto have_name;
+ 			default:
+ 				/* Empty name: bizarre but legitimate. */
+ 				*myref = empty_name;
+ 				sputback(s);
+ 				goto have_name;
+ 			   }
+ 		case ctype_space:
+ 			/* Empty name: bizarre but legitimate. */
+ 			*myref = empty_name;
+ 			/* Check for \r\n */
+ 			if ( c == '\r' && (c = sgetc(s)) != '\n' && c != EOFC )
+ 				sputback(s);
+ 			goto have_name;
+ 		   }
+ 		/* NOTREACHED */
+ 	case '%':
+ 	   {	int c1;
+ 		do { c = sgetc(s); }
+ 		while ( c != '\f' && c != '\n' && c != '\r' && c != EOFC );
+ 		if ( c == '\r' && (c1 = sgetc(s)) != '\n' && c1 != EOFC )
+ 			sputback(s);
+ 		if ( c != EOFC ) goto top;
+ 	   }	/* falls through */
+ 	case EOFC:
+ 		retcode = (pstack != 0 ? e_syntaxerror : 1);
+ 		break;
+ 	/* Handle separately the names that might be a number */
+ 	case '0': case '1': case '2': case '3': case '4':
+ 	case '5': case '6': case '7': case '8': case '9':
+ 	case '.': case '+': case '-':
+ 		try_number = 1;
+ 		name_type = 0;
+ 		goto do_name;
+ 	/* Check for a binary object */
+ 	default:			/* ****** NYI ****** */
+ 	/* Handle the common cases (letters and _) explicitly, */
+ 	/* rather than going through the default test. */
+ 	case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ 	case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm':
+ 	case 'n': case 'o': case 'p': case 'q': case 'r': case 's':
+ 	case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
+ 	case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ 	case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M':
+ 	case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S':
+ 	case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
+ 	case '_':
+ 		try_number = 0;
+ 		name_type = 0;
+ 		/* Common code for scanning a name. */
+ 		/* try_number and name_type are already set. */
+ 		/* We know c has ctype_name or is a digit. */
+ do_name:
+ 	   {	dynamic_area da;
+ 		/* Try to scan entirely within the stream buffer. */
+ 		/* We stop 1 character early, so we don't switch buffers */
+ 		/* looking ahead if the name is terminated by \r\n. */
+ 		register byte *ptr = sbufptr(s);
+ 		byte *end = sbufend(s) - 1;
+ 		da.base = ptr - 1;
+ 		da.is_dynamic = 0;
+ 		do
+ 		   {	if ( ptr >= end )
+ 			   {	ssetbufptr(s, ptr);
+ 				/* Initialize the dynamic area. */
+ 				/* We have to do this before the next */
+ 				/* sgetc, which will overwrite the buffer. */
+ 				da.next = da.limit = ptr;
+ 				da.num_elts = ptr - da.base;
+ 				da.elt_size = 1;
+ 				if ( !dynamic_grow(&da) ) return e_VMerror;
+ 				ptr = da.next;
+ 				goto dyn_name;
+ 			   }
+ 			c = *ptr++;
+ 		   }
+ 		while ( decoder[c] <= ctype_name );	/* digit or name */
+ 		/* Name ended within the buffer. */
+ 		ssetbufptr(s, ptr);
+ 		ptr--;
+ 		goto nx;
+ 		/* Name overran buffer. */
+ dyn_name:	while ( decoder[c = sgetc(s)] <= ctype_name )
+ 		  {	if ( ptr == da.limit )
+ 			   {	da.next = ptr;
+ 				if ( !dynamic_grow(&da) )
+ 				  return e_VMerror;
+ 				ptr = da.next;
+ 			   }
+ 			*ptr++ = c;
+ 		   }
+ nx:		switch ( decoder[c] )
+ 		  {
+ 		  case ctype_other:
+ 			sputback(s);
+ 		  case ctype_space:
+ 			/* Check for \r\n */
+ 			if ( c == '\r' && (c = sgetc(s)) != '\n' && c != EOFC )
+ 				sputback(s);
+ 		  case ctype_eof: ;
+ 		  }
+ 		/* Check for a number */
+ 		if ( try_number )
+ 		   {	stream nst;
+ 			stream *ns = &nst;
+ 			sread_string(ns, da.base, (uint)(ptr - da.base));
+ 			retcode = scan_number(ns, myref);
+ 			if ( retcode != e_syntaxerror )
+ 			   {	dynamic_free(&da);
+ 				goto have_name;	/* might be e_limitcheck */
+ 			   }
+ 		   }
+ 		retcode = name_ref(da.base, (uint)(ptr - da.base), myref, 1);
+ 		dynamic_free(&da);
+ 	   }
+ 		/* Done scanning.  Check for preceding /'s. */
+ have_name:	if ( retcode < 0 ) return retcode;
+ 		switch ( name_type )
+ 		   {
+ 		case 0:			/* ordinary executable name */
+ 			if ( r_type(myref) == t_name )	/* i.e., not a number */
+ 			  r_set_attrs(myref, a_executable);
+ 		case 1:			/* quoted name */
+ 			break;
+ 		case 2:			/* immediate lookup */
+ 		   {	ref *pvalue;
+ 			if ( dict_lookup(dstack, dsp, myref, &pvalue) <= 0 )
+ 				return e_undefined;
+ 			store(myref, *pvalue);
+ 		   }
+ 		   }
+ 	   }
+ 	/* If we are the top level, return the object, otherwise keep going */
+ 	if ( pstack == 0 || retcode < 0 )
+ 	  return retcode;
+ 	if ( proc_da.limit - (byte *)myref < 2 * sizeof(ref) )
+ 	   {	proc_da.next = (byte *)myref;
+ 		if ( !dynamic_grow(&proc_da) )
+ 		  return e_VMerror;		/* out of room */
+ 		myref = (ref *)proc_da.next;
+ 	   }
+ 	myref++;
+ 	goto top;
+ }
+ 
+ /* The internal scanning procedures return 0 on success, */
+ /* or a (negative) error code on failure. */
+ 
+ /* Procedure to scan a number.  This is also called by cvi and cvr. */
+ int
+ scan_number(register stream *s, ref *pref)
+ {	/* Powers of 10 up to 6 can be represented accurately as */
+ 	/* a single-precision float. */
+ #define num_powers_10 6
+ 	static float powers_10[num_powers_10+1] =
+ 	   {	1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6	};
+ 	int sign = 0;
+ 	long ival;
+ 	double dval;
+ 	int exp10 = 0;
+ 	int code;
+ 	register int c;
+ 	switch ( c = sgetc(s) )
+ 	   {
+ 	case '+': sign = 1; c = sgetc(s); break;
+ 	case '-': sign = -1; c = sgetc(s); break;
+ 	   }
+ 	if ( !isdigit(c) )
+ 	   {	if ( c != '.' ) return e_syntaxerror;
+ 		c = sgetc(s);
+ 		if ( !isdigit(c) ) return e_syntaxerror;
+ 		ival = 0;
+ 		goto fi;
+ 	   }
+ 	sputback(s);
+ 	if ( (code = scan_int(s, 10, &ival, &dval)) != 0 )
+ 	   {	if ( code < 0 ) return code;	/* e_syntaxerror */
+ 		/* Code == 1, i.e., the integer overflowed. */
+ 		switch ( c = sgetc(s) )
+ 		   {
+ 		default: return e_syntaxerror;	/* not terminated properly */
+ 		case '.': c = sgetc(s); goto fd;
+ 		case EOFC:		/* return a float */
+ 			make_real(pref, (float)(sign < 0 ? -dval : dval));
+ 			return 0;
+ 		   }
+ 	   }
+ 	switch ( c = sgetc(s) )
+ 	   {
+ 	default: return e_syntaxerror;	/* not terminated properly */
+ 	case '.': c = sgetc(s); goto fi;
+ 	case '#':
+ 		if ( sign || ival < min_radix || ival > max_radix )
+ 			return e_syntaxerror;
+ 		code = scan_int(s, (int)ival, &ival, NULL);
+ 		if ( code ) return code;
+ 		if ( sgetc(s) != EOFC ) return e_syntaxerror;
+ 	case EOFC: ;
+ 	   }
+ 	/* Return an integer */
+ 	make_int(pref, (sign < 0 ? -ival : ival));
+ 	return 0;
+ 	/* Handle a real.  We just saw the decimal point. */
+ 	/* Enter here if we are still accumulating an integer in ival. */
+ fi:	while ( isdigit(c) )
+ 	   {	/* Check for overflowing ival */
+ 		if ( ival >= (max_ulong >> 1) / 10 - 1 )
+ 		   {	dval = ival;
+ 			goto fd;
+ 		   }
+ 		ival = ival * 10 + (c - '0');
+ 		c = sgetc(s);
+ 		exp10--;
+ 	   }
+ 	if ( sign < 0 ) ival = -ival;
+ 	/* Take a shortcut for the common case */
+ 	if ( !(c == 'e' || c == 'E' || exp10 < -num_powers_10) )
+ 	   {	make_real(pref, (float)(ival / powers_10[-exp10]));
+ 		return 0;
+ 	   }
+ 	dval = ival;
+ 	goto fe;
+ 	/* Now we are accumulating a double in dval. */
+ fd:	while ( isdigit(c) )
+ 	   {	dval = dval * 10 + (c - '0');
+ 		c = sgetc(s);
+ 		exp10--;
+ 	   }
+ 	if ( sign < 0 ) dval = -dval;
+ fe:	/* dval contains the value, negated if necessary */
+ 	if ( c == 'e' || c == 'E' )
+ 	   {	/* Check for a following exponent. */
+ 		int esign = 0;
+ 		long eexp;
+ 		switch ( c = sgetc(s) )
+ 		   {
+ 		case '+': break;
+ 		case '-': esign = 1; break;
+ 		default: sputback(s);
+ 		   }
+ 		code = scan_int(s, 10, &eexp, NULL);
+ 		if ( code < 0 ) return code;
+ 		if ( code > 0 || eexp > 999 )
+ 			return e_limitcheck;	/* semi-arbitrary */
+ 		if ( esign )
+ 			exp10 -= (int)eexp;
+ 		else
+ 			exp10 += (int)eexp;
+ 		c = sgetc(s);
+ 	   }
+ 	if ( c != EOFC ) return e_syntaxerror;
+ 	/* Compute dval * 10^exp10. */
+ 	if ( exp10 > 0 )
+ 	   {	while ( exp10 > num_powers_10 )
+ 			dval *= powers_10[num_powers_10],
+ 			exp10 -= num_powers_10;
+ 		if ( exp10 > 0 )
+ 			dval *= powers_10[exp10];
+ 	   }
+ 	else if ( exp10 < 0 )
+ 	   {	while ( exp10 < -num_powers_10 )
+ 			dval /= powers_10[num_powers_10],
+ 			exp10 += num_powers_10;
+ 		if ( exp10 < 0 )
+ 			dval /= powers_10[-exp10];
+ 	   }
+ 	make_real(pref, (float)dval);
+ 	return 0;
+ }
+ /* Internal subroutine to scan an integer. */
+ /* Return 0, e_limitcheck, or e_syntaxerror. */
+ /* (The only syntax error is no digits encountered.) */
+ /* If the integer won't fit in a long, then: */
+ /*   if pdval == NULL, return e_limitcheck; */
+ /*   if pdval != NULL, return 1 and store a double value in *pdval. */
+ /* Put back the terminating character. */
+ private int
+ scan_int(register stream *s, int radix, long *pval, double *pdval)
+ {	int ival = 0, imax, irem;
+ #if ints_are_short
+ 	long lval, lmax;
+ 	int lrem;
+ #else
+ #  define lval ival			/* for overflowing into double */
+ #endif
+ 	double dval;
+ 	register int c, d;
+ 	register byte *decoder = scan_char_decoder;
+ 	/* Avoid the long divisions when radix = 10 */
+ #define set_max(vmax, vrem, big)\
+   if ( radix == 10 )	vmax = (big) / 10, vrem = (big) % 10;\
+   else			vmax = (big) / radix, vrem = (big) % radix
+ 	set_max(imax, irem, max_uint >> 1);
+ #define convert_digit_fails(c, d)\
+   (d = decoder[c]) >= radix
+ 	while ( 1 )
+ 	   {	c = sgetc(s);
+ 		if ( convert_digit_fails(c, d) )
+ 		   {	if ( c != EOFC ) sputback(s);
+ 			*pval = ival;
+ 			return 0;
+ 		   }
+ 		if ( ival >= imax && (ival > imax || d > irem) )
+ 			break;		/* overflow */
+ 		ival = ival * radix + d;
+ 	   }
+ #if ints_are_short
+ 	/* Short integer overflowed.  Accumulate in a long. */
+ 	lval = (long)ival * radix + d;
+ 	set_max(lmax, lrem, max_ulong >> 1);
+ 	while ( 1 )
+ 	   {	c = sgetc(s);
+ 		if ( convert_digit_fails(c, d) )
+ 		   {	if ( c != EOFC ) sputback(s);
+ 			*pval = lval;
+ 			return 0;
+ 		   }
+ 		if ( lval >= lmax && (lval > lmax || d > lrem) )
+ 			break;		/* overflow */
+ 		lval = lval * radix + d;
+ 	   }
+ #endif
+ 	/* Integer overflowed.  Accumulate the result as a double. */
+ 	if ( pdval == NULL ) return e_limitcheck;
+ 	dval = (double)lval * radix + d;
+ 	while ( 1 )
+ 	   {	c = sgetc(s);
+ 		if ( convert_digit_fails(c, d) )
+ 		   {	if ( c != EOFC ) sputback(s);
+ 			*pdval = dval;
+ 			return 1;
+ 		   }
+ 		dval = dval * radix + d;
+ 	   }
+ 	/* Control doesn't get here */
+ }
+ 
+ /* Make a string */
+ private int
+ mk_string(ref *pref, dynamic_area *pda)
+ {	uint size = pda->next - pda->base;
+ 	byte *body = alloc_shrink(pda->base, pda->num_elts, size, 1, "scanner(string)");
+ 	if ( body == 0 ) return e_VMerror;
+ 	make_tasv(pref, t_string, a_all, size, bytes, body);
+ 	return 0;
+ }
+ 
+ /* Internal procedure to scan a string. */
+ private int
+ scan_string(register stream *s, int from_string, ref *pref)
+ {	dynamic_area da;
+ 	register int c;
+ 	register byte *ptr = dynamic_begin(&da, 100, 1);
+ 	int plevel = 0;
+ 	if ( ptr == 0 ) return e_VMerror;
+ top:	while ( 1 )
+ 	   {	c = sgetc(s);
+ 		if ( c == EOFC ) return e_syntaxerror;
+ 		else if ( c == '(' ) plevel++;
+ 		else if ( c == ')' ) { if ( --plevel < 0 ) break; }
+ 		else if ( c == '\\' && !from_string )
+ 		   {	c = sgetc(s);
+ 			switch ( c )
+ 			   {
+ 			case 'n': c = '\n'; break;
+ 			case 'r': c = '\r'; break;
+ 			case 't': c = '\t'; break;
+ 			case 'b': c = '\b'; break;
+ 			case 'f': c = '\f'; break;
+ 			case '\n': goto top;	/* ignore */
+ 			case '0': case '1': case '2': case '3':
+ 			case '4': case '5': case '6': case '7':
+ 			   {	int d = sgetc(s);
+ 				c -= '0';
+ 				if ( d >= '0' && d <= '7' )
+ 				   {	c = (c << 3) + d - '0';
+ 					d = sgetc(s);
+ 					if ( d >= '0' && d <= '7' )
+ 					   {	c = (c << 3) + d - '0';
+ 						break;
+ 					   }
+ 				   }
+ 				if ( d == EOFC ) return e_syntaxerror;
+ 				sputback(s);
+ 			   }
+ 				break;
+ 			default: ;	/* ignore the \ */
+ 			   }
+ 		   }
+ 		if ( ptr == da.limit )
+ 		   {	da.next = ptr;
+ 			if ( !dynamic_grow(&da) )
+ 			  return e_VMerror;
+ 			ptr = da.next;
+ 		   }
+ 		*ptr++ = c;
+ 	   }
+ 	da.next = ptr;
+ 	return mk_string(pref, &da);
+ }
+ 
+ /* Internal procedure to scan a hex string. */
+ private int
+ scan_hex_string(stream *s, ref *pref)
+ {	dynamic_area da;
+ 	int c1, c2, val1, val2;
+ 	byte *ptr = dynamic_begin(&da, 100, 1);
+ 	register byte *decoder = scan_char_decoder;
+ 	if ( ptr == 0 ) return e_VMerror;
+ l1:	do
+ 	   {	c1 = sgetc(s);
+ 		if ( (val1 = decoder[c1]) < 0x10 )
+ 		   {	do
+ 			   {	c2 = sgetc(s);
+ 				if ( (val2 = decoder[c2]) < 0x10 )
+ 				   {	if ( ptr == da.limit )
+ 					   {	da.next = ptr;
+ 						if ( !dynamic_grow(&da) )
+ 						  return e_VMerror;
+ 						ptr = da.next;
+ 					   }
+ 					*ptr++ = (val1 << 4) + val2;
+ 					goto l1;
+ 				   }
+ 			   }
+ 			while ( val2 == ctype_space );
+ 			if ( c2 != '>' ) return e_syntaxerror;
+ 			if ( ptr == da.limit )
+ 			   {	da.next = ptr;
+ 				if ( !dynamic_grow(&da) )
+ 				  return e_VMerror;
+ 				ptr = da.next;
+ 			   }
+ 			*ptr++ = val1 << 4;	/* no 2nd char */
+ 			goto lx;
+ 		   }
+ 	   }
+ 	while ( val1 == ctype_space );
+ 	if ( c1 != '>' ) return e_syntaxerror;
+ lx:	da.next = ptr;
+ 	return mk_string(pref, &da);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iutil.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iutil.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/iutil.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,272 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* iutil.c */
+ /* Utilities for GhostScript interpreter */
+ #include "memory_.h"
+ #include "string_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "alloc.h"
+ #include "oper.h"
+ #include "store.h"
+ #include "gsmatrix.h"
+ #include "gxdevice.h"			/* for gx_color_index */
+ #include "gzcolor.h"
+ 
+ /* Imported from name.c */
+ extern ref *name_string_ref(P2(ref *, ref *));
+ 
+ /* ------ Object utilities ------ */
+ 
+ /* Copy refs from one place to another. */
+ void
+ refcpy(register ref *to, register ref *from, register uint size)
+ {	while ( size-- ) store_i(to++, from++);
+ }
+ 
+ /* Compare two objects for equality.  Return 1 if equal, 0 if not. */
+ int
+ obj_eq(register ref *pref1, register ref *pref2)
+ {	ref nref;
+ 	if ( r_btype(pref1) != r_btype(pref2) )
+ 	   {	/* Only a few cases need be considered here: */
+ 		/* integer/real, name/string, and vice versa. */
+ 		switch ( r_type(pref1) )
+ 		   {
+ 		case t_integer:
+ 			return (r_type(pref2) == t_real &&
+ 				pref2->value.realval == pref1->value.intval);
+ 		case t_real:
+ 			return (r_type(pref2) == t_integer &&
+ 				pref2->value.intval == pref1->value.realval);
+ 		case t_name:
+ 			if ( r_type(pref2) != t_string ) return 0;
+ 			name_string_ref(pref1, &nref);
+ 			pref1 = &nref;
+ 			break;
+ 		case t_string:
+ 			if ( r_type(pref2) != t_name ) return 0;
+ 			name_string_ref(pref2, &nref);
+ 			pref2 = &nref;
+ 			break;
+ 		default:
+ 			return 0;
+ 		   }
+ 	   }
+ 	/* Now do a type-dependent comparison. */
+ 	/* This would be very simple if we always filled in */
+ 	/* all 8 bytes of a ref, but we currently don't. */
+ 	switch ( r_btype(pref1) )
+ 	   {
+ 	case t_array:
+ 	case t_packedarray:
+ 		return (pref1->value.refs == pref2->value.refs &&
+ 			pref1->size == pref2->size);
+ 	case t_boolean:
+ 		return (pref1->value.index == pref2->value.index);
+ 	case t_dictionary:
+ 		return (pref1->value.pdict == pref2->value.pdict);
+ 	case t_file:
+ 		return (pref1->value.pfile == pref2->value.pfile);
+ 	case t_fontID:
+ 		return (pref1->value.pfont == pref2->value.pfont);
+ 	case t_integer:
+ 		return (pref1->value.intval == pref2->value.intval);
+ 	case t_mark:
+ 	case t_null:
+ 		return 1;
+ 	case t_name:
+ 		return (pref1->value.pname == pref2->value.pname);
+ 	case t_operator:
+ 		return ((long)pref1->value.opproc ==
+ 			(long)pref2->value.opproc);
+ 	case t_real:
+ 		return (pref1->value.realval == pref2->value.realval);
+ 	case t_save:
+ 		return (pref1->value.psave == pref2->value.psave);
+ 	case t_string:
+ 		return (!bytes_compare(pref1->value.bytes, pref1->size,
+ 				       pref2->value.bytes, pref2->size));
+ 	case t_color:
+ 	   {	struct gs_color_s
+ 		  *pc1 = pref1->value.pcolor,
+ 		  *pc2 = pref2->value.pcolor;
+ 		return (pc1->red == pc2->red && pc1->green == pc2->green &&
+ 			pc1->blue == pc2->blue);
+ 	   }
+ 	case t_device:
+ 		return (pref1->value.pdevice == pref2->value.pdevice);
+ 	   }
+ 	return 0;			/* shouldn't happen! */
+ }
+ 
+ /* ------ String utilities ------ */
+ 
+ /* Compare two strings, returning -1 if the first is less, */
+ /* 0 if they are equal, and 1 if first is greater. */
+ /* We can't use memcmp, because we always use unsigned characters. */
+ int
+ bytes_compare(byte *s1, uint len1, byte *s2, uint len2)
+ {	register uint len = len1;
+ 	if ( len2 < len ) len = len2;
+ 	   {	register byte *p1 = s1;
+ 		register byte *p2 = s2;
+ 		while ( len-- )
+ 			if ( *p1++ != *p2++ )
+ 				return (p1[-1] < p2[-1] ? -1 : 1);
+ 	   }
+ 	/* Now check for differing lengths */
+ 	return (len1 == len2 ? 0 : len1 < len2 ? -1 : 1);
+ }
+ 
+ /* Compute a hash for a string */
+ uint
+ string_hash(byte *ptr, uint len)
+ {	register byte *p = ptr;
+ 	register uint hash = 0;
+ 	register uint n = len;
+ 	while ( n-- ) hash = hash * 19 + *p++;
+ 	return hash;
+ }
+ 
+ /* Convert a C string to a Ghostscript string */
+ int
+ string_to_ref(char *cstr, ref *pref, char *cname)
+ {	uint size = strlen(cstr);
+ 	char *str = alloc(size, 1, cname);
+ 	if ( str == 0 ) return e_VMerror;
+ 	memcpy(str, cstr, size);
+ 	make_tasv(pref, t_string, a_all, size, bytes, (byte *)str);
+ 	return 0;
+ }
+ 
+ /* Convert a Ghostscript string to a C string. */
+ /* Return 0 iff the buffer can't be allocated. */
+ char *
+ ref_to_string(ref *pref, char *client_name)
+ {	uint size = pref->size;
+ 	char *str = alloc(size + 1, 1, client_name);
+ 	if ( str == 0 ) return 0;
+ 	memcpy(str, (char *)pref->value.bytes, size);
+ 	str[size] = 0;
+ 	return str;
+ }
+ 
+ /* ------ Operand utilities ------ */
+ 
+ /* Get N numeric operands from the stack. */
+ /* Return a bit-mask indicating which ones are integers, */
+ /* or a (negative) error indication. */
+ /* The 1-bit in the bit-mask refers to the bottommost stack entry. */
+ /* If pval is non-zero, also store float versions of the operands there. */
+ int
+ num_params(ref *op, int count, float *pval)
+ {	int mask = 0;
+ 	while ( --count >= 0 )
+ 	   {	mask <<= 1;
+ 		switch ( r_type(op) )
+ 		   {
+ 		case t_real:
+ 			if ( pval ) pval[count] = op->value.realval;
+ 			break;
+ 		case t_integer:
+ 			if ( pval ) pval[count] = op->value.intval;
+ 			mask++;
+ 			break;
+ 		default:
+ 			return e_typecheck;
+ 		   }
+ 		op--;
+ 	   }
+ 	return mask;
+ }
+ 
+ /* Get a real parameter. */
+ /* If unit is true, the parameter must lie in [0..1],
+ /* to within a reasonable rounding error. */
+ /* If an error is returned, the return value is not updated. */
+ int
+ real_param(ref *op, float *pparam, int unit)
+ {	float fval;
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_integer: fval = op->value.intval; break;
+ 	case t_real: fval = op->value.realval; break;
+ 	default: return e_typecheck;
+ 	   }
+ 	if ( unit )
+ 	   {	if ( fval < 0.0 )
+ 		   {	if ( fval < -0.00001 ) return e_rangecheck;
+ 			fval = 0.0;
+ 		   }
+ 		else if ( fval > 1.0 )
+ 		   {	if ( fval > 1.00001 ) return e_rangecheck;
+ 			fval = 1.0;
+ 		   }
+ 	   }
+ 	*pparam = fval;
+ 	return 0;
+ }
+ 
+ /* Check for a matrix operand with read access. */
+ /* Return 0 if OK, error code if not. */
+ /* Store an all-float version of the matrix in *pmat. */
+ int
+ read_matrix(ref *op, gs_matrix *pmat)
+ {	check_array(*op);
+ 	if ( op->size != 6 ) return e_rangecheck;
+ 	if ( !(r_attrs(op) & a_read) ) return e_invalidaccess;
+ 	*pmat = *(gs_matrix *)op->value.refs;
+ 	   {	ref *pel = (ref *)pmat;
+ 		int i;
+ 		for ( i = 0; i < 6; i++ )
+ 		   {	switch ( r_type(pel) )
+ 			   {
+ 			default: return e_typecheck;
+ 			case t_integer:
+ 				make_real(pel, pel->value.intval);
+ 			case t_real: ;
+ 			   }
+ 			pel++;
+ 		   }
+ 	   }
+ 	return 0;
+ }
+ 
+ /* Check for a matrix operand with write access. */
+ /* Return 0 if OK, error code if not. */
+ /* Any element that isn't a number gets set to 0. */
+ int
+ write_matrix(register ref *op)
+ {	ref *aptr;
+ 	int i;
+ 	if ( r_type(op) != t_array ) return e_typecheck;
+ 	if ( op->size != 6 ) return e_rangecheck;
+ 	if ( !(r_attrs(op) & a_write) ) return e_invalidaccess;
+ 	aptr = op->value.refs;
+ 	for ( i = 5; i >= 0; i--, aptr++ )
+ 	  { switch ( r_type(aptr) )
+ 	      {
+ 	      default: store_int(aptr, 0);
+ 	      case t_real: case t_integer: ;
+ 	      }
+ 	  }
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/lines.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/lines.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/lines.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,89 ----
+ % ** Copyright (C) 1989, 1990 by Aladdin Enterprises.  All rights reserved. **
+ 
+ % Test line rendering (stroke).
+ 
+ % Exercise all the combinations of cap and join styles
+ % for one-line, two-line, and closed paths.
+ 
+ gsave
+ 2.0 setmiterlimit
+ 2.0 setlinewidth
+ 6 6 scale
+ 
+ 5 20 translate
+ {0 1 2}				% line cap
+  { setlinecap gsave
+    {0 1 2}			% line join
+     { setlinejoin gsave
+       { {3 7 lineto}
+         {3 7 lineto 5 1 lineto}
+ 	{3 7 lineto 5 3 lineto closepath}
+       }
+        { gsave 0 0 moveto exec
+          gsave stroke grestore
+ 	 0.5 setlinewidth 1 0 0 setrgbcolor stroke
+ 	 grestore 10 0 translate
+        } forall
+       grestore 35 0 translate
+     } forall
+    grestore 0 10 translate
+  } forall
+ 
+ showpage
+ grestore
+ 
+ % Exercise the miter limit.  The lower row of lines should bevel at
+ % 90 degrees, the upper at 60 degrees.
+ 
+ gsave
+ 1.5 setlinewidth
+ 0 setgray
+ 6 6 scale
+ 5 20 translate
+ [1.415 2.0]
+  { setmiterlimit 0 10 translate 0 0 moveto
+    5 30 360
+     { gsave 2.5 0 rlineto rotate 2.5 0 rlineto stroke grestore
+       6.5 0 rmoveto
+     } for
+  } forall
+ 
+ showpage
+ grestore
+ 
+ % Here are some boundary conditions, contributed by Mark Rawling.
+ 
+ gsave
+ 1 setlinecap
+ 2.6 setmiterlimit
+ 3.0 setlinewidth
+ 
+ 5 5 scale
+ 10 20 translate
+ 
+ %{0 1 2}                        % line join
+ {0}                     % line join
+ {
+     setlinejoin gsave
+     0 0 moveto 0 10 lineto 10 0 lineto gsave stroke grestore
+     15 0 translate
+     0 0 moveto 0 10 lineto 10 20 lineto gsave stroke grestore
+     15 0 translate
+     10 0 moveto 10 10 lineto 0 20 lineto gsave stroke grestore
+     15 0 translate
+     10 0 moveto 10 10 lineto 0 0 lineto gsave stroke grestore
+     grestore
+     gsave
+     0 20 translate
+     0 20 moveto 0 10 lineto 10 20 lineto gsave stroke grestore
+     15 0 translate
+     0 20 moveto 0 10 lineto 10 0 lineto gsave stroke grestore
+     15 0 translate
+     10 20 moveto 10 10 lineto 0 0 lineto gsave stroke grestore
+     15 0 translate
+     10 20 moveto 10 10 lineto 0 20 lineto gsave stroke grestore
+     grestore 20 0 translate
+ } forall
+ 
+ showpage
+ grestore


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,36 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* malloc_.h */
+ /* Generic substitute for Unix malloc.h */
+ 
+ #ifdef __MSDOS__
+ #  include <alloc.h>
+ #else
+ #  ifdef VMS
+      extern char *malloc();
+      extern void free();
+ #  else
+ #    ifdef BSD4_2
+        extern char *malloc();
+ #    else
+ #      include <malloc.h>
+ #    endif
+ #  endif
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/math_.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/math_.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/math_.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,28 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* math_.h */
+ /* Generic substitute for math.h */
+ 
+ #ifdef VMS
+ /*  DEC VAX/VMS C comes with a math.h file, but GNU VAX/VMS C does not. */
+ #  include "vmsmath.h"
+ #else
+ #  include <math.h>
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/memory_.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/memory_.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/memory_.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,64 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* memory_.h */
+ /* Generic substitute for Unix memory.h */
+ 
+ /****** Note: the System V bcmp routine only returns zero or non-zero, ******/
+ /****** unlike memcmp which returns -1, 0, or 1. ******/
+ 
+ #ifdef __MSDOS__
+ /* The Turbo C implementation of memset swaps the arguments and calls */
+ /* the non-standard routine setmem.  We may as well do it in advance. */
+ #  undef memset				/* just in case */
+ #  include <mem.h>
+ #  define memset(dest,chr,cnt) setmem(dest,cnt,chr)
+ #else
+ #  ifdef VMS
+ 	extern char *memcpy(), *memset();
+ 	extern int memcmp();
+ #  else
+ #    ifdef BSD4_2
+ 	extern bcopy(), bcmp(), bzero();
+ #       define memcpy(dest,src,len) bcopy(src,dest,len)
+ #       define memcmp(b1,b2,len) bcmp(b1,b2,len)
+ 	/* Define our own version of memset */
+ #	ifdef __STDC__
+ 	static void memset(void *dest, register char ch, unsigned len)
+ #	else
+ 	static void memset(dest, ch, len)
+ 	  void *dest; register char ch; unsigned len;
+ #	endif				/* (!)__STDC__ */
+ 	   {	if ( ch == 0 )
+ 			bzero(dest, len);
+ 		else if ( len > 0 )
+ 		   {	register char *p = (char *)dest;
+ 			register unsigned count = len;
+ 			do { *p++ = ch; } while ( --count );
+ 		   }
+ 	   }
+ #    else				/* !BSD4_2 */
+ #      ifdef _POSIX_SOURCE
+ #        include <string.h>
+ #      else
+ #        include <memory.h>
+ #      endif				/* !_POSIX_SOURCE */
+ #    endif				/* !BSD4_2 */
+ #  endif				/* !VMS */
+ #endif					/* !__MSDOS__ */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/name.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/name.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/name.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,58 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* name.h */
+ /* Name table entry structure for Ghostscript */
+ 
+ /* Name structure.  The name table is a simple chained hash table. */
+ /* There is an optimization to avoid lookup for operator and other */
+ /* global names. */
+ struct name_s {
+ 	struct name_s *next;	/* next name in chain or 0 */
+ 	ushort index;
+ /* In order to pack names into 16 bytes, we use a non-standard */
+ /* representation for the string, omitting the type_attrs field. */
+ 	ushort string_size;
+ 	byte *string_bytes;
+ /* pvalue specifies the definition status of the name: */
+ /*	pvalue == pv_no_defn: no definitions */
+ #define pv_no_defn ((ref *)0)
+ /*	pvalue == pv_other: other status */
+ #define pv_other ((ref *)1)
+ #define pv_valid(pvalue) ((unsigned long)(pvalue) > 1)
+ /*	pvalue != pv_no_defn, pvalue != pv_other: pvalue is valid */
+ 	ref *pvalue;		/* if only defined in systemdict */
+ 				/* or userdict, this points to */
+ 				/* the value */
+ };
+ /*typedef struct name_s name;*/		/* in ghost.h */
+ 
+ /* Procedures for the name table. */
+ /* The size argument for name_ref should be a ushort, */
+ /* but this gets the Apollo compiler confused. */
+ /* enterflag=-1 means don't enter (return an error if missing); */
+ /* enterflag=0 means enter if missing, don't copy the string; */
+ /* enterflag=1 means enter if missing, copy the string. */
+ extern	int	name_ref(P4(byte *ptr, uint size, ref *pnref, int enterflag));
+ extern	void	name_string_ref(P2(ref *pnref, ref *psref));
+ extern	void	name_enter(P2(char *str, ref *pnref));
+ /* Conversion between names and indices. */
+ #define name_index(pnref) ((pnref)->index)
+ extern	void	name_index_ref(P2(uint index /* should be ushort*/,
+ 			          ref *pnref));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/oper.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/oper.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/oper.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,105 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* oper.h */
+ /* Definitions for GhostScript operators */
+ 
+ /* Structure for initializing the operator table. */
+ /* Each operator file declares an array of these, */
+ /* and supplies an initialization procedure of the following kind: */
+ /*
+ void
+ zxxx_init()
+ {	static op_def my_defs[] = {
+ 		{"1name", zname},
+ 		    ...
+ 		op_def_end
+ 	};
+ 	z_init(my_defs);
+ }
+  */
+ /* This definition always appears at the END of the file, */
+ /* to avoid the necessity for forward declarations for all the */
+ /* operator procedures. */
+ typedef struct {
+ 	char *name;
+ 	op_proc_p proc;
+ } op_def;
+ #define op_def_end {(char *)0, (op_proc_p)0}
+ 
+ /* Operand stack manipulation */
+ extern ref *osbot, *osp, *ostop;
+ /* The most efficient code is different on MS-DOS vs. Unix.... */
+ #ifdef __MSDOS__			/* stupid compiler */
+ #define push(n)\
+   if ( (op += (n)) > ostop ) return (e_stackoverflow); else osp += (n)
+ #else					/* reasonable compiler */
+ #define push(n)\
+   if ( (osp = op += (n)) > ostop ) return (osp -= (n), e_stackoverflow)
+ #endif
+ /*
+  * Note that the pop macro only decrements osp, not op.  For this reason,
+  *
+  *	>>>	pop should only be used just before returning,	<<<
+  *	>>>	or else op must be decremented explicitly.	<<<
+  */
+ #define pop(n) (osp -= (n))
+ /*
+  * Note that the interpreter does not check for operand stack underflow
+  * before calling the operator procedure.  There are "guard" entries
+  * with invalid types and attributes just below the bottom of the
+  * operand stack: if the operator returns with a typecheck error,
+  * the interpreter checks for underflow at that time.
+  * Operators that don't typecheck their arguments must check for
+  * operand stack underflow explicitly.
+  */
+ #define os_max_nargs 6
+ extern ref *osp_nargs[os_max_nargs];
+ #define check_op(nargs)\
+   if ( op < osp_nargs[(nargs) - 1] ) return e_stackunderflow
+ 
+ /* Check type */
+ #define check_type(rf,typ)\
+   if ( !r_has_type(&rf,typ) ) return e_typecheck
+ /* Check for array */
+ #define check_array_else(rf,err)\
+   switch ( r_type(&rf) )\
+    { default: return err; case t_array: case t_packedarray: ; }
+ #define check_array(rf) check_array_else(rf, e_typecheck)
+ /* Check for procedure */
+ #define check_proc(rf)\
+   check_array(rf); check_access(rf, (a_execute+a_executable))
+ 
+ /* Check for read, write, or execute access */
+ #define check_access(rf,acc)\
+   if ( !r_has_attrs(&rf,acc) ) return e_invalidaccess
+ #define check_read(rf) check_access(rf,a_read)
+ #define check_read_type(rf,typ) check_type(rf,typ); check_read(rf)
+ #define check_write(rf) check_access(rf,a_write)
+ #define check_write_type(rf,typ) check_type(rf,typ); check_write(rf)
+ #define check_execute(rf) check_access(rf,a_execute)
+ 
+ /* Macro for as yet unimplemented operators. */
+ /* The if ( 1 ) is to prevent the compiler from complaining about */
+ /* unreachable code. */
+ #define NYI(msg) if ( 1 ) return e_undefined
+ 
+ /* If an operator may have popped or pushed something on the control stack, */
+ /* it must return o_check_estack rather than 0 to indicate success. */
+ #define o_check_estack 1


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/path.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/path.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/path.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,26 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* path.h */
+ /* Representation of paths for GhostScript */
+ 
+ /* The current path in the graphics state */
+ extern gx_path gs_path;
+ extern gx_path gs_clip_path;
+ #define gs_point gs_path.position


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/pcharstr.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/pcharstr.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/pcharstr.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,75 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % Print the CharStrings and Subrs from a Type 1 font in symbolic form.
+ 
+ 30 dict dup begin
+   1 (hstem) def   3 (vstem) def   4 (vmoveto) def
+   5 (rlineto) def   6 (hlineto) def   7 (vlineto) def
+   8 (rrcurveto) def   9 (closepath) def   10 (callsubr) def
+   11 (return) def   13 (hsbw) def   14 (endchar) def
+   21 (rmoveto) def   22 (hmoveto) def   30 (vhcurveto) def
+   31 (hvcurveto) def
+   32 (dotsection) def   33 (vstem3) def   34 (hstem3) def
+   38 (seac) def   39 (sbw) def   44 (div) def
+   48 (callothersubr) def   49 (pop) def   65 (setcurrentpoint) def
+ end /csdict exch def
+ 
+ /printcs
+  { 4330 exch dup length string type1decrypt exch pop
+    dup /s exch def length /n exch def
+    lenIV 1 sub
+     { 1 add dup n ge { exit } if
+       ( ) print dup s exch get
+       dup 31 le
+        { dup 12 eq { pop 1 add dup s exch get 32 add } if
+          dup csdict exch known
+ 	  { csdict exch get print }
+ 	  { =only (?) print }
+ 	 ifelse
+        }
+        { dup 247 lt
+        	  { 139 sub }
+ 	  { dup 255 eq
+ 	     { pop 4 add (****)
+ 	     }
+ 	     { 247 sub {108 364 620 876 -108 -364 -620 -876} exch get
+ 	       exch 1 add exch s 2 index get add
+ 	     }
+ 	    ifelse
+ 	  }
+ 	 ifelse =only
+        }
+       ifelse
+     } loop
+    pop (\n) print
+  } bind def
+ 
+ /printfont
+  { currentfont begin Private begin 10 dict begin
+    CharStrings { exch ==only printcs } forall
+    0 1 Subrs length 1 sub
+     { dup =only
+       Subrs exch get printcs
+     } for
+    end end end
+  } bind def
+ 
+ /Times-Roman findfont setfont
+ printfont


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ppath.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ppath.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ppath.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,22 ----
+ % Redefine pathforall for tracing.
+ % Can't be used recursively.
+ 
+ /# {( )print} def
+ 
+ /-pathforall /pathforall load def
+ 
+ /pathforall
+  { /-close exch def  /-curve exch def  /-line exch def  /-move exch def
+    {2 copy exch =only # =only ( moveto\n)print   /-move load exec}
+    {2 copy exch =only # =only ( lineto\n)print   /-line load exec}
+    {6 copy 6 -1 roll =only # 5 -1 roll =only #
+     4 -1 roll =only # 3 -1 roll =only # exch =only # =only ( curveto\n)print
+     /-curve load exec}
+    {(closepath\n)print   /-close load exec}
+    -pathforall flush }
+  def
+ 
+ % Just print the current path
+ 
+ /printpath
+  { {pop pop} {pop pop} {pop pop pop pop pop pop} {} pathforall } def


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/prfont.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/prfont.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/prfont.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,83 ----
+ %!PS-Adobe-1.0
+ %%Creator: Eric Gisin <egisin at waterloo.csnet>
+ %%Title: Print font catalog
+ % Copyright (c) 1986 Eric Gisin
+ 
+ % Example usages at bottom of file
+ 
+ /#copies 1 def
+ 
+ /T6 /Times-Roman findfont 6 scalefont def
+ /Temp 64 string def
+ /Inch {72 mul} def
+ /Base 16 def	% char code output base
+ 
+ % do single character of page
+ % output to rectangle ll=(0,-24) ur=(36,24)
+ /DoChar {
+   /C exch def
+   /S (_) dup 0 C put def
+   /N F /Encoding get C get def
+ 
+   % print code name, width and char name
+   /W F setfont S stringwidth pop def
+   T6 setfont
+   N /.notdef ne {0 -20 moveto N Temp cvs show} if
+   0 -12 moveto C Base Temp cvrs show (  ) show
+   W 0.0005 add Temp cvs 0 5 getinterval show
+ 
+   % print char with reference lines
+   N /.notdef ne {
+     3 0 translate
+     0 0 moveto F24 setfont S show
+     /W S stringwidth pop def
+     0 -6 moveto 0 24 lineto
+     W -6 moveto W 24 lineto
+     -3 0 moveto W 3 add 0 lineto
+     0 setlinewidth stroke
+   } if
+ } def
+ 
+ % print font sample page
+ /DoFont {
+   /FName exch def	% font name
+   /F FName findfont def
+   /F24 F 24 scalefont def
+   /Line0 96 string def
+   /Line1 96 string def
+ 
+   /Times-Roman findfont 18 scalefont setfont
+   18 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
+ 
+   0 1 95 {
+     /I exch def
+     /Xn I 16 mod def /Yn I 16 idiv def
+ 
+     % chars 20-7F
+     gsave
+     Xn 36 mul 18 add Yn -48 mul 9.5 Inch add translate
+     Line0 I I 16#20 add put
+     I 16#20 add DoChar
+     grestore
+ 
+     % chars A0-FF
+     gsave
+     Xn 36 mul 18 add Yn -48 mul 4.5 Inch add translate
+     Line1 I I 16#A0 add put
+     I 16#A0 add DoChar
+     grestore
+   } for
+ 
+   F 10 scalefont setfont
+   18 5.5 Inch moveto Line0 show
+   18 0.5 Inch moveto Line1 show
+ 
+   showpage
+ } def
+ 
+ % Do font samples
+ % /Times-Roman DoFont			% Test (less than a minute)
+ % /Hershey-Gothic-English DoFont	% Test (8 minutes)
+ 
+ % Do a complete catalog
+ % FontDirectory {pop DoFont} forall	% All fonts (quite a long time)


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ps2image.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ps2image.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ps2image.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,106 ----
+ %    Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % Convert a .ps file to another .ps file containing only a bit image.
+ % Usage:
+ %	(filename) ps2image
+ % This replaces the current device, writing the output on the file
+ % instead of to the device.  To display the image at a later time,
+ % simply run the file that was written.
+ 
+ % Initialize, and redefine copypage and showpage.
+ /ps2idict 25 dict def
+ ps2idict begin
+ 				% Save the showpage operator
+   /realshowpage //showpage def
+ 				% Define a monochrome palette
+   /monopalette [ 0 0 0 rgbcolor 1 1 1 rgbcolor ] def
+ 				% The main procedure
+   /ps2image
+    {				% Open the file
+      (w) file /myfile exch def
+      myfile (/readimage ) writestring
+      myfile /readimage load write==only
+      myfile ( bind def\n) writestring
+ 					% Get the device parameters
+      currentdevice matrix deviceparams
+      /devheight exch def
+      /devwidth exch def
+      /devmatrix exch def
+      cleartomark
+ 				% Make a corresponding memory device
+      devmatrix devwidth devheight monopalette
+      makeimagedevice
+      /mydevice exch def
+      mydevice setdevice
+      erasepage
+      /row devwidth 7 add 8 idiv string def
+      /prevrow row length string def
+ 				% Replace the definition of showpage
+      userdict /showpage { ps2idict begin myshowpage end } bind put
+    } def
+ 				% Procedure for reading and displaying
+ 				% the rendered image.
+ 				% <width> <height> readimage
+   /readimage
+    { gsave matrix setmatrix
+      1 matrix
+      3 index 7 add 8 idiv string currentfile
+      				% At each iteration of the loop,
+ 				% the stack contains <buffer> <file>
+       { 2 copy exch
+         1 index token pop	% starting index
+         2 index token pop	% count
+ 	getinterval
+         readhexstring pop pop 1 index }
+      3 1 roll
+      7 2 roll
+      image pop pop
+      grestore showpage
+    } def
+ 				% Write the image on the file
+   /myshowpage
+    { myfile devwidth write==only   myfile ( ) writestring
+      myfile devheight write==only   myfile ( readimage\n) writestring
+      0 1 prevrow length 1 sub { row exch 0 put } for
+ 	 			% Write the hex data
+      0 1 devheight 1 sub
+       { mydevice exch row copyscanlines
+         0 row length 1 sub -1 0
+ 	 { dup dup prevrow exch get exch row exch get
+ 	   ne { 1 add exch pop exit } { pop } ifelse
+ 	 } for
+ 	dup dup 0 exch 1 exch 1 sub
+ 	 { dup dup prevrow exch get exch row exch get
+ 	   ne { exch pop exit } { pop } ifelse
+ 	 } for
+ 	   			% stack now has stop index, start index
+ 	exch 1 index sub 2 copy exch	% start, length, length, start
+ 	myfile exch write==only   myfile ( ) writestring
+ 	myfile exch write==only   myfile ( ) writestring
+ 	getinterval myfile exch writehexstring
+ 	row prevrow copy pop
+ 	myfile (\n) writestring
+       } for
+      myfile flushfile
+    } bind def
+ 
+ end
+ 
+ /ps2image { ps2idict begin ps2image end } bind def


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/pstoppm.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/pstoppm.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/pstoppm.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,403 ----
+ %! PS-Adobe-2.0
+ %% for GhostScript 2.0
+ %% Program for reading a .ps file and writing out a PPM file.
+ %% Original version by Phillip Conrad - Perfect Byte, Inc.
+ %% Modified 06/26/90 for a color file
+ %% Modified on 08/02/90 for using the CORRECT color map.
+ %% Modified by L. Peter Deutsch -- Aladdin Enterprises -- 08/02/90
+ %% Modified by L. Peter Deutsch -- Aladdin Enterprises -- 08/25/90 --
+ %%   converted from a one-shot program to a utility package,
+ %%   designed to be used from an interactive terminal.
+ %% Modified by Henry Minsky 11/03/90
+ %%   for each showpage, it writes out a ppm file with name filename.ppm.N
+ %%   where N increments each showpage, starting at 1
+ %% Modified by L. Peter Deutsch 11/07/90
+ %%   to use filename.ppm for the first page, renamed to filename.1ppm
+ %%   with subsequent pages .2ppm, etc. if more than one page.
+ %%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ 
+ %%%%%% Define the directory for holding the PPM information
+ 
+ /ppmdict 30 dict def
+ ppmdict begin
+ 
+   /Horz_dpi 72 def		% defaults to screen density
+   /Vert_dpi 72 def
+ 
+   /OutFilePrefix () def		% default to null (current directory)
+ 
+   /Palette1 [1 1 1 rgbcolor 0 0 0 rgbcolor] def
+   /Palette8
+     [
+ %========== Here we define all 256 color entries as color objects. ======
+ %========== Colors were taken from the W Xindows default colors. ======
+ 0.000   0.000   0.000   rgbcolor
+ 1.000   1.000   1.000   rgbcolor
+ 0.659   0.659   0.659   rgbcolor
+ 0.922   0.922   0.922   rgbcolor
+ 0.361   0.361   0.361   rgbcolor
+ 0.216   0.216   0.216   rgbcolor
+ 0.373   0.573   0.620   rgbcolor
+ 0.522   0.800   0.867   rgbcolor
+ 0.204   0.314   0.341   rgbcolor
+ 0.122   0.188   0.204   rgbcolor
+ 0.447   0.620   0.996   rgbcolor
+ 0.627   0.867   1.000   rgbcolor
+ 0.247   0.341   0.549   rgbcolor
+ 0.149   0.204   0.329   rgbcolor
+ 0.380   0.525   0.847   rgbcolor
+ 0.184   0.184   0.392   rgbcolor
+ 1.000   1.000   0.000   rgbcolor
+ 0.690   0.886   1.000   rgbcolor
+ 1.000   0.000   0.000   rgbcolor
+ 0.502   0.502   0.502   rgbcolor
+ 0.937   0.875   0.518   rgbcolor
+ 0.333   0.996   0.333   rgbcolor
+ 0.996   0.000   0.000   rgbcolor
+ 0.400   0.996   0.341   rgbcolor
+ 0.996   0.596   0.478   rgbcolor
+ 0.996   0.792   0.443   rgbcolor
+ 0.996   0.996   0.996   rgbcolor
+ 0.996   0.553   0.486   rgbcolor
+ 0.996   0.663   0.467   rgbcolor
+ 0.996   0.769   0.447   rgbcolor
+ 0.996   0.722   0.459   rgbcolor
+ 0.996   0.576   0.482   rgbcolor
+ 0.996   0.584   0.478   rgbcolor
+ 0.996   0.710   0.459   rgbcolor
+ 0.596   0.996   0.365   rgbcolor
+ 0.996   0.545   0.490   rgbcolor
+ 0.996   0.651   0.467   rgbcolor
+ 0.996   0.698   0.463   rgbcolor
+ 0.996   0.686   0.463   rgbcolor
+ 0.996   0.745   0.455   rgbcolor
+ 0.996   0.514   0.494   rgbcolor
+ 0.996   0.988   0.416   rgbcolor
+ 0.996   0.047   0.604   rgbcolor
+ 0.996   0.012   0.314   rgbcolor
+ 0.996   0.031   0.710   rgbcolor
+ 0.404   0.082   0.996   rgbcolor
+ 0.996   0.984   0.247   rgbcolor
+ 0.996   0.329   0.294   rgbcolor
+ 0.000   0.753   0.000   rgbcolor
+ 0.125   0.753   0.000   rgbcolor
+ 0.251   0.753   0.000   rgbcolor
+ 0.376   0.753   0.000   rgbcolor
+ 0.502   0.753   0.000   rgbcolor
+ 0.627   0.753   0.000   rgbcolor
+ 0.753   0.753   0.000   rgbcolor
+ 0.878   0.753   0.000   rgbcolor
+ 0.000   0.878   0.000   rgbcolor
+ 0.125   0.878   0.000   rgbcolor
+ 0.251   0.878   0.000   rgbcolor
+ 0.376   0.878   0.000   rgbcolor
+ 0.502   0.878   0.000   rgbcolor
+ 0.627   0.878   0.000   rgbcolor
+ 0.753   0.878   0.000   rgbcolor
+ 0.878   0.878   0.000   rgbcolor
+ 0.000   0.000   0.251   rgbcolor
+ 0.125   0.000   0.251   rgbcolor
+ 0.251   0.000   0.251   rgbcolor
+ 0.376   0.000   0.251   rgbcolor
+ 0.502   0.000   0.251   rgbcolor
+ 0.627   0.000   0.251   rgbcolor
+ 0.753   0.000   0.251   rgbcolor
+ 0.878   0.000   0.251   rgbcolor
+ 0.000   0.125   0.251   rgbcolor
+ 0.125   0.125   0.251   rgbcolor
+ 0.251   0.125   0.251   rgbcolor
+ 0.376   0.125   0.251   rgbcolor
+ 0.502   0.125   0.251   rgbcolor
+ 0.627   0.125   0.251   rgbcolor
+ 0.753   0.125   0.251   rgbcolor
+ 0.878   0.125   0.251   rgbcolor
+ 0.000   0.251   0.251   rgbcolor
+ 0.125   0.251   0.251   rgbcolor
+ 0.251   0.251   0.251   rgbcolor
+ 0.376   0.251   0.251   rgbcolor
+ 0.502   0.251   0.251   rgbcolor
+ 0.627   0.251   0.251   rgbcolor
+ 0.753   0.251   0.251   rgbcolor
+ 0.878   0.251   0.251   rgbcolor
+ 0.000   0.376   0.251   rgbcolor
+ 0.125   0.376   0.251   rgbcolor
+ 0.251   0.376   0.251   rgbcolor
+ 0.376   0.376   0.251   rgbcolor
+ 0.502   0.376   0.251   rgbcolor
+ 0.627   0.376   0.251   rgbcolor
+ 0.753   0.376   0.251   rgbcolor
+ 0.878   0.376   0.251   rgbcolor
+ 0.000   0.502   0.251   rgbcolor
+ 0.125   0.502   0.251   rgbcolor
+ 0.251   0.502   0.251   rgbcolor
+ 0.376   0.502   0.251   rgbcolor
+ 0.502   0.502   0.251   rgbcolor
+ 0.627   0.502   0.251   rgbcolor
+ 0.753   0.502   0.251   rgbcolor
+ 0.878   0.502   0.251   rgbcolor
+ 0.000   0.627   0.251   rgbcolor
+ 0.125   0.627   0.251   rgbcolor
+ 0.251   0.627   0.251   rgbcolor
+ 0.376   0.627   0.251   rgbcolor
+ 0.502   0.627   0.251   rgbcolor
+ 0.627   0.627   0.251   rgbcolor
+ 0.753   0.627   0.251   rgbcolor
+ 0.878   0.627   0.251   rgbcolor
+ 0.000   0.753   0.251   rgbcolor
+ 0.125   0.753   0.251   rgbcolor
+ 0.251   0.753   0.251   rgbcolor
+ 0.376   0.753   0.251   rgbcolor
+ 0.502   0.753   0.251   rgbcolor
+ 0.627   0.753   0.251   rgbcolor
+ 0.753   0.753   0.251   rgbcolor
+ 0.878   0.753   0.251   rgbcolor
+ 0.000   0.878   0.251   rgbcolor
+ 0.125   0.878   0.251   rgbcolor
+ 0.251   0.878   0.251   rgbcolor
+ 0.376   0.878   0.251   rgbcolor
+ 0.502   0.878   0.251   rgbcolor
+ 0.627   0.878   0.251   rgbcolor
+ 0.753   0.878   0.251   rgbcolor
+ 0.878   0.878   0.251   rgbcolor
+ 0.000   0.000   0.502   rgbcolor
+ 0.125   0.000   0.502   rgbcolor
+ 0.251   0.000   0.502   rgbcolor
+ 0.376   0.000   0.502   rgbcolor
+ 0.502   0.000   0.502   rgbcolor
+ 0.627   0.000   0.502   rgbcolor
+ 0.753   0.000   0.502   rgbcolor
+ 0.878   0.000   0.502   rgbcolor
+ 0.000   0.125   0.502   rgbcolor
+ 0.125   0.125   0.502   rgbcolor
+ 0.251   0.125   0.502   rgbcolor
+ 0.376   0.125   0.502   rgbcolor
+ 0.502   0.125   0.502   rgbcolor
+ 0.627   0.125   0.502   rgbcolor
+ 0.753   0.125   0.502   rgbcolor
+ 0.878   0.125   0.502   rgbcolor
+ 0.000   0.251   0.502   rgbcolor
+ 0.125   0.251   0.502   rgbcolor
+ 0.251   0.251   0.502   rgbcolor
+ 0.376   0.251   0.502   rgbcolor
+ 0.502   0.251   0.502   rgbcolor
+ 0.627   0.251   0.502   rgbcolor
+ 0.753   0.251   0.502   rgbcolor
+ 0.878   0.251   0.502   rgbcolor
+ 0.000   0.376   0.502   rgbcolor
+ 0.125   0.376   0.502   rgbcolor
+ 0.251   0.376   0.502   rgbcolor
+ 0.376   0.376   0.502   rgbcolor
+ 0.502   0.376   0.502   rgbcolor
+ 0.627   0.376   0.502   rgbcolor
+ 0.753   0.376   0.502   rgbcolor
+ 0.878   0.376   0.502   rgbcolor
+ 0.000   0.502   0.502   rgbcolor
+ 0.125   0.502   0.502   rgbcolor
+ 0.251   0.502   0.502   rgbcolor
+ 0.376   0.502   0.502   rgbcolor
+ 0.502   0.502   0.502   rgbcolor
+ 0.627   0.502   0.502   rgbcolor
+ 0.753   0.502   0.502   rgbcolor
+ 0.878   0.502   0.502   rgbcolor
+ 0.000   0.627   0.502   rgbcolor
+ 0.125   0.627   0.502   rgbcolor
+ 0.251   0.627   0.502   rgbcolor
+ 0.376   0.627   0.502   rgbcolor
+ 0.502   0.627   0.502   rgbcolor
+ 0.627   0.627   0.502   rgbcolor
+ 0.753   0.627   0.502   rgbcolor
+ 0.878   0.627   0.502   rgbcolor
+ 0.000   0.753   0.502   rgbcolor
+ 0.125   0.753   0.502   rgbcolor
+ 0.251   0.753   0.502   rgbcolor
+ 0.376   0.753   0.502   rgbcolor
+ 0.502   0.753   0.502   rgbcolor
+ 0.627   0.753   0.502   rgbcolor
+ 0.753   0.753   0.502   rgbcolor
+ 0.878   0.753   0.502   rgbcolor
+ 0.000   0.878   0.502   rgbcolor
+ 0.125   0.878   0.502   rgbcolor
+ 0.251   0.878   0.502   rgbcolor
+ 0.376   0.878   0.502   rgbcolor
+ 0.502   0.878   0.502   rgbcolor
+ 0.627   0.878   0.502   rgbcolor
+ 0.753   0.878   0.502   rgbcolor
+ 0.878   0.878   0.502   rgbcolor
+ 0.000   0.000   0.753   rgbcolor
+ 0.125   0.000   0.753   rgbcolor
+ 0.251   0.000   0.753   rgbcolor
+ 0.376   0.000   0.753   rgbcolor
+ 0.502   0.000   0.753   rgbcolor
+ 0.627   0.000   0.753   rgbcolor
+ 0.753   0.000   0.753   rgbcolor
+ 0.878   0.000   0.753   rgbcolor
+ 0.000   0.125   0.753   rgbcolor
+ 0.125   0.125   0.753   rgbcolor
+ 0.251   0.125   0.753   rgbcolor
+ 0.376   0.125   0.753   rgbcolor
+ 0.502   0.125   0.753   rgbcolor
+ 0.627   0.125   0.753   rgbcolor
+ 0.753   0.125   0.753   rgbcolor
+ 0.878   0.125   0.753   rgbcolor
+ 0.000   0.251   0.753   rgbcolor
+ 0.125   0.251   0.753   rgbcolor
+ 0.251   0.251   0.753   rgbcolor
+ 0.376   0.251   0.753   rgbcolor
+ 0.502   0.251   0.753   rgbcolor
+ 0.627   0.251   0.753   rgbcolor
+ 0.753   0.251   0.753   rgbcolor
+ 0.878   0.251   0.753   rgbcolor
+ 0.000   0.376   0.753   rgbcolor
+ 0.125   0.376   0.753   rgbcolor
+ 0.251   0.376   0.753   rgbcolor
+ 0.376   0.376   0.753   rgbcolor
+ 0.502   0.376   0.753   rgbcolor
+ 0.627   0.376   0.753   rgbcolor
+ 0.753   0.376   0.753   rgbcolor
+ 0.878   0.376   0.753   rgbcolor
+ 0.000   0.502   0.753   rgbcolor
+ 0.125   0.502   0.753   rgbcolor
+ 0.251   0.502   0.753   rgbcolor
+ 0.376   0.502   0.753   rgbcolor
+ 0.502   0.502   0.753   rgbcolor
+ 0.627   0.502   0.753   rgbcolor
+ 0.753   0.502   0.753   rgbcolor
+ 0.878   0.502   0.753   rgbcolor
+ 0.000   0.627   0.753   rgbcolor
+ 0.125   0.627   0.753   rgbcolor
+ 0.251   0.627   0.753   rgbcolor
+ 0.376   0.627   0.753   rgbcolor
+ 0.502   0.627   0.753   rgbcolor
+ 0.627   0.627   0.753   rgbcolor
+ 0.753   0.627   0.753   rgbcolor
+ 0.878   0.627   0.753   rgbcolor
+ 0.000   0.753   0.753   rgbcolor
+ 0.125   0.753   0.753   rgbcolor
+ 0.251   0.753   0.753   rgbcolor
+ 0.376   0.753   0.753   rgbcolor
+ 0.502   0.753   0.753   rgbcolor
+ 0.627   0.753   0.753   rgbcolor
+ 0.753   0.753   0.753   rgbcolor
+ 0.878   0.753   0.753   rgbcolor
+ 0.000   0.878   0.753   rgbcolor
+ 0.125   0.878   0.753   rgbcolor
+ 0.251   0.878   0.753   rgbcolor
+ 0.376   0.878   0.753   rgbcolor
+ 0.502   0.878   0.753   rgbcolor
+ 0.627   0.878   0.753   rgbcolor
+ 0.753   0.878   0.753   rgbcolor
+ 0.878   0.878   0.753   rgbcolor
+     ] def
+ 
+   % Redefine copypage and showpage appropriately
+   /copypage
+    { ppmdict begin
+ 
+        /PageCount PageCount 1 add def
+ 
+        OutFilePrefix FileName concatstrings
+        PageCount 1 eq
+ 	{ (.ppm) concatstrings			% first page
+ 	}
+ 	{ PageCount 2 eq
+ 	   {					% second page, rename first
+ 	     dup dup (.ppm) concatstrings
+ 	     exch (.1ppm) concatstrings
+ 	     (Renaming ) print 1 index print ( to ) print
+ 	       dup print (\n) print
+ 	     flush
+ 	     renamefile
+ 	   } if
+ 	  (.) PageCount (xxxxxx) cvs concatstrings
+ 	  (ppm) concatstrings concatstrings
+ 	} ifelse
+        /FileNameOut exch def
+ 
+        FileNameOut (w) file
+          /FileDescOut exch def
+ 
+        (Writing ) print FileNameOut print (\n) print
+        flush
+        FileDescOut Device writeppmfile
+        FileDescOut closefile
+ 
+        /WrotePage true def
+ 
+      end
+    } userdict begin def end
+   /showpage
+    { copypage erasepage initgraphics
+    } userdict begin def end
+ 
+   /Convert			% the main procedure
+   				% <filename> <palette> Convert -
+    { /Palette exch def
+      /FileName exch def
+ 
+      /PageCount 0 def
+ 
+      /ScaleX Horz_dpi 72 div def
+      /ScaleY Vert_dpi 72 div def
+ 
+      /Width 85 Horz_dpi mul 5 add 10 div cvi def % add 5 to round up!
+      /Height 11 Vert_dpi mul def
+ 
+      FileName (.ps) concatstrings
+        /FileNameIn exch def		% file name with extension
+ 
+      [ScaleX 0.0 0.0 ScaleY neg 0.0 Height]
+      Width Height Palette makeimagedevice
+        /Device exch def
+      Device setdevice
+ 
+      /WrotePage false def
+ 
+      % For running the file, remove ppmdict from the dict stack
+      FileNameIn end run		% ppmdict
+      ppmdict begin
+      WrotePage not { showpage } if	% make sure the page got written
+      end			% ppmdict
+ 
+    } def
+ 
+ end				% ppmdict
+ 
+ %%%%%% Define the user-callable procedures
+ 
+ /ppmsetdensity
+  { ppmdict begin
+    /Vert_dpi exch def
+    /Horz_dpi exch def
+    end
+  } def
+ 
+ /ppmsetprefix
+  { ppmdict begin
+    /OutFilePrefix exch def
+    end
+  } def
+ 
+ /ppm1run
+  { ppmdict begin   Palette1 Convert
+  } def
+ 
+ /ppm8run
+  { ppmdict begin   Palette8 Convert
+  } def
+ 
+ /ppm24run
+  { ppmdict begin   null Convert
+  } def
+ 
+ %%%%%% Display instructions for the user.
+ 
+ (Usage: (file) ppmNrun\n) print
+ (   converts file.ps to file.ppm (single page),\n) print
+ (     or file.1ppm, file.2ppm, ... (multi page).\n) print
+ (   N is # of bits per pixel (1, 8, or 24).\n) print
+ (Examples: (golfer) ppm1run   ..or..   (escher) ppm8run\n) print
+ (Optional commands you can give first:\n) print
+ (   horiz_DPI vert_DPI ppmsetdensity\n) print
+ (   (dirname/) ppmsetprefix\n) print
+ flush


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/quit.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/quit.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:24 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/quit.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1 ----
+ quit


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/scanchar.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/scanchar.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/scanchar.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,42 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* scanchar.h */
+ /* Character scanning table for Ghostscript */
+ 
+ /* An array for fast scanning of names, numbers, and hex strings. */
+ /*  Indexed by character code (including EOFC), it contains: */
+ /*	0 - max_radix-1 for valid digits, */
+ /*	ctype_name for other characters valid in names, */
+ /*	ctype_space for whitespace characters, */
+ /*	ctype_eof for end-of-file, and */
+ /*	ctype_other for everything else. */
+ /* This table is initialized in iscan.c, used in iscan.c and stream.c. */
+ extern byte scan_char_array[257];
+ #define scan_char_decoder (&scan_char_array[1])	/* account for EOFC */
+ #define min_radix 2
+ #define max_radix 36
+ #define ctype_name 100
+ #define ctype_space 101
+ #define ctype_other 102
+ #define ctype_eof 103
+ /* Special characters with no \xxx representation */
+ #define char_NULL 0
+ #define char_VT 013			/* ^K, vertical tab */
+ #define char_DOS_EOF 032		/* ^Z */


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/sstorei.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/sstorei.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/sstorei.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,36 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* sstorei.h */
+ /* Fast assignment macros */
+ 
+ /* See store.h for a discussion of the purpose of the following. */
+ 
+ /* Here is where we check for getting around Turbo C's inefficiencies. */
+ #ifdef __MSDOS__
+ 	/* s_store_* are in-line assembly code */
+ /* This is a separate file so that other compilers don't have to */
+ /* deal with Turbo C's #pragma directive. */
+ #  include "dosstore.h"
+ #else
+ 	/* s_store_* are simple assignment */
+ #  define s_store_i(pto,pfrom) (*(pto) = *(pfrom))
+ #  define s_store_b(pto,ito,pfrom,ifrom) ((pto)[ito] = (pfrom)[ifrom])
+ #  define s_store_r(ptr,ito,ifrom) ((ptr)[ito] = (ptr)[ifrom])
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/state.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/state.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/state.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,37 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* state.h */
+ /* GhostScript graphics state definition */
+ 
+ /* Note that from the interpreter's point of view, */
+ /* the graphics state is opaque, i.e. the interpreter is */
+ /* just another client of the library. */
+ 
+ /* The interpreter requires additional items in the graphics state: */
+ typedef struct int_state_s int_state;
+ struct int_state_s {
+ 	int_state *saved;		/* previous int_state from gsave */
+ 	ref screen_proc;		/* halftone screen procedure */
+ 	ref transfer;			/* gray transfer procedure */
+ 	ref show_proc;			/* device show procedure */
+ 	ref font;			/* font object (dictionary) */
+ };
+ extern int_state istate;
+ extern gs_state *igs;


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/statusd.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/statusd.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/statusd.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,98 ----
+ %    Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+ %    Distributed by Free Software Foundation, Inc.
+ %
+ % This file is part of Ghostscript.
+ %
+ % Ghostscript is distributed in the hope that it will be useful, but
+ % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ % to anyone for the consequences of using it or for whether it serves any
+ % particular purpose or works at all, unless he says so in writing.  Refer
+ % to the Ghostscript General Public License for full details.
+ %
+ % Everyone is granted permission to copy, modify and redistribute
+ % Ghostscript, but only under the conditions described in the Ghostscript
+ % General Public License.  A copy of this license is supposed to have been
+ % given to you along with Ghostscript so you can know your rights and
+ % responsibilities.  It should be in a file named COPYING.  Among other
+ % things, the copyright notice and this notice must be preserved on all
+ % copies.
+ 
+ % This file provides a dummy 'statusdict' and 'serverdict',
+ % and a few of the other LaserWriter operators, for the benefit of
+ % PostScript programs that think they are running on a LaserWriter.
+ 
+ systemdict begin
+ 
+  /letter {statusdict begin 0 setpagetype end} def
+  /note {statusdict begin 1 setpagetype end} def
+  /legal {} def
+  /a4 {} def			% not in original Red Book,
+  				% but apparently standard now
+ 
+  /statusdict 50 dict def
+  /serverdict 4 dict def
+ 
+ end
+ 
+ statusdict begin
+ 
+  /checkpassword {statusdict begin .password eq end} def
+  /defaulttimeouts {statusdict begin .timeouts aload pop end} def
+ %/dostartpage
+  /eescratch {pop 0} def
+  /idlefonts {statusdict begin mark .idlefonts aload pop end} def
+  /jobname () def
+ %/jobtimeout
+  /manualfeed false def
+  /manualfeedtimeout 60 def
+  /margins {statusdict begin .topmargin .leftmargin end} def
+  /pagecount {4711} def
+  /pagestackorder {false} def
+ %/pagetype
+  /prefeed false def
+  /printererror {pop pop} def
+  /printername {statusdict begin .printername exch copy end} def
+  /product (Ghostscript) def
+  /revision 20100 def
+  /sccbatch {pop 9600 0} def
+  /sccinteractive {pop 9600 0} def
+  /setdefaulttimeouts {statusdict begin .timeouts astore pop end} def
+  /setdostartpage {statusdict exch /dostartpage exch put} def
+  /seteescratch {pop pop} def
+  /setidlefonts {] statusdict exch /.idlefonts exch put} def
+  /setjobtimeout {statusdict exch /jobtimeout exch put} def
+  /setmargins
+   {statusdict begin /.lmargin exch def /.topmargin exch def end} def
+  /setpagetype {statusdict exch /pagetype exch put} def
+  /setpassword
+   {exch checkpassword
+     {statusdict exch /.password exch put true}
+     {pop false}
+    ifelse} def
+  /setprintername
+   {dup length string copy statusdict exch /printername exch put} def
+  /setsccbatch {pop pop pop} def
+  /setsccinteractive {pop pop pop} def
+  /waittimeout 300 def
+ 
+ /.password 0 def
+ /.timeouts [0 60 30] def
+ true setdostartpage
+ mark setidlefonts
+ 0 setjobtimeout
+ 0 0 setmargins
+ 0 setpagetype
+ product setprintername
+ 
+ end	% statusdict
+ 
+ % The following contents of serverdict are a complete guess,
+ % based on some observed LaserWriter boilerplate.
+ 
+ serverdict begin
+ 
+  /execjob { } def
+  /exitserver { clear stop } def
+  /setrealdevice { } def
+ 
+ end	% serverdict


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/std.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/std.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/std.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,219 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* std.h */
+ /* Standard definitions for Aladdin Enterprises code */
+ 
+ /*
+  * Here we deal with the vagaries of various C compilers.  We assume that:
+  *	ANSI-standard Unix compilers define __STDC__.
+  *	Turbo C defines __MSDOS__.
+  *	Microsoft C defines MSDOS.
+  * Also, not used much here, but used in other header files, we assume:
+  *	Unix System V environments define USG or SYSV.
+  *	  (GNU software uses the former, non-GNU tends to use the latter.)
+  *	VMS systems define VMS.
+  *	bsd 4.2 or 4.3 systems define BSD4_2.
+  *	POSIX-compliant environments define _POSIX_SOURCE.
+  *
+  * We make fairly heroic efforts to confine all uses of these flags to
+  * header files, and never to use them in code.
+  */
+ 
+ #ifdef __STDC__
+ #  define STDC_OR_MSDOS /* */
+ #endif
+ #ifdef __MSDOS__
+ #  define STDC_OR_MSDOS /* */
+ #endif
+ 
+ /* Recognize USG and SYSV as synonyms.  GNU software uses the former, */
+ /* non-GNU tends to use the latter.  We use the latter. */
+ #ifdef USG
+ #  define SYSV /* */
+ #endif
+ 
+ /* Disable 'const' if the compiler can't handle it. */
+ #ifndef STDC_OR_MSDOS
+ #  define const /* */
+ #endif
+ 
+ /* Disable MS-DOS specialized pointer types on non-MS-DOS systems. */
+ #ifndef __MSDOS__
+ #  define near /* */
+ #  define far /* */
+ #  define huge /* */
+ #  define _cs /* */
+ #  define _ds /* */
+ /* _es is never safe to use */
+ #  define _ss /* */
+ #endif
+ 
+ /* Miscellaneous types */
+ typedef unsigned char byte;
+ typedef unsigned char uchar;
+ typedef unsigned short ushort;
+ typedef unsigned int uint;
+ typedef unsigned long ulong;
+ 
+ /* Maximum values for the unsigned types. */
+ /* The "+0" is to get around apparent bugs in the UTek compiler. */
+ #define max_uchar ((uchar)0xff + (uchar)0)
+ #define max_ushort ((ushort)0xffff + (ushort)0)
+ #define max_uint ((uint)0xffffffff + (uint)0)
+ #define max_ulong ((ulong)0xffffffffL + (ulong)0)
+ 
+ /* Define a reliable arithmetic right shift. */
+ #if (-2 >> 1) == -1
+ #  define arith_rshift(x,n) ((x) >> (n))
+ #else
+ #  define arith_rshift(x,n) ((x) < 0 ? ~(~(x) >> (n)) : (x) >> (n))
+ #endif
+ 
+ /* The type to be used for comparing pointers for order (<, >=, etc.). */
+ /* Turbo C large model doesn't compare pointers per se correctly. */
+ #ifdef __MSDOS__
+ typedef unsigned long ptr_ord_t;
+ #else
+ typedef char *ptr_ord_t;
+ #endif
+ 
+ /* In case stdio.h doesn't have these: */
+ #ifndef min
+ #  define min(a, b) ((a) < (b) ? (a) : (b))
+ #endif
+ #ifndef max
+ #  define max(a, b) ((a) > (b) ? (a) : (b))
+ #endif
+ 
+ /* math.h is different for Turbo and Unix.... */
+ #ifndef M_PI
+ #  ifdef PI
+ #    define M_PI PI
+ #  else
+ #    define M_PI 3.14159265358979324
+ #  endif
+ #endif
+ 
+ /* VMS doesn't have the unlink system call.  Use delete instead. */
+ #ifdef VMS
+ #  define unlink(fname) delete(fname)
+ #endif
+ 
+ /* K&R specifies that float parameters get converted to double. */
+ /* Most compilers allow a formal parameter to be declared float, */
+ /* and treat it as though it had been declared double; however, */
+ /* Turbo C (and perhaps the ANSI standard) doesn't allow this. */
+ /* Pending a deeper understanding of this issue, we define a */
+ /* special type for float parameters. */
+ #ifdef __STDC__
+ typedef double floatp;
+ #else
+ typedef float floatp;
+ #endif
+ 
+ /* If we are debugging, make all static variables and procedures public */
+ /* so they get passed through the linker. */
+ #ifdef NOPRIVATE
+ # define private /* */
+ #else
+ # define private static
+ #endif
+ 
+ /* Macros for argument templates.  ANSI has these, as does Turbo C, */
+ /* but most Unix compilers don't. */
+ 
+ #ifdef STDC_OR_MSDOS
+ # define P0() void
+ # define P1(t1) t1
+ # define P2(t1,t2) t1,t2
+ # define P3(t1,t2,t3) t1,t2,t3
+ # define P4(t1,t2,t3,t4) t1,t2,t3,t4
+ # define P5(t1,t2,t3,t4,t5) t1,t2,t3,t4,t5
+ # define P6(t1,t2,t3,t4,t5,t6) t1,t2,t3,t4,t5,t6
+ # define P7(t1,t2,t3,t4,t5,t6,t7) t1,t2,t3,t4,t5,t6,t7
+ # define P8(t1,t2,t3,t4,t5,t6,t7,t8) t1,t2,t3,t4,t5,t6,t7,t8
+ # define P9(t1,t2,t3,t4,t5,t6,t7,t8,t9) t1,t2,t3,t4,t5,t6,t7,t8,t9
+ # define P10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10)\
+    t1,t2,t3,t4,t5,t6,t7,t8,t9,t10
+ # define P11(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11)\
+    t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11
+ # define P12(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12)\
+    t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12
+ #else
+ # define P0() /* */
+ # define P1(t1) /* */
+ # define P2(t1,t2) /* */
+ # define P3(t1,t2,t3) /* */
+ # define P4(t1,t2,t3,t4) /* */
+ # define P5(t1,t2,t3,t4,t5) /* */
+ # define P6(t1,t2,t3,t4,t5,t6) /* */
+ # define P7(t1,t2,t3,t4,t5,t6,t7) /* */
+ # define P8(t1,t2,t3,t4,t5,t6,t7,t8) /* */
+ # define P9(t1,t2,t3,t4,t5,t6,t7,t8,t9) /* */
+ # define P10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) /* */
+ # define P11(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11) /* */
+ # define P12(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12) /* */
+ #endif
+ 
+ /* Types for client-supplied allocate and free procedures. */
+ /* For accountability, debugging, and error messages, */
+ /* we pass an identifying string to alloc and free. */
+ /* Note that the arguments are like calloc, not like malloc, */
+ /* but an alloc procedure doesn't clear the block. */
+ typedef char *(*proc_alloc_t)(P3(unsigned num_elements, unsigned element_size, char *client_name));
+ typedef void (*proc_free_t)(P4(char *data, unsigned num_elements, unsigned element_size, char *client_name));
+ 
+ /* Standard error printing macros */
+ /* Use eprintf for ordinary error messages, */
+ /* dprintf for messages that should include debugging info. */
+ 
+ #ifdef PROGRAM_NAME
+ #  define _epn fprintf(stderr, PROGRAM_NAME),
+ #else
+ #  define _epn /* */
+ #endif
+ 
+ #define eprintf(str)\
+   (_epn fprintf(stderr, str))
+ #define eprintf1(str,arg1)\
+   (_epn fprintf(stderr, str, arg1))
+ #define eprintf2(str,arg1,arg2)\
+   (_epn fprintf(stderr, str, arg1, arg2))
+ #define eprintf3(str,arg1,arg2,arg3)\
+   (_epn fprintf(stderr, str, arg1, arg2, arg3))
+ 
+ #define _epfl /* */
+ #ifdef __FILE__
+ #  ifdef __LINE__
+ #    undef _epfl
+ #    define _epfl fprintf(stderr, "%s(%d): ", __FILE__, __LINE__),
+ #  endif
+ #endif
+ 
+ #define _epd _epn _epfl
+ 
+ #define dprintf(str)\
+   (_epd fprintf(stderr, str))
+ #define dprintf1(str,arg1)\
+   (_epd fprintf(stderr, str, arg1))
+ #define dprintf2(str,arg1,arg2)\
+   (_epd fprintf(stderr, str, arg1, arg2))
+ #define dprintf3(str,arg1,arg2,arg3)\
+   (_epd fprintf(stderr, str, arg1, arg2, arg3))


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/store.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/store.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/store.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,118 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* store.h */
+ /* Assignment macros */
+ 
+ /*
+  * Macros for storing a ref.  We use macros for storing into objects,
+  * since this is what a reference counting storage manager needs to know.
+  * We also use macros for other ref assignments, because (as it happens)
+  * Turbo C generates pretty awful code for doing this.
+  *
+  * The potentially reference counted macro names all have the form
+  *	<place><new_type>(place_to_store, new_value)
+  * <place> may be either
+  *	store (for an unrestricted store)
+  *	n_store (for storing into a new object, or when the old contents
+  *	  are known not to be a pointer-type ref)
+  * <new_type> and new_value are chosen from the following alternatives:
+  *	_i		POINTER TO arbitrary ref
+  *	_i_n		POINTER TO non-pointer-type ref
+  *	(nothing)	arbitrary ref
+  *	_n		non-pointer-type ref
+  *	_tv		type, value field name, value
+  *			  (only for scalars, which don't have attributes)
+  *	_tav		type, attributes, value field name, value
+  *	_tasv		type, attributes, size, value field name, value
+  *	_int		integer value
+  *	_real		float value
+  *
+  * For _tav and _tasv, we must store the value first, because sometimes
+  * it depends on the contents of the place being stored into.
+  * Note that n_store_tav and n_store_tasv are only needed if
+  * the type being stored is a pointer type.
+  *
+  * In addition, we define make_xxx macros for making refs on the stack,
+  * and s_store[_*](place_to_store, new_value) for stores to the stack
+  * or to local variables.  For s_store_*, new_value must be a simple
+  * variable because of the ref_assign macro (see below).
+  *
+  * Note that the storage manager is not actually implemented yet,
+  * so none of the macros do anything special.
+  */
+ 
+ /*
+  * Here is where we check for getting around Turbo C's inefficiencies.
+  */
+ #ifdef __MSDOS__
+ 	/* ref_assign is an assembly code procedure */
+ extern	void	ref_assign(P2(ref *, ref *));
+ #else
+ 	/* ref_assign is a macro */
+ #  define ref_assign(pto,pfrom) (*(pto) = *(pfrom))
+ #endif
+ 
+ #define n_store_i(pto,pfrom) ref_assign(pto,pfrom)
+ #define n_store_i_n(pto,pfrom) ref_assign(pto,pfrom)
+ #define n_store(pref,newref) (*(pref)=(newref))
+ #define n_store_n(pref,newref) (*(pref)=(newref))
+ #define store_i(pto,pfrom) ref_assign(pto,pfrom)
+ #define store_i_n(pto,pfrom) ref_assign(pto,pfrom)
+ #define store(pref,newref) n_store(pref,newref)
+ #define store_n(pref,newref) n_store(pref,newref)
+ 
+ #define n_store_tv(pref,newtype,valfield,newvalue)\
+   ((pref)->value.valfield = (newvalue),\
+    r_set_type(pref, newtype))
+ #define store_tv(pref,t,vf,v) n_store_tv(pref,t,vf,v)
+ #define make_tv(pref,t,vf,v) n_store_tv(pref,t,vf,v)
+ 
+ #define n_store_tav(pref,newtype,newattrs,valfield,newvalue)\
+   ((pref)->value.valfield = (newvalue),\
+    r_set_type_attrs(pref, newtype, newattrs))
+ #define store_tav(pref,t,a,vf,v) n_store_tav(pref,t,a,vf,v)
+ #define make_tav(pref,t,a,vf,v) n_store_tav(pref,t,a,vf,v)
+ 
+ #define n_store_tasv(pref,newtype,newattrs,newsize,valfield,newvalue)\
+   (n_store_tav(pref,newtype,newattrs,valfield,newvalue),\
+    (pref)->size = (newsize))
+ #define store_tasv(pref,t,a,s,vf,v) n_store_tasv(pref,t,a,s,vf,v)
+ #define make_tasv(pref,t,a,s,vf,v) n_store_tasv(pref,t,a,s,vf,v)
+ 
+ #define make_bool(pref,bval)\
+   n_store_tv(pref,t_boolean,index,bval)
+ #define make_false(pref) make_bool(pref,0)
+ #define make_true(pref) make_bool(pref,1)
+ 
+ #define n_store_int(pref,ival)\
+   n_store_tv(pref,t_integer,intval,ival)
+ #define store_int(pref,ival) n_store_int(pref,ival)
+ #define make_int(pref,ival) n_store_int(pref,ival)
+ 
+ #define make_mark(pref) make_tv(pref, t_mark, intval, 0)
+ 
+ #define make_null(pref) make_tv(pref, t_null, intval, 0)
+ 
+ #define n_store_real(pref,rval)\
+   n_store_tv(pref,t_real,realval,rval)
+ #define store_real(pref,rval) n_store_real(pref,rval)
+ #define make_real(pref,rval) n_store_real(pref,rval)
+ 
+ #define s_store(pref,newref) (*(pref)=(newref))


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/stream.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/stream.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/stream.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,404 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* stream.c */
+ /* Stream package for GhostScript interpreter */
+ #include <stdio.h>
+ #include "memory_.h"
+ #include "std.h"
+ #include "stream.h"
+ #include "scanchar.h"
+ #include "gxfixed.h"			/* for gstype1.h */
+ #include "gstype1.h"
+ 
+ /* Forward declarations */
+ 	/* Generic */
+ private int
+   snull(P1(stream *)),
+   snoavailable(P2(stream *, long *));
+ 	/* Strings */
+ private int
+   ssread(P1(stream *)),
+   sswrite(P2(stream *, byte)),
+   ssavailable(P2(stream *, long *)),
+   ssseek(P2(stream *, long));
+ private void
+   ssinit(P4(stream *, byte *, uint, stream_procs *));
+ 	/* Files */
+ private int
+   sfread(P1(stream *)),
+   sfavailable(P2(stream *, long *)),
+   srseek(P2(stream *, long)),
+   srclose(P1(stream *));
+ private int
+   sfwrite(P2(stream *, byte)),
+   swseek(P2(stream *, long)),
+   swflush(P1(stream *)),
+   swclose(P1(stream *));
+ private void
+   sfinit(P5(stream *, FILE *, byte *, uint, stream_procs *));
+ 	/* decrypting */
+ private int
+   sxread(P1(stream *)),
+   sxavailable(P2(stream *, long *));
+ 
+ /* ------ String streams ------ */
+ 
+ /* Initialize a stream for reading a string. */
+ void
+ sread_string(register stream *s, byte *ptr, uint len)
+ {	static stream_procs p =
+ 		{ ssread, NULL, ssavailable, ssseek, snull, snull };
+ 	ssinit(s, ptr, len, &p);
+ 	s->writing = 0;
+ }
+ /* Handle end-of-buffer when reading from a string. */
+ private int
+ ssread(stream *s)
+ {	s->cptr = s->endptr;
+ 	return EOFC;
+ }
+ /* Return the number of available bytes when reading from a string. */
+ private int
+ ssavailable(stream *s, long *pl)
+ {	*pl = sbufavailable(s);
+ 	if ( *pl == 0 ) *pl = -1;	/* EOF */
+ 	return 0;
+ }
+ 
+ /* Initialize a stream for writing a string. */
+ void
+ swrite_string(register stream *s, byte *ptr, uint len)
+ {	static stream_procs p =
+ 		{ NULL, sswrite, snoavailable, ssseek, snull, snull };
+ 	ssinit(s, ptr, len, &p);
+ 	s->writing = 1;
+ }
+ /* Handle end-of-buffer when writing a string. */
+ private int
+ sswrite(stream *s, byte c)
+ {	s->cptr = s->endptr;
+ 	return EOFC;
+ }
+ 
+ /* Seek in a string.  Return 0 if OK, -1 if not. */
+ private int
+ ssseek(register stream *s, long pos)
+ {	if ( pos < 0 || pos > s->bsize ) return -1;
+ 	s->cptr = s->cbuf + pos - 1;
+ 	return 0;
+ }
+ 
+ /* Private initialization */
+ private void
+ ssinit(register stream *s, byte *ptr, uint len, stream_procs *p)
+ {	s->cbuf = ptr;
+ 	s->cptr = ptr - 1;
+ 	s->endptr = s->cptr + len;
+ 	s->bsize = len;
+ 	s->eof = 1;			/* this is all there is */
+ 	s->position = 0;
+ 	s->procs = *p;
+ }
+ 
+ /* ------ File streams ------ */
+ 
+ /* Initialize a stream for reading an OS file. */
+ void
+ sread_file(register stream *s, FILE *file, byte *buf, uint len)
+ {	static stream_procs p =
+ 		{ sfread, NULL, sfavailable, srseek, snull, srclose };
+ 	sfinit(s, file, buf, len, &p);
+ 	s->writing = 0;
+ 	s->position = (file == stdin ? -1 : 0);
+ }
+ /* Procedures for reading from a file */
+ private int
+ sfread(register stream *s)
+ {	int nread;
+ 	if ( s->eof )
+ 	   {	s->cptr = s->endptr;
+ 		return EOFC;
+ 	   }
+ 	if ( s->position >= 0 )		/* file is positionable */
+ 		s->position = ftell(s->file);
+ 	nread = fread(s->cbuf, 1, s->bsize, s->file);
+ 	s->cptr = s->cbuf - 1;
+ 	s->eof = feof(s->file);
+ 	if ( nread > 0 )
+ 	   {	s->endptr = s->cptr + nread;
+ 		return (int)*++(s->cptr);	/* don't understand why the cast is needed.... */
+ 	   }
+ 	else if ( nread == 0 )
+ 	   {	s->endptr = s->cptr;
+ 		s->eof = 1;
+ 		return EOFC;
+ 	   }
+ 	else				/* error, now what?? */
+ 	   {	s->endptr = s->cptr;
+ 		return 0;
+ 	   }
+    }
+ private int
+ sfavailable(register stream *s, long *pl)
+ {	*pl = sbufavailable(s);
+ 	if ( sseekable(s) )
+ 	   {	long pos, end;
+ 		pos = ftell(s->file);
+ 		if ( fseek(s->file, 0L, 2) ) return -1;
+ 		end = ftell(s->file);
+ 		if ( fseek(s->file, pos, 0) ) return -1;
+ 		*pl += end - pos;
+ 		if ( *pl == 0 ) *pl = -1;	/* EOF */
+ 	   }
+ 	else
+ 	   {	if ( *pl == 0 && feof(s->file) ) *pl = -1;	/* EOF */
+ 	   }
+ 	return 0;
+ }
+ private int
+ srseek(register stream *s, long pos)
+ {	uint end = s->endptr - s->cbuf + 1;
+ 	long offset = pos - s->position;
+ 	if ( offset >= 0 && offset <= end )
+ 	   {	/* Staying within the same buffer */
+ 		s->cptr = s->cbuf + offset - 1;
+ 		return 0;
+ 	   }
+ 	if ( fseek(s->file, pos, 0) != 0 )
+ 		return -1;
+ 	s->endptr = s->cptr = s->cbuf - 1;
+ 	s->eof = 0;
+ 	return 0;
+ }
+ private int
+ srclose(stream *s)
+ {	return fclose(s->file);
+ }
+ 
+ /* Initialize a stream for writing an OS file. */
+ void
+ swrite_file(register stream *s, FILE *file, byte *buf, uint len)
+ {	static stream_procs p =
+ 		{ NULL, sfwrite, snoavailable, swseek, swflush, swclose };
+ 	sfinit(s, file, buf, len, &p);
+ 	s->writing = 1;
+ 	s->position = (file == stdout || file == stderr ? -1 : 0);
+    }
+ /* Procedures for writing on a file */
+ #define fwrite_buf(s)\
+   fwrite(s->cbuf, 1, (uint)(s->cptr + 1 - s->cbuf), s->file)
+ private int
+ sfwrite(register stream *s, byte c)
+ {	fwrite_buf(s);
+ 	if ( s->position >= 0 )		/* file is positionable */
+ 		s->position = ftell(s->file);
+ 	s->cptr = s->cbuf - 1;
+ 	s->endptr = s->cptr + s->bsize;
+ 	return sputc(s, c);
+ }
+ private int
+ swseek(stream *s, long pos)
+ {	/* Output files are not positionable */
+ 	return -1;
+ }
+ private int
+ swflush(register stream *s)
+ {	int result = fwrite_buf(s);
+ 	fflush(s->file);
+ 	s->position = ftell(s->file);
+ 	s->cptr = s->cbuf - 1;
+ 	s->endptr = s->cptr + s->bsize;
+ 	return result;
+ }
+ private int
+ swclose(register stream *s)
+ {	fwrite_buf(s);
+ 	return fclose(s->file);
+ }
+ 
+ /* Private initialization */
+ private void
+ sfinit(register stream *s, FILE *file, byte *buf, uint len, stream_procs *p)
+ {	s->cbuf = buf;
+ 	s->cptr = buf - 1;
+ 	s->bsize = len;
+ 	s->file = file;
+ 	s->endptr = s->cptr;
+ 	s->eof = 0;
+ 	s->procs = *p;
+ }
+ 
+ /* ------ Encrypted streams ------ */
+ 
+ /* Initialize a stream for reading and decrypting another stream. */
+ /* Decrypting streams are not positionable. */
+ void
+ sread_decrypt(register stream *s, stream *xs, byte *buf, uint len,
+   ushort /*crype_state*/ state)
+ {	static stream_procs p =
+ 		{ sxread, NULL, sxavailable, NULL, snull, snull };
+ 	sfinit(s, (FILE *)NULL, buf, len, &p);
+ 	s->writing = 0;
+ 	s->position = -1;		/* not positionable */
+ 	s->strm = xs;
+ 	s->cstate = state;
+ 	s->odd = -1;
+ }
+ /* Refill the buffer of a decrypting stream. */
+ private int
+ sxread(register stream *s)
+ {	byte *buf = s->cbuf;
+ 	uint nread;
+ 	s->cptr = buf - 1;
+ top:	nread = sgets(s->strm, buf, s->bsize);
+ 	if ( nread == 0 )		/* end of stream */
+ 	   {	s->endptr = s->cptr;
+ 		s->eof = 1;
+ 		return EOFC;
+ 	   }
+ 	else
+ 	   {	/* Decrypt the buffer.  The buffer consists of information */
+ 		/* in the form suitable for readhexstring. */
+ 		stream sst;
+ 		sread_string(&sst, buf, nread);
+ 		sreadhex(&sst, buf, nread, &nread, &s->odd);
+ 		if ( nread == 0 ) goto top;	/* try again */
+ 		gs_type1_decrypt(buf, buf, nread, (crypt_state *)&s->cstate);
+ 		s->endptr = s->cptr + nread;
+ 		return (int)*++(s->cptr);	/* don't understand why the cast is needed.... */
+ 	   }
+ }
+ /* Estimate the number of remaining bytes in a decrypting stream. */
+ private int
+ sxavailable(stream *s, long *pl)
+ {	if ( savailable(s->strm, pl) < 0 ) return -1;
+ 	if ( *pl >= 0 ) *pl /= 2;
+ 	return 0;
+ }
+ 
+ /* ------ Generic procedures ------ */
+ 
+ /* Implement a stream procedure as a no-op. */
+ private int
+ snull(stream *s)
+ {	return 0;
+ }
+ 
+ /* Indicate an error when asked for available input bytes. */
+ private int
+ snoavailable(stream *s, long *pl)
+ {	return -1;
+ }
+ 
+ /* Push back a character onto a (read) stream. */
+ /* Return 0 on success, -1 on failure. */
+ int
+ sungetc(register stream *s, byte c)
+ {	if ( s->writing || s->cptr < s->cbuf ) return -1;
+ 	*(s->cptr)-- = c;
+ 	return 0;
+ }
+ 
+ /* Read a string from a stream. */
+ /* Return the number of bytes read. */
+ uint
+ sgets(register stream *s, byte *str, uint rlen)
+ {	uint len = rlen;
+ 	while ( len > 0 )
+ 	   {	uint count = sbufavailable(s);
+ 		if ( count > 0 )
+ 		   {	if ( count > len ) count = len;
+ 			memcpy(str, s->cptr + 1, count);
+ 			s->cptr += count;
+ 			str += count;
+ 			len -= count;
+ 		   }
+ 		else
+ 		   {	int ch = sgetc(s);
+ 			if ( s->eof ) return rlen - len;
+ 			*str++ = ch;
+ 			len--;
+ 		   }
+ 	   }
+ 	return rlen;
+ }
+ 
+ /* Write a string on a stream. */
+ /* Return the number of bytes written. */
+ uint
+ sputs(register stream *s, byte *str, uint wlen)
+ {	uint len = wlen;
+ 	while ( len > 0 )
+ 	   {	uint count = sbufavailable(s);
+ 		if ( count > 0 )
+ 		   {	if ( count > len ) count = len;
+ 			memcpy(s->cptr + 1, str, count);
+ 			s->cptr += count;
+ 			str += count;
+ 			len -= count;
+ 		   }
+ 		else
+ 		   {	byte ch = *str++;
+ 			sputc(s, ch);
+ 			if ( s->eof ) return wlen - len;
+ 			len--;
+ 		   }
+ 	   }
+ 	return wlen;
+ }
+ 
+ /* Read a hex string from a stream. */
+ /* Skip all characters other than hex digits. */
+ /* Answer 1 if we reached end-of-file before filling the string, */
+ /* 0 if we filled the string first, or <0 on error. */
+ /* *odd_digit should be -1 initially: */
+ /* if an odd number of hex digits was read, *odd_digit is set to */
+ /* the odd digit value, otherwise *odd_digit is set to -1. */
+ int
+ sreadhex(register stream *s, byte *str, uint rlen, uint *nread,
+   int *odd_digit)
+ {	byte *ptr = str;
+ 	byte *limit = ptr + rlen;
+ 	byte val1 = (byte)*odd_digit;
+ 	byte val2;
+ #ifdef __MSDOS__
+ /* MS-DOS can't put pointers in registers.... */
+ #	define decoder scan_char_decoder
+ #else
+ 	register byte *decoder = scan_char_decoder;
+ #endif
+ 	if ( rlen == 0 )
+ 	   {	*nread = 0;
+ 		return 0;
+ 	   }
+ 	if ( val1 <= 0xf ) goto d2;
+ d1:	while ( (val1 = decoder[sgetc(s)]) > 0xf )
+ 	   {	if ( val1 == ctype_eof ) { *odd_digit = -1; goto ended; }
+ 	   }
+ d2:	while ( (val2 = decoder[sgetc(s)]) > 0xf )
+ 	   {	if ( val2 == ctype_eof ) { *odd_digit = val1; goto ended; }
+ 	   }
+ 	*ptr++ = (val1 << 4) + val2;
+ 	if ( ptr < limit ) goto d1;
+ 	*nread = rlen;
+ 	return 0;
+ ended:	*nread = ptr - str;
+ 	return 1;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/stream.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/stream.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/stream.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,115 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* stream.h */
+ /* Definitions for standard stream package for GhostScript */
+ /* Requires stdio.h */
+ 
+ /* Note that the stream package works with bytes, not chars. */
+ /* This is to ensure unsigned representation on all systems. */
+ /* A stream can only be read or written, not both. */
+ /* Note also that the read procedure returns an int, */
+ /* not a char or a byte, because EOFC is -1. */
+ typedef struct stream_s stream;
+ typedef struct {
+ 	int (*read)(P1(stream *));
+ 	int (*write)(P2(stream *, byte));
+ 	int (*available)(P2(stream *, long *));
+ 	int (*seek)(P2(stream *, long));
+ 	int (*flush)(P1(stream *));
+ 	int (*close)(P1(stream *));
+ } stream_procs;
+ struct stream_s {
+ 	byte *cptr;			/* pointer to last byte */
+ 					/* read or written */
+ 	byte *endptr;			/* pointer to last byte */
+ 					/* containing data for reading, */
+ 					/* or to be filled for writing */
+ 	byte *cbuf;			/* base of buffer */
+ 	uint bsize;			/* size of buffer */
+ 	char writing;			/* 0 if reading, 1 if writing */
+ 	char eof;			/* non-zero if at EOF when buffer */
+ 					/* becomes empty */
+ 	long position;			/* file position of beginning of */
+ 					/* buffer, -1 means not seekable */
+ 	stream_procs procs;
+ 	int num_format;			/* format for Level 2 */
+ 					/* encoded number reader */
+ 					/* (only used locally) */
+ 	/*
+ 	 * If were were able to program in a real object-oriented style, 
+ 	 * the remaining data would be per-subclass.  It's just too much
+ 	 * of a nuisance to do this in C, so we allocate space for the
+ 	 * private data of ALL subclasses.
+ 	 */
+ 	/* The following is for file streams. */
+ 	FILE *file;			/* file handle for C library */
+ 	/* The following are for decrypting streams. */
+ 	stream *strm;
+ 	ushort cstate;			/* encryption state */
+ 	int odd;			/* odd hex digit */
+ };
+ 
+ /* Stream functions.  Some of these are macros -- beware. */
+ /* Note that there is no eof test -- instead, do a sgetc, */
+ /* compare against EOFC, and then do sputback if not at eof. */
+ /* Also note that unlike the C stream library, */
+ /* ALL stream procedures take the stream as the first argument. */
+ 
+ /* Following are valid for all streams. */
+ /* flush is a no-op for read streams. */
+ /* close is a no-op for non-file streams. */
+ #define sseekable(s) ((s)->position >= 0)
+ #define savailable(s,pl) (*(s)->procs.available)(s,pl)
+ #define sflush(s) (*(s)->procs.flush)(s)
+ #define sclose(s) (*(s)->procs.close)(s)
+ 
+ /* Following are only valid for read streams. */
+ #define sgetc(s)\
+   ((s)->cptr < (s)->endptr ? *++((s)->cptr) : (*(s)->procs.read)(s))
+ extern uint sgets(P3(stream *, byte *, uint));
+ extern int sreadhex(P5(stream *, byte *, uint, uint *, int *));
+ extern int sungetc(P2(stream *, byte));	/* -1 on error, 0 if OK */
+ #define sputback(s) ((s)->cptr--)
+ 
+ /* Following are only valid for write streams. */
+ #define sputc(s,c)\
+   ((s)->cptr < (s)->endptr ? ((int)(*++((s)->cptr)=(c))) :\
+    (*(s)->procs.write)((s),(c)))
+ extern uint sputs(P3(stream *, byte *, uint));
+ 
+ /* Following are only valid for positionable streams. */
+ #define stell(s) ((s)->cptr + 1 - (s)->cbuf + (s)->position)
+ #define sseek(s,pos) (*(s)->procs.seek)(s,(long)(pos))
+ 
+ /* Following are for high-performance clients. */
+ /* bufptr points to the next item, bufend points beyond the last item. */
+ #define sbufptr(s) ((s)->cptr + 1)
+ #define sbufend(s) ((s)->endptr + 1)
+ #define ssetbufptr(s,ptr) ((s)->cptr = (ptr) - 1)
+ #define sbufavailable(s) ((s)->endptr - (s)->cptr)
+ 
+ #define EOFC (-1)
+ 
+ /* Stream creation procedures */
+ extern	void	sread_string(P3(stream *, byte *, uint)),
+ 		swrite_string(P3(stream *, byte *, uint));
+ extern	void	sread_file(P4(stream *, FILE *, byte *, uint)),
+ 		swrite_file(P4(stream *, FILE *, byte *, uint));
+ extern	void	sread_decrypt(P5(stream *, stream *, byte *, uint, ushort));


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/string_.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/string_.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/string_.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,39 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* string.h */
+ /* Generic substitute for Unix string.h */
+ 
+ #ifdef BSD4_2
+ #  include <strings.h>
+ #  define strchr index
+ #else
+ #  ifdef VMS
+ 	extern char *strcat(), *strchr(), *strcpy(), *strupr();
+ 	extern int strcmp(), strlen(), strncmp();
+ #  else
+ #    ifdef __MSDOS__
+ #      undef memset			/* see memory_.h */
+ #      include <string.h>
+ #      define memset(dest,chr,cnt) setmem(dest,cnt,chr)
+ #    else
+ #      include <string.h>
+ #    endif
+ #  endif
+ #endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/traceop.ps
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/traceop.ps:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/traceop.ps	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,10 ----
+ % Trace vmem usage after individual operators
+ /.traceop
+  { vmstatus exch =only ( ) print = pop flush
+    systemdict exch get exec
+  } bind def
+ /traceop
+  { dup [ exch /.traceop cvx ] cvx def
+  } bind def
+ 
+ /setcachedevice traceop


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/utrace.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/utrace.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/utrace.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,95 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* utrace.c */
+ /* Dummy tracing package for Unix C */
+ #include <stdio.h>
+ #include <setjmp.h>
+ #include "std.h"
+ #include "cframe_.h"
+ 
+ /* This file replaces trace.c for Unix and VMS. */
+ /* It has only the stack parsing functionality of trace.c -- */
+ /* the tracing procedures are stubs. */
+ 
+ char *
+ strupr(char *str)
+ {	return str;
+ }
+ 
+ /* Open the map file */
+ FILE *
+ trace_open_map(char *mapname, long *preloc)
+ {	return NULL;
+ }
+ 
+ /* Enumerate a symbol file */
+ char *
+ trace_next_symbol(char **paddr, FILE *mapf)
+ {	return NULL;
+ }
+ 
+ 
+ /* Look up a symbol in a file */
+ char *
+ trace_find_symbol(char *name, FILE *mapf)
+ {	return NULL;
+ }
+ 
+ int trace_flush_flag;
+ 
+ /* Trace a named procedure */
+ int
+ trace_name(char *name, FILE *mapf, char *arg_format, int retsize)
+ {	return -1;
+ }
+ 
+ /* Trace a procedure */
+ int
+ trace(void (*proc)(), char *name, char *arg_format, int retsize)
+ {	return -1;
+ }
+ 
+ /* ------ Stack parsing ------ */
+ 
+ /* Forward declarations */
+ char *stack_next_frame(P1(char *));
+ 
+ /* Get the address of the caller's frame */
+ char *
+ stack_top_frame()
+ {	jmp_buf buf;
+ 	setjmp(buf);			/* acquire registers */
+ 	return stack_next_frame(cstack_top_frame(buf));
+ }
+ 
+ /* Get the return address of a frame. */
+ unsigned long
+ stack_return(char *bp)
+ {	return *(unsigned long *)(bp + 16);
+ }
+ 
+ /* Get the address of the next higher frame, */
+ /* or 0 if there is none. */
+ char *
+ stack_next_frame(char *bp)
+ {	char *nbp = cstack_next_frame(bp);
+ 	if ( nbp < bp ) return 0;
+ 	return nbp;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/vmsmath.h
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/vmsmath.h:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/vmsmath.h	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,37 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* vmsmath.h */
+ /* Substitute for math.h on VAX/VMS systems */
+ 
+ /*  DEC VAX/VMS C comes with a math.h file but GNU VAX/VMS C does not */
+ #  ifndef __MATH
+ #    define __MATH
+ #    if CC$gfloat
+ #      define HUGE_VAL 8.988465674311578540726371186585e+307
+ #    else
+ #      define HUGE_VAL 1.70141183460469229e+38
+ #    endif
+      extern double acos(), asin(), atan(), atan2();
+      extern double sin(), tan(), cos();
+      extern double cosh(), sinh(), tanh();
+      extern double exp(), frexp(), ldexp(), log(), log10(), pow();
+      extern double modf(), fmod(), sqrt(), ceil(), floor();
+      extern double fabs(), cabs(), hypot();
+ #  endif


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zarith.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zarith.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zarith.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,260 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zarith.c */
+ /* Arithmetic operators for GhostScript */
+ #include "math_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ 
+ /****** NOTE: none of the arithmetic operators  ******/
+ /****** currently check for floating exceptions ******/
+ 
+ /* Macro for accessing next-to-top stack element */
+ #define opm1 (op-1)
+ /* Macros for generating non-integer cases for arithmetic operations. */
+ /* 'frob' is one of the arithmetic operators, +, -, or *. */
+ #define non_int_cases(frob,frob_equals)\
+  switch ( r_type(op) ) {\
+   default: return e_typecheck;\
+   case t_real: switch ( r_type(opm1) ) {\
+    default: return e_typecheck;\
+    case t_real: opm1->value.realval frob_equals op->value.realval; break;\
+    case t_integer: make_real(opm1, opm1->value.intval frob op->value.realval);\
+   } break;\
+   case t_integer: switch ( r_type(opm1) ) {\
+    default: return e_typecheck;\
+    case t_real: opm1->value.realval frob_equals op->value.intval; break;\
+    case t_integer:
+ #define end_cases()\
+   } }
+ 
+ /* add */
+ int
+ zadd(register ref *op)
+ {	non_int_cases(+, +=)
+ 	   {	long int2 = op->value.intval;
+ 		if ( ((opm1->value.intval += int2) ^ int2) < 0 &&
+ 		     ((opm1->value.intval - int2) ^ int2) >= 0
+ 		   )
+ 		   {	/* Overflow, convert to real */
+ 			make_real(opm1, (float)opm1->value.intval - int2);
+ 		   }
+ 	   }
+ 	end_cases()
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* div */
+ int
+ zdiv(register ref *op)
+ {	register ref *op1 = op - 1;
+ 	/* We can't use the non_int_cases macro, */
+ 	/* because we have to check explicitly for op == 0. */
+ 	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_real:
+ 		if ( op->value.realval == 0 ) return e_undefinedresult;
+ 		switch ( r_type(op1) )
+ 		   {
+ 		default: return e_typecheck;
+ 		case t_real: op1->value.realval /= op->value.realval; break;
+ 		case t_integer: make_real(op1, op1->value.intval / op->value.realval);
+ 		   }
+ 		break;
+ 	case t_integer:
+ 		if ( op->value.intval == 0 ) return e_undefinedresult;
+ 		switch ( r_type(op1) )
+ 		   {
+ 		default: return e_typecheck;
+ 		case t_real: op1->value.realval /= op->value.intval; break;
+ 		case t_integer: make_real(op1, (float)op1->value.intval / op->value.intval);
+ 		   }
+ 	   }
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* mul */
+ int
+ zmul(register ref *op)
+ {	non_int_cases(*, *=)
+ 	   {	long int1 = opm1->value.intval;
+ 		long int2 = op->value.intval;
+ 		long abs1 = (int1 >= 0 ? int1 : - int1);
+ 		long abs2 = (int2 >= 0 ? int2 : - int2);
+ 		float fprod;
+ 		if (	(abs1 > 0x7fff || abs2 > 0x7fff) &&
+ 			/* At least one of the operands is very large. */
+ 			/* Check for integer overflow. */
+ 			abs1 != 0 &&
+ 			abs2 > 0x7fffffffL / abs1 &&
+ 			/* Check for the boundary case */
+ 			(fprod = (float)int1 * int2,
+ 			 (int1 * int2 != -0x80000000L ||
+ 			 fprod != (float)-0x80000000L))
+ 		   )
+ 			make_real(opm1, fprod);
+ 		else
+ 			opm1->value.intval = int1 * int2;
+ 	   }
+ 	end_cases()
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* sub */
+ int
+ zsub(register ref *op)
+ {	non_int_cases(-, -=)
+ 	   {	long int1 = opm1->value.intval;
+ 		if ( (int1 ^ (opm1->value.intval = int1 - op->value.intval)) < 0 &&
+ 		     (int1 ^ op->value.intval) < 0
+ 		   )
+ 		   {	/* Overflow, convert to real */
+ 			make_real(opm1, (float)int1 - op->value.intval);
+ 		   }
+ 	   }
+ 	end_cases()
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* idiv */
+ int
+ zidiv(register ref *op)
+ {	/* The Red Book says this only works on integers, */
+ 	/* but implementations also accept reals. */
+ 	ref save_num;
+ 	int code;
+ 	save_num = op[-1];
+ 	code = zdiv(op);
+ 	if ( code < 0 ) return code;	/* division failed */
+ 	code = zcvi(op - 1);
+ 	if ( code < 0 )
+ 	   {	/* cvi failed, restore numerator */
+ 		op[-1] = save_num;
+ 		osp = op;		/* restore osp as well */
+ 	   }
+ 	return code;
+ }
+ 
+ /* mod */
+ int
+ zmod(register ref *op)
+ {	check_type(op[-1], t_integer);
+ 	check_type(*op, t_integer);
+ 	if ( op->value.intval == 0 ) return e_undefinedresult;
+ 	op[-1].value.intval %= op->value.intval;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* neg */
+ int
+ zneg(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_real: op->value.realval = -op->value.realval; break;
+ 	case t_integer:
+ 		if ( op->value.intval == -0x80000000L )	/* min integer */
+ 			make_real(op, -(float)-0x80000000L);
+ 		else
+ 			op->value.intval = -op->value.intval;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* ceiling */
+ int
+ zceiling(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_real: op->value.realval = ceil(op->value.realval);
+ 	case t_integer: ;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* floor */
+ int
+ zfloor(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_real: op->value.realval = floor(op->value.realval);
+ 	case t_integer: ;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* round */
+ int
+ zround(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_real: op->value.realval = floor(op->value.realval + 0.5);
+ 	case t_integer: ;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* truncate */
+ int
+ ztruncate(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_real:
+ 		op->value.realval =
+ 			(op->value.realval < 0.0 ?
+ 				ceil(op->value.realval) :
+ 				floor(op->value.realval));
+ 	case t_integer: ;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zarith_op_init()
+ {	static op_def my_defs[] = {
+ 		{"2add", zadd},
+ 		{"1ceiling", zceiling},
+ 		{"2div", zdiv},
+ 		{"2idiv", zidiv},
+ 		{"1floor", zfloor},
+ 		{"2mod", zmod},
+ 		{"2mul", zmul},
+ 		{"1neg", zneg},
+ 		{"1round", zround},
+ 		{"2sub", zsub},
+ 		{"1truncate", ztruncate},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zarray.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zarray.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zarray.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,109 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zarray.c */
+ /* Array operators for GhostScript */
+ #include "memory_.h"
+ #include "ghost.h"
+ #include "alloc.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ #include "sstorei.h"
+ 
+ /* The generic operators (copy, get, put, getinterval, putinterval, */
+ /* length, and forall) are implemented in zgeneric.c. */
+ 
+ /* Forward references */
+ int make_array(P4(register ref *, int, int, char *));
+ 
+ /* array */
+ int
+ zarray(register ref *op)
+ {	int code = make_array(op, t_array, a_all, "array");
+ 	if ( code < 0 ) return code;
+ 	   {	/* Fill the array with nulls. */
+ 		ushort size = op->size;
+ 		ref *abody = op->value.refs;
+ 		while ( size-- ) abody++->type_attrs = null_type_attrs;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* aload */
+ int
+ zaload(register ref *op)
+ {	ref aref;
+ 	check_array(*op);
+ 	check_read(*op);
+ 	aref = *op;
+ 	if ( aref.size > ostop - op ) return e_rangecheck;
+ 	memcpy((char *)op, (char *)aref.value.refs, aref.size * sizeof(ref));
+ 	push(aref.size);
+ 	*op = aref;
+ 	return 0;
+ }
+ 
+ /* astore */
+ int
+ zastore(register ref *op)
+ {	uint size;
+ 	check_type(*op, t_array);
+ 	check_write(*op);
+ 	size = op->size;
+ 	if ( size > op - osbot ) return e_stackunderflow;
+ 	refcpy(op->value.refs, op - size, size);
+ 	op[-size] = *op;
+ 	pop(size);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zarray_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1aload", zaload},
+ 		{"1array", zarray},
+ 		{"1astore", zastore},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Internal procedures ------ */
+ 
+ /* Make an array from the operand stack. */
+ /* Don't fill it in. */
+ /* This is also used, for the moment, for packed arrays. */
+ int
+ make_array(register ref *op, int type, int attrs, char *client_name)
+ {	ref *abody;
+ 	uint size;
+ 	check_type(*op, t_integer);
+ 	if ( op->value.intval < 0 ||
+ 	     op->value.intval > max_uint / sizeof(ref) - 1
+ 	   )
+ 		return e_rangecheck;
+ 	size = op->value.intval;
+ 	abody = (ref *)alloc(size, sizeof(ref), client_name);
+ 	if ( abody == 0 ) return e_VMerror;
+ 	make_tasv(op, type, attrs, size, refs, abody);
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zchar.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zchar.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zchar.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,478 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zchar.c */
+ /* Character operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "gxfixed.h"			/* for gstype1.h, gxfont1.h */
+ #include "gxmatrix.h"			/* for font.h */
+ #include "gschar.h"
+ #include "gstype1.h"
+ #include "gxdevice.h"			/* for gxfont.h */
+ #include "gxfont.h"
+ #include "gxfont1.h"
+ #include "gzpath.h"			/* for type1addpath: see below */
+ #include "gzstate.h"
+ #include "alloc.h"
+ #include "dict.h"
+ #include "font.h"
+ #include "estack.h"
+ #include "state.h"
+ #include "store.h"
+ 
+ /* All the character rendering operators use the execution stack */
+ /* for loop control -- see estack.h for details. */
+ /* The information pushed by these operators is as follows: */
+ /*	the enumerator (t_string, but points to a gs_show_enum); */
+ /*	a slot for the procedure for kshow, unused otherwise; */
+ /*	the procedure to be called at the end of the enumeration */
+ /*		(t_operator, but called directly, not by the interpreter); */
+ /*	the usual e-stack mark (t_null). */
+ #define snumpush 4
+ #define senum (gs_show_enum *)(esp->value.bytes)
+ #define sslot esp[-1]
+ #define seproc esp[-2]
+ 
+ /* Forward references */
+ private int setup_show(P2(ref *, op_proc_p));
+ private int show_continue(P1(ref *));
+ private int finish_show(P1(ref *));
+ private int finish_stringwidth(P1(ref *));
+ private gs_show_enum *find_show();
+ private void free_show();
+ 
+ /* show */
+ int
+ zshow(register ref *op)
+ {	int code = setup_show(op, finish_show);
+ 	if ( code < 0 ) return code;
+ 	if ( (code = gs_show_n_init(senum, igs, (char *)op->value.bytes, op->size)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	pop(1);  op--;
+ 	return show_continue(op);
+ }
+ 
+ /* ashow */
+ int
+ zashow(register ref *op)
+ {	int code;
+ 	float axy[2];
+ 	if (	(code = num_params(op - 1, 2, axy)) < 0 ||
+ 		(code = setup_show(op, finish_show)) < 0
+ 	   )
+ 		return code;
+ 	if ( (code = gs_ashow_n_init(senum, igs, axy[0], axy[1], (char *)op->value.bytes, op->size)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	pop(3);  op -= 3;
+ 	return show_continue(op);
+ }
+ 
+ /* widthshow */
+ int
+ zwidthshow(register ref *op)
+ {	int code;
+ 	float cxy[2];
+ 	check_type(op[-1], t_integer);
+ 	if ( (ulong)(op[-1].value.intval) > 255 ) return e_rangecheck;
+ 	if (	(code = num_params(op - 2, 2, cxy)) < 0 ||
+ 		(code = setup_show(op, finish_show)) < 0
+ 	   )
+ 		return code;
+ 	if ( (code = gs_widthshow_n_init(senum, igs, cxy[0], cxy[1],
+ 					 (char)op[-1].value.intval,
+ 					 (char *)op->value.bytes,
+ 					 op->size)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	pop(4);  op -= 4;
+ 	return show_continue(op);
+ }
+ 
+ /* awidthshow */
+ int
+ zawidthshow(register ref *op)
+ {	int code;
+ 	float cxy[2], axy[2];
+ 	check_type(op[-3], t_integer);
+ 	if ( (ulong)(op[-3].value.intval) > 255 ) return e_rangecheck;
+ 	if (	(code = num_params(op - 4, 2, cxy)) < 0 ||
+ 		(code = num_params(op - 1, 2, axy)) < 0 ||
+ 		(code = setup_show(op, finish_show)) < 0
+ 	   )
+ 		return code;
+ 	if ( (code = gs_awidthshow_n_init(senum, igs, cxy[0], cxy[1],
+ 					  (char)op[-3].value.intval,
+ 					  axy[0], axy[1],
+ 					  (char *)op->value.bytes,
+ 					  op->size)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	pop(6);  op -= 6;
+ 	return show_continue(op);
+ }
+ 
+ /* kshow */
+ int
+ zkshow(register ref *op)
+ {	int code;
+ 	check_proc(op[-1]);
+ 	if ( (code = setup_show(op, finish_show)) < 0 ) return code;
+ 	if ( (code = gs_kshow_n_init(senum, igs, (char *)op->value.bytes, op->size)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	sslot = op[-1];		/* save kerning proc */
+ 	pop(2);  op -= 2;
+ 	return show_continue(op);
+ }
+ 
+ /* Common finish procedure for all show operations. */
+ /* Doesn't have to do anything. */
+ private int
+ finish_show(ref *op)
+ {	return 0;
+ }
+ 
+ /* stringwidth */
+ int
+ zstringwidth(register ref *op)
+ {	int code = setup_show(op, finish_stringwidth);
+ 	if ( code < 0 ) return code;
+ 	if ( (code = gs_stringwidth_n_init(senum, igs, (char *)op->value.bytes, op->size)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	pop(1);  op--;
+ 	return show_continue(op);
+ }
+ /* Finishing procedure for stringwidth. */
+ /* Pushes the accumulated width. */
+ private int
+ finish_stringwidth(register ref *op)
+ {	gs_point width;
+ 	gs_show_width(senum, &width);
+ 	push(2);
+ 	make_real(op - 1, width.x);
+ 	make_real(op, width.y);
+ 	return 0;
+ }
+ 
+ /* charpath */
+ int
+ zcharpath(register ref *op)
+ {	int code;
+ 	check_type(*op, t_boolean);
+ 	code = setup_show(op - 1, finish_show);
+ 	if ( code < 0 ) return code;
+ 	if ( (code = gs_charpath_n_init(senum, igs, (char *)op[-1].value.bytes, op[-1].size, op->value.index)) < 0 )
+ 	   {	free_show();
+ 		return code;
+ 	   }
+ 	pop(2);  op -= 2;
+ 	return show_continue(op);
+ }
+ 
+ /* setcachedevice */
+ int
+ zsetcachedevice(register ref *op)
+ {	float wbox[6];
+ 	int npop = 6;
+ 	gs_show_enum *penum = find_show();
+ 	int code = num_params(op, 6, wbox);
+ 	if ( penum == 0 ) return e_undefined;
+ 	if ( code < 0 )
+ 	   {	/* P*stScr*pt implementations apparently allow the */
+ 		/* bounding box to be specified as a 4-element array. */
+ 		/* Check for this here. */
+ 		check_array(*op);
+ 		if ( op->size != 4 ||
+ 		     num_params(op - 1, 2, wbox) < 0 ||
+ 		     num_params(op->value.refs + 3, 4, wbox + 2) < 0
+ 		   )
+ 			return code;
+ 		npop = 3;
+ 	   }
+ 	if ( (code = gs_setcachedevice(penum, wbox[0], wbox[1], wbox[2], wbox[3], wbox[4], wbox[5])) < 0 )
+ 		return code;
+ 	pop(npop);
+ 	return 0;
+ }
+ 
+ /* setcharwidth */
+ int
+ zsetcharwidth(register ref *op)
+ {	float width[2];
+ 	gs_show_enum *penum = find_show();
+ 	int code = num_params(op, 2, width);
+ 	if ( penum == 0 ) return e_undefined;
+ 	if (	code < 0 || 
+ 		(code = gs_setcharwidth(penum, width[0], width[1])) < 0
+ 	   )
+ 		return code;
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* type1addpath */
+ typedef struct {
+ 	font_data *pfdata;
+ 	fixed *osptr;			/* fake interpreter operand stack */
+ 	fixed ostack[2];
+ } z1_data;
+ int
+ ztype1addpath(register ref *op)
+ {	int code;
+ 	gs_show_enum *penum = find_show();
+ 	gs_font *pfont = gs_currentfont(igs);
+ 	font_data *pfdata = (font_data *)pfont->client_data;
+ 	gs_type1_state *pis;
+ 	fixed discard;
+ 	gs_fixed_point spt, ept;
+ 	int flex_path_was_open;
+ 	gs_type1_data tdata;
+ 	z1_data zdata;
+ 	byte *charstring = 0;
+ 	if ( penum == 0 ) return e_undefined;
+ 	check_type(*op, t_string);
+ 	tdata = pfdata->type1_data;
+ 	zdata.pfdata = pfdata;
+ 	zdata.osptr = zdata.ostack;
+ 	tdata.proc_data = (char *)&zdata;
+ 	if ( op->size <= tdata.lenIV )
+ 	   {	/* String is empty, or too short.  Just ignore it. */
+ 		pop(1);
+ 		return 0;
+ 	   }
+ 	pis = (gs_type1_state *)alloc(1, gs_type1_state_sizeof, "type1addpath");
+ 	if ( pis == 0 ) return e_VMerror;
+ 	code = gs_type1_init(pis, penum,
+ 			     gs_show_in_charpath(penum), pfont->paint_type,
+ 			     op->value.bytes,
+ 			     &tdata);
+ 	if ( code < 0 )
+ 	   {	alloc_free((char *)pis, 1, gs_type1_state_sizeof, "type1addpath");
+ 		return code;
+ 	   }
+ more:	code = gs_type1_interpret(pis, charstring);
+ 	charstring = 0;
+ 	if ( code > 0 )			/* seac or callothersubr */
+ 	 { if ( code & 1)		/* seac */
+ 	    {	ref *pcstr;
+ 		code >>= 1;
+ 		/* The restriction on seac seems to imply that */
+ 		/* Adobe interpreters do something special about */
+ 		/* StandardEncoding, but it seems just as easy for us */
+ 		/* not to do anything special.... */
+ 		if ( code >= pfdata->Encoding.size )
+ 			return e_rangecheck;
+ 		if ( dict_find(&pfdata->CharStrings,
+ 			pfdata->Encoding.value.refs + code, &pcstr) <= 0 )
+ 				return e_undefined;
+ 		if ( r_type(pcstr) != t_string )
+ 			return e_invalidfont;
+ 		charstring = pcstr->value.bytes;
+ 		goto more;
+ 	    }
+ 	  else				/* callothersubr */
+ 	    {	/* We aren't prepared to call the interpreter here, */
+ 		/* so we fake the Flex feature. */
+ 		gx_path *ppath = igs->path;
+ 		gs_type1_pop(pis, &discard);	/* pop # of args */
+ 		switch ( (code >> 1) - 1 )
+ 		   {
+ 		case 0:
+ 			/* We have to do something really sleazy here, */
+ 			/* namely, make it look as though the rmovetos */
+ 			/* never really happened, because we don't want */
+ 			/* to interrupt the current subpath. */
+ 			gx_path_current_point(ppath, &ept);
+ 			gx_path_add_point(ppath, spt.x, spt.y);
+ 			ppath->subpath_open = flex_path_was_open;
+ 					/* ^--- sleaze */
+ 			gx_path_add_line(ppath, ept.x, ept.y);
+ 			/* Transfer endpoint coordinates to 'ostack' */
+ 			gs_type1_pop(pis, &zdata.ostack[0]);
+ 			gs_type1_pop(pis, &zdata.ostack[1]);
+ 			gs_type1_pop(pis, &discard);
+ 			zdata.osptr = &zdata.ostack[2];
+ 			goto more;
+ 		case 1:
+ 			gx_path_current_point(ppath, &spt);
+ 			flex_path_was_open = ppath->subpath_open;
+ 					/* ^--- more sleaze */
+ 			goto more;
+ 		case 2:
+ 			goto more;
+ 		case 3:
+ 			gs_type1_pop(pis, &discard);	/* pop subr# */
+ 			zdata.ostack[0] = int2fixed(3);
+ 			zdata.osptr = &zdata.ostack[1];
+ 			goto more;
+ 		   }
+ 		/* Unrecognized othersubr */
+ 		code = e_rangecheck;
+ 	    }
+ 	 }
+ 	alloc_free((char *)pis, 1, gs_type1_state_sizeof, "type1addpath");
+ 	if ( code >= 0 ) pop(1);
+ 	return code;
+ }
+ 
+ /* type1imagepath */
+ int
+ ztype1imagepath(register ref *op)
+ {	float woxy[4];
+ 	int code;
+ 	check_type(op[-7], t_string);
+ 	check_type(op[-6], t_integer);
+ 	check_type(op[-5], t_integer);
+ 	if ( (code = num_params(op - 1, 4, woxy)) < 0 ) return code;
+ 	check_write_type(*op, t_string);
+ 	code = gs_type1imagepath(igs, op[-7].value.bytes,
+ 		(int)op[-6].value.intval, (int)op[-5].value.intval,
+ 		woxy[0], woxy[1], woxy[2], woxy[3],
+ 		op->value.bytes, op->size);
+ 	if ( code < 0 ) return code;
+ 	op[-7] = *op;
+ 	op[-7].size = code;
+ 	pop(7);
+ 	return 0;
+ }
+ 
+ /* ------ Auxiliary procedures for type 1 fonts ------ */
+ 
+ int
+ z1_subr_proc(gs_type1_data *pdata, int index, byte **pstr)
+ {	font_data *pfdata = ((z1_data *)(pdata->proc_data))->pfdata;
+ 	ref *psubr;
+ 	if ( index < 0 || index >= pfdata->Subrs.size )
+ 		return e_rangecheck;
+ 	psubr = pfdata->Subrs.value.refs + index;
+ 	check_type(*psubr, t_string);
+ 	*pstr = psubr->value.bytes;
+ 	return 0;
+ }
+ 
+ int
+ z1_pop_proc(gs_type1_data *pdata, fixed *pf)
+ {	*pf = *--(((z1_data *)(pdata->proc_data))->osptr);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zchar_op_init()
+ {	static op_def my_defs[] = {
+ 		{"3ashow", zashow},
+ 		{"6awidthshow", zawidthshow},
+ 		{"2charpath", zcharpath},
+ 		{"2kshow", zkshow},
+ 		{"3setcachedevice", zsetcachedevice},
+ 		{"2setcharwidth", zsetcharwidth},
+ 		{"1show", zshow},
+ 		{"1stringwidth", zstringwidth},
+ 		{"1type1addpath", ztype1addpath},
+ 		{"8type1imagepath", ztype1imagepath},
+ 		{"4widthshow", zwidthshow},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Set up for a show operator. */
+ /* The top stack element must be the string to be scanned. */
+ /* The caller has already done all other argument checking. */
+ private int
+ setup_show(ref *op, op_proc_p endproc /* end procedure */)
+ {	gs_show_enum *penum;
+ 	check_read_type(*op, t_string);
+ 	check_estack(snumpush + 2);
+ 	if ( (penum = (gs_show_enum *)alloc(1, gs_show_enum_sizeof, "setup_show")) == 0 )
+ 		return e_VMerror;
+ 	mark_estack(es_show);
+ 	push_op_estack(endproc);
+ 	++esp;
+ 	make_tv(esp, t_null, index, 0);		/* reserve slot */
+ 	++esp;
+ 	make_tasv(esp, t_string, 0, gs_show_enum_sizeof, bytes, (byte *)penum);
+ 	return o_check_estack;
+ }
+ 
+ /* Continuation operator for character rendering. */
+ private int
+ show_continue(register ref *op)
+ {	gs_show_enum *penum = senum;
+ 	int code = gs_show_next(penum);
+ 	switch ( code )
+ 	   {
+ 	case 0:				/* all done */
+ 		code = (*seproc.value.opproc)(op);
+ 		free_show();
+ 		return (code >= 0 ? o_check_estack : code);
+ 	case gs_show_kern:
+ 	   {	ref *pslot = &sslot;
+ 		push(2);
+ 		make_int(op - 1, gs_kshow_previous_char(penum));
+ 		make_int(op, gs_kshow_next_char(penum));
+ 		push_op_estack(show_continue);		/* continue after kerning */
+ 		*++esp = *pslot;	/* kerning procedure */
+ 	   }
+ 		return o_check_estack;
+ 	case gs_show_render:
+ 	   {	font_data *pfont = (font_data *)gs_currentfont(igs)->client_data;
+ 		push(2);
+ 		op[-1] = pfont->dict;	/* push the font */
+ 		make_int(op, gs_show_current_char(penum));
+ 		push_op_estack(show_continue);
+ 		*++esp = pfont->BuildChar;
+ 	   }
+ 		return o_check_estack;
+ 	default:			/* error */
+ 		free_show();
+ 		return code;
+ 	   }
+ }
+ 
+ /* Find the current show enumerator on the e-stack. */
+ private gs_show_enum *
+ find_show()
+ {	ref *ep = esp;
+ 	while ( !(r_type(ep) == t_null && ep->value.index == es_show) )
+ 	   {	if ( --ep < estack ) return 0;	/* no mark */
+ 	   }
+ 	return (gs_show_enum *)ep[snumpush - 1].value.bytes;
+ }
+ 
+ /* Discard the show record (after an error, or at the end). */
+ private void
+ free_show()
+ {	alloc_free((char *)senum, 1, gs_show_enum_sizeof, "free_show");
+ 	esp -= snumpush;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zcolor.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zcolor.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zcolor.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,83 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zcolor.c */
+ /* Color operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "store.h"
+ #include "gsmatrix.h"			/* for gs_state */
+ #include "gsstate.h"
+ #include "state.h"
+ 
+ /* Imported from util.c */
+ extern	int	num_params(P3(ref *, int, float *));
+ /* Imported from zgstate.c */
+ extern	void	tri_put(P2(ref *, float [3]));
+ 
+ /* Forward declarations */
+ private int make_color(P1(ref *));
+ 
+ /* currentgscolor */
+ int
+ zcurrentgscolor(register ref *op)
+ {	int code;
+ 	push(1);
+ 	if (	(code = make_color(op)) < 0 ||
+ 		(code = gs_currentgscolor(igs, op->value.pcolor)) < 0
+ 	   )
+ 		pop(1);
+ 	return code;
+ }
+ 
+ /* setgscolor */
+ int
+ zsetgscolor(register ref *op)
+ {	int code;
+ 	check_type(*op, t_color);
+ 	if ( (code = gs_setgscolor(igs, op->value.pcolor)) < 0 )
+ 		return code;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zcolor_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0currentgscolor", zcurrentgscolor},
+ 		{"1setgscolor", zsetgscolor},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Make a color object */
+ private int
+ make_color(ref *op)
+ {	gs_color *cp = (gs_color *)alloc(1, gs_color_sizeof, "make_color");
+ 	if ( cp == 0 ) return e_VMerror;
+ 	make_tv(op, t_color, pcolor, cp);
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zcontrol.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zcontrol.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zcontrol.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,311 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zcontrol.c */
+ /* Control operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "estack.h"
+ #include "store.h"
+ #include "sstorei.h"
+ 
+ /* Imported from util.h */
+ extern int num_params(P3(ref *, int, float *));
+ 
+ /* exec */
+ int
+ zexec(register ref *op)
+ {	check_op(1);
+ 	check_estack(1);
+ 	++esp;
+ 	s_store_i(esp, op);
+ 	pop(1);
+ 	return o_check_estack;
+ }
+ 
+ /* if */
+ int
+ zif(register ref *op)
+ {	check_type(op[-1], t_boolean);
+ 	if ( op[-1].value.index )		/* true */
+ 	   {	check_estack(1);
+ 		++esp;
+ 		s_store_i(esp, op);
+ 	   }
+ 	pop(2);
+ 	return o_check_estack;
+ }
+ 
+ /* ifelse */
+ int
+ zifelse(register ref *op)
+ {	check_type(op[-2], t_boolean);
+ 	check_estack(1);
+ 	++esp;
+ 	if ( op[-2].value.index )
+ 	   {	s_store_b(esp, 0, op, -1);
+ 	   }
+ 	else
+ 	   {	s_store_i(esp, op);
+ 	   }
+ 	pop(3);
+ 	return o_check_estack;
+ }
+ 
+ /* for */
+ private int
+   for_int_continue(P1(ref *)),
+   for_real_continue(P1(ref *));
+ int
+ zfor(register ref *op)
+ {	int code = num_params(op - 1, 3, (float *)0);
+ 	if ( code < 0 ) return code;	/* non-numeric arg */
+ 	check_estack(7);
+ 	/* Push a mark, the control variable, the increment, */
+ 	/* the limit, and the procedure, and invoke */
+ 	/* the continuation operator. */
+ 	mark_estack(es_for);
+ 	*++esp = op[-3];
+ 	*++esp = op[-2];
+ 	*++esp = op[-1];
+ 	*++esp = *op;
+ 	pop(4);
+ 	op -= 4;
+ 	/* If the parameters are not all integers, */
+ 	/* coerce them all to floats now. */
+ 	if ( code == 7 )		/* i.e. all integer args */
+ 		return for_int_continue(op);
+ 	else
+ 	   {	if ( code & 1 ) make_real(esp - 3, esp[-3].value.intval);
+ 		if ( code & 2 ) make_real(esp - 2, esp[-2].value.intval);
+ 		if ( code & 4 ) make_real(esp - 1, esp[-1].value.intval);
+ 		return for_real_continue(op);
+ 	   }
+ }
+ /* Continuation operators for for, separate for integer and real. */
+ /* Execution stack contains mark, control variable, increment, */
+ /* limit, and procedure (procedure is topmost.) */
+ /* Continuation operator for integers. */
+ private int
+ for_int_continue(register ref *op)
+ {	ref proc;
+ 	long var = esp[-3].value.intval;
+ 	long incr = esp[-2].value.intval;
+ 	if ( incr >= 0 ? (var > esp[-1].value.intval) :
+ 		(var < esp[-1].value.intval) )
+ 		   {	esp -= 5;	/* pop everything */
+ 			return o_check_estack;
+ 		   }
+ 	push(1);
+ 	*op = esp[-3];
+ 	esp[-3].value.intval = var + incr;
+ 	proc = *esp;		/* saved proc */
+ 	push_op_estack(for_int_continue);	/* push continuation */
+ 	*++esp = proc;
+ 	return o_check_estack;
+ }
+ /* Continuation operator for reals. */
+ private int
+ for_real_continue(register ref *op)
+ {	ref proc;
+ 	float var = esp[-3].value.realval;
+ 	float incr = esp[-2].value.realval;
+ 	if ( incr >= 0 ? (var > esp[-1].value.realval) :
+ 		(var < esp[-1].value.realval) )
+ 		   {	esp -= 5;	/* pop everything */
+ 			return o_check_estack;
+ 		   }
+ 	push(1);
+ 	*op = esp[-3];
+ 	esp[-3].value.realval = var + incr;
+ 	proc = *esp;		/* saved proc */
+ 	push_op_estack(for_real_continue);	/* push continuation */
+ 	*++esp = proc;
+ 	return o_check_estack;
+ }
+ 
+ /* repeat */
+ private int repeat_continue(P1(ref *));
+ int
+ zrepeat(register ref *op)
+ {	check_type(op[-1], t_integer);
+ 	if ( op[-1].value.intval < 0 ) return e_rangecheck;
+ 	check_estack(5);
+ 	/* Push a mark, the count, and the procedure, and invoke */
+ 	/* the continuation operator. */
+ 	mark_estack(es_for);
+ 	*++esp = op[-1];
+ 	*++esp = *op;
+ 	pop(2);
+ 	return repeat_continue(op - 2);
+ }
+ /* Continuation operator for repeat */
+ private int
+ repeat_continue(register ref *op)
+ {	ref proc;
+ 	proc = *esp;		/* saved proc */
+ 	if ( --(esp[-1].value.intval) >= 0 )	/* continue */
+ 	   {	push_op_estack(repeat_continue);	/* push continuation */
+ 		*++esp = proc;
+ 	   }
+ 	else				/* done */
+ 	   {	esp -= 3;		/* pop mark, count, proc */
+ 	   }
+ 	return o_check_estack;
+ }
+ 
+ /* loop */
+ private int loop_continue(P1(ref *));
+ int
+ zloop(register ref *op)
+ {	check_op(1);
+ 	check_estack(4);
+ 	/* Push a mark and the procedure, and invoke */
+ 	/* the continuation operator. */
+ 	mark_estack(es_for);
+ 	*++esp = *op;
+ 	pop(1);
+ 	return loop_continue(op - 1);
+ }
+ /* Continuation operator for loop */
+ private int
+ loop_continue(register ref *op)
+ {	ref proc;
+ 	proc = *esp;		/* saved proc */
+ 	push_op_estack(loop_continue);	/* push continuation */
+ 	*++esp = proc;
+ 	return o_check_estack;
+ }
+ 
+ /* exit */
+ int
+ zexit(register ref *op)
+ {	ref *ep = esp;
+ 	while ( ep >= estack )
+ 	   {	if ( r_type(ep) == t_null )	/* control mark */
+ 			switch ( (ep--)->value.index )
+ 			   {
+ 			case es_for: esp = ep; return o_check_estack;
+ 			case es_stopped: return e_invalidexit;	/* not a loop */
+ 			   }
+ 		else
+ 			ep--;
+ 	   }
+ 	/* Return e_invalidexit if there is no mark at all. */
+ 	/* This is different from PostScript, which aborts. */
+ 	/* It shouldn't matter in practice. */
+ 	return e_invalidexit;
+ }
+ 
+ /* stop */
+ int
+ zstop(register ref *op)
+ {	ref *ep = esp;
+ 	while ( ep >= estack )
+ 	   {	if ( r_type(ep) == t_null && ep->value.index == es_stopped )
+ 		   {	esp = ep - 1;
+ 			push(1);
+ 			make_bool(op, 1);
+ 			return o_check_estack;
+ 		   }
+ 		ep--;
+ 	   }
+ 	/* Return e_invalidexit if there is no mark at all. */
+ 	/* This is different from PostScript, which aborts. */
+ 	/* It shouldn't matter in practice. */
+ 	return e_invalidexit;
+ }
+ 
+ /* stopped */
+ int
+ zstopped(register ref *op)
+ {	check_op(1);
+ 	/* Mark the execution stack, and push a false in case */
+ 	/* control returns normally. */
+ 	check_estack(3);
+ 	mark_estack(es_stopped);
+ 	++esp; make_false(esp);
+ 	*++esp = *op;			/* execute the operand */
+ 	pop(1);
+ 	return o_check_estack;
+ }
+ 
+ /* countexecstack */
+ int
+ zcountexecstack(register ref *op)
+ {	push(1);
+ 	make_int(op, esp - estack + 1);
+ 	return 0;
+ }
+ 
+ /* execstack */
+ private int continue_execstack(P1(ref *));
+ int
+ zexecstack(register ref *op)
+ {	/* We can't do this directly, because the interpreter */
+ 	/* might have cached some state.  To force the interpreter */
+ 	/* to update the stored state, we push a continuation on */
+ 	/* the exec stack; the continuation is executed immediately, */
+ 	/* and does the actual transfer. */
+ 	int depth = esp - estack + 1;
+ 	check_write_type(*op, t_array);
+ 	if ( depth > op->size ) return e_rangecheck;
+ 	if ( estack >= estop ) return e_execstackoverflow;	/* no room to push */
+ 	op->size = depth;
+ 	r_set_attrs(op, a_subrange);
+ 	push_op_estack(continue_execstack);
+ 	return o_check_estack;
+ }
+ /* Continuation operator to do the actual transfer */
+ private int
+ continue_execstack(register ref *op)
+ {	int depth = op->size;		/* was set above */
+ 	refcpy(op->value.refs, estack, depth);
+ 	return 0;
+ }
+ 
+ 
+ /* quit */
+ int
+ zquit(register ref *op)
+ {	gs_exit(0);
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zcontrol_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0countexecstack", zcountexecstack},
+ 		{"1exec", zexec},
+ 		{"0execstack", zexecstack},
+ 		{"0exit", zexit},
+ 		{"2if", zif},
+ 		{"3ifelse", zifelse},
+ 		{"4for", zfor},
+ 		{"1loop", zloop},
+ 		{"0quit", zquit},
+ 		{"2repeat", zrepeat},
+ 		{"0stop", zstop},
+ 		{"1stopped", zstopped},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zdevice.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zdevice.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zdevice.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,228 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zdevice.c */
+ /* Device-related operators for GhostScript */
+ #include "ghost.h"
+ #include "alloc.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "state.h"
+ #include "gsmatrix.h"
+ #include "gsstate.h"
+ #include "gxdevice.h"
+ #include "store.h"
+ 
+ /* copypage */
+ int
+ zcopypage(register ref *op)
+ {	return gs_copypage(igs);
+ }
+ 
+ /* copyscanlines */
+ int
+ zcopyscanlines(register ref *op)
+ {	ref *op1 = op - 1;
+ 	ref *op2 = op - 2;
+ 	gx_device *dev;
+ 	int code;
+ 	uint bytes_copied;
+ 	check_type(*op2, t_device);
+ 	dev = op2->value.pdevice;
+ 	check_type(*op1, t_integer);
+ 	if ( op1->value.intval < 0 || op1->value.intval > dev->height )
+ 		return e_rangecheck;
+ 	check_write_type(*op, t_string);
+ 	code = gs_copyscanlines(dev, (int)op1->value.intval,
+ 		op->value.bytes, op->size, NULL, &bytes_copied);
+ 	if ( code < 0 ) return e_typecheck;	/* not a memory device */
+ 	*op2 = *op;
+ 	op2->size = bytes_copied;
+ 	r_set_attrs(op2, a_subrange);
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* currentdevice */
+ int
+ zcurrentdevice(register ref *op)
+ {	gx_device *dev = gs_currentdevice(igs);
+ 	push(1);
+ 	make_tv(op, t_device, pdevice, dev);
+ 	return 0;
+ }
+ 
+ /* devicename */
+ int
+ zdevicename(register ref *op)
+ {	char *dname;
+ 	int code;
+ 	check_type(*op, t_device);
+ 	dname = gs_devicename(op->value.pdevice);
+ 	code = string_to_ref(dname, op, "devicename");
+ 	if ( code < 0 ) return code;
+ 	return 0;
+ }
+ 
+ /* deviceparams */
+ int
+ zdeviceparams(register ref *op)
+ {	int code = write_matrix(op);
+ 	ref *pmat;
+ 	gs_matrix imat;
+ 	int width, height;
+ 	if ( code < 0 ) return code;
+ 	check_type(op[-1], t_device);
+ 	gs_deviceparams(op[-1].value.pdevice, &imat, &width, &height);
+ 	/* Transfer the values to the matrix */
+ 	pmat = op->value.refs;
+ 	make_real(pmat+0, imat.xx); make_real(pmat+1, imat.xy);
+ 	make_real(pmat+2, imat.yx); make_real(pmat+3, imat.yy);
+ 	make_real(pmat+4, imat.tx); make_real(pmat+5, imat.ty);
+ 	push(2);
+ 	make_mark(op - 3);
+ 	make_int(op - 1, width);
+ 	make_int(op, height);
+ 	return 0;
+ }
+ 
+ /* flushpage */
+ int
+ zflushpage(register ref *op)
+ {	return gs_flushpage(igs);
+ }
+ 
+ /* getdevice */
+ int
+ zgetdevice(register ref *op)
+ {	gx_device *dev;
+ 	check_type(*op, t_integer);
+ 	if ( op->value.intval != (int)(op->value.intval) )
+ 		return e_rangecheck;	/* won't fit in an int */
+ 	dev = gs_getdevice((int)(op->value.intval));
+ 	if ( dev == 0 ) return e_rangecheck;	/* index out of range */
+ 	make_tv(op, t_device, pdevice, dev);
+ 	return 0;
+ }
+ 
+ /* makedevice */
+ int
+ zmakedevice(register ref *op)
+ {	gs_matrix imat;
+ 	gx_device *new_dev;
+ 	int code;
+ 	check_type(op[-3], t_device);
+ 	check_type(op[-1], t_integer);	/* width */
+ 	check_type(*op, t_integer);	/* height */
+ 	if (	(ulong)(op[-1].value.intval) > max_uint >> 1 ||
+ 		(ulong)(op->value.intval) > max_uint >> 1
+ 	   ) return e_rangecheck;
+ 	if ( (code = read_matrix(op - 2, &imat)) < 0 ) return code;
+ 	/* Everything OK, create device */
+ 	code = gs_makedevice(&new_dev, op[-3].value.pdevice, &imat,
+ 			     (int)op[-1].value.intval, (int)op->value.intval,
+ 			     alloc);
+ 	if ( code == 0 )
+ 	   {	make_tv(op - 3, t_device, pdevice, new_dev);
+ 		pop(3);
+ 	   }
+ 	return code;
+ }
+ 
+ /* makeimagedevice */
+ int
+ zmakeimagedevice(register ref *op)
+ {	gs_matrix imat;
+ 	gx_device *new_dev;
+ 	float colors[256 * 3];
+ 	int num_colors;
+ 	int code;
+ 	check_type(op[-2], t_integer);	/* width */
+ 	check_type(op[-1], t_integer);	/* height */
+ 	if ( r_type(op) == t_null )	/* true color */
+ 	   {	num_colors = -24;	/* 24-bit true color */
+ 	   }
+ 	else
+ 	   {	check_array(*op);	/* palette */
+ 		num_colors = op->size;
+ 	   }
+ 	if (	(ulong)(op[-2].value.intval) > max_uint >> 1 ||
+ 		(ulong)(op[-1].value.intval) > max_uint >> 1 ||
+ 		num_colors > 256
+ 	   ) return e_rangecheck;
+ 	if ( (code = read_matrix(op - 3, &imat)) < 0 ) return code;
+ 	/* Check and convert colors */
+ 	   {	int i;
+ 		ref *pc = op->value.refs;
+ 		float *p = colors;
+ 		for ( i = 0; i < num_colors; i++, pc++, p += 3 )
+ 		   {	check_type(*pc, t_color);
+ 			code = gs_colorrgb(pc->value.pcolor, p);
+ 			if ( code < 0 ) return code;
+ 		   }
+ 	   }
+ 	/* Everything OK, create device */
+ 	code = gs_makeimagedevice(&new_dev, &imat,
+ 				  (int)op[-2].value.intval,
+ 				  (int)op[-1].value.intval,
+ 				  colors, num_colors, alloc);
+ 	if ( code == 0 )
+ 	   {	make_tv(op - 3, t_device, pdevice, new_dev);
+ 		pop(3);
+ 	   }
+ 	return code;
+ }
+ 
+ /* .nulldevice */
+ int
+ znulldevice(register ref *op)
+ {	gs_nulldevice(igs);
+ 	return 0;
+ }
+ 
+ /* .setdevice */
+ int
+ zsetdevice(register ref *op)
+ {	int code;
+ 	check_type(*op, t_device);
+ 	code = gs_setdevice(igs, op->value.pdevice);
+ 	if ( code == 0 ) pop(1);
+ 	return code;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zdevice_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0copypage", zcopypage},
+ 		{"3copyscanlines", zcopyscanlines},
+ 		{"0currentdevice", zcurrentdevice},
+ 		{"1devicename", zdevicename},
+ 		{"1deviceparams", zdeviceparams},
+ 		{"0flushpage", zflushpage},
+ 		{"1getdevice", zgetdevice},
+ 		{"4makedevice", zmakedevice},
+ 		{"4makeimagedevice", zmakeimagedevice},
+ 		{"0.nulldevice", znulldevice},
+ 		{"1.setdevice", zsetdevice},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zdict.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zdict.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zdict.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,236 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zdict.c */
+ /* Dictionary operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "dict.h"
+ #include "store.h"
+ 
+ /* Import the dictionary stack */
+ extern ref dstack[];
+ extern ref *dsp, *dstop;
+ 
+ /* dict */
+ int
+ zdict(register ref *op)
+ {	check_type(*op, t_integer);
+ 	if ( op->value.intval < 0 || op->value.intval > dict_max_size )
+ 		return e_rangecheck;
+ 	return dict_create((uint)op->value.intval, op);
+ }
+ 
+ /* maxlength */
+ int
+ zmaxlength(register ref *op)
+ {	check_type(*op, t_dictionary);
+ 	check_dict_read(*op);
+ 	make_int(op, dict_maxlength(op));
+ 	return 0;
+ }
+ 
+ /* setmaxlength */
+ int
+ zsetmaxlength(register ref *op)
+ {	uint new_size;
+ 	int code;
+ 	ref *op1 = op - 1;
+ 	check_type(*op1, t_dictionary);
+ 	check_dict_write(*op1);
+ 	check_type(*op, t_integer);
+ 	if ( op->value.intval < 0 || op->value.intval > dict_max_size )
+ 		return e_rangecheck;
+ 	new_size = (uint)op->value.intval;
+ 	if ( dict_length(op - 1) > new_size )
+ 		return e_dictfull;
+ 	code = dict_resize(op - 1, new_size);
+ 	if ( code >= 0 ) pop(2);
+ 	return code;
+ }
+ 
+ /* begin */
+ int
+ zbegin(register ref *op)
+ {	check_type(*op, t_dictionary);
+ 	check_dict_read(*op);
+ 	if ( dsp == dstop ) return e_dictstackoverflow;
+ 	*++dsp = *op;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* end */
+ int
+ zend(register ref *op)
+ {	if ( dsp == dstack + 1 ) return e_dictstackunderflow;
+ 	dsp--;
+ 	return 0;
+ }
+ 
+ /* def */
+ int
+ zdef(register ref *op)
+ {	int code;
+ 	check_op(2);
+ 	if ( r_type(op - 1) == t_null ) return e_typecheck;
+ 	check_dict_write(*dsp);
+ 	code = dict_put(dsp, op - 1, op);
+ 	if ( !code ) pop(2);
+ 	return code;
+ }
+ 
+ /* load */
+ int
+ zload(register ref *op)
+ {	ref *pvalue;
+ 	check_op(1);
+ 	if ( r_type(op) == t_null ) return e_typecheck;
+ 	if ( dict_lookup(dstack, dsp, op, &pvalue) <= 0 )
+ 		return e_undefined;
+ 	*op = *pvalue;
+ 	return 0;
+ }
+ 
+ /* store */
+ int
+ zstore(register ref *op)
+ {	ref *pvalue;
+ 	int code;
+ 	check_op(2);
+ 	if ( r_type(op - 1) == t_null ) return e_typecheck;
+ 	if ( dict_lookup(dstack, dsp, op - 1, &pvalue) <= 0 )
+ 	   {	code = dict_put(dsp, op - 1, op);
+ 		if ( code ) return code;
+ 	   }
+ 	else
+ 		store_i(pvalue, op);
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* get - implemented in zarray.c */
+ 
+ /* put - implemented in zarray.c */
+ 
+ /* known */
+ int
+ zknown(register ref *op)
+ {	ref *op1 = op - 1;
+ 	ref *pvalue;
+ 	check_type(*op1, t_dictionary);
+ 	check_dict_read(*op1);
+ 	make_bool(op1,
+ 		  (r_type(op) == t_null ? 0 :
+ 		   dict_find(op1, op, &pvalue) > 0 ? 1 : 0));
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* where */
+ int
+ zwhere(register ref *op)
+ {	ref *pdref = dsp;
+ 	ref *pvalue;
+ 	check_op(1);
+ 	if ( r_type(op) == t_null )
+ 	   {	make_bool(op, 0);
+ 		return 0;
+ 	   }
+ 	while ( 1 )
+ 	   {	check_dict_read(*pdref);
+ 		if ( dict_find(pdref, op, &pvalue) > 0 ) break;
+ 		if ( --pdref < dstack )
+ 		   {	make_bool(op, 0);
+ 			return 0;
+ 		   }
+ 	   }
+ 	*op = *pdref;
+ 	push(1);
+ 	make_bool(op, 1);
+ 	return 0;
+ }
+ 
+ /* copy for dictionaries -- called from zcopy in zgeneric.c. */
+ /* Only the type of *op has been checked. */
+ int
+ zcopy_dict(register ref *op)
+ {	ref *op1 = op - 1;
+ 	check_type(*op1, t_dictionary);
+ 	check_dict_read(*op1);
+ 	check_dict_write(*op);
+ 	if ( dict_length(op) != 0 || dict_maxlength(op) < dict_maxlength(op1) )
+ 		return e_rangecheck;
+ 	dict_copy(op1, op);
+ 	op[-1] = *op;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* currentdict */
+ int
+ zcurrentdict(register ref *op)
+ {	push(1);
+ 	*op = *dsp;
+ 	return 0;
+ }
+ 
+ /* countdictstack */
+ int
+ zcountdictstack(register ref *op)
+ {	push(1);
+ 	make_int(op, dsp - dstack + 1);
+ 	return 0;
+ }
+ 
+ /* dictstack */
+ int
+ zdictstack(register ref *op)
+ {	int depth = dsp - dstack + 1;
+ 	check_write_type(*op, t_array);
+ 	if ( depth > op->size ) return e_rangecheck;
+ 	op->size = depth;
+ 	r_set_attrs(op, a_subrange);
+ 	refcpy(op->value.refs, dstack, depth);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zdict_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1begin", zbegin},
+ 		{"0countdictstack", zcountdictstack},
+ 		{"0currentdict", zcurrentdict},
+ 		{"2def", zdef},
+ 		{"1dict", zdict},
+ 		{"0dictstack", zdictstack},
+ 		{"0end", zend},
+ 		{"2known", zknown},
+ 		{"1load", zload},
+ 		{"1maxlength", zmaxlength},
+ 		{"2setmaxlength", zsetmaxlength},
+ 		{"2store", zstore},
+ 		{"1where", zwhere},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zfile.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zfile.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zfile.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,872 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zfile.c */
+ /* File operators for GhostScript */
+ #include "memory_.h"
+ #include "string_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "stream.h"
+ #include "store.h"
+ #include "gsmatrix.h"			/* for gxdevice.h */
+ #include "gxdevice.h"
+ #include "gxdevmem.h"
+ 
+ /* Forward references */
+ int zreadline_from(P4(byte *, uint, uint *, stream *));
+ int lib_file_open(P3(byte *, uint, ref *));
+ private int open_std_file(P3(ref *, char *, ref *));
+ private ref *get_current_file();
+ private int write_string(P2(ref *, stream *));
+ 
+ /* Imported from gs.c */
+ extern char **gs_lib_paths;		/* search path list, */
+ 					/* terminated by a null pointer */
+ 
+ /* Imported from gp_*.c. */
+ extern char gp_file_name_list_separator;
+ extern int gp_file_name_is_absolute(P2(char *, uint));
+ extern char *gp_file_name_concat_string(P4(char *, uint, char *, uint));
+ 
+ /* Imported from iutil.c */
+ extern char *ref_to_string(P2(ref *, char *));
+ 
+ /* Import the execution stack for currentfile */
+ extern ref estack[];
+ extern ref *esp;
+ 
+ /* File objects store a pointer to a file entry in value.pfile. */
+ /* A file entry is valid if its stream pointer is non-zero. */
+ #define fptr(pref) (pref)->value.pfile
+ #define make_file(pref,a,pfe)\
+   make_tav(pref,t_file,a,pfile,pfe)
+ typedef struct file_entry_s file_entry;
+ struct file_entry_s {
+ 	stream *s;
+ 	int can_close;			/* 0 for stdin/out/err, */
+ 					/* -1 for line/statementedit, */
+ 					/* 1 for other files */
+ 	ref file_name;			/* t_string */
+ };
+ 
+ /* File buffer sizes.  For real files, this is arbitrary, */
+ /* since the C library does its own buffering in addition. */
+ /* stdout and stderr use smaller buffers, */
+ /* on the assumption that they are usually not real files. */
+ /* The buffer size for type 1 encrypted files is NOT arbitrary: */
+ /* it must be at most 512. */
+ #define buffer_size 512
+ 
+ /* Standard file objects: */
+ /* 0 is stdin, 1 is stdout, 2 is stderr, 3 is lineedit, 4 is statementedit */
+ #define num_std_files 5
+ private file_entry invalid_file_entry = { (stream *)0 };
+ private byte
+ #define stdin_buf_size 1
+ 	stdin_buf[stdin_buf_size],
+ #define stdout_buf_size 128
+ 	stdout_buf[stdout_buf_size],
+ #define stderr_buf_size 128
+ 	stderr_buf[stderr_buf_size],
+ #define lineedit_buf_size 160
+ 	lineedit_buf[lineedit_buf_size];
+ /* statementedit is equivalent to lineedit for now */
+ private stream std_file_streams[num_std_files];
+ private file_entry std_files[num_std_files] =
+    {	{ &std_file_streams[0], 0 },
+ 	{ &std_file_streams[1], 0 },
+ 	{ &std_file_streams[2], 0 },
+ 	{ &std_file_streams[3], -1 },
+ 	{ &std_file_streams[4], -1 }
+    };
+ private char *std_file_names[num_std_files] =
+    {	"%stdin",
+ 	"%stdout",
+ 	"%stderr",
+ 	"%lineedit",
+ 	"%statementedit"
+    };
+ private int std_file_attrs[num_std_files] =
+    {	a_read+a_execute,
+ 	a_write+a_execute,
+ 	a_write+a_execute,
+ 	a_read+a_execute,
+ 	a_read+a_execute
+    };
+ 
+ /* Macros for checking file validity */
+ #define check_file_access(svar,op,acc)\
+    {	file_entry *fe = fptr(op);\
+ 	svar = fe->s;		/* do first, acc may refer to it */\
+ 	if ( svar == 0 || !(acc) )\
+ 		return e_invalidaccess;\
+    }
+ #define check_file_ref(svar,op,acc)\
+    {	if ( r_type(op) != t_file ) return e_typecheck;\
+ 	check_file_access(svar,op,acc);\
+    }
+ #define check_file(svar,op) check_file_ref(svar,op,1)
+ #define check_read_file(svar,op) check_file_ref(svar,op,!svar->writing)
+ #define check_write_file(svar,op) check_file_ref(svar,op,svar->writing)
+ 
+ /* Initialize the file table */
+ void
+ zfile_init()
+ {	/* Create files for stdin, stdout, and stderr. */
+ 	int i;
+ 	/****** stdin IS NOT IMPLEMENTED PROPERLY ******/
+ 	sread_file(std_files[0].s, stdin, stdin_buf, stdin_buf_size);
+ 	swrite_file(std_files[1].s, stdout, stdout_buf, stdout_buf_size);
+ 	swrite_file(std_files[2].s, stderr, stderr_buf, stderr_buf_size);
+ 	for ( i = 0; i < num_std_files; i++ )
+ 	   {	ref *pfn = &std_files[i].file_name;
+ 		make_tv(pfn, t_null, intval, 0);	/* pre-clear */
+ 		if ( string_to_ref(std_file_names[i], pfn, "zfile_init") < 0 )
+ 		   {	dprintf("alloc failed in zfile_init!\n");
+ 			gs_exit(1);
+ 		   }
+ 	   }
+ }
+ 
+ /* file */
+ int
+ zfile(register ref *op)
+ {	char *file_access;
+ 	ref fname;
+ 	int code;
+ 	fname = op[-1];
+ 	check_type(fname, t_string);
+ 	check_type(*op, t_string);
+ 	if ( op->size != 1 ) return e_invalidfileaccess;
+ 	switch ( *op->value.bytes )
+ 	   {
+ 	case 'r': file_access = "r"; break;
+ 	case 'w': file_access = "w"; break;
+ 	default: return e_invalidfileaccess;
+ 	   }
+ 	code = open_std_file(op - 1, file_access, op - 1);
+ 	switch ( code )
+ 	   {
+ 	case 0:				/* successful open */
+ 		pop(1);
+ 	default:			/* unsuccessful open */
+ 		return code;
+ 	case e_undefinedfilename:	/* not a %file */
+ 		;
+ 	   }
+ 	code = file_open(fname.value.bytes, fname.size, file_access, op - 1);
+ 	if ( code >= 0 ) pop(1);
+ 	return code;
+ }
+ 
+ /* closefile */
+ int
+ zclosefile(register ref *op)
+ {	stream *s;
+ 	int code;
+ 	check_file(s, op);
+ 	if ( (code = file_close(op, s)) >= 0 )
+ 	   {	/* If we just closed the file from which the interpreter */
+ 		/* is reading, zap it on the exec stack. */
+ 		ref *fp = get_current_file();
+ 		if ( fp != 0 && fptr(fp) == fptr(op) )
+ 			/* A null would confuse the estack parser.... */
+ 			make_tasv(fp, t_array, a_executable+a_execute, 0, refs, (ref *)0);
+ 		pop(1);
+ 	   }
+ 	return code;
+ }
+ 
+ /* read */
+ int
+ zread(register ref *op)
+ {	stream *s;
+ 	int ch;
+ 	check_read_file(s, op);
+ 	check_read(*op);
+ 	ch = sgetc(s);
+ 	if ( ch == EOFC )
+ 		make_bool(op, 0);
+ 	else
+ 	   {	make_int(op, ch);
+ 		push(1);
+ 		make_bool(op, 1);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* unread */
+ int
+ zunread(register ref *op)
+ {	stream *s;
+ 	ulong ch;
+ 	check_read_file(s, op - 1);
+ 	check_type(*op, t_integer);
+ 	ch = op->value.intval;
+ 	if ( ch > 0xff ) return e_rangecheck;
+ 	if ( sungetc(s, (byte)ch) < 0 ) return e_ioerror;
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* write */
+ int
+ zwrite(register ref *op)
+ {	stream *s;
+ 	ulong ch;
+ 	check_write_file(s, op - 1);
+ 	check_write(op[-1]);
+ 	check_type(*op, t_integer);
+ 	ch = op->value.intval;
+ 	if ( ch > 0xff ) return e_rangecheck;
+ 	sputc(s, (byte)ch);
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* readhexstring */
+ int
+ zreadhexstring(register ref *op)
+ {	stream st;
+ 	stream *s;
+ 	ref *op1 = op - 1;
+ 	int odd = -1;
+ 	int code;
+ 	uint nread;
+ 	switch ( r_type(op1) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_file:
+ 		check_read_file(s, op1);
+ 		check_read(*op1);
+ 		break;
+ 	case t_string:
+ 		s = &st;
+ 		sread_string(s, op1->value.bytes, op1->size);
+ 	   }
+ 	check_type(*op, t_string);
+ 	check_write(*op);
+ 	code = sreadhex(s, op->value.bytes, op->size, &nread, &odd);
+ 	switch ( code )
+ 	   {
+ 	case 1:
+ 		/* Reached end-of-file before filling the string. */
+ 		/* Return an appropriate substring. */
+ 		op->size = nread;
+ 		r_set_attrs(op, a_subrange);
+ 		break;
+ 	case 0:
+ 		/* Filled the string. */
+ 		break;
+ 	default:			/* Error */
+ 		return e_ioerror;
+ 	   }
+ 	if ( s == &st )
+ 	   {	/* Reading from a string, return remainder */
+ 		uint pos = stell(&st);
+ 		op1->size -= pos, op1->value.bytes += pos;
+ 		r_set_attrs(op1, a_subrange);
+ 		push(1);
+ 	   }
+ 	else
+ 	   {	/* Reading from a file */
+ 		*op1 = *op;
+ 	   }
+ 	make_bool(op, 1 - code);
+ 	return 0;
+ }
+ 
+ /* writehexstring */
+ int
+ zwritehexstring(register ref *op)
+ {	stream *s;
+ 	byte *p;
+ 	uint len;
+ 	static char *hex_digits = "0123456789abcdef";
+ 	check_write_file(s, op - 1);
+ 	check_write(op[-1]);
+ 	check_read_type(*op, t_string);
+ 	p = op->value.bytes;
+ 	len = op->size;
+ 	while ( len-- )
+ 	   {	byte ch = *p++;
+ 		sputc(s, hex_digits[ch >> 4]);
+ 		sputc(s, hex_digits[ch & 0xf]);
+ 	   }
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* readstring */
+ int
+ zreadstring(register ref *op)
+ {	stream *s;
+ 	uint len, rlen;
+ 	check_read_file(s, op - 1);
+ 	check_read(op[-1]);
+ 	check_write_type(*op, t_string);
+ 	len = op->size;
+ 	rlen = sgets(s, op->value.bytes, len);
+ 	op->size = rlen;
+ 	r_set_attrs(op, a_subrange);
+ 	op[-1] = *op;
+ 	make_bool(op, (rlen == len ? 1 : 0));
+ 	return 0;
+ }
+ 
+ /* writestring */
+ int
+ zwritestring(register ref *op)
+ {	stream *s;
+ 	int code;
+ 	check_write_file(s, op - 1);
+ 	check_write(op[-1]);
+ 	code = write_string(op, s);
+ 	if ( code >= 0 ) pop(2);
+ 	return code;
+ }
+ 
+ /* readline */
+ int
+ zreadline(register ref *op)
+ {	stream *s;
+ 	uint count;
+ 	int code;
+ 	check_read_file(s, op - 1);
+ 	check_read(op[-1]);
+ 	check_write_type(*op, t_string);
+ 	code = zreadline_from(op->value.bytes, op->size, &count, s);
+ 	if ( code < 0 ) return code;
+ 	op->size = count;
+ 	r_set_attrs(op, a_subrange);
+ 	op[-1] = *op;
+ 	make_bool(op, code);
+ 	return 0;
+ }
+ 
+ /* Read a line from stdin.  This is called from gs.c. */
+ int
+ zreadline_stdin(byte *ptr, uint size, uint *pcount)
+ {	return zreadline_from(ptr, size, pcount, std_files[0].s);
+ }
+ 
+ /* Internal readline routine. */
+ /* Returns 1 if OK, 0 if end of file, or an error code. */
+ int
+ zreadline_from(byte *ptr, uint size, uint *pcount, stream *s)
+ {	uint count = 0;
+ 	int ch;
+ 	while ( count < size )
+ 	   {	switch ( ch = sgetc(s) )
+ 		   {
+ 		case '\r':
+ 			ch = sgetc(s);
+ 			if ( ch != '\n' && ch != EOFC ) sputback(s);
+ 			/* falls through */
+ 		case '\n':
+ 			*pcount = count;
+ 			return 1;
+ 		case EOFC:
+ 			*pcount = count;
+ 			return 0;
+ 		   }
+ 		*ptr++ = ch;
+ 		count++;
+ 	   }
+ 	return e_rangecheck;		/* filled the string */
+ }
+ 
+ /* token - this is called from zstring.c */
+ int
+ ztoken_file(register ref *op)
+ {	stream *s;
+ 	ref token;
+ 	int code;
+ 	check_read_file(s, op);
+ 	check_read(*op);
+ 	switch ( code = scan_token(s, 0, &token) )
+ 	   {
+ 	case 0:				/* read a token */
+ 		*op = token;
+ 		push(1);
+ 		make_bool(op, 1);
+ 		return 0;
+ 	case 1:				/* no tokens */
+ 		make_bool(op, 0);
+ 		return 0;
+ 	default:			/* error */
+ 		return code;
+ 	   }
+ }
+ 
+ /* bytesavailable */
+ int
+ zbytesavailable(register ref *op)
+ {	stream *s;
+ 	long avail;
+ 	check_read_file(s, op);
+ 	if ( savailable(s, &avail) < 0 ) return e_ioerror;
+ 	make_int(op, avail);
+ 	return 0;
+ }
+ 
+ /* flush */
+ int
+ zflush(register ref *op)
+ {	sflush(std_files[1].s);
+ 	return 0;
+ }
+ 
+ /* flushfile */
+ int
+ zflushfile(register ref *op)
+ {	stream *s;
+ 	check_file(s, op);
+ 	sflush(s);
+ 	if ( !s->writing )
+ 		fseek(s->file, 0L, 2);	/* set to end */
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* resetfile */
+ int
+ zresetfile(register ref *op)
+ {	NYI("resetfile");
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* status */
+ int
+ zstatus(register ref *op)
+ {	check_type(*op, t_file);
+ 	make_bool(op, (fptr(op)->s != 0 ? 1 : 0));
+ 	return 0;
+ }
+ 
+ /* run */
+ int
+ zrun(register ref *op)
+ {	NYI("run");
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* currentfile */
+ int
+ zcurrentfile(register ref *op)
+ {	ref *fp;
+ 	push(1);
+ 	if ( (fp = get_current_file()) == 0 )
+ 	   {	/* Return an invalid file object. */
+ 		/* This doesn't make a lot of sense to me, */
+ 		/* but it's what the PostScript manual specifies. */
+ 		make_file(op, 0, &invalid_file_entry);
+ 	   }
+ 	else
+ 		*op = *fp;
+ 	/* Make sure the returned value is literal. */
+ 	r_clear_attrs(op, a_executable);
+ 	return 0;
+ }
+ 
+ /* print */
+ int
+ zprint(register ref *op)
+ {	int code = write_string(op, std_files[1].s);
+ 	if ( code >= 0 ) pop(1);
+ 	return code;
+ }
+ 
+ /* echo */
+ int
+ zecho(register ref *op)
+ {	check_type(*op, t_boolean);
+ 	/****** NOT IMPLEMENTED YET ******/
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ------ Level 2 extensions ------ */
+ 
+ /* setfileposition */
+ int
+ zsetfileposition(register ref *op)
+ {	stream *s;
+ 	check_file(s, op - 1);
+ 	check_type(*op, t_integer);
+ 	if ( sseek(s, op->value.intval) < 0 ) return e_ioerror;
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* fileposition */
+ int
+ zfileposition(register ref *op)
+ {	stream *s;
+ 	check_file(s, op);
+ 	if ( !sseekable(s) ) return e_ioerror;
+ 	make_int(op, stell(s));
+ 	return 0;
+ }
+ 
+ /* deletefile */
+ int
+ zdeletefile(register ref *op)
+ {	char *str;
+ 	int stat;
+ 	check_read_type(*op, t_string);
+ 	str = ref_to_string(op, "deletefile");
+ 	if ( str == 0 ) return e_VMerror;
+ 	stat = unlink(str);
+ 	alloc_free(str, op->size + 1, 1, "deletefile");
+ 	if ( stat != 0 ) return e_ioerror;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* renamefile */
+ int
+ zrenamefile(register ref *op)
+ {	char *str1 = 0, *str2 = 0;
+ 	check_read_type(*op, t_string);
+ 	check_read_type(op[-1], t_string);
+ 	str1 = ref_to_string(op - 1, "renamefile(from)");
+ 	str2 = ref_to_string(op, "renamefile(to)");
+ 	if ( str1 != 0 && str2 != 0 && rename(str1, str2) == 0 )
+ 	   {	pop(2);
+ 	   }
+ 	if ( str1 != 0 )
+ 		alloc_free(str1, op[-1].size + 1, 1, "renamefile(from)");
+ 	if ( str2 != 0 )
+ 		alloc_free(str2, op->size + 1, 1, "renamefile(to)");
+ 	return 0;
+ }	
+ 
+ /* ------ Ghostscript extensions ------ */
+ 
+ /* filename */
+ int
+ zfilename(register ref *op)
+ {	stream *s;
+ 	check_file(s, op);
+ 	*op = op->value.pfile->file_name;
+ 	return 0;
+ }
+ 
+ /* findlibfile */
+ int
+ zfindlibfile(register ref *op)
+ {	int code;
+ 	check_type(*op, t_string);
+ 	code = open_std_file(op, "r", op);
+ 	switch ( code )
+ 	   {
+ 	case 0:				/* successful open */
+ 		push(1);
+ 		make_bool(op, 1);
+ 	default:			/* unsuccessful open */
+ 		return code;
+ 	case e_undefinedfilename:	/* not a %file */
+ 		;
+ 	   }
+ 	code = lib_file_open(op->value.bytes, op->size, op);
+ 	push(1);
+ 	make_bool(op, code >= 0);
+ 	return 0;
+ }
+ 
+ /* writeppmfile */
+ int
+ zwriteppmfile(register ref *op)
+ {	stream *s;
+ 	int code;
+ 	check_write_file(s, op - 1);
+ 	check_write(op[-1]);
+ 	check_type(*op, t_device);
+ 	if ( !gs_device_is_memory(op->value.pdevice) ) return e_typecheck;
+ 	sflush(s);
+ 	code = gs_writeppmfile((gx_device_memory *)(op->value.pdevice), s->file);
+ 	if ( code >= 0 ) pop(2);
+ 	return code;
+ }
+ 
+ /* type1decryptfile */
+ int
+ ztype1decryptfile(register ref *op)
+ {	stream *s;
+ 	ushort state;
+ 	ref dec_file;
+ 	int code;
+ 	stream *es;
+ 	check_type(op[-1], t_integer);
+ 	state = op[-1].value.intval;
+ 	if ( op[-1].value.intval != state )
+ 		return e_rangecheck;	/* state value was truncated */
+ 	check_read_file(s, op);
+ 	code = file_open((byte *)0, 0, "r", &dec_file);
+ 	if ( code < 0 ) return code;
+ 	es = fptr(&dec_file)->s;
+ 	sread_decrypt(es, fptr(op)->s, es->cbuf, es->bsize, state);
+ 	op[-1] = dec_file;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zfile_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1bytesavailable", zbytesavailable},
+ 		{"1closefile", zclosefile},
+ 		{"0currentfile", zcurrentfile},
+ 		{"1deletefile", zdeletefile},
+ 		{"1echo", zecho},
+ 		{"2file", zfile},
+ 		{"1filename", zfilename},
+ 		{"1fileposition", zfileposition},
+ 		{"1findlibfile", zfindlibfile},
+ 		{"0flush", zflush},
+ 		{"1flushfile", zflushfile},
+ 		{"1print", zprint},
+ 		{"1read", zread},
+ 		{"2readhexstring", zreadhexstring},
+ 		{"2readline", zreadline},
+ 		{"2readstring", zreadstring},
+ 		{"2renamefile", zrenamefile},
+ 		{"1resetfile", zresetfile},
+ 		{"1run", zrun},
+ 		{"2setfileposition", zsetfileposition},
+ 		{"2type1decryptfile", ztype1decryptfile},
+ 		{"2unread", zunread},
+ 		{"1status", zstatus},
+ 		{"2write", zwrite},
+ 		{"2writehexstring", zwritehexstring},
+ 		{"2writeppmfile", zwriteppmfile},
+ 		{"2writestring", zwritestring},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Non-operator routines ------ */
+ 
+ /* Open a file, using the search paths if necessary. */
+ /* The startup code calls this to open the initialization file ghost.ps, */
+ /* and any other files specified on the command line. */
+ int
+ lib_file_open(byte *fname, uint len, ref *pfile)
+ {	int code;
+ 	char **ppath;
+ #define max_len 200
+ 	char cname[max_len];
+ 	code = file_open(fname, len, "r", pfile);
+ 	if ( code >= 0 ) return code;
+ 	if ( gp_file_name_is_absolute((char *)fname, len) )
+ 		return e_undefinedfilename;
+ 	/* Go through the list of search paths */
+ 	for ( ppath = gs_lib_paths; *ppath != 0; ppath++ )
+ 	   {	char *path = *ppath;
+ 		for ( ; ; )
+ 		   {	/* Find the end of the next path */
+ 			char *npath = path;
+ 			uint plen;
+ 			char *cstr;
+ 			int clen;
+ 			while ( *npath != 0 && *npath != gp_file_name_list_separator )
+ 				npath++;
+ 			plen = npath - path;
+ 			cstr = gp_file_name_concat_string(path, plen,
+ 							  (char *)fname, len);
+ 			/* Concatenate the prefix, combiner, and file name. */
+ 			clen = plen + strlen(cstr) + len;
+ 			if ( clen <= max_len )	/* otherwise punt */
+ 			   {	memcpy(cname, path, plen);
+ 				strcpy(cname + plen, cstr);
+ 				memcpy(cname + clen - len, fname, len);
+ 				code = file_open(cname, clen, "r", pfile);
+ 				if ( code >= 0 ) return code;
+ 			   }
+ 			/****** NYI ******/
+ 			if ( !*npath ) break;
+ 			path = npath + 1;
+ 		   }
+ 	   }
+ 	return code;
+ }
+ 
+ /* Open a file and create a file object. */
+ /* Return 0 if successful, error code if not. */
+ /* If fname==0, set up the file entry, stream, and buffer, */
+ /* but don't open an OS file or initialize the stream. */
+ int
+ file_open(byte *fname, uint len, char *file_access, ref *pfile)
+ {	byte *buffer;
+ 	stream *s;
+ 	file_entry *fe;
+ 	int code;
+ 	if ( len >= buffer_size )
+ 		return e_limitcheck;	/* we copy the file name into the buffer */
+ 	/* Allocate the file entry first, since it persists */
+ 	/* even after the file has been closed. */
+ 	fe = (file_entry *)alloc(1, sizeof(file_entry), "file_open(file_entry)");
+ 	if ( fe == 0 ) return e_VMerror;
+ 	/* Allocate the buffer and stream. */
+ 	buffer = (byte *)alloc(buffer_size, 1, "file_open(buffer)");
+ 	if ( buffer == 0 )
+ 	   {	alloc_free((char *)fe, 1, sizeof(file_entry), "file_open(file_entry)");
+ 		return e_VMerror;
+ 	   }
+ 	s = (stream *)alloc(1, sizeof(stream), "file_open(stream)");
+ 	if ( s == 0 )
+ 	   {	alloc_free((char *)buffer, buffer_size, 1, "file_open(buffer)");
+ 		alloc_free((char *)fe, 1, sizeof(file_entry), "file_open(file_entry)");
+ 		return e_VMerror;
+ 	   }
+ 	if ( fname != 0 )
+ 	   {	/* Copy the name (so we can terminate it with a zero byte.) */
+ 		char *file_name = (char *)buffer;
+ 		FILE *file;
+ 		memcpy(file_name, fname, len);
+ 		file_name[len] = 0;		/* terminate string */
+ 		/* Open the file. */
+ 		file = fopen(file_name, file_access);
+ 		code = e_undefinedfilename;
+ 		if ( file == 0 || (code = string_to_ref(file_name, &fe->file_name, "file_open(file_name)")) < 0 )
+ 		   {	alloc_free((char *)s, 1, sizeof(stream), "file_open(stream)");
+ 			alloc_free((char *)buffer, buffer_size, 1, "file_open(buffer)");
+ 			alloc_free((char *)fe, 1, sizeof(file_entry), "file_open(file_entry)");
+ 			return code;
+ 		   }
+ 		/* Set up the stream. */
+ 		if ( *file_access == 'r' )	/* reading */
+ 			sread_file(s, file, buffer, buffer_size);
+ 		else
+ 			swrite_file(s, file, buffer, buffer_size);
+ 	   }
+ 	else				/* save the buffer and size */
+ 	   {	s->cbuf = buffer;
+ 		s->bsize = buffer_size;
+ 	   }
+ 	fe->s = s;
+ 	fe->can_close = 1;
+ 	make_file(pfile,
+ 		(*file_access == 'r' ? a_read+a_execute : a_write+a_execute),
+ 		fe);
+ 	return 0;
+ }
+ 
+ /* Check a file for reading. */
+ /* The interpreter calls this to check an executable file. */
+ int
+ file_check_read(ref *op, stream **ps)
+ {	stream *s;
+ 	check_file_access(s, op, !s->writing);
+ 	*ps = s;
+ 	return 0;
+ }
+ 
+ /* Get the current file from which the interpreter is reading. */
+ private ref *
+ get_current_file()
+ {	ref *ep = esp;
+ 	while ( ep >= estack )
+ 	{	if ( r_type(ep) == t_file && r_has_attrs(ep, a_executable) )
+ 			return ep;
+ 		ep--;
+ 	}
+ 	return (ref *)0;
+ }
+ 
+ /* Close a file.  The interpreter calls this when */
+ /* it reaches the end of an executable file. */
+ int
+ file_close(ref *fp /* t_file */, stream *s)
+ {	file_entry *fe = fptr(fp);
+ 	byte *buffer = s->cbuf;
+ 	switch ( fe->can_close )
+ 	   {
+ 	case 0:				/* can't close std files */
+ 		return e_invalidaccess;
+ 	case -1:			/* ignore on statement/lineedit */
+ 		sclose(s);
+ 		break;
+ 	default:			/* ordinary file */
+ 		if ( sclose(s) ) return e_ioerror;
+ 		/* Free the stream and buffer in the reverse of the order */
+ 		/* in which they were created, and hope for LIFO storage behavior. */
+ 		alloc_free((char *)s, 1, sizeof(stream), "file_close(stream)");
+ 		alloc_free((char *)buffer, buffer_size, 1, "file_close(buffer)");
+ 	   }
+ 	fe->s = 0;
+ 	return 0;
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* If a file name refers to one of the standard %files, */
+ /* 'open' the file and return 0 or an error code, otherwise */
+ /* return e_undefinedfilename. */
+ private int
+ open_std_file(ref *pfname, char *file_access, ref *pfile)
+ {	int i;
+ 	for ( i = 0; i < num_std_files; i++ )
+ 	  if ( !bytes_compare(pfname->value.bytes, pfname->size,
+ 			    std_file_names[i], strlen(std_file_names[i]))
+ 	    )
+ 	   {	/* This is a standard file */
+ 		int attrs = (*file_access == 'r' ? a_read+a_execute : a_write+a_execute);
+ 		file_entry *fe = &std_files[i];
+ 		if ( attrs != std_file_attrs[i] )
+ 			return e_invalidaccess;
+ 		make_file(pfile, attrs, fe);
+ 		/* If this is %lineedit or %statementedit, */
+ 		/* read a line now. */
+ 		switch ( i )
+ 		   {
+ 		case 3: case 4:
+ 		   {	uint count;
+ 			int code = zreadline_stdin(lineedit_buf,
+ 				lineedit_buf_size, &count);
+ 			if ( code < 0 ) return code;
+ 			fe->s = &std_file_streams[i];
+ 			sread_string(fe->s, lineedit_buf, count);
+ 			return 0;
+ 		   }
+ 		   }
+ 		return 0;
+ 	   }
+ 	return e_undefinedfilename;
+ }
+ 
+ /* Write a string on a file.  The file has been checked for validity, */
+ /* but not the string. */
+ private int
+ write_string(ref *op, stream *s)
+ {	uint len;
+ 	check_read_type(*op, t_string);
+ 	len = op->size;
+ 	if ( sputs(s, op->value.bytes, len) != len ) return e_ioerror;
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zfont.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zfont.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zfont.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,447 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zfont.c */
+ /* Font operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ /*
+  * The following lines used to say:
+  *	#include "gsmatrix.h"
+  *	#include "gxdevice.h"		/. for gxfont.h ./
+  * Tony Li says the longer list is necessary to keep the GNU compiler
+  * happy, but this is pretty hard to understand....
+  */
+ #include	"gxfixed.h"
+ #include	"gxmatrix.h"
+ #include	"gzstate.h"		/* must precede gxdevice */
+ #include	"gxdevice.h"		/* must precede gxfont */
+ #include	"gschar.h"
+ #include "gxfont.h"
+ #include "gxfont1.h"
+ #include "alloc.h"
+ #include "font.h"
+ #include "dict.h"
+ #include "name.h"
+ #include "state.h"
+ #include "store.h"
+ 
+ /* Forward references */
+ private int font_param(P2(ref *, gs_font **));
+ private int add_FID(P2(ref *, gs_font *));
+ private int make_font(P2(ref *, gs_matrix *));
+ private void make_uint_array(P3(ref *, uint *, int));
+ 
+ /* Imported from util.h */
+ extern int num_params(P3(ref *, int, float *));
+ 
+ /* The (global) font directory */
+ private gs_font_dir *ifont_dir;
+ 
+ /* Import systemdict for looking up FontDirectory */
+ extern ref dstack[];
+ #define systemdict (dstack[0])
+ 
+ /* Type 1 auxiliary procedures (defined in zchar.c) */
+ extern int z1_subr_proc(P3(gs_type1_data *, int, byte **));
+ extern int z1_pop_proc(P2(gs_type1_data *, fixed *));
+ 
+ /* Global font-related objects */
+ private ref name_FontDirectory;
+ /* Names of system-known keys in font dictionaries: */
+ private ref name_FontMatrix;
+ private ref name_FontType;
+ private ref name_FontBBox;
+ private ref name_Encoding;		/* only needed for seac */
+ private ref name_PaintType;
+ private ref name_UniqueID;
+ private ref name_BuildChar;
+ private ref name_Type1BuildChar;
+ private ref name_Private;
+ private ref name_CharStrings;		/* only needed for seac */
+ private ref name_FID;
+ /* Names of system-known keys in type 1 font Private dictionary: */
+ private ref name_Subrs;
+ private ref name_lenIV;
+ 
+ /* Default value of lenIV */
+ #define default_lenIV 4
+ 
+ /* Initialize the font operators */
+ void
+ zfont_init()
+ {	ifont_dir = gs_font_dir_alloc(alloc, alloc_free);
+ 
+ 	/* Create the name of the font dictionary. */
+ 	name_enter("FontDirectory", &name_FontDirectory);
+ 
+ 	/* Create the names of the standard elements of */
+ 	/* a font dictionary. */
+ 	name_enter("FontMatrix", &name_FontMatrix);
+ 	name_enter("FontType", &name_FontType);
+ 	name_enter("FontBBox", &name_FontBBox);
+ 	name_enter("Encoding", &name_Encoding);
+ 	name_enter("PaintType", &name_PaintType);
+ 	name_enter("UniqueID", &name_UniqueID);
+ 	name_enter("BuildChar", &name_BuildChar);
+ 	name_enter("Type1BuildChar", &name_Type1BuildChar);
+ 	name_enter("Private", &name_Private);
+ 	name_enter("CharStrings", &name_CharStrings);
+ 	name_enter("FID", &name_FID);
+ 
+ 	/* Create the names of the known entries in */
+ 	/* a type 1 font Private dictionary. */
+ 	name_enter("Subrs", &name_Subrs);
+ 	name_enter("lenIV", &name_lenIV);
+ }
+ 
+ /* definefont */
+ int
+ zdefinefont(register ref *op)
+ {	ref *pFontDirectory;
+ 	int code;
+ 	ref *pfid;
+ 	/* Validate and unpack the font. */
+ 	ref *pmatrix, *ptype, *pbbox, *pencoding, *pcharstrings;
+ 	ref *ppainttype, *puniqueid, *pbuildchar;
+ 	ref *psubrs;
+ 	int paint_type;
+ 	long unique_id;
+ 	static ref no_subrs, no_charstrings;
+ 	int lenIV;
+ 	gs_matrix mat;
+ 	float bbox[4];
+ 	check_op(2);
+ 	check_type(*op, t_dictionary);
+ 	if ( dict_find(dstack, &name_FontDirectory, &pFontDirectory) <= 0 )
+ 		return e_invalidfont;	/* no FontDirectory?? */
+ 	if ( dict_find(op, &name_FontMatrix, &pmatrix) <= 0 ||
+ 	    dict_find(op, &name_FontType, &ptype) <= 0 ||
+ 	       r_type(ptype) != t_integer ||
+ 	       (ulong)(ptype->value.intval) > 255 ||
+ 	    dict_find(op, &name_FontBBox, &pbbox) <= 0 ||
+ 	    dict_find(op, &name_Encoding, &pencoding) <= 0 ||
+ 	    read_matrix(pmatrix, &mat) < 0
+ 	   )
+ 	  return e_invalidfont;
+ 	check_array_else(*pbbox, e_invalidfont);
+ 	check_array_else(*pencoding, e_invalidfont);
+ 	if ( pbbox->size != 4 ||
+ 	    num_params(pbbox->value.refs + 3, 4, bbox) < 0
+ 	   )
+ 	  return e_invalidfont;
+ 	/* If no PaintType entry, set the paint_type member to -1. */
+ 	if ( dict_find(op, &name_PaintType, &ppainttype) <= 0 )
+ 		paint_type = -1;
+ 	else
+ 	   {	if ( r_type(ppainttype) != t_integer ||
+ 		     ppainttype->value.intval < 0 ||
+ 		     ppainttype->value.intval > 0xffff
+ 		   )
+ 			return e_invalidfont;
+ 		paint_type = (int)ppainttype->value.intval;
+ 	   }
+ 	/* If no UniqueID entry, set the unique_id member to -1, */
+ 	/* because the specifications say UniqueID need not be */
+ 	/* present in all fonts -- and if it is, the legal range */
+ 	/* is 0 to 2^24-1.  */
+ 	if ( dict_find(op, &name_UniqueID, &puniqueid) <= 0 )
+ 		unique_id = -1;
+ 	else
+ 	   {	if ( r_type(puniqueid) != t_integer ||
+ 		     puniqueid->value.intval < 0 ||
+ 		     puniqueid->value.intval > ((1L << 24) - 1)
+ 		   )
+ 			return e_invalidfont;
+ 		unique_id = puniqueid->value.intval;
+ 	   }
+ 	/* In contrast to what is stated (or at least implied) in */
+ 	/* the PostScript manual, every font in GhostScript, */
+ 	/* other than type 1 fonts, must have a BuildChar procedure. */
+ 	code = dict_find(op, &name_BuildChar, &pbuildchar);
+ 	/* Pre-initialize the subrs array, just in case. */
+ 	make_tasv(&no_subrs, t_string, 0, 0, bytes, (byte *)0),
+ 	psubrs = &no_subrs;
+ 	make_null(&no_charstrings);
+ 	pcharstrings = &no_charstrings;
+ 	if ( ptype->value.intval == 1 )
+ 	   {	ref *pprivate;
+ 		ref *plenIV;
+ 		if ( code > 0 ||
+ 		    dict_find(op, &name_CharStrings, &pcharstrings) <= 0 ||
+ 		    r_type(pcharstrings) != t_dictionary ||
+ 		    dict_find(op, &name_Private, &pprivate) <= 0 ||
+ 		    r_type(pprivate) != t_dictionary
+ 		   )
+ 			return e_invalidfont;
+ 		if ( dict_find(pprivate, &name_Subrs, &psubrs) > 0 )
+ 		   {	check_array_else(*psubrs, e_invalidfont);
+ 		   }
+ 		if ( dict_find(pprivate, &name_lenIV, &plenIV) > 0 )
+ 		   {	if ( r_type(plenIV) != t_integer ||
+ 			    (ulong)(plenIV->value.intval) > 255 /* arbitrary */
+ 			   )
+ 				return e_invalidfont;
+ 			lenIV = plenIV->value.intval;
+ 		   }
+ 		else
+ 			lenIV = default_lenIV;
+ 		/* Check that the UniqueIDs match.  This is part of the */
+ 		/* Adobe protection scheme, but we may as well emulate it. */
+ 		if ( unique_id >= 0 )
+ 		   {	if ( dict_find(pprivate, &name_UniqueID, &puniqueid) <= 0 ||
+ 			     r_type(puniqueid) != t_integer ||
+ 			     puniqueid->value.intval != unique_id
+ 			   )
+ 				unique_id = -1;
+ 		   }
+ 		pbuildchar = &name_Type1BuildChar;
+ 		r_set_attrs(pbuildchar, a_executable);
+ 	   }
+ 	else				/* not type 1 */
+ 	   {	if ( code <= 0 ) return e_invalidfont;
+ 		check_proc(*pbuildchar);
+ 	   }
+ 	code = dict_find(op, &name_FID, &pfid);
+ 	if ( r_attrs(op) & a_write )
+ 	   {	/* Assume this is a new font */
+ 		gs_font *pfont;
+ 		font_data *pdata;
+ 		if ( code > 0 ) return e_invalidfont;	/* has FID already */
+ 		if ( (pfont = (gs_font *)alloc(1, sizeof(gs_font), "definefont(font)")) == 0 ||
+ 		     (pdata = (font_data *)alloc(1, sizeof(font_data), "definefont(data)")) == 0
+ 		   )
+ 		  return e_VMerror;
+ 		if ( (code = add_FID(op, pfont)) < 0 ) return code;
+ 		store_i(&pdata->dict, op);
+ 		store_i(&pdata->BuildChar, pbuildchar);
+ 		store_i(&pdata->Encoding, pencoding);
+ 		store_i(&pdata->CharStrings, pcharstrings);
+ 		store_i(&pdata->Subrs, psubrs);
+ 		pdata->type1_data.subr_proc = z1_subr_proc;
+ 		pdata->type1_data.pop_proc = z1_pop_proc;
+ 		pdata->type1_data.proc_data = (char *)pdata;
+ 		pdata->type1_data.lenIV = lenIV;
+ 		pfont->base = pfont;
+ 		pfont->dir = ifont_dir;
+ 		pfont->client_data = (char *)pdata;
+ 		pfont->matrix = mat;
+ 		pfont->font_type = ptype->value.intval;
+ 		pfont->xmin = bbox[0];
+ 		pfont->ymin = bbox[1];
+ 		pfont->xmax = bbox[2];
+ 		pfont->ymax = bbox[3];
+ 		pfont->build_char_proc = gs_no_build_char_proc;
+ 		pfont->paint_type = paint_type;
+ 		pfont->unique_id = unique_id;
+ 	   }
+ 	else
+ 	   {	/* Assume this was made by makefont or scalefont */
+ 		if ( code <= 0 ) return e_invalidfont;	/* no FID */
+ 	   }
+ 	r_clear_attrs(op, a_write);	/****** SHOULD ALTER DICT ACCESS ******/
+ 	if ( (code = dict_put(pFontDirectory, op - 1, op)) < 0 ) return code;
+ 	op[-1] = *op;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* scalefont */
+ int
+ zscalefont(register ref *op)
+ {	int code;
+ 	float scale;
+ 	gs_matrix mat;
+ 	if ( (code = num_params(op, 1, &scale)) < 0 ) return code;
+ 	if ( (code = gs_make_scaling(scale, scale, &mat)) < 0 ) return code;
+ 	return make_font(op, &mat);
+ }
+ 
+ /* makefont */
+ int
+ zmakefont(register ref *op)
+ {	int code;
+ 	gs_matrix mat;
+ 	if ( (code = read_matrix(op, &mat)) < 0 ) return code;
+ 	return make_font(op, &mat);
+ }
+ 
+ /* setfont */
+ int
+ zsetfont(register ref *op)
+ {	gs_font *pfont;
+ 	int code = font_param(op, &pfont);
+ 	if ( code < 0 || (code = gs_setfont(igs, pfont)) < 0 )
+ 	  return code;
+ 	istate.font = *op;
+ 	pop(1);
+ 	return code;
+ }
+ 
+ /* currentfont */
+ int
+ zcurrentfont(register ref *op)
+ {	push(1);
+ 	*op = istate.font;
+ 	return 0;
+ }
+ 
+ /* cachestatus */
+ int
+ zcachestatus(register ref *op)
+ {	uint status[7];
+ 	gs_cachestatus(ifont_dir, status);
+ 	push(7);
+ 	make_uint_array(op - 6, status, 7);
+ 	return 0;
+ }
+ 
+ /* setcachelimit */
+ int
+ zsetcachelimit(register ref *op)
+ {	int code = num_params(op, 1, (float *)0);
+ 	long limit;
+ 	if ( code != 1 ) return (code < 0 ? code : e_typecheck);
+ 	limit = op->value.intval;
+ 	if ( limit < 0 || limit > max_uint )
+ 		return e_rangecheck;
+ 	gs_setcachelimit(ifont_dir, (uint)limit);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* setcacheparams */
+ int
+ zsetcacheparams(register ref *op)
+ {	uint params[2];
+ 	int i, code;
+ 	for ( i = 0; i < 2 && r_type(op - i) != t_mark ; i++ )
+ 	   {	long parm;
+ 		code = num_params(op - i, 1, (float *)0);
+ 		if ( code != 1 ) return (code < 0 ? code : e_typecheck);
+ 		parm = op[-i].value.intval;
+ 		if ( parm < 0 || parm > max_uint )
+ 			return e_rangecheck;
+ 		params[i] = parm;
+ 	   }
+ 	switch ( i )
+ 	   {
+ 	case 2:
+ 		if ( (code = gs_setcachelower(ifont_dir, params[1])) < 0 )
+ 			return code;
+ 	case 1:
+ 		if ( (code = gs_setcacheupper(ifont_dir, params[0])) < 0 )
+ 			return code;
+ 	case 0: ;
+ 	   }
+ 	return zcleartomark(op);
+ }
+ 
+ /* currentcacheparams */
+ int
+ zcurrentcacheparams(register ref *op)
+ {	uint params[2];
+ 	params[0] = gs_currentcachelower(ifont_dir);
+ 	params[1] = gs_currentcacheupper(ifont_dir);
+ 	push(3);
+ 	make_tv(op - 2, t_mark, intval, 0);
+ 	make_uint_array(op - 1, params, 2);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zfont_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0currentfont", zcurrentfont},
+ 		{"2definefont", zdefinefont},
+ 		{"2makefont", zmakefont},
+ 		{"2scalefont", zscalefont},
+ 		{"1setfont", zsetfont},
+ 		{"0cachestatus", zcachestatus},
+ 		{"1setcachelimit", zsetcachelimit},
+ 		{"1setcacheparams", zsetcacheparams},
+ 		{"0currentcacheparams", zcurrentcacheparams},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Subroutines ------ */
+ 
+ /* Validate a font parameter. */
+ private int
+ font_param(ref *fp, gs_font **pfont)
+ {	/* Check that fp is a read-only dictionary, */
+ 	/* and that it has a FID entry. */
+ 	ref *pid;
+ 	int code;
+ 	check_type(*fp, t_dictionary);
+ 	if ( (code = dict_find(fp, &name_FID, &pid)) < 0 ) return code;
+ 	*pfont = pid->value.pfont;
+ 	if ( *pfont == 0 ) return e_invalidfont; /* unregistered font */
+ 	return 0;
+ }
+ 
+ /* Add the FID entry to a font dictionary. */
+ private int
+ add_FID(ref *fp /* t_dictionary */,  gs_font *pfont)
+ {	ref fid;
+ 	make_tv(&fid, t_fontID, pfont, pfont);
+ 	return dict_put(fp, &name_FID, &fid);
+ }
+ 
+ /* Make a transformed font (common code for makefont/scalefont). */
+ private int
+ make_font(ref *op, gs_matrix *pmat)
+ {	ref *fp = op - 1;
+ 	gs_font *oldfont, *newfont, *ffont;
+ 	ref newdict;
+ 	ref newmat;
+ 	int code;
+ 	make_int(&newmat, 6);	/* for zarray */
+ 	if ( (code = font_param(fp, &oldfont)) < 0 ||
+ 	     (code = gs_makefont(ifont_dir, oldfont, pmat,
+ 				 &newfont, &ffont)) < 0 ||
+ 	     (code = dict_create(dict_maxlength(fp), &newdict)) < 0 ||
+ 	     (code = dict_copy(fp, &newdict)) < 0 ||
+ 	     (code = zarray(&newmat)) < 0 ||
+ 	     (code = dict_put(&newdict, &name_FontMatrix, &newmat)) < 0 ||
+ 	     (code = add_FID(&newdict, newfont)) < 0
+ 	   )
+ 	  return code;
+ 	*(gs_matrix *)(newmat.value.refs) = newfont->matrix;
+ 	if ( ffont )
+ 	  { /****** SHOULD DECREMENT REFCT ******/
+ 	  }
+ 	*fp = newdict;
+ 	r_clear_attrs(fp, a_write);	/****** SHOULD SET DICT ACCESS ******/
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* Convert an array of (unsigned) integers to stack form. */
+ private void
+ make_uint_array(register ref *op, uint *intp, int count)
+ {	int i;
+ 	for ( i = 0; i < count; i++, op++, intp++ )
+ 		make_int(op, *intp);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zgeneric.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zgeneric.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zgeneric.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,362 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zgeneric.c */
+ /* Array/string/dictionary generic operators for PostScript */
+ #include "memory_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "dict.h"
+ #include "estack.h"	/* for forall */
+ #include "store.h"
+ 
+ /* This file implements copy, get, put, getinterval, putinterval, */
+ /* length, and forall, which apply generically to */
+ /* arrays, strings, and dictionaries.  (Copy also has a special */
+ /* meaning for copying the top N elements of the stack.) */
+ 
+ /* Forward references */
+ private int copy_interval(P3(ref *, uint, ref*));
+ 
+ /* copy */
+ /* Note that this implements copy for arrays and strings, */
+ /* but not for dictionaries (see zcopy_dict in zdict.c). */
+ int
+ zcopy(register ref *op)
+ {	int code;
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_integer:
+ 	   {	int count;
+ 		if ( (ulong)op->value.intval > op - osbot )
+ 			return e_rangecheck;
+ 		count = op->value.intval;
+ 		if ( op - 1 + count > ostop )
+ 			return e_stackoverflow;
+ 		memcpy((char *)op, (char *)(op - count), count * sizeof(ref));
+ 		push(count - 1);
+ 		return 0;
+ 	   }
+ 	case t_array:
+ 	case t_packedarray:
+ 	case t_string:
+ 		code = copy_interval(op, 0, op - 1);
+ 		break;
+ 	case t_dictionary:
+ 		return zcopy_dict(op);
+ 	default:
+ 		return e_typecheck;
+ 	   }
+ 	if ( code ) return code;	/* error */
+ 	op->size = op[-1].size;
+ 	op[-1] = *op;
+ 	r_set_attrs(op - 1, a_subrange);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* length */
+ int
+ zlength(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	case t_array:
+ 	case t_packedarray:
+ 	case t_string:
+ 		check_read(*op);
+ 		make_int(op, op->size);
+ 		return 0;
+ 	case t_dictionary:
+ 		check_dict_read(*op);
+ 		make_int(op, dict_length(op));
+ 		return 0;
+ 	case t_name:
+ 	   {	/* The PostScript manual doesn't allow length on names, */
+ 		/* but the implementations apparently do. */
+ 		ref str;
+ 		name_string_ref(op, &str);
+ 		make_int(op, str.size);
+ 	   }
+ 		return 0;
+ 	default:
+ 		return e_typecheck;
+ 	   }
+ }
+ 
+ /* get */
+ int
+ zget(register ref *op)
+ {	ref *op1 = op - 1;
+ 	ref *pvalue;
+ 	switch ( r_type(op1) )
+ 	   {
+ 	case t_dictionary:
+ 		check_dict_read(*op1);
+ 		if ( dict_find(op1, op, &pvalue) <= 0 ) return e_undefined;
+ 		break;
+ 	case t_array:
+ 	case t_packedarray:
+ 		check_type(*op, t_integer);
+ 		check_read(*op1);
+ 		if ( (ulong)(op->value.intval) >= op1->size )
+ 			return e_rangecheck;
+ 		pvalue = op1->value.refs + (uint)op->value.intval;
+ 		break;
+ 	case t_string:
+ 		check_type(*op, t_integer);
+ 		check_read(*op1);
+ 		if ( (ulong)(op->value.intval) >= op1->size )
+ 			return e_rangecheck;
+ 	   {	int element = op1->value.bytes[(uint)op->value.intval];
+ 		make_int(op1, element);
+ 		pop(1);
+ 	   }
+ 		return 0;
+ 	default:
+ 		return e_typecheck;
+ 	   }
+ 	op[-1] = *pvalue;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* put */
+ int
+ zput(register ref *op)
+ {	ref *op1 = op - 1;
+ 	ref *op2 = op1 - 1;
+ 	switch ( r_type(op2) )
+ 	   {
+ 	case t_dictionary:
+ 		check_dict_write(*op2);
+ 	   {	int code = dict_put(op2, op1, op);
+ 		if ( code ) return code;	/* error */
+ 	   }
+ 		break;
+ 	case t_array:
+ 		check_type(*op1, t_integer);
+ 		check_write(*op2);
+ 		if ( op1->value.intval < 0 || op1->value.intval >= op2->size )
+ 			return e_rangecheck;
+ 		store_i(op2->value.refs + (uint)op1->value.intval, op);
+ 		break;
+ 	case t_packedarray:		/* packed arrays are read-only */
+ 		return e_invalidaccess;
+ 	case t_string:
+ 		check_type(*op1, t_integer);
+ 		check_write(*op2);
+ 		if ( op1->value.intval < 0 || op1->value.intval >= op2->size )
+ 			return e_rangecheck;
+ 		check_type(*op, t_integer);
+ 		if ( (ulong)op->value.intval > 0xff )
+ 			return e_rangecheck;
+ 		op2->value.bytes[(uint)op1->value.intval] = (byte)op->value.intval;
+ 		break;
+ 	default:
+ 		return e_typecheck;
+ 	   }
+ 	pop(3);
+ 	return 0;
+ }
+ 
+ /* getinterval */
+ int
+ zgetinterval(register ref *op)
+ {	ref *op1 = op - 1;
+ 	ref *op2 = op1 - 1;
+ 	uint index;
+ 	uint count;
+ 	check_type(*op1, t_integer);
+ 	check_type(*op, t_integer);
+ 	switch ( r_type(op2) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_array: case t_packedarray: case t_string: ;
+ 	   }
+ 	check_read(*op2);
+ 	if ( (ulong)op1->value.intval > op2->size ) return e_rangecheck;
+ 	index = op1->value.intval;
+ 	if ( (ulong)op->value.intval > op2->size - index ) return e_rangecheck;
+ 	count = op->value.intval;
+ 	switch ( r_type(op2) )
+ 	   {
+ 	case t_array:
+ 	case t_packedarray: op2->value.refs += index; break;
+ 	case t_string: op2->value.bytes += index; break;
+ 	   }
+ 	op2->size = count;
+ 	r_set_attrs(op2, a_subrange);
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* putinterval */
+ int
+ zputinterval(register ref *op)
+ {	ref *opindex = op - 1;
+ 	ref *opto = opindex - 1;
+ 	int code;
+ 	check_type(*opindex, t_integer);
+ 	switch ( r_type(opto) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_packedarray: return e_invalidaccess;
+ 	case t_array: case t_string: ;
+ 	   }
+ 	check_write(*opto);
+ 	if ( (ulong)opindex->value.intval > opto->size ) return e_rangecheck;
+ 	code = copy_interval(opto, (uint)(opindex->value.intval), op);
+ 	if ( code >= 0 ) pop(3);
+ 	return 0;
+ }
+ 
+ /* forall */
+ private int
+   array_continue(P1(ref *)),
+   string_continue(P1(ref *)),
+   dict_continue(P1(ref *));
+ int
+ zforall(register ref *op)
+ {	int (*cproc)(P1(ref *));
+ 	ref *obj = op - 1;
+ 	uint index;
+ 	switch ( r_type(obj) )
+ 	   {
+ 	default:
+ 		return e_typecheck;
+ 	case t_array:
+ 	case t_packedarray:
+ 		check_read(*obj);
+ 		cproc = array_continue;
+ 		index = 0;		/* not used */
+ 		break;
+ 	case t_string:
+ 		check_read(*obj);
+ 		cproc = string_continue;
+ 		index = 0;		/* not used */
+ 		break;
+ 	case t_dictionary:
+ 		check_dict_read(*obj);
+ 		cproc = dict_continue;
+ 		index = dict_first(obj);
+ 		break;
+ 	   }
+ 	/* Push a mark, the composite object, the iteration index, */
+ 	/* and the procedure, and invoke the continuation operator. */
+ 	check_estack(6);
+ 	mark_estack(es_for);
+ 	*++esp = *obj;
+ 	++esp;
+ 	make_int(esp, index);
+ 	*++esp = *op;
+ 	pop(2);  op -= 2;
+ 	return (*cproc)(op);
+ }
+ /* Continuation operator for arrays */
+ private int
+ array_continue(register ref *op)
+ {	ref *obj = esp - 2;
+ 	if ( obj->size-- )		/* continue */
+ 	   {	push(1);
+ 		*op = *obj->value.refs;
+ 		obj->value.refs++;
+ 		push_op_estack(array_continue);	/* push continuation */
+ 		*++esp = obj[2];
+ 	   }
+ 	else				/* done */
+ 	   {	esp -= 4;		/* pop mark, object, index, proc */
+ 	   }
+ 	return o_check_estack;
+ }
+ /* Continuation operator for strings */
+ private int
+ string_continue(register ref *op)
+ {	ref *obj = esp - 2;
+ 	if ( obj->size-- )		/* continue */
+ 	   {	push(1);
+ 		make_int(op, *obj->value.bytes);
+ 		obj->value.bytes++;
+ 		push_op_estack(string_continue);	/* push continuation */
+ 		*++esp = obj[2];
+ 	   }
+ 	else				/* done */
+ 	   {	esp -= 4;		/* pop mark, object, index, proc */
+ 	   }
+ 	return o_check_estack;
+ }
+ /* Continuation operator for dictionaries */
+ private int
+ dict_continue(register ref *op)
+ {	ref *obj = esp - 2;
+ 	int index = (int)esp[-1].value.intval;
+ 	push(2);			/* make room for key and value */
+ 	if ( (index = dict_next(obj, index, op - 1)) >= 0 )	/* continue */
+ 	   {	esp[-1].value.intval = index;
+ 		push_op_estack(dict_continue);	/* push continuation */
+ 		*++esp = obj[2];
+ 	   }
+ 	else				/* done */
+ 	   {	pop(2);			/* undo push */
+ 		esp -= 4;		/* pop mark, object, index, proc */
+ 	   }
+ 	return o_check_estack;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zgeneric_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1copy", zcopy},
+ 		{"2forall", zforall},
+ 		{"2get", zget},
+ 		{"3getinterval", zgetinterval},
+ 		{"1length", zlength},
+ 		{"3put", zput},
+ 		{"3putinterval", zputinterval},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Shared routines ------ */
+ 
+ /* Copy an interval from one operand to another. */
+ /* This is used by both putinterval and string/array copy. */
+ /* One operand is known to be an array or string, */
+ /* and the starting index is known to be less than or equal to */
+ /* its length; nothing else has been checked. */
+ private int
+ copy_interval(ref *prto, uint index, ref *prfrom)
+ {	if ( r_type(prfrom) != r_type(prto) ) return e_typecheck;
+ 	check_read(*prfrom);
+ 	check_write(*prto);
+ 	if ( prfrom->size > prto->size - index ) return e_rangecheck;
+ 	switch ( r_type(prto) )
+ 	   {
+ 	case t_array:
+ 	case t_packedarray:
+ 		refcpy(prto->value.refs + index, prfrom->value.refs, prfrom->size);
+ 		break;
+ 	case t_string:
+ 		memcpy(prto->value.bytes + index, prfrom->value.bytes, prfrom->size);
+ 	   }
+ 	return 0;
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zgstate.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zgstate.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zgstate.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,378 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zgstate.c */
+ /* Graphics state operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "gsmatrix.h"
+ #include "gsstate.h"
+ #include "state.h"
+ #include "store.h"
+ 
+ /* Forward references */
+ private int num_param(P2(ref *, int (*)(P2(gs_state *, floatp))));
+ private int line_param(P2(ref *, int *));
+ 
+ /* Imported from util.c */
+ extern	int	real_param(P3(ref *, float *, int));
+ extern	int	num_params(P3(ref *, int, float *));
+ 
+ /* Forward declarations */
+ void	tri_put(P2(ref *, float [3]));
+ 
+ /* The current graphics state */
+ gs_state *igs;
+ int_state istate;
+ 
+ /* Initialize the graphics stack. */
+ void
+ gs_init()
+ {	igs = gs_state_alloc(alloc, alloc_free);
+ 	istate.saved = 0;
+ 	make_null(&istate.screen_proc);
+ 	make_null(&istate.transfer);
+ }
+ 
+ /* gsave */
+ int
+ zgsave(register ref *op)
+ {	int_state *pis = (int_state *)alloc(1, sizeof(int_state), "gsave");
+ 	if ( gs_gsave(igs) < 0 || pis == 0 )
+ 		return e_limitcheck;
+ 	*pis = istate;
+ 	istate.saved = pis;
+ 	return 0;
+ }
+ 
+ /* grestore */
+ int
+ zgrestore(register ref *op)
+ {	if ( gs_grestore(igs) >= 0 )
+ 	   {	int_state *pis = istate.saved;
+ 		istate = *pis;
+ 		alloc_free((char *)pis, 1, sizeof(int_state), "grestore");
+ 	   }
+ 	return 0;
+ }
+ 
+ /* grestoreall */
+ int
+ zgrestoreall(register ref *op)
+ {	gs_grestoreall(igs);
+ 	while ( istate.saved != 0 )
+ 	   {	int_state *pis = istate.saved;
+ 		istate = *pis;
+ 		alloc_free((char *)pis, 1, sizeof(int_state), "restoreall");
+ 	   }
+ 	return 0;
+ }
+ 
+ /* initgraphics */
+ int
+ zinitgraphics(register ref *op)
+ {	return gs_initgraphics(igs);
+ }
+ 
+ /* setlinewidth */
+ int
+ zsetlinewidth(register ref *op)
+ {	return num_param(op, gs_setlinewidth);
+ }
+ 
+ /* currentlinewidth */
+ int
+ zcurrentlinewidth(register ref *op)
+ {	push(1);
+ 	make_real(op, gs_currentlinewidth(igs));
+ 	return 0;
+ }
+ 
+ /* setlinecap */
+ int
+ zsetlinecap(register ref *op)
+ {	int param;
+ 	int code = line_param(op, &param);
+ 	if ( !code ) code = gs_setlinecap(igs, (gs_line_cap)param);
+ 	return code;
+ }
+ 
+ /* currentlinecap */
+ int
+ zcurrentlinecap(register ref *op)
+ {	push(1);
+ 	make_int(op, (int)gs_currentlinecap(igs));
+ 	return 0;
+ }
+ 
+ /* setlinejoin */
+ int
+ zsetlinejoin(register ref *op)
+ {	int param;
+ 	int code = line_param(op, &param);
+ 	if ( !code ) code = gs_setlinejoin(igs, (gs_line_join)param);
+ 	return code;
+ }
+ 
+ /* currentlinejoin */
+ int
+ zcurrentlinejoin(register ref *op)
+ {	push(1);
+ 	make_int(op, (int)gs_currentlinejoin(igs));
+ 	return 0;
+ }
+ 
+ /* setmiterlimit */
+ int
+ zsetmiterlimit(register ref *op)
+ {	return num_param(op, gs_setmiterlimit);
+ }
+ 
+ /* currentmiterlimit */
+ int
+ zcurrentmiterlimit(register ref *op)
+ {	push(1);
+ 	make_real(op, gs_currentmiterlimit(igs));
+ 	return 0;
+ }
+ 
+ /* setdash */
+ int
+ zsetdash(register ref *op)
+ {	float offset;
+ 	uint n, i;
+ 	ref *dfrom;
+ 	float *pattern, *dto;
+ 	int code = real_param(op, &offset, 0);
+ 	if ( code ) return code;
+ 	check_array(op[-1]);
+ 	check_read(op[-1]);
+ 	/* Unpack the dash pattern and check it */
+ 	dfrom = op[-1].value.refs;
+ 	i = n = op[-1].size;
+ 	pattern = dto = (float *)alloc(n, sizeof(float), "setdash");
+ 	while ( i-- )
+ 	   {	switch ( r_type(dfrom) )
+ 		   {
+ 		case t_integer:
+ 			*dto++ = dfrom->value.intval;
+ 			break;
+ 		case t_real:
+ 			*dto++ = dfrom->value.realval;
+ 			break;
+ 		default:
+ 			alloc_free((char *)dto, n, sizeof(float), "setdash");
+ 			return e_typecheck;
+ 		   }
+ 		dfrom++;
+ 	   }
+ 	code = gs_setdash(igs, pattern, n, offset);
+ 	if ( !code ) pop(2);
+ 	return code;
+ }
+ 
+ /* currentdash */
+ int
+ zcurrentdash(register ref *op)
+ {	int n = gs_currentdash_length(igs);
+ 	int i = n;
+ 	ref *pattern = (ref *)alloc(n, sizeof(ref), "currentdash");
+ 	ref *dto = pattern;
+ 	float *dfrom = (float *)((char *)pattern + n * (sizeof(ref) - sizeof(float)));
+ 	gs_currentdash_pattern(igs, dfrom);
+ 	while ( i-- )
+ 	   {	make_real(dto, *dfrom);
+ 		dto++, dfrom++;
+ 	   }
+ 	push(2);
+ 	make_tasv(op - 1, t_array, a_all, n, refs, pattern);
+ 	make_real(op, gs_currentdash_offset(igs));
+ 	return 0;
+ }
+ 
+ /* setflat */
+ int
+ zsetflat(register ref *op)
+ {	return num_param(op, gs_setflat);
+ }
+ 
+ /* currentflat */
+ int
+ zcurrentflat(register ref *op)
+ {	push(1);
+ 	make_real(op, gs_currentflat(igs));
+ 	return 0;
+ }
+ 
+ /* .setgray */
+ int
+ zsetgray(register ref *op)
+ {	return num_param(op, gs_setgray);
+ }
+ 
+ /* currentgray */
+ int
+ zcurrentgray(register ref *op)
+ {	push(1);
+ 	make_real(op, gs_currentgray(igs));
+ 	return 0;
+ }
+ 
+ /* sethsbcolor */
+ int
+ zsethsbcolor(register ref *op)
+ {	float par[3];
+ 	int code;
+ 	if (	(code = num_params(op, 3, par)) >= 0 &&
+ 		(code = gs_sethsbcolor(igs, par[0], par[1], par[2])) >= 0
+ 	   )
+ 		pop(3);
+ 	return code;
+ }
+ 
+ /* currenthsbcolor */
+ int
+ zcurrenthsbcolor(register ref *op)
+ {	float par[3];
+ 	gs_currenthsbcolor(igs, par);
+ 	push(3);
+ 	tri_put(op, par);
+ 	return 0;
+ }
+ 
+ /* setrgbcolor */
+ int
+ zsetrgbcolor(register ref *op)
+ {	float par[3];
+ 	int code;
+ 	if (	(code = num_params(op, 3, par)) >= 0 &&
+ 		(code = gs_setrgbcolor(igs, par[0], par[1], par[2])) >= 0
+ 	   )
+ 		pop(3);
+ 	return code;
+ }
+ 
+ /* currentrgbcolor */
+ int
+ zcurrentrgbcolor(register ref *op)
+ {	float par[3];
+ 	gs_currentrgbcolor(igs, par);
+ 	push(3);
+ 	tri_put(op, par);
+ 	return 0;
+ }
+ 
+ /* settransfer */
+ int
+ zsettransfer(register ref *op)
+ {	check_proc(*op);
+ 	istate.transfer = *op;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* currenttransfer */
+ int
+ zcurrenttransfer(register ref *op)
+ {	push(1);
+ 	*op = istate.transfer;
+ 	return 0;
+ }
+ 
+ /* currentscreen */
+ int
+ zcurrentscreen(register ref *op)
+ {	float freq, angle;
+ 	float (*proc)(P2(floatp, floatp));
+ 	gs_currentscreen(igs, &freq, &angle, &proc);
+ 	push(3);
+ 	make_real(op - 2, freq);
+ 	make_real(op - 1, angle);
+ 	*op = istate.screen_proc;
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zgstate_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0currentdash", zcurrentdash},
+ 		{"0currentflat", zcurrentflat},
+ 		{"0currentgray", zcurrentgray},
+ 		{"0currenthsbcolor", zcurrenthsbcolor},
+ 		{"0currentlinecap", zcurrentlinecap},
+ 		{"0currentlinejoin", zcurrentlinejoin},
+ 		{"0currentlinewidth", zcurrentlinewidth},
+ 		{"0currentmiterlimit", zcurrentmiterlimit},
+ 		{"0currentrgbcolor", zcurrentrgbcolor},
+ 		{"0currentscreen", zcurrentscreen},
+ 		{"0currenttransfer", zcurrenttransfer},
+ 		{"0grestore", zgrestore},
+ 		{"0grestoreall", zgrestoreall},
+ 		{"0gsave", zgsave},
+ 		{"0initgraphics", zinitgraphics},
+ 		{"2setdash", zsetdash},
+ 		{"1setflat", zsetflat},
+ 		{"1.setgray", zsetgray},
+ 		{"3sethsbcolor", zsethsbcolor},
+ 		{"1setlinecap", zsetlinecap},
+ 		{"1setlinejoin", zsetlinejoin},
+ 		{"1setlinewidth", zsetlinewidth},
+ 		{"1setmiterlimit", zsetmiterlimit},
+ 		{"3setrgbcolor", zsetrgbcolor},
+ 		{"1settransfer", zsettransfer},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Get a numeric parameter */
+ private int
+ num_param(ref *op, int (*pproc)(P2(gs_state *, floatp)))
+ {	float param;
+ 	int code = real_param(op, &param, 0);
+ 	if ( !code ) code = (*pproc)(igs, param);
+ 	if ( !code ) pop(1);
+ 	return code;
+ }
+ 
+ /* Get an integer parameter 0-2. */
+ private int
+ line_param(register ref *op, int *pparam)
+ {	check_type(*op, t_integer);
+ 	if ( op->value.intval < 0 || op->value.intval > 2 )
+ 		return e_rangecheck;
+ 	*pparam = (int)op->value.intval;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* Put 3 reals on the operand stack. */
+ /* This routine is also used by zcolor.c. */
+ void
+ tri_put(register ref *op, float pf3[3])
+ {	make_real(op - 2, pf3[0]);
+ 	make_real(op - 1, pf3[1]);
+ 	make_real(op, pf3[2]);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zht.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zht.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zht.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,120 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zht.c */
+ /* Halftone operator and rendering for GhostScript */
+ #include "ghost.h"
+ #include "memory_.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "estack.h"
+ #include "gsmatrix.h"
+ #include "gsstate.h"
+ #include "state.h"
+ #include "store.h"
+ 
+ /* Forward references */
+ private int screen_sample(P1(ref *));
+ private int set_screen_continue(P1(ref *));
+ 
+ /* Imported from util.c */
+ extern	int	num_params(P3(ref *, int, float *));
+ 
+ /* The setscreen operator is complex because it has to sample */
+ /* each pixel in the pattern cell, calling a procedure, and then */
+ /* sort the result into a whitening order. */
+ 
+ /* Layout of stuff pushed on estack: */
+ /*	Control mark, */
+ /*	spot procedure, */
+ /*	enumeration structure (as bytes). */
+ #define snumpush 3
+ #define sproc esp[-1]
+ #define senum (gs_screen_enum *)esp->value.bytes
+ 
+ /* setscreen */
+ int
+ zsetscreen(register ref *op)
+ {	float fa[2];
+ 	int code = num_params(op - 1, 2, fa);
+ 	gs_screen_enum *penum;
+ 	if ( code < 0 ) return code;
+ 	check_proc(*op);
+ 	penum = (gs_screen_enum *)alloc(1, gs_screen_enum_sizeof, "setscreen");
+ 	if ( penum == 0 ) return e_VMerror;
+ 	code = gs_screen_init(penum, igs, fa[0], fa[1]);
+ 	if ( code < 0 )
+ 	   {	alloc_free((char *)penum, 1, gs_screen_enum_sizeof, "setscreen");
+ 		return code;
+ 	   }
+ 	/* Push everything on the estack */
+ 	check_estack(snumpush);
+ 	mark_estack(es_other);
+ 	*++esp = *op;			/* sproc = proc */
+ 	++esp;
+ 	make_tasv(esp, t_string, 0, gs_screen_enum_sizeof, bytes, (byte *)penum);
+ 	pop(3);  op -= 3;
+ 	return screen_sample(op);
+ }
+ /* Set up the next sample */
+ private int
+ screen_sample(register ref *op)
+ {	gs_screen_enum *penum = senum;
+ 	gs_point pt;
+ 	int code = gs_screen_currentpoint(penum, &pt);
+ 	int set_screen_continue(P1(ref *));
+ 	ref proc;
+ 	if ( code < 0 ) return code;
+ 	if ( code != 0 )
+ 	   {	/* All done */
+ 		istate.screen_proc = sproc;
+ 		esp -= snumpush;
+ 		return o_check_estack;
+ 	   }
+ 	push(2);
+ 	make_real(op - 1, pt.x);
+ 	make_real(op, pt.y);
+ 	proc = sproc;
+ 	push_op_estack(set_screen_continue);
+ 	*++esp = proc;
+ 	return o_check_estack;
+ }
+ /* Continuation procedure for processing sampled pixels. */
+ private int
+ set_screen_continue(register ref *op)
+ {	float value;
+ 	int code = num_params(op, 1, &value);
+ 	if ( code < 0 ) return code;
+ 	code = gs_screen_next(senum, value);
+ 	if ( code < 0 ) return code;
+ 	pop(1);  op--;
+ 	return screen_sample(op);
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zht_op_init()
+ {	static op_def my_defs[] = {
+ 		{"3setscreen", zsetscreen},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmath.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmath.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmath.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,223 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zmath.c */
+ /* Mathematical operators for GhostScript */
+ #include "math_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ 
+ /* Imported from util.h */
+ extern int num_params(P3(ref *, int, float *));
+ 
+ /* Factors for converting between degrees and radians */
+ double degrees_to_radians = M_PI / 180.0;
+ double radians_to_degrees = 180.0 / M_PI;
+ 
+ /* Current state of random number generator. */
+ /* We have to implement this ourselves because */
+ /* the Unix rand doesn't provide anything equivalent to rrand. */
+ private ulong rand_state;
+ 
+ /* Initialize the random number generator. */
+ void
+ zmath_init()
+ {	rand_state = 1;
+ }
+ 
+ /****** NOTE: none of these operators currently ******/
+ /****** check for floating over- or underflow.	******/
+ 
+ /* sqrt */
+ int
+ zsqrt(register ref *op)
+ {	float num;
+ 	int code = num_params(op, 1, &num);
+ 	if ( code < 0 ) return code;
+ 	if ( num < 0.0 ) return e_rangecheck;
+ 	make_real(op, sqrt(num));
+ 	return 0;
+ }
+ 
+ /* arccos */
+ int
+ zarccos(register ref *op)
+ {	float num, result;
+ 	int code = num_params(op, 1, &num);
+ 	if ( code < 0 ) return code;
+ 	result = acos(num) * radians_to_degrees;
+ 	make_real(op, result);
+ 	return 0;
+ }
+ 
+ /* arcsin */
+ int
+ zarcsin(register ref *op)
+ {	float num, result;
+ 	int code = num_params(op, 1, &num);
+ 	if ( code < 0 ) return code;
+ 	result = asin(num) * radians_to_degrees;
+ 	make_real(op, result);
+ 	return 0;
+ }
+ 
+ /* atan */
+ int
+ zatan(register ref *op)
+ {	float args[2];
+ 	float result;
+ 	int code = num_params(op, 2, args);
+ 	if ( code < 0 ) return code;
+ 	if ( args[0] == 0 )		/* on X-axis, special case */
+ 	   {	if ( args[1] == 0 ) return e_undefinedresult;
+ 		result = (args[1] < 0 ? 180 : 0);
+ 	   }
+ 	else
+ 	   {	result = atan2(args[0], args[1]) * radians_to_degrees;
+ 		/* Normalize quadrants by PostScript convention. */
+ 		/* The result of atan2 is in the range (-pi..pi) */
+ 		/* (we got rid of the endpoints above). */
+ 		if ( result < 0 )
+ 			{ do { result += 180; } while ( result < 0 ); }
+ 		else	{ while ( result >= 180 ) result -= 180; }
+ 		if ( args[0] < 0 ) result += 180;
+ 	   }
+ 	make_real(op - 1, result);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* cos */
+ int
+ zcos(register ref *op)
+ {	float angle;
+ 	int code = num_params(op, 1, &angle);
+ 	if ( code < 0 ) return code;
+ 	make_real(op, cos(angle * degrees_to_radians));
+ 	return 0;
+ }
+ 
+ /* sin */
+ int
+ zsin(register ref *op)
+ {	float angle;
+ 	int code = num_params(op, 1, &angle);
+ 	if ( code < 0 ) return code;
+ 	make_real(op, sin(angle * degrees_to_radians));
+ 	return 0;
+ }
+ 
+ /* exp */
+ int
+ zexp(register ref *op)
+ {	float args[2];
+ 	float result;
+ 	double ipart;
+ 	int code = num_params(op, 2, args);
+ 	if ( code < 0 ) return code;
+ 	if ( args[0] == 0.0 && args[1] == 0.0 ) return e_undefinedresult;
+ 	if ( args[0] < 0.0 && modf(args[1], &ipart) != 0.0 )
+ 		return e_undefinedresult;
+ 	result = pow(args[0], args[1]);
+ 	make_real(op - 1, result);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ln */
+ int
+ zln(register ref *op)
+ {	float num;
+ 	int code = num_params(op, 1, &num);
+ 	if ( code < 0 ) return code;
+ 	if ( num <= 0.0 ) return e_rangecheck;
+ 	make_real(op, log(num));
+ 	return 0;
+ }
+ 
+ /* log */
+ int
+ zlog(register ref *op)
+ {	float num;
+ 	int code = num_params(op, 1, &num);
+ 	if ( code < 0 ) return code;
+ 	if ( num <= 0.0 ) return e_rangecheck;
+ 	make_real(op, log10(num));
+ 	return 0;
+ }
+ 
+ /* rand */
+ int
+ zrand(register ref *op)
+ {	ulong value;
+ 	/* We implement the rand algorithm ourselves. */
+ 	/* This implementation is not very good. */
+ 	/* The Unix man page for rand suggests dropping the lowest bits, */
+ 	/* so that's effectively what we do here. */
+ #define rand_step()\
+   (rand_state = rand_state * 0x41c64e6dL + 0x3039)
+ 	value = rand_step() << 21;
+ 	value += rand_step() << 10;
+ 	value += rand_step() >> 3;
+ 	value &= 0x7fffffffL;
+ 	push(1);
+ 	make_int(op, value);
+ 	return 0;
+ }
+ 
+ /* srand */
+ int
+ zsrand(register ref *op)
+ {	check_type(*op, t_integer);
+ 	rand_state = op->value.intval;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* rrand */
+ int
+ zrrand(register ref *op)
+ {	push(1);
+ 	make_int(op, rand_state);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zmath_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1arccos", zarccos},		/* extension */
+ 		{"1arcsin", zarcsin},		/* extension */
+ 		{"2atan", zatan},
+ 		{"1cos", zcos},
+ 		{"2exp", zexp},
+ 		{"1ln", zln},
+ 		{"1log", zlog},
+ 		{"0rand", zrand},
+ 		{"0rrand", zrrand},
+ 		{"1sin", zsin},
+ 		{"1sqrt", zsqrt},
+ 		{"1srand", zsrand},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmatrix.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmatrix.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmatrix.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,249 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zmatrix.c */
+ /* Matrix operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "gsmatrix.h"
+ #include "state.h"
+ #include "gscoord.h"
+ #include "store.h"
+ 
+ /* Forward references */
+ private int common_transform(P3(ref *,
+   int (*)(P4(gs_state *, floatp, floatp, gs_point *)),
+   int (*)(P4(floatp, floatp, gs_matrix *, gs_point *))));
+ 
+ /* Imported from util.c */
+ extern int num_params(P3(ref *, int, float *));
+ 
+ /* Initialize the type and attributes of the identity matrix */
+ void
+ zmatrix_init()
+ {	extern gs_matrix gs_identity_matrix;
+ 	ref *mp = (ref *)&gs_identity_matrix;
+ 	int i;
+ 	for ( i = 0; i < 6; i++, mp++ )
+ 		make_real(mp, mp->value.realval);
+ }
+ 
+ /* currentmatrix */
+ int
+ zcurrentmatrix(register ref *op)
+ {	int code = write_matrix(op);
+ 	if ( code < 0 ) return code;
+ 	gs_currentmatrix(igs, (gs_matrix *)(op->value.refs));
+ 	return 0;
+ }
+ 
+ /* setmatrix */
+ int
+ zsetmatrix(register ref *op)
+ {	gs_matrix mat;
+ 	int code = read_matrix(op, &mat);
+ 	if ( code < 0 ) return code;
+ 	if ( (code = gs_setmatrix(igs, &mat)) < 0 ) return code;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* translate */
+ int
+ ztranslate(register ref *op)
+ {	int code = write_matrix(op);
+ 	float trans[2];
+ 	if ( code < 0 )			/* no matrix operand */
+ 	   {	if ( (code = num_params(op, 2, trans)) < 0 ) return code;
+ 		code = gs_translate(igs, trans[0], trans[1]);
+ 	   }
+ 	else				/* matrix operand */
+ 	   {	gs_matrix *pmat = (gs_matrix *)op->value.refs;
+ 		if ( (code = num_params(op - 1, 2, trans)) < 0 ) return code;
+ 		code = gs_make_translation(trans[0], trans[1], pmat);
+ 		op[-2] = *op;
+ 	   }
+ 	if ( code >= 0 ) pop(2);
+ 	return code;
+ }
+ 
+ /* scale */
+ int
+ zscale(register ref *op)
+ {	float scale[2];
+ 	int code = write_matrix(op);
+ 	if ( code < 0 )			/* no matrix operand */
+ 	   {	if ( (code = num_params(op, 2, scale)) < 0 ) return code;
+ 		code = gs_scale(igs, scale[0], scale[1]);
+ 	   }
+ 	else				/* matrix operand */
+ 	   {	gs_matrix *pmat = (gs_matrix *)op->value.refs;
+ 		if ( (code = num_params(op - 1, 2, scale)) < 0 ) return code;
+ 		code = gs_make_scaling(scale[0], scale[1], pmat);
+ 		op[-2] = *op;
+ 	   }
+ 	if ( code >= 0 ) pop(2);
+ 	return code;
+ }
+ 
+ /* rotate */
+ int
+ zrotate(register ref *op)
+ {	int code = write_matrix(op);
+ 	float ang;
+ 	if ( code < 0 )			/* no matrix operand */
+ 	   {	if ( (code = num_params(op, 1, &ang)) < 0 ) return code;
+ 		code = gs_rotate(igs, ang);
+ 	   }
+ 	else				/* matrix operand */
+ 	   {	gs_matrix *pmat = (gs_matrix *)op->value.refs;
+ 		if ( (code = num_params(op - 1, 1, &ang)) < 0 ) return code;
+ 		code = gs_make_rotation(ang, pmat);
+ 		op[-1] = *op;
+ 	   }
+ 	if ( code >= 0 ) pop(1);
+ 	return code;
+ }
+ 
+ /* concat */
+ int
+ zconcat(register ref *op)
+ {	gs_matrix mat;
+ 	int code = read_matrix(op, &mat);
+ 	if ( code < 0 ) return code;
+ 	code = gs_concat(igs, &mat);
+ 	if ( code < 0 ) return code;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* concatmatrix */
+ int
+ zconcatmatrix(register ref *op)
+ {	gs_matrix m1, m2;
+ 	int code;
+ 	if (	(code = read_matrix(op - 2, &m1)) < 0 ||
+ 		(code = read_matrix(op - 1, &m2)) < 0 ||
+ 		(code = write_matrix(op)) < 0 ||
+ 		(code = gs_matrix_multiply(&m1, &m2, (gs_matrix *)(op->value.refs))) < 0
+ 	   ) return code;
+ 	op[-2] = *op;
+ 	pop(2);
+ 	return code;
+ }
+ 
+ /* transform */
+ int
+ ztransform(register ref *op)
+ {	return common_transform(op, gs_transform, gs_point_transform);
+ }
+ 
+ /* dtransform */
+ int
+ zdtransform(register ref *op)
+ {	return common_transform(op, gs_dtransform, gs_distance_transform);
+ }
+ 
+ /* itransform */
+ int
+ zitransform(register ref *op)
+ {	return common_transform(op, gs_itransform, gs_point_transform_inverse);
+ }
+ 
+ /* idtransform */
+ int
+ zidtransform(register ref *op)
+ {	return common_transform(op, gs_idtransform, gs_distance_transform_inverse);
+ }
+ 
+ /* Common logic for [i][d]transform */
+ private int
+ common_transform(register ref *op,
+   int (*ptproc)(P4(gs_state *, floatp, floatp, gs_point *)),
+   int (*matproc)(P4(floatp, floatp, gs_matrix *, gs_point *)))
+ {	float opxy[2];
+ 	gs_point pt;
+ 	int code;
+ 	/* Optimize for the non-matrix case */
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_real: opxy[1] = op->value.realval; break;
+ 	case t_integer: opxy[1] = op->value.intval; break;
+ 	case t_array: case t_packedarray:	/* might be a matrix */
+ 	   {	gs_matrix mat;
+ 		gs_matrix *pmat = &mat;
+ 		if (	(code = read_matrix(op, pmat)) < 0 ||
+ 			(code = num_params(op - 1, 2, opxy)) < 0 ||
+ 			(code = (*matproc)(opxy[0], opxy[1], pmat, &pt)) < 0
+ 		   ) return code;
+ 		op--;
+ 		pop(1);
+ 		goto out;
+ 	   }
+ 	default: return e_typecheck;
+ 	   }
+ 	switch ( r_type(op - 1) )
+ 	   {
+ 	case t_real: opxy[0] = (op - 1)->value.realval; break;
+ 	case t_integer: opxy[0] = (op - 1)->value.intval; break;
+ 	default: return e_typecheck;
+ 	   }
+ 	if ( (code = (*ptproc)(igs, opxy[0], opxy[1], &pt)) < 0 )
+ 		return code;
+ out:	make_real(op - 1, pt.x);
+ 	make_real(op, pt.y);
+ 	return 0;
+ }
+ 
+ /* invertmatrix */
+ int
+ zinvertmatrix(register ref *op)
+ {	gs_matrix m;
+ 	int code;
+ 	if (	(code = read_matrix(op - 1, &m)) < 0 ||
+ 		(code = write_matrix(op)) < 0 ||
+ 		(code = gs_matrix_invert(&m, (gs_matrix *)op->value.refs)) < 0
+ 	   ) return code;
+ 	op[-1] = *op;
+ 	pop(1);
+ 	return code;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zmatrix_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1concat", zconcat},
+ 		{"2dtransform", zdtransform},
+ 		{"3concatmatrix", zconcatmatrix},
+ 		{"1currentmatrix", zcurrentmatrix},
+ 		{"2idtransform", zidtransform},
+ 		{"2invertmatrix", zinvertmatrix},
+ 		{"2itransform", zitransform},
+ 		{"1rotate", zrotate},
+ 		{"2scale", zscale},
+ 		{"1setmatrix", zsetmatrix},
+ 		{"2transform", ztransform},
+ 		{"2translate", ztranslate},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmisc.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmisc.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zmisc.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,195 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zmisc.c */
+ /* Miscellaneous operators for GhostScript */
+ #include "string_.h"
+ #include "ghost.h"
+ #include "memory_.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "dict.h"
+ #include "store.h"
+ #include "gxfixed.h"			/* for gstype1.h */
+ #include "gstype1.h"
+ 
+ /* Import the dictionary stack pointer (for bind) */
+ extern ref dstack[];
+ extern ref *dsp;
+ 
+ /* Import the C getenv function */
+ extern char *getenv(P1(char *));
+ 
+ /* Import from iutil.c */
+ extern char *ref_to_string(P2(ref *, char *));
+ 
+ /* bind */
+ int
+ zbind(register ref *op)
+ {	ref *bsp = op;			/* bottom of stack */
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_array:
+ 	case t_packedarray: break;
+ 	default: return e_typecheck;
+ 	   }
+ 	/* It appears from the PostScript manual that bind works */
+ 	/* even on procedures whose top level isn't writable. */
+ 	/* This seems a little counter-intuitive, but we do the same. */
+ 	*++bsp = *op;
+ 	/* Here are the invariants for the following loop: */
+ 	/*	op < bsp <= ostop; */
+ 	/*	for every pointer p such that op < p <= bsp, */
+ 	/*	  *p is an array (or packedarray) ref. */
+ 	while ( bsp > op )
+ 	   {	while ( bsp->size )
+ 		   {	ref *tp = bsp->value.refs++;
+ 			bsp->size--;
+ 			switch ( r_type(tp) )
+ 			 {
+ 			case t_name:	/* bind the name if an operator */
+ 			  if ( r_has_attrs(tp, a_executable) )
+ 			   {	ref *pvalue;
+ 				if ( dict_lookup(dstack, dsp, tp, &pvalue) > 0 &&
+ 				     r_btype(pvalue) == t_operator && r_has_attrs(pvalue, a_executable)
+ 				   )
+ 					store(tp, *pvalue);
+ 			   }
+ 			  break;
+ 			case t_array:	/* push into array if procedure */
+ 			  if ( !r_has_attrs(tp, a_write) ) break;
+ 			case t_packedarray:
+ 			  if ( r_has_attrs(tp, a_executable) && bsp < ostop )
+ 			   {	/* Make reference read-only */
+ 				r_clear_attrs(tp, a_write);
+ 				*++bsp = *tp;
+ 			   }
+ 			 }
+ 		   }
+ 		bsp--;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* currenttime */
+ int
+ zcurrenttime(register ref *op)
+ {	long date_time[2];
+ 	gs_get_clock(date_time);
+ 	push(1);
+ 	make_real(op, date_time[0] * 1440.0 + date_time[1] / 60000.0);
+ 	return 0;
+ }
+ 
+ /* getenv */
+ int
+ zgetenv(register ref *op)
+ {	char *str, *value;
+ 	int code;
+ 	check_read_type(*op, t_string);
+ 	str = ref_to_string(op, "getenv name");
+ 	if ( str == 0 ) return e_VMerror;
+ 	value = getenv(str);
+ 	alloc_free(str, op->size + 1, 1, "getenv name");
+ 	if ( value == 0 )		/* not found */
+ 	   {	make_bool(op, 0);
+ 		return 0;
+ 	   }
+ 	code = string_to_ref(value, op, "getenv value");
+ 	if ( code < 0 ) return code;
+ 	push(1);
+ 	make_bool(op, 1);
+ 	return 0;
+ }
+ 
+ /* setdebug */
+ int
+ zsetdebug(register ref *op)
+ {	check_read_type(op[-1], t_string);
+ 	check_type(*op, t_boolean);
+ #ifdef DEBUG
+ 	   {	int i;
+ 		for ( i = 0; i < op[-1].size; i++ )
+ 			gs_debug[op[-1].value.bytes[i] & 127] =
+ 				op->value.index;
+ 	   }
+ #endif
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* type1encrypt, type1decrypt */
+ private int type1crypt(P2(ref *,
+ 			  int (*)(P4(byte *, byte *, uint, ushort *))));
+ int
+ ztype1encrypt(ref *op)
+ {	return type1crypt(op, gs_type1_encrypt);
+ }
+ int
+ ztype1decrypt(ref *op)
+ {	return type1crypt(op, gs_type1_decrypt);
+ }
+ private int
+ type1crypt(register ref *op, int (*proc)(P4(byte *, byte *, uint, ushort *)))
+ {	crypt_state state;
+ 	check_type(op[-2], t_integer);
+ 	state = op[-2].value.intval;
+ 	if ( op[-2].value.intval != state )
+ 		return e_rangecheck;	/* state value was truncated */
+ 	check_read_type(op[-1], t_string);
+ 	check_write_type(*op, t_string);
+ 	if ( op->size < op[-1].size )
+ 		return e_rangecheck;
+ 	(void) (*proc)(op->value.bytes, op[-1].value.bytes, op[-1].size,
+ 		       &state);		/* can't fail */
+ 	op[-2].value.intval = state;
+ 	op[-1] = *op;
+ 	op[-1].size = op->size;
+ 	r_set_attrs(op - 1, a_subrange);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* usertime */
+ int
+ zusertime(register ref *op)
+ {	long date_time[2];
+ 	gs_get_clock(date_time);
+ 	push(1);
+ 	make_int(op, date_time[0] * 86400000L + date_time[1]);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zmisc_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1bind", zbind},
+ 		{"0currenttime", zcurrenttime},
+ 		{"1getenv", zgetenv},
+ 		{"2setdebug", zsetdebug},
+ 		{"3type1encrypt", ztype1encrypt},
+ 		{"3type1decrypt", ztype1decrypt},
+ 		{"0usertime", zusertime},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpacked.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpacked.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpacked.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,102 ----
+ /* Copyright (C) 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zpacked.c */
+ /* Packed array operators for Ghostscript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ 
+ /* Import the array packing flag */
+ extern int array_packing;
+ 
+ /* Import a utility procedure from zarray.c. */
+ extern int make_array(P4(ref *, int, int, char *));
+ 
+ /*
+ 
+ The following is a new design for packed arrays, not implemented yet.
+ 
+ Use packed elements of 2 different sizes, 2 bytes or 8 bytes.  The top
+ bits of the first 16-bit subelement distinguish the 2 forms.  The 'size'
+ of a packed array is the number of bytes it occupies, not the number of
+ elements.  A plausible encoding:
+ 
+ 	00iiiiii iiiiiiii	executable name
+ 	01iiiiii iiiiiiii	literal name
+ 	100jjjjj jjjjjjjj	(executable) operator (for bind)
+ 	101svvvv vvvvvvvv	2's complement integer
+ 	11s000wr ttttttxe	full 8-byte object
+ 
+ It would be very nice to have a code that says "embedded packed array
+ follows", but this would create a lot of extra complexity for both the
+ scanner (the only place where such a thing could be constructed) and the
+ accessing routines for packed arrays.
+ 
+ This encoding requires a table of all operators, and a table of all
+ names.  (The latter already exists.)  Both are easy to construct
+ dynamically as a 2-level array of (say) 256-element arrays.
+ 
+  */
+ 
+ /* currentpacking */
+ int
+ zcurrentpacking(register ref *op)
+ {	push(1);
+ 	make_bool(op, array_packing);
+ 	return 0;
+ }
+ 
+ /* packedarray */
+ int
+ zpackedarray(register ref *op)
+ {	int code = make_array(op, t_packedarray, a_read+a_execute, "packedarray");
+ 	if ( code < 0 ) return code;
+ 	   {	/* Fill the array from the stack. */
+ 		uint size = op->size;
+ 		if ( size > op - osbot ) return e_stackunderflow;
+ 		refcpy(op->value.refs, op - size, size);
+ 		op[-size] = *op;
+ 		pop(size);
+ 	   }
+ 	return 0;
+ }
+ 
+ /* setpacking */
+ int
+ zsetpacking(register ref *op)
+ {	check_type(*op, t_boolean);
+ 	array_packing = op->value.index;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zpacked_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0currentpacking", zcurrentpacking},
+ 		{"1packedarray", zpackedarray},
+ 		{"1setpacking", zsetpacking},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpaint.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpaint.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpaint.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,207 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zpaint.c */
+ /* Painting operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "estack.h"			/* for image[mask] */
+ #include "store.h"
+ #include "gsmatrix.h"
+ #include "gspaint.h"
+ #include "state.h"
+ 
+ /* Forward references */
+ private int image_setup(P3(ref *, int, int));
+ private int image_continue(P1(ref *));
+ 
+ /* erasepage */
+ int
+ zerasepage(register ref *op)
+ {	return gs_erasepage(igs);
+ }
+ 
+ /* fill */
+ int
+ zfill(register ref *op)
+ {	return gs_fill(igs);
+ }
+ 
+ /* eofill */
+ int
+ zeofill(register ref *op)
+ {	return gs_eofill(igs);
+ }
+ 
+ /* stroke */
+ int
+ zstroke(register ref *op)
+ {	return gs_stroke(igs);
+ }
+ 
+ /* colorimage */
+ int
+ zcolorimage(register ref *op)
+ {	int spp;			/* samples per pixel */
+ 	int npop = 7;
+ 	ref *procp = op - 2;
+ 	int code;
+ 	check_type(*op, t_integer);	/* ncolors */
+ 	check_type(op[-1], t_boolean);	/* multiproc */
+ 	if ( (ulong)(op->value.intval) > 4 ) return e_rangecheck;
+ 	switch ( (spp = (int)(op->value.intval)) )
+ 	   {
+ 	case 1:
+ 		pop(2);			/* WRONG if zimage fails */
+ 		return zimage(op);
+ 	case 3: case 4:
+ 		break;
+ 	default:
+ 		return e_rangecheck;
+ 	   }
+ 	if ( op[-1].value.index )	/* planar format */
+ 		npop += spp - 1,
+ 		procp -= spp - 1,
+ 		spp = - spp;
+ 	check_type(procp[-2], t_integer);	/* bits/sample */
+ 	if ( (ulong)(procp[-2].value.intval) > 8 ) return e_rangecheck;
+ 	code = image_setup(procp, (int)procp[-2].value.intval, spp);
+ 	if ( code >= 0 ) pop(npop);
+ 	return code;
+ }
+ 
+ /* image */
+ int
+ zimage(register ref *op)
+ {	int code;
+ 	check_type(op[-2], t_integer);	/* bits/sample */
+ 	if ( (ulong)(op[-2].value.intval) > 8 ) return e_rangecheck;
+ 	code = image_setup(op, (int)op[-2].value.intval, 1);
+ 	if ( code >= 0 ) pop(5);
+ 	return code;
+ }
+ 
+ /* imagemask */
+ int
+ zimagemask(register ref *op)
+ {	int code;
+ 	check_type(op[-2], t_boolean);
+ 	code = image_setup(op, op[-2].value.index, 0);
+ 	if ( code >= 0 ) pop(5);
+ 	return code;
+ }
+ 
+ /* Common setup for [color]image and imagemask. */
+ /* spp is 0 for imagemask, 1 for image, and [-]3 or [-]4 for colorimage. */
+ private int
+ image_setup(ref *op, int param3 /* bits/sample or invert */, int spp)
+ {	int code;
+ 	gs_image_enum *penum;
+ 	gs_matrix mat;
+ 	int px;
+ 	int pmax = (spp < 0 ? ~ spp : 0);
+ 	/* We push on the estack: */
+ 	/*	Control mark, 4 procs, last plane index, */
+ 	/*	enumeration structure (as bytes). */
+ #define inumpush 7
+ 	check_estack(inumpush + 2);	/* stuff above, + continuation + proc */
+ 	check_type(op[-4], t_integer);	/* width */
+ 	check_type(op[-3], t_integer);	/* height */
+ 	/* Note that the "procedures" might not be procedures, */
+ 	/* but might be literal strings. */
+ 	for ( px = 0; px <= pmax; px++ )
+ 	  if ( r_type(op + px) != t_string )
+ 	   {	check_proc(op[px]);	/* proc(s) */
+ 	   }
+ 	if ( op[-4].value.intval <= 0 || op[-3].value.intval < 0 )
+ 		return e_undefinedresult;
+ 	if ( op[-3].value.intval == 0 ) return 0;	/* empty image */
+ 	if ( (code = read_matrix(op - 1, &mat)) < 0 )
+ 		return code;
+ 	if ( (penum = (gs_image_enum *)alloc(1, gs_image_enum_sizeof, "image_setup")) == 0 )
+ 		return e_VMerror;
+ 	code = (spp == 0 ?
+ 		gs_imagemask_init(penum, igs, (int)op[-4].value.intval,
+ 				  (int)op[-3].value.intval, param3, &mat) :
+ 		gs_image_init(penum, igs, (int)op[-4].value.intval,
+ 			      (int)op[-3].value.intval, param3, spp, &mat) );
+ 	if ( code < 0 ) return code;
+ 	mark_estack(es_other);
+ 	++esp;
+ 	for ( px = 0; px < 4; esp++, px++ )
+ 	  if ( px <= pmax )
+ 		*esp = op[px];
+ 	  else
+ 		make_null(esp);
+ 	make_int(esp, 0);		/* current plane */
+ 	esp->size = pmax;
+ 	++esp;
+ 	make_tasv(esp, t_string, 0, gs_image_enum_sizeof, bytes, (byte *)penum);
+ 	push_op_estack(image_continue);
+ 	*++esp = *op;			/* run the (first) procedure */
+ 	return o_check_estack;
+ }
+ /* Continuation procedure.  Hand the string to the enumerator. */
+ private int
+ image_continue(register ref *op)
+ {	gs_image_enum *penum = (gs_image_enum *)esp->value.bytes;
+ 	int code;
+ 	if ( r_type(op) != t_string )
+ 	   {	/* Procedure didn't return a string.  Quit. */
+ 		esp -= inumpush;
+ 		alloc_free((char *)penum, 1, gs_image_enum_sizeof,
+ 			   "image_continue(quit)");
+ 		return e_typecheck;
+ 	   }
+ 	code = gs_image_next(penum, op->value.bytes, op->size);
+ 	if ( op->size == 0 || code > 0 )	/* stop now */
+ 	   {	esp -= inumpush;
+ 		alloc_free((char *)penum, 1, gs_image_enum_sizeof,
+ 			   "image_continue(finished)");
+ 	   }
+ 	else
+ 	   {	int px = (int)++(esp[-1].value.intval);
+ 		ref *pproc = esp - 5;
+ 		if ( px > esp[-1].size )
+ 			esp[-1].value.intval = px = 0;
+ 		push_op_estack(image_continue);
+ 		*++esp = pproc[px];
+ 	   }
+ 	pop(1);
+ 	return o_check_estack;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zpaint_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0eofill", zeofill},
+ 		{"0erasepage", zerasepage},
+ 		{"0fill", zfill},
+ 		{"7colorimage", zcolorimage},
+ 		{"5image", zimage},
+ 		{"5imagemask", zimagemask},
+ 		{"0stroke", zstroke},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpath.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpath.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpath.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,207 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zpath.c */
+ /* Path operators for GhostScript */
+ #include "math_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "gsmatrix.h"
+ #include "gspath.h"
+ #include "state.h"
+ #include "store.h"
+ 
+ /* Forward references */
+ private int common_to(P2(ref *,
+   int (*)(P3(gs_state *, floatp, floatp))));
+ private int common_arc(P2(ref *,
+   int (*)(P6(gs_state *, floatp, floatp, floatp, floatp, floatp))));
+ private int common_arct(P2(ref *, float *));
+ private int common_curve(P2(ref *,
+   int (*)(P7(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp))));
+ 
+ /* Imported from util.c */
+ extern int num_params(P3(ref *, int, float *));
+ 
+ /* Imported from zmath.c */
+ extern double degrees_to_radians, radians_to_degrees;
+ 
+ /* newpath */
+ int
+ znewpath(register ref *op)
+ {	return gs_newpath(igs);
+ }
+ 
+ /* currentpoint */
+ int
+ zcurrentpoint(register ref *op)
+ {	gs_point pt;
+ 	int code = gs_currentpoint(igs, &pt);
+ 	if ( code < 0 ) return code;
+ 	push(2);
+ 	make_real(op - 1, pt.x);
+ 	make_real(op, pt.y);
+ 	return 0;
+ }
+ 
+ /* moveto */
+ int
+ zmoveto(register ref *op)
+ {	return common_to(op, gs_moveto);
+ }
+ 
+ /* rmoveto */
+ int
+ zrmoveto(register ref *op)
+ {	return common_to(op, gs_rmoveto);
+ }
+ 
+ /* lineto */
+ int
+ zlineto(register ref *op)
+ {	return common_to(op, gs_lineto);
+ }
+ 
+ /* rlineto */
+ int
+ zrlineto(register ref *op)
+ {	return common_to(op, gs_rlineto);
+ }
+ 
+ /* Common code for [r](move/line)to */
+ private int
+ common_to(ref *op, int (*add_proc)(P3(gs_state *, floatp, floatp)))
+ {	float opxy[2];
+ 	int code;
+ 	if (	(code = num_params(op, 2, opxy)) < 0 ||
+ 		(code = (*add_proc)(igs, opxy[0], opxy[1])) < 0
+ 	   ) return code;
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* arc */
+ int
+ zarc(register ref *op)
+ {	return common_arc(op, gs_arc);
+ }
+ 
+ /* arcn */
+ int
+ zarcn(register ref *op)
+ {	return common_arc(op, gs_arcn);
+ }
+ 
+ /* Common code for arc[n] */
+ private int
+ common_arc(ref *op,
+   int (*aproc)(P6(gs_state *, floatp, floatp, floatp, floatp, floatp)))
+ {	float xyra[5];			/* x, y, r, ang1, ang2 */
+ 	int code;
+ 	if ( (code = num_params(op, 5, xyra)) < 0 ) return code;
+ 	code = (*aproc)(igs, xyra[0], xyra[1], xyra[2], xyra[3], xyra[4]);
+ 	if ( code >= 0 ) pop(5);
+ 	return code;
+ }
+ 
+ /* arct */
+ int
+ zarct(register ref *op)
+ {	int code = common_arct(op, (float *)0);
+ 	if ( code < 0 ) return code;
+ 	pop(5);
+ 	return 0;
+ }
+ 
+ /* arcto */
+ int
+ zarcto(register ref *op)
+ {	float tanxy[4];			/* xt1, yt1, xt2, yt2 */
+ 	int code = common_arct(op, tanxy);
+ 	if ( code < 0 ) return code;
+ 	make_real(op - 4, tanxy[0]);
+ 	make_real(op - 3, tanxy[1]);
+ 	make_real(op - 2, tanxy[2]);
+ 	make_real(op - 1, tanxy[3]);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* Common code for arct[o] */
+ private int
+ common_arct(ref *op, float *tanxy)
+ {	float args[5];			/* x1, y1, x2, y2, r */
+ 	int code;
+ 	if ( (code = num_params(op, 5, args)) < 0 ) return code;
+ 	return gs_arcto(igs, args[0], args[1], args[2], args[3], args[4], tanxy);
+ }
+ 
+ /* curveto */
+ int
+ zcurveto(register ref *op)
+ {	return common_curve(op, gs_curveto);
+ }
+ 
+ /* rcurveto */
+ int
+ zrcurveto(register ref *op)
+ {	return common_curve(op, gs_rcurveto);
+ }
+ 
+ /* Common code for [r]curveto */
+ private int
+ common_curve(ref *op,
+   int (*add_proc)(P7(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp)))
+ {	float opxy[6];
+ 	int code;
+ 	if ( (code = num_params(op, 6, opxy)) < 0 ) return code;
+ 	code = (*add_proc)(igs, opxy[0], opxy[1], opxy[2], opxy[3], opxy[4], opxy[5]);
+ 	if ( code >= 0 ) pop(6);
+ 	return code;
+ }
+ 
+ /* closepath */
+ int
+ zclosepath(register ref *op)
+ {	return gs_closepath(igs);
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zpath_op_init()
+ {	static op_def my_defs[] = {
+ 		{"5arc", zarc},
+ 		{"5arcn", zarcn},
+ 		{"5arct", zarct},
+ 		{"5arcto", zarcto},
+ 		{"0closepath", zclosepath},
+ 		{"0currentpoint", zcurrentpoint},
+ 		{"6curveto", zcurveto},
+ 		{"2lineto", zlineto},
+ 		{"2moveto", zmoveto},
+ 		{"0newpath", znewpath},
+ 		{"6rcurveto", zrcurveto},
+ 		{"2rlineto", zrlineto},
+ 		{"2rmoveto", zrmoveto},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpath2.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpath2.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zpath2.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,178 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zpath2.c */
+ /* Non-constructor path operators for GhostScript */
+ #include "ghost.h"
+ #include "oper.h"
+ #include "errors.h"
+ #include "alloc.h"
+ #include "estack.h"	/* for pathforall */
+ #include "gspath.h"
+ #include "state.h"
+ #include "store.h"
+ 
+ /* flattenpath */
+ int
+ zflattenpath(register ref *op)
+ {	return gs_flattenpath(igs);
+ }
+ 
+ /* reversepath */
+ int
+ zreversepath(register ref *op)
+ {	return gs_reversepath(igs);
+ }
+ 
+ /* strokepath */
+ int
+ zstrokepath(register ref *op)
+ {	return gs_strokepath(igs);
+ }
+ 
+ /* clippath */
+ int
+ zclippath(register ref *op)
+ {	return gs_clippath(igs);
+ }
+ 
+ /* pathbbox */
+ int
+ zpathbbox(register ref *op)
+ {	gs_rect box;
+ 	int code = gs_pathbbox(igs, &box);
+ 	if ( code < 0 ) return code;
+ 	push(4);
+ 	make_real(op - 3, box.p.x);
+ 	make_real(op - 2, box.p.y);
+ 	make_real(op - 1, box.q.x);
+ 	make_real(op, box.q.y);
+ 	return 0;
+ }
+ 
+ /* pathforall */
+ private int path_continue(P1(ref *));
+ int
+ zpathforall(register ref *op)
+ {	gs_path_enum *penum;
+ 	check_op(4);
+ 	check_estack(8);
+ 	if ( (penum = (gs_path_enum *)alloc(1, gs_path_enum_sizeof, "pathforall")) == 0 )
+ 	  return e_VMerror;
+ 	gs_path_enum_init(penum, igs);
+ 	/* Push a mark, the four procedures, and a pseudo-integer */
+ 	/* in which value.bytes points to the path enumerator, */
+ 	/* and then call the continuation procedure. */
+ 	mark_estack(es_for);	/* iterator */
+ 	*++esp = op[-3];	/* moveto proc */
+ 	*++esp = op[-2];	/* lineto proc */
+ 	*++esp = op[-1];	/* curveto proc */
+ 	*++esp = *op;		/* closepath proc */
+ 	++esp;
+ 	make_tv(esp, t_integer, bytes, (byte *)penum);
+ 	pop(4);  op -= 4;
+ 	return path_continue(op);
+ }
+ /* Continuation procedure for pathforall */
+ private int pf_push(P3(gs_point *, int, ref *));
+ private int
+ path_continue(register ref *op)
+ {	gs_path_enum *penum = (gs_path_enum *)esp->value.bytes;
+ 	gs_point ppts[3];
+ 	int code;
+ 	code = gs_path_enum_next(penum, ppts);
+ 	switch ( code )
+ 	  {
+ 	case 0:			/* all done */
+ 	    { alloc_free((char *)penum, 1, gs_path_enum_sizeof, "pathforall");
+ 	      esp -= 6;
+ 	      return o_check_estack;
+ 	    }
+ 	default:		/* error */
+ 	    return code;
+ 	case gs_pe_moveto:
+ 	    esp[2] = esp[-4];			/* moveto proc */
+ 	    code = pf_push(ppts, 1, op);
+ 	    break;
+ 	case gs_pe_lineto:
+ 	    esp[2] = esp[-3];			/* lineto proc */
+ 	    code = pf_push(ppts, 1, op);
+ 	    break;
+ 	case gs_pe_curveto:
+ 	    esp[2] = esp[-2];			/* curveto proc */
+ 	    code = pf_push(ppts, 3, op);
+ 	    break;
+ 	case gs_pe_closepath:
+ 	    esp[2] = esp[-1];			/* closepath proc */
+ 	    code = 0;
+ 	    break;
+ 	  }
+ 	if ( code < 0 ) return code;	/* ostack overflow in pf_push */
+ 	push_op_estack(path_continue);
+ 	++esp;		/* include pushed procedure */
+ 	return o_check_estack;
+ }
+ /* Internal procedure to push one or more points */
+ private int
+ pf_push(gs_point *ppts, int n, ref *op)
+ {	while ( n-- )
+ 	  { push(2);
+ 	    make_real(op - 1, ppts->x);
+ 	    make_real(op, ppts->y);
+ 	    ppts++;
+ 	  }
+ 	return 0;
+ }
+ 
+ /* initclip */
+ int
+ zinitclip(register ref *op)
+ {	return gs_initclip(igs);
+ }
+ 
+ /* clip */
+ int
+ zclip(register ref *op)
+ {	return gs_clip(igs);
+ }
+ 
+ /* eoclip */
+ int
+ zeoclip(register ref *op)
+ {	return gs_eoclip(igs);
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zpath2_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0clip", zclip},
+ 		{"0clippath", zclippath},
+ 		{"0eoclip", zeoclip},
+ 		{"0flattenpath", zflattenpath},
+ 		{"0initclip", zinitclip},
+ 		{"0pathbbox", zpathbbox},
+ 		{"4pathforall", zpathforall},
+ 		{"0reversepath", zreversepath},
+ 		{"0strokepath", zstrokepath},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zrelbit.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zrelbit.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zrelbit.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,269 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zrelbit.c */
+ /* Relational, boolean, and bit operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ #include "sstorei.h"
+ #include "dict.h"
+ 
+ /* eq */
+ int
+ zeq(register ref *op)
+ {	register ref *op1 = op - 1;
+ #define eq_check_read(opp)\
+   switch ( r_type(opp) )\
+    {	case t_string: case t_array: case t_packedarray:\
+ 	  check_read(*opp); break;\
+ 	case t_dictionary: check_dict_read(*opp);\
+    }
+ 	eq_check_read(op);
+ 	eq_check_read(op1);
+ 	make_bool(op1, (obj_eq(op1, op) ? 1 : 0));
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ne */
+ int
+ zne(register ref *op)
+ {	/* We'll just be lazy and use eq. */
+ 	int code = zeq(op);
+ 	if ( !code ) op[-1].value.index ^= 1;
+ 	return code;
+ }
+ 
+ /* ge */
+ int
+ zge(register ref *op)
+ {	int code = obj_compare(op, 4+2);
+ 	if ( code < 0 ) return code;
+ 	make_bool(op - 1, code);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* gt */
+ int
+ zgt(register ref *op)
+ {	int code = obj_compare(op, 4);
+ 	if ( code < 0 ) return code;
+ 	make_bool(op - 1, code);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* le */
+ int
+ zle(register ref *op)
+ {	int code = obj_compare(op, 2+1);
+ 	if ( code < 0 ) return code;
+ 	make_bool(op - 1, code);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* lt */
+ int
+ zlt(register ref *op)
+ {	int code = obj_compare(op, 1);
+ 	if ( code < 0 ) return code;
+ 	make_bool(op - 1, code);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* max */
+ int
+ zmax(register ref *op)
+ {	int code = obj_compare(op, 1);
+ 	if ( code < 0 ) return code;
+ 	if ( code )
+ 	   {	s_store_r(op, -1, 0);
+ 	   }
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* min */
+ int
+ zmin(register ref *op)
+ {	int code = obj_compare(op, 4);
+ 	if ( code < 0 ) return code;
+ 	if ( code )
+ 	   {	s_store_r(op, -1, 0);
+ 	   }
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* and */
+ int
+ zand(register ref *op)
+ {	check_type(op[-1], r_type(op));
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_boolean: op[-1].value.index &= op->value.index; break;
+ 	case t_integer: op[-1].value.intval &= op->value.intval; break;
+ 	default: return e_typecheck;
+ 	   }
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* not */
+ int
+ znot(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	case t_boolean: op->value.index = !op->value.index; break;
+ 	case t_integer: op->value.intval = ~op->value.intval; break;
+ 	default: return e_typecheck;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* or */
+ int
+ zor(register ref *op)
+ {	check_type(op[-1], r_type(op));
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_boolean: op[-1].value.index |= op->value.index; break;
+ 	case t_integer: op[-1].value.intval |= op->value.intval; break;
+ 	default: return e_typecheck;
+ 	   }
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* xor */
+ int
+ zxor(register ref *op)
+ {	check_type(op[-1], r_type(op));
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_boolean: op[-1].value.index ^= op->value.index; break;
+ 	case t_integer: op[-1].value.intval ^= op->value.intval; break;
+ 	default: return e_typecheck;
+ 	   }
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* bitshift */
+ int
+ zbitshift(register ref *op)
+ {	int shift;
+ 	check_type(op[-1], t_integer);
+ 	check_type(*op, t_integer);
+ 	if ( op->value.intval < -31 || op->value.intval > 31 )
+ 		op[-1].value.intval = 0;
+ 	else if ( (shift = op->value.intval) < 0 )
+ 		op[-1].value.intval = ((ulong)(op[-1].value.intval)) >> -shift;
+ 	else
+ 		op[-1].value.intval <<= shift;
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zrelbit_op_init()
+ {	static op_def my_defs[] = {
+ 		{"2and", zand},
+ 		{"2bitshift", zbitshift},
+ 		{"2eq", zeq},
+ 		{"2ge", zge},
+ 		{"2gt", zgt},
+ 		{"2le", zle},
+ 		{"2lt", zlt},
+ 		{"2max", zmax},
+ 		{"2min", zmin},
+ 		{"2ne", zne},
+ 		{"1not", znot},
+ 		{"2or", zor},
+ 		{"2xor", zxor},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Compare two operands (both numeric, or both strings). */
+ /* Compute a result: 4 if >, 2 if =, 1 if <. */
+ /* If the result matches a 1-bit in the mask, return 1, */
+ /* otherwise return 0. */
+ /* If the comparison fails, return a (negative) error code. */
+ int
+ obj_compare(register ref *op, int mask)
+ {
+ #define op1 (op-1)
+ 	float real1, real2;
+ 	switch ( r_type(op1) )
+ 	   {
+ 	case t_integer:
+ 		switch ( r_type(op) )
+ 		   {
+ 		case t_integer:
+ 			if ( op1->value.intval > op->value.intval )
+ 				mask >>= 2;
+ 			else if ( op1->value.intval == op->value.intval )
+ 				mask >>= 1;
+ 			return (mask & 1);
+ 		case t_real:
+ 			real1 = op1->value.intval;
+ 			real2 = op->value.realval;
+ 			break;
+ 		default: return e_typecheck;
+ 		   }
+ 		break;
+ 	case t_real:
+ 		real1 = op1->value.realval;
+ 		switch ( r_type(op) )
+ 		   {
+ 		case t_integer:
+ 			real2 = op->value.intval;
+ 			break;
+ 		case t_real:
+ 			real2 = op->value.realval;
+ 			break;
+ 		default: return e_typecheck;
+ 		   }
+ 		break;
+ 	case t_string:
+ 		check_read(*op1);
+ 		check_read_type(*op, t_string);
+ 		mask >>= (bytes_compare(op1->value.bytes, op1->size,
+ 				op->value.bytes, op->size) + 1);
+ 		return (mask & 1);
+ 	default: return e_typecheck;
+ 	   }
+ 	if ( real1 > real2 )
+ 		mask >>= 2;
+ 	else if ( real1 == real2 )
+ 		mask >>= 1;
+ 	return (mask & 1);
+ #undef op1
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zstack.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zstack.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zstack.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,173 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zstack.c */
+ /* Operand stack operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ #include "sstorei.h"
+ 
+ /* pop */
+ int
+ zpop(register ref *op)
+ {	check_op(1);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* exch */
+ int
+ zexch(register ref *op)
+ {	ref next;
+ 	ref *pnext = &next;
+ 	check_op(2);
+ 	s_store_b(pnext, 0, op, -1);
+ 	s_store_r(op, -1, 0);
+ 	s_store_i(op, pnext);
+ 	return 0;
+ }
+ 
+ /* dup */
+ int
+ zdup(register ref *op)
+ {	check_op(1);
+ 	push(1);
+ 	s_store_r(op, 0, -1);
+ 	return 0;
+ }
+ 
+ /* index */
+ int
+ zindex(register ref *op)
+ {	ref *opn;
+ 	check_type(*op, t_integer);
+ 	if ( (ulong)op->value.intval >= op - osbot ) return e_rangecheck;
+ 	opn = op + ~(int)op->value.intval;
+ 	s_store_i(op, opn);
+ 	return 0;
+ }
+ 
+ /* roll */
+ int
+ zroll(register ref *op)
+ {	ref *op1 = op - 1;
+ 	int count, mod;
+ 	int istart, n;
+ 	ref *base;
+ 	check_type(*op1, t_integer);
+ 	check_type(*op, t_integer);
+ 	if ( (ulong)op1->value.intval > op1 - osbot )
+ 		return e_rangecheck;
+ 	count = op1->value.intval;
+ 	if ( count == 0 ) { pop(2); return 0; }	/* no action */
+ 	mod = op->value.intval % count;
+ 	pop(2);				/* we're OK now */
+ 	op -= 2;
+ 	if ( mod < 0 )			/* can't assume % means mod! */
+ 		mod += count;
+ 	else if ( mod == 0 ) return 0;	/* no action */
+ 	/* Rotate the elements in chains separated by mod elements. */
+ 	/* The number of chains is gcd(count,mod): rather than compute */
+ 	/* this, we simply proceed until we have moved count elements. */
+ 	/* Since the loop interprets mod backwards from the way PostScript */
+ 	/* specifies it, we have to complement mod first. */
+ 	mod = count - mod;
+ 	istart = 0;			/* first element of chain */
+ 	n = count;			/* # of elements left to move */
+ 	base = op - count + 1;
+ 	while ( n )
+ 	   {	ref save;
+ 		int i = istart;
+ 		int inext;
+ 		save = base[istart];	/* no auto init for structures! */
+ 		while ( n--, (inext = (i + mod) % count) != istart )
+ 		   {	base[i] = base[inext];
+ 			i = inext;
+ 		   }
+ 		base[i] = save;
+ 		istart++;
+ 	   }
+ 	return 0;
+ }
+ 
+ /* clear */
+ /* The function name is changed, because the IRIS library has */
+ /* a function called zclear. */
+ int
+ zclear_stack(ref *op)
+ {	osp = osbot - 1;
+ 	return 0;
+ }
+ 
+ /* count */
+ int
+ zcount(register ref *op)
+ {	push(1);
+ 	make_int(op, op - osbot);
+ 	return 0;
+ }
+ 
+ /* cleartomark */
+ int
+ zcleartomark(register ref *op)
+ {	while ( op >= osbot )
+ 	   {	if ( r_type(op) == t_mark )
+ 		   {	osp = op - 1;
+ 			return 0;
+ 		   }
+ 		op--;
+ 	   }
+ 	return e_unmatchedmark;
+ }
+ 
+ /* counttomark */
+ int
+ zcounttomark(register ref *op)
+ {	register ref *mp = op;
+ 	while ( mp >= osbot )
+ 	   {	if ( r_type(mp) == t_mark )
+ 		   {	push(1);
+ 			make_int(op, op - mp - 1);
+ 			return 0;
+ 		   }
+ 		mp--;
+ 	   }
+ 	return e_unmatchedmark;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zstack_op_init()
+ {	static op_def my_defs[] = {
+ 		{"0clear", zclear_stack},
+ 		{"0cleartomark", zcleartomark},
+ 		{"0count", zcount},
+ 		{"0counttomark", zcounttomark},
+ 		{"1dup", zdup},
+ 		{"2exch", zexch},
+ 		{"2index", zindex},
+ 		{"1pop", zpop},
+ 		{"2roll", zroll},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zstring.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zstring.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zstring.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,155 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zstring.c */
+ /* String operators for GhostScript */
+ #include "memory_.h"
+ #include "ghost.h"
+ #include "alloc.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "store.h"
+ #include "stream.h"
+ 
+ /* The generic operators (copy, get, put, getinterval, putinterval, */
+ /* length, and forall) are implemented in zgeneric.c. */
+ 
+ /* string */
+ int
+ zstring(register ref *op)
+ {	byte *sbody;
+ 	uint size;
+ 	check_type(*op, t_integer);
+ 	if ( op->value.intval < 0 || (ulong)(op->value.intval) > max_uint )
+ 		return e_rangecheck;
+ 	size = op->value.intval;
+ 	sbody = (byte *)alloc(size, 1, "string");
+ 	if ( sbody == 0 ) return e_VMerror;
+ 	make_tasv(op, t_string, a_all, size, bytes, sbody);
+ 	memset(sbody, 0, size);
+ 	return 0;
+ }
+ 
+ /* anchorsearch */
+ int
+ zanchorsearch(register ref *op)
+ {	ref *op1 = op - 1;
+ 	uint size = op->size;
+ 	check_read_type(*op1, t_string);
+ 	check_read_type(*op, t_string);
+ 	if ( size <= op1->size && !memcmp(op1->value.bytes, op->value.bytes, size) )
+ 	   {	r_set_attrs(op1, a_subrange);
+ 		*op = *op1;
+ 		op->size = size;
+ 		op1->value.bytes += size;
+ 		op1->size -= size;
+ 		push(1);
+ 		make_bool(op, 1);
+ 	   }
+ 	else
+ 		make_bool(op, 0);
+ 	return 0;
+ }
+ 
+ /* search */
+ int
+ zsearch(register ref *op)
+ {	ref *op1 = op - 1;
+ 	uint size = op->size;
+ 	uint count;
+ 	byte *ptr;
+ 	check_read_type(*op1, t_string);
+ 	check_read_type(*op, t_string);
+ 	if ( size > op1->size )		/* can't match */
+ 	   {	make_bool(op, 0);
+ 		return 0;
+ 	   }
+ 	count = op1->size - size;
+ 	ptr = op1->value.bytes;
+ 	do
+ 	   {	if ( !memcmp(ptr, op->value.bytes, size) )
+ 		   {	op->type_attrs = op1->type_attrs;
+ 			r_set_attrs(op, a_subrange);
+ 			op->value.bytes = ptr;
+ 			op->size = size;
+ 			push(1);
+ 			*op = *op1;
+ 			op->size = ptr - op->value.bytes;
+ 			op1->value.bytes = ptr + size;
+ 			op1->size = count;
+ 			push(1);
+ 			make_bool(op, 1);
+ 			return 0;
+ 		   }
+ 		ptr++;
+ 	   }
+ 	while ( count-- );
+ 	/* No match */
+ 	make_bool(op, 0);
+ 	return 0;
+ }
+ 
+ /* token */
+ int
+ ztoken(register ref *op)
+ {	stream st;
+ 	stream *s = &st;
+ 	int code;
+ 	ref token;
+ 	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_file: return ztoken_file(op);
+ 	case t_string: ;
+ 	   }
+ 	check_read(*op);
+ 	sread_string(s, op->value.bytes, op->size);
+ 	switch ( code = scan_token(s, 1, &token) )
+ 	   {
+ 	case 0:				/* read a token */
+ 	   {	uint pos = stell(s);
+ 		op->value.bytes += pos;
+ 		op->size -= pos;
+ 		r_set_attrs(op, a_subrange);
+ 	   }
+ 		push(2);
+ 		op[-1] = token;
+ 		make_bool(op, 1);
+ 		return 0;
+ 	case 1:				/* no tokens */
+ 		make_bool(op, 0);
+ 		return 0;
+ 	default:			/* error */
+ 		return code;
+ 	   }
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zstring_op_init()
+ {	static op_def my_defs[] = {
+ 		{"2anchorsearch", zanchorsearch},
+ 		{"2search", zsearch},
+ 		{"1string", zstring},
+ 		{"1token", ztoken},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ztype.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ztype.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/ztype.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,339 ----
+ /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* ztype.c */
+ /* Type, attribute, and conversion operators for GhostScript */
+ #include "math_.h"
+ #include "memory_.h"
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "dict.h"
+ #include "name.h"
+ #include "store.h"
+ #include "stream.h"
+ 
+ /* Imported values */
+ extern ref dstack[];			/* for systemdict */
+ #define systemdict (dstack[0])
+ 
+ /* Forward references */
+ private int access_check(P3(ref *, int, int));
+ 
+ /* Max and min integer values expressed as reals. */
+ /* Note that these are biased by 1 to correct for truncation. */
+ #define lb_real_int (-0x8000L * 1.0 * 0x10000L - 1)
+ #define ub_real_int (0x8000L * 1.0 * 0x10000L)
+ 
+ /* Get the pointer to the access flags for a ref. */
+ #define access_ref(opp)\
+   (r_type(opp) == t_dictionary ? dict_access_ref(opp) : opp)
+ 
+ /* .typenumber */
+ int
+ ztypenumber(register ref *op)
+ {	check_op(1);
+ 	make_int(op, r_btype(op));
+ 	return 0;
+ }
+ 
+ /* cvlit */
+ int
+ zcvlit(register ref *op)
+ {	ref *aop;
+ 	check_op(1);
+ 	aop = access_ref(op);
+ 	r_clear_attrs(aop, a_executable);
+ 	return 0;
+ }
+ 
+ /* cvx */
+ int
+ zcvx(register ref *op)
+ {	ref *aop;
+ 	check_op(1);
+ 	aop = access_ref(op);
+ 	r_set_attrs(aop, a_executable);
+ 	return 0;
+ }
+ 
+ /* xcheck */
+ int
+ zxcheck(register ref *op)
+ {	check_op(1);
+ 	make_bool(op, (r_attrs(access_ref(op)) & a_executable ? 1 : 0));
+ 	return 0;
+ }
+ 
+ /* executeonly */
+ int
+ zexecuteonly(register ref *op)
+ {	check_op(1);
+ 	if ( r_type(op) == t_dictionary ) return e_typecheck;
+ 	return access_check(op, a_execute, 1);
+ }
+ 
+ /* noaccess */
+ int
+ znoaccess(register ref *op)
+ {	return access_check(op, 0, 1);
+ }
+ 
+ /* readonly */
+ int
+ zreadonly(register ref *op)
+ {	return access_check(op, a_read+a_execute, 1);
+ }
+ 
+ /* rcheck */
+ int
+ zrcheck(register ref *op)
+ {	int code = access_check(op, a_read, 0);
+ 	if ( code >= 0 ) make_bool(op, code);
+ 	return code;
+ }
+ 
+ /* wcheck */
+ int
+ zwcheck(register ref *op)
+ {	int code = access_check(op, a_write, 0);
+ 	if ( code >= 0 ) make_bool(op, code);
+ 	return code;
+ }
+ 
+ /* cvi */
+ int
+ zcvi(register ref *op)
+ {	float fval;
+ 	switch ( r_type(op) )
+ 	   {
+ 	case t_integer: return 0;
+ 	case t_real: fval = op->value.realval; break;
+ 	default: return e_typecheck;
+ 	case t_string:
+ 	   {	stream st;
+ 		ref nref;
+ 		int code;
+ 		check_read(*op);
+ 		sread_string(&st, op->value.bytes, op->size);
+ 		code = scan_number(&st, &nref);
+ 		if ( code ) return code;	/* error condition */
+ 		if ( sgetc(&st) != EOFC ) return e_syntaxerror;
+ 		if ( r_type(&nref) == t_integer ) { *op = nref; return 0; }
+ 		/* Otherwise, result was a real */
+ 		fval = nref.value.realval;
+ 	   }
+ 	   }
+ 	/* Check if a real will fit into an integer value */
+ 	if ( fval <= lb_real_int || fval >= ub_real_int )
+ 		return e_rangecheck;
+ 	make_int(op, (long)fval);	/* truncates towards 0 */
+ 	return 0;
+ }
+ 
+ /* cvn */
+ int
+ zcvn(register ref *op)
+ {	int exec;
+ 	int code;
+ 	check_read_type(*op, t_string);
+ 	exec = r_attrs(op) & a_executable;
+ 	code = name_ref(op->value.bytes, op->size, op, 1);
+ 	if ( code ) return code;
+ 	r_set_attrs(op, exec);
+ 	return 0;
+    }
+ 
+ /* cvr */
+ int
+ zcvr(register ref *op)
+ {	switch ( r_type(op) )
+ 	   {
+ 	case t_integer: make_real(op, op->value.intval);
+ 	case t_real: return 0;
+ 	default: return e_typecheck;
+ 	case t_string:
+ 	   {	stream st;
+ 		ref nref;
+ 		int code;
+ 		check_read(*op);
+ 		sread_string(&st, op->value.bytes, op->size);
+ 		code = scan_number(&st, &nref);
+ 		if ( code ) return code;	/* error condition */
+ 		if ( sgetc(&st) != EOFC ) return e_syntaxerror;
+ 		if ( r_type(&nref) == t_real ) { *op = nref; return 0; }
+ 		/* Otherwise, result was an integer */
+ 		make_real(op, nref.value.intval);
+ 		return 0;
+ 	   }
+ 	   }
+ }
+ 
+ /* cvrs */
+ int
+ zcvrs(register ref *op)
+ {	int radix;
+ 	long ival;
+ 	ulong val;
+ 	byte digits[31];
+ 	byte *endp = &digits[31];
+ 	byte *dp = endp;
+ 	check_type(op[-1], t_integer);
+ 	if ( op[-1].value.intval < 2 || op[-1].value.intval > 36 )
+ 		return e_rangecheck;
+ 	radix = op[-1].value.intval;
+ 	check_write_type(*op, t_string);
+ 	switch ( r_type(op - 2) )
+ 	   {
+ 	case t_integer: ival = op[-2].value.intval; break;
+ 	case t_real:	/****** SHOULD USE cvi HERE ******/
+ 	default:
+ 		return e_typecheck;
+ 	   }
+ 	val = (ival < 0 ? -ival : ival);
+ 	do
+ 	   {	int dit = val % radix;
+ 		*--dp = dit + (dit < 10 ? '0' : ('A' - 10));
+ 		val /= radix;
+ 	   }
+ 	while ( val );
+ 	if ( ival < 0 ) *--dp = '-';
+ 	if ( endp - dp > op->size ) return e_rangecheck;
+ 	memcpy(op->value.bytes, dp, (uint)(endp - dp));
+ 	op->size = endp - dp;
+ 	r_set_attrs(op, a_subrange);
+ 	op[-2] = *op;
+ 	pop(2);
+ 	return 0;
+ }
+ 
+ /* cvs */
+ int
+ zcvs(register ref *op)
+ {	ref *op1 = op - 1;
+ 	char buf[25];			/* big enough for any float */
+ 	ref stref;
+ 	check_write_type(*op, t_string);
+ 	stref.value.bytes = (byte *)buf;
+ 	switch ( r_btype(op1) )
+ 	   {
+ 	case t_boolean:
+ 		stref.value.bytes =
+ 			(byte *)(op1->value.index ? "true" : "false");
+ 		break;
+ 	case t_integer:
+ 		sprintf(buf, "%ld", op1->value.intval);
+ 		break;
+ 	case t_name:
+ 		name_string_ref(op1, &stref);	/* name string */
+ 		goto nl;
+ 	case t_operator:
+ 	   {	/* Get the name by enumerating systemdict. */
+ 		int pos = dict_first(&systemdict);
+ 		ref entry[2];
+ 		while ( (pos = dict_next(&systemdict, pos, entry)) >= 0 )
+ 		   {	if ( (long)op1->value.opproc ==
+ 			       (long)entry[1].value.opproc &&
+ 			     r_type(&entry[0]) == t_name
+ 			   )
+ 			   {	/* Found it. */
+ 				name_string_ref(&entry[0], &stref);
+ 				goto nl;
+ 			   }
+ 		   }
+ 	   }
+ 		/* Can't find it (shouldn't happen...). */
+ 		sprintf(buf, "operator %lx", (ulong)op1->value.opproc);
+ 		break;
+ 	case t_real:
+ 		sprintf(buf, "%g", op1->value.realval);
+ 		break;
+ 	case t_string:
+ 		check_read(*op1);
+ 		stref = *op1;
+ 		goto nl;
+ 	default:
+ 		check_op(1);
+ 		stref.value.bytes = (byte *)"--nostringval--";
+ 	   }
+ 	stref.size = strlen((char *)stref.value.bytes);
+ nl:	if ( stref.size > op->size ) return e_rangecheck;
+ 	memcpy(op->value.bytes, stref.value.bytes, stref.size);
+ 	op[-1] = *op;
+ 	op[-1].size = stref.size;
+ 	r_set_attrs(op - 1, a_subrange);
+ 	pop(1);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ ztype_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1cvi", zcvi},
+ 		{"1cvlit", zcvlit},
+ 		{"1cvn", zcvn},
+ 		{"1cvr", zcvr},
+ 		{"3cvrs", zcvrs},
+ 		{"2cvs", zcvs},
+ 		{"1cvx", zcvx},
+ 		{"1executeonly", zexecuteonly},
+ 		{"1noaccess", znoaccess},
+ 		{"1rcheck", zrcheck},
+ 		{"1readonly", zreadonly},
+ 		{"1.typenumber", ztypenumber},
+ 		{"1wcheck", zwcheck},
+ 		{"1xcheck", zxcheck},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }
+ 
+ /* ------ Internal routines ------ */
+ 
+ /* Test or modify the access of an object. */
+ /* If modify = 1, restrict to the selected access and return 0; */
+ /* if modify = 0, return 1 if the object had the access, 0 if not. */
+ /* Return an error code if the object is not of appropriate type, */
+ /* or if the object did not have the access already when modify=1. */
+ private int
+ access_check(ref *op,
+     int access,				/* mask for attrs */
+     int modify)				/* if true, reduce access */
+ {	ref *aop = op;
+ 	switch ( r_type(op) )
+ 	   {
+ 	default: return e_typecheck;
+ 	case t_dictionary:
+ 		aop = dict_access_ref(op);
+ 	case t_array: case t_file:
+ 	case t_packedarray: case t_string: ;
+ 	   }
+ 	if ( modify )
+ 	   {	if ( ~r_attrs(aop) & access )
+ 			return e_invalidaccess;
+ 		r_clear_attrs(aop, a_all);
+ 		r_set_attrs(aop, access);
+ 		return 0;
+ 	   }
+ 	else
+ 	   {	return (r_attrs(aop) & access) == access;
+ 	   }
+ }


Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zvmem.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zvmem.c:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:25 2004
--- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/zvmem.c	Mon Mar  1 17:59:11 2004
***************
*** 0 ****
--- 1,147 ----
+ /* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
+    Distributed by Free Software Foundation, Inc.
+ 
+ This file is part of Ghostscript.
+ 
+ Ghostscript is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+ to anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.  Refer
+ to the Ghostscript General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ Ghostscript, but only under the conditions described in the Ghostscript
+ General Public License.  A copy of this license is supposed to have been
+ given to you along with Ghostscript so you can know your rights and
+ responsibilities.  It should be in a file named COPYING.  Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies.  */
+ 
+ /* zvmem.c */
+ /* "Virtual memory" operators for GhostScript */
+ #include "ghost.h"
+ #include "errors.h"
+ #include "oper.h"
+ #include "alloc.h"
+ #include "state.h"
+ #include "store.h"
+ #include "gsmatrix.h"			/* for gsstate.h */
+ #include "gsstate.h"
+ 
+ /* Import the stacks for checking in restore */
+ extern ref estack[], dstack[];
+ extern ref *osbot, *esp, *dsp;
+ 
+ /* 'Save' structure */
+ typedef struct vm_save_s vm_save;
+ struct vm_save_s {
+ 	alloc_save *asave;		/* allocator save */
+ 	int_state *isave;		/* old interpreter state */
+ 	gs_state *gsave;		/* old graphics state */
+ };
+ 
+ /* save */
+ int
+ zsave(register ref *op)
+ {	int code = zgsave(op);
+ 	vm_save *vmsave = (vm_save *)alloc(1, sizeof(vm_save), "zsave");
+ 	alloc_save *asave = alloc_save_state();
+ 	if ( code < 0 ) return code;
+ 	if ( vmsave == 0 || asave == 0 ) return e_VMerror;
+ 	vmsave->asave = asave;
+ 	/* Save the old interpreter state pointers, */
+ 	/* and cut the chains so we can't grestore past here. */
+ 	vmsave->isave = istate.saved;
+ 	istate.saved = 0;
+ 	vmsave->gsave = gs_state_swap_saved(igs, (gs_state *)0);
+ 	push(1);
+ 	make_tv(op, t_save, psave, vmsave);
+ 	return 0;
+ }
+ 
+ /* restore */
+ private int restore_check_stack(P3(ref *, ref *, alloc_save *));
+ int
+ zrestore(register ref *op)
+ {	vm_save *vmsave;
+ 	alloc_save *asave;
+ 	int code;
+ 	check_type(*op, t_save);
+ 	vmsave = op->value.psave;
+ 	asave = vmsave->asave;
+ 	/* Check the contents of the stacks. */
+ 	   {	int code;
+ 		if ( (code = restore_check_stack(osbot, op, asave)) < 0 ||
+ 		     (code = restore_check_stack(estack, esp + 1, asave)) < 0 ||
+ 		     (code = restore_check_stack(dstack, dsp + 1, asave)) < 0
+ 		   )
+ 			return code;
+ 	   }
+ 	if ( alloc_restore_state_check(asave) < 0 )
+ 		return e_invalidrestore;
+ 	/* Restore the graphics state back to the state */
+ 	/* that was allocated by the save. */
+ 	/* This must be done before the alloc_restore_state. */
+ 	zgrestoreall(op);
+ 	/* Now it's safe to restore the state of memory. */
+ 	alloc_restore_state(asave);
+ 	/* Put back the interpreter state chain pointers, */
+ 	/* and do a grestore. */
+ 	istate.saved = vmsave->isave;
+ 	gs_state_swap_saved(igs, vmsave->gsave);
+ 	if ( (code = zgrestore(op)) < 0 ) return code;
+ 	alloc_free((char *)vmsave, 1, sizeof(vm_save), "zrestore");
+ 	pop(1);
+ 	return 0;
+ }
+ /* Check a stack to make sure all its elements are older than a save. */
+ private int
+ restore_check_stack(ref *bot, ref *top, alloc_save *asave)
+ {	ref *stkp;
+ 	for ( stkp = bot; stkp < top; stkp++ )
+ 	   {	char *ptr;
+ 		switch ( r_type(stkp) )
+ 		   {
+ 		case t_array:
+ 		case t_packedarray: ptr = (char *)stkp->value.refs; break;
+ 		case t_dictionary: ptr = (char *)stkp->value.pdict; break;
+ 		case t_fontID: ptr = (char *)stkp->value.pfont; break;
+ 		/* case t_file: ****** WHAT? ****** */
+ 		case t_name: ptr = (char *)stkp->value.pname; break;
+ 		case t_save: ptr = (char *)stkp->value.psave; break;
+ 		case t_string: ptr = (char *)stkp->value.bytes; break;
+ 		case t_color: ptr = (char *)stkp->value.pcolor; break;
+ 		case t_device: ptr = (char *)stkp->value.pdevice; break;
+ 		default: continue;
+ 		   }
+ 		if ( alloc_is_since_save(ptr, asave) )
+ 			return e_invalidrestore;
+ 	   }
+ 
+ 	return 0;			/* OK */
+ }
+ 
+ /* vmstatus */
+ int
+ zvmstatus(register ref *op)
+ {	long used, total;
+ 	alloc_status(&used, &total);
+ 	push(3);
+ 	make_int(op - 2, alloc_save_level());
+ 	make_int(op - 1, used);
+ 	make_int(op, total);
+ 	return 0;
+ }
+ 
+ /* ------ Initialization procedure ------ */
+ 
+ void
+ zvmem_op_init()
+ {	static op_def my_defs[] = {
+ 		{"1restore", zrestore},
+ 		{"0save", zsave},
+ 		{"0vmstatus", zvmstatus},
+ 		op_def_end
+ 	};
+ 	z_op_init(my_defs);
+ }





More information about the llvm-commits mailing list