clarify the purpose of this project
[nyanglibc.git] / stdlib / divrem.shared.s
blob43e75aca2dc64666885f67bcc285e4a1518e93b4
1 .text
2 #APP
3 memmove = __GI_memmove
4 memset = __GI_memset
5 memcpy = __GI_memcpy
6 #NO_APP
7 .p2align 4,,15
8 .globl __mpn_divrem
9 .hidden __mpn_divrem
10 .type __mpn_divrem, @function
11 __mpn_divrem:
12 pushq %r15
13 pushq %r14
14 movq %rdx, %r10
15 pushq %r13
16 pushq %r12
17 pushq %rbp
18 pushq %rbx
19 subq $88, %rsp
20 cmpq $1, %r9
21 je .L3
22 cmpq $2, %r9
23 je .L4
24 testq %r9, %r9
25 je .L68
26 movq %rcx, %rax
27 movq %rdi, 48(%rsp)
28 movq %rcx, %rbx
29 subq %r9, %rax
30 movq %rsi, 40(%rsp)
31 movq %r9, 8(%rsp)
32 leaq (%rdx,%rax,8), %r14
33 leaq 0(,%r9,8), %rax
34 movq %r8, 24(%rsp)
35 movq $0, 32(%rsp)
36 leaq -8(%rax), %rdi
37 movq -8(%r8,%rax), %r15
38 leaq -16(%rax), %rsi
39 movq %rax, 56(%rsp)
40 movq -16(%r8,%rax), %r12
41 leaq (%r14,%rdi), %r13
42 movq %rdi, 64(%rsp)
43 movq %rsi, 72(%rsp)
44 movq 0(%r13), %rcx
45 cmpq %rcx, %r15
46 jbe .L69
47 .L29:
48 addq 40(%rsp), %rbx
49 subq 8(%rsp), %rbx
50 subq $1, %rbx
51 js .L1
52 movq %r13, %rax
53 movq %r12, %r13
54 movq %rbx, %r12
55 movq %rax, %rbp
56 .p2align 4,,10
57 .p2align 3
58 .L42:
59 cmpq %r12, 40(%rsp)
60 jg .L32
61 movq 56(%rsp), %rax
62 subq $8, %r14
63 movq (%r14,%rax), %rax
64 movq %rax, 16(%rsp)
65 movq 64(%rsp), %rax
66 leaq (%r14,%rax), %rbp
67 .L33:
68 cmpq %rcx, %r15
69 movq $-1, %rbx
70 je .L36
71 movq %rcx, %rdx
72 movq 0(%rbp), %rax
73 movq 72(%rsp), %rdi
74 #APP
75 # 201 "divrem.c" 1
76 divq %r15
77 # 0 "" 2
78 #NO_APP
79 movq %rax, %rbx
80 movq %rdx, %rcx
81 movq %r13, %rax
82 #APP
83 # 202 "divrem.c" 1
84 mulq %rbx
85 # 0 "" 2
86 #NO_APP
87 movq %rdx, %rsi
88 jmp .L37
89 .p2align 4,,10
90 .p2align 3
91 .L70:
92 xorl %edx, %edx
93 cmpq %r13, %rax
94 setb %dl
95 subq %r13, %rax
96 subq %rdx, %rsi
97 .L37:
98 cmpq %rcx, %rsi
99 ja .L40
100 jne .L36
101 cmpq %rax, (%r14,%rdi)
102 jnb .L36
103 .L40:
104 subq $1, %rbx
105 addq %r15, %rcx
106 jnc .L70
107 .L36:
108 movq 8(%rsp), %rdx
109 movq 24(%rsp), %rsi
110 movq %rbx, %rcx
111 movq %r14, %rdi
112 call __mpn_submul_1
113 cmpq %rax, 16(%rsp)
114 je .L41
115 movq 8(%rsp), %rcx
116 movq 24(%rsp), %rdx
117 movq %r14, %rsi
118 movq %r14, %rdi
119 subq $1, %rbx
120 call __mpn_add_n
121 .L41:
122 movq 48(%rsp), %rax
123 movq %rbx, (%rax,%r12,8)
124 subq $1, %r12
125 movq 0(%rbp), %rcx
126 cmpq $-1, %r12
127 jne .L42
128 .L1:
129 movq 32(%rsp), %rax
130 addq $88, %rsp
131 popq %rbx
132 popq %rbp
133 popq %r12
134 popq %r13
135 popq %r14
136 popq %r15
138 .p2align 4,,10
139 .p2align 3
140 .L68:
142 .p2align 4,,10
143 .p2align 3
144 .L32:
145 cmpq $0, 8(%rsp)
146 movq 0(%rbp), %rax
147 movq %rax, 16(%rsp)
148 jle .L34
149 movq 56(%rsp), %rax
150 addq %r14, %rax
151 .p2align 4,,10
152 .p2align 3
153 .L35:
154 movq -8(%rax), %rdx
155 subq $8, %rax
156 movq %rdx, 8(%rax)
157 cmpq %rax, %r14
158 jne .L35
159 .L34:
160 movq $0, (%r14)
161 jmp .L33
162 .p2align 4,,10
163 .p2align 3
164 .L4:
165 leaq -16(%rdx,%rcx,8), %r12
166 movq 8(%r8), %r11
167 movq (%r8), %rbp
168 movq $0, 32(%rsp)
169 movq 8(%r12), %r8
170 movq (%r12), %r9
171 cmpq %r8, %r11
172 jbe .L71
173 .L12:
174 leaq -3(%rsi,%rcx), %rbx
175 testq %rbx, %rbx
176 js .L14
177 movq %rbp, %r13
178 movq $-1, %r14
179 negq %r13
180 jmp .L28
181 .p2align 4,,10
182 .p2align 3
183 .L72:
184 movq -8(%r12), %rcx
185 subq $8, %r12
186 cmpq %r8, %r11
187 jne .L17
188 .L73:
189 addq %r11, %r9
190 movq %r9, %r8
191 jnc .L20
192 movq %r14, (%rdi,%rbx,8)
193 subq $1, %rbx
194 subq %rbp, %r8
195 movq %rcx, %r9
196 #APP
197 # 121 "divrem.c" 1
198 addq %rbp,%r9
199 adcq $0,%r8
200 # 0 "" 2
201 #NO_APP
202 cmpq $-1, %rbx
203 je .L14
204 .L28:
205 cmpq %rbx, %rsi
206 jle .L72
207 xorl %ecx, %ecx
208 cmpq %r8, %r11
209 movq $0, (%r12)
210 je .L73
211 .L17:
212 movq %r9, %rax
213 movq %r8, %rdx
214 #APP
215 # 130 "divrem.c" 1
216 divq %r11
217 # 0 "" 2
218 #NO_APP
219 movq %rax, %r9
220 movq %rdx, %r8
221 movq %rbp, %rax
222 #APP
223 # 131 "divrem.c" 1
224 mulq %r9
225 # 0 "" 2
226 .p2align 4,,10
227 .p2align 3
228 #NO_APP
229 .L23:
230 cmpq %r8, %rdx
231 ja .L24
232 jne .L25
233 cmpq %rcx, %rax
234 jbe .L25
235 .L24:
236 subq $1, %r9
237 #APP
238 # 141 "divrem.c" 1
239 subq %rbp,%rax
240 sbbq $0,%rdx
241 # 0 "" 2
242 #NO_APP
243 addq %r11, %r8
244 jnc .L23
245 .L25:
246 movq %r9, (%rdi,%rbx,8)
247 subq $1, %rbx
248 movq %rcx, %r9
249 #APP
250 # 148 "divrem.c" 1
251 subq %rax,%r9
252 sbbq %rdx,%r8
253 # 0 "" 2
254 #NO_APP
255 cmpq $-1, %rbx
256 jne .L28
257 .L14:
258 movq %r8, 8(%r12)
259 movq %r9, (%r12)
260 jmp .L1
261 .p2align 4,,10
262 .p2align 3
263 .L20:
264 xorl %eax, %eax
265 testq %rbp, %rbp
266 movq %rbp, %rdx
267 setne %al
268 movq $-1, %r9
269 subq %rax, %rdx
270 movq %r13, %rax
271 jmp .L23
272 .p2align 4,,10
273 .p2align 3
274 .L3:
275 movq (%r8), %r8
276 movq -8(%rdx,%rcx,8), %rdx
277 movq $0, 32(%rsp)
278 cmpq %rdx, %r8
279 jbe .L74
280 .L6:
281 subq $2, %rcx
282 js .L7
283 leaq (%rcx,%rsi), %rax
284 leaq (%rdi,%rax,8), %r9
285 .p2align 4,,10
286 .p2align 3
287 .L8:
288 movq (%r10,%rcx,8), %rax
289 subq $1, %rcx
290 subq $8, %r9
291 #APP
292 # 73 "divrem.c" 1
293 divq %r8
294 # 0 "" 2
295 #NO_APP
296 movq %rax, 8(%r9)
297 cmpq $-1, %rcx
298 jne .L8
299 .L7:
300 subq $1, %rsi
301 js .L9
302 leaq (%rdi,%rsi,8), %rcx
303 subq $8, %rdi
304 xorl %esi, %esi
305 .p2align 4,,10
306 .p2align 3
307 .L10:
308 movq %rsi, %rax
309 subq $8, %rcx
310 #APP
311 # 77 "divrem.c" 1
312 divq %r8
313 # 0 "" 2
314 #NO_APP
315 movq %rax, 8(%rcx)
316 cmpq %rcx, %rdi
317 jne .L10
318 .L9:
319 movq %rdx, (%r10)
320 jmp .L1
321 .p2align 4,,10
322 .p2align 3
323 .L74:
324 subq %r8, %rdx
325 movq $1, 32(%rsp)
326 jmp .L6
327 .p2align 4,,10
328 .p2align 3
329 .L71:
330 jb .L48
331 cmpq %r9, %rbp
332 ja .L12
333 .L48:
334 #APP
335 # 97 "divrem.c" 1
336 subq %rbp,%r9
337 sbbq %r11,%r8
338 # 0 "" 2
339 #NO_APP
340 movq $1, 32(%rsp)
341 jmp .L12
342 .p2align 4,,10
343 .p2align 3
344 .L69:
345 jb .L31
346 movq 8(%rsp), %rax
347 movq 24(%rsp), %rsi
348 movq %r14, %rdi
349 movq %rcx, 16(%rsp)
350 leaq -1(%rax), %rdx
351 call __mpn_cmp
352 testl %eax, %eax
353 movq 16(%rsp), %rcx
354 js .L29
355 .L31:
356 movq 8(%rsp), %rcx
357 movq 24(%rsp), %rdx
358 movq %r14, %rsi
359 movq %r14, %rdi
360 call __mpn_sub_n
361 movq 0(%r13), %rcx
362 movq $1, 32(%rsp)
363 jmp .L29
364 .size __mpn_divrem, .-__mpn_divrem
365 .hidden __mpn_sub_n
366 .hidden __mpn_cmp
367 .hidden __mpn_add_n
368 .hidden __mpn_submul_1