1.data	16
2ok:
3.c	"ok"
4
5.code
6	jmpi main
7
8/*
9 * very simple test on purpose because otherwise it would not trigger
10 * the bug where the retr %r0 or retr_d %f0 would be omitted because
11 * the argument was already the return register, but the register end
12 * clobbered by another instruction, like the div*, and the wrong
13 * value returned because the retr* was removed and this way, lost
14 * information that the register was live at function exit.
15 */
16
17check_r0:
18	prolog
19	movi %r0 1
20	movi %r2 10
21	// on x86 this changes %rax on other arches could use %r0 as temporary
22	divi %r1 %r2 3
23	// %r0 must still be 1
24	retr %r0
25	epilog
26
27check_f0:
28	prolog
29	movi_d %f0 0.5
30	movi_d %f2 10
31	divi_d %f1 %f2 3
32	retr_d %f0
33	epilog
34
35main:
36	prolog
37	calli check_r0
38	retval %r1
39	beqi r0_ok %r1 1
40	calli @abort
41r0_ok:
42	calli check_f0
43	retval_d %f1
44	beqi_d f0_ok %f1 0.5
45	calli @abort
46f0_ok:
47	prepare
48		pushargi ok
49	finishi @puts
50	ret
51	epilog
52