// ==============================================================
//#+ This module generated by Mumps Compiler 9.00 Nov 23 2005
//#+  
//#+ Portions of this code are part of the Mumps Compiler
//#+ 
//#+ Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by Kevin C. O'Kane  
//#+ 
//#+ Kevin C. O'Kane, Ph.D.
//#+ Computer Science Department
//#+ University of Northern Iowa
//#+ Cedar Falls, IA 50614-0507
//#+ Tel 319 273 7322
//#+ okane@cs.uni.edu
//#+ http://www.cs.uni.edu/~okane
//#+ -----------------------------------
//#+ 
//#+ Consult individual modules for copyright details
//#+ The runtime libraries are covered by the following license:
//#+  
//#+ This library is free software; you can redistribute it and/or
//#+ modify it under the terms of the GNU Lesser General Public
//#+ License as published by the Free Software Foundation; either
//#+ version 2.1 of the License, or (at your option) any later version.
//#+ 
//#+ This library is distributed in the hope that it will be useful,
//#+ but WITHOUT ANY WARRANTY; without even the implied warranty of
//#+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//#+ Lesser General Public License for more details.
//#+ 
//#+ You should have received a copy of the GNU Lesser General Public
//#+ License along with this library; if not, write to the Free Software
//#+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//#+ 
//#+ This code is unverified - use at your own risk 
//#+==============================================================

#define _INTERP_ // indicates .cpp file for includes expansions
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <setjmp.h>
#ifndef _MSC_VER
#include <unistd.h>
#else
#include <process.h>
#endif
#include <mumpsc/strmax.h>
#include <mumpsc/libmpscpp.h>
#include <mumpsc/sym.h>
#include <mumpsc/builtin.h>
#define SYM_MAX 100 /* Max Symbol Table Depth */
#define FORPARM 32  /* Size of For loop parameter */
#include <mumpsc/stateVector.h>
int (*__label_lookup)(char *);
char * (*__text_function)(int);
void fcn(MSV *);
void zfcn(unsigned char *, unsigned char *, struct MSV *); /* z functions */
char * sym_(int, unsigned char *, unsigned char *, struct MSV *); /* symbol table */
char * makeLock(char *, char *, char *, char, char *); /* global array lock service */
char * cleanLocks(char *); /* global array lock service */
char * releaseLock(char *, char *, char *); /* global array lock service */
char * eraseLocks(char *); /* global array lock service */
void add(char *a,char *b,char *c); /* math function */
void sub(char *a,char *b,char *c); /* math function */
void mult(char *a,char *b,char *c); /* math function */
void divx(char *a,char *b,char *c); /* math function */
void divi(char *a,char *b,char *c); /* math function */
void _fnumber(unsigned char *,unsigned char *,
       unsigned char *,unsigned char *); /* math function */
#include <mumpsc/global.h>  /* Global array definitions */
  /* Interface to Mglobal(): */
  /* g = command */
  /* key = key sought or stored */
  /* bd = value returned or stored */
  /* svPtr = address of state vector */
#ifndef SUB
#include <mumpsc/fcns.h>  /* System support functions */
#include <mumpsc/sysfunc.h>  /* Many common global variables */
#endif
/*=================================================================================*/
//      zmain
/*=================================================================================*/

