1%ifidn __OUTPUT_FORMAT__,obj
2section	code	use32 class=code align=64
3%elifidn __OUTPUT_FORMAT__,win32
4%ifdef __YASM_VERSION_ID__
5%if __YASM_VERSION_ID__ < 01010000h
6%error yasm version 1.1.0 or later needed.
7%endif
8; Yasm automatically includes .00 and complains about redefining it.
9; https://www.tortall.net/projects/yasm/manual/html/objfmt-win32-safeseh.html
10%else
11$@feat.00 equ 1
12%endif
13section	.text	code align=64
14%else
15section	.text	code
16%endif
17global	_md5_block_asm_data_order
18align	16
19_md5_block_asm_data_order:
20L$_md5_block_asm_data_order_begin:
21	push	esi
22	push	edi
23	mov	edi,DWORD [12+esp]
24	mov	esi,DWORD [16+esp]
25	mov	ecx,DWORD [20+esp]
26	push	ebp
27	shl	ecx,6
28	push	ebx
29	add	ecx,esi
30	sub	ecx,64
31	mov	eax,DWORD [edi]
32	push	ecx
33	mov	ebx,DWORD [4+edi]
34	mov	ecx,DWORD [8+edi]
35	mov	edx,DWORD [12+edi]
36L$000start:
37	;
38	; R0 section
39	mov	edi,ecx
40	mov	ebp,DWORD [esi]
41	; R0 0
42	xor	edi,edx
43	and	edi,ebx
44	lea	eax,[3614090360+ebp*1+eax]
45	xor	edi,edx
46	add	eax,edi
47	mov	edi,ebx
48	rol	eax,7
49	mov	ebp,DWORD [4+esi]
50	add	eax,ebx
51	; R0 1
52	xor	edi,ecx
53	and	edi,eax
54	lea	edx,[3905402710+ebp*1+edx]
55	xor	edi,ecx
56	add	edx,edi
57	mov	edi,eax
58	rol	edx,12
59	mov	ebp,DWORD [8+esi]
60	add	edx,eax
61	; R0 2
62	xor	edi,ebx
63	and	edi,edx
64	lea	ecx,[606105819+ebp*1+ecx]
65	xor	edi,ebx
66	add	ecx,edi
67	mov	edi,edx
68	rol	ecx,17
69	mov	ebp,DWORD [12+esi]
70	add	ecx,edx
71	; R0 3
72	xor	edi,eax
73	and	edi,ecx
74	lea	ebx,[3250441966+ebp*1+ebx]
75	xor	edi,eax
76	add	ebx,edi
77	mov	edi,ecx
78	rol	ebx,22
79	mov	ebp,DWORD [16+esi]
80	add	ebx,ecx
81	; R0 4
82	xor	edi,edx
83	and	edi,ebx
84	lea	eax,[4118548399+ebp*1+eax]
85	xor	edi,edx
86	add	eax,edi
87	mov	edi,ebx
88	rol	eax,7
89	mov	ebp,DWORD [20+esi]
90	add	eax,ebx
91	; R0 5
92	xor	edi,ecx
93	and	edi,eax
94	lea	edx,[1200080426+ebp*1+edx]
95	xor	edi,ecx
96	add	edx,edi
97	mov	edi,eax
98	rol	edx,12
99	mov	ebp,DWORD [24+esi]
100	add	edx,eax
101	; R0 6
102	xor	edi,ebx
103	and	edi,edx
104	lea	ecx,[2821735955+ebp*1+ecx]
105	xor	edi,ebx
106	add	ecx,edi
107	mov	edi,edx
108	rol	ecx,17
109	mov	ebp,DWORD [28+esi]
110	add	ecx,edx
111	; R0 7
112	xor	edi,eax
113	and	edi,ecx
114	lea	ebx,[4249261313+ebp*1+ebx]
115	xor	edi,eax
116	add	ebx,edi
117	mov	edi,ecx
118	rol	ebx,22
119	mov	ebp,DWORD [32+esi]
120	add	ebx,ecx
121	; R0 8
122	xor	edi,edx
123	and	edi,ebx
124	lea	eax,[1770035416+ebp*1+eax]
125	xor	edi,edx
126	add	eax,edi
127	mov	edi,ebx
128	rol	eax,7
129	mov	ebp,DWORD [36+esi]
130	add	eax,ebx
131	; R0 9
132	xor	edi,ecx
133	and	edi,eax
134	lea	edx,[2336552879+ebp*1+edx]
135	xor	edi,ecx
136	add	edx,edi
137	mov	edi,eax
138	rol	edx,12
139	mov	ebp,DWORD [40+esi]
140	add	edx,eax
141	; R0 10
142	xor	edi,ebx
143	and	edi,edx
144	lea	ecx,[4294925233+ebp*1+ecx]
145	xor	edi,ebx
146	add	ecx,edi
147	mov	edi,edx
148	rol	ecx,17
149	mov	ebp,DWORD [44+esi]
150	add	ecx,edx
151	; R0 11
152	xor	edi,eax
153	and	edi,ecx
154	lea	ebx,[2304563134+ebp*1+ebx]
155	xor	edi,eax
156	add	ebx,edi
157	mov	edi,ecx
158	rol	ebx,22
159	mov	ebp,DWORD [48+esi]
160	add	ebx,ecx
161	; R0 12
162	xor	edi,edx
163	and	edi,ebx
164	lea	eax,[1804603682+ebp*1+eax]
165	xor	edi,edx
166	add	eax,edi
167	mov	edi,ebx
168	rol	eax,7
169	mov	ebp,DWORD [52+esi]
170	add	eax,ebx
171	; R0 13
172	xor	edi,ecx
173	and	edi,eax
174	lea	edx,[4254626195+ebp*1+edx]
175	xor	edi,ecx
176	add	edx,edi
177	mov	edi,eax
178	rol	edx,12
179	mov	ebp,DWORD [56+esi]
180	add	edx,eax
181	; R0 14
182	xor	edi,ebx
183	and	edi,edx
184	lea	ecx,[2792965006+ebp*1+ecx]
185	xor	edi,ebx
186	add	ecx,edi
187	mov	edi,edx
188	rol	ecx,17
189	mov	ebp,DWORD [60+esi]
190	add	ecx,edx
191	; R0 15
192	xor	edi,eax
193	and	edi,ecx
194	lea	ebx,[1236535329+ebp*1+ebx]
195	xor	edi,eax
196	add	ebx,edi
197	mov	edi,ecx
198	rol	ebx,22
199	mov	ebp,DWORD [4+esi]
200	add	ebx,ecx
201	;
202	; R1 section
203	; R1 16
204	lea	eax,[4129170786+ebp*1+eax]
205	xor	edi,ebx
206	and	edi,edx
207	mov	ebp,DWORD [24+esi]
208	xor	edi,ecx
209	add	eax,edi
210	mov	edi,ebx
211	rol	eax,5
212	add	eax,ebx
213	; R1 17
214	lea	edx,[3225465664+ebp*1+edx]
215	xor	edi,eax
216	and	edi,ecx
217	mov	ebp,DWORD [44+esi]
218	xor	edi,ebx
219	add	edx,edi
220	mov	edi,eax
221	rol	edx,9
222	add	edx,eax
223	; R1 18
224	lea	ecx,[643717713+ebp*1+ecx]
225	xor	edi,edx
226	and	edi,ebx
227	mov	ebp,DWORD [esi]
228	xor	edi,eax
229	add	ecx,edi
230	mov	edi,edx
231	rol	ecx,14
232	add	ecx,edx
233	; R1 19
234	lea	ebx,[3921069994+ebp*1+ebx]
235	xor	edi,ecx
236	and	edi,eax
237	mov	ebp,DWORD [20+esi]
238	xor	edi,edx
239	add	ebx,edi
240	mov	edi,ecx
241	rol	ebx,20
242	add	ebx,ecx
243	; R1 20
244	lea	eax,[3593408605+ebp*1+eax]
245	xor	edi,ebx
246	and	edi,edx
247	mov	ebp,DWORD [40+esi]
248	xor	edi,ecx
249	add	eax,edi
250	mov	edi,ebx
251	rol	eax,5
252	add	eax,ebx
253	; R1 21
254	lea	edx,[38016083+ebp*1+edx]
255	xor	edi,eax
256	and	edi,ecx
257	mov	ebp,DWORD [60+esi]
258	xor	edi,ebx
259	add	edx,edi
260	mov	edi,eax
261	rol	edx,9
262	add	edx,eax
263	; R1 22
264	lea	ecx,[3634488961+ebp*1+ecx]
265	xor	edi,edx
266	and	edi,ebx
267	mov	ebp,DWORD [16+esi]
268	xor	edi,eax
269	add	ecx,edi
270	mov	edi,edx
271	rol	ecx,14
272	add	ecx,edx
273	; R1 23
274	lea	ebx,[3889429448+ebp*1+ebx]
275	xor	edi,ecx
276	and	edi,eax
277	mov	ebp,DWORD [36+esi]
278	xor	edi,edx
279	add	ebx,edi
280	mov	edi,ecx
281	rol	ebx,20
282	add	ebx,ecx
283	; R1 24
284	lea	eax,[568446438+ebp*1+eax]
285	xor	edi,ebx
286	and	edi,edx
287	mov	ebp,DWORD [56+esi]
288	xor	edi,ecx
289	add	eax,edi
290	mov	edi,ebx
291	rol	eax,5
292	add	eax,ebx
293	; R1 25
294	lea	edx,[3275163606+ebp*1+edx]
295	xor	edi,eax
296	and	edi,ecx
297	mov	ebp,DWORD [12+esi]
298	xor	edi,ebx
299	add	edx,edi
300	mov	edi,eax
301	rol	edx,9
302	add	edx,eax
303	; R1 26
304	lea	ecx,[4107603335+ebp*1+ecx]
305	xor	edi,edx
306	and	edi,ebx
307	mov	ebp,DWORD [32+esi]
308	xor	edi,eax
309	add	ecx,edi
310	mov	edi,edx
311	rol	ecx,14
312	add	ecx,edx
313	; R1 27
314	lea	ebx,[1163531501+ebp*1+ebx]
315	xor	edi,ecx
316	and	edi,eax
317	mov	ebp,DWORD [52+esi]
318	xor	edi,edx
319	add	ebx,edi
320	mov	edi,ecx
321	rol	ebx,20
322	add	ebx,ecx
323	; R1 28
324	lea	eax,[2850285829+ebp*1+eax]
325	xor	edi,ebx
326	and	edi,edx
327	mov	ebp,DWORD [8+esi]
328	xor	edi,ecx
329	add	eax,edi
330	mov	edi,ebx
331	rol	eax,5
332	add	eax,ebx
333	; R1 29
334	lea	edx,[4243563512+ebp*1+edx]
335	xor	edi,eax
336	and	edi,ecx
337	mov	ebp,DWORD [28+esi]
338	xor	edi,ebx
339	add	edx,edi
340	mov	edi,eax
341	rol	edx,9
342	add	edx,eax
343	; R1 30
344	lea	ecx,[1735328473+ebp*1+ecx]
345	xor	edi,edx
346	and	edi,ebx
347	mov	ebp,DWORD [48+esi]
348	xor	edi,eax
349	add	ecx,edi
350	mov	edi,edx
351	rol	ecx,14
352	add	ecx,edx
353	; R1 31
354	lea	ebx,[2368359562+ebp*1+ebx]
355	xor	edi,ecx
356	and	edi,eax
357	mov	ebp,DWORD [20+esi]
358	xor	edi,edx
359	add	ebx,edi
360	mov	edi,ecx
361	rol	ebx,20
362	add	ebx,ecx
363	;
364	; R2 section
365	; R2 32
366	xor	edi,edx
367	xor	edi,ebx
368	lea	eax,[4294588738+ebp*1+eax]
369	add	eax,edi
370	rol	eax,4
371	mov	ebp,DWORD [32+esi]
372	mov	edi,ebx
373	; R2 33
374	lea	edx,[2272392833+ebp*1+edx]
375	add	eax,ebx
376	xor	edi,ecx
377	xor	edi,eax
378	mov	ebp,DWORD [44+esi]
379	add	edx,edi
380	mov	edi,eax
381	rol	edx,11
382	add	edx,eax
383	; R2 34
384	xor	edi,ebx
385	xor	edi,edx
386	lea	ecx,[1839030562+ebp*1+ecx]
387	add	ecx,edi
388	rol	ecx,16
389	mov	ebp,DWORD [56+esi]
390	mov	edi,edx
391	; R2 35
392	lea	ebx,[4259657740+ebp*1+ebx]
393	add	ecx,edx
394	xor	edi,eax
395	xor	edi,ecx
396	mov	ebp,DWORD [4+esi]
397	add	ebx,edi
398	mov	edi,ecx
399	rol	ebx,23
400	add	ebx,ecx
401	; R2 36
402	xor	edi,edx
403	xor	edi,ebx
404	lea	eax,[2763975236+ebp*1+eax]
405	add	eax,edi
406	rol	eax,4
407	mov	ebp,DWORD [16+esi]
408	mov	edi,ebx
409	; R2 37
410	lea	edx,[1272893353+ebp*1+edx]
411	add	eax,ebx
412	xor	edi,ecx
413	xor	edi,eax
414	mov	ebp,DWORD [28+esi]
415	add	edx,edi
416	mov	edi,eax
417	rol	edx,11
418	add	edx,eax
419	; R2 38
420	xor	edi,ebx
421	xor	edi,edx
422	lea	ecx,[4139469664+ebp*1+ecx]
423	add	ecx,edi
424	rol	ecx,16
425	mov	ebp,DWORD [40+esi]
426	mov	edi,edx
427	; R2 39
428	lea	ebx,[3200236656+ebp*1+ebx]
429	add	ecx,edx
430	xor	edi,eax
431	xor	edi,ecx
432	mov	ebp,DWORD [52+esi]
433	add	ebx,edi
434	mov	edi,ecx
435	rol	ebx,23
436	add	ebx,ecx
437	; R2 40
438	xor	edi,edx
439	xor	edi,ebx
440	lea	eax,[681279174+ebp*1+eax]
441	add	eax,edi
442	rol	eax,4
443	mov	ebp,DWORD [esi]
444	mov	edi,ebx
445	; R2 41
446	lea	edx,[3936430074+ebp*1+edx]
447	add	eax,ebx
448	xor	edi,ecx
449	xor	edi,eax
450	mov	ebp,DWORD [12+esi]
451	add	edx,edi
452	mov	edi,eax
453	rol	edx,11
454	add	edx,eax
455	; R2 42
456	xor	edi,ebx
457	xor	edi,edx
458	lea	ecx,[3572445317+ebp*1+ecx]
459	add	ecx,edi
460	rol	ecx,16
461	mov	ebp,DWORD [24+esi]
462	mov	edi,edx
463	; R2 43
464	lea	ebx,[76029189+ebp*1+ebx]
465	add	ecx,edx
466	xor	edi,eax
467	xor	edi,ecx
468	mov	ebp,DWORD [36+esi]
469	add	ebx,edi
470	mov	edi,ecx
471	rol	ebx,23
472	add	ebx,ecx
473	; R2 44
474	xor	edi,edx
475	xor	edi,ebx
476	lea	eax,[3654602809+ebp*1+eax]
477	add	eax,edi
478	rol	eax,4
479	mov	ebp,DWORD [48+esi]
480	mov	edi,ebx
481	; R2 45
482	lea	edx,[3873151461+ebp*1+edx]
483	add	eax,ebx
484	xor	edi,ecx
485	xor	edi,eax
486	mov	ebp,DWORD [60+esi]
487	add	edx,edi
488	mov	edi,eax
489	rol	edx,11
490	add	edx,eax
491	; R2 46
492	xor	edi,ebx
493	xor	edi,edx
494	lea	ecx,[530742520+ebp*1+ecx]
495	add	ecx,edi
496	rol	ecx,16
497	mov	ebp,DWORD [8+esi]
498	mov	edi,edx
499	; R2 47
500	lea	ebx,[3299628645+ebp*1+ebx]
501	add	ecx,edx
502	xor	edi,eax
503	xor	edi,ecx
504	mov	ebp,DWORD [esi]
505	add	ebx,edi
506	mov	edi,-1
507	rol	ebx,23
508	add	ebx,ecx
509	;
510	; R3 section
511	; R3 48
512	xor	edi,edx
513	or	edi,ebx
514	lea	eax,[4096336452+ebp*1+eax]
515	xor	edi,ecx
516	mov	ebp,DWORD [28+esi]
517	add	eax,edi
518	mov	edi,-1
519	rol	eax,6
520	xor	edi,ecx
521	add	eax,ebx
522	; R3 49
523	or	edi,eax
524	lea	edx,[1126891415+ebp*1+edx]
525	xor	edi,ebx
526	mov	ebp,DWORD [56+esi]
527	add	edx,edi
528	mov	edi,-1
529	rol	edx,10
530	xor	edi,ebx
531	add	edx,eax
532	; R3 50
533	or	edi,edx
534	lea	ecx,[2878612391+ebp*1+ecx]
535	xor	edi,eax
536	mov	ebp,DWORD [20+esi]
537	add	ecx,edi
538	mov	edi,-1
539	rol	ecx,15
540	xor	edi,eax
541	add	ecx,edx
542	; R3 51
543	or	edi,ecx
544	lea	ebx,[4237533241+ebp*1+ebx]
545	xor	edi,edx
546	mov	ebp,DWORD [48+esi]
547	add	ebx,edi
548	mov	edi,-1
549	rol	ebx,21
550	xor	edi,edx
551	add	ebx,ecx
552	; R3 52
553	or	edi,ebx
554	lea	eax,[1700485571+ebp*1+eax]
555	xor	edi,ecx
556	mov	ebp,DWORD [12+esi]
557	add	eax,edi
558	mov	edi,-1
559	rol	eax,6
560	xor	edi,ecx
561	add	eax,ebx
562	; R3 53
563	or	edi,eax
564	lea	edx,[2399980690+ebp*1+edx]
565	xor	edi,ebx
566	mov	ebp,DWORD [40+esi]
567	add	edx,edi
568	mov	edi,-1
569	rol	edx,10
570	xor	edi,ebx
571	add	edx,eax
572	; R3 54
573	or	edi,edx
574	lea	ecx,[4293915773+ebp*1+ecx]
575	xor	edi,eax
576	mov	ebp,DWORD [4+esi]
577	add	ecx,edi
578	mov	edi,-1
579	rol	ecx,15
580	xor	edi,eax
581	add	ecx,edx
582	; R3 55
583	or	edi,ecx
584	lea	ebx,[2240044497+ebp*1+ebx]
585	xor	edi,edx
586	mov	ebp,DWORD [32+esi]
587	add	ebx,edi
588	mov	edi,-1
589	rol	ebx,21
590	xor	edi,edx
591	add	ebx,ecx
592	; R3 56
593	or	edi,ebx
594	lea	eax,[1873313359+ebp*1+eax]
595	xor	edi,ecx
596	mov	ebp,DWORD [60+esi]
597	add	eax,edi
598	mov	edi,-1
599	rol	eax,6
600	xor	edi,ecx
601	add	eax,ebx
602	; R3 57
603	or	edi,eax
604	lea	edx,[4264355552+ebp*1+edx]
605	xor	edi,ebx
606	mov	ebp,DWORD [24+esi]
607	add	edx,edi
608	mov	edi,-1
609	rol	edx,10
610	xor	edi,ebx
611	add	edx,eax
612	; R3 58
613	or	edi,edx
614	lea	ecx,[2734768916+ebp*1+ecx]
615	xor	edi,eax
616	mov	ebp,DWORD [52+esi]
617	add	ecx,edi
618	mov	edi,-1
619	rol	ecx,15
620	xor	edi,eax
621	add	ecx,edx
622	; R3 59
623	or	edi,ecx
624	lea	ebx,[1309151649+ebp*1+ebx]
625	xor	edi,edx
626	mov	ebp,DWORD [16+esi]
627	add	ebx,edi
628	mov	edi,-1
629	rol	ebx,21
630	xor	edi,edx
631	add	ebx,ecx
632	; R3 60
633	or	edi,ebx
634	lea	eax,[4149444226+ebp*1+eax]
635	xor	edi,ecx
636	mov	ebp,DWORD [44+esi]
637	add	eax,edi
638	mov	edi,-1
639	rol	eax,6
640	xor	edi,ecx
641	add	eax,ebx
642	; R3 61
643	or	edi,eax
644	lea	edx,[3174756917+ebp*1+edx]
645	xor	edi,ebx
646	mov	ebp,DWORD [8+esi]
647	add	edx,edi
648	mov	edi,-1
649	rol	edx,10
650	xor	edi,ebx
651	add	edx,eax
652	; R3 62
653	or	edi,edx
654	lea	ecx,[718787259+ebp*1+ecx]
655	xor	edi,eax
656	mov	ebp,DWORD [36+esi]
657	add	ecx,edi
658	mov	edi,-1
659	rol	ecx,15
660	xor	edi,eax
661	add	ecx,edx
662	; R3 63
663	or	edi,ecx
664	lea	ebx,[3951481745+ebp*1+ebx]
665	xor	edi,edx
666	mov	ebp,DWORD [24+esp]
667	add	ebx,edi
668	add	esi,64
669	rol	ebx,21
670	mov	edi,DWORD [ebp]
671	add	ebx,ecx
672	add	eax,edi
673	mov	edi,DWORD [4+ebp]
674	add	ebx,edi
675	mov	edi,DWORD [8+ebp]
676	add	ecx,edi
677	mov	edi,DWORD [12+ebp]
678	add	edx,edi
679	mov	DWORD [ebp],eax
680	mov	DWORD [4+ebp],ebx
681	mov	edi,DWORD [esp]
682	mov	DWORD [8+ebp],ecx
683	mov	DWORD [12+ebp],edx
684	cmp	edi,esi
685	jae	NEAR L$000start
686	pop	eax
687	pop	ebx
688	pop	ebp
689	pop	edi
690	pop	esi
691	ret
692