2024-02-09 14:19:29 +03:00
|
|
|
|
|
|
|
function ext_10((integer, integer) → integer) : integer → integer;
|
|
|
|
function app_0(integer → integer) : integer;
|
|
|
|
function f((integer, integer) → integer) : integer;
|
|
|
|
function plus(integer, integer) : integer;
|
|
|
|
function minus(integer, integer) : integer;
|
|
|
|
function mult(integer, integer) : integer;
|
2024-03-20 14:14:12 +03:00
|
|
|
function g(integer, integer, integer, integer) : integer;
|
2024-02-09 14:19:29 +03:00
|
|
|
function main() : *;
|
|
|
|
|
|
|
|
function ext_10((integer, integer) → integer) : integer → integer {
|
2024-03-20 14:14:12 +03:00
|
|
|
prealloc 6, live: (arg[0]);
|
2024-02-09 14:19:29 +03:00
|
|
|
tmp[0] = 10;
|
|
|
|
tmp[1] = arg[0];
|
|
|
|
tmp[0] = cextend tmp[1] (tmp[0]);
|
|
|
|
ret tmp[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function app_0(integer → integer) : integer {
|
|
|
|
tmp[0] = 1;
|
|
|
|
tmp[1] = arg[0];
|
|
|
|
tcall tmp[1] (tmp[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function f((integer, integer) → integer) : integer {
|
|
|
|
tmp[0] = arg[0];
|
|
|
|
tmp[0] = call ext_10 (tmp[0]), live: (arg[0]);
|
|
|
|
tcall app_0 (tmp[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function plus(integer, integer) : integer {
|
|
|
|
tmp[0] = arg[1];
|
|
|
|
tmp[1] = arg[0];
|
|
|
|
tmp[0] = add tmp[1] tmp[0];
|
|
|
|
ret tmp[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function minus(integer, integer) : integer {
|
|
|
|
tmp[0] = arg[1];
|
|
|
|
tmp[1] = arg[0];
|
|
|
|
tmp[0] = sub tmp[1] tmp[0];
|
|
|
|
ret tmp[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function mult(integer, integer) : integer {
|
|
|
|
tmp[0] = arg[1];
|
|
|
|
tmp[1] = arg[0];
|
|
|
|
tmp[0] = mul tmp[1] tmp[0];
|
|
|
|
ret tmp[0];
|
|
|
|
}
|
|
|
|
|
2024-03-20 14:14:12 +03:00
|
|
|
function g(integer, integer, integer, integer) : integer {
|
|
|
|
tmp[0] = arg[1];
|
|
|
|
tmp[1] = arg[0];
|
|
|
|
tmp[0] = sub tmp[1] tmp[0];
|
|
|
|
tmp[1] = arg[2];
|
|
|
|
tmp[0] = add tmp[1] tmp[0];
|
|
|
|
tmp[1] = arg[3];
|
|
|
|
tmp[0] = mul tmp[1] tmp[0];
|
|
|
|
ret tmp[0];
|
|
|
|
}
|
|
|
|
|
2024-02-09 14:19:29 +03:00
|
|
|
function main() : * {
|
|
|
|
prealloc 2;
|
|
|
|
tmp[0] = calloc plus ();
|
|
|
|
tmp[0] = call f (tmp[0]);
|
|
|
|
prealloc 2, live: (tmp[0]);
|
|
|
|
trace tmp[0];
|
|
|
|
nop;
|
|
|
|
tmp[0] = calloc minus ();
|
|
|
|
tmp[0] = call f (tmp[0]);
|
|
|
|
prealloc 2, live: (tmp[0]);
|
|
|
|
trace tmp[0];
|
|
|
|
nop;
|
|
|
|
tmp[0] = calloc mult ();
|
|
|
|
tmp[0] = call f (tmp[0]);
|
2024-03-20 14:14:12 +03:00
|
|
|
prealloc 4, live: (tmp[0]);
|
|
|
|
trace tmp[0];
|
|
|
|
nop;
|
|
|
|
tmp[0] = 2;
|
|
|
|
tmp[1] = 3;
|
|
|
|
tmp[0] = calloc g (tmp[1], tmp[0]);
|
|
|
|
tmp[0] = call f (tmp[0]);
|
2024-02-09 14:19:29 +03:00
|
|
|
trace tmp[0];
|
|
|
|
nop;
|
|
|
|
tmp[0] = void;
|
|
|
|
ret tmp[0];
|
|
|
|
}
|