#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 (6) s
_imp_string6 S;
// 3 s = "hello"
_imp_strcpy(&S, _imp_strp(_imp_str_literal("hello")), /*max:*/ 6);
// 4 s = string(addr(s))
_imp_strcpy(&S, _imp_strp(*_imp_STRING(((_imp_address)(&S)))), /*max:*/ 6);
// 5 s <- "longer string"
/* clang-format off */
_imp_strncpy(_imp_strp(S), _imp_strp(_imp_str_literal("longer string")), /*max:*/6);
/* clang-format on */
/* truncated copy of no more than 6 chars */
/* clang-format off */
if (*_imp_LENGTH((_imp_string *)_imp_strp(S)) > 6) *_imp_LENGTH((_imp_string *)_imp_strp(S)) = 6;
/* clang-format on */
// 6 %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_end_backtrace();
_imp_stop(0);
}