summary refs log tree commit diff
path: root/test/cprime.ssa
blob: 1ca60e18890fed91e861fc085bc79b1771d20db3 (plain) (blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# generated by Andrew Chambers'
# compiler from the C program
# following in comments

function w $main() {
@start
	%v0 =l alloc8 4
	%v1 =l alloc8 4
	%v2 =l alloc8 4
	%v3 =l alloc8 4
	%v4 =l alloc8 4
	storew 5, %v1
	storew 11, %v2
	storew 12, %v3
@L0
	%v5 =w loadw %v1
	%v6 =w cnew %v5, 201
	jnz %v6, @L8, @L1
@L8
	storew 1, %v4
	%v7 =w loadw %v3
	%v8 =w rem %v7, 2
	%v9 =w ceqw %v8, 0
	jnz %v9, @L9, @L5
@L9
	storew 0, %v4
@L5
	storew 3, %v0
@L2
	%v10 =w loadw %v0
	%v11 =w loadw %v3
	%v12 =w csltw %v10, %v11
	jnz %v12, @L10, @L3
@L10
	%v13 =w loadw %v3
	%v14 =w loadw %v0
	%v15 =w rem %v13, %v14
	%v16 =w ceqw %v15, 0
	jnz %v16, @L11, @L4
@L11
	storew 0, %v4
	jmp @L3
@L4
	%v17 =w loadw %v0
	%v18 =w add %v17, 2
	storew %v18, %v0
	jmp @L2
@L3
	%v19 =w loadw %v4
	jnz %v19, @L12, @L6
@L12
	%v20 =w loadw %v3
	storew %v20, %v2
	%v21 =w loadw %v1
	%v22 =w add %v21, 1
	storew %v22, %v1
@L6
	%v23 =w loadw %v3
	%v24 =w add %v23, 1
	storew %v24, %v3
	jmp @L0
@L1
	%v25 =w loadw %v2
	%v26 =w cnew %v25, 1229
	jnz %v26, @L13, @L7
@L13
	ret 1
@L7
	ret 0
@end
	ret 0
}

# int
# main()
# {
#         int i, n, p, next, isprime;
#
#         n = 5;
#         p = 11;
#         next = 12;
#         while(n != 201) {
#                 isprime = 1;
#                 if(next % 2 == 0) {
#                         isprime = 0;
#                 } else {
#                         for(i = 3; i < next; i = i + 2) {
#                                 if(next % i == 0) {
#                                         isprime = 0;
#                                         break;
#                                 }
#                         }
#                 }
#                 if(isprime) {
#                         p = next;
#                         n = n + 1;
#                 }
#                 next = next + 1;
#         }
#         if(p != 1229)
#                 return 1;
#         return 0;
# }