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