/* Generated with C2C (Cedar To C)*/
/* Copyright (C) 1992 by Xerox Corporation.  All rights reserved. */
/* time: February 21, 1992 7:40:53 pm PST */
/* C2C version: October 16, 1990 (native) */
/* ref-counting: off */
/* file: AsynchronousEventsImpl, module: AsynchronousEventsImpl */ 
/* switches: bcfhklnouw */ 
#include <cedar/InstallationSupport.h>
#include <cedar/CedarExtra.h>
static char versionStamp[] = "@(#)mob←version [1958539963,3845346028] AsynchronousEventsImpl";
typedef unsigned word, *ptr;
typedef unsigned char byte, *bPt;
typedef unsigned short half, *hPt;
typedef struct {word f0, f1;} W2;
typedef word (*fPt)();
typedef struct {word f0, f1, f2;} W3;
typedef W3 *W3Pt;
typedef W2 *W2Pt;
typedef struct {word f0, f1, f2, f3;} W4;
typedef struct {word f0, f1, f2, f3, f4, f5, f6, f7;} W8;
#define SOURCE(p, l) /* source p, l */
#define BCK(idx, lim) ( ((unsigned) idx) >= ((unsigned) lim) ? (XR←RaiseBoundsFault()) : (idx) )
static void NoName←Q672();
static void AsynchronousEventsImpl←P0();
static void RegisterInterest←P60();
static void TellPCR←P120();
static word Ok←P180();
static void MoreRegistrations←P240();
static void StopProcessingEvents←P300();
static void ProcessEvents←P360();
static void ProcessOneEvent←P420();
static word NoName←Q732();
static void NoName←Q792();
static word NoName←Q852();
static struct {unsigned f; char r[16];} string1 = {851984, "\257\300\164\274\362\273\300\345\063\122\354\100\214\000\000"};
static struct {unsigned f; char r[16];} string2 = {851984, "\257\300\164\274\362\273\300\345\063\122\354\100\164\000\000"};
static struct {unsigned f; char r[4];} string3 = {131074, "\003\010\000"};
static struct {unsigned f; char r[16];} string4 = {851984, "\257\300\240\236\274\315\300\111\163\325\023\100\150\000\000"};
static struct {unsigned f; char r[16];} string5 = {851984, "\257\300\254\022\215\272\300\356\006\202\125\100\150\000\000"};
static struct {
   word f0[12]; 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; word f26; 
   word f27; word f28; word f29; word f30; 
   word f31; word f32; word f33; word f34; 
   word f35; word f36; word f37; word f38; 
   word f39; word f40[2]; 
   } globalframe = {
   {0}, (word) ProcessOneEvent←P420, 0, (word) ProcessEvents←P360, 
   0, (word) StopProcessingEvents←P300, 0, (word) MoreRegistrations←P240, 
   0, (word) Ok←P180, 0, (word) TellPCR←P120, 
   0, (word) RegisterInterest←P60, 0, (word) AsynchronousEventsImpl←P0, 
   0, 1, 2, 13, 
   17, 23, 24, 25, 
   26, 27, 28, 29, 
   31, {0}
   };

static void NoName←Q672()
   {
   register ptr gf←c068 =  (ptr) &globalframe;
   word var←c6564;
   (* (( (ptr) gf←c068)+10) ) = (word) XR←GetTypeIndexS((word) (&string1));
   (void) XR←DeclareGlobalFrame((word) "AsynchronousEventsImpl", &globalframe, (word) XR←GetTypeIndex((word) &string2, 0, (word) &string3)
      , (word) (( (bPt) gf←c068)+104)/* var←c5764 */ );
   var←c6564 = (word) XR←ImportInterface((word) "Process", (word) XR←GetTypeIndexS((word) (&string4)), 22);
   (* (( (ptr) gf←c068)+40)/* var←c5924 */  ) = var←c6564;
   (void) XR←ImportProcS(var←c6564, 527105);
   (void) XR←ImportProcS(var←c6564, 134219776);
   (void) XR←ImportProcS(var←c6564, 526081);
   var←c6564 = (word) XR←ExportInterface((word) "AsynchronousEvents", (word) XR←GetTypeIndexS((word) (&string5)), 1);
   (* (( (ptr) gf←c068)+41)/* var←c6596 */  ) = var←c6564;
   (void) XR←ExportProcS(var←c6564, (word) (( (bPt) gf←c068)+96)/* var←c5732 */ , 524290);
   }

