clarify the purpose of this project
[nyanglibc.git] / io / ttyname_r.s
blobe8e38637238a5c1ca8179fbeae617ed99d54cbc1
1 .text
2 .section .rodata.str1.1,"aMS",@progbits,1
3 .LC0:
4 .string "stdin"
5 .LC1:
6 .string "stdout"
7 .LC2:
8 .string "stderr"
9 .section .text.compat,"ax",@progbits
10 .p2align 4,,15
11 .type getttyname_r, @function
12 getttyname_r:
13 pushq %r15
14 pushq %r14
15 movq %rdi, %r14
16 pushq %r13
17 pushq %r12
18 movq %r8, %r12
19 pushq %rbp
20 pushq %rbx
21 movq %rdx, %rbp
22 subq $200, %rsp
23 movq %rsi, 16(%rsp)
24 movl %ecx, 44(%rsp)
25 call strlen
26 movq %r14, %rdi
27 movq %rax, 24(%rsp)
28 call __opendir
29 testq %rax, %rax
30 je .L19
31 movq %rax, %rbx
32 leaq 48(%rsp), %rax
33 leaq .LC0(%rip), %r13
34 leaq .LC1(%rip), %r15
35 movq %rax, 32(%rsp)
36 .p2align 4,,10
37 .p2align 3
38 .L2:
39 movq %rbx, %rdi
40 call __readdir64
41 testq %rax, %rax
42 je .L22
43 movq 8(%rbp), %rcx
44 cmpq %rcx, (%rax)
45 je .L4
46 movl (%r12), %edx
47 testl %edx, %edx
48 je .L2
49 .L4:
50 leaq 19(%rax), %r8
51 movl $6, %ecx
52 movq %r13, %rdi
53 movq %r8, %rsi
54 repz cmpsb
55 je .L2
56 movl $7, %ecx
57 movq %r8, %rsi
58 movq %r15, %rdi
59 repz cmpsb
60 je .L2
61 leaq .LC2(%rip), %rdi
62 movl $7, %ecx
63 movq %r8, %rsi
64 repz cmpsb
65 je .L2
66 movq %r8, %rdi
67 movq %r8, 8(%rsp)
68 call strlen
69 leaq 1(%rax), %rdx
70 cmpq 16(%rsp), %rdx
71 movq 8(%rsp), %r8
72 ja .L23
73 movq 24(%rsp), %rax
74 movq %r8, %rsi
75 leaq (%r14,%rax), %rdi
76 call __stpncpy
77 movq 32(%rsp), %rsi
78 movb $0, (%rax)
79 movq %r14, %rdi
80 call __stat64
81 testl %eax, %eax
82 movl %eax, %edx
83 jne .L2
84 movq 8(%rbp), %rax
85 cmpq %rax, 56(%rsp)
86 jne .L2
87 movq 0(%rbp), %rax
88 cmpq %rax, 48(%rsp)
89 jne .L2
90 movl 72(%rsp), %eax
91 andl $61440, %eax
92 cmpl $8192, %eax
93 jne .L2
94 movq 40(%rbp), %rax
95 cmpq %rax, 88(%rsp)
96 jne .L2
97 movq %rbx, %rdi
98 movl %edx, 8(%rsp)
99 call __closedir
100 movq __libc_errno@gottpoff(%rip), %rax
101 movl 44(%rsp), %ebx
102 movl 8(%rsp), %edx
103 movl %ebx, %fs:(%rax)
104 jmp .L1
105 .p2align 4,,10
106 .p2align 3
107 .L22:
108 movq %rbx, %rdi
109 call __closedir
110 movq __libc_errno@gottpoff(%rip), %rax
111 movl 44(%rsp), %ebx
112 movl $25, %edx
113 movl %ebx, %fs:(%rax)
114 .L1:
115 addq $200, %rsp
116 movl %edx, %eax
117 popq %rbx
118 popq %rbp
119 popq %r12
120 popq %r13
121 popq %r14
122 popq %r15
124 .p2align 4,,10
125 .p2align 3
126 .L19:
127 movq __libc_errno@gottpoff(%rip), %rax
128 movl $-1, (%r12)
129 movl %fs:(%rax), %edx
130 jmp .L1
131 .L23:
132 movl $-1, (%r12)
133 movq %rbx, %rdi
134 call __closedir
135 movq __libc_errno@gottpoff(%rip), %rax
136 movl $34, %edx
137 movl $34, %fs:(%rax)
138 jmp .L1
139 .size getttyname_r, .-getttyname_r
140 .section .rodata.str1.1
141 .LC3:
142 .string "(unreachable)"
143 .text
144 .p2align 4,,15
145 .globl __ttyname_r
146 .hidden __ttyname_r
147 .type __ttyname_r, @function
148 __ttyname_r:
149 pushq %r15
150 pushq %r14
151 pushq %r13
152 pushq %r12
153 pushq %rbp
154 pushq %rbx
155 subq $424, %rsp
156 testq %rsi, %rsi
157 movl $0, 28(%rsp)
158 je .L59
159 cmpq $9, %rdx
160 jbe .L60
161 movq __libc_errno@gottpoff(%rip), %r13
162 movq %rsi, %rbx
163 leaq 64(%rsp), %rsi
164 movq %rdx, %r12
165 movl %edi, %ebp
166 movl %fs:0(%r13), %r15d
167 call __tcgetattr
168 testl %eax, %eax
169 js .L58
170 leaq 128(%rsp), %r14
171 movl %ebp, %edi
172 movq %r14, %rsi
173 call __fstat64
174 testl %eax, %eax
175 js .L58
176 leaq 32(%rsp), %r8
177 movl $12132, %edx
178 leaq 46(%rsp), %rsi
179 xorl %ecx, %ecx
180 movabsq $7310238724270485551, %rax
181 movw %dx, 44(%rsp)
182 movslq %ebp, %rdi
183 movl $10, %edx
184 movq %r8, 8(%rsp)
185 movq %rax, 32(%rsp)
186 movl $1714382444, 40(%rsp)
187 movb $0, 46(%rsp)
188 call _fitoa_word
189 movq 8(%rsp), %r8
190 leaq -1(%r12), %rdx
191 movb $0, (%rax)
192 movq %rbx, %rsi
193 movq %r8, %rdi
194 call __readlink
195 cmpq $-1, %rax
196 je .L61
197 cmpq $13, %rax
198 movq %rax, %rbp
199 jbe .L35
200 movabsq $7521962890978293032, %rax
201 cmpq %rax, (%rbx)
202 je .L62
203 .L35:
204 movb $0, (%rbx,%rbp)
205 cmpb $47, (%rbx)
206 leaq 272(%rsp), %rdx
207 je .L36
208 .L37:
209 movl $1, %ebp
210 .L32:
211 movabsq $8319397760812278831, %rax
212 movq %rdx, %rsi
213 movq %rbx, %rdi
214 movq %rax, (%rbx)
215 movl $47, %eax
216 movw %ax, 8(%rbx)
217 call __stat64
218 testl %eax, %eax
219 jne .L38
220 movl 296(%rsp), %eax
221 andl $61440, %eax
222 cmpl $16384, %eax
223 je .L63
224 .L38:
225 cmpl $-1, 28(%rsp)
226 movl %r15d, %fs:0(%r13)
227 je .L51
228 leaq 28(%rsp), %r9
229 .L43:
230 subq $5, %r12
231 movq %r9, %r8
232 movb $0, 5(%rbx)
233 movl %r15d, %ecx
234 movq %r14, %rdx
235 movq %r12, %rsi
236 movq %rbx, %rdi
237 movq %r9, 8(%rsp)
238 call getttyname_r
239 cltq
240 movq 8(%rsp), %r9
241 testq %rax, %rax
242 jne .L64
243 .L40:
244 xorl %eax, %eax
245 jmp .L24
246 .p2align 4,,10
247 .p2align 3
248 .L60:
249 movq __libc_errno@gottpoff(%rip), %r13
250 .L31:
251 movl $34, %fs:0(%r13)
252 movl $34, %eax
253 .L24:
254 addq $424, %rsp
255 popq %rbx
256 popq %rbp
257 popq %r12
258 popq %r13
259 popq %r14
260 popq %r15
262 .p2align 4,,10
263 .p2align 3
264 .L58:
265 movl %fs:0(%r13), %eax
266 jmp .L24
267 .p2align 4,,10
268 .p2align 3
269 .L59:
270 movq __libc_errno@gottpoff(%rip), %rax
271 movl $22, %fs:(%rax)
272 movl $22, %eax
273 jmp .L24
274 .p2align 4,,10
275 .p2align 3
276 .L51:
277 movl $1, %edx
278 movl $2, %eax
279 .L41:
280 testl %ebp, %ebp
281 je .L24
282 testb %dl, %dl
283 je .L24
284 movq 168(%rsp), %rdx
285 movq %rdx, %rcx
286 shrq $32, %rdx
287 shrq $8, %rcx
288 andl $-4096, %edx
289 andl $4095, %ecx
290 orl %ecx, %edx
291 subl $136, %edx
292 cmpl $7, %edx
293 ja .L24
294 movl $19, %fs:0(%r13)
295 movl $19, %eax
296 jmp .L24
297 .p2align 4,,10
298 .p2align 3
299 .L61:
300 cmpl $36, %fs:0(%r13)
301 je .L31
302 xorl %ebp, %ebp
303 leaq 272(%rsp), %rdx
304 jmp .L32
305 .p2align 4,,10
306 .p2align 3
307 .L64:
308 cmpl $-1, 28(%rsp)
309 je .L57
310 movb $0, 5(%rbx)
311 movq %r9, %r8
312 movl %r15d, %ecx
313 movq %r14, %rdx
314 movq %r12, %rsi
315 movq %rbx, %rdi
316 movl $1, 28(%rsp)
317 call getttyname_r
318 cltq
319 .L57:
320 testq %rax, %rax
321 setne %dl
322 jmp .L41
323 .p2align 4,,10
324 .p2align 3
325 .L36:
326 movq %rdx, %rsi
327 movq %rbx, %rdi
328 movq %rdx, 8(%rsp)
329 call __stat64
330 testl %eax, %eax
331 movq 8(%rsp), %rdx
332 jne .L37
333 movq 280(%rsp), %rcx
334 cmpq %rcx, 136(%rsp)
335 jne .L37
336 movq 128(%rsp), %rcx
337 cmpq %rcx, 272(%rsp)
338 jne .L37
339 movl 296(%rsp), %ecx
340 andl $61440, %ecx
341 cmpl $8192, %ecx
342 jne .L37
343 movq 168(%rsp), %rcx
344 cmpq %rcx, 312(%rsp)
345 jne .L37
346 jmp .L24
347 .p2align 4,,10
348 .p2align 3
349 .L62:
350 cmpl $1701601889, 8(%rbx)
351 jne .L35
352 cmpb $41, 12(%rbx)
353 jne .L35
354 subq $13, %rbp
355 leaq 13(%rbx), %rsi
356 movq %rbx, %rdi
357 movq %rbp, %rdx
358 call memmove
359 jmp .L35
360 .p2align 4,,10
361 .p2align 3
362 .L63:
363 leaq 28(%rsp), %r9
364 leaq -9(%r12), %rsi
365 movl %r15d, %ecx
366 movq %r14, %rdx
367 movq %rbx, %rdi
368 movq %r9, %r8
369 movq %r9, 8(%rsp)
370 call getttyname_r
371 cltq
372 movq 8(%rsp), %r9
373 testq %rax, %rax
374 je .L40
375 cmpl $-1, 28(%rsp)
376 je .L57
377 jmp .L43
378 .size __ttyname_r, .-__ttyname_r
379 .weak ttyname_r
380 .set ttyname_r,__ttyname_r
381 .hidden memmove
382 .hidden __readlink
383 .hidden _fitoa_word
384 .hidden __fstat64
385 .hidden __tcgetattr
386 .hidden __closedir
387 .hidden __stat64
388 .hidden __stpncpy
389 .hidden __readdir64
390 .hidden __opendir
391 .hidden strlen