! comparing true imp vs imptoc gives correct results
! 
! pizzabox:~/public_html/imptoc> ./test-imp
! fred( 1000, 2) is  1
! fred( 1000, 3) is  3
! fred( 1001, 2) is  2
! fred( 1001, 3) is  4
! 
! Program stopped
! pizzabox:~/public_html/imptoc> ./test
! fred(1000,2) is 1
! fred(1000,3) is 3
! fred(1001,2) is 2
! fred(1001,3) is 4

%begin
   %integer i, j, k, l, p, q
   i = 1000
   j = 1001
   k = 2
   l = 3
   %begin
      %own %byte %integer %array fred(1000:1001, 2:3) = 1, 2, 3, 4

      %for p = i, 1, j %cycle
         %for q = k, 1, l %cycle
            printstring("fred(")
            write(p, 0)
            printsymbol(',')
            write(q, 0)
            printstring(") is ")
            write(fred(p, q), 0)
            newline
         %repeat
      %repeat
   %end
%end %of %program

#include "imptoc.h"
main ()
{
int i, j, k, l, p, q;

   i = 1000;
   j = 1001;
   k = 2;
   l = 3;
   {
      static unsigned char **fred, *fred_1;
      static int fred_dim_2, fred_dim_1;
      static unsigned char fred_data[] = {1, 2, 3, 4};
      static unsigned char *fred_datap = fred_data;
      int fred_inels = 4;
      fred = (unsigned char **) malloc (((l) - (k) + 1) * sizeof (unsigned char *));

      fred -= k;
      for (fred_dim_2 = k; fred_dim_2 <= l; fred_dim_2++) {
	 fred_1 = (unsigned char *) malloc (((j) - (i) + 1) * sizeof (unsigned char));

	 fred_1 -= i;
	 for (fred_dim_1 = i; fred_dim_1 <= j; fred_dim_1++) {
           /* Assign initialised elements if any */
	 }
	 fred[fred_dim_2] = fred_1;
      }

      for (fred_dim_2 = k; fred_dim_2 <= l; fred_dim_2++) {
	 if (fred_inels == 0)
	    break;
	 for (fred_dim_1 = i; fred_dim_1 <= j; fred_dim_1++) {
	    if (fred_inels == 0)
	       break;
	    fred[fred_dim_2][fred_dim_1] = *fred_datap++;
	    fred_inels += 1;
	 }
      }

      selectoutput(0);

      fprintf(stderr, "i %d  j %d   k %d   l %d   \n", i, j, k, l);

      for (p = i; p <= j; p++) {
	 for (q = k; q <= l; q++) {
/*            fprintf(stderr, "i %d  j %d   k %d   l %d   p %d   q %d\n", i, j, k, l, p, q);*/
	    fprintf (out_file, "%s", "fred(");
	    fprintf (out_file, "%1d", p);
	    fprintf (out_file, "%c", ',');
	    fprintf (out_file, "%1d", q);
	    fprintf (out_file, "%s", ") is ");
	    fprintf (out_file, "%1d", fred[q][p]);
	    fprintf (out_file, "%s", "\n");
	 }
      }
   }
   exit (0);
}

/* end of automatic translation */
