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