/* Generated with C2C (Cedar To C)*/
/* Copyright (C) 1992 by Xerox Corporation.  All rights reserved. */
/* time: August 19, 1992 3:36:00 pm PDT */
/* C2C version: October 16, 1990 (native) */
/* ref-counting: off */
/* file: XlPrivateResourcesImpl, module: XlPrivateResourcesImpl */ 
/* switches: bcfhklnouw */ 
#include <cedar/InstallationSupport.h>
#include <cedar/CedarExtra.h>
#define XRM←BITAND(x, y) (((word)(x)) & ((word)(y)))
#define XRM←BITOR(x, y) (((word)(x)) | ((word)(y)))
static char versionStamp[] = "@(#)mob←version [2861273789,3017289246] XlPrivateResourcesImpl";
typedef unsigned word, *ptr;
typedef unsigned char byte, *bPt;
typedef unsigned short half, *hPt;
typedef word (*fPt)();
typedef struct {word f0, f1;} W2;
#define SOURCE(p, l) /* source p, l */
#define SGNCK(i) ((int) (word) (i) < 0 ? XR←RaiseArithmeticFault(): i )
#define BCK(idx, lim) ( ((unsigned) idx) >= ((unsigned) lim) ? (XR←RaiseBoundsFault()) : (idx) )
static void NoName←Q1080();
static void XlPrivateResourcesImpl←P0();
static void InitPrivateResources←P60();
static void MarkDead←P120();
static word NewResourceID←P180();
static void InternalFreeResourceID←P240();
static void EntryFreeResourceID←P300();
static word ValidID←P360();
static void Attach←P420();
static void Detach←P480();
static word Fetch←P540();
static struct {unsigned f; char r[16];} string1 = {851984, "\257\300\252\213\222\275\300\263\330\056\036\100\214\000\000"};
static struct {unsigned f; char r[4];} string2 = {131074, "\0040\000"};
static struct {unsigned f; char r[16];} string3 = {851984, "\257\300\252\213\222\275\300\263\330\056\036\100\230\000\000"};
static struct {unsigned f; char r[4];} string4 = {196611, "\003@A"};
static struct {unsigned f; char r[16];} string5 = {851984, "\257\300\252\213\222\275\300\263\330\056\036\100\200\000\000"};
static struct {unsigned f; char r[16];} string6 = {851984, "\257\300\223\215\300\016\300\070\141\304\023\100\150\000\000"};
static struct {unsigned f; char r[16];} string7 = {851984, "\257\300\351\276\264\273\300\115\104\320\264\100\164\000\000"};
static struct {unsigned f; char r[32];} string8 = {1900576, "\211\021\020\122\145\163\157\165\162\143\145\123\164\165\146\146\122\145\160\300\351\276\264\273\300\115\104\320\264\000\000"};
static struct {unsigned f; char r[16];} string9 = {851984, "\257\300\044\126\136\322\300\125\273\233\107\100\150\000\000"};
static struct {
   word f0[6]; word f6; word f7; word f8; 
   word f9; word f10; word f11; word f12; 
   word f13; word f14; word f15; word f16; 
   word f17; word f18; word f19; word f20; 
   word f21; word f22; word f23; word f24; 
   word f25[4]; 
   } globalframe = {
   {0}, (word) Fetch←P540, 0, (word) Detach←P480, 
   0, (word) Attach←P420, 0, (word) ValidID←P360, 
   0, (word) EntryFreeResourceID←P300, 0, (word) InternalFreeResourceID←P240, 
   0, (word) NewResourceID←P180, 0, (word) MarkDead←P120, 
   0, (word) InitPrivateResources←P60, 0, (word) XlPrivateResourcesImpl←P0, 
   {0}
   };

