#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 %begin
int main(int argc, char **argv) { /*%begin*/
_imp_initialise(argc, argv);
// 2 %constant %string (1) SNL = "
const _imp_string1 SNL = _imp_str_init("\n");
// 3+ "
// 4 %string(31)%array NAMES(1:99)
_imp_string31 NAMES[99];
auto void STRINGSORT(_imp_string * X, int FROM, int TO);
// 5 %routine %spec STRINGSORT(%string(*)%array %name X,
// 6+ %integer F, T)
// 7 %integer I, N
int I;
int N;
// 8
// 9 READ(N) %until 1 <= N <= 99; ! Reject if not in range.
L_0001:;
_imp_READ(/*?*/ &N);
{
// Double-sided test on N (Part I)
int tmp;
if (1 > (tmp = N)) goto L_0002;
// Double-sided test on N (Part II)
if (tmp <= 99) goto L_0003;
}
L_0002:;
goto L_0001;
L_0003:;
// 10 READSTRING(NAMES(I)) %for I=1,1,N
// %for I = 1, 1, N %cycle
{
int _final = N;
if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = 1, 1, N");
I = 0;
L_0004:
if (I == _final) goto L_0005;
I += 1;
_imp_READSTRING((_imp_string255 *)/*p*/ /*?*/ &NAMES[I - 1]);
goto L_0004;
}
L_0005:;
// 11 STRINGSORT(NAMES,1,N)
STRINGSORT(
({
__typeof__(_imp_string31) tmp = NAMES /*q*/;
(_imp_string255 *)&tmp;
})
,
1, N);
// 12 PRINTSTRING(NAMES(I).SNL) %for I=1,1,N
// %for I = 1, 1, N %cycle
{
int _final = N;
if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = 1, 1, N");
I = 0;
L_0007:
if (I == _final) goto L_0008;
I += 1;
_imp_PRINTSTRING(
*({
__typeof__(_imp_string255) tmp = *({
_imp_string255 tmp = _imp_join((_imp_string *)/*?*/ &NAMES[I - 1], (_imp_string *)/*?*/ &SNL);
(_imp_string255 *)&tmp;
}) /*q*/;
(_imp_string255 *)&tmp;
})
);
goto L_0007;
}
L_0008:;
// 13
// 14 %routine STRINGSORT(%string(*)%array %name X,
void STRINGSORT(_imp_string * X, int FROM, int TO) {
// 15+ %integer FROM, TO)
// 16 %integer L, U
int L;
int U;
// 17 %string(255) D
_imp_string255 D;
// 18
// 19 %return %if FROM >= TO
if (FROM < TO) goto L_0009;
return;
L_0009:;
// 20 L = FROM; U = TO
L = FROM;
U = TO;
// 21 D = X(U)
_imp_strncpy(/*?*/ &D, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = [/*BUG*/ 0];
(void *)&tmp;
}),
/*max:*/ 255);
// 22
// 23 %cycle
L_000A:;
// 24 L = L+1 %while L < U %and X(L) <= D
L_000B:;
if (L >= U) goto L_000C;
if (_imp_strcmp((_imp_string *)/*?*/ &[/*BUG*/ 0], (_imp_string *)/*?*/ &D) > 0) goto L_000C;
L = L + 1;
goto L_000B;
L_000C:;
// 25 %exit %if L = U
if (L != U) goto L_000D;
goto L_000E;
L_000D:;
// 26 X(U) = X(L)
[/*BUG*/ 0] = [/*BUG*/ 0];
// 27 U = U-1 %while U > L %and X(U) >= D
L_000F:;
if (U <= L) goto L_0010;
if (_imp_strcmp((_imp_string *)/*?*/ &[/*BUG*/ 0], (_imp_string *)/*?*/ &D) < 0) goto L_0010;
U = U - 1;
goto L_000F;
L_0010:;
// 28 %exit %if U = L
if (U != L) goto L_0011;
goto L_000E;
L_0011:;
// 29 X(L) = X(U)
[/*BUG*/ 0] = [/*BUG*/ 0];
// 30 %repeat
goto L_000A;
L_000E:;
// 31 ! Now L = U.
// 32
// 33 X(U) = D
[/*BUG*/ 0] = D;
// 34 L = L-1; U = U+1
L = L - 1;
U = U + 1;
// 35 STRINGSORT(X,FROM,L) %if FROM < L
if (FROM >= L) goto L_0012;
STRINGSORT(
({
__typeof__(_imp_string255) tmp = X /*q*/;
(_imp_string255 *)&tmp;
})
,
FROM, L);
L_0012:;
// 36 STRINGSORT(X,U,TO) %if U < TO
if (U >= TO) goto L_0013;
STRINGSORT(
({
__typeof__(_imp_string255) tmp = X /*q*/;
(_imp_string255 *)&tmp;
})
,
U, TO);
L_0013:;
// 37 %end
return;
} /* end of STRINGSORT */
// 38
// 39 %end %of %program
_imp_stop(0);
return 0;
end_0:;
}