#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 %BEGIN
int main(int argc, char **argv) { /*%begin*/
_imp_enter(main);
_imp_initialise(argc, argv);
// 2 %owninteger fail=0
static int FAIL = 0;
// 3 %STRING(5) %ARRAY a(1:10)
_imp_string5 A[10];
_imp_create_constdv(, _imp_string, A, 1, 10);
// 4 %STRING(5) %NAME ap
_imp_string5 *AP = (void *)0xFEFEFEFEFEFEFEFELL;
// 5 %INTEGER i
int I = 0xFEFEFEFE;
// 6 %ROUTINE conc(%STRING(5) %NAME x)
void CONC(_imp_string5 * X) {
_imp_enter(CONC);
// 7 x=x."a"
*X = **_imp_strp(_imp_strconcat("%S%s", X, "a")); // UNHANDLED STR ASSVAL DEST
// 8 %END
_imp_return;
_imp_begin_backtrace(CONC);
_imp_diagf("\n\nArguments:\n\n");
_imp_diagf("X = \"%.*s\"\n", X->cstr.len, X->cstr.s);
_imp_diagf("\nLocal Variables:\n\n");
_imp_end_backtrace();
} /* end of CONC */
// 9 a(i)=tostring(i+'0') %FOR i=1,1,10
// %for I = 1, 1, 10 %cycle
{
I = 0;
L_0001:
if (I == 10) goto L_0002;
I += 1;
_imp_strcpy(&A[I - 1], _imp_strp(_imp_TOSTRING(I + 48)), /*max:*/ 5);
goto L_0001;
}
L_0002:;
// 10 conc(a(i)) %FOR i=1,1,10
// %for I = 1, 1, 10 %cycle
{
I = 0;
L_0004:
if (I == 10) goto L_0005;
I += 1;
CONC((_imp_string5 *)&A[I - 1]);
goto L_0004;
}
L_0005:;
// 11 %FOR i=1,1,10 %CYCLE
// %for I = 1, 1, 10 %cycle
{
I = 0;
L_0006:
if (I == 10) goto L_0007;
I += 1;
// 12 ap==a(i)
AP = (_imp_string5 *)_imp_strp(A[I - 1]);
// 13 ap=ap."b"
*AP = **_imp_strp(_imp_strconcat("%S%s", AP, "b")); // UNHANDLED STR ASSVAL DEST
// 14 printstring(a(i)) %and fail=1 %UNLESS a(i)=tostring(i+'0')."ab"
/* clang-format off */
if (_imp_strcmp((_imp_string *)_imp_strp(A[I - 1]), (_imp_string *)_imp_strp(*_imp_strp(_imp_strconcat("%S%s", _imp_strp(_imp_TOSTRING(I + 48)), "ab")))) == 0) goto L_0008;
/* clang-format on */
_imp_printf("%S", _imp_strp(A[I - 1]));
FAIL = 1;
L_0008:;
// 15 %REPEAT
goto L_0006;
}
L_0007:;
// 16 printstring("TEST OK") %if fail=0
if ((FAIL) != (0)) goto L_0009;
_imp_printf("%s", "TEST OK");
L_0009:;
// 17 %ENDOFPROGRAM
_imp_stop(0);
end_0:;
_imp_begin_backtrace(main);
_imp_diagf("\n\nArguments:\n\n");
_imp_diagf("ARGC = %d\n", argc);
_imp_diagf("ARGV @[%p]\n", argv);
for (int i = 0; i < argc; i++) {
_imp_diagf(" ARGV(%d) = \"%s\"\n", i, argv[i]);
}
if (argv[argc] == 0) {
_imp_diagf(" ARGV(%d) = NULL\n", argc);
} else {
_imp_diagf(" ARGV(%d) = \"%s\"\n", argc, argv[argc]);
}
_imp_diagf("\nLocal Variables:\n\n");
_imp_bt_int(FAIL);
_imp_diagf("AP @[%p] = \"%.*s\"\n", AP, AP->cstr.len, AP->cstr.s);
_imp_bt_int(I);
_imp_end_backtrace();
_imp_stop(0);
}