clarify the purpose of this project
[nyanglibc.git] / stdlib / msort.shared.s
blob3e725ba77f5baeea82bad0429707bba1886c7f16
1 .text
2 #APP
3 memmove = __GI_memmove
4 memset = __GI_memset
5 memcpy = __GI_memcpy
6 #NO_APP
7 .p2align 4,,15
8 .type msort_with_tmp.part.0, @function
9 msort_with_tmp.part.0:
10 .LFB49:
11 pushq %r15
12 pushq %r14
13 movq %rdx, %rax
14 pushq %r13
15 pushq %r12
16 movq %rdx, %r13
17 pushq %rbp
18 pushq %rbx
19 shrq %r13
20 subq %r13, %rax
21 movq %rdi, %r12
22 subq $56, %rsp
23 movq (%rdi), %r8
24 movq %rax, %rbx
25 movq %rsi, 24(%rsp)
26 movq %rdx, 40(%rsp)
27 imulq %r13, %r8
28 cmpq $1, %r13
29 leaq (%rsi,%r8), %r14
30 ja .L66
31 .L2:
32 cmpq $1, %rbx
33 ja .L67
34 .L3:
35 movq (%r12), %rax
36 testq %rbx, %rbx
37 movq 32(%r12), %r15
38 movq 24(%rsp), %rbp
39 movq %rax, (%rsp)
40 movq 16(%r12), %rax
41 movq %rax, 8(%rsp)
42 movq 24(%r12), %rax
43 movq %rax, 16(%rsp)
44 setne %al
45 testq %r13, %r13
46 setne %dl
47 andl %edx, %eax
48 movq 8(%r12), %rdx
49 cmpq $1, %rdx
50 je .L5
51 jb .L6
52 cmpq $2, %rdx
53 je .L7
54 cmpq $3, %rdx
55 jne .L4
56 testb %al, %al
57 jne .L9
58 .p2align 4,,10
59 .p2align 3
60 .L10:
61 testq %r13, %r13
62 jne .L68
63 .L32:
64 movq 40(%rsp), %rdx
65 movq 32(%r12), %rsi
66 movq 24(%rsp), %rdi
67 subq %rbx, %rdx
68 imulq (%rsp), %rdx
69 addq $56, %rsp
70 popq %rbx
71 popq %rbp
72 popq %r12
73 popq %r13
74 popq %r14
75 popq %r15
76 jmp __GI_memcpy@PLT
77 .p2align 4,,10
78 .p2align 3
79 .L70:
80 movq %r10, %r15
81 .p2align 4,,10
82 .p2align 3
83 .L7:
84 testq %r13, %r13
85 je .L10
86 testq %rbx, %rbx
87 je .L10
88 movq (%rsp), %rax
89 movq 16(%rsp), %rdx
90 movq %r14, %rsi
91 movq %rbp, %rdi
92 leaq (%r15,%rax), %r10
93 movq 8(%rsp), %rax
94 movq %r10, 32(%rsp)
95 call *%rax
96 testl %eax, %eax
97 movq 32(%rsp), %r10
98 jle .L69
99 movq (%rsp), %rax
100 movq %r14, %rsi
101 subq $1, %rbx
102 addq %rax, %r14
103 .L20:
104 cmpq %r10, %r15
105 jnb .L70
106 .p2align 4,,10
107 .p2align 3
108 .L21:
109 movq %r15, %rdi
110 movsq
111 cmpq %rdi, %r10
112 movq %rdi, %r15
113 ja .L21
114 movq %r10, %r15
115 jmp .L7
116 .p2align 4,,10
117 .p2align 3
118 .L25:
119 movq (%r14), %rax
120 subq $1, %rbx
121 addq $8, %r14
122 movq %rax, (%r15)
123 .L26:
124 addq $8, %r15
125 testq %r13, %r13
126 je .L10
127 testq %rbx, %rbx
128 je .L10
129 .L9:
130 movq 16(%rsp), %rdx
131 movq (%r14), %rsi
132 movq 0(%rbp), %rdi
133 movq 8(%rsp), %rax
134 call *%rax
135 testl %eax, %eax
136 jg .L25
137 movq 0(%rbp), %rax
138 subq $1, %r13
139 addq $8, %rbp
140 movq %rax, (%r15)
141 jmp .L26
142 .p2align 4,,10
143 .p2align 3
144 .L71:
145 movq %rbp, %rsi
146 movq %r15, %rdi
147 subq $1, %r13
148 call __GI_mempcpy@PLT
149 addq (%rsp), %rbp
150 movq %rax, %r15
151 .L4:
152 testq %r13, %r13
153 je .L10
154 .L72:
155 testq %rbx, %rbx
156 je .L10
157 movq 16(%rsp), %rdx
158 movq %r14, %rsi
159 movq %rbp, %rdi
160 movq 8(%rsp), %rax
161 call *%rax
162 testl %eax, %eax
163 movq (%rsp), %rdx
164 jle .L71
165 movq %r14, %rsi
166 movq %r15, %rdi
167 subq $1, %rbx
168 call __GI_mempcpy@PLT
169 addq (%rsp), %r14
170 testq %r13, %r13
171 movq %rax, %r15
172 jne .L72
173 jmp .L10
174 .p2align 4,,10
175 .p2align 3
176 .L69:
177 movq (%rsp), %rax
178 movq %rbp, %rsi
179 subq $1, %r13
180 addq %rax, %rbp
181 jmp .L20
182 .p2align 4,,10
183 .p2align 3
184 .L68:
185 movq (%rsp), %rdx
186 movq %rbp, %rsi
187 movq %r15, %rdi
188 imulq %r13, %rdx
189 call __GI_memcpy@PLT
190 jmp .L32
191 .p2align 4,,10
192 .p2align 3
193 .L67:
194 movq %rbx, %rdx
195 movq %r14, %rsi
196 movq %r12, %rdi
197 call msort_with_tmp.part.0
198 jmp .L3
199 .p2align 4,,10
200 .p2align 3
201 .L66:
202 movq %r13, %rdx
203 call msort_with_tmp.part.0
204 jmp .L2
205 .p2align 4,,10
206 .p2align 3
207 .L6:
208 testb %al, %al
209 jne .L14
210 jmp .L10
211 .p2align 4,,10
212 .p2align 3
213 .L12:
214 movl (%r14), %eax
215 subq $1, %rbx
216 addq $4, %r14
217 movl %eax, (%r15)
218 .L13:
219 addq $4, %r15
220 testq %r13, %r13
221 je .L10
222 testq %rbx, %rbx
223 je .L10
224 .L14:
225 movq 16(%rsp), %rdx
226 movq %r14, %rsi
227 movq %rbp, %rdi
228 movq 8(%rsp), %rax
229 call *%rax
230 testl %eax, %eax
231 jg .L12
232 movl 0(%rbp), %eax
233 subq $1, %r13
234 addq $4, %rbp
235 movl %eax, (%r15)
236 jmp .L13
237 .p2align 4,,10
238 .p2align 3
239 .L5:
240 testb %al, %al
241 jne .L11
242 jmp .L10
243 .p2align 4,,10
244 .p2align 3
245 .L16:
246 movq (%r14), %rax
247 subq $1, %rbx
248 addq $8, %r14
249 movq %rax, (%r15)
250 .L17:
251 addq $8, %r15
252 testq %r13, %r13
253 je .L10
254 testq %rbx, %rbx
255 je .L10
256 .L11:
257 movq 16(%rsp), %rdx
258 movq %r14, %rsi
259 movq %rbp, %rdi
260 movq 8(%rsp), %rax
261 call *%rax
262 testl %eax, %eax
263 jg .L16
264 movq 0(%rbp), %rax
265 subq $1, %r13
266 addq $8, %rbp
267 movq %rax, (%r15)
268 jmp .L17
269 .LFE49:
270 .size msort_with_tmp.part.0, .-msort_with_tmp.part.0
271 .p2align 4,,15
272 .globl __GI___qsort_r
273 .hidden __GI___qsort_r
274 .type __GI___qsort_r, @function
275 __GI___qsort_r:
276 .LFB47:
277 pushq %rbp
278 movq %rsp, %rbp
279 pushq %r15
280 pushq %r14
281 pushq %r13
282 pushq %r12
283 movq %rdx, %r15
284 pushq %rbx
285 movq %rcx, %r13
286 subq $104, %rsp
287 cmpq $32, %rdx
288 movq %rdi, -112(%rbp)
289 movq %rsi, -120(%rbp)
290 ja .L74
291 imulq %rdx, %rsi
292 movq %rsi, %r12
293 cmpq $1023, %r12
294 ja .L76
295 .L107:
296 addq $30, %r12
297 movq $0, -136(%rbp)
298 andq $-16, %r12
299 subq %r12, %rsp
300 leaq 15(%rsp), %rax
301 andq $-16, %rax
302 movq %rax, -64(%rbp)
303 .L77:
304 cmpq $32, %r15
305 movq %r15, -96(%rbp)
306 movq $4, -88(%rbp)
307 movq %r13, -80(%rbp)
308 movq %r8, -72(%rbp)
309 jbe .L83
310 movq -120(%rbp), %rax
311 movq -64(%rbp), %rbx
312 leaq 0(,%rax,8), %rsi
313 addq %rsi, %rbx
314 leaq (%rbx,%rsi), %rax
315 cmpq %rax, %rbx
316 movq %rax, -128(%rbp)
317 jnb .L97
318 movq -112(%rbp), %rdx
319 movq %rbx, %rax
320 .p2align 4,,10
321 .p2align 3
322 .L85:
323 addq $8, %rax
324 movq %rdx, -8(%rax)
325 addq %r15, %rdx
326 cmpq %rax, -128(%rbp)
327 ja .L85
328 addq -64(%rbp), %rsi
329 .L84:
330 movq -120(%rbp), %rdx
331 movq $8, -96(%rbp)
332 movq $3, -88(%rbp)
333 cmpq $1, %rdx
334 ja .L106
335 cmpq $0, -120(%rbp)
336 je .L88
337 .L87:
338 movq -112(%rbp), %r12
339 movq $0, -104(%rbp)
340 jmp .L91
341 .p2align 4,,10
342 .p2align 3
343 .L89:
344 addq $1, -104(%rbp)
345 addq %r15, %r12
346 movq -104(%rbp), %rax
347 cmpq %rax, -120(%rbp)
348 je .L88
349 .L91:
350 movq -104(%rbp), %rax
351 movq (%rbx,%rax,8), %r13
352 cmpq %r12, %r13
353 je .L89
354 movq -128(%rbp), %rdi
355 movq %r12, %rsi
356 movq %r15, %rdx
357 call __GI_memcpy@PLT
358 movq %r12, %rdi
359 movq -104(%rbp), %rsi
360 jmp .L90
361 .p2align 4,,10
362 .p2align 3
363 .L98:
364 movq %rax, %r13
365 .L90:
366 movq %r13, %rax
367 subq -112(%rbp), %rax
368 xorl %edx, %edx
369 movq %rdi, (%rbx,%rsi,8)
370 movq %r13, %rsi
371 divq %r15
372 movq %r15, %rdx
373 movq %rax, %r14
374 call __GI_memcpy@PLT
375 leaq (%rbx,%r14,8), %rdx
376 movq %r14, %rsi
377 movq %r13, %rdi
378 movq (%rdx), %rax
379 cmpq %r12, %rax
380 jne .L98
381 movq -128(%rbp), %rsi
382 movq %r13, (%rdx)
383 movq %r15, %rdx
384 call __GI_memcpy@PLT
385 jmp .L89
386 .p2align 4,,10
387 .p2align 3
388 .L74:
389 movq -120(%rbp), %r12
390 salq $4, %r12
391 addq %rdx, %r12
392 cmpq $1023, %r12
393 jbe .L107
394 .L76:
395 movl pagesize.8383(%rip), %edx
396 testl %edx, %edx
397 je .L108
398 .L78:
399 movslq %edx, %rsi
400 movq %r12, %rax
401 xorl %edx, %edx
402 divq %rsi
403 cmpq phys_pages.8382(%rip), %rax
404 jbe .L80
405 .L82:
406 movq -120(%rbp), %rsi
407 movq -112(%rbp), %rdi
408 movq %r13, %rcx
409 movq %r15, %rdx
410 call _quicksort@PLT
411 leaq -40(%rbp), %rsp
412 popq %rbx
413 popq %r12
414 popq %r13
415 popq %r14
416 popq %r15
417 popq %rbp
419 .p2align 4,,10
420 .p2align 3
421 .L83:
422 movq -112(%rbp), %rax
423 orq %r15, %rax
424 testb $3, %al
425 je .L109
426 .L93:
427 movq -120(%rbp), %rdx
428 cmpq $1, %rdx
429 jbe .L88
430 movq -112(%rbp), %rsi
431 leaq -96(%rbp), %rdi
432 call msort_with_tmp.part.0
433 .L88:
434 movq -136(%rbp), %rdi
435 call free@PLT
436 leaq -40(%rbp), %rsp
437 popq %rbx
438 popq %r12
439 popq %r13
440 popq %r14
441 popq %r15
442 popq %rbp
444 .p2align 4,,10
445 .p2align 3
446 .L80:
447 movq __libc_errno@gottpoff(%rip), %r14
448 movq %r12, %rdi
449 movq %r8, -104(%rbp)
450 movl %fs:(%r14), %ebx
451 call malloc@PLT
452 testq %rax, %rax
453 movq %rax, -136(%rbp)
454 movq -104(%rbp), %r8
455 movl %ebx, %fs:(%r14)
456 je .L82
457 movq %rax, -64(%rbp)
458 jmp .L77
459 .p2align 4,,10
460 .p2align 3
461 .L108:
462 movl $85, %edi
463 movq %r8, -104(%rbp)
464 call __GI___sysconf
465 cmpq $-1, %rax
466 movabsq $2305843009213693951, %rdx
467 movq -104(%rbp), %r8
468 je .L79
469 leaq 3(%rax), %rdx
470 testq %rax, %rax
471 cmovns %rax, %rdx
472 sarq $2, %rdx
473 .L79:
474 movq %r8, -104(%rbp)
475 movq %rdx, phys_pages.8382(%rip)
476 movl $30, %edi
477 call __GI___sysconf
478 movq -104(%rbp), %r8
479 movl %eax, %edx
480 movl %eax, pagesize.8383(%rip)
481 jmp .L78
482 .p2align 4,,10
483 .p2align 3
484 .L106:
485 leaq -96(%rbp), %rdi
486 call msort_with_tmp.part.0
487 jmp .L87
488 .p2align 4,,10
489 .p2align 3
490 .L109:
491 cmpq $4, %r15
492 je .L110
493 cmpq $8, %r15
494 je .L111
495 .L95:
496 testb $7, %al
497 jne .L93
498 movq $2, -88(%rbp)
499 jmp .L93
500 .p2align 4,,10
501 .p2align 3
502 .L97:
503 movq %rbx, %rsi
504 jmp .L84
505 .L111:
506 testb $7, -112(%rbp)
507 jne .L95
508 movq $1, -88(%rbp)
509 jmp .L93
510 .L110:
511 movq $0, -88(%rbp)
512 jmp .L93
513 .LFE47:
514 .size __GI___qsort_r, .-__GI___qsort_r
515 .globl __qsort_r
516 .set __qsort_r,__GI___qsort_r
517 .weak qsort_r
518 .set qsort_r,__qsort_r
519 .p2align 4,,15
520 .globl __GI_qsort
521 .hidden __GI_qsort
522 .type __GI_qsort, @function
523 __GI_qsort:
524 .LFB48:
525 xorl %r8d, %r8d
526 jmp __GI___qsort_r
527 .LFE48:
528 .size __GI_qsort, .-__GI_qsort
529 .globl qsort
530 .set qsort,__GI_qsort
531 .local phys_pages.8382
532 .comm phys_pages.8382,8,8
533 .local pagesize.8383
534 .comm pagesize.8383,4,4