-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathX25519-AArch64.s
1624 lines (1535 loc) · 37.9 KB
/
X25519-AArch64.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* X25519-AArch64 by Emil Lenngren (2018)
*
* To the extent possible under law, the person who associated CC0 with
* X25519-AArch64 has waived all copyright and related or neighboring rights
* to X25519-AArch64.
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
/*
* This is an AArch64 implementation of X25519.
* It follows the reference implementation where the representation of
* a field element [0..2^255-19) is represented by a 256-bit little endian integer,
* reduced modulo 2^256-38, and may possibly be in the range [2^256-38..2^256).
* The scalar is a 256-bit integer where certain bits are hardcoded per specification.
*
* The implementation runs in constant time (~145k cycles on Cortex-A53),
* and no conditional branches or memory access pattern depend on secret data.
*/
.cpu generic+fp+simd
.text
.align 2
// in: x0: pointer
// out: x0: loaded value
.type load64unaligned, %function
load64unaligned:
ldrb w1, [x0]
ldrb w2, [x0, #1]
ldrb w3, [x0, #2]
ldrb w4, [x0, #3]
ldrb w5, [x0, #4]
ldrb w6, [x0, #5]
ldrb w7, [x0, #6]
ldrb w8, [x0, #7]
orr w1, w1, w2, lsl #8
orr w3, w3, w4, lsl #8
orr w5, w5, w6, lsl #8
orr w7, w7, w8, lsl #8
orr w1, w1, w3, lsl #16
orr w5, w5, w7, lsl #16
orr x0, x1, x5, lsl #32
ret
.size load64unaligned, .-load64unaligned
// in: x0: pointer
// out: x0-x3: loaded value
.type load256unaligned, %function
load256unaligned:
stp x29, x30, [sp, #-64]!
mov x29, sp
stp x19, x20, [sp, #16]
stp x21, x22, [sp, #32]
mov x19, x0
bl load64unaligned
mov x20, x0
add x0, x19, #8
bl load64unaligned
mov x21, x0
add x0, x19, #16
bl load64unaligned
mov x22, x0
add x0, x19, #24
bl load64unaligned
mov x3, x0
mov x0, x20
mov x1, x21
mov x2, x22
ldp x19, x20, [sp, #16]
ldp x21, x22, [sp, #32]
ldp x29, x30, [sp], #64
ret
.size load256unaligned, .-load256unaligned
// in: x1: scalar pointer, x2: base point pointer
// out: x0: result pointer
.global x25519_scalarmult
.type x25519_scalarmult, %function
x25519_scalarmult:
stp x29, x30, [sp, #-160]!
mov x29, sp
stp x19, x20, [sp, #16]
stp x21, x22, [sp, #32]
stp x23, x24, [sp, #48]
stp x25, x26, [sp, #64]
stp x27, x28, [sp, #80]
stp d8, d9, [sp, #96]
stp d10, d11, [sp, #112]
stp d12, d13, [sp, #128]
stp d14, d15, [sp, #144]
sub sp, sp, 192
// 0: mask1, 8: mask2, 16: AA, 56: B/BB, 96: counter, 100: lastbit, 104: scalar, 136: X1, 176: outptr, 184: padding, 192: fp, 200: lr
str x0, [sp, #176] // outptr
mov x19, x2 // point
mov x0, x1 // scalar
bl load256unaligned
and x3, x3, #0x7fffffffffffffff
and x0, x0, #0xfffffffffffffff8
orr x3, x3, #0x4000000000000000
stp x0, x1, [sp, #104]
stp x2, x3, [sp, #104+16]
mov x0, x19 // point
bl load256unaligned
// Unpack point (discard most significant bit)
lsr x12, x0, #51
lsr x17, x2, #51
orr w12, w12, w1, lsl #13
orr w17, w17, w3, lsl #13
ubfx x8, x3, #12, #26
ubfx x9, x3, #38, #25
ubfx x11, x0, #26, #25
ubfx x13, x1, #13, #25
lsr x14, x1, #38
ubfx x16, x2, #25, #26
and w10, w0, #0x3ffffff
and w12, w12, #0x3ffffff
and w15, w2, #0x1ffffff
and w17, w17, #0x1ffffff
stp w10, w11, [sp, #136]
stp w12, w13, [sp, #136+8]
stp w14, w15, [sp, #136+16]
stp w16, w17, [sp, #136+24]
stp w8, w9, [sp, #136+32]
// X2 (initially set to 1)
mov x1, #1
mov v0.d[0], x1
mov v2.d[0], xzr
mov v4.d[0], xzr
mov v6.d[0], xzr
mov v8.d[0], xzr
// Z2 (initially set to 0)
mov v1.d[0], xzr
mov v3.d[0], xzr
mov v5.d[0], xzr
mov v7.d[0], xzr
mov v9.d[0], xzr
// X3 (initially set to X1)
mov v10.s[0], w10
mov v10.s[1], w11
mov v12.s[0], w12
mov v12.s[1], w13
mov v14.s[0], w14
mov v14.s[1], w15
mov v16.s[0], w16
mov v16.s[1], w17
mov v18.s[0], w8
mov v18.s[1], w9
// Z3 (initially set to 1)
mov v11.d[0], x1
mov v13.d[0], xzr
mov v15.d[0], xzr
mov v17.d[0], xzr
mov v19.d[0], xzr
mov x0, #255-1 // 255 iterations
str w0, [sp, #96]
mov w30, #19
dup v31.2s, w30
mov x0, #(1<<26)-1
dup v30.2d, x0
ldr x0, =0x07fffffe07fffffc
stp x0, x0, [sp]
sub x1, x0, #0xfc-0xb4
stp x1, x0, [sp, #8]
ldr d28, [sp, #8]
ldr d29, [sp]
ldrb w1, [sp, #135]
lsr w1, w1, #6
str w1, [sp, #100]
.Lmainloop:
tst w1, #1
// (2^255-19)*4 - Z_
sub v20.2s, v28.2s, v1.2s
sub v21.2s, v29.2s, v3.2s
sub v22.2s, v29.2s, v5.2s
sub v23.2s, v29.2s, v7.2s
sub v24.2s, v29.2s, v9.2s
sub v25.2s, v28.2s, v11.2s
sub v26.2s, v29.2s, v13.2s
sub v27.2s, v29.2s, v15.2s
sub v28.2s, v29.2s, v17.2s
sub v29.2s, v29.2s, v19.2s
// ... + X_
add v20.2s, v0.2s, v20.2s
add v21.2s, v2.2s, v21.2s
add v22.2s, v4.2s, v22.2s
add v23.2s, v6.2s, v23.2s
add v24.2s, v8.2s, v24.2s
add v25.2s, v10.2s, v25.2s
add v26.2s, v12.2s, v26.2s
add v27.2s, v14.2s, v27.2s
add v28.2s, v16.2s, v28.2s
add v29.2s, v18.2s, v29.2s
// X_ + Z_
add v0.2s, v0.2s, v1.2s
add v10.2s, v10.2s, v11.2s
add v2.2s, v2.2s, v3.2s
add v12.2s, v12.2s, v13.2s
fcsel d1, d0, d10, eq
add v4.2s, v4.2s, v5.2s
fcsel d3, d2, d12, eq
add v14.2s, v14.2s, v15.2s
add v6.2s, v6.2s, v7.2s
add v16.2s, v16.2s, v17.2s
mov x0, v1.d[0]
add v8.2s, v8.2s, v9.2s
mov x2, v3.d[0]
add v18.2s, v18.2s, v19.2s
fcsel d5, d4, d14, eq
// [B A]
trn2 v1.2s, v0.2s, v20.2s
fcsel d7, d6, d16, eq
trn1 v0.2s, v0.2s, v20.2s
fcsel d9, d8, d18, eq
trn2 v3.2s, v2.2s, v21.2s
mov x4, v5.d[0]
trn1 v2.2s, v2.2s, v21.2s
mov x6, v7.d[0]
trn2 v5.2s, v4.2s, v22.2s
mov x8, v9.d[0]
trn1 v4.2s, v4.2s, v22.2s
fcsel d20, d20, d25, eq
trn2 v7.2s, v6.2s, v23.2s
fcsel d21, d21, d26, eq
trn1 v6.2s, v6.2s, v23.2s
fcsel d22, d22, d27, eq
trn2 v9.2s, v8.2s, v24.2s
fcsel d23, d23, d28, eq
trn1 v8.2s, v8.2s, v24.2s
fcsel d24, d24, d29, eq
// [C D]
trn2 v11.2s, v25.2s, v10.2s
trn1 v10.2s, v25.2s, v10.2s
trn2 v13.2s, v26.2s, v12.2s
trn1 v12.2s, v26.2s, v12.2s
trn2 v15.2s, v27.2s, v14.2s
trn1 v14.2s, v27.2s, v14.2s
trn2 v17.2s, v28.2s, v16.2s
trn1 v16.2s, v28.2s, v16.2s
stp d20, d21, [sp, #56]
trn2 v19.2s, v29.2s, v18.2s
stp d22, d23, [sp, #56+16]
trn1 v18.2s, v29.2s, v18.2s
str d24, [sp, #56+32]
//v0-v9: [B A]
//v10-v19: [C D]
umull v29.2d, v0.2s, v19.2s
lsr x1, x0, #32
umlal v29.2d, v2.2s, v17.2s
lsr x3, x2, #32
umlal v29.2d, v4.2s, v15.2s
lsr x5, x4, #32
umlal v29.2d, v6.2s, v13.2s
lsr x7, x6, #32
umlal v29.2d, v8.2s, v11.2s
lsr x9, x8, #32
mul v19.2s, v19.2s, v31.2s
add x21, x9, x9
umull v28.2d, v1.2s, v17.2s
add x17, x8, x8
umlal v28.2d, v3.2s, v15.2s
add x16, x7, x7
umlal v28.2d, v5.2s, v13.2s
add x15, x6, x6
umlal v28.2d, v7.2s, v11.2s
add x14, x5, x5
umlal v28.2d, v9.2s, v19.2s
add x13, x4, x4
umlal v29.2d, v1.2s, v18.2s
add x12, x3, x3
umlal v29.2d, v3.2s, v16.2s
add x11, x2, x2
umlal v29.2d, v5.2s, v14.2s
add x10, x1, x1
umlal v29.2d, v7.2s, v12.2s
umull x28, w4, w4
umlal v29.2d, v9.2s, v10.2s
umull x19, w4, w14
shl v28.2d, v28.2d, #1
mul w9, w9, w30
umull v27.2d, v0.2s, v17.2s
mul w7, w7, w30
umlal v27.2d, v2.2s, v15.2s
mul w5, w5, w30
umlal v27.2d, v4.2s, v13.2s
umaddl x28, w9, w21, x28
umlal v27.2d, v6.2s, v11.2s
umaddl x19, w0, w21, x19
umlal v27.2d, v8.2s, v19.2s
umull x20, w0, w0
mul v17.2s, v17.2s, v31.2s
umull x21, w0, w10
umlal v28.2d, v0.2s, v18.2s
umull x22, w0, w11
umlal v28.2d, v2.2s, v16.2s
umull x23, w0, w12
umlal v28.2d, v4.2s, v14.2s
umull x24, w0, w13
umlal v28.2d, v6.2s, v12.2s
umull x25, w0, w14
umlal v28.2d, v8.2s, v10.2s
umull x26, w0, w15
mul v18.2s, v18.2s, v31.2s
umull x27, w0, w16
umull v26.2d, v1.2s, v15.2s
umaddl x28, w0, w17, x28
umlal v26.2d, v3.2s, v13.2s
mul w0, w6, w30
umlal v26.2d, v5.2s, v11.2s
umaddl x22, w1, w10, x22
umlal v26.2d, v7.2s, v19.2s
umaddl x23, w1, w11, x23
umlal v26.2d, v9.2s, v17.2s
umaddl x24, w10, w12, x24
umlal v27.2d, v1.2s, v16.2s
umaddl x25, w1, w13, x25
umlal v27.2d, v3.2s, v14.2s
umaddl x26, w10, w14, x26
umlal v27.2d, v5.2s, v12.2s
umaddl x27, w1, w15, x27
umlal v27.2d, v7.2s, v10.2s
umaddl x28, w10, w16, x28
umlal v27.2d, v9.2s, v18.2s
umaddl x19, w1, w17, x19
shl v26.2d, v26.2d, #1
mul w1, w8, w30
umull v25.2d, v0.2s, v15.2s
umaddl x24, w2, w2, x24
umlal v25.2d, v2.2s, v13.2s
umaddl x25, w2, w12, x25
umlal v25.2d, v4.2s, v11.2s
umaddl x26, w2, w13, x26
umlal v25.2d, v6.2s, v19.2s
umaddl x27, w2, w14, x27
umlal v25.2d, v8.2s, v17.2s
umaddl x28, w2, w15, x28
mul v15.2s, v15.2s, v31.2s
umaddl x19, w2, w16, x19
umlal v26.2d, v0.2s, v16.2s
umaddl x26, w3, w12, x26
umlal v26.2d, v2.2s, v14.2s
umaddl x27, w3, w13, x27
umlal v26.2d, v4.2s, v12.2s
umaddl x28, w12, w14, x28
umlal v26.2d, v6.2s, v10.2s
umaddl x19, w3, w15, x19
umlal v26.2d, v8.2s, v18.2s
umaddl x26, w1, w8, x26
mul v16.2s, v16.2s, v31.2s
umaddl x22, w0, w6, x22
umull v24.2d, v1.2s, v13.2s
add x19, x19, x28, lsr #26
umlal v24.2d, v3.2s, v11.2s
umaddl x20, w5, w14, x20
umlal v24.2d, v5.2s, v19.2s
add x20, x20, x19, lsr #25
umlal v24.2d, v7.2s, v17.2s
bic x2, x19, #0x1ffffff
umlal v24.2d, v9.2s, v15.2s
add x20, x20, x2, lsr #24
umlal v25.2d, v1.2s, v14.2s
and x19, x19, #0x1ffffff
umlal v25.2d, v3.2s, v12.2s
add x20, x20, x2, lsr #21
umlal v25.2d, v5.2s, v10.2s
umaddl x24, w7, w16, x24
umlal v25.2d, v7.2s, v18.2s
add x2, x10, x10
umlal v25.2d, v9.2s, v16.2s
add x3, x12, x12
shl v24.2d, v24.2d, #1
add x4, x14, x14
umull v23.2d, v0.2s, v13.2s
add x5, x16, x16
umlal v23.2d, v2.2s, v11.2s
umaddl x20, w0, w13, x20
umlal v23.2d, v4.2s, v19.2s
umaddl x21, w0, w14, x21
umlal v23.2d, v6.2s, v17.2s
and x28, x28, #0x3ffffff
umlal v23.2d, v8.2s, v15.2s
umaddl x20, w7, w3, x20
mul v13.2s, v13.2s, v31.2s
umaddl x21, w7, w13, x21
umlal v24.2d, v0.2s, v14.2s
umaddl x22, w7, w4, x22
umlal v24.2d, v2.2s, v12.2s
umaddl x23, w7, w15, x23
umlal v24.2d, v4.2s, v10.2s
umaddl x20, w1, w11, x20
umlal v24.2d, v6.2s, v18.2s
umaddl x21, w1, w12, x21
umlal v24.2d, v8.2s, v16.2s
umaddl x22, w1, w13, x22
mul v14.2s, v14.2s, v31.2s
umaddl x23, w1, w14, x23
umull v22.2d, v1.2s, v11.2s
umaddl x24, w1, w15, x24
umlal v22.2d, v3.2s, v19.2s
umaddl x25, w1, w16, x25
umlal v22.2d, v5.2s, v17.2s
umaddl x20, w9, w2, x20
umlal v22.2d, v7.2s, v15.2s
umaddl x21, w9, w11, x21
umlal v22.2d, v9.2s, v13.2s
umaddl x22, w9, w3, x22
umlal v23.2d, v1.2s, v12.2s
umaddl x23, w9, w13, x23
umlal v23.2d, v3.2s, v10.2s
umaddl x24, w9, w4, x24
umlal v23.2d, v5.2s, v18.2s
umaddl x25, w9, w15, x25
umlal v23.2d, v7.2s, v16.2s
umaddl x26, w9, w5, x26
umlal v23.2d, v9.2s, v14.2s
umaddl x27, w9, w17, x27
shl v22.2d, v22.2d, #1
add x21, x21, x20, lsr #26
umull v21.2d, v0.2s, v11.2s
and x20, x20, #0x3ffffff
umlal v21.2d, v2.2s, v19.2s
add x22, x22, x21, lsr #25
umlal v21.2d, v4.2s, v17.2s
bfi x20, x21, #32, #25
umlal v21.2d, v6.2s, v15.2s
add x23, x23, x22, lsr #26
umlal v21.2d, v8.2s, v13.2s
and x22, x22, #0x3ffffff
mul v11.2s, v11.2s, v31.2s
add x24, x24, x23, lsr #25
umlal v22.2d, v0.2s, v12.2s
bfi x22, x23, #32, #25
umlal v22.2d, v2.2s, v10.2s
add x25, x25, x24, lsr #26
umlal v22.2d, v4.2s, v18.2s
and x24, x24, #0x3ffffff
umlal v22.2d, v6.2s, v16.2s
add x26, x26, x25, lsr #25
umlal v22.2d, v8.2s, v14.2s
bfi x24, x25, #32, #25
mul v12.2s, v12.2s, v31.2s
add x27, x27, x26, lsr #26
umull v20.2d, v1.2s, v19.2s
and x26, x26, #0x3ffffff
umlal v20.2d, v3.2s, v17.2s
add x28, x28, x27, lsr #25
umlal v20.2d, v5.2s, v15.2s
bfi x26, x27, #32, #25
ushr v15.2d, v30.2d, #1
add x19, x19, x28, lsr #26
usra v23.2d, v22.2d, #26
and x28, x28, #0x3ffffff
and v22.16b, v22.16b, v30.16b
bfi x28, x19, #32, #26
umlal v21.2d, v1.2s, v10.2s
stp x20, x22, [sp, #16]
usra v24.2d, v23.2d, #25
stp x24, x26, [sp, #32]
and v23.16b, v23.16b, v15.16b
str x28, [sp, #48]
umlal v20.2d, v7.2s, v13.2s
ldr x8, [sp, #88]
usra v25.2d, v24.2d, #26
ldr x6, [sp, #80]
and v24.16b, v24.16b, v30.16b
ldr x4, [sp, #72]
umlal v21.2d, v3.2s, v18.2s
ldr x2, [sp, #64]
usra v26.2d, v25.2d, #25
lsr x9, x8, #32
and v25.16b, v25.16b, v15.16b
ldr x0, [sp, #56]
umlal v20.2d, v9.2s, v11.2s
lsr x7, x6, #32
usra v27.2d, v26.2d, #26
lsr x5, x4, #32
and v26.16b, v26.16b, v30.16b
lsr x3, x2, #32
umlal v21.2d, v5.2s, v16.2s
lsr x1, x0, #32
umlal v21.2d, v7.2s, v14.2s
add x21, x9, x9
umlal v21.2d, v9.2s, v12.2s
add x17, x8, x8
usra v28.2d, v27.2d, #25
add x16, x7, x7
and v27.16b, v27.16b, v15.16b
add x15, x6, x6
shl v20.2d, v20.2d, #1
add x14, x5, x5
usra v29.2d, v28.2d, #26
add x13, x4, x4
and v28.16b, v28.16b, v30.16b
add x12, x3, x3
umlal v20.2d, v0.2s, v10.2s
add x11, x2, x2
umlal v20.2d, v2.2s, v18.2s
add x10, x1, x1
umlal v20.2d, v4.2s, v16.2s
umull x28, w4, w4
umlal v20.2d, v6.2s, v14.2s
umull x19, w4, w14
umlal v20.2d, v8.2s, v12.2s
mul w9, w9, w30
bic v19.16b, v29.16b, v15.16b
mul w7, w7, w30
and v29.16b, v29.16b, v15.16b
mul w5, w5, w30
usra v20.2d, v19.2d, #25
umaddl x28, w9, w21, x28
uzp1 v24.4s, v24.4s, v25.4s
umaddl x19, w0, w21, x19
usra v20.2d, v19.2d, #24
umull x20, w0, w0
uzp1 v25.4s, v26.4s, v27.4s
umull x21, w0, w10
usra v20.2d, v19.2d, #21
umull x22, w0, w11
ld1r {v19.2d}, [sp]
umull x23, w0, w12
uzp1 v26.4s, v24.4s, v25.4s
umull x24, w0, w13
usra v21.2d, v20.2d, #26
umull x25, w0, w14
and v20.16b, v20.16b, v30.16b
umull x26, w0, w15
uzp2 v27.4s, v24.4s, v25.4s
umull x27, w0, w16
usra v22.2d, v21.2d, #25
umaddl x28, w0, w17, x28
and v21.16b, v21.16b, v15.16b
mul w0, w6, w30
trn1 v28.4s, v28.4s, v29.4s
umaddl x22, w1, w10, x22
usra v23.2d, v22.2d, #26
umaddl x23, w1, w11, x23
and v22.16b, v22.16b, v30.16b
umaddl x24, w10, w12, x24
ldr b0, [sp, #8]
umaddl x25, w1, w13, x25
uzp1 v20.4s, v20.4s, v21.4s
umaddl x26, w10, w14, x26
uzp1 v21.4s, v22.4s, v23.4s
umaddl x27, w1, w15, x27
mov v29.d[0], v28.d[1]
umaddl x28, w10, w16, x28
uzp1 v24.4s, v20.4s, v21.4s
umaddl x19, w1, w17, x19
uzp2 v25.4s, v20.4s, v21.4s
mul w1, w8, w30
add v11.4s, v26.4s, v19.4s
umaddl x24, w2, w2, x24
add v12.2s, v28.2s, v19.2s
umaddl x25, w2, w12, x25
mov v19.b[0], v0.b[0]
umaddl x26, w2, w13, x26
add v20.4s, v24.4s, v25.4s
umaddl x27, w2, w14, x27
add v21.4s, v26.4s, v27.4s
umaddl x28, w2, w15, x28
add v22.2s, v28.2s, v29.2s
umaddl x19, w2, w16, x19
add v10.4s, v24.4s, v19.4s
umaddl x26, w3, w12, x26
sub v11.4s, v11.4s, v27.4s
umaddl x27, w3, w13, x27
sub v10.4s, v10.4s, v25.4s
umaddl x28, w12, w14, x28
sub v12.2s, v12.2s, v29.2s
umaddl x19, w3, w15, x19
zip1 v0.4s, v10.4s, v20.4s
umaddl x26, w1, w8, x26
zip2 v2.4s, v10.4s, v20.4s
umaddl x22, w0, w6, x22
zip1 v4.4s, v11.4s, v21.4s
add x19, x19, x28, lsr #26
zip2 v6.4s, v11.4s, v21.4s
umaddl x20, w5, w14, x20
zip1 v8.2s, v12.2s, v22.2s
add x20, x20, x19, lsr #25
zip2 v9.2s, v12.2s, v22.2s
bic x2, x19, #0x1ffffff
mov v1.d[0], v0.d[1]
add x20, x20, x2, lsr #24
mov v3.d[0], v2.d[1]
and x19, x19, #0x1ffffff
mov v5.d[0], v4.d[1]
add x20, x20, x2, lsr #21
mov v7.d[0], v6.d[1]
umaddl x24, w7, w16, x24
shl v19.2s, v9.2s, #1
add x2, x10, x10
shl v18.2s, v8.2s, #1
add x3, x12, x12
shl v17.2s, v7.2s, #1
add x4, x14, x14
shl v16.2s, v6.2s, #1
add x5, x16, x16
shl v10.2s, v5.2s, #1
umaddl x20, w0, w13, x20
shl v14.2s, v4.2s, #1
umaddl x21, w0, w14, x21
shl v13.2s, v3.2s, #1
and x28, x28, #0x3ffffff
shl v12.2s, v2.2s, #1
umaddl x20, w7, w3, x20
shl v11.2s, v1.2s, #1
umaddl x21, w7, w13, x21
umull v29.2d, v0.2s, v19.2s
umaddl x22, w7, w4, x22
umlal v29.2d, v1.2s, v18.2s
umaddl x23, w7, w15, x23
umlal v29.2d, v2.2s, v17.2s
umaddl x20, w1, w11, x20
umlal v29.2d, v3.2s, v16.2s
umaddl x21, w1, w12, x21
umlal v29.2d, v4.2s, v10.2s
umaddl x22, w1, w13, x22
umull v28.2d, v0.2s, v18.2s
umaddl x23, w1, w14, x23
umlal v28.2d, v11.2s, v17.2s
umaddl x24, w1, w15, x24
umlal v28.2d, v2.2s, v16.2s
umaddl x25, w1, w16, x25
umlal v28.2d, v13.2s, v10.2s
umaddl x20, w9, w2, x20
umlal v28.2d, v4.2s, v4.2s
umaddl x21, w9, w11, x21
mul v4.2s, v9.2s, v31.2s
umaddl x22, w9, w3, x22
umull v27.2d, v0.2s, v17.2s
umaddl x23, w9, w13, x23
umlal v27.2d, v1.2s, v16.2s
umaddl x24, w9, w4, x24
umlal v27.2d, v2.2s, v10.2s
umaddl x25, w9, w15, x25
umlal v27.2d, v3.2s, v14.2s
umaddl x26, w9, w5, x26
umlal v28.2d, v4.2s, v19.2s
umaddl x27, w9, w17, x27
umull v26.2d, v0.2s, v16.2s
add x1, x21, x20, lsr #26
umlal v26.2d, v11.2s, v10.2s
and x0, x20, #0x3ffffff
umlal v26.2d, v2.2s, v14.2s
add x2, x22, x1, lsr #25
umlal v26.2d, v13.2s, v3.2s
bfi x0, x1, #32, #25
umull v25.2d, v0.2s, v10.2s
add x3, x23, x2, lsr #26
umlal v25.2d, v1.2s, v14.2s
and x2, x2, #0x3ffffff
umlal v25.2d, v2.2s, v13.2s
add x4, x24, x3, lsr #25
umull v24.2d, v0.2s, v14.2s
bfi x2, x3, #32, #25
umlal v24.2d, v11.2s, v13.2s
add x5, x25, x4, lsr #26
umlal v24.2d, v2.2s, v2.2s
and x4, x4, #0x3ffffff
umull v23.2d, v0.2s, v13.2s
add x6, x26, x5, lsr #25
umlal v23.2d, v1.2s, v12.2s
bfi x4, x5, #32, #25
umull v22.2d, v0.2s, v12.2s
add x7, x27, x6, lsr #26
umlal v22.2d, v11.2s, v1.2s
and x6, x6, #0x3ffffff
umull v21.2d, v0.2s, v11.2s
add x8, x28, x7, lsr #25
umull v20.2d, v0.2s, v0.2s
bfi x6, x7, #32, #25
usra v29.2d, v28.2d, #26
add x9, x19, x8, lsr #26
and v28.16b, v28.16b, v30.16b
and x8, x8, #0x3ffffff
mul v3.2s, v8.2s, v31.2s
bfi x8, x9, #32, #26
bic v19.16b, v29.16b, v15.16b
and x1, x1, #0x1ffffff
and v9.16b, v29.16b, v15.16b
and x3, x3, #0x1ffffff
usra v20.2d, v19.2d, #25
and x5, x5, #0x1ffffff
mul v2.2s, v7.2s, v31.2s
and x7, x7, #0x1ffffff
usra v20.2d, v19.2d, #24
stp x0, x2, [sp, #56]
mul v1.2s, v6.2s, v31.2s
stp x4, x6, [sp, #56+16]
usra v20.2d, v19.2d, #21
str x8, [sp, #56+32]
mul v0.2s, v5.2s, v31.2s
ldr x21, =0x07fffffe07fffffc
shl v5.2s, v11.2s, #1
ldr x10, [sp, #16]
shl v7.2s, v13.2s, #1
ldr x12, [sp, #16+8]
shl v19.2s, v10.2s, #1
ldr x14, [sp, #16+16]
shl v11.2s, v17.2s, #1
ldr x16, [sp, #16+24]
umlal v20.2d, v0.2s, v10.2s
ldr x19, [sp, #16+32]
umlal v20.2d, v4.2s, v5.2s
add x12, x12, x21
umlal v20.2d, v3.2s, v12.2s
add x14, x14, x21
umlal v20.2d, v2.2s, v7.2s
add x16, x16, x21
umlal v20.2d, v1.2s, v14.2s
add x19, x19, x21
umlal v21.2d, v4.2s, v12.2s
movk x21, #0xffb4
umlal v21.2d, v3.2s, v13.2s
add x10, x10, x21
umlal v21.2d, v2.2s, v14.2s
sub x10, x10, x0
umlal v21.2d, v1.2s, v10.2s
sub x12, x12, x2
umlal v22.2d, v1.2s, v6.2s
sub x14, x14, x4
umlal v22.2d, v4.2s, v7.2s
sub x16, x16, x6
umlal v22.2d, v3.2s, v14.2s
sub x19, x19, x8
umlal v22.2d, v2.2s, v19.2s
mov w0, w0
usra v21.2d, v20.2d, #26
mov w2, w2
umlal v23.2d, v4.2s, v14.2s
mov w4, w4
umlal v23.2d, v3.2s, v10.2s
mov w6, w6
umlal v23.2d, v2.2s, v16.2s
mov w8, w8
usra v22.2d, v21.2d, #25
lsr x11, x10, #32
umlal v24.2d, v2.2s, v17.2s
lsr x13, x12, #32
umlal v24.2d, v4.2s, v19.2s
lsr x15, x14, #32
umlal v24.2d, v3.2s, v16.2s
lsr x17, x16, #32
usra v23.2d, v22.2d, #26
lsr x20, x19, #32
umlal v25.2d, v4.2s, v16.2s
ldr x21, =121666
umlal v25.2d, v3.2s, v17.2s
umaddl x9, w20, w21, x9
usra v24.2d, v23.2d, #25
umaddl x0, w10, w21, x0
umlal v26.2d, v3.2s, v8.2s
umaddl x1, w11, w21, x1
umlal v26.2d, v4.2s, v11.2s
umaddl x2, w12, w21, x2
usra v25.2d, v24.2d, #26
lsr x22, x9, #25
umlal v27.2d, v4.2s, v18.2s
umaddl x3, w13, w21, x3
and v4.16b, v24.16b, v30.16b
and x9, x9, #0x1ffffff
usra v26.2d, v25.2d, #25
umaddl x4, w14, w21, x4
and v5.16b, v25.16b, v15.16b
add x0, x0, x22
and v0.16b, v20.16b, v30.16b
umaddl x5, w15, w21, x5
usra v27.2d, v26.2d, #26
add x0, x0, x22, lsl #1
and v6.16b, v26.16b, v30.16b
umaddl x6, w16, w21, x6
and v1.16b, v21.16b, v15.16b
add x0, x0, x22, lsl #4
usra v28.2d, v27.2d, #25
umaddl x7, w17, w21, x7
and v7.16b, v27.16b, v15.16b
umaddl x8, w19, w21, x8
and v2.16b, v22.16b, v30.16b
add x26, sp, #136 // X1 for ASIMD part
usra v9.2d, v28.2d, #26
add x27, sp, #16 // AA
and v8.16b, v28.16b, v30.16b
add x28, sp, #56 // BB
and v3.16b, v23.16b, v15.16b
add x1, x1, x0, lsr #26
ld2 { v0.s, v1.s }[1], [x27], #8 // X1, AA, BB loaded from a64 part
and x0, x0, #0x3ffffff
ld2 { v10.s, v11.s }[1], [x28], #8
add x2, x2, x1, lsr #25
ld2 { v10.s, v11.s }[0], [x26], #8
and x1, x1, #0x1ffffff
ld2 { v2.s, v3.s }[1], [x27], #8
add x3, x3, x2, lsr #26
ld2 { v12.s, v13.s }[1], [x28], #8
and x2, x2, #0x3ffffff
ld2 { v12.s, v13.s }[0], [x26], #8
add x4, x4, x3, lsr #25
ld2 { v4.s, v5.s }[1], [x27], #8
and x3, x3, #0x1ffffff
ld2 { v14.s, v15.s }[1], [x28], #8
add x5, x5, x4, lsr #26
ld2 { v14.s, v15.s }[0], [x26], #8
and x4, x4, #0x3ffffff
ld2 { v6.s, v7.s }[1], [x27], #8
add x6, x6, x5, lsr #25
ld2 { v16.s, v17.s }[1], [x28], #8
and x5, x5, #0x1ffffff
ld2 { v16.s, v17.s }[0], [x26], #8
add x7, x7, x6, lsr #26
ld2 { v8.s, v9.s }[1], [x27], #8
and x6, x6, #0x3ffffff
ld2 { v18.s, v19.s }[1], [x28], #8
add x8, x8, x7, lsr #25
ld2 { v18.s, v19.s }[0], [x26], #8
and x7, x7, #0x1ffffff
umull v29.2d, v6.2s, v13.2s
add x9, x9, x8, lsr #26
umlal v29.2d, v4.2s, v15.2s
and x8, x8, #0x3ffffff
umlal v29.2d, v0.2s, v19.2s
umull x21, w1, w19
umlal v29.2d, v2.2s, v17.2s
umull x22, w1, w17
umlal v29.2d, v8.2s, v11.2s
umull x23, w1, w16
mul v19.2s, v19.2s, v31.2s
umull x24, w1, w15
umull v28.2d, v1.2s, v17.2s
umaddl x21, w3, w16, x21
umlal v28.2d, v3.2s, v15.2s
umaddl x22, w3, w15, x22
umlal v28.2d, v5.2s, v13.2s
umaddl x23, w3, w14, x23
umlal v28.2d, v7.2s, v11.2s
umaddl x24, w3, w13, x24
umlal v28.2d, v9.2s, v19.2s
umaddl x21, w5, w14, x21
umlal v29.2d, v1.2s, v18.2s
umaddl x22, w5, w13, x22
umlal v29.2d, v3.2s, v16.2s
umaddl x23, w5, w12, x23
umlal v29.2d, v5.2s, v14.2s
umaddl x24, w5, w11, x24
umlal v29.2d, v7.2s, v12.2s
umaddl x21, w7, w12, x21
umlal v29.2d, v9.2s, v10.2s
umaddl x22, w7, w11, x22
shl v28.2d, v28.2d, #1
umaddl x23, w7, w10, x23
umull v27.2d, v0.2s, v17.2s
mul w27, w7, w30
umlal v27.2d, v2.2s, v15.2s
mul w25, w9, w30
umlal v27.2d, v4.2s, v13.2s
mul w26, w8, w30
umlal v27.2d, v6.2s, v11.2s
mul w28, w6, w30
umlal v27.2d, v8.2s, v19.2s
umaddl x24, w27, w20, x24
mul v17.2s, v17.2s, v31.2s
umaddl x21, w9, w10, x21
umlal v28.2d, v0.2s, v18.2s
umaddl x22, w25, w20, x22
umlal v28.2d, v2.2s, v16.2s
umaddl x23, w25, w19, x23
umlal v28.2d, v4.2s, v14.2s
umaddl x24, w25, w17, x24
umlal v28.2d, v6.2s, v12.2s
add x22, x22, x22
umlal v28.2d, v8.2s, v10.2s
umaddl x21, w0, w20, x21
mul v18.2s, v18.2s, v31.2s
add x24, x24, x24
umull v26.2d, v1.2s, v15.2s
umaddl x22, w0, w19, x22
umlal v26.2d, v3.2s, v13.2s
umaddl x23, w0, w17, x23
umlal v26.2d, v5.2s, v11.2s
umaddl x24, w0, w16, x24
umlal v26.2d, v7.2s, v19.2s
umaddl x21, w2, w17, x21
umlal v26.2d, v9.2s, v17.2s
umaddl x22, w2, w16, x22
umlal v27.2d, v1.2s, v16.2s
umaddl x23, w2, w15, x23
umlal v27.2d, v3.2s, v14.2s
umaddl x24, w2, w14, x24
umlal v27.2d, v5.2s, v12.2s
umaddl x21, w4, w15, x21
umlal v27.2d, v7.2s, v10.2s
umaddl x22, w4, w14, x22
umlal v27.2d, v9.2s, v18.2s
umaddl x23, w4, w13, x23
shl v26.2d, v26.2d, #1
umaddl x24, w4, w12, x24
umull v25.2d, v0.2s, v15.2s
umaddl x21, w6, w13, x21
umlal v25.2d, v2.2s, v13.2s
umaddl x22, w6, w12, x22
umlal v25.2d, v4.2s, v11.2s
umaddl x23, w6, w11, x23
umlal v25.2d, v6.2s, v19.2s
umaddl x24, w6, w10, x24
umlal v25.2d, v8.2s, v17.2s
umaddl x21, w8, w11, x21
mul v15.2s, v15.2s, v31.2s
umaddl x22, w8, w10, x22
umlal v26.2d, v0.2s, v16.2s
umaddl x23, w26, w20, x23
umlal v26.2d, v2.2s, v14.2s
umaddl x24, w26, w19, x24
umlal v26.2d, v4.2s, v12.2s
umull x6, w25, w16
umlal v26.2d, v6.2s, v10.2s
umull x7, w25, w15
umlal v26.2d, v8.2s, v18.2s
umull x8, w25, w14
mul v16.2s, v16.2s, v31.2s
umaddl x6, w5, w10, x6
umull v24.2d, v1.2s, v13.2s
mul w5, w5, w30
umlal v24.2d, v3.2s, v11.2s
umaddl x7, w27, w17, x7
umlal v24.2d, v5.2s, v19.2s
umaddl x8, w27, w16, x8
umlal v24.2d, v7.2s, v17.2s
umaddl x6, w27, w19, x6
umlal v24.2d, v9.2s, v15.2s
umaddl x7, w5, w20, x7
umlal v25.2d, v1.2s, v14.2s
umaddl x8, w5, w19, x8
umlal v25.2d, v3.2s, v12.2s
umaddl x6, w3, w12, x6
umlal v25.2d, v5.2s, v10.2s
umaddl x7, w3, w11, x7
umlal v25.2d, v7.2s, v18.2s
umaddl x8, w3, w10, x8
umlal v25.2d, v9.2s, v16.2s
umaddl x6, w1, w14, x6
shl v24.2d, v24.2d, #1
umaddl x7, w1, w13, x7
umull v23.2d, v0.2s, v13.2s
umaddl x8, w1, w12, x8
umlal v23.2d, v2.2s, v11.2s
mul w9, w4, w30
umlal v23.2d, v4.2s, v19.2s
add x7, x7, x7
umlal v23.2d, v6.2s, v17.2s
umaddl x6, w26, w17, x6
umlal v23.2d, v8.2s, v15.2s
umaddl x7, w26, w16, x7
mul v13.2s, v13.2s, v31.2s
umaddl x8, w26, w15, x8
umlal v24.2d, v0.2s, v14.2s
umaddl x6, w28, w20, x6
umlal v24.2d, v2.2s, v12.2s
umaddl x7, w28, w19, x7
umlal v24.2d, v4.2s, v10.2s
umaddl x8, w28, w17, x8
umlal v24.2d, v6.2s, v18.2s
umaddl x6, w4, w11, x6
umlal v24.2d, v8.2s, v16.2s