clarify the purpose of this project
[nyanglibc.git] / io / getcwd.s
blob149cdf7733afdb46145cf5cb73906c817d3eba8e
1 .text
2 .section .rodata.str1.1,"aMS",@progbits,1
3 .LC0:
4 .string "."
5 .LC1:
6 .string "/"
7 .LC2:
8 .string ".."
9 .section .rodata.str1.8,"aMS",@progbits,1
10 .align 8
11 .LC3:
12 .string "../sysdeps/unix/sysv/linux/getcwd.c"
13 .align 8
14 .LC4:
15 .string "errno != ERANGE || buf != NULL || size != 0"
16 .text
17 .p2align 4,,15
18 .globl __getcwd
19 .hidden __getcwd
20 .type __getcwd, @function
21 __getcwd:
22 pushq %r15
23 pushq %r14
24 pushq %r13
25 pushq %r12
26 pushq %rbp
27 pushq %rbx
28 movq %rdi, %rbx
29 subq $264, %rsp
30 testq %rsi, %rsi
31 movq %rsi, 24(%rsp)
32 jne .L2
33 testq %rdi, %rdi
34 jne .L100
35 call __getpagesize
36 movl $4096, %esi
37 cmpl $4096, %eax
38 cmovge %eax, %esi
39 movslq %esi, %rsi
40 .L5:
41 movq %rsi, %rdi
42 movq %rsi, 8(%rsp)
43 call malloc@PLT
44 testq %rax, %rax
45 movq %rax, %r15
46 movq 8(%rsp), %rsi
47 jne .L6
48 .p2align 4,,10
49 .p2align 3
50 .L101:
51 xorl %r15d, %r15d
52 .L1:
53 addq $264, %rsp
54 movq %r15, %rax
55 popq %rbx
56 popq %rbp
57 popq %r12
58 popq %r13
59 popq %r14
60 popq %r15
61 ret
62 .p2align 4,,10
63 .p2align 3
64 .L2:
65 testq %rdi, %rdi
66 movq 24(%rsp), %rsi
67 je .L5
68 movq %rdi, %r15
69 .L6:
70 movq %r15, %rdi
71 movl $79, %eax
72 #APP
73 # 81 "../sysdeps/unix/sysv/linux/getcwd.c" 1
74 syscall
76 # 0 "" 2
77 #NO_APP
78 cmpq $-4096, %rax
79 ja .L103
80 cmpl $0, %eax
81 jle .L9
82 testq %rbx, %rbx
83 sete 70(%rsp)
84 cmpq $0, 24(%rsp)
85 movzbl 70(%rsp), %ecx
86 sete %dl
87 andl %ecx, %edx
88 cmpb $47, (%r15)
89 je .L104
90 testb %dl, %dl
91 jne .L105
92 .L15:
93 cmpq $0, 24(%rsp)
94 jne .L54
95 .L100:
96 movq __libc_errno@gottpoff(%rip), %rax
97 xorl %r15d, %r15d
98 movl $22, %fs:(%rax)
99 jmp .L1
100 .p2align 4,,10
101 .p2align 3
102 .L105:
103 movq %r15, %rdi
104 call free@PLT
105 movl $4096, %edi
106 call malloc@PLT
107 testq %rax, %rax
108 movq %rax, %r15
109 movq $0, 40(%rsp)
110 je .L16
111 movq $4096, 48(%rsp)
112 .L17:
113 movq 48(%rsp), %rax
114 leaq 112(%rsp), %rsi
115 leaq .LC0(%rip), %rdi
116 movq %rsi, 8(%rsp)
117 leaq (%r15,%rax), %rbx
118 leaq -1(%rbx), %rax
119 movb $0, -1(%rbx)
120 movq %rax, 72(%rsp)
121 call __lstat64
122 testl %eax, %eax
123 js .L99
124 movq 112(%rsp), %rax
125 movq 8(%rsp), %rsi
126 leaq .LC1(%rip), %rdi
127 movq %rax, 16(%rsp)
128 movq 120(%rsp), %rax
129 movq %rax, %r14
130 call __lstat64
131 testl %eax, %eax
132 js .L99
133 movq 112(%rsp), %rax
134 cmpq %rax, 16(%rsp)
135 movq %r14, %rcx
136 movq 120(%rsp), %rdi
137 movq %rax, 80(%rsp)
138 setne %dl
139 cmpq %rdi, %r14
140 movq %rdi, 88(%rsp)
141 setne %al
142 orb %al, %dl
143 movb %dl, 71(%rsp)
144 je .L21
145 movq __libc_errno@gottpoff(%rip), %r12
146 movq %r15, 56(%rsp)
147 xorl %ebp, %ebp
148 movl $-100, %r14d
149 movq %rcx, %r15
150 .L82:
151 leaq .LC2(%rip), %rsi
152 xorl %edx, %edx
153 movl %r14d, %edi
154 xorl %eax, %eax
155 call __openat64
156 testl %eax, %eax
157 movl %eax, %r14d
158 js .L22
159 movq 8(%rsp), %rsi
160 movl %eax, %edi
161 call __fstat64
162 testl %eax, %eax
163 jne .L23
164 testq %rbp, %rbp
165 je .L27
166 movq %rbp, %rdi
167 call __closedir
168 testl %eax, %eax
169 jne .L95
170 .L27:
171 movq 112(%rsp), %rax
172 movl %r14d, %edi
173 movq %rax, 32(%rsp)
174 movq 120(%rsp), %rax
175 movq %rax, 96(%rsp)
176 call __fdopendir
177 testq %rax, %rax
178 movq %rax, %rbp
179 je .L95
180 movzbl 71(%rsp), %r13d
181 .p2align 4,,10
182 .p2align 3
183 .L26:
184 movq %rbp, %rdi
185 movl $0, %fs:(%r12)
186 call __readdir64
187 testq %rax, %rax
188 je .L106
189 cmpb $46, 19(%rax)
190 je .L51
191 .L32:
192 testb %r13b, %r13b
193 je .L34
194 cmpq %r15, (%rax)
195 movq 16(%rsp), %rsi
196 sete %dl
197 cmpq %rsi, 32(%rsp)
198 setne %cl
199 orb %cl, %dl
200 je .L26
201 movl %edx, %r13d
202 .L34:
203 leaq 19(%rax), %rbx
204 movq 8(%rsp), %rdx
205 movl $256, %ecx
206 movl %r14d, %edi
207 movq %rbx, %rsi
208 call __fstatat64
209 testl %eax, %eax
210 jne .L26
211 movl 136(%rsp), %eax
212 andl $61440, %eax
213 cmpl $16384, %eax
214 jne .L26
215 movq 16(%rsp), %rax
216 cmpq %rax, 112(%rsp)
217 jne .L26
218 cmpq %r15, 120(%rsp)
219 jne .L26
220 movq 72(%rsp), %r13
221 subq 56(%rsp), %r13
222 movq %rbx, %rdi
223 call strlen
224 movq %rax, %rcx
225 cmpq %rax, %r13
226 ja .L35
227 cmpq $0, 24(%rsp)
228 jne .L107
229 movq 48(%rsp), %rax
230 movq %rcx, 104(%rsp)
231 cmpq %rax, %rcx
232 movq %rax, %r15
233 cmovnb %rcx, %r15
234 addq %rax, %r15
235 jc .L39
236 movq 56(%rsp), %rdi
237 movq %r15, %rsi
238 call realloc@PLT
239 testq %rax, %rax
240 movq %rax, %r8
241 je .L39
242 movq 48(%rsp), %rax
243 movq %r13, %rdi
244 leaq (%r8,%r13), %rsi
245 movq %r8, 16(%rsp)
246 subq %rax, %rdi
247 subq %r13, %rax
248 addq %r15, %rdi
249 movq %rax, %rdx
250 addq %r8, %rdi
251 call memcpy@PLT
252 movq 16(%rsp), %r8
253 movq 104(%rsp), %rcx
254 movq %rax, 72(%rsp)
255 movq %r15, 48(%rsp)
256 movq %r8, 56(%rsp)
257 .L35:
258 movq 72(%rsp), %r8
259 movq %rbx, %rsi
260 movq %rcx, %rdx
261 subq %rcx, %r8
262 movq %r8, %rdi
263 call memcpy@PLT
264 movq %rax, %r8
265 leaq -1(%rax), %rax
266 movq 96(%rsp), %rbx
267 movb $47, -1(%r8)
268 movq %rax, 72(%rsp)
269 movq 32(%rsp), %rax
270 cmpq %rax, 80(%rsp)
271 movq %rbx, %r15
272 movq %rax, 16(%rsp)
273 jne .L82
274 cmpq %rbx, 88(%rsp)
275 jne .L82
276 movq %rbp, %rdi
277 movq 56(%rsp), %r15
278 call __closedir
279 testl %eax, %eax
280 jne .L41
281 movq 48(%rsp), %rax
282 leaq (%r15,%rax), %rbx
283 .L21:
284 movq 48(%rsp), %rax
285 leaq -1(%r15,%rax), %rax
286 cmpq 72(%rsp), %rax
287 je .L108
288 .L42:
289 movq 72(%rsp), %rsi
290 movq %r15, %rdi
291 subq %rsi, %rbx
292 movq %rbx, %rdx
293 call memmove
294 cmpq $0, 24(%rsp)
295 jne .L43
296 cmpq 48(%rsp), %rbx
297 jnb .L1
298 movq %rbx, %rsi
299 movq %r15, %rdi
300 call realloc@PLT
301 movq %rax, 40(%rsp)
302 .L43:
303 movq 40(%rsp), %rax
304 testq %rax, %rax
305 cmovne %rax, %r15
306 jmp .L1
307 .p2align 4,,10
308 .p2align 3
309 .L106:
310 movl %fs:(%r12), %ebx
311 testl %ebx, %ebx
312 jne .L97
313 testb %r13b, %r13b
314 je .L97
315 movq %rbp, %rdi
316 call __rewinddir
317 movq %rbp, %rdi
318 call __readdir64
319 testq %rax, %rax
320 je .L109
321 xorl %r13d, %r13d
322 cmpb $46, 19(%rax)
323 jne .L34
324 .L51:
325 cmpb $0, 20(%rax)
326 je .L26
327 cmpw $46, 20(%rax)
328 jne .L32
329 jmp .L26
330 .p2align 4,,10
331 .p2align 3
332 .L97:
333 movq 56(%rsp), %r15
334 .L29:
335 testl %ebx, %ebx
336 jne .L31
337 movl $2, %fs:(%r12)
338 movl $2, %ebx
339 .L31:
340 movq %rbp, %rdi
341 call __closedir
342 .L19:
343 cmpq $0, 40(%rsp)
344 je .L110
345 .L46:
346 movl %ebx, %fs:(%r12)
347 .L16:
348 cmpq $0, 24(%rsp)
349 je .L101
350 cmpb $0, 70(%rsp)
351 je .L101
352 movq 40(%rsp), %rdi
353 call free@PLT
354 jmp .L101
355 .p2align 4,,10
356 .p2align 3
357 .L9:
358 je .L13
359 movq __libc_errno@gottpoff(%rip), %r12
360 movl %fs:(%r12), %eax
361 .L8:
362 cmpl $36, %eax
363 je .L13
364 cmpl $34, %eax
365 je .L111
366 .L48:
367 testq %rbx, %rbx
368 jne .L101
369 movq %r15, %rdi
370 xorl %r15d, %r15d
371 call free@PLT
372 jmp .L1
373 .p2align 4,,10
374 .p2align 3
375 .L104:
376 testb %dl, %dl
377 jne .L112
378 .L11:
379 testq %rbx, %rbx
380 cmovne %rbx, %r15
381 jmp .L1
382 .p2align 4,,10
383 .p2align 3
384 .L54:
385 movq 24(%rsp), %rax
386 movq %r15, 40(%rsp)
387 movq %rax, 48(%rsp)
388 jmp .L17
389 .p2align 4,,10
390 .p2align 3
391 .L13:
392 testq %rbx, %rbx
393 sete 70(%rsp)
394 cmpq $0, 24(%rsp)
395 movzbl 70(%rsp), %eax
396 sete %dl
397 andl %eax, %edx
398 testb %dl, %dl
399 je .L15
400 jmp .L105
401 .p2align 4,,10
402 .p2align 3
403 .L103:
404 movq __libc_errno@gottpoff(%rip), %r12
405 negl %eax
406 movl %eax, %fs:(%r12)
407 jmp .L8
408 .p2align 4,,10
409 .p2align 3
410 .L110:
411 movq %r15, %rdi
412 call free@PLT
413 jmp .L46
414 .p2align 4,,10
415 .p2align 3
416 .L99:
417 movq __libc_errno@gottpoff(%rip), %r12
418 movl %fs:(%r12), %ebx
419 jmp .L19
420 .p2align 4,,10
421 .p2align 3
422 .L112:
423 movslq %eax, %rsi
424 call realloc@PLT
425 movq %rax, %rbx
426 jmp .L11
427 .p2align 4,,10
428 .p2align 3
429 .L111:
430 testq %rbx, %rbx
431 jne .L48
432 cmpq $0, 24(%rsp)
433 jne .L48
434 leaq __PRETTY_FUNCTION__.9119(%rip), %rcx
435 leaq .LC3(%rip), %rsi
436 leaq .LC4(%rip), %rdi
437 movl $124, %edx
438 call __assert_fail
439 .p2align 4,,10
440 .p2align 3
441 .L109:
442 movq 56(%rsp), %r15
443 movl %fs:(%r12), %ebx
444 jmp .L29
445 .L95:
446 movq 56(%rsp), %r15
447 movl %fs:(%r12), %ebx
448 .L45:
449 movl %r14d, %edi
450 call __close_nocancel
451 jmp .L19
452 .L22:
453 testq %rbp, %rbp
454 movq 56(%rsp), %r15
455 movl %fs:(%r12), %ebx
456 je .L19
457 jmp .L31
458 .p2align 4,,10
459 .p2align 3
460 .L23:
461 testq %rbp, %rbp
462 movq 56(%rsp), %r15
463 movl %fs:(%r12), %ebx
464 je .L45
465 movq %rbp, %rdi
466 call __closedir
467 jmp .L45
468 .p2align 4,,10
469 .p2align 3
470 .L108:
471 subq $1, 72(%rsp)
472 movb $47, -1(%rax)
473 jmp .L42
474 .L41:
475 movl %fs:(%r12), %ebx
476 jmp .L19
477 .L39:
478 movq 56(%rsp), %r15
479 movl $12, %fs:(%r12)
480 movl $12, %ebx
481 jmp .L31
482 .L107:
483 movq 56(%rsp), %r15
484 movl $34, %fs:(%r12)
485 movl $34, %ebx
486 jmp .L31
487 .size __getcwd, .-__getcwd
488 .weak getcwd
489 .set getcwd,__getcwd
490 .section .rodata.str1.8
491 .align 8
492 .type __PRETTY_FUNCTION__.9119, @object
493 .size __PRETTY_FUNCTION__.9119, 9
494 __PRETTY_FUNCTION__.9119:
495 .string "__getcwd"
496 .hidden __close_nocancel
497 .hidden __assert_fail
498 .hidden __rewinddir
499 .hidden memmove
500 .hidden strlen
501 .hidden __fstatat64
502 .hidden __readdir64
503 .hidden __fdopendir
504 .hidden __closedir
505 .hidden __fstat64
506 .hidden __openat64
507 .hidden __lstat64
508 .hidden __getpagesize