#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 %begin
int main(int argc, char **argv) { /*%begin*/
_imp_initialise(argc, argv);
// 2 %string (255) s
_imp_string255 S;
// 3 %integerfn fred(%integername i)
int FRED(int *I) {
// 4 %integer total = 0
int TOTAL;
TOTAL = 0;
// 5 %if charno(s, i) = 's' %start
if (*_imp_CHARNO((_imp_string255 *)/*p*/ /*?*/ &S, *I) != 115) goto L_0001;
// 6 %result = 0
return 0;
// 7 %finish
L_0001:;
// 8 total = 0
TOTAL = 0;
// 9 %for i = 1, 1, i %cycle
// %for *I = 1, 1, *I %cycle
{
int _final = *I;
if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle *I = 1, 1, *I");
*I = 0;
L_0002:
if (*I == _final) goto L_0003;
*I += 1;
// 10 total = total + i
TOTAL = TOTAL + *I;
// 11 %repeat
goto L_0002;
}
L_0003:;
// 12 %result = total
return TOTAL;
// 13 %end
} /* end of FRED */
// 14 %integer x, y
int X;
int Y;
// 15 s = "a string"
/* clang-format off */
_imp_strncpy(/*?*/&S, ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("a string"); (void *)&tmp;}), /*max:*/255);
/* clang-format on */
// 16 y = 3
Y = 3;
// 17 x = fred(y)
X = FRED(/*?*/ &Y);
// 18 %endofprogram
_imp_stop(0);
return 0;
end_0:;
}