int main(int argc, char *argv[]) {

//#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//#+ Intermediate temporary variables used during execution of string expressions
//#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

char _ftmp[STR_MAX]; /* intermediate temp */
/*** Temporary variables */
char for1_incr[FORPARM],for1_lim[FORPARM],for1_init[FORPARM];
int for1F; int for1T; long for1; double for1D;
char for2_incr[FORPARM],for2_lim[FORPARM],for2_init[FORPARM];
int for2F; int for2T; long for2; double for2D;
char for3_incr[FORPARM],for3_lim[FORPARM],for3_init[FORPARM];
int for3F; int for3T; long for3; double for3D;
char for4_incr[FORPARM],for4_lim[FORPARM],for4_init[FORPARM];
int for4F; int for4T; long for4; double for4D;
jmp_buf for0J;
jmp_buf for1J;
jmp_buf for2J;
jmp_buf for3J;
jmp_buf for4J;
jmp_buf for5J;
jmp_buf Efor0J;
int tpx0;
jmp_buf Efor1J;
int tpx1;
jmp_buf Efor2J;
int tpx2;
jmp_buf Efor3J;
int tpx3;
unsigned char tmp0[STR_MAX];
unsigned char tmp1[STR_MAX];
unsigned char tmp2[STR_MAX];
unsigned char tmp3[STR_MAX];
unsigned char tmp4[STR_MAX];
unsigned char tmp5[STR_MAX];
unsigned char tmp6[STR_MAX];
unsigned char tmp7[STR_MAX];
unsigned char tmp8[STR_MAX];
char _dummy[STR_MAX]; /* temporary variable */
unsigned char atmp[STR_MAX]; /* temporary variable */
unsigned char gtmp[STR_MAX]; /* temporary variable */
unsigned char gtmpL[STR_MAX]; /* temporary variable */
unsigned char tmp[STR_MAX]; /* temporary variable */
int _label_lookup(char *); /* resolution of labels */
char * _text_function(int);
static unsigned char _ReturnVal[STR_MAX]; /* function returns */
int _ArgCount=0; /* Nbr of args to extrinsic */
long _i,_jj,_j,_k,_new;
int _SymPush=0,f=0;
int g=0;
jmp_buf _doStack[128]; /* <do> return stack mechanism */
short   _doStackN[128]={0}; /* <do> return stack mechanism */
static int     _doStx=0; /* <do> return stack mechanism */
char _Refs[10][16];
int _Refsx=0;
if (svPtr == NULL) svPtr = AllocSV();
_SymPush=0; // zap pushed tables  
svPtr->in_file[5]=stdin; /* console default */
svPtr->out_file[5]=stdout; /* console default */
__label_lookup=_label_lookup;
__text_function=_text_function;
#ifdef CLIENT
if (argc < 2) {
#ifdef DEFAULT_IP
   printf("Warning: Using default IP\n");
   client_init(DEFAULT_IP);
#else
   printf("Usage: %s <server IP>\n", argv[0]);
   exit(-1);
#endif
} else {
   client_init(argv[1]);
}
#endif

/*=================================================================================*/
svPtr->LineNumber=2; //       open 1:"dead.short,old"
/*=================================================================================*/
	 _i=atoi((char *) "1");
	 strmove((unsigned char *) tmp0,(unsigned char *) "dead.short,old");
	 for(_j=0; tmp0[_j]!=0 && tmp0[_j]!=',';_j++);
	 if (tmp0[_j]!=',') ErrorMessage("File open error",svPtr->LineNumber);
	 tmp0[_j++]=0;
	 strmove((unsigned char *) gtmp,(unsigned char *) tmp0);
	 if (strcmp((const char *) &tmp0[_j],(const char *) "old")==0||strcmp((const char *) &tmp0[_j],(const char *) "OLD")==0) _new=0;
	 else if (strcmp((const char *) &tmp0[_j],(const char *) "new")==0||strcmp((const char *) &tmp0[_j],(const char *) "NEW")==0) _new=1;
	 else if (strcmp((const char *) &tmp0[_j],(const char *) "append")==0||strcmp((const char *) &tmp0[_j],(const char *) "APPEND")==0) _new=2;
	 else ErrorMessage("File open error",svPtr->LineNumber);
	 if (svPtr->out_file[_i]!=NULL||svPtr->in_file[_i]!=NULL) ErrorMessage("File already open",svPtr->LineNumber);
	 if (_new==1) { /* output */
		 svPtr->out_file[_i]=fopen((const char *) gtmp,"w");
		 if(svPtr->out_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
	 else if (_new==2) { /* append */
		 svPtr->out_file[_i]=fopen((const char *) gtmp,"a");
		 if(svPtr->out_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
	 else { /* input */
		 svPtr->in_file[_i]=fopen((const char *) gtmp,"r");
		 if(svPtr->in_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
/*=================================================================================*/
svPtr->LineNumber=3; //       use 1
/*=================================================================================*/
	 svPtr->io=atoi((char *) "1");
/*=================================================================================*/
svPtr->LineNumber=4; //       set D=1
/*=================================================================================*/
	 sym_(0,(unsigned char *)"D",(unsigned char *)"1",svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=5; //       set i=$ztell // return the integer offset in the file
/*=================================================================================*/
	 strcpy((char *) &gtmp[1],(const char *) "$ztell");
	 zfcn(gtmp,tmp1,svPtr);
	 sym_(0,(unsigned char *)"i",(unsigned char *)tmp1,svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=6; //       for  do
/*=================================================================================*/
	 while(1) {  /* Argumentless FOR */
		 tpx0=svPtr->tpx;
		 if (setjmp(Efor0J)==0) 
			 goto Do_Block_Entry0; 
		 svPtr->tpx=tpx0; /* return from argumentless do */
	 } 
	 goto Do_Block_Bypass0; /* by pass indented group */
Do_Block_Entry0: ; do { /* dotted indent entry */
/*=================================================================================*/
svPtr->LineNumber=7; //       . use 1
/*=================================================================================*/
	 svPtr->io=atoi((char *) "1");
/*=================================================================================*/
svPtr->LineNumber=8; //       . read a
/*=================================================================================*/
	 if (svPtr->in_file[svPtr->io]==NULL) ErrorMessage("Read from input file",svPtr->LineNumber);
	 svPtr->tpx=getstr1(svPtr->in_file[svPtr->io],gtmp); // Read string into gtmp
	 if (svPtr->tpx>=0) svPtr->tpx=1; else svPtr->tpx=0; // Set $Test
	 sym_(0,(unsigned char *)"a",(unsigned char *)gtmp,svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=9; //       . if '$test break // end this loop
/*=================================================================================*/
	 if (svPtr->tpx) tmp0[0]='1'; /* $test */
	 else tmp0[0]='0';
	 tmp0[1]='\0';
	 if (numcomp1((unsigned char *) tmp0,0)==0) strmove((unsigned char *) tmp1,(unsigned char *) "1");
	    else strmove((unsigned char *) tmp1,(unsigned char *) "0");
	 svPtr->tpx=0;  /* Default $Test indicator */
	 if (strcmp((const char *) tmp1,(const char *) "0")!=0) {  /* Test expression for True */
	 svPtr->tpx=1;  /* Set $Test indicator True */
	 svPtr->tpx=tpx0; goto Do_Block_Bypass0; // break
	 }
/*=================================================================================*/
svPtr->LineNumber=10; //       . use 5
/*=================================================================================*/
	 svPtr->io=atoi((char *) "5");
/*=================================================================================*/
svPtr->LineNumber=11; //       . do $zwi(a)
/*=================================================================================*/
	 _ArgCount=0;
	 svPtr->Rargsx=0;
	 {
	 strmove((unsigned char *)  &gtmp[1],(unsigned char *) "");
	 strcat((char *) &gtmp[1],"$zwi\xce");
	 if (sym_(SYMGET,(unsigned char *) "a",(unsigned char *) tmp0,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcat((char *) &gtmp[1],(char *) tmp0);
	 strcat((char *) &gtmp[1],"\xcf");
	 zfcn(gtmp,tmp1,svPtr);
	 }
/*=================================================================================*/
svPtr->LineNumber=12; //       . for word=$zwp do
/*=================================================================================*/
For_Group2: 
	 strcpy((char *) &gtmp[1],(const char *) "$zwp");
	 zfcn(gtmp,tmp0,svPtr);
	 sym_( 0, ( unsigned char * ) "word", ( unsigned char * ) tmp0, svPtr); /* set loop variable */
	 if (strcmp( (char *) tmp0, "0")==0 || strlen( (const char *) tmp0)==0 ) goto For2Exit; // exit if match
	 if ( setjmp( for2J ) == 0 ) goto For2;
	 goto For_Group2;
	 goto For2Exit; /* bypass block */
For2: /* FOR loop entry point */
	 do { 
	 svPtr->LineNumber=12;
		 tpx1=svPtr->tpx;
		 if (setjmp(Efor1J)==0) 
			 goto Do_Block_Entry1; 
		 svPtr->tpx=tpx1; /* return from argumentless do */
	 } while (0); longjmp(for2J,99); /* FOR loop 1 close */
For2Exit:;
	 goto Do_Block_Bypass1; /* by pass indented group */
Do_Block_Entry1: ; do { /* dotted indent entry */
/*=================================================================================*/
svPtr->LineNumber=13; //       .. if word'?1A2E.E quit
/*=================================================================================*/
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp0,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 if (pm((const unsigned char *) tmp0,(const unsigned char *) "1A2E.E",svPtr)) strmove((unsigned char *) tmp1,(unsigned char *) "0"); else strmove((unsigned char *) tmp1,(unsigned char *) "1");
	 svPtr->tpx=0;  /* Default $Test indicator */
	 if (strcmp((const char *) tmp1,(const char *) "0")!=0) {  /* Test expression for True */
	 svPtr->tpx=1;  /* Set $Test indicator True */
	 break;
	 } /* if block */
/*=================================================================================*/
svPtr->LineNumber=14; //       .. if $data(^dict(word)) set ^dict(word)=^dict(word)+1
/*=================================================================================*/
	 strmove((unsigned char *) gtmp,(unsigned char *) "^dict\x01");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp0,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcatx((unsigned char *) gtmp,(unsigned char *) tmp0);
	 strmove((unsigned char *) tmp1,(unsigned char *) gtmp);
	 GlobalData(tmp1,tmp2,svPtr);
	 svPtr->tpx=0;  /* Default $Test indicator */
	 if (strcmp((const char *) tmp2,(const char *) "0")!=0) {  /* Test expression for True */
	 svPtr->tpx=1;  /* Set $Test indicator True */
	 strmove((unsigned char *) tmp4,(unsigned char *) "^dict\xce");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp3,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcat((char *) tmp4,(char *) tmp3);
	 strcat((char *) tmp4,(char *) "\xcf");
	 strmove((unsigned char *) gtmp,(unsigned char *) "^dict\x01");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp5,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcatx((unsigned char *) gtmp,(unsigned char *) tmp5);
	 strmove((unsigned char *) tmp6,(unsigned char *) gtmp);
	 if (!Mglobal(RETRIEVE,tmp6,tmp7,svPtr)) VariableNotFound(svPtr->LineNumber);
	 add1((char *) tmp7, 1,(char *) tmp8);
	 f=Mglobal(STORE,tmp4,(unsigned char *)tmp8,svPtr);
	 } 
/*=================================================================================*/
svPtr->LineNumber=15; //       .. else  set ^dict(word)=1
/*=================================================================================*/
	 if (svPtr->tpx==0) {
	 strmove((unsigned char *) tmp1,(unsigned char *) "^dict\xce");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp0,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcat((char *) tmp1,(char *) tmp0);
	 strcat((char *) tmp1,(char *) "\xcf");
	 f=Mglobal(STORE,tmp1,(unsigned char *)"1",svPtr);
	 } 
	 } while(0); // dotted un-indent 1
	 longjmp(Efor1J,99); /* return */
Do_Block_Bypass1: ; 
	 } while(0); // dotted un-indent 0
	 longjmp(Efor0J,99); /* return */
Do_Block_Bypass0: ; 
/*=================================================================================*/
svPtr->LineNumber=17; //       close 1
/*=================================================================================*/
	 _i=atoi((char *) "1");
	 if (svPtr->in_file[_i]==NULL&&svPtr->out_file[_i]==NULL) ErrorMessage("Attempt to close unopened file",svPtr->LineNumber);
	 if (svPtr->in_file[_i]!=NULL) { fclose(svPtr->in_file[_i]); svPtr->in_file[_i]=NULL; }
	 else { fclose(svPtr->out_file[_i]); svPtr->out_file[_i]=NULL; }
/*=================================================================================*/
svPtr->LineNumber=18; //       open 1:"tmp,new"
/*=================================================================================*/
	 _i=atoi((char *) "1");
	 strmove((unsigned char *) tmp0,(unsigned char *) "tmp,new");
	 for(_j=0; tmp0[_j]!=0 && tmp0[_j]!=',';_j++);
	 if (tmp0[_j]!=',') ErrorMessage("File open error",svPtr->LineNumber);
	 tmp0[_j++]=0;
	 strmove((unsigned char *) gtmp,(unsigned char *) tmp0);
	 if (strcmp((const char *) &tmp0[_j],(const char *) "old")==0||strcmp((const char *) &tmp0[_j],(const char *) "OLD")==0) _new=0;
	 else if (strcmp((const char *) &tmp0[_j],(const char *) "new")==0||strcmp((const char *) &tmp0[_j],(const char *) "NEW")==0) _new=1;
	 else if (strcmp((const char *) &tmp0[_j],(const char *) "append")==0||strcmp((const char *) &tmp0[_j],(const char *) "APPEND")==0) _new=2;
	 else ErrorMessage("File open error",svPtr->LineNumber);
	 if (svPtr->out_file[_i]!=NULL||svPtr->in_file[_i]!=NULL) ErrorMessage("File already open",svPtr->LineNumber);
	 if (_new==1) { /* output */
		 svPtr->out_file[_i]=fopen((const char *) gtmp,"w");
		 if(svPtr->out_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
	 else if (_new==2) { /* append */
		 svPtr->out_file[_i]=fopen((const char *) gtmp,"a");
		 if(svPtr->out_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
	 else { /* input */
		 svPtr->in_file[_i]=fopen((const char *) gtmp,"r");
		 if(svPtr->in_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
/*=================================================================================*/
svPtr->LineNumber=19; //       use 1
/*=================================================================================*/
	 svPtr->io=atoi((char *) "1");
/*=================================================================================*/
svPtr->LineNumber=20; //       for word="":$order(^dict(word)):"" write ^dict(word)," ",word,!
/*=================================================================================*/
	 strmove((unsigned char *) for4_init,(unsigned char *) "");
	 sym_(0,(unsigned char *) "word",(unsigned char *) for4_init,svPtr); /* init loop variable */
For_Group4: 
	 strmove((unsigned char *) gtmp,(unsigned char *) "^dict\x01");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp0,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcatx((unsigned char *) gtmp,(unsigned char *) tmp0);
	 strmove((unsigned char *) tmp1,(unsigned char *) gtmp);
	 GlobalOrder((unsigned char *) tmp1,(unsigned char *) tmp2,(unsigned char *) NULL,svPtr);
	 strmove( (unsigned char *) for4_incr, (unsigned char *) tmp2);
	 strmove((unsigned char *) for4_lim,(unsigned char *) "");
	 sym_( 0, ( unsigned char * ) "word", ( unsigned char * ) for4_incr, svPtr); /* set loop variable */
	 if (strcmp( for4_incr, for4_lim)==0) goto For4Exit; // exit if match
	 if ( setjmp( for4J ) == 0 ) goto For4;
	 goto For_Group4;
	 goto For4Exit; /* bypass block */
For4: /* FOR loop entry point */
	 do { 
	 svPtr->LineNumber=20;
	 if (svPtr->out_file[svPtr->io]==NULL) ErrorMessage("Write to input file",svPtr->LineNumber);
	 strmove((unsigned char *) gtmp,(unsigned char *) "^dict\x01");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp3,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 strcatx((unsigned char *) gtmp,(unsigned char *) tmp3);
	 strmove((unsigned char *) tmp4,(unsigned char *) gtmp);
	 if (!Mglobal(RETRIEVE,tmp4,tmp5,svPtr)) VariableNotFound(svPtr->LineNumber);
	 svPtr->hor[svPtr->io]+=fprintf(svPtr->out_file[svPtr->io],"%s",tmp5);
	 svPtr->hor[svPtr->io]+=fprintf(svPtr->out_file[svPtr->io],"%s"," ");
	 if (sym_(SYMGET,(unsigned char *) "word",(unsigned char *) tmp6,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 svPtr->hor[svPtr->io]+=fprintf(svPtr->out_file[svPtr->io],"%s",tmp6);
	 fprintf(svPtr->out_file[svPtr->io],"\n"); svPtr->hor[svPtr->io]=0; svPtr->ver[svPtr->io]++;
	 } while (0); longjmp(for4J,99); /* FOR loop 1 close */
For4Exit:;
/*=================================================================================*/
svPtr->LineNumber=21; //       close 1
/*=================================================================================*/
	 _i=atoi((char *) "1");
	 if (svPtr->in_file[_i]==NULL&&svPtr->out_file[_i]==NULL) ErrorMessage("Attempt to close unopened file",svPtr->LineNumber);
	 if (svPtr->in_file[_i]!=NULL) { fclose(svPtr->in_file[_i]); svPtr->in_file[_i]=NULL; }
	 else { fclose(svPtr->out_file[_i]); svPtr->out_file[_i]=NULL; }
/*=================================================================================*/
svPtr->LineNumber=22; //       do $zs("sort -r -n < tmp > tmp.sorted")
/*=================================================================================*/
	 _ArgCount=0;
	 svPtr->Rargsx=0;
	 {
	 strmove((unsigned char *)  &gtmp[1],(unsigned char *) "");
	 strcat((char *) &gtmp[1],"$zs\xce");
	 strcat((char *) &gtmp[1],(char *) "sort -r -n < tmp > tmp.sorted");
	 strcat((char *) &gtmp[1],"\xcf");
	 zfcn(gtmp,tmp0,svPtr);
	 }
/*=================================================================================*/
svPtr->LineNumber=23; //       open 1:"tmp.sorted,old"
/*=================================================================================*/
	 _i=atoi((char *) "1");
	 strmove((unsigned char *) tmp0,(unsigned char *) "tmp.sorted,old");
	 for(_j=0; tmp0[_j]!=0 && tmp0[_j]!=',';_j++);
	 if (tmp0[_j]!=',') ErrorMessage("File open error",svPtr->LineNumber);
	 tmp0[_j++]=0;
	 strmove((unsigned char *) gtmp,(unsigned char *) tmp0);
	 if (strcmp((const char *) &tmp0[_j],(const char *) "old")==0||strcmp((const char *) &tmp0[_j],(const char *) "OLD")==0) _new=0;
	 else if (strcmp((const char *) &tmp0[_j],(const char *) "new")==0||strcmp((const char *) &tmp0[_j],(const char *) "NEW")==0) _new=1;
	 else if (strcmp((const char *) &tmp0[_j],(const char *) "append")==0||strcmp((const char *) &tmp0[_j],(const char *) "APPEND")==0) _new=2;
	 else ErrorMessage("File open error",svPtr->LineNumber);
	 if (svPtr->out_file[_i]!=NULL||svPtr->in_file[_i]!=NULL) ErrorMessage("File already open",svPtr->LineNumber);
	 if (_new==1) { /* output */
		 svPtr->out_file[_i]=fopen((const char *) gtmp,"w");
		 if(svPtr->out_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
	 else if (_new==2) { /* append */
		 svPtr->out_file[_i]=fopen((const char *) gtmp,"a");
		 if(svPtr->out_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
	 else { /* input */
		 svPtr->in_file[_i]=fopen((const char *) gtmp,"r");
		 if(svPtr->in_file[_i]==NULL) svPtr->tpx=0;
		 else svPtr->tpx=1;
	 }
/*=================================================================================*/
svPtr->LineNumber=24; //       set i=1
/*=================================================================================*/
	 sym_(0,(unsigned char *)"i",(unsigned char *)"1",svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=25; //       for  do
/*=================================================================================*/
	 while(1) {  /* Argumentless FOR */
		 tpx2=svPtr->tpx;
		 if (setjmp(Efor2J)==0) 
			 goto Do_Block_Entry2; 
		 svPtr->tpx=tpx2; /* return from argumentless do */
	 } 
	 goto Do_Block_Bypass2; /* by pass indented group */
Do_Block_Entry2: ; do { /* dotted indent entry */
/*=================================================================================*/
svPtr->LineNumber=26; //       . use 1
/*=================================================================================*/
	 svPtr->io=atoi((char *) "1");
/*=================================================================================*/
svPtr->LineNumber=27; //       . read a
/*=================================================================================*/
	 if (svPtr->in_file[svPtr->io]==NULL) ErrorMessage("Read from input file",svPtr->LineNumber);
	 svPtr->tpx=getstr1(svPtr->in_file[svPtr->io],gtmp); // Read string into gtmp
	 if (svPtr->tpx>=0) svPtr->tpx=1; else svPtr->tpx=0; // Set $Test
	 sym_(0,(unsigned char *)"a",(unsigned char *)gtmp,svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=28; //       . if '$test break
/*=================================================================================*/
	 if (svPtr->tpx) tmp0[0]='1'; /* $test */
	 else tmp0[0]='0';
	 tmp0[1]='\0';
	 if (numcomp1((unsigned char *) tmp0,0)==0) strmove((unsigned char *) tmp1,(unsigned char *) "1");
	    else strmove((unsigned char *) tmp1,(unsigned char *) "0");
	 svPtr->tpx=0;  /* Default $Test indicator */
	 if (strcmp((const char *) tmp1,(const char *) "0")!=0) {  /* Test expression for True */
	 svPtr->tpx=1;  /* Set $Test indicator True */
	 svPtr->tpx=tpx2; goto Do_Block_Bypass2; // break
	 }
/*=================================================================================*/
svPtr->LineNumber=29; //       . set f=$piece(a," ",1)
/*=================================================================================*/
	 if (sym_(SYMGET,(unsigned char *) "a",(unsigned char *) tmp1,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 _piece((unsigned char *) tmp2,(unsigned char *) tmp1,(unsigned char *) " ",(unsigned char *) "1",(unsigned char *) "-1",0,(unsigned char *) "",svPtr);
	 sym_(0,(unsigned char *)"f",(unsigned char *)tmp2,svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=30; //       . set w=$piece(a," ",2)
/*=================================================================================*/
	 if (sym_(SYMGET,(unsigned char *) "a",(unsigned char *) tmp1,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 _piece((unsigned char *) tmp2,(unsigned char *) tmp1,(unsigned char *) " ",(unsigned char *) "2",(unsigned char *) "-1",0,(unsigned char *) "",svPtr);
	 sym_(0,(unsigned char *)"w",(unsigned char *)tmp2,svPtr); // Store result
/*=================================================================================*/
svPtr->LineNumber=31; //       . use 5
/*=================================================================================*/
	 svPtr->io=atoi((char *) "5");
/*=================================================================================*/
svPtr->LineNumber=32; //       . write f*i," ",w,!
/*=================================================================================*/
	 if (svPtr->out_file[svPtr->io]==NULL) ErrorMessage("Write to input file",svPtr->LineNumber);
	 if (sym_(SYMGET,(unsigned char *) "f",(unsigned char *) tmp0,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 if (sym_(SYMGET,(unsigned char *) "i",(unsigned char *) tmp1,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 mult((char *) tmp0,(char *) tmp1,(char *) tmp2);
	 svPtr->hor[svPtr->io]+=fprintf(svPtr->out_file[svPtr->io],"%s",tmp2);
	 svPtr->hor[svPtr->io]+=fprintf(svPtr->out_file[svPtr->io],"%s"," ");
	 if (sym_(SYMGET,(unsigned char *) "w",(unsigned char *) tmp3,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 svPtr->hor[svPtr->io]+=fprintf(svPtr->out_file[svPtr->io],"%s",tmp3);
	 fprintf(svPtr->out_file[svPtr->io],"\n"); svPtr->hor[svPtr->io]=0; svPtr->ver[svPtr->io]++;
/*=================================================================================*/
svPtr->LineNumber=33; //       . set i=i+1
/*=================================================================================*/
	 if (sym_(SYMGET,(unsigned char *) "i",(unsigned char *) tmp1,svPtr)==NULL) VariableNotFound(svPtr->LineNumber);
	 add1((char *) tmp1, 1,(char *) tmp2);
	 sym_(0,(unsigned char *)"i",(unsigned char *)tmp2,svPtr); // Store result
	 } while(0); // dotted un-indent 0
	 longjmp(Efor2J,99); /* return */
Do_Block_Bypass2: ; 
/*=================================================================================*/
svPtr->LineNumber=34; //       use 5
/*=================================================================================*/
	 svPtr->io=atoi((char *) "5");
/*=================================================================================*/
svPtr->LineNumber=35; //       close 1
/*=================================================================================*/
	 _i=atoi((char *) "1");
	 if (svPtr->in_file[_i]==NULL&&svPtr->out_file[_i]==NULL) ErrorMessage("Attempt to close unopened file",svPtr->LineNumber);
	 if (svPtr->in_file[_i]!=NULL) { fclose(svPtr->in_file[_i]); svPtr->in_file[_i]=NULL; }
	 else { fclose(svPtr->out_file[_i]); svPtr->out_file[_i]=NULL; }

//=================================================================================
_epilogue: tmp0[0]=0; tmp1[0]=0;  /*  Function Epilogue */
#ifndef _MSC_VER
	 Mltoa(getpid(),atmp);
	 if (svPtr->LockDone) cleanLocks((char *) atmp);
#endif
	 Mglobal(GCLOSE,tmp0,tmp1,svPtr);  /* Close Globals */
	 return EXIT_SUCCESS; }  /* Terminate */
//=================================================================================



int _label_lookup(char *label) { return -1; }
char * _text_function(int disp) { return NULL; }

