#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 %string(255) S = "A string"
_imp_string255 S;
_imp_strcpy(&S, _imp_strp(_imp_str_literal("A string")), /*max:*/ 255);
// 3 %integer len
int LEN = 0xFEFEFEFE;
// 4 len = length(S)
LEN = *_imp_LENGTH((_imp_string255 *)&S);
// 5 ! Write() below outputs the wrong value. Not sure if the problem is with length or write.
// 6 %if len < -128 %start
if ((LEN) >= (-128)) goto L_0001;
// 7 printstring("len < -128");
_imp_printf("%s", "len < -128");
// 8 %finish %else %if len < 0 %start
goto L_0002;
L_0001:;
if ((LEN) >= (0)) goto L_0003;
// 9 printstring("len >= -128 and < 0");
_imp_printf("%s", "len >= -128 and < 0");
// 10 %finish %else %if len < 128 %start
goto L_0002;
L_0003:;
if ((LEN) >= (128)) goto L_0004;
// 11 printstring("len >= 0 and < 128");
_imp_printf("%s", "len >= 0 and < 128");
// 12 %finish %else %if len < 256 %start
goto L_0002;
L_0004:;
if ((LEN) >= (256)) goto L_0005;
// 13 printstring("len >= 128 and < 256");
_imp_printf("%s", "len >= 128 and < 256");
// 14 %finish %else %start
goto L_0002;
L_0005:;
// 15 printstring("len >= 256");
_imp_printf("%s", "len >= 256");
// 16 %finish
L_0002:;
// 17 newline
_imp_NEWLINE();
// 18 write(len,0)
_imp_WRITE(LEN, 0);
// 19 newline
_imp_NEWLINE();
// 20 %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_diagf("S = \"%.*s\"\n", S.cstr.len, S.cstr.s);
_imp_bt_int(LEN);
_imp_end_backtrace();
_imp_stop(0);
}