         Edinburgh IMP77 Compiler - Version 8.4
    1 %begin
		.Ltext0:
				.align	1
				.global	main
				.thumb
				.thumb_func
		main:
		.LFB185:
				@ args = 0, pretend = 0, frame = 584
				@ frame_needed = 0, uses_anonymous_args = 0
		.LVL0:
				push	{r4, r5, lr}
				sub	sp, sp, #588
				ldr	r3, .L12
		.LPIC8:
				add	r3, pc
				ldr	r2, .L12+4
				ldr	r3, [r3, r2]
				ldr	r3, [r3]
				str	r3, [sp, #580]
    2
				bl	_imp_initialise(PLT)
		.LVL1:
				add	r2, sp, #172
    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
				mov	r3, #-1
		.LVL2:
		.L2:
   12   write(n,3); newline
				mov	r3, #-1
		.LVL4:
		.L3:
				adds	r3, r3, #1
		.LVL5:
				movs	r1, #3
				movs	r0, #42
				bl	_imp_writeint(PLT)
		.LVL6:
		.LBB11:
		.LBB12:
				bl	_imp_newline(PLT)
		.LVL7:
				add	r3, sp, #176
				add	r2, sp, #8
				add	r5, sp, #344
		.LBE12:
		.LBE11:
				movs	r0, #0
   13
				cmp	r3, #100
				bne	.L2
				mov	r2, sp
   14   n = 42
				adds	r3, r3, #1
		.LVL3:
				cmp	r3, #42
				bne	.L3
		.L4:
   15
				str	r3, [r2, #4]!
		.LDL1:
   16   j = 0; k = 0;
				str	r3, [r2, #4]!
		.LDL2:
		.LDL3:
   17
				mov	r4, r0
		.LVL8:
		.L5:
		.LBB13:
   18   %cycle i = 1, 1, n
   19     j = j + a(i)
				ldr	r1, [r3, #4]!
				add	r0, r0, r1
		.LVL9:
   20     k = k + b(i+1)        ;! should cause a runtime error since i+1 == n+1 and array b is 0:n ...
				ldr	r1, [r2, #4]!
				add	r4, r4, r1
		.LVL10:
		.LDL4:
   21   %repeat
   22
   23   write(j, 5); write(k, 5); newline
				cmp	r3, r5
				bne	.L5
		.L6:
		.LBE13:
				movs	r1, #5
				bl	_imp_writeint(PLT)
		.LVL11:
   24
				movs	r1, #5
				mov	r0, r4
				bl	_imp_writeint(PLT)
		.LVL12:
		.LBB14:
		.LBB15:
				bl	_imp_newline(PLT)
		.LVL13:
		.LBE15:
		.LBE14:
		.LBB16:
		.LBB17:
				movs	r0, #0
				bl	exit(PLT)
		.LVL14:
		.L13:
				.align	2
		.L12:
				.word	_GLOBAL_OFFSET_TABLE_-(.LPIC8+4)
				.word	__stack_chk_guard(GOT)
		.LBE17:
		.LBE16:
		.LFE185:
		.Letext0:
   25 %endofprogram
   19 Statements compiled