static void NoName←Q1080()
   {
   register ptr gf←c066 =  (ptr) &globalframe;
   word var←c8788;
   (* (( (ptr) gf←c066)+4) ) = (word) XR←GetTypeIndex((word) &string1, 0, (word) &string2);
   (* (( (ptr) gf←c066)+5) ) = (word) XR←GetTypeIndex((word) &string3, 0, (word) &string4);
   (void) XR←DeclareGlobalFrame((word) "XlPrivateResourcesImpl", &globalframe, (word) XR←GetTypeIndexS((word) (&string5)), (word) (
         ( (bPt) gf←c066)+96)/* var←c8212 */ );
   var←c8788 = (word) XR←ImportInterface((word) "CardTab", (word) XR←GetTypeIndexS((word) (&string6)), 12);
   (* (( (ptr) gf←c066)+26)/* var←c8372 */  ) = var←c8788;
   (void) XR←ImportProcS(var←c8788, 134742786);
   (void) XR←ImportProcS(var←c8788, 67634946);
   (void) XR←ImportProcS(var←c8788, 67896579);
   (void) XR←ImportProcS(var←c8788, 264193);
   (void) XR←ImportProcS(var←c8788, 67371265);
   var←c8788 = (word) XR←ExportInterface((word) "Xl", (word) XR←GetTypeIndexS((word) (&string7)), 218);
   (* (( (ptr) gf←c066)+27)/* var←c8820 */  ) = var←c8788;
   (void) XR←ExportType((word) "ResourceStuffRep", (word) XR←GetTypeIndexS((word) (&string8)), (word) XR←GetTypeIndex((word) &string1, 0, (word) &string2)
      );
   var←c8788 = (word) XR←ExportInterface((word) "XlPrivateResources", (word) XR←GetTypeIndexS((word) (&string9)), 9);
   (* (( (ptr) gf←c066)+28)/* var←c8852 */  ) = var←c8788;
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+88)/* var←c8180 */ , 786435);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+80)/* var←c8148 */ , 262401);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+72)/* var←c8116 */ , 67371521);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+64)/* var←c8084 */ , 525058);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+56)/* var←c8052 */ , 525314);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+48)/* var←c8020 */ , 67634434);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+40)/* var←c7988 */ , 787971);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+32)/* var←c7956 */ , 526082);
   (void) XR←ExportProcS(var←c8788, (word) (( (bPt) gf←c066)+24)/* var←c7924 */ , 67635202);
   }

static void XlPrivateResourcesImpl←P0(formal←c017, formal←c016)
   word formal←c017;
   word formal←c016;
   {
   /* XlPrivateResourcesImpl: */ 
   }

static void InitPrivateResources←P60(c←v3424, resourceIdBase←v3452, resourceIdMask←v3480)
   word c←v3424;
   word resourceIdBase←v3452;
   word resourceIdMask←v3480;
   {
   register ptr gf←c8884 =  (ptr) &globalframe;
   word resources←v4344;
   /* InitPrivateResources: */ 
SOURCE(640, 345)
SOURCE(734, 222)
   {
      word var←c8244;
      word var←c8340;
      word var←c8404;
      {
         word var←c8276;
         word w2←v7876;
         w2←v7876 = ( (word) -1 - (resourceIdMask←v3480 - 1));
         var←c8276 = (word) XRM←BITAND(resourceIdMask←v3480, w2←v7876);
         var←c8244 = var←c8276;
         };
      {
         word pd10;
         pd10 = (* (( (ptr) (* (( (ptr) gf←c8884)+26)/* var←c8372 */  ))+5) );
         var←c8340 = (word) ( *( (fPt) ((*  (ptr) pd10 ))))(17, pd10);
         };
      var←c8404 = XR←NewObject(24, (* (( (ptr) gf←c8884)+4) ));
      (*  (ptr) var←c8404 ) = resourceIdBase←v3452;
      (* (( (ptr) var←c8404)+1) ) = resourceIdMask←v3480;
      (* (( (ptr) var←c8404)+2) ) = var←c8244;
      (* (( (ptr) var←c8404)+5) ) = var←c8340;
      resources←v4344 = var←c8404;
      };
SOURCE(958, 27)
   (* (( (ptr) c←v3424)+26) ) = resources←v4344;
   }

static void MarkDead←P120(c←v3540)
   word c←v3540;
   {
   register ptr gf←c8916 =  (ptr) &globalframe;
   word resources←v4400;
   /* MarkDead: */ 
SOURCE(990, 214)
SOURCE(1032, 49)
   resources←v4400 = (* (( (ptr) c←v3540)+26) );
SOURCE(1083, 121)
   if ((resources←v4400 != 0)) {
SOURCE(1107, 24)
      (* (( (ptr) resources←v4400)+4) ) = 0;
SOURCE(1133, 71)
      if (((* (( (ptr) resources←v4400)+5) ) != 0)) {
SOURCE(1167, 37)
         {
            word pd11;
            pd11 = (* (( (ptr) (* (( (ptr) gf←c8916)+26)/* var←c8372 */  ))+12) );
            (void) ( *( (fPt) ((*  (ptr) pd11 ))))((* ((( (ptr) resources←v4400)+5)) ), pd11);
            };
         };
      };
   }