static void AsynchronousEventsImpl←P0(formal←c027, formal←c020)
   word formal←c027;
   word formal←c020;
   {
   register ptr gf←c6628 =  (ptr) &globalframe;
   /* AsynchronousEventsImpl: */ 
SOURCE(51, 3182)
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
   /* moved to installation proc */ 
SOURCE(579, 59)
   {
      word var←c5860;
      var←c5860 = XR←NewObject(128, (* (( (ptr) gf←c6628)+10) ));
      (* (( (ptr) var←c5860)+1) ) = 10;
      (* (( (ptr) gf←c6628)+8)/* registrations←v2664 */  ) = var←c5860;
      };
SOURCE(2412, 21)
   (* (( (ptr) gf←c6628)+9)/* continue←v2888 */  ) = 1;
SOURCE(3192, 41)
SOURCE(3194, 39)
   {
      W2 var←c5892;
      {
         W2 var←c024;
         word var←c023;
         var←c023 = XR←ExtensionAlloc(4);
         {
            word tmpAddr6;
            tmpAddr6 = (word) var←c023;
            (*  (ptr) tmpAddr6 ) = ( ((word)  (fPt) NoName←Q852) );
            (* (( (ptr) tmpAddr6) + 1) ) = 0;
            (* (( (ptr) tmpAddr6) + 2) ) = (word) (( (bPt) gf←c6628)+56)/* var←c5572 */ ;
            (* (( (ptr) tmpAddr6) + 3) ) = 0;
            };
         (void) XR←Fork((word) &var←c024, var←c023);
         var←c5892 = var←c024;
         };
      {
         word pd7;
         pd7 = (* (( (ptr) (* (( (ptr) gf←c6628)+40)/* var←c5924 */  ))+11) );
         (void) ( *( (fPt) ((*  (ptr) pd7 ))))(var←c5892, pd7);
         };
      };
   }

