#include <perms.h>

                                                                //      1  %begin
#line 1 "regression-bugs-tmp/erccprint.imp"
int main(int argc, char **argv) {
  _imp_initialise(argc, argv);
                                                                //      2  
                                                                //      3  %ROUTINESPEC ERCC PRINTFL (%LONGREAL X, %INTEGER N)
#line 3 "regression-bugs-tmp/erccprint.imp"
auto void ERCCPRINTFL( double X, int N );
                                                                //      4  
                                                                //      5  %ROUTINE ERCC PRINT (%LONGREAL X, %INTEGER N,M)
#line 5 "regression-bugs-tmp/erccprint.imp"
void ERCCPRINT( double X, int N, int M )
#line 5 "regression-bugs-tmp/erccprint.imp"
{
                                                                //      6  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
                                                                //      7  !*       PRINTS A REAL NUMBER (X) ALLOWING N PLACES BEFORE THE DECIMAL *
                                                                //      8  !*       POINT AND M PLACES AFTER.IT REQUIRES (M+N+2) PRINT PLACES     *
                                                                //      9  !*       UNLESS (M=0) WHEN  (N+1) PLACES ARE REQUIRED.                 *
                                                                //     10  !*                                                                     *
                                                                //     11  !*       A LITTLE CARE IS NEEDED TO AVOID UNNECESSARY LOSS OF ACCURACY *
                                                                //     12  !*       AND TO AVOID OVERFLOW WHEN DEALING WITH VERY LARGE NUMBERS    *
                                                                //     13  %CONSTLONGREAL DZ=0
#line 13 "regression-bugs-tmp/erccprint.imp"
const double DZ = 0;
                                                                //     14  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
                                                                //     15  %LONGREAL Y,Z,ROUND,FACTOR
#line 15 "regression-bugs-tmp/erccprint.imp"
double Y;
#line 15 "regression-bugs-tmp/erccprint.imp"
double Z;
#line 15 "regression-bugs-tmp/erccprint.imp"
double ROUND;
#line 15 "regression-bugs-tmp/erccprint.imp"
double FACTOR;
                                                                //     16  %INTEGER I,J,L,MORIG
#line 16 "regression-bugs-tmp/erccprint.imp"
int I;
#line 16 "regression-bugs-tmp/erccprint.imp"
int J;
#line 16 "regression-bugs-tmp/erccprint.imp"
int L;
#line 16 "regression-bugs-tmp/erccprint.imp"
int MORIG;
                                                                //     17  %BYTEINTEGER SIGN
#line 17 "regression-bugs-tmp/erccprint.imp"
unsigned char SIGN;
                                                                //     18        M=M&63;                           ! DEAL WITH STUPID PARAMS
#line 18 "regression-bugs-tmp/erccprint.imp"
M = ((M) & (63));
                                                                //     19        MORIG=M
#line 19 "regression-bugs-tmp/erccprint.imp"
MORIG = M;
                                                                //     20        %IF N<0 %THEN N=1; N=N&31;        ! DEAL WITH STUPID PARAMS
#line 20 "regression-bugs-tmp/erccprint.imp"
if (((N) >= (0))) goto L_0002;
#line 20 "regression-bugs-tmp/erccprint.imp"
N = 1;
#line 20 "regression-bugs-tmp/erccprint.imp"
L_0002:;
#line 20 "regression-bugs-tmp/erccprint.imp"
N = ((N) & (31));
                                                                //     21        X=X+DZ;                           ! NORMALISE
#line 21 "regression-bugs-tmp/erccprint.imp"
X = (((double)(X)) + (DZ));
                                                                //     22        SIGN=' ';                         ! '+' IMPLIED
#line 22 "regression-bugs-tmp/erccprint.imp"
SIGN = 32;
                                                                //     23        %IF X<0 %THEN SIGN='-'
#line 23 "regression-bugs-tmp/erccprint.imp"
if (((X) >= (0))) goto L_0003;
#line 23 "regression-bugs-tmp/erccprint.imp"
SIGN = 45;
#line 23 "regression-bugs-tmp/erccprint.imp"
L_0003:;
                                                                //     24        Y=MOD(X);                         ! ALL WORK DONE WITH Y
#line 24 "regression-bugs-tmp/erccprint.imp"
Y = _imp_MOD(X);
                                                                //     25        ROUND=0.5/10^M;                  ! ROUNDING FACTOR
#line 25 "regression-bugs-tmp/erccprint.imp"
ROUND = (double)((double)((double)(0.5)) / (double)((_imp_REXP(10, M))));
/*promote*/                                                                //     26        %IF Y>1.0*10^16 %OR N=0 %THENSTART;    ! MEANINGLESS FIGURES GENERATED
#line 26 "regression-bugs-tmp/erccprint.imp"
if (((Y) > (((1.0) * ((double)(_imp_REXP(10, 16))))))) goto L_0004;
#line 26 "regression-bugs-tmp/erccprint.imp"
if (((N) != (0))) goto L_0005;
#line 26 "regression-bugs-tmp/erccprint.imp"
L_0004:;
                                                                //     27           %IF N>M %THEN M=N;             ! FOR FIXED POINT PRINTING
#line 27 "regression-bugs-tmp/erccprint.imp"
if (((N) <= (M))) goto L_0006;
#line 27 "regression-bugs-tmp/erccprint.imp"
M = N;
#line 27 "regression-bugs-tmp/erccprint.imp"
L_0006:;
                                                                //     28           ERCC PRINTFL(X,M);             ! OF ENORMOUS NUMBERS
#line 28 "regression-bugs-tmp/erccprint.imp"
ERCCPRINTFL(X, M);
                                                                //     29           %RETURN;                       ! SO PRINT IN FLOATING FORM
#line 29 "regression-bugs-tmp/erccprint.imp"
/* Remove %on %event handler here if present for this block */
return;
                                                                //     30        %FINISH
#line 30 "regression-bugs-tmp/erccprint.imp"
L_0005:;
                                                                //     31        I=0; Z=1; Y=Y+ROUND
#line 31 "regression-bugs-tmp/erccprint.imp"
I = 0;
#line 31 "regression-bugs-tmp/erccprint.imp"
Z = 1;
#line 31 "regression-bugs-tmp/erccprint.imp"
Y = (((double)(Y)) + (ROUND));
                                                                //     32        {%UNTIL Z>Y} %CYCLE;                ! COUNT LEADING PLACES
#line 32 "regression-bugs-tmp/erccprint.imp"
L_0007:;
                                                                //     33           I=I+1; Z=10*Z;                 ! NO DANGER OF OVERFLOW HERE
#line 33 "regression-bugs-tmp/erccprint.imp"
I = (((int)(I)) + (1));
/*promote*/#line 33 "regression-bugs-tmp/erccprint.imp"
Z = (((double)(10)) * (Z));
                                                                //     34        %REPEAT %UNTIL Z>Y
#line 34 "regression-bugs-tmp/erccprint.imp"
if (((Z) > (Y))) goto L_0008;
#line 34 "regression-bugs-tmp/erccprint.imp"
goto L_0007;
#line 34 "regression-bugs-tmp/erccprint.imp"
L_0008:;
                                                                //     35        PRINTSYMBOL(SIGN)
#line 35 "regression-bugs-tmp/erccprint.imp"
_imp_PRINTSYMBOL(SIGN);
                                                                //     36        J=I-1; Z=10^J
#line 36 "regression-bugs-tmp/erccprint.imp"
J = (((int)(I)) - (1));
#line 36 "regression-bugs-tmp/erccprint.imp"
Z = _imp_REXP(10, J);
                                                                //     37        FACTOR=1/10
#line 37 "regression-bugs-tmp/erccprint.imp"
FACTOR = (double)((double)((float)(1)) / (double)((float)(10)));
                                                                //     38        %CYCLE
#line 38 "regression-bugs-tmp/erccprint.imp"
L_000a:;
                                                                //     39           {%UNTIL J<0} %CYCLE
#line 39 "regression-bugs-tmp/erccprint.imp"
L_000d:;
                                                                //     40              L=INT PT(Y/Z);              ! OBTAIN NEXT DIGIT
#line 40 "regression-bugs-tmp/erccprint.imp"
L = _imp_INTPT(((double)((double)((double)(Y)) / (double)((double)(Z)))));
/*promote*//*promote*/                                                                //     41              Y=Y-L*Z; Z=Z*FACTOR;        ! AND REDUCE TOTAL
#line 41 "regression-bugs-tmp/erccprint.imp"
Y = ((Y) - ((double)((((double)(L)) * (Z)))));
#line 41 "regression-bugs-tmp/erccprint.imp"
Z = (((double)(Z)) * (FACTOR));
                                                                //     42              PRINTSYMBOL(L+'0')
#line 42 "regression-bugs-tmp/erccprint.imp"
_imp_PRINTSYMBOL((((int)(L)) + (48)));
                                                                //     43              J=J-1
#line 43 "regression-bugs-tmp/erccprint.imp"
J = (((int)(J)) - (1));
                                                                //     44           %REPEAT %UNTIL J<0
#line 44 "regression-bugs-tmp/erccprint.imp"
if (((J) < (0))) goto L_000e;
#line 44 "regression-bugs-tmp/erccprint.imp"
goto L_000d;
#line 44 "regression-bugs-tmp/erccprint.imp"
L_000e:;
                                                                //     45           %IF M=0 %THEN %EXIT;           ! NO DECIMAL PART TO BE O/P
#line 45 "regression-bugs-tmp/erccprint.imp"
if (((M) != (0))) goto L_0010;
#line 45 "regression-bugs-tmp/erccprint.imp"
goto L_000b;
#line 45 "regression-bugs-tmp/erccprint.imp"
L_0010:;
                                                                //     46           PRINTSTRING(".")
#line 46 "regression-bugs-tmp/erccprint.imp"
_imp_PRINTSTRING(_imp_str_literal("."));
                                                                //     47           J=M-1; Z=10^(J-1); M=0
#line 47 "regression-bugs-tmp/erccprint.imp"
J = (((int)(M)) - (1));
#line 47 "regression-bugs-tmp/erccprint.imp"
Z = _imp_REXP(10, (((int)(J)) - (1)));
#line 47 "regression-bugs-tmp/erccprint.imp"
M = 0;
/*promote*//*promote*/                                                                //     48           Y=10*Y*Z
#line 48 "regression-bugs-tmp/erccprint.imp"
Y = (((double)((((double)(10)) * (Y)))) * (Z));
                                                                //     49        %REPEAT
#line 49 "regression-bugs-tmp/erccprint.imp"
goto L_000a;
#line 49 "regression-bugs-tmp/erccprint.imp"
L_000b:;
                                                                //     50  !!      %if MORIG>0 %start          { Chop any redundant trailing 0s}
                                                                //     51  !!         opline_length=opline_length-1 %while %c
                                                                //     52  !!           opline_l(opline_length-1)='0' %and opline_l(opline_length-2)#'.'
                                                                //     53  !!      %finish
                                                                //     54  %END;                                   ! OF ROUTINE PRINT
#line 54 "regression-bugs-tmp/erccprint.imp"
/* Remove %on %event handler here if present for this block */
return;
} // End of block ERCCPRINT at level 2
                                                                //     55  
                                                                //     56  %ROUTINE ERCC PRINTFL (%LONGREAL X, %INTEGER N)
#line 56 "regression-bugs-tmp/erccprint.imp"
void ERCCPRINTFL( double X, int N )
#line 56 "regression-bugs-tmp/erccprint.imp"
{
                                                                //     57  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
                                                                //     58  !*       PRINTS IN FLOATING POINT FORMAT WITH N PLACES AFTER THE       *
                                                                //     59  !*       DECIMAL POINT. ALWAYS TAKES N+7 PRINTING POSITIONS.           *
                                                                //     60  !*       CARE REQUIRED TO AVOID OVERFLOW WITH LARGE X                  *
                                                                //     61  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
                                                                //     62  %LONGREAL SIGN,ROUND,FACTOR,LB,UB
#line 62 "regression-bugs-tmp/erccprint.imp"
double SIGN;
#line 62 "regression-bugs-tmp/erccprint.imp"
double ROUND;
#line 62 "regression-bugs-tmp/erccprint.imp"
double FACTOR;
#line 62 "regression-bugs-tmp/erccprint.imp"
double LB;
#line 62 "regression-bugs-tmp/erccprint.imp"
double UB;
                                                                //     63  %CONSTLONGREAL DZ=0
#line 63 "regression-bugs-tmp/erccprint.imp"
const double DZ = 0;
                                                                //     64  %INTEGER COUNT,INC
#line 64 "regression-bugs-tmp/erccprint.imp"
int COUNT;
#line 64 "regression-bugs-tmp/erccprint.imp"
int INC;
                                                                //     65        inc=integer(addr(x))
#line 65 "regression-bugs-tmp/erccprint.imp"
INC = *_imp_INTEGER(_imp_ADDR(&X));
                                                                //     66        %if inc>>20&x'7ff'=x'7ff' %start
#line 66 "regression-bugs-tmp/erccprint.imp"
if ((((((int)((((unsigned int)(INC)) >> (20)))) & (2047))) != (2047))) goto L_0011;
                                                                //     67  !!         outstring("NAN {");
                                                                //     68  !!         outhex(inc);
                                                                //     69  !!         outhex(integer(addr(x)+4))
                                                                //     70  !!         outsym('}'); %return
                                                                //     71        %finish
#line 71 "regression-bugs-tmp/erccprint.imp"
L_0011:;
                                                                //     72        ROUND=0.5/10^N;                  ! TO ROUND SCALED NO
#line 72 "regression-bugs-tmp/erccprint.imp"
ROUND = (double)((double)((double)(0.5)) / (double)((_imp_REXP(10, N))));
/*promote*/                                                                //     73        LB=1-ROUND; UB=10-ROUND
#line 73 "regression-bugs-tmp/erccprint.imp"
LB = (((double)(1)) - (ROUND));
/*promote*/#line 73 "regression-bugs-tmp/erccprint.imp"
UB = (((double)(10)) - (ROUND));
                                                                //     74        SIGN=1
#line 74 "regression-bugs-tmp/erccprint.imp"
SIGN = 1;
                                                                //     75        X=X+DZ;                           ! NORMALISE
#line 75 "regression-bugs-tmp/erccprint.imp"
X = (((double)(X)) + (DZ));
                                                                //     76        %IF X=0 %THEN COUNT=0 %ELSESTART
#line 76 "regression-bugs-tmp/erccprint.imp"
if (((X) != (0))) goto L_0012;
#line 76 "regression-bugs-tmp/erccprint.imp"
COUNT = 0;
#line 76 "regression-bugs-tmp/erccprint.imp"
goto L_0013;
#line 76 "regression-bugs-tmp/erccprint.imp"
L_0012:;
                                                                //     77           %IF X<0 %THEN X=-X %AND SIGN=-SIGN
#line 77 "regression-bugs-tmp/erccprint.imp"
if (((X) >= (0))) goto L_0014;
#line 77 "regression-bugs-tmp/erccprint.imp"
X = (-(X));
#line 77 "regression-bugs-tmp/erccprint.imp"
SIGN = (-(SIGN));
#line 77 "regression-bugs-tmp/erccprint.imp"
L_0014:;
                                                                //     78           INC=1; COUNT=0
#line 78 "regression-bugs-tmp/erccprint.imp"
INC = 1;
#line 78 "regression-bugs-tmp/erccprint.imp"
COUNT = 0;
                                                                //     79           FACTOR=1/10
#line 79 "regression-bugs-tmp/erccprint.imp"
FACTOR = (double)((double)((float)(1)) / (double)((float)(10)));
                                                                //     80           %IF X<=1 %THEN FACTOR=10 %AND INC=-1
#line 80 "regression-bugs-tmp/erccprint.imp"
if (((X) > (1))) goto L_0015;
#line 80 "regression-bugs-tmp/erccprint.imp"
FACTOR = 10;
#line 80 "regression-bugs-tmp/erccprint.imp"
INC = (-1);
#line 80 "regression-bugs-tmp/erccprint.imp"
L_0015:;
                                                                //     81                                          ! FORCE INTO RANGE 1->10
                                                                //     82           %WHILE X<LB %OR X>=UB %CYCLE
#line 82 "regression-bugs-tmp/erccprint.imp"
L_0016:;
#line 82 "regression-bugs-tmp/erccprint.imp"
if (((X) < (LB))) goto L_0018;
#line 82 "regression-bugs-tmp/erccprint.imp"
if (((X) < (UB))) goto L_0017;
#line 82 "regression-bugs-tmp/erccprint.imp"
L_0018:;
                                                                //     83              X=X*FACTOR; COUNT=COUNT+INC
#line 83 "regression-bugs-tmp/erccprint.imp"
X = (((double)(X)) * (FACTOR));
#line 83 "regression-bugs-tmp/erccprint.imp"
COUNT = (((int)(COUNT)) + (INC));
                                                                //     84           %REPEAT
#line 84 "regression-bugs-tmp/erccprint.imp"
goto L_0016;
#line 84 "regression-bugs-tmp/erccprint.imp"
L_0017:;
                                                                //     85        %FINISH
#line 85 "regression-bugs-tmp/erccprint.imp"
L_0013:;
                                                                //     86        ERCC PRINT(SIGN*X,1,N)
#line 86 "regression-bugs-tmp/erccprint.imp"
ERCCPRINT((((double)(SIGN)) * (X)), 1, N);
                                                                //     87        %if count#0 %start
#line 87 "regression-bugs-tmp/erccprint.imp"
if (((COUNT) == (0))) goto L_0019;
                                                                //     88           PRINTSTRING("E")
#line 88 "regression-bugs-tmp/erccprint.imp"
_imp_PRINTSTRING(_imp_str_literal("E"));
                                                                //     89           WRITE(COUNT,0)
#line 89 "regression-bugs-tmp/erccprint.imp"
_imp_WRITE(COUNT, 0);
                                                                //     90        %finish
#line 90 "regression-bugs-tmp/erccprint.imp"
L_0019:;
                                                                //     91  %END;                                   ! OF ROUTINE PRINTFL
#line 91 "regression-bugs-tmp/erccprint.imp"
/* Remove %on %event handler here if present for this block */
return;
} // End of block ERCCPRINTFL at level 2
                                                                //     92  
                                                                //     93  %endofprogram
#line 93 "regression-bugs-tmp/erccprint.imp"
/* Remove %on %event handler here if present for this block */
return 0;
} // End of block _imp_main at level 1
#line 93 "regression-bugs-tmp/erccprint.imp"
// End of file