static word NewResourceID←P180(c←v3600)
   word c←v3600;
   {
   word id←v3644;
   word resources←v4484;
   word free←v4512;
   /* NewResourceID: */ 
SOURCE(1210, 635)
SOURCE(1580, 49)
   resources←v4484 = (* (( (ptr) c←v3600)+26) );
SOURCE(1631, 39)
   free←v4512 = (* (( (ptr) resources←v4484)+4) );
SOURCE(1672, 49)
   if ( ( (free←v4512 != 0) ? ((* (( (ptr) free←v4512)+64) ) == 0) : 0 ) ) {
SOURCE(1705, 16)
      free←v4512 = (* (( (ptr) free←v4512)+65) );
      };
SOURCE(1723, 85)
   if ( ( (free←v4512 != 0) ? ((* (( (ptr) free←v4512)+64) ) > 0) : 0 ) ) {
SOURCE(1757, 23)
      {
         word idx12;
         (* (( (ptr) free←v4512)+64) ) = (
            idx12 = (word) ((* (( (ptr) free←v4512)+64) ) - 1),
            SGNCK(idx12)
            );
         };
SOURCE(1782, 26)
      {
         word idx13;
         return((* (( (ptr) free←v4512)+(
               idx13 = (* (( (ptr) free←v4512)+64) ),
               BCK(idx13, 64)
               )) ));
         };
      };
SOURCE(1811, 34)
   {
      word var←c8468;
      word resources←v7676;
      resources←v7676 = resources←v4484;
      {
         word var←c8532;
         word w1←v7724;
         word w2←v7752;
SOURCE(1366, 41)
         if (((* (( (ptr) resources←v7676)+3) ) == (* (( (ptr) resources←v7676)+1) ))) {
SOURCE(1407, 5)
            (void) XR←RaiseUnnamedError();
            };
SOURCE(1462, 55)
         (* (( (ptr) resources←v7676)+3) ) = ((* (( (ptr) resources←v7676)+3) ) + (* (( (ptr) resources←v7676)+2) ));
SOURCE(1519, 56)
         w1←v7724 = (* (( (ptr) resources←v7676)+3) );
         w2←v7752 = (*  (ptr) resources←v7676 );
         var←c8532 = (word) XRM←BITOR(w1←v7724, w2←v7752);
         var←c8468 = (var←c8532
         );
         };
      return(var←c8468);
      };
   }

static void InternalFreeResourceID←P240(c←v3704, id←v3732)
   word c←v3704;
   word id←v3732;
   {
   register ptr gf←c8948 =  (ptr) &globalframe;
   /* InternalFreeResourceID: */ 
SOURCE(1850, 381)
SOURCE(1927, 304)
   if ( (  ( (c←v3704 != 0) ? (0 != (* (( (ptr) c←v3704)+15) )) : 0 )  ? (0 != (word) ValidID←P360(c←v3704, id←v3732)) : 0 ) ) {
SOURCE(1966, 267)
      {
         word resources←v4696;
         word free←v4724;
SOURCE(1968, 49)
         resources←v4696 = (* (( (ptr) c←v3704)+26) );
SOURCE(2019, 39)
         free←v4724 = (* (( (ptr) resources←v4696)+4) );
SOURCE(2060, 121)
         if ((free←v4724 == 0) || ((* (( (ptr) free←v4724)+64) ) >= 64)) {
SOURCE(2104, 49)
            {
               word var←c8596;
               var←c8596 = XR←NewObject(264, (* (( (ptr) gf←c8948)+5) ));
               (* (( (ptr) var←c8596)+65) ) = (* (( (ptr) resources←v4696)+4) );
               free←v4724 = var←c8596;
               };
SOURCE(2155, 26)
            (* (( (ptr) resources←v4696)+4) ) = free←v4724;
            };
SOURCE(2184, 22)
         {
            word idx14;
            (* (( (ptr) free←v4724)+(
                  idx14 = (* (( (ptr) free←v4724)+64) ),
                  BCK(idx14, 64)
                  )) ) = id←v3732;
            };
SOURCE(2208, 23)
         (* (( (ptr) free←v4724)+64) ) = ((* (( (ptr) free←v4724)+64) ) + 1);
         };
      };
   }