static void RegisterInterest←P60(event←v3316, interested←v3344)
   word event←v3316;
   word interested←v3344;
   {
   register ptr gf←c6660 =  (ptr) &globalframe;
   W2 self←v4080;
   /* RegisterInterest: */ 
SOURCE(641, 506)
   (void) (XR←MonitorEntry((word) (( (bPt) gf←c6660)+16)/* LOCK←v2496 */ ));
SOURCE(714, 36)
   {
      word pd8;
      pd8 = (* (( (ptr) (* (( (ptr) gf←c6660)+40)/* var←c5924 */  ))+12) );
      (void) ( *( (fPt) ((*  (ptr) pd8 ))))((word) (&self←v4080), pd8);
      };
SOURCE(752, 42)
   if ((0 != (word) Ok←P180(event←v3316, interested←v3344, self←v4080))) {
SOURCE(788, 6)
      (void) (XR←MonitorExit((word) (( (bPt) gf←c6660)+16)/* LOCK←v2496 */ ));
      return;
      };
SOURCE(796, 89)
   if (((*  (ptr) (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  ) ) == (* (( (ptr) (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  ))+1)
    ))) {
SOURCE(866, 19)
      (void) MoreRegistrations←P240();
      };
SOURCE(887, 260)
   {
      register word i←v4140 = 0;
      register word noName←c5956;
      word var←c5988;
      noName←c5956 = (* (( (ptr) (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  ))+1) );
      if ((i←v4140 >= noName←c5956)) {
         goto lab←L100000;
         };
      lab←L100003: ;
SOURCE(941, 206)
      {
         word limit9;
         W2 temp10;
         var←c5988 = (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  );
         (*  (ptr) &temp10 ) = 0;
         (* (( (ptr) &temp10) + 1) ) = 0;
         if (XR←EqualWords((( (W3Pt) (( (ptr) var←c5988)+2))+(
                  limit9 = (* (( (ptr) var←c5988)+1) ),
                  BCK(i←v4140, limit9)
                  )), &temp10, 2)) {
            {
               word var←c6020;
               word var←c6052;
SOURCE(982, 31)
               {
                  word limit11;
                  var←c6020 = (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  );
                  (*  (W2Pt) (( (W3Pt) (( (ptr) var←c6020)+2))+(
                        limit11 = (* (( (ptr) var←c6020)+1) ),
                        BCK(i←v4140, limit11)
                        )) ) = self←v4080;
                  };
SOURCE(1015, 30)
               {
                  word limit12;
                  var←c6052 = (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  );
                  (* (( (W3Pt) (( (ptr) var←c6052)+2))+(
                        limit12 = (* (( (ptr) var←c6052)+1) ),
                        BCK(i←v4140, limit12)
                        )) ).f2 = event←v3316;
                  };
SOURCE(1047, 64)
               (*  (ptr) (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  ) ) = ((*  (ptr) (* (( (ptr) gf←c6660)+8)/* registrations←v2664 */  ) ) + 
               1);
SOURCE(1113, 26)
               (void) TellPCR←P120((* (((( (ptr) gf←c6660)+28)/* var←c5828 */ +event←v3316)) ));
SOURCE(1141, 6)
               (void) (XR←MonitorExit((word) (( (bPt) gf←c6660)+16)/* LOCK←v2496 */ ));
               return;
               };
            };
         };
      i←v4140 = (i←v4140 + 1);
      if ((i←v4140 < noName←c5956)) {
         goto lab←L100003;
         };
      lab←L100000: ;
      };
SOURCE(1161, 5)
   (void) XR←RaiseUnnamedError();
   }

static void TellPCR←P120(sig←v3404)
   word sig←v3404;
   {
   /* TellPCR: */ 
SOURCE(1172, 135)
SOURCE(1208, 99)
   if ((sig←v3404 == 2)) {
SOURCE(1229, 41)
      (void) XR←UIORegisterInterestInINTEvent(1);
      }
   else {
SOURCE(1270, 37)
      (void) XR←UIORegisterInterestInEvent(sig←v3404, 1);
      };
   }

static word Ok←P180(event←v3612, interested←v3640, process←v3668)
   word event←v3612;
   word interested←v3640;
   W2 process←v3668;
   {
   register ptr gf←c6692 =  (ptr) &globalframe;
   word var←c3728;
   /* Ok: */ 
SOURCE(1599, 393)
SOURCE(1678, 275)
   {
      register word i←v4184 = 0;
      register word noName←c6084;
      word var←c6116;
      word var←c6148;
      word var←c078;
      noName←c6084 = (* (( (ptr) (* (( (ptr) gf←c6692)+8)/* registrations←v2664 */  ))+1) );
      if ((i←v4184 >= noName←c6084)) {
         goto lab←L100004;
         };
      lab←L100007: ;
SOURCE(1732, 221)
      {
         word tc13;
         word limit14;
         var←c6116 = (* (( (ptr) gf←c6692)+8)/* registrations←v2664 */  );
         if (XR←EqualWords((( (W3Pt) (( (ptr) var←c6116)+2))+(
                  limit14 = (* (( (ptr) var←c6116)+1) ),
                  BCK(i←v4184, limit14)
                  )), &process←v3668, 2)) {
            {
               word limit15;
               var←c6148 = (* (( (ptr) gf←c6692)+8)/* registrations←v2664 */  );
               var←c078 = (* (( (W3Pt) (( (ptr) var←c6148)+2))+(
                     limit15 = (* (( (ptr) var←c6148)+1) ),
                     BCK(i←v4184, limit15)
                     )) ).f2;
               };
            tc13 =  (word) (var←c078 == event←v3612);
            }
         else {
            tc13 =  (word) 0;
            };
         if (tc13) {
SOURCE(1813, 121)
            if ((0 == interested←v3640)) {
               {
                  word var←c6180;
SOURCE(1838, 30)
                  {
                     word limit16;
                     word tmpAddr17;
                     var←c6180 = (* (( (ptr) gf←c6692)+8)/* registrations←v2664 */  );
                     tmpAddr17 = (word) (( (W3Pt) (( (ptr) var←c6180)+2))+(
                           limit16 = (* (( (ptr) var←c6180)+1) ),
                           BCK(i←v4184, limit16)
                           ));
                     (*  (ptr) tmpAddr17 ) = 0;
                     (* (( (ptr) tmpAddr17) + 1) ) = 0;
                     };
SOURCE(1870, 64)
                  (*  (ptr) (* (( (ptr) gf←c6692)+8)/* registrations←v2664 */  ) ) = ((*  (ptr) (* (( (ptr) gf←c6692)+8)/* registrations←v2664 */  ) ) - 1);
                  };
               };
SOURCE(1939, 14)
            return(1);
            };
         };
      i←v4184 = (i←v4184 + 1);
      if ((i←v4184 < noName←c6084)) {
         goto lab←L100007;
         };
      lab←L100004: ;
      };
SOURCE(1967, 25)
   return((0 == interested←v3640));
   }

