         Edinburgh IMP77 Compiler - Version 8.4
    1 %begin
		.Ltext0:
				.align	2
				.global	main
		main:
		.LFB185:
		.LVL0:
				sub	sp, sp, #624
				stp	x29, x30, [sp]
				add	x29, sp, 0
				str	x19, [sp, 16]
				adrp	x2, :got:__stack_chk_guard
				ldr	x2, [x2, #:got_lo12:__stack_chk_guard]
				ldr	x3, [x2]
				str	x3, [x29, 616]
				mov	x3,0
    2
				bl	_imp_initialise
		.LVL1:
				mov	x0, 0
    3   ! the example in https://www.ancientgeek.org.uk/EMAS/EMAS_Papers/The_IMP_language_and_compiler.pdf
    4   %integer i, j, k, n
    5
    6   n = 42 ; ! a little initialisation has been added which was not explicit in the paper to avoid runtime errors.
    7
    8   %integer %array a(0:100), b(0:n)
    9
   10   a(n) = n %for n = 0, 1, 100
   11   b(n) = n %for n = 0, 1, 42
   12   write(n,3); newline
				mov	w1, 3
		.LVL7:
				mov	w0, 42
		.LVL8:
				bl	_imp_writeint
		.LVL9:
		.LBB11:
		.LBB12:
				bl	_imp_newline
		.LVL10:
				add	x2, x29, 212
				add	x1, x29, 40
				add	x4, x29, 208
		.LBE12:
		.LBE11:
   13
				cmp	x0, 101
				bne	.L2
   14   n = 42
				str	w0, [x1, x0, lsl 2]
		.LDL1:
				add	x0, x0, 1
		.LVL3:
				cmp	x0, 43
				bne	.L3
		.L4:
   15
				add	x1, x29, 208
		.LVL2:
		.L2:
				str	w0, [x1, x0, lsl 2]
		.LDL2:
		.LDL3:
				add	x0, x0, 1
		.LVL6:
   16   j = 0; k = 0;
				add	x1, x29, 32
		.LVL5:
		.L3:
				mov	w0, 0
   17
				mov	w19, 0
		.LVL11:
		.L5:
		.LBB13:
				ldr	w3, [x2], 4
				add	w0, w0, w3
		.LVL12:
   18   %cycle i = 1, 1, n
   19     j = j + a(i)
				mov	x0, 0
		.LVL4:
   20     k = k + b(i+1)        ;! should cause a runtime error since i+1 == n+1 and array b is 0:n ...
				ldr	w3, [x1], 4
				add	w19, w19, w3
		.LVL13:
		.LDL4:
   21   %repeat
   22
   23   write(j, 5); write(k, 5); newline
				cmp	x1, x4
				bne	.L5
		.L6:
		.LBE13:
				mov	w1, 5
				bl	_imp_writeint
		.LVL14:
   24
				mov	w1, 5
				mov	w0, w19
				bl	_imp_writeint
		.LVL15:
		.LBB14:
		.LBB15:
				bl	_imp_newline
		.LVL16:
		.LBE15:
		.LBE14:
		.LBB16:
		.LBB17:
				mov	w0, 0
				bl	exit
		.LVL17:
		.LBE17:
		.LBE16:
		.LFE185:
		.Letext0:
   25 %endofprogram
   19 Statements compiled
