clarify the purpose of this project
[nyanglibc.git] / stdio-common / tempname.s
blob9caf314a1646752cf4e28441a4b1a3cd1c97a616
1 .text
2 .p2align 4,,15
3 .type try_nocreate, @function
4 try_nocreate:
5 .LFB69:
6 .cfi_startproc
7 subq $152, %rsp
8 .cfi_def_cfa_offset 160
9 movq %rsp, %rsi
10 call __lstat64
11 testl %eax, %eax
12 movq __libc_errno@gottpoff(%rip), %rax
13 je .L2
14 movl %fs:(%rax), %edx
15 cmpl $75, %edx
16 je .L2
17 xorl %eax, %eax
18 cmpl $2, %edx
19 setne %al
20 addq $152, %rsp
21 .cfi_remember_state
22 .cfi_def_cfa_offset 8
23 negl %eax
24 ret
25 .p2align 4,,10
26 .p2align 3
27 .L2:
28 .cfi_restore_state
29 movl $17, %fs:(%rax)
30 movl $-1, %eax
31 addq $152, %rsp
32 .cfi_def_cfa_offset 8
33 ret
34 .cfi_endproc
35 .LFE69:
36 .size try_nocreate, .-try_nocreate
37 .p2align 4,,15
38 .type try_dir, @function
39 try_dir:
40 .LFB68:
41 .cfi_startproc
42 movl $448, %esi
43 jmp __mkdir
44 .cfi_endproc
45 .LFE68:
46 .size try_dir, .-try_dir
47 .p2align 4,,15
48 .type try_file, @function
49 try_file:
50 .LFB67:
51 .cfi_startproc
52 movl (%rsi), %esi
53 movl $384, %edx
54 xorl %eax, %eax
55 andb $60, %sil
56 orb $-62, %sil
57 jmp __open
58 .cfi_endproc
59 .LFE67:
60 .size try_file, .-try_file
61 .section .rodata.str1.1,"aMS",@progbits,1
62 .LC0:
63 .string "file"
64 .LC1:
65 .string "/tmp"
66 .LC2:
67 .string "TMPDIR"
68 .LC3:
69 .string "%.*s/%.*sXXXXXX"
70 .text
71 .p2align 4,,15
72 .globl __path_search
73 .hidden __path_search
74 .type __path_search, @function
75 __path_search:
76 .LFB66:
77 .cfi_startproc
78 pushq %r15
79 .cfi_def_cfa_offset 16
80 .cfi_offset 15, -16
81 pushq %r14
82 .cfi_def_cfa_offset 24
83 .cfi_offset 14, -24
84 pushq %r13
85 .cfi_def_cfa_offset 32
86 .cfi_offset 13, -32
87 pushq %r12
88 .cfi_def_cfa_offset 40
89 .cfi_offset 12, -40
90 movq %rdi, %r13
91 pushq %rbp
92 .cfi_def_cfa_offset 48
93 .cfi_offset 6, -48
94 pushq %rbx
95 .cfi_def_cfa_offset 56
96 .cfi_offset 3, -56
97 movq %rsi, %r12
98 movq %rdx, %rbx
99 subq $168, %rsp
100 .cfi_def_cfa_offset 224
101 testq %rcx, %rcx
102 je .L33
103 cmpb $0, (%rcx)
104 movq %rcx, %r14
105 jne .L46
106 .L33:
107 testl %r8d, %r8d
108 movl $4, %ebp
109 leaq .LC0(%rip), %r14
110 jne .L47
111 .L16:
112 testq %rbx, %rbx
113 je .L48
114 .L19:
115 movq %rbx, %rdi
116 call strlen
117 cmpq $1, %rax
118 jbe .L34
119 cmpb $47, -1(%rbx,%rax)
120 leaq -1(%rax), %rdx
121 je .L29
122 jmp .L34
123 .p2align 4,,10
124 .p2align 3
125 .L30:
126 cmpb $47, -1(%rbx,%rdx)
127 leaq -1(%rdx), %rdi
128 jne .L28
129 movq %rdi, %rdx
130 .L29:
131 cmpq $1, %rdx
132 jne .L30
133 .L28:
134 leaq 8(%rbp,%rdx), %rax
135 cmpq %r12, %rax
136 ja .L49
137 leaq .LC3(%rip), %rsi
138 movq %r14, %r9
139 movl %ebp, %r8d
140 movq %rbx, %rcx
141 movq %r13, %rdi
142 xorl %eax, %eax
143 call sprintf
144 xorl %eax, %eax
145 .L14:
146 addq $168, %rsp
147 .cfi_remember_state
148 .cfi_def_cfa_offset 56
149 popq %rbx
150 .cfi_def_cfa_offset 48
151 popq %rbp
152 .cfi_def_cfa_offset 40
153 popq %r12
154 .cfi_def_cfa_offset 32
155 popq %r13
156 .cfi_def_cfa_offset 24
157 popq %r14
158 .cfi_def_cfa_offset 16
159 popq %r15
160 .cfi_def_cfa_offset 8
162 .p2align 4,,10
163 .p2align 3
164 .L46:
165 .cfi_restore_state
166 movq %rcx, %rdi
167 movl %r8d, 8(%rsp)
168 movl $5, %ebp
169 call strlen
170 movl 8(%rsp), %r8d
171 cmpq $5, %rax
172 cmovbe %rax, %rbp
173 testl %r8d, %r8d
174 je .L16
175 .L47:
176 leaq .LC2(%rip), %rdi
177 leaq 16(%rsp), %r15
178 call __libc_secure_getenv
179 testq %rax, %rax
180 je .L17
181 movq %r15, %rsi
182 movq %rax, %rdi
183 movq %rax, 8(%rsp)
184 call __stat64
185 testl %eax, %eax
186 jne .L17
187 movl 40(%rsp), %eax
188 movq 8(%rsp), %rdx
189 andl $61440, %eax
190 cmpl $16384, %eax
191 je .L50
192 .p2align 4,,10
193 .p2align 3
194 .L17:
195 testq %rbx, %rbx
196 je .L21
197 movq %r15, %rsi
198 movq %rbx, %rdi
199 call __stat64
200 testl %eax, %eax
201 jne .L21
202 movl 40(%rsp), %eax
203 andl $61440, %eax
204 cmpl $16384, %eax
205 jne .L21
206 jmp .L19
207 .p2align 4,,10
208 .p2align 3
209 .L48:
210 leaq 16(%rsp), %r15
211 .L21:
212 leaq .LC1(%rip), %rdi
213 movq %r15, %rsi
214 call __stat64
215 testl %eax, %eax
216 jne .L25
217 movl 40(%rsp), %eax
218 leaq .LC1(%rip), %rbx
219 movl $4, %edx
220 andl $61440, %eax
221 cmpl $16384, %eax
222 je .L28
223 .L25:
224 movq __libc_errno@gottpoff(%rip), %rax
225 movl $2, %fs:(%rax)
226 movl $-1, %eax
227 jmp .L14
228 .p2align 4,,10
229 .p2align 3
230 .L34:
231 movq %rax, %rdx
232 jmp .L28
233 .L50:
234 movq %rdx, %rbx
235 jmp .L19
236 .L49:
237 movq __libc_errno@gottpoff(%rip), %rax
238 movl $22, %fs:(%rax)
239 movl $-1, %eax
240 jmp .L14
241 .cfi_endproc
242 .LFE66:
243 .size __path_search, .-__path_search
244 .section .rodata.str1.1
245 .LC4:
246 .string "X"
247 .text
248 .p2align 4,,15
249 .globl __gen_tempname
250 .hidden __gen_tempname
251 .type __gen_tempname, @function
252 __gen_tempname:
253 .LFB72:
254 .cfi_startproc
255 pushq %r15
256 .cfi_def_cfa_offset 16
257 .cfi_offset 15, -16
258 pushq %r14
259 .cfi_def_cfa_offset 24
260 .cfi_offset 14, -24
261 movslq %ecx, %rax
262 pushq %r13
263 .cfi_def_cfa_offset 32
264 .cfi_offset 13, -32
265 pushq %r12
266 .cfi_def_cfa_offset 40
267 .cfi_offset 12, -40
268 movq %rdi, %r15
269 pushq %rbp
270 .cfi_def_cfa_offset 48
271 .cfi_offset 6, -48
272 pushq %rbx
273 .cfi_def_cfa_offset 56
274 .cfi_offset 3, -56
275 movslq %esi, %rbx
276 subq $104, %rsp
277 .cfi_def_cfa_offset 160
278 movl %edx, 60(%rsp)
279 leaq tryfunc.8752(%rip), %rdx
280 leaq 64(%rsp), %rcx
281 movq %rdi, 24(%rsp)
282 movq (%rdx,%rax,8), %rsi
283 movq __libc_errno@gottpoff(%rip), %rax
284 shrq $4, %rcx
285 movq %rcx, %r14
286 movq %rcx, 64(%rsp)
287 movl %fs:(%rax), %eax
288 movq %rsi, 16(%rsp)
289 movl %eax, 44(%rsp)
290 leaq try_nocreate(%rip), %rax
291 cmpq %rax, %rsi
292 sete %r9b
293 movb %r9b, 8(%rsp)
294 call strlen
295 leaq 6(%rbx), %rdx
296 cmpq %rdx, %rax
297 jb .L52
298 subq %rbx, %rax
299 leaq .LC4(%rip), %rsi
300 leaq -6(%r15,%rax), %rax
301 movq %rax, %rdi
302 movq %rax, (%rsp)
303 call strspn
304 cmpq $5, %rax
305 movzbl 8(%rsp), %r9d
306 jbe .L52
307 leaq 60(%rsp), %rax
308 leaq letters(%rip), %r15
309 movl $238328, 40(%rsp)
310 xorl %r8d, %r8d
311 movabsq $-821457390474406913, %rbp
312 movabsq $2862933555777941757, %r13
313 movq %rax, 32(%rsp)
314 movl $3037000493, %r12d
315 .p2align 4,,10
316 .p2align 3
317 .L53:
318 xorl %ebx, %ebx
319 jmp .L60
320 .p2align 4,,10
321 .p2align 3
322 .L71:
323 subl $1, %r8d
324 .L56:
325 movq %r14, %rdx
326 movabsq $-8925843906633654007, %rax
327 movq %r14, %rcx
328 shrq %rdx
329 movq (%rsp), %rdi
330 mulq %rdx
331 shrq $4, %rdx
332 movq %rdx, %rax
333 movq %rdx, %r14
334 movq %rdx, 64(%rsp)
335 salq $5, %rax
336 subq %rdx, %rax
337 addq %rax, %rax
338 subq %rax, %rcx
339 movzbl (%r15,%rcx), %eax
340 movb %al, (%rdi,%rbx)
341 addq $1, %rbx
342 cmpq $6, %rbx
343 je .L70
344 .L60:
345 testl %r8d, %r8d
346 jne .L71
347 testb %r9b, %r9b
348 jne .L59
349 .L57:
350 leaq 80(%rsp), %rsi
351 movl $1, %edi
352 call __clock_gettime
353 movq 88(%rsp), %rcx
354 xorq %r14, %rcx
355 imulq %r13, %rcx
356 leaq (%rcx,%r12), %r14
357 cmpq %rbp, %r14
358 movq %r14, 64(%rsp)
359 jbe .L72
360 .L59:
361 leaq 72(%rsp), %rdi
362 movl $1, %edx
363 movl $8, %esi
364 call __getrandom
365 cmpq $8, %rax
366 jne .L57
367 movq 72(%rsp), %r14
368 cmpq %rbp, %r14
369 movq %r14, 64(%rsp)
370 ja .L59
371 .p2align 4,,10
372 .p2align 3
373 .L72:
374 movl $9, %r8d
375 movl $1, %r9d
376 jmp .L56
377 .p2align 4,,10
378 .p2align 3
379 .L70:
380 movb %r9b, 15(%rsp)
381 movl %r8d, 8(%rsp)
382 movq 32(%rsp), %rsi
383 movq 24(%rsp), %rdi
384 movq 16(%rsp), %rax
385 call *%rax
386 testl %eax, %eax
387 movl 8(%rsp), %r8d
388 movzbl 15(%rsp), %r9d
389 jns .L73
390 movq __libc_errno@gottpoff(%rip), %rax
391 cmpl $17, %fs:(%rax)
392 jne .L64
393 subl $1, 40(%rsp)
394 jne .L53
395 .L64:
396 movl $-1, %eax
397 .L51:
398 addq $104, %rsp
399 .cfi_remember_state
400 .cfi_def_cfa_offset 56
401 popq %rbx
402 .cfi_def_cfa_offset 48
403 popq %rbp
404 .cfi_def_cfa_offset 40
405 popq %r12
406 .cfi_def_cfa_offset 32
407 popq %r13
408 .cfi_def_cfa_offset 24
409 popq %r14
410 .cfi_def_cfa_offset 16
411 popq %r15
412 .cfi_def_cfa_offset 8
414 .L73:
415 .cfi_restore_state
416 movq __libc_errno@gottpoff(%rip), %rbx
417 movl 44(%rsp), %esi
418 movl %esi, %fs:(%rbx)
419 addq $104, %rsp
420 .cfi_remember_state
421 .cfi_def_cfa_offset 56
422 popq %rbx
423 .cfi_def_cfa_offset 48
424 popq %rbp
425 .cfi_def_cfa_offset 40
426 popq %r12
427 .cfi_def_cfa_offset 32
428 popq %r13
429 .cfi_def_cfa_offset 24
430 popq %r14
431 .cfi_def_cfa_offset 16
432 popq %r15
433 .cfi_def_cfa_offset 8
435 .L52:
436 .cfi_restore_state
437 movq __libc_errno@gottpoff(%rip), %rax
438 movl $22, %fs:(%rax)
439 movl $-1, %eax
440 jmp .L51
441 .cfi_endproc
442 .LFE72:
443 .size __gen_tempname, .-__gen_tempname
444 .section .data.rel.ro.local,"aw",@progbits
445 .align 16
446 .type tryfunc.8752, @object
447 .size tryfunc.8752, 24
448 tryfunc.8752:
449 .quad try_file
450 .quad try_dir
451 .quad try_nocreate
452 .section .rodata.str1.32,"aMS",@progbits,1
453 .align 32
454 .type letters, @object
455 .size letters, 63
456 letters:
457 .string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
458 .hidden __getrandom
459 .hidden __clock_gettime
460 .hidden strspn
461 .hidden __stat64
462 .hidden __libc_secure_getenv
463 .hidden sprintf
464 .hidden strlen
465 .hidden __open
466 .hidden __mkdir
467 .hidden __lstat64