static void MoreRegistrations←P240()
   {
   register ptr gf←c6724 =  (ptr) &globalframe;
   word newRegistrations←v4228;
   /* MoreRegistrations: */ 
SOURCE(1998, 322)
SOURCE(2026, 93)
   {
      word var←c6212;
      word var←c6244;
      word var←c6276;
      var←c6212 = ((* (( (ptr) (* (( (ptr) gf←c6724)+8)/* registrations←v2664 */  ))+1) ) + 10);
      var←c6244 = (var←c6212 * 12);
      var←c6276 = XR←NewObject((8 + var←c6244), (* (( (ptr) gf←c6724)+10) ));
      (* (( (ptr) var←c6276)+1) ) = var←c6212;
      newRegistrations←v4228 = var←c6276;
      };
SOURCE(2121, 62)
   (*  (ptr) newRegistrations←v4228 ) = (*  (ptr) (* (( (ptr) gf←c6724)+8)/* registrations←v2664 */  ) );
SOURCE(2185, 92)
   {
      register word i←v4284 = 0;
      register word noName←c6308;
      noName←c6308 = (* (( (ptr) (* (( (ptr) gf←c6724)+8)/* registrations←v2664 */  ))+1) );
      if ((i←v4284 >= noName←c6308)) {
         goto lab←L100008;
         };
      lab←L100011: ;
SOURCE(2239, 38)
      {
         word var←c6340;
         var←c6340 = (* (( (ptr) gf←c6724)+8)/* registrations←v2664 */  );
         {
            word limit18;
            word limit19;
            (* (( (W3Pt) (( (ptr) newRegistrations←v4228)+2))+(
                  limit18 = (* (( (ptr) newRegistrations←v4228)+1) ),
                  BCK(i←v4284, limit18)
                  )) ) = (* (( (W3Pt) (( (ptr) var←c6340)+2))+(
                  limit19 = (* (( (ptr) var←c6340)+1) ),
                  BCK(i←v4284, limit19)
                  )) );
            };
         };
      i←v4284 = (i←v4284 + 1);
      if ((i←v4284 < noName←c6308)) {
         goto lab←L100011;
         };
      lab←L100008: ;
      };
SOURCE(2288, 32)
   (* (( (ptr) gf←c6724)+8)/* registrations←v2664 */  ) = newRegistrations←v4228;
   }

static void StopProcessingEvents←P300()
   {
   register ptr gf←c6756 =  (ptr) &globalframe;
   /* StopProcessingEvents: */ 
SOURCE(2435, 47)
SOURCE(2466, 16)
   (* (( (ptr) gf←c6756)+9)/* continue←v2888 */  ) = 0;
   }

