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