         Edinburgh IMP77 Compiler - Version 8.4
    1 %begin
		.Ltext0:
				.section	.rodata
		.LC1:
				.string	"Illegal cycle I = 1, 1, N"
				.align 32
		.LC0:
				.byte	17
				.string	"test-in/paper.imp"
				.zero	237
				.globl	main
		main:
		.LFB189:
				leal	4(%esp), %ecx
				andl	$-16, %esp
				pushl	-4(%ecx)
				pushl	%ebp
				movl	%esp, %ebp
				pushl	%edi
				pushl	%esi
				pushl	%ebx
				pushl	%ecx
				subl	$1384, %esp
				call	__x86.get_pc_thunk.bx
				addl	$_GLOBAL_OFFSET_TABLE_, %ebx
				movl	%ecx, %eax
				movl	4(%eax), %edx
				movl	%edx, -1388(%ebp)
				movl	%gs:20, %esi
				movl	%esi, -28(%ebp)
				xorl	%esi, %esi
				subl	$8, %esp
				pushl	-1388(%ebp)
				pushl	(%eax)
				call	_imp_initialise@PLT
				addl	$16, %esp
    2
    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.
				movl	$42, -1372(%ebp)
    7
    8   %integer %array a(0:100), b(0:n)
				leal	-1336(%ebp), %edx
				movl	$0, %eax
				movl	$17, %ecx
				movl	%edx, %edi
				rep stosl
				leal	-432(%ebp), %eax
				movl	%eax, -1336(%ebp)
				movl	$4, -1332(%ebp)
				movl	-1372(%ebp), %eax
				addl	$1, %eax
				leal	-1(%eax), %edx
				movl	%edx, -1356(%ebp)
				sall	$2, %eax
				leal	3(%eax), %edx
				movl	$16, %eax
				subl	$1, %eax
				addl	%edx, %eax
				movl	$16, %esi
				movl	$0, %edx
				divl	%esi
				imull	$16, %eax, %eax
				subl	%eax, %esp
				movl	%esp, %eax
				addl	$3, %eax
				shrl	$2, %eax
				sall	$2, %eax
				movl	%eax, -1352(%ebp)
				leal	-1268(%ebp), %edx
				movl	$0, %eax
				movl	$17, %ecx
				movl	%edx, %edi
				rep stosl
				movl	-1352(%ebp), %eax
				movl	%eax, -1268(%ebp)
				movl	$4, -1264(%ebp)
    9
   10   a(n) = n %for n = 0, 1, 100
				movl	$-1, -1372(%ebp)
		.L2:
				cmpl	$100, -1372(%ebp)
				je	.L22
				addl	$1, -1372(%ebp)
				movl	-1372(%ebp), %eax
				movl	-1372(%ebp), %edx
				movl	%edx, -432(%ebp,%eax,4)
				jmp	.L2
		.L22:
				nop
		.L4:
   11   b(n) = n %for n = 0, 1, 42
				movl	$-1, -1372(%ebp)
		.L5:
				cmpl	$42, -1372(%ebp)
				je	.L23
				addl	$1, -1372(%ebp)
				movl	-1352(%ebp), %eax
				movl	-1372(%ebp), %edx
				movl	-1372(%ebp), %ecx
				movl	%ecx, (%eax,%edx,4)
				jmp	.L5
		.L7:
		.L23:
				nop
   12   write(n,3); newline
				subl	$8, %esp
				pushl	$3
				pushl	-1372(%ebp)
				call	_imp_writeint@PLT
				addl	$16, %esp
		.LBB11:
		.LBB12:
				call	_imp_newline@PLT
		.LBE12:
		.LBE11:
   13
   14   n = 42
				movl	$42, -1372(%ebp)
   15
   16   j = 0; k = 0;
				movl	$0, -1364(%ebp)
				movl	$0, -1368(%ebp)
		.LBB13:
   17
   18   %cycle i = 1, 1, n
				movl	-1372(%ebp), %eax
				movl	%eax, -1348(%ebp)
		.LBB14:
				movl	-1348(%ebp), %eax
				subl	$1, %eax
				movl	%eax, -1344(%ebp)
				movl	-1344(%ebp), %eax
				xorl	$1, %eax
				shrl	$31, %eax
				movzbl	%al, %eax
		.LBE14:
				testl	%eax, %eax
				je	.L8
				leal	-944(%ebp), %eax
				subl	$8, %esp
				leal	.LC1@GOTOFF(%ebx), %edx
				pushl	%edx
				pushl	%eax
				call	_imp_c2istr@PLT
				addl	$12, %esp
				movl	_imp_current_line@GOT(%ebx), %eax
				movl	(%eax), %eax
				testl	%eax, %eax
				je	.L9
				movl	_imp_current_line@GOT(%ebx), %eax
				movl	(%eax), %eax
				movl	%eax, -1392(%ebp)
				jmp	.L10
		.L9:
				movl	$18, -1392(%ebp)
		.L10:
				movl	_imp_current_file@GOT(%ebx), %eax
				movl	(%eax), %eax
				testl	%eax, %eax
				je	.L11
				movl	_imp_current_file@GOT(%ebx), %eax
				movl	(%eax), %edx
				leal	-688(%ebp), %eax
				subl	$8, %esp
				pushl	%edx
				pushl	%eax
				call	_imp_c2istr@PLT
				addl	$12, %esp
				jmp	.L12
		.L11:
		.LBB15:
				leal	-688(%ebp), %eax
				leal	.LC0@GOTOFF(%ebx), %edx
				movl	$64, %ecx
				movl	%eax, %edi
				movl	%edx, %esi
				rep movsl
				leal	-1200(%ebp), %eax
				leal	-688(%ebp), %edx
				movl	$64, %ecx
				movl	%eax, %edi
				movl	%edx, %esi
				rep movsl
		.LBE15:
				leal	-688(%ebp), %eax
				leal	-1200(%ebp), %edx
				movl	$64, %ecx
				movl	%eax, %edi
				movl	%edx, %esi
				rep movsl
		.L12:
				pushl	$0
				pushl	$1
				pushl	$5
				subl	$256, %esp
				movl	%esp, %eax
				movl	%eax, %edi
				leal	-944(%ebp), %eax
				movl	$64, %edx
				movl	%eax, %esi
				movl	%edx, %ecx
				rep movsl
				pushl	-1392(%ebp)
				subl	$256, %esp
				movl	%esp, %eax
				movl	%eax, %edi
				leal	-688(%ebp), %eax
				movl	$64, %edx
				movl	%eax, %esi
				movl	%edx, %ecx
				rep movsl
				call	_signal_event@PLT
				addl	$528, %esp
		.L8:
				movl	$0, -1360(%ebp)
		.L13:
				movl	-1360(%ebp), %eax
				cmpl	-1348(%ebp), %eax
				je	.L24
				addl	$1, -1360(%ebp)
				nop
		.LBE13:
   19     j = j + a(i)
				movl	-1360(%ebp), %eax
				movl	-432(%ebp,%eax,4), %eax
				addl	%eax, -1364(%ebp)
   20     k = k + b(i+1)        ;! should cause a runtime error since i+1 == n+1 and array b is 0:n ...
				movl	-1360(%ebp), %eax
				leal	1(%eax), %edx
				movl	-1352(%ebp), %eax
				movl	(%eax,%edx,4), %eax
				addl	%eax, -1368(%ebp)
   21   %repeat
				jmp	.L13
		.L15:
		.L24:
   22
   23   write(j, 5); write(k, 5); newline
				subl	$8, %esp
				pushl	$5
				pushl	-1364(%ebp)
				call	_imp_writeint@PLT
				addl	$16, %esp
				subl	$8, %esp
				pushl	$5
				pushl	-1368(%ebp)
				call	_imp_writeint@PLT
				addl	$16, %esp
		.LBB16:
		.LBB17:
				call	_imp_newline@PLT
				movl	$0, -1340(%ebp)
		.LBE17:
		.LBE16:
		.LBB18:
		.LBB19:
				subl	$12, %esp
				pushl	-1340(%ebp)
				call	exit@PLT
		.LBE19:
		.LBE18:
		.LFE189:
				.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
				.globl	__x86.get_pc_thunk.bx
				.hidden	__x86.get_pc_thunk.bx
		__x86.get_pc_thunk.bx:
		.LFB190:
				movl	(%esp), %ebx
				ret
		.LFE190:
		.Letext0:
   24
   25 %endofprogram
   19 Statements compiled