static void ProcessEvents←P360()
   {
   register ptr gf←c6788 =  (ptr) &globalframe;
   W4 myEvent←v4328;
   /* ProcessEvents: */ 
SOURCE(2488, 118)
SOURCE(2520, 17)
   myEvent←v4328.f0 = 0;
   myEvent←v4328.f1 = 0;
   myEvent←v4328.f2 = 0;
   myEvent←v4328.f3 = 0;
SOURCE(2539, 67)
   lab←L100014: ;
   if ((* (( (ptr) gf←c6788)+9)/* continue←v2888 */  )) {
      }
   else {
      goto lab←L100012;
      };
SOURCE(2557, 23)
   (void) XR←UIOAwaitEvent((word) (&myEvent←v4328));
SOURCE(2582, 24)
   (void) ProcessOneEvent←P420(myEvent←v4328);
   goto lab←L100014;
   lab←L100012: ;
   }

static void ProcessOneEvent←P420(eventInstance←v4052)
   W4 eventInstance←v4052;
   {
   W8 var←c6820;
   register ptr gf←c6852 =  (ptr) &globalframe;
   /* ProcessOneEvent: */ 
SOURCE(2711, 442)
   (void) (XR←MonitorEntry((word) (( (bPt) gf←c6852)+16)/* LOCK←v2496 */ ));
SOURCE(2769, 384)
   {
      /* declaration of i←v4372 skipped */ 
      register word noName←c6404;
      word var←c6436;
      word var←c6468;
      word var←c079;
      var←c6820.f4/* i←v4372 */  = 0;
      noName←c6404 = (* (( (ptr) (* (( (ptr) gf←c6852)+8)/* registrations←v2664 */  ))+1) );
      if ((var←c6820.f4/* i←v4372 */  >= noName←c6404)) {
         goto lab←L100015;
         };
      lab←L100018: ;
SOURCE(2823, 330)
      {
         word tc20;
         word idx21;
         word limit22;
         W2 temp23;
         var←c6436 = (* (( (ptr) gf←c6852)+8)/* registrations←v2664 */  );
         (*  (ptr) &temp23 ) = 0;
         (* (( (ptr) &temp23) + 1) ) = 0;
         if ( ! XR←EqualWords((( (W3Pt) (( (ptr) var←c6436)+2))+(
                  idx21 = (word) var←c6820.f4/* i←v4372 */ ,
                  limit22 = (* (( (ptr) var←c6436)+1) ),
                  BCK(idx21, limit22)
                  )), &temp23, 2)) {
            {
               word idx24;
               word limit25;
               var←c6468 = (* (( (ptr) gf←c6852)+8)/* registrations←v2664 */  );
               var←c079 = (* ((( (ptr) gf←c6852)+28)/* var←c5828 */ +(* (( (W3Pt) (( (ptr) var←c6468)+2))+(
                        idx24 = (word) var←c6820.f4/* i←v4372 */ ,
                        limit25 = (* (( (ptr) var←c6468)+1) ),
                        BCK(idx24, limit25)
                        )) ).f2) );
               };
            tc20 =  (word) (var←c079 == eventInstance←v4052.f2);
            }
         else {
            tc20 =  (word) 0;
            };
         if (tc20) {
SOURCE(2922, 231)
            if ((eventInstance←v4052.f2 != 2) || (eventInstance←v4052.f1 == 1)) {
SOURCE(2987, 166)
SOURCE(2987, 166)
               {
                  /* declaration of var←c01 skipped */ 
                  word var←c6500;
                  /* declaration of var←c02 skipped */ 
                  {
                     word idx26;
                     word limit27;
                     var←c6500 = (* (( (ptr) gf←c6852)+8)/* registrations←v2664 */  );
                     (*  (W2Pt) (( (ptr) &var←c6820)+5)/* var←c01 */  ) = (*  (W2Pt) (( (W3Pt) (( (ptr) var←c6500)+2))+(
                           idx26 = (word) var←c6820.f4/* i←v4372 */ ,
                           limit27 = (* (( (ptr) var←c6500)+1) ),
                           BCK(idx26, limit27)
                           )) );
                     };
                  var←c6820.f7/* var←c02 */  = (* (( (ptr) (* (( (ptr) gf←c6852)+40)/* var←c5924 */  ))+15) );
                  {
                     word var←c03;
                     {
                        word var←c080;
                        var←c080 = (word) &var←c6820;
                        var←c03 = (word) XR←Enable(( ((word)  (fPt) NoName←Q732) ), ( ((word)  (fPt) NoName←Q792) ), var←c080);
                        };
                     /* removed trivial cond node */ 
                     };
                  };
               };
            };
         };
      var←c6820.f4/* i←v4372 */  = (var←c6820.f4/* i←v4372 */  + 1);
      if ((var←c6820.f4/* i←v4372 */  < noName←c6404)) {
         goto lab←L100018;
         };
      lab←L100015: ;
      };
SOURCE(2711, 442)
   (void) (XR←MonitorExit((word) (( (bPt) gf←c6852)+16)/* LOCK←v2496 */ ));
   return;
   }

