#include <perms.h>

                                                                //      1  %begin
#line 1 "regression-bugs-tmp/ercc-write.imp"
int main(int argc, char **argv) {
  _imp_initialise(argc, argv);
                                                                //      2  
                                                                //      3  %routine emaswrite(%integer value, places)
#line 3 "regression-bugs-tmp/ercc-write.imp"
void EMASWRITE( int VALUE, int PLACES )
#line 3 "regression-bugs-tmp/ercc-write.imp"
{
                                                                //      4     !***********************************************************************
                                                                //      5     !*    SIMPLE MINDED ALL IMP VERSION NOT USING STRINGS                  *
                                                                //      6     !***********************************************************************
                                                                //      7     %string (15) %fn swrite %alias "S#SWRITE"(%integer value, places)
#line 7 "regression-bugs-tmp/ercc-write.imp"
_imp_string /*%string(15)*/ SWRITE( int VALUE, int PLACES )
#line 7 "regression-bugs-tmp/ercc-write.imp"
{
                                                                //      8        !***********************************************************************
                                                                //      9        !*    SIMPLE MINDED ALL IMP VERSION                                    *
                                                                //     10        !***********************************************************************
                                                                //     11        %string (1) sign
#line 11 "regression-bugs-tmp/ercc-write.imp"
_imp_string /*%string(1)*/ SIGN;
                                                                //     12        %string (15) res
#line 12 "regression-bugs-tmp/ercc-write.imp"
_imp_string /*%string(15)*/ RES;
                                                                //     13        %integer work, ptr
#line 13 "regression-bugs-tmp/ercc-write.imp"
int WORK;
#line 13 "regression-bugs-tmp/ercc-write.imp"
int PTR;
                                                                //     14        %string (1) %array ch(0 : 15)
#line 14 "regression-bugs-tmp/ercc-write.imp"
_imp_string /*%string(1)*/ CH[16];
                                                                //     15        res = ""
#line 15 "regression-bugs-tmp/ercc-write.imp"
RES = _imp_str_literal("");
                                                                //     16        sign = " "
#line 16 "regression-bugs-tmp/ercc-write.imp"
SIGN = _imp_str_literal(" ");
                                                                //     17        %if value = X'80000000' %then %start
#line 17 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) != ((-2147483648)))) goto L_0002;
                                                                //     18           res = "-2147483548"
#line 18 "regression-bugs-tmp/ercc-write.imp"
RES = _imp_str_literal("-2147483548");
                                                                //     19           res = " " . res %for ptr = 1, 1, places - 10
#line 19 "regression-bugs-tmp/ercc-write.imp"
{static int _initial, _increment, _final, _control;
_initial = 1; _increment = 1; _final = (((int)(PLACES)) - (10)); PTR = _control = _initial;
if (((_final-_initial) % _increment) != 0) _imp_signal(5,1,0,"Illegal cycle PTR = 1, 1, (((int)(PLACES)) - (10))");
PTR -= _increment; _control -= _increment;
L_0003:;
if (PTR == _final) goto L_0004;
PTR += _increment; _control += _increment;
if (PTR != _control) _imp_signal(4,2,0,"Corrupt control variable PTR"); /* FOR loop control variable corrupted */
}
#line 19 "regression-bugs-tmp/ercc-write.imp"
RES = _imp_join((_imp_string)_imp_str_literal(" "),(_imp_string)RES);
#line 19 "regression-bugs-tmp/ercc-write.imp"
goto L_0003;
#line 19 "regression-bugs-tmp/ercc-write.imp"
L_0004:;
                                                                //     20           %result = res
#line 20 "regression-bugs-tmp/ercc-write.imp"
/* Remove %on %event handler here if present for this block */
return RES;
                                                                //     21        %finish
#line 21 "regression-bugs-tmp/ercc-write.imp"
L_0002:;
                                                                //     22        %if value = X'80000000' %then %result = "-2147483648"
#line 22 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) != ((-2147483648)))) goto L_0006;
#line 22 "regression-bugs-tmp/ercc-write.imp"
/* Remove %on %event handler here if present for this block */
return _imp_str_literal("-2147483648");
#line 22 "regression-bugs-tmp/ercc-write.imp"
L_0006:;
                                                                //     23        %if value < 0 %then sign = "-" %and value = -value
#line 23 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) >= (0))) goto L_0007;
#line 23 "regression-bugs-tmp/ercc-write.imp"
SIGN = _imp_str_literal("-");
#line 23 "regression-bugs-tmp/ercc-write.imp"
VALUE = (-(VALUE));
#line 23 "regression-bugs-tmp/ercc-write.imp"
L_0007:;
                                                                //     24        ptr = 0
#line 24 "regression-bugs-tmp/ercc-write.imp"
PTR = 0;
                                                                //     25        %cycle 
#line 25 "regression-bugs-tmp/ercc-write.imp"
L_0008:;
                                                                //     26           work = value // 10
#line 26 "regression-bugs-tmp/ercc-write.imp"
WORK = (long)((long)((int)(VALUE)) / (long)((int)(10)));
                                                                //     27           ch(ptr) = tostring(value - 10 * work + '0')
#line 27 "regression-bugs-tmp/ercc-write.imp"
CH[PTR] = _imp_TOSTRING((((int)(((VALUE) - ((int)((((int)(10)) * (WORK))))))) + (48)));
                                                                //     28           value = work
#line 28 "regression-bugs-tmp/ercc-write.imp"
VALUE = WORK;
                                                                //     29           ptr = ptr + 1
#line 29 "regression-bugs-tmp/ercc-write.imp"
PTR = (((int)(PTR)) + (1));
                                                                //     30        %repeat %until value = 0
#line 30 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) == (0))) goto L_0009;
#line 30 "regression-bugs-tmp/ercc-write.imp"
goto L_0008;
#line 30 "regression-bugs-tmp/ercc-write.imp"
L_0009:;
                                                                //     31        res = res . " " %for work = ptr, 1, places - 1
#line 31 "regression-bugs-tmp/ercc-write.imp"
{static int _initial, _increment, _final, _control;
_initial = PTR; _increment = 1; _final = (((int)(PLACES)) - (1)); WORK = _control = _initial;
if (((_final-_initial) % _increment) != 0) _imp_signal(5,1,0,"Illegal cycle WORK = PTR, 1, (((int)(PLACES)) - (1))");
WORK -= _increment; _control -= _increment;
L_000b:;
if (WORK == _final) goto L_000c;
WORK += _increment; _control += _increment;
if (WORK != _control) _imp_signal(4,2,0,"Corrupt control variable WORK"); /* FOR loop control variable corrupted */
}
#line 31 "regression-bugs-tmp/ercc-write.imp"
RES = _imp_join((_imp_string)RES,(_imp_string)_imp_str_literal(" "));
#line 31 "regression-bugs-tmp/ercc-write.imp"
goto L_000b;
#line 31 "regression-bugs-tmp/ercc-write.imp"
L_000c:;
                                                                //     32        work = ptr - 1
#line 32 "regression-bugs-tmp/ercc-write.imp"
WORK = (((int)(PTR)) - (1));
                                                                //     33        res = res . sign
#line 33 "regression-bugs-tmp/ercc-write.imp"
RES = _imp_join((_imp_string)RES,(_imp_string)SIGN);
                                                                //     34        res = res . ch(ptr) %for ptr = work, -1, 0
#line 34 "regression-bugs-tmp/ercc-write.imp"
PTR = ((WORK) + ((int)(1)));
if ((((0)-(WORK)) % ((-1))) != 0) _imp_signal(5,1,0,"Illegal cycle PTR = WORK, (-1), 0");
L_000e:;
if (PTR == 0) goto L_000f;
PTR += (-1);
#line 34 "regression-bugs-tmp/ercc-write.imp"
RES = _imp_join((_imp_string)RES,(_imp_string)CH[PTR]);
#line 34 "regression-bugs-tmp/ercc-write.imp"
goto L_000e;
#line 34 "regression-bugs-tmp/ercc-write.imp"
L_000f:;
                                                                //     35        %result = res
#line 35 "regression-bugs-tmp/ercc-write.imp"
/* Remove %on %event handler here if present for this block */
return RES;
                                                                //     36     %end
#line 36 "regression-bugs-tmp/ercc-write.imp"
} // End of block SWRITE at level 3
                                                                //     37     %integer sign, work, ptr
#line 37 "regression-bugs-tmp/ercc-write.imp"
int SIGN;
#line 37 "regression-bugs-tmp/ercc-write.imp"
int WORK;
#line 37 "regression-bugs-tmp/ercc-write.imp"
int PTR;
                                                                //     38     %byte %integer %array ch(0 : 15)
#line 38 "regression-bugs-tmp/ercc-write.imp"
unsigned char CH[16];
                                                                //     39     sign = ' '
#line 39 "regression-bugs-tmp/ercc-write.imp"
SIGN = 32;
                                                                //     40     %if value = X'80000000' %then printstring(swrite(value, places)) %and %return
#line 40 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) != ((-2147483648)))) goto L_0011;
#line 40 "regression-bugs-tmp/ercc-write.imp"
_imp_PRINTSTRING(SWRITE(VALUE, PLACES));
#line 40 "regression-bugs-tmp/ercc-write.imp"
/* Remove %on %event handler here if present for this block */
return;
#line 40 "regression-bugs-tmp/ercc-write.imp"
L_0011:;
                                                                //     41     %if value < 0 %then sign = '-' %and value = -value
#line 41 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) >= (0))) goto L_0012;
#line 41 "regression-bugs-tmp/ercc-write.imp"
SIGN = 45;
#line 41 "regression-bugs-tmp/ercc-write.imp"
VALUE = (-(VALUE));
#line 41 "regression-bugs-tmp/ercc-write.imp"
L_0012:;
                                                                //     42     ptr = 0
#line 42 "regression-bugs-tmp/ercc-write.imp"
PTR = 0;
                                                                //     43     %cycle 
#line 43 "regression-bugs-tmp/ercc-write.imp"
L_0013:;
                                                                //     44        work = value // 10
#line 44 "regression-bugs-tmp/ercc-write.imp"
WORK = (long)((long)((int)(VALUE)) / (long)((int)(10)));
                                                                //     45        ch(ptr) = value - 10 * work
#line 45 "regression-bugs-tmp/ercc-write.imp"
CH[PTR] = ((VALUE) - ((int)((((int)(10)) * (WORK)))));
                                                                //     46        value = work
#line 46 "regression-bugs-tmp/ercc-write.imp"
VALUE = WORK;
                                                                //     47        ptr = ptr + 1
#line 47 "regression-bugs-tmp/ercc-write.imp"
PTR = (((int)(PTR)) + (1));
                                                                //     48     %repeat %until value = 0
#line 48 "regression-bugs-tmp/ercc-write.imp"
if (((VALUE) == (0))) goto L_0014;
#line 48 "regression-bugs-tmp/ercc-write.imp"
goto L_0013;
#line 48 "regression-bugs-tmp/ercc-write.imp"
L_0014:;
                                                                //     49     %if places > ptr %then spaces(places - ptr)
#line 49 "regression-bugs-tmp/ercc-write.imp"
if (((PLACES) <= (PTR))) goto L_0016;
#line 49 "regression-bugs-tmp/ercc-write.imp"
_imp_SPACES((((int)(PLACES)) - (PTR)));
#line 49 "regression-bugs-tmp/ercc-write.imp"
L_0016:;
                                                                //     50     work = ptr - 1
#line 50 "regression-bugs-tmp/ercc-write.imp"
WORK = (((int)(PTR)) - (1));
                                                                //     51     printsymbol(sign)
#line 51 "regression-bugs-tmp/ercc-write.imp"
_imp_PRINTSYMBOL(SIGN);
                                                                //     52     printsymbol(ch(ptr) + '0') %for ptr = work, -1, 0
#line 52 "regression-bugs-tmp/ercc-write.imp"
PTR = ((WORK) + ((int)(1)));
if ((((0)-(WORK)) % ((-1))) != 0) _imp_signal(5,1,0,"Illegal cycle PTR = WORK, (-1), 0");
L_0017:;
if (PTR == 0) goto L_0018;
PTR += (-1);
#line 52 "regression-bugs-tmp/ercc-write.imp"
_imp_PRINTSYMBOL((((int)(CH[PTR])) + (48)));
#line 52 "regression-bugs-tmp/ercc-write.imp"
goto L_0017;
#line 52 "regression-bugs-tmp/ercc-write.imp"
L_0018:;
                                                                //     53  %end
#line 53 "regression-bugs-tmp/ercc-write.imp"
/* Remove %on %event handler here if present for this block */
return;
} // End of block EMASWRITE at level 2
                                                                //     54  
                                                                //     55  %endofprogram
#line 55 "regression-bugs-tmp/ercc-write.imp"
/* Remove %on %event handler here if present for this block */
return 0;
} // End of block _imp_main at level 1
#line 55 "regression-bugs-tmp/ercc-write.imp"
// End of file
