#include <perms.h>

                                                                //      1  %begin
#line 1 "regression-compile-tmp/array2d.imp"
int main(int argc, char **argv) {
  _imp_initialise(argc, argv);
                                                                //      2  
                                                                //      3    %routine printarray(%integerarray(2)%name A, %integer a0low, a0high, a1low, a1high)
#line 3 "regression-compile-tmp/array2d.imp"
void PRINTARRAY( int /*arrayname*/*A, int A0LOW, int A0HIGH, int A1LOW, int A1HIGH )
#line 3 "regression-compile-tmp/array2d.imp"
{
                                                                //      4      %integer A0, A1
#line 4 "regression-compile-tmp/array2d.imp"
int A0;
#line 4 "regression-compile-tmp/array2d.imp"
int A1;
                                                                //      5      ! Imp needs some perm code to determine upper and lower bounds of arrays
                                                                //      6      %for A0 = a0low, 1, a0high %cycle
#line 6 "regression-compile-tmp/array2d.imp"
{static int _initial, _increment, _final, _control;
_initial = A0LOW; _increment = 1; _final = A0HIGH; A0 = _control = _initial;
if (((_final-_initial) % _increment) != 0) _imp_signal(5,1,0,"Illegal cycle A0 = A0LOW, 1, A0HIGH");
A0 -= _increment; _control -= _increment;
L_0002:;
if (A0 == _final) goto L_0003;
A0 += _increment; _control += _increment;
if (A0 != _control) _imp_signal(4,2,0,"Corrupt control variable A0"); /* FOR loop control variable corrupted */
}
                                                                //      7        %for A1 = a1low, 1, a1high %cycle
#line 7 "regression-compile-tmp/array2d.imp"
{static int _initial, _increment, _final, _control;
_initial = A1LOW; _increment = 1; _final = A1HIGH; A1 = _control = _initial;
if (((_final-_initial) % _increment) != 0) _imp_signal(5,1,0,"Illegal cycle A1 = A1LOW, 1, A1HIGH");
A1 -= _increment; _control -= _increment;
L_0005:;
if (A1 == _final) goto L_0006;
A1 += _increment; _control += _increment;
if (A1 != _control) _imp_signal(4,2,0,"Corrupt control variable A1"); /* FOR loop control variable corrupted */
}
                                                                //      8          write(A(A0, A1), 3); print string(", ")
#line 8 "regression-compile-tmp/array2d.imp"
_imp_WRITE(A[A1], 3);
#line 8 "regression-compile-tmp/array2d.imp"
_imp_PRINTSTRING(_imp_str_literal(", "));
                                                                //      9        %repeat
#line 9 "regression-compile-tmp/array2d.imp"
goto L_0005;
#line 9 "regression-compile-tmp/array2d.imp"
L_0006:;
                                                                //     10        newline
#line 10 "regression-compile-tmp/array2d.imp"
_imp_NEWLINE();
                                                                //     11      %repeat
#line 11 "regression-compile-tmp/array2d.imp"
goto L_0002;
#line 11 "regression-compile-tmp/array2d.imp"
L_0003:;
                                                                //     12      newline
#line 12 "regression-compile-tmp/array2d.imp"
_imp_NEWLINE();
                                                                //     13    %end
#line 13 "regression-compile-tmp/array2d.imp"
/* Remove %on %event handler here if present for this block */
return;
} // End of block PRINTARRAY at level 2
                                                                //     14  
                                                                //     15    %integername element
#line 15 "regression-compile-tmp/array2d.imp"
int /*name*/*ELEMENT;
                                                                //     16    %integer i
#line 16 "regression-compile-tmp/array2d.imp"
int I;
                                                                //     17  
                                                                //     18    ! imp77 doesn't allow initialised multi-dimensional arrays.  (Imp80 would!)
                                                                //     19    ! So I'll initialise these explicitly:
                                                                //     20    %integerarray fred(0:1, 0:2)       { simple case }
#line 20 "regression-compile-tmp/array2d.imp"
int FRED[2][3];
                                                                //     21    %integerarray jim(11:13, 100:103)  { non-zero lower bounds }
#line 21 "regression-compile-tmp/array2d.imp"
int JIM[3][4];
                                                                //     22    element == fred(0,0); element = i %and element == element++1 %for i = 0, 1, 5
#line 22 "regression-compile-tmp/array2d.imp"
ELEMENT = &FRED[0][0];
#line 22 "regression-compile-tmp/array2d.imp"
I = (-1);
if ((((5)-(0)) % (1)) != 0) _imp_signal(5,1,0,"Illegal cycle I = 0, 1, 5");
L_0008:;
if (I == 5) goto L_0009;
I += 1;
#line 22 "regression-compile-tmp/array2d.imp"
*ELEMENT = I;
#line 22 "regression-compile-tmp/array2d.imp"
ELEMENT = /*F_VOID*/((ELEMENT) + (1));
#line 22 "regression-compile-tmp/array2d.imp"
goto L_0008;
#line 22 "regression-compile-tmp/array2d.imp"
L_0009:;
                                                                //     23    element == jim(11,100); element = i %and element == element++1 %for i = 0, 1, 11
#line 23 "regression-compile-tmp/array2d.imp"
ELEMENT = &JIM[(-89)][89];
#line 23 "regression-compile-tmp/array2d.imp"
I = (-1);
if ((((11)-(0)) % (1)) != 0) _imp_signal(5,1,0,"Illegal cycle I = 0, 1, 11");
L_000b:;
if (I == 11) goto L_000c;
I += 1;
#line 23 "regression-compile-tmp/array2d.imp"
*ELEMENT = I;
#line 23 "regression-compile-tmp/array2d.imp"
ELEMENT = /*F_VOID*/((ELEMENT) + (1));
#line 23 "regression-compile-tmp/array2d.imp"
goto L_000b;
#line 23 "regression-compile-tmp/array2d.imp"
L_000c:;
                                                                //     24  
                                                                //     25    printarray(fred, 0,1, 0,2)
#line 25 "regression-compile-tmp/array2d.imp"
PRINTARRAY(&FRED[-(0)][-(0)], 0, 1, 0, 2);
                                                                //     26    printarray(jim, 11,13, 100,103)
#line 26 "regression-compile-tmp/array2d.imp"
PRINTARRAY(&JIM[-(100)][-(11)], 11, 13, 100, 103);
                                                                //     27    
                                                                //     28  %endofprogram
#line 28 "regression-compile-tmp/array2d.imp"
/* Remove %on %event handler here if present for this block */
return 0;
} // End of block _imp_main at level 1
#line 28 "regression-compile-tmp/array2d.imp"
// End of file
