1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
namespace;
include rt;
// native calls from o3 code: lifted into the region as micro-ops, called directly by llvm
extern double sqrt(double);
extern double pow(double, double);
extern double fma(double, double, double);
extern int snprintf9(word *buf, long cap, str fmt, long a, long b, long c, long d, long e, long f) = "snprintf";
extern long labs(long);
fn put_f(x) { asm { x @ #1220 } return 0; }
o3 float norm(int n) {
float acc = 0.0;
for (int i = 1; i <= n; i++) acc = acc + sqrt(i * 1.0) + fma(1.0, 2.0, 0.5);
return acc;
}
o3 int absum(int n) {
int t = 0;
for (int i = 0; i < n; i++) t = t + labs(i - 50);
return t;
}
fn main() {
let buf[16];
let i = 0;
put_f(norm(100)); rt.put_c(32);
put_f(pow(2.0, 0.5)); rt.put_c(32);
rt.put_n(absum(100)); rt.put_c(10);
rt.put_n(snprintf9(buf, 100, b"%ld-%ld-%ld-%ld-%ld-%ld", 1, 2, 3, 4, 5, 6)); rt.put_c(32);
while (i < 11) { rt.put_c(rt.ld8(rt.addr_b(buf) + i)); i++; }
rt.put_c(10);
return 0;
}
|