static word NoName←Q732(formal←c076)
   word formal←c076;
   {
SOURCE(2987, 166)
   {
      word pd28;
      pd28 = (* (( (ptr) formal←c076)+7) );
      (void) ( *( (fPt) ((*  (ptr) pd28 ))))((*  (W2Pt) ((( (ptr) formal←c076)+5)) ), pd28);
      };
   return(0);
   }

static void NoName←Q792(formal←c067, formal←c200000, formal←c200001, formal←c200002, formal←c200003)
   word formal←c067;
   word formal←c200000;
   word formal←c200001;
   word formal←c200002;
   word formal←c200003;
   {
   register ptr gf←c077 =  (ptr) &globalframe;
   if ((formal←c200001 == (*  (ptr) (* (( (ptr) (* (( (ptr) gf←c077)+40)/* var←c5924 */  ))+25) ) ))) {
      {
         W2 process←v5428;
         word var←c6532;
         process←v5428 = (*  (W2Pt) formal←c200003 );
SOURCE(3057, 30)
         {
            word idx29;
            word limit30;
            word tmpAddr31;
            var←c6532 = (* (( (ptr) gf←c077)+8)/* registrations←v2664 */  );
            tmpAddr31 = (word) (( (W3Pt) (( (ptr) var←c6532)+2))+(
                  idx29 = (* (( (ptr) formal←c200000)+4) ),
                  limit30 = (* (( (ptr) var←c6532)+1) ),
                  BCK(idx29, limit30)
                  ));
            (*  (ptr) tmpAddr31 ) = 0;
            (* (( (ptr) tmpAddr31) + 1) ) = 0;
            };
SOURCE(3089, 64)
         (*  (ptr) (* (( (ptr) gf←c077)+8)/* registrations←v2664 */  ) ) = ((*  (ptr) (* (( (ptr) gf←c077)+8)/* registrations←v2664 */  ) ) - 1);
SOURCE(3155, 9)
         (*  (ptr) formal←c067 ) = 2;
         (* (( (ptr) formal←c067)+1) ) = 2;
         return;
         };
      };
   (*  (ptr) formal←c067 ) = 0;
   (* (( (ptr) formal←c067)+1) ) = 0;
   return;
   }

static word NoName←Q852(formal←c025)
   word formal←c025;
   {
   word var←c026;
   /* intermediary proc for a FORK, nArgs: 0, nRets: 0 */ 
   var←c026 = (* (( (ptr) formal←c025)+2) );
   formal←c025 = XR←ExtensionFree(formal←c025);
   (void) ( *( (fPt) ((*  (ptr) var←c026 ))))(var←c026);
   return(0);
   }

/* file: AsynchronousEventsImpl, module: AsynchronousEventsImpl, compiled at: February 21, 1992 7:40:52 pm PST */ 
extern void XR←install←AsynchronousEventsImpl() {
   NoName←Q672();
   }
extern void XR←run←AsynchronousEventsImpl() { XR←Start(&globalframe); }