-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpureconst-test.s
279 lines (263 loc) · 4.54 KB
/
pureconst-test.s
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
.section __TEXT,__text,regular,pure_instructions
.globl _callfunc__foo_pure
.align 4, 0x90
_callfunc__foo_pure:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
call _foo_pure
imull $100, %eax, %eax
addl $8, %esp
popl %ebp
ret
.globl _callfunc__bar_pure
.align 4, 0x90
_callfunc__bar_pure:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
pushl %esi
subl $12, %esp
call L1$pb
L1$pb:
popl %eax
movl %eax, -20(%ebp)
xorl %esi, %esi
movl $1, %edi
movl _barc-L1$pb(%eax), %eax
movl %eax, -16(%ebp)
.align 4, 0x90
LBB1_1:
movl -16(%ebp), %eax
leal (%eax,%edi), %ebx
call _bar_pure
movl -20(%ebp), %ecx
movl %ebx, _barc-L1$pb(%ecx)
addl %eax, %esi
incl %edi
cmpl $101, %edi
jne LBB1_1
movl %esi, %eax
addl $12, %esp
popl %esi
popl %edi
popl %ebx
popl %ebp
ret
.globl _callfunc__foo_const
.align 4, 0x90
_callfunc__foo_const:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
call _foo_const
imull $100, %eax, %eax
addl $8, %esp
popl %ebp
ret
.globl _callfunc__bar_const
.align 4, 0x90
_callfunc__bar_const:
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
call L3$pb
L3$pb:
popl %esi
movl _barc-L3$pb(%esi), %edi
addl $100, %edi
call _bar_const
movl %edi, _barc-L3$pb(%esi)
imull $100, %eax, %eax
popl %esi
popl %edi
popl %ebp
ret
.globl _callfunc__bar2_const
.align 4, 0x90
_callfunc__bar2_const:
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
subl $16, %esp
call L4$pb
L4$pb:
popl %esi
movl _barc-L4$pb(%esi), %edi
leal _barc-L4$pb(%esi), %eax
movl %eax, (%esp)
addl $100, %edi
call _bar2_const
movl %edi, _barc-L4$pb(%esi)
imull $100, %eax, %eax
addl $16, %esp
popl %esi
popl %edi
popl %ebp
ret
.globl _callfunc__bar2_pure
.align 4, 0x90
_callfunc__bar2_pure:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
pushl %esi
subl $12, %esp
call L5$pb
L5$pb:
popl %esi
xorl %edi, %edi
movl $1, %ebx
movl _barc-L5$pb(%esi), %eax
movl %eax, -20(%ebp)
.align 4, 0x90
LBB5_1:
leal _barc-L5$pb(%esi), %ecx
movl %ecx, (%esp)
movl -20(%ebp), %eax
leal (%eax,%ebx), %eax
movl %eax, -16(%ebp)
call _bar2_pure
movl -16(%ebp), %ecx
movl %ecx, _barc-L5$pb(%esi)
addl %eax, %edi
incl %ebx
cmpl $101, %ebx
jne LBB5_1
movl %edi, %eax
addl $12, %esp
popl %esi
popl %edi
popl %ebx
popl %ebp
ret
.globl _callfunc__bar3_const
.align 4, 0x90
_callfunc__bar3_const:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
call L6$pb
L6$pb:
popl %eax
leal _barc-L6$pb(%eax), %eax
movl %eax, (%esp)
call _bar3_const
imull $100, %eax, %eax
addl $8, %esp
popl %ebp
ret
.globl _main
.align 4, 0x90
_main:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
pushl %esi
subl $12, %esp
call L7$pb
L7$pb:
popl %esi
call _foo_pure
imull $100, %eax, %eax
movl %eax, 4(%esp)
leal L_.str-L7$pb(%esi), %eax
movl %eax, (%esp)
call _printf
movl $0, _barc-L7$pb(%esi)
xorl %edi, %edi
movl $1, %ebx
.align 4, 0x90
LBB7_1:
call _bar_pure
addl %eax, %edi
movl %ebx, _barc-L7$pb(%esi)
incl %ebx
cmpl $101, %ebx
jne LBB7_1
movl %edi, 4(%esp)
leal L_.str1-L7$pb(%esi), %ecx
movl %ecx, (%esp)
call _printf
movl $0, _barc-L7$pb(%esi)
call _foo_const
imull $100, %eax, %eax
movl %eax, 4(%esp)
leal L_.str2-L7$pb(%esi), %eax
movl %eax, (%esp)
call _printf
call _bar_const
movl $100, _barc-L7$pb(%esi)
imull $100, %eax, %eax
movl %eax, 4(%esp)
leal L_.str3-L7$pb(%esi), %eax
movl %eax, (%esp)
call _printf
leal _barc-L7$pb(%esi), %ecx
movl %ecx, (%esp)
call _bar2_const
movl $100, _barc-L7$pb(%esi)
imull $100, %eax, %eax
movl %eax, 4(%esp)
leal L_.str4-L7$pb(%esi), %eax
movl %eax, (%esp)
call _printf
movl $0, _barc-L7$pb(%esi)
xorl %edi, %edi
movl $1, %ebx
.align 4, 0x90
LBB7_3:
leal _barc-L7$pb(%esi), %ecx
movl %ecx, (%esp)
call _bar2_pure
addl %eax, %edi
movl %ebx, _barc-L7$pb(%esi)
incl %ebx
cmpl $101, %ebx
jne LBB7_3
movl %edi, 4(%esp)
leal L_.str5-L7$pb(%esi), %ecx
movl %ecx, (%esp)
call _printf
movl $0, _barc-L7$pb(%esi)
leal _barc-L7$pb(%esi), %ecx
movl %ecx, (%esp)
call _bar3_const
imull $100, %eax, %eax
movl %eax, 4(%esp)
leal L_.str6-L7$pb(%esi), %eax
movl %eax, (%esp)
call _printf
movl $0, _barc-L7$pb(%esi)
xorl %eax, %eax
addl $12, %esp
popl %esi
popl %edi
popl %ebx
popl %ebp
ret
.globl _barc
.zerofill __DATA,__common,_barc,4,2
.section __TEXT,__cstring,cstring_literals
L_.str:
.asciz "foo_pure = %i\n"
L_.str1:
.asciz "bar_pure = %i\n"
L_.str2:
.asciz "foo_const = %i\n"
L_.str3:
.asciz "bar_const = %i\n"
.align 4
L_.str4:
.asciz "bar2_const = %i\n"
L_.str5:
.asciz "bar2_pure = %i\n"
.align 4
L_.str6:
.asciz "bar3_const = %i\n"
.subsections_via_symbols