static void EntryFreeResourceID←P300(c←v3792, id←v3820)
   word c←v3792;
   word id←v3820;
   {
   /* EntryFreeResourceID: */ 
SOURCE(2240, 96)
   (void) (XR←MonitorEntry(c←v3792));
SOURCE(2307, 29)
   (void) InternalFreeResourceID←P240(c←v3792, id←v3820);
SOURCE(2240, 96)
   (void) (XR←MonitorExit(c←v3792));
   return;
   }

static word ValidID←P360(c←v3880, id←v3908)
   word c←v3880;
   word id←v3908;
   {
   word var←c3952;
   word resources←v4792;
   /* ValidID: */ 
SOURCE(2342, 203)
SOURCE(2406, 49)
   resources←v4792 = (* (( (ptr) c←v3880)+26) );
SOURCE(2457, 88)
   {
      word var←c073;
      if ((id←v3908 != 0)) {
         {
            word var←c8660;
            word w1←v7800;
            word w2←v7828;
            w1←v7800 = ( (word) -1 - (* (( (ptr) resources←v4792)+1) ));
            w2←v7828 = (id←v3908 - (*  (ptr) resources←v4792 ));
            var←c8660 = (word) XRM←BITAND(w1←v7800, w2←v7828);
            var←c073 = (var←c8660 == 0);
            };
         }
      else {
         var←c073 = 0;
         };
      return(var←c073);
      };
   }

static void Attach←P420(c←v4012, id←v4040, ref←v4068)
   word c←v4012;
   word id←v4040;
   word ref←v4068;
   {
   register ptr gf←c8980 =  (ptr) &globalframe;
   word resources←v4848;
   /* Attach: */ 
SOURCE(2551, 159)
SOURCE(2609, 49)
   resources←v4848 = (* (( (ptr) c←v4012)+26) );
SOURCE(2660, 50)
   {
      word var←c8724;
      word pd15;
      pd15 = (* (( (ptr) (* (( (ptr) gf←c8980)+26)/* var←c8372 */  ))+9) );
      var←c8724 = (word) ( *( (fPt) ((*  (ptr) pd15 ))))((* (( (ptr) resources←v4848)+5) ), id←v4040, ref←v4068, pd15);
      };
   }

static void Detach←P480(c←v4144, id←v4172)
   word c←v4144;
   word id←v4172;
   {
   register ptr gf←c9012 =  (ptr) &globalframe;
   word resources←v4904;
   /* Detach: */ 
SOURCE(2715, 145)
SOURCE(2763, 49)
   resources←v4904 = (* (( (ptr) c←v4144)+26) );
SOURCE(2814, 46)
   {
      word var←c8756;
      word pd16;
      pd16 = (* (( (ptr) (* (( (ptr) gf←c9012)+26)/* var←c8372 */  ))+11) );
      var←c8756 = (word) ( *( (fPt) ((*  (ptr) pd16 ))))((* (( (ptr) resources←v4904)+5) ), id←v4172, pd16);
      };
   }

static word Fetch←P540(c←v4232, id←v4260)
   word c←v4232;
   word id←v4260;
   {
   register ptr gf←c9044 =  (ptr) &globalframe;
   word ref←v4304;
   word resources←v4960;
   W2 var←c065;
   /* Fetch: */ 
SOURCE(2865, 167)
SOURCE(2865, 167)
   ref←v4304 = 0;
SOURCE(2931, 49)
   resources←v4960 = (* (( (ptr) c←v4232)+26) );
SOURCE(2982, 50)
   {
      word pd17;
      pd17 = (* (( (ptr) (* (( (ptr) gf←c9044)+26)/* var←c8372 */  ))+7) );
      (void) ( *( (fPt) ((*  (ptr) pd17 ))))((word) &var←c065, (* (( (ptr) resources←v4960)+5) ), id←v4260, pd17);
      };
   ref←v4304 = var←c065.f1;
SOURCE(2865, 167)
   return(ref←v4304);
   }

/* file: XlPrivateResourcesImpl, module: XlPrivateResourcesImpl, compiled at: August 19, 1992 3:35:59 pm PDT */ 
extern void XR←install←XlPrivateResourcesImpl() {
   NoName←Q1080();
   }
extern void XR←run←XlPrivateResourcesImpl() { XR←Start(&globalframe); }