clarify the purpose of this project
[nyanglibc.git] / libio / oldfmemopen.shared.s
blob0a3ff13c06bd79d4b1af53d5caa44a816084cb97
1 .text
2 #APP
3 memmove = __GI_memmove
4 memset = __GI_memset
5 memcpy = __GI_memcpy
6 .symver __old_fmemopen,fmemopen@GLIBC_2.2.5
7 #NO_APP
8 .p2align 4,,15
9 .type fmemopen_seek, @function
10 fmemopen_seek:
11 cmpl $1, %edx
12 je .L3
13 cmpl $2, %edx
14 je .L4
15 testl %edx, %edx
16 je .L14
17 .L11:
18 movl $-1, %eax
19 ret
20 .p2align 4,,10
21 .p2align 3
22 .L14:
23 movq (%rsi), %rax
24 .L6:
25 testq %rax, %rax
26 js .L11
27 cmpq %rax, 16(%rdi)
28 jb .L11
29 movq %rax, 24(%rdi)
30 movq %rax, (%rsi)
31 xorl %eax, %eax
32 ret
33 .p2align 4,,10
34 .p2align 3
35 .L4:
36 movl 12(%rdi), %eax
37 testl %eax, %eax
38 jne .L15
39 movq 32(%rdi), %rax
40 .L8:
41 subq (%rsi), %rax
42 jmp .L6
43 .p2align 4,,10
44 .p2align 3
45 .L3:
46 movq (%rsi), %rax
47 addq 24(%rdi), %rax
48 jmp .L6
49 .p2align 4,,10
50 .p2align 3
51 .L15:
52 movq 16(%rdi), %rax
53 jmp .L8
54 .size fmemopen_seek, .-fmemopen_seek
55 .p2align 4,,15
56 .type fmemopen_close, @function
57 fmemopen_close:
58 pushq %rbx
59 movl 8(%rdi), %eax
60 movq %rdi, %rbx
61 testl %eax, %eax
62 je .L17
63 movq (%rdi), %rdi
64 call free@PLT
65 .L17:
66 movq %rbx, %rdi
67 call free@PLT
68 xorl %eax, %eax
69 popq %rbx
70 ret
71 .size fmemopen_close, .-fmemopen_close
72 .p2align 4,,15
73 .type fmemopen_write, @function
74 fmemopen_write:
75 pushq %r12
76 pushq %rbp
77 movq %rdi, %rbp
78 pushq %rbx
79 movl 12(%rdi), %eax
80 movq %rdx, %rbx
81 testl %eax, %eax
82 jne .L27
83 testq %rdx, %rdx
84 jne .L34
85 movl $1, %ecx
86 movl $1, %r12d
87 jmp .L20
88 .p2align 4,,10
89 .p2align 3
90 .L27:
91 xorl %ecx, %ecx
92 xorl %r12d, %r12d
93 .L20:
94 movq 24(%rbp), %rdi
95 movq 16(%rbp), %rax
96 leaq (%rdi,%rbx), %rdx
97 addq %rcx, %rdx
98 cmpq %rax, %rdx
99 jbe .L21
100 movslq %r12d, %rdx
101 addq %rdi, %rdx
102 cmpq %rdx, %rax
103 jbe .L35
104 subq %rdi, %rax
105 subq %rcx, %rax
106 movq %rax, %rbx
107 .L21:
108 addq 0(%rbp), %rdi
109 movq %rbx, %rdx
110 call __GI_memcpy@PLT
111 movq 24(%rbp), %rax
112 addq %rbx, %rax
113 cmpq 32(%rbp), %rax
114 movq %rax, 24(%rbp)
115 ja .L36
116 .L25:
117 movq %rbx, %rax
118 popq %rbx
119 popq %rbp
120 popq %r12
122 .p2align 4,,10
123 .p2align 3
124 .L36:
125 testl %r12d, %r12d
126 movq %rax, 32(%rbp)
127 je .L25
128 movq 0(%rbp), %rdx
129 movb $0, (%rdx,%rax)
130 jmp .L25
131 .p2align 4,,10
132 .p2align 3
133 .L35:
134 movq __libc_errno@gottpoff(%rip), %rax
135 movl $28, %fs:(%rax)
136 xorl %eax, %eax
137 popq %rbx
138 popq %rbp
139 popq %r12
141 .p2align 4,,10
142 .p2align 3
143 .L34:
144 cmpb $1, -1(%rsi,%rdx)
145 sbbq %rcx, %rcx
146 xorl %r12d, %r12d
147 addq $1, %rcx
148 cmpb $0, -1(%rsi,%rdx)
149 setne %r12b
150 jmp .L20
151 .size fmemopen_write, .-fmemopen_write
152 .p2align 4,,15
153 .type fmemopen_read, @function
154 fmemopen_read:
155 pushq %rbp
156 pushq %rbx
157 movq %rdi, %rbp
158 movq %rsi, %rdi
159 movq %rdx, %rbx
160 subq $8, %rsp
161 movq 24(%rbp), %rsi
162 movq 16(%rbp), %rdx
163 leaq (%rsi,%rbx), %rax
164 cmpq %rdx, %rax
165 jbe .L38
166 xorl %eax, %eax
167 cmpq %rdx, %rsi
168 je .L37
169 movq %rdx, %rbx
170 subq %rsi, %rbx
171 .L38:
172 addq 0(%rbp), %rsi
173 movq %rbx, %rdx
174 call __GI_memcpy@PLT
175 movq 24(%rbp), %rax
176 addq %rbx, %rax
177 cmpq 32(%rbp), %rax
178 movq %rax, 24(%rbp)
179 jbe .L40
180 movq %rax, 32(%rbp)
181 .L40:
182 movq %rbx, %rax
183 .L37:
184 addq $8, %rsp
185 popq %rbx
186 popq %rbp
188 .size fmemopen_read, .-fmemopen_read
189 .p2align 4,,15
190 .globl __old_fmemopen
191 .type __old_fmemopen, @function
192 __old_fmemopen:
193 pushq %r14
194 pushq %r13
195 pushq %r12
196 pushq %rbp
197 pushq %rbx
198 subq $48, %rsp
199 testq %rsi, %rsi
200 je .L45
201 movq %rdi, %rbp
202 movl $40, %edi
203 movq %rdx, %r13
204 movq %rsi, %r12
205 call malloc@PLT
206 testq %rax, %rax
207 movq %rax, %rbx
208 je .L56
209 xorl %eax, %eax
210 testq %rbp, %rbp
211 sete %al
212 movl %eax, 8(%rbx)
213 je .L60
214 movq %rbp, %rax
215 negq %rax
216 cmpq %r12, %rax
217 jb .L61
218 movzbl 0(%r13), %r14d
219 movq %rbp, (%rbx)
220 cmpb $119, %r14b
221 je .L62
222 .L51:
223 movq %r12, %rsi
224 movq %rbp, %rdi
225 call __GI_strnlen
226 movq %rax, 32(%rbx)
227 .L49:
228 cmpb $97, %r14b
229 movq %r12, 16(%rbx)
230 je .L63
231 xorl %eax, %eax
232 testb %r14b, %r14b
233 movq $0, 24(%rbx)
234 jne .L53
235 .L54:
236 movl %eax, 12(%rbx)
237 leaq fmemopen_read(%rip), %rax
238 movq %r13, %rsi
239 movq %rbx, %rdi
240 movq %rax, 16(%rsp)
241 leaq fmemopen_write(%rip), %rax
242 movq %rax, 24(%rsp)
243 leaq fmemopen_seek(%rip), %rax
244 movq %rax, 32(%rsp)
245 leaq fmemopen_close(%rip), %rax
246 movq %rax, 40(%rsp)
247 pushq 40(%rsp)
248 pushq 40(%rsp)
249 pushq 40(%rsp)
250 pushq 40(%rsp)
251 call _IO_fopencookie@PLT
252 addq $32, %rsp
253 testq %rax, %rax
254 je .L64
255 .L43:
256 addq $48, %rsp
257 popq %rbx
258 popq %rbp
259 popq %r12
260 popq %r13
261 popq %r14
263 .p2align 4,,10
264 .p2align 3
265 .L63:
266 movq 32(%rbx), %rax
267 movq %rax, 24(%rbx)
268 .L53:
269 xorl %eax, %eax
270 cmpb $98, 1(%r13)
271 sete %al
272 jmp .L54
273 .p2align 4,,10
274 .p2align 3
275 .L60:
276 movq %r12, %rdi
277 call malloc@PLT
278 testq %rax, %rax
279 movq %rax, (%rbx)
280 je .L65
281 movb $0, (%rax)
282 movq $0, 32(%rbx)
283 movzbl 0(%r13), %r14d
284 jmp .L49
285 .p2align 4,,10
286 .p2align 3
287 .L62:
288 movb $0, 0(%rbp)
289 movzbl 0(%r13), %r14d
290 jmp .L51
291 .p2align 4,,10
292 .p2align 3
293 .L61:
294 movq %rbx, %rdi
295 call free@PLT
296 .L45:
297 movq __libc_errno@gottpoff(%rip), %rax
298 movl $22, %fs:(%rax)
299 addq $48, %rsp
300 xorl %eax, %eax
301 popq %rbx
302 popq %rbp
303 popq %r12
304 popq %r13
305 popq %r14
307 .p2align 4,,10
308 .p2align 3
309 .L64:
310 movl 8(%rbx), %edx
311 testl %edx, %edx
312 jne .L66
313 .L55:
314 movq %rbx, %rdi
315 movq %rax, 8(%rsp)
316 call free@PLT
317 movq 8(%rsp), %rax
318 jmp .L43
319 .p2align 4,,10
320 .p2align 3
321 .L56:
322 xorl %eax, %eax
323 jmp .L43
324 .p2align 4,,10
325 .p2align 3
326 .L66:
327 movq (%rbx), %rdi
328 movq %rax, 8(%rsp)
329 call free@PLT
330 movq 8(%rsp), %rax
331 jmp .L55
332 .L65:
333 movq %rbx, %rdi
334 call free@PLT
335 xorl %eax, %eax
336 jmp .L43
337 .size __old_fmemopen, .-__old_fmemopen