clarify the purpose of this project
[nyanglibc.git] / catgets / open_catalog.s
blobb770312e57e2e0f673e0ee016bd6045c7df3098c
1 .text
2 .p2align 4,,15
3 .globl __open_catalog
4 .hidden __open_catalog
5 .type __open_catalog, @function
6 __open_catalog:
7 pushq %r15
8 pushq %r14
9 pushq %r13
10 pushq %r12
11 movq %rsi, %r13
12 pushq %rbp
13 pushq %rbx
14 movl $47, %esi
15 subq $200, %rsp
16 movq %rdi, 16(%rsp)
17 movq %rdx, 8(%rsp)
18 movq %rcx, 32(%rsp)
19 call strchr
20 testq %rax, %rax
21 jne .L2
22 testq %r13, %r13
23 jne .L132
24 .L2:
25 movq 16(%rsp), %rdi
26 xorl %esi, %esi
27 xorl %eax, %eax
28 call __open_nocancel
29 testl %eax, %eax
30 movl %eax, %ebx
31 js .L4
32 xorl %r14d, %r14d
33 .L5:
34 leaq 48(%rsp), %rsi
35 movl %ebx, %edi
36 call __fstat64
37 testl %eax, %eax
38 js .L130
39 movl 72(%rsp), %eax
40 andl $61440, %eax
41 cmpl $32768, %eax
42 jne .L47
43 movq 96(%rsp), %rsi
44 cmpq $11, %rsi
45 ja .L48
46 .L47:
47 movq __libc_errno@gottpoff(%rip), %rax
48 movl $-1, %ebp
49 movl $22, %fs:(%rax)
50 .L46:
51 movl %ebx, %edi
52 call __close_nocancel
53 movq %r14, %rdi
54 call free@PLT
55 .L1:
56 addq $200, %rsp
57 movl %ebp, %eax
58 popq %rbx
59 popq %rbp
60 popq %r12
61 popq %r13
62 popq %r14
63 popq %r15
64 ret
65 .p2align 4,,10
66 .p2align 3
67 .L132:
68 movzbl 0(%r13), %eax
69 testb %al, %al
70 je .L4
71 xorl %r15d, %r15d
72 xorl %r14d, %r14d
73 .L3:
74 cmpb $58, %al
75 je .L6
76 movzbl 0(%r13), %ebx
77 movq %r13, %r12
78 xorl %ebp, %ebp
79 .p2align 4,,10
80 .p2align 3
81 .L7:
82 cmpb $58, %bl
83 je .L10
84 .L135:
85 testb %bl, %bl
86 je .L10
87 cmpb $37, %bl
88 je .L133
89 leaq 1(%rbp), %r13
90 cmpq %r15, %r13
91 jnb .L134
92 .L38:
93 movb %bl, (%r14,%rbp)
94 movzbl 1(%r12), %ebx
95 addq $1, %r12
96 movq %r13, %rbp
97 cmpb $58, %bl
98 jne .L135
99 .L10:
100 leaq 1(%rbp), %rax
101 cmpq %r15, %rax
102 jnb .L136
103 .L41:
104 testq %rbp, %rbp
105 movb $0, (%r14,%rbp)
106 jne .L42
107 .L44:
108 movzbl 1(%r12), %eax
109 leaq 1(%r12), %r13
110 testb %al, %al
111 jne .L3
112 .p2align 4,,10
113 .p2align 3
114 .L43:
115 movq %r14, %rdi
116 movl $-1, %ebp
117 call free@PLT
118 jmp .L1
119 .p2align 4,,10
120 .p2align 3
121 .L133:
122 movzbl 1(%r12), %eax
123 leaq 2(%r12), %r13
124 cmpb $78, %al
125 je .L13
126 jle .L137
127 cmpb $108, %al
128 je .L69
129 cmpb $116, %al
130 je .L70
131 cmpb $99, %al
132 je .L68
133 .L12:
134 movzbl 2(%r12), %ebx
135 testb %bl, %bl
136 je .L83
137 cmpb $58, %bl
138 movq %r13, %r12
139 jne .L20
140 jmp .L83
141 .p2align 4,,10
142 .p2align 3
143 .L138:
144 cmpb $58, %bl
145 je .L87
146 .L20:
147 addq $1, %r12
148 movzbl (%r12), %ebx
149 testb %bl, %bl
150 jne .L138
151 .L87:
152 xorl %ebp, %ebp
153 jmp .L7
154 .p2align 4,,10
155 .p2align 3
156 .L137:
157 cmpb $37, %al
158 je .L15
159 cmpb $76, %al
160 jne .L12
161 movq 8(%rsp), %rdi
162 call strlen
163 leaq 0(%rbp,%rax), %r11
164 movq %rax, %rdx
165 cmpq %r15, %r11
166 jnb .L139
167 .L24:
168 movq 8(%rsp), %rsi
169 leaq (%r14,%rbp), %rdi
170 movq %r11, 24(%rsp)
171 .L127:
172 call memcpy@PLT
173 movq 24(%rsp), %r11
174 movzbl 2(%r12), %ebx
175 movq %r13, %r12
176 movq %r11, %rbp
177 jmp .L7
178 .p2align 4,,10
179 .p2align 3
180 .L134:
181 cmpq $257, %r15
182 movl $257, %eax
183 movq %r14, %rdi
184 cmovnb %r15, %rax
185 addq %rax, %r15
186 movq %r15, %rsi
187 call realloc@PLT
188 testq %rax, %rax
189 je .L43
190 movq %rax, %r14
191 jmp .L38
192 .p2align 4,,10
193 .p2align 3
194 .L69:
195 movq 8(%rsp), %rbx
196 jmp .L17
197 .p2align 4,,10
198 .p2align 3
199 .L25:
200 addq $1, %rbx
201 movzbl -1(%rbx), %eax
202 movb %al, (%r14,%rbp)
203 movzbl (%rbx), %eax
204 movq %rdx, %rbp
205 testb %al, %al
206 setne %dil
207 cmpb $95, %al
208 setne %sil
209 testb %sil, %dil
210 je .L128
211 cmpb $46, %al
212 je .L128
213 .L17:
214 leaq 1(%rbp), %rdx
215 cmpq %r15, %rdx
216 jb .L25
217 cmpq $257, %r15
218 movl $257, %eax
219 movq %r14, %rdi
220 cmovnb %r15, %rax
221 movq %rdx, 24(%rsp)
222 addq %rax, %r15
223 movq %r15, %rsi
224 call realloc@PLT
225 testq %rax, %rax
226 movq 24(%rsp), %rdx
227 je .L43
228 movq %rax, %r14
229 jmp .L25
230 .p2align 4,,10
231 .p2align 3
232 .L15:
233 leaq 1(%rbp), %rdx
234 cmpq %r15, %rdx
235 jnb .L140
236 .L36:
237 movb $37, (%r14,%rbp)
238 .L128:
239 movzbl 2(%r12), %ebx
240 movq %rdx, %rbp
241 movq %r13, %r12
242 jmp .L7
243 .p2align 4,,10
244 .p2align 3
245 .L68:
246 movq 8(%rsp), %rdx
247 jmp .L19
248 .p2align 4,,10
249 .p2align 3
250 .L141:
251 cmpb $46, %al
252 je .L86
253 movq %rsi, %rdx
254 .L19:
255 movzbl 1(%rdx), %eax
256 leaq 1(%rdx), %rsi
257 testb %al, %al
258 jne .L141
259 .L86:
260 cmpb $46, %al
261 je .L33
262 .L129:
263 movzbl 2(%r12), %ebx
264 movq %r13, %r12
265 jmp .L7
266 .p2align 4,,10
267 .p2align 3
268 .L70:
269 movq 8(%rsp), %rdx
270 jmp .L18
271 .p2align 4,,10
272 .p2align 3
273 .L142:
274 cmpb $95, %al
275 je .L27
276 cmpb $46, %al
277 movq %rsi, %rdx
278 je .L129
279 .L18:
280 movzbl 1(%rdx), %eax
281 leaq 1(%rdx), %rsi
282 testb %al, %al
283 jne .L142
284 .L27:
285 cmpb $95, %al
286 jne .L129
287 leaq 2(%rdx), %rbx
288 jmp .L30
289 .p2align 4,,10
290 .p2align 3
291 .L29:
292 addq $1, %rbx
293 movzbl -1(%rbx), %eax
294 movb %al, (%r14,%rbp)
295 movzbl (%rbx), %eax
296 movq %rdx, %rbp
297 testb %al, %al
298 je .L128
299 cmpb $46, %al
300 je .L128
301 .L30:
302 leaq 1(%rbp), %rdx
303 cmpq %r15, %rdx
304 jb .L29
305 cmpq $257, %r15
306 movl $257, %eax
307 movq %r14, %rdi
308 cmovnb %r15, %rax
309 movq %rdx, 24(%rsp)
310 addq %rax, %r15
311 movq %r15, %rsi
312 call realloc@PLT
313 testq %rax, %rax
314 movq 24(%rsp), %rdx
315 je .L43
316 movq %rax, %r14
317 jmp .L29
318 .p2align 4,,10
319 .p2align 3
320 .L13:
321 movq 16(%rsp), %rdi
322 call strlen
323 leaq 0(%rbp,%rax), %r11
324 movq %rax, %rdx
325 cmpq %r15, %r11
326 jnb .L143
327 .L23:
328 movq %r11, 24(%rsp)
329 leaq (%r14,%rbp), %rdi
330 movq 16(%rsp), %rsi
331 jmp .L127
332 .p2align 4,,10
333 .p2align 3
334 .L6:
335 movq 16(%rsp), %rdi
336 call strlen
337 cmpq %rax, %r15
338 movq %rax, %rdx
339 movq %rax, %rbp
340 jbe .L144
341 .L8:
342 movq 16(%rsp), %rsi
343 movq %r14, %rdi
344 movq %r13, %r12
345 call memcpy@PLT
346 leaq 1(%rbp), %rax
347 cmpq %r15, %rax
348 jb .L41
349 .L136:
350 cmpq $257, %r15
351 movl $257, %eax
352 movq %r14, %rdi
353 cmovnb %r15, %rax
354 addq %rax, %r15
355 movq %r15, %rsi
356 call realloc@PLT
357 testq %rax, %rax
358 je .L43
359 movq %rax, %r14
360 jmp .L41
361 .p2align 4,,10
362 .p2align 3
363 .L42:
364 xorl %esi, %esi
365 xorl %eax, %eax
366 movq %r14, %rdi
367 call __open_nocancel
368 testl %eax, %eax
369 movl %eax, %ebx
370 js .L44
371 jmp .L5
372 .p2align 4,,10
373 .p2align 3
374 .L48:
375 movq 32(%rsp), %r15
376 xorl %r9d, %r9d
377 xorl %edi, %edi
378 movl %ebx, %r8d
379 movl $2, %ecx
380 movl $1, %edx
381 movq %rsi, 48(%r15)
382 call __mmap
383 cmpq $-1, %rax
384 movq %rax, 40(%r15)
385 je .L49
386 movl $0, (%r15)
387 .L50:
388 movl (%rax), %edx
389 cmpl $-1778120482, %edx
390 jne .L145
391 movl 4(%rax), %edx
392 movq 32(%rsp), %rcx
393 movq %rdx, 8(%rcx)
394 movl 8(%rax), %ecx
395 .L60:
396 imulq %rcx, %rdx
397 movq 32(%rsp), %rsi
398 leaq 12(%rax), %r9
399 movq %rcx, 16(%rsi)
400 movq %r9, 24(%rsi)
401 leaq (%rdx,%rdx,2), %rdi
402 xorl %edx, %edx
403 leaq (%rdi,%rdi), %r11
404 cmpq $2, %rdi
405 leaq 12(%rax,%r11,4), %r8
406 movq %r8, 32(%rsi)
407 jbe .L61
408 movl $2, %ecx
409 .p2align 4,,10
410 .p2align 3
411 .L62:
412 movl (%r9,%rcx,4), %esi
413 cmpq %rsi, %rdx
414 cmovb %rsi, %rdx
415 addq $3, %rcx
416 cmpq %rcx, %rdi
417 ja .L62
418 .L61:
419 movq 96(%rsp), %rsi
420 leaq 12(%rdx,%r11), %rcx
421 cmpq %rcx, %rsi
422 jbe .L63
423 leaq (%r8,%rdx), %rcx
424 leaq -13(%rsi,%r11), %rsi
425 cmpb $0, (%rcx)
426 je .L82
427 addq %rsi, %rdx
428 je .L63
429 addq %rcx, %rdx
430 jmp .L64
431 .p2align 4,,10
432 .p2align 3
433 .L65:
434 cmpq %rdx, %rcx
435 je .L63
436 .L64:
437 addq $1, %rcx
438 cmpb $0, (%rcx)
439 jne .L65
440 .L82:
441 xorl %ebp, %ebp
442 jmp .L46
443 .p2align 4,,10
444 .p2align 3
445 .L33:
446 leaq 2(%rdx), %rbx
447 jmp .L35
448 .p2align 4,,10
449 .p2align 3
450 .L34:
451 addq $1, %rbx
452 movzbl -1(%rbx), %eax
453 cmpb $0, (%rbx)
454 movb %al, (%r14,%rbp)
455 movq %rdx, %rbp
456 je .L129
457 .L35:
458 leaq 1(%rbp), %rdx
459 cmpq %r15, %rdx
460 jb .L34
461 cmpq $257, %r15
462 movl $257, %eax
463 movq %r14, %rdi
464 cmovnb %r15, %rax
465 movq %rdx, 24(%rsp)
466 addq %rax, %r15
467 movq %r15, %rsi
468 call realloc@PLT
469 testq %rax, %rax
470 movq 24(%rsp), %rdx
471 je .L43
472 movq %rax, %r14
473 jmp .L34
474 .L83:
475 movq %r13, %r12
476 xorl %ebp, %ebp
477 jmp .L7
478 .L59:
479 movq %rax, %rdi
480 call free@PLT
481 .L130:
482 movl $-1, %ebp
483 jmp .L46
484 .L63:
485 movq 32(%rsp), %rcx
486 movl (%rcx), %edx
487 testl %edx, %edx
488 jne .L59
489 movq 48(%rcx), %rsi
490 movq %rax, %rdi
491 movl $-1, %ebp
492 call __munmap
493 jmp .L46
494 .L140:
495 cmpq $257, %r15
496 movl $257, %eax
497 movq %r14, %rdi
498 cmovnb %r15, %rax
499 movq %rdx, 24(%rsp)
500 addq %rax, %r15
501 movq %r15, %rsi
502 call realloc@PLT
503 testq %rax, %rax
504 movq 24(%rsp), %rdx
505 je .L43
506 movq %rax, %r14
507 jmp .L36
508 .L143:
509 leaq 256(%rax), %rax
510 movq %r14, %rdi
511 movq %r11, 40(%rsp)
512 movq %rdx, 24(%rsp)
513 cmpq %r15, %rax
514 cmovb %r15, %rax
515 addq %rax, %r15
516 movq %r15, %rsi
517 call realloc@PLT
518 testq %rax, %rax
519 movq 24(%rsp), %rdx
520 movq 40(%rsp), %r11
521 je .L43
522 movq %rax, %r14
523 jmp .L23
524 .L139:
525 leaq 256(%rax), %rax
526 movq %r14, %rdi
527 movq %r11, 40(%rsp)
528 movq %rdx, 24(%rsp)
529 cmpq %r15, %rax
530 cmovb %r15, %rax
531 addq %rax, %r15
532 movq %r15, %rsi
533 call realloc@PLT
534 testq %rax, %rax
535 movq 24(%rsp), %rdx
536 movq 40(%rsp), %r11
537 je .L43
538 movq %rax, %r14
539 jmp .L24
540 .L144:
541 leaq 256(%rax), %rax
542 movq %r14, %rdi
543 movq %rdx, 24(%rsp)
544 cmpq %r15, %rax
545 cmovb %r15, %rax
546 addq %rax, %r15
547 movq %r15, %rsi
548 call realloc@PLT
549 testq %rax, %rax
550 movq 24(%rsp), %rdx
551 je .L43
552 movq %rax, %r14
553 jmp .L8
554 .L4:
555 xorl %r14d, %r14d
556 jmp .L43
557 .L49:
558 movq 96(%rsp), %rbp
559 movq %rbp, %rdi
560 movq %rbp, %r12
561 call malloc@PLT
562 movq 32(%rsp), %rcx
563 testq %rax, %rax
564 movq %rax, 40(%rcx)
565 je .L130
566 .L56:
567 movq %rbp, %rsi
568 movq %r12, %rdx
569 movl %ebx, %edi
570 subq %r12, %rsi
571 addq %rax, %rsi
572 call __read_nocancel
573 leaq -1(%rax), %rdx
574 cmpq $-3, %rdx
575 jbe .L52
576 cmpq $-1, %rax
577 jne .L53
578 movq __libc_errno@gottpoff(%rip), %rax
579 cmpl $4, %fs:(%rax)
580 je .L54
581 .L53:
582 movq 32(%rsp), %rax
583 movl $-1, %ebp
584 movq 40(%rax), %rdi
585 call free@PLT
586 jmp .L46
587 .L52:
588 subq %rax, %r12
589 .L54:
590 movq 32(%rsp), %rax
591 testq %r12, %r12
592 movq 40(%rax), %rax
593 je .L55
594 movq 96(%rsp), %rbp
595 jmp .L56
596 .L145:
597 cmpl $-569899882, %edx
598 jne .L63
599 movl 4(%rax), %edx
600 movq 32(%rsp), %rcx
601 bswap %edx
602 movl %edx, %edx
603 movq %rdx, 8(%rcx)
604 movl 8(%rax), %ecx
605 bswap %ecx
606 movl %ecx, %ecx
607 jmp .L60
608 .L55:
609 movq 32(%rsp), %rcx
610 movl $1, (%rcx)
611 jmp .L50
612 .size __open_catalog, .-__open_catalog
613 .hidden __read_nocancel
614 .hidden __munmap
615 .hidden __mmap
616 .hidden strlen
617 .hidden __close_nocancel
618 .hidden __fstat64
619 .hidden __open_nocancel
620 .hidden strchr