-
Notifications
You must be signed in to change notification settings - Fork 147
/
sm2_32.c
5446 lines (5421 loc) · 170 KB
/
sm2_32.c
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
/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier sm2 32 '2^256 - 2^224 - 2^96 + 2^64 - 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */
/* curve description: sm2 */
/* machine_wordsize = 32 (from "32") */
/* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */
/* m = 0xfffffffeffffffffffffffffffffffffffffffff00000000ffffffffffffffff (from "2^256 - 2^224 - 2^96 + 2^64 - 1") */
/* */
/* NOTE: In addition to the bounds specified above each function, all */
/* functions synthesized for this Montgomery arithmetic require the */
/* input to be strictly less than the prime modulus (m), and also */
/* require the input to be in the unique saturated representation. */
/* All functions also ensure that these two properties are true of */
/* return values. */
/* */
/* Computed values: */
/* eval z = z[0] + (z[1] << 32) + (z[2] << 64) + (z[3] << 96) + (z[4] << 128) + (z[5] << 160) + (z[6] << 192) + (z[7] << 224) */
/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */
/* twos_complement_eval z = let x1 := z[0] + (z[1] << 32) + (z[2] << 64) + (z[3] << 96) + (z[4] << 128) + (z[5] << 160) + (z[6] << 192) + (z[7] << 224) in */
/* if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 */
#include <stdint.h>
typedef unsigned char fiat_sm2_uint1;
typedef signed char fiat_sm2_int1;
#if defined(__GNUC__) || defined(__clang__)
# define FIAT_SM2_FIAT_INLINE __inline__
#else
# define FIAT_SM2_FIAT_INLINE
#endif
/* The type fiat_sm2_montgomery_domain_field_element is a field element in the Montgomery domain. */
/* Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */
typedef uint32_t fiat_sm2_montgomery_domain_field_element[8];
/* The type fiat_sm2_non_montgomery_domain_field_element is a field element NOT in the Montgomery domain. */
/* Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */
typedef uint32_t fiat_sm2_non_montgomery_domain_field_element[8];
#if (-1 & 3) != 3
#error "This code only works on a two's complement system"
#endif
#if !defined(FIAT_SM2_NO_ASM) && (defined(__GNUC__) || defined(__clang__))
static __inline__ uint32_t fiat_sm2_value_barrier_u32(uint32_t a) {
__asm__("" : "+r"(a) : /* no inputs */);
return a;
}
#else
# define fiat_sm2_value_barrier_u32(x) (x)
#endif
/*
* The function fiat_sm2_addcarryx_u32 is an addition with carry.
*
* Postconditions:
* out1 = (arg1 + arg2 + arg3) mod 2^32
* out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffff]
* arg3: [0x0 ~> 0xffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffff]
* out2: [0x0 ~> 0x1]
*/
static FIAT_SM2_FIAT_INLINE void fiat_sm2_addcarryx_u32(uint32_t* out1, fiat_sm2_uint1* out2, fiat_sm2_uint1 arg1, uint32_t arg2, uint32_t arg3) {
uint64_t x1;
uint32_t x2;
fiat_sm2_uint1 x3;
x1 = ((arg1 + (uint64_t)arg2) + arg3);
x2 = (uint32_t)(x1 & UINT32_C(0xffffffff));
x3 = (fiat_sm2_uint1)(x1 >> 32);
*out1 = x2;
*out2 = x3;
}
/*
* The function fiat_sm2_subborrowx_u32 is a subtraction with borrow.
*
* Postconditions:
* out1 = (-arg1 + arg2 + -arg3) mod 2^32
* out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffff]
* arg3: [0x0 ~> 0xffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffff]
* out2: [0x0 ~> 0x1]
*/
static FIAT_SM2_FIAT_INLINE void fiat_sm2_subborrowx_u32(uint32_t* out1, fiat_sm2_uint1* out2, fiat_sm2_uint1 arg1, uint32_t arg2, uint32_t arg3) {
int64_t x1;
fiat_sm2_int1 x2;
uint32_t x3;
x1 = ((arg2 - (int64_t)arg1) - arg3);
x2 = (fiat_sm2_int1)(x1 >> 32);
x3 = (uint32_t)(x1 & UINT32_C(0xffffffff));
*out1 = x3;
*out2 = (fiat_sm2_uint1)(0x0 - x2);
}
/*
* The function fiat_sm2_mulx_u32 is a multiplication, returning the full double-width result.
*
* Postconditions:
* out1 = (arg1 * arg2) mod 2^32
* out2 = ⌊arg1 * arg2 / 2^32⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0xffffffff]
* arg2: [0x0 ~> 0xffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffff]
* out2: [0x0 ~> 0xffffffff]
*/
static FIAT_SM2_FIAT_INLINE void fiat_sm2_mulx_u32(uint32_t* out1, uint32_t* out2, uint32_t arg1, uint32_t arg2) {
uint64_t x1;
uint32_t x2;
uint32_t x3;
x1 = ((uint64_t)arg1 * arg2);
x2 = (uint32_t)(x1 & UINT32_C(0xffffffff));
x3 = (uint32_t)(x1 >> 32);
*out1 = x2;
*out2 = x3;
}
/*
* The function fiat_sm2_cmovznz_u32 is a single-word conditional move.
*
* Postconditions:
* out1 = (if arg1 = 0 then arg2 else arg3)
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffff]
* arg3: [0x0 ~> 0xffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffff]
*/
static FIAT_SM2_FIAT_INLINE void fiat_sm2_cmovznz_u32(uint32_t* out1, fiat_sm2_uint1 arg1, uint32_t arg2, uint32_t arg3) {
fiat_sm2_uint1 x1;
uint32_t x2;
uint32_t x3;
x1 = (!(!arg1));
x2 = ((fiat_sm2_int1)(0x0 - x1) & UINT32_C(0xffffffff));
x3 = ((fiat_sm2_value_barrier_u32(x2) & arg3) | (fiat_sm2_value_barrier_u32((~x2)) & arg2));
*out1 = x3;
}
/*
* The function fiat_sm2_mul multiplies two field elements in the Montgomery domain.
*
* Preconditions:
* 0 ≤ eval arg1 < m
* 0 ≤ eval arg2 < m
* Postconditions:
* eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m
* 0 ≤ eval out1 < m
*
*/
static FIAT_SM2_FIAT_INLINE void fiat_sm2_mul(fiat_sm2_montgomery_domain_field_element out1, const fiat_sm2_montgomery_domain_field_element arg1, const fiat_sm2_montgomery_domain_field_element arg2) {
uint32_t x1;
uint32_t x2;
uint32_t x3;
uint32_t x4;
uint32_t x5;
uint32_t x6;
uint32_t x7;
uint32_t x8;
uint32_t x9;
uint32_t x10;
uint32_t x11;
uint32_t x12;
uint32_t x13;
uint32_t x14;
uint32_t x15;
uint32_t x16;
uint32_t x17;
uint32_t x18;
uint32_t x19;
uint32_t x20;
uint32_t x21;
uint32_t x22;
uint32_t x23;
uint32_t x24;
uint32_t x25;
fiat_sm2_uint1 x26;
uint32_t x27;
fiat_sm2_uint1 x28;
uint32_t x29;
fiat_sm2_uint1 x30;
uint32_t x31;
fiat_sm2_uint1 x32;
uint32_t x33;
fiat_sm2_uint1 x34;
uint32_t x35;
fiat_sm2_uint1 x36;
uint32_t x37;
fiat_sm2_uint1 x38;
uint32_t x39;
uint32_t x40;
uint32_t x41;
uint32_t x42;
uint32_t x43;
uint32_t x44;
uint32_t x45;
uint32_t x46;
uint32_t x47;
uint32_t x48;
uint32_t x49;
uint32_t x50;
uint32_t x51;
uint32_t x52;
uint32_t x53;
uint32_t x54;
fiat_sm2_uint1 x55;
uint32_t x56;
uint32_t x57;
fiat_sm2_uint1 x58;
uint32_t x59;
fiat_sm2_uint1 x60;
uint32_t x61;
fiat_sm2_uint1 x62;
uint32_t x63;
fiat_sm2_uint1 x64;
uint32_t x65;
uint32_t x66;
fiat_sm2_uint1 x67;
uint32_t x68;
fiat_sm2_uint1 x69;
uint32_t x70;
fiat_sm2_uint1 x71;
uint32_t x72;
fiat_sm2_uint1 x73;
uint32_t x74;
fiat_sm2_uint1 x75;
uint32_t x76;
fiat_sm2_uint1 x77;
uint32_t x78;
fiat_sm2_uint1 x79;
uint32_t x80;
fiat_sm2_uint1 x81;
uint32_t x82;
fiat_sm2_uint1 x83;
uint32_t x84;
uint32_t x85;
uint32_t x86;
uint32_t x87;
uint32_t x88;
uint32_t x89;
uint32_t x90;
uint32_t x91;
uint32_t x92;
uint32_t x93;
uint32_t x94;
uint32_t x95;
uint32_t x96;
uint32_t x97;
uint32_t x98;
uint32_t x99;
uint32_t x100;
fiat_sm2_uint1 x101;
uint32_t x102;
fiat_sm2_uint1 x103;
uint32_t x104;
fiat_sm2_uint1 x105;
uint32_t x106;
fiat_sm2_uint1 x107;
uint32_t x108;
fiat_sm2_uint1 x109;
uint32_t x110;
fiat_sm2_uint1 x111;
uint32_t x112;
fiat_sm2_uint1 x113;
uint32_t x114;
uint32_t x115;
fiat_sm2_uint1 x116;
uint32_t x117;
fiat_sm2_uint1 x118;
uint32_t x119;
fiat_sm2_uint1 x120;
uint32_t x121;
fiat_sm2_uint1 x122;
uint32_t x123;
fiat_sm2_uint1 x124;
uint32_t x125;
fiat_sm2_uint1 x126;
uint32_t x127;
fiat_sm2_uint1 x128;
uint32_t x129;
fiat_sm2_uint1 x130;
uint32_t x131;
fiat_sm2_uint1 x132;
uint32_t x133;
uint32_t x134;
uint32_t x135;
uint32_t x136;
uint32_t x137;
uint32_t x138;
uint32_t x139;
uint32_t x140;
uint32_t x141;
uint32_t x142;
uint32_t x143;
uint32_t x144;
uint32_t x145;
uint32_t x146;
uint32_t x147;
fiat_sm2_uint1 x148;
uint32_t x149;
uint32_t x150;
fiat_sm2_uint1 x151;
uint32_t x152;
fiat_sm2_uint1 x153;
uint32_t x154;
fiat_sm2_uint1 x155;
uint32_t x156;
fiat_sm2_uint1 x157;
uint32_t x158;
uint32_t x159;
fiat_sm2_uint1 x160;
uint32_t x161;
fiat_sm2_uint1 x162;
uint32_t x163;
fiat_sm2_uint1 x164;
uint32_t x165;
fiat_sm2_uint1 x166;
uint32_t x167;
fiat_sm2_uint1 x168;
uint32_t x169;
fiat_sm2_uint1 x170;
uint32_t x171;
fiat_sm2_uint1 x172;
uint32_t x173;
fiat_sm2_uint1 x174;
uint32_t x175;
fiat_sm2_uint1 x176;
uint32_t x177;
uint32_t x178;
uint32_t x179;
uint32_t x180;
uint32_t x181;
uint32_t x182;
uint32_t x183;
uint32_t x184;
uint32_t x185;
uint32_t x186;
uint32_t x187;
uint32_t x188;
uint32_t x189;
uint32_t x190;
uint32_t x191;
uint32_t x192;
uint32_t x193;
uint32_t x194;
fiat_sm2_uint1 x195;
uint32_t x196;
fiat_sm2_uint1 x197;
uint32_t x198;
fiat_sm2_uint1 x199;
uint32_t x200;
fiat_sm2_uint1 x201;
uint32_t x202;
fiat_sm2_uint1 x203;
uint32_t x204;
fiat_sm2_uint1 x205;
uint32_t x206;
fiat_sm2_uint1 x207;
uint32_t x208;
uint32_t x209;
fiat_sm2_uint1 x210;
uint32_t x211;
fiat_sm2_uint1 x212;
uint32_t x213;
fiat_sm2_uint1 x214;
uint32_t x215;
fiat_sm2_uint1 x216;
uint32_t x217;
fiat_sm2_uint1 x218;
uint32_t x219;
fiat_sm2_uint1 x220;
uint32_t x221;
fiat_sm2_uint1 x222;
uint32_t x223;
fiat_sm2_uint1 x224;
uint32_t x225;
fiat_sm2_uint1 x226;
uint32_t x227;
uint32_t x228;
uint32_t x229;
uint32_t x230;
uint32_t x231;
uint32_t x232;
uint32_t x233;
uint32_t x234;
uint32_t x235;
uint32_t x236;
uint32_t x237;
uint32_t x238;
uint32_t x239;
uint32_t x240;
uint32_t x241;
fiat_sm2_uint1 x242;
uint32_t x243;
uint32_t x244;
fiat_sm2_uint1 x245;
uint32_t x246;
fiat_sm2_uint1 x247;
uint32_t x248;
fiat_sm2_uint1 x249;
uint32_t x250;
fiat_sm2_uint1 x251;
uint32_t x252;
uint32_t x253;
fiat_sm2_uint1 x254;
uint32_t x255;
fiat_sm2_uint1 x256;
uint32_t x257;
fiat_sm2_uint1 x258;
uint32_t x259;
fiat_sm2_uint1 x260;
uint32_t x261;
fiat_sm2_uint1 x262;
uint32_t x263;
fiat_sm2_uint1 x264;
uint32_t x265;
fiat_sm2_uint1 x266;
uint32_t x267;
fiat_sm2_uint1 x268;
uint32_t x269;
fiat_sm2_uint1 x270;
uint32_t x271;
uint32_t x272;
uint32_t x273;
uint32_t x274;
uint32_t x275;
uint32_t x276;
uint32_t x277;
uint32_t x278;
uint32_t x279;
uint32_t x280;
uint32_t x281;
uint32_t x282;
uint32_t x283;
uint32_t x284;
uint32_t x285;
uint32_t x286;
uint32_t x287;
uint32_t x288;
fiat_sm2_uint1 x289;
uint32_t x290;
fiat_sm2_uint1 x291;
uint32_t x292;
fiat_sm2_uint1 x293;
uint32_t x294;
fiat_sm2_uint1 x295;
uint32_t x296;
fiat_sm2_uint1 x297;
uint32_t x298;
fiat_sm2_uint1 x299;
uint32_t x300;
fiat_sm2_uint1 x301;
uint32_t x302;
uint32_t x303;
fiat_sm2_uint1 x304;
uint32_t x305;
fiat_sm2_uint1 x306;
uint32_t x307;
fiat_sm2_uint1 x308;
uint32_t x309;
fiat_sm2_uint1 x310;
uint32_t x311;
fiat_sm2_uint1 x312;
uint32_t x313;
fiat_sm2_uint1 x314;
uint32_t x315;
fiat_sm2_uint1 x316;
uint32_t x317;
fiat_sm2_uint1 x318;
uint32_t x319;
fiat_sm2_uint1 x320;
uint32_t x321;
uint32_t x322;
uint32_t x323;
uint32_t x324;
uint32_t x325;
uint32_t x326;
uint32_t x327;
uint32_t x328;
uint32_t x329;
uint32_t x330;
uint32_t x331;
uint32_t x332;
uint32_t x333;
uint32_t x334;
uint32_t x335;
fiat_sm2_uint1 x336;
uint32_t x337;
uint32_t x338;
fiat_sm2_uint1 x339;
uint32_t x340;
fiat_sm2_uint1 x341;
uint32_t x342;
fiat_sm2_uint1 x343;
uint32_t x344;
fiat_sm2_uint1 x345;
uint32_t x346;
uint32_t x347;
fiat_sm2_uint1 x348;
uint32_t x349;
fiat_sm2_uint1 x350;
uint32_t x351;
fiat_sm2_uint1 x352;
uint32_t x353;
fiat_sm2_uint1 x354;
uint32_t x355;
fiat_sm2_uint1 x356;
uint32_t x357;
fiat_sm2_uint1 x358;
uint32_t x359;
fiat_sm2_uint1 x360;
uint32_t x361;
fiat_sm2_uint1 x362;
uint32_t x363;
fiat_sm2_uint1 x364;
uint32_t x365;
uint32_t x366;
uint32_t x367;
uint32_t x368;
uint32_t x369;
uint32_t x370;
uint32_t x371;
uint32_t x372;
uint32_t x373;
uint32_t x374;
uint32_t x375;
uint32_t x376;
uint32_t x377;
uint32_t x378;
uint32_t x379;
uint32_t x380;
uint32_t x381;
uint32_t x382;
fiat_sm2_uint1 x383;
uint32_t x384;
fiat_sm2_uint1 x385;
uint32_t x386;
fiat_sm2_uint1 x387;
uint32_t x388;
fiat_sm2_uint1 x389;
uint32_t x390;
fiat_sm2_uint1 x391;
uint32_t x392;
fiat_sm2_uint1 x393;
uint32_t x394;
fiat_sm2_uint1 x395;
uint32_t x396;
uint32_t x397;
fiat_sm2_uint1 x398;
uint32_t x399;
fiat_sm2_uint1 x400;
uint32_t x401;
fiat_sm2_uint1 x402;
uint32_t x403;
fiat_sm2_uint1 x404;
uint32_t x405;
fiat_sm2_uint1 x406;
uint32_t x407;
fiat_sm2_uint1 x408;
uint32_t x409;
fiat_sm2_uint1 x410;
uint32_t x411;
fiat_sm2_uint1 x412;
uint32_t x413;
fiat_sm2_uint1 x414;
uint32_t x415;
uint32_t x416;
uint32_t x417;
uint32_t x418;
uint32_t x419;
uint32_t x420;
uint32_t x421;
uint32_t x422;
uint32_t x423;
uint32_t x424;
uint32_t x425;
uint32_t x426;
uint32_t x427;
uint32_t x428;
uint32_t x429;
fiat_sm2_uint1 x430;
uint32_t x431;
uint32_t x432;
fiat_sm2_uint1 x433;
uint32_t x434;
fiat_sm2_uint1 x435;
uint32_t x436;
fiat_sm2_uint1 x437;
uint32_t x438;
fiat_sm2_uint1 x439;
uint32_t x440;
uint32_t x441;
fiat_sm2_uint1 x442;
uint32_t x443;
fiat_sm2_uint1 x444;
uint32_t x445;
fiat_sm2_uint1 x446;
uint32_t x447;
fiat_sm2_uint1 x448;
uint32_t x449;
fiat_sm2_uint1 x450;
uint32_t x451;
fiat_sm2_uint1 x452;
uint32_t x453;
fiat_sm2_uint1 x454;
uint32_t x455;
fiat_sm2_uint1 x456;
uint32_t x457;
fiat_sm2_uint1 x458;
uint32_t x459;
uint32_t x460;
uint32_t x461;
uint32_t x462;
uint32_t x463;
uint32_t x464;
uint32_t x465;
uint32_t x466;
uint32_t x467;
uint32_t x468;
uint32_t x469;
uint32_t x470;
uint32_t x471;
uint32_t x472;
uint32_t x473;
uint32_t x474;
uint32_t x475;
uint32_t x476;
fiat_sm2_uint1 x477;
uint32_t x478;
fiat_sm2_uint1 x479;
uint32_t x480;
fiat_sm2_uint1 x481;
uint32_t x482;
fiat_sm2_uint1 x483;
uint32_t x484;
fiat_sm2_uint1 x485;
uint32_t x486;
fiat_sm2_uint1 x487;
uint32_t x488;
fiat_sm2_uint1 x489;
uint32_t x490;
uint32_t x491;
fiat_sm2_uint1 x492;
uint32_t x493;
fiat_sm2_uint1 x494;
uint32_t x495;
fiat_sm2_uint1 x496;
uint32_t x497;
fiat_sm2_uint1 x498;
uint32_t x499;
fiat_sm2_uint1 x500;
uint32_t x501;
fiat_sm2_uint1 x502;
uint32_t x503;
fiat_sm2_uint1 x504;
uint32_t x505;
fiat_sm2_uint1 x506;
uint32_t x507;
fiat_sm2_uint1 x508;
uint32_t x509;
uint32_t x510;
uint32_t x511;
uint32_t x512;
uint32_t x513;
uint32_t x514;
uint32_t x515;
uint32_t x516;
uint32_t x517;
uint32_t x518;
uint32_t x519;
uint32_t x520;
uint32_t x521;
uint32_t x522;
uint32_t x523;
fiat_sm2_uint1 x524;
uint32_t x525;
uint32_t x526;
fiat_sm2_uint1 x527;
uint32_t x528;
fiat_sm2_uint1 x529;
uint32_t x530;
fiat_sm2_uint1 x531;
uint32_t x532;
fiat_sm2_uint1 x533;
uint32_t x534;
uint32_t x535;
fiat_sm2_uint1 x536;
uint32_t x537;
fiat_sm2_uint1 x538;
uint32_t x539;
fiat_sm2_uint1 x540;
uint32_t x541;
fiat_sm2_uint1 x542;
uint32_t x543;
fiat_sm2_uint1 x544;
uint32_t x545;
fiat_sm2_uint1 x546;
uint32_t x547;
fiat_sm2_uint1 x548;
uint32_t x549;
fiat_sm2_uint1 x550;
uint32_t x551;
fiat_sm2_uint1 x552;
uint32_t x553;
uint32_t x554;
uint32_t x555;
uint32_t x556;
uint32_t x557;
uint32_t x558;
uint32_t x559;
uint32_t x560;
uint32_t x561;
uint32_t x562;
uint32_t x563;
uint32_t x564;
uint32_t x565;
uint32_t x566;
uint32_t x567;
uint32_t x568;
uint32_t x569;
uint32_t x570;
fiat_sm2_uint1 x571;
uint32_t x572;
fiat_sm2_uint1 x573;
uint32_t x574;
fiat_sm2_uint1 x575;
uint32_t x576;
fiat_sm2_uint1 x577;
uint32_t x578;
fiat_sm2_uint1 x579;
uint32_t x580;
fiat_sm2_uint1 x581;
uint32_t x582;
fiat_sm2_uint1 x583;
uint32_t x584;
uint32_t x585;
fiat_sm2_uint1 x586;
uint32_t x587;
fiat_sm2_uint1 x588;
uint32_t x589;
fiat_sm2_uint1 x590;
uint32_t x591;
fiat_sm2_uint1 x592;
uint32_t x593;
fiat_sm2_uint1 x594;
uint32_t x595;
fiat_sm2_uint1 x596;
uint32_t x597;
fiat_sm2_uint1 x598;
uint32_t x599;
fiat_sm2_uint1 x600;
uint32_t x601;
fiat_sm2_uint1 x602;
uint32_t x603;
uint32_t x604;
uint32_t x605;
uint32_t x606;
uint32_t x607;
uint32_t x608;
uint32_t x609;
uint32_t x610;
uint32_t x611;
uint32_t x612;
uint32_t x613;
uint32_t x614;
uint32_t x615;
uint32_t x616;
uint32_t x617;
fiat_sm2_uint1 x618;
uint32_t x619;
uint32_t x620;
fiat_sm2_uint1 x621;
uint32_t x622;
fiat_sm2_uint1 x623;
uint32_t x624;
fiat_sm2_uint1 x625;
uint32_t x626;
fiat_sm2_uint1 x627;
uint32_t x628;
uint32_t x629;
fiat_sm2_uint1 x630;
uint32_t x631;
fiat_sm2_uint1 x632;
uint32_t x633;
fiat_sm2_uint1 x634;
uint32_t x635;
fiat_sm2_uint1 x636;
uint32_t x637;
fiat_sm2_uint1 x638;
uint32_t x639;
fiat_sm2_uint1 x640;
uint32_t x641;
fiat_sm2_uint1 x642;
uint32_t x643;
fiat_sm2_uint1 x644;
uint32_t x645;
fiat_sm2_uint1 x646;
uint32_t x647;
uint32_t x648;
uint32_t x649;
uint32_t x650;
uint32_t x651;
uint32_t x652;
uint32_t x653;
uint32_t x654;
uint32_t x655;
uint32_t x656;
uint32_t x657;
uint32_t x658;
uint32_t x659;
uint32_t x660;
uint32_t x661;
uint32_t x662;
uint32_t x663;
uint32_t x664;
fiat_sm2_uint1 x665;
uint32_t x666;
fiat_sm2_uint1 x667;
uint32_t x668;
fiat_sm2_uint1 x669;
uint32_t x670;
fiat_sm2_uint1 x671;
uint32_t x672;
fiat_sm2_uint1 x673;
uint32_t x674;
fiat_sm2_uint1 x675;
uint32_t x676;
fiat_sm2_uint1 x677;
uint32_t x678;
uint32_t x679;
fiat_sm2_uint1 x680;
uint32_t x681;
fiat_sm2_uint1 x682;
uint32_t x683;
fiat_sm2_uint1 x684;
uint32_t x685;
fiat_sm2_uint1 x686;
uint32_t x687;
fiat_sm2_uint1 x688;
uint32_t x689;
fiat_sm2_uint1 x690;
uint32_t x691;
fiat_sm2_uint1 x692;
uint32_t x693;
fiat_sm2_uint1 x694;
uint32_t x695;
fiat_sm2_uint1 x696;
uint32_t x697;
uint32_t x698;
uint32_t x699;
uint32_t x700;
uint32_t x701;
uint32_t x702;
uint32_t x703;
uint32_t x704;
uint32_t x705;
uint32_t x706;
uint32_t x707;
uint32_t x708;
uint32_t x709;
uint32_t x710;
uint32_t x711;
fiat_sm2_uint1 x712;
uint32_t x713;
uint32_t x714;
fiat_sm2_uint1 x715;
uint32_t x716;
fiat_sm2_uint1 x717;
uint32_t x718;
fiat_sm2_uint1 x719;
uint32_t x720;
fiat_sm2_uint1 x721;
uint32_t x722;
uint32_t x723;
fiat_sm2_uint1 x724;
uint32_t x725;
fiat_sm2_uint1 x726;
uint32_t x727;
fiat_sm2_uint1 x728;
uint32_t x729;
fiat_sm2_uint1 x730;
uint32_t x731;
fiat_sm2_uint1 x732;
uint32_t x733;
fiat_sm2_uint1 x734;
uint32_t x735;
fiat_sm2_uint1 x736;
uint32_t x737;
fiat_sm2_uint1 x738;
uint32_t x739;
fiat_sm2_uint1 x740;
uint32_t x741;
uint32_t x742;
fiat_sm2_uint1 x743;
uint32_t x744;
fiat_sm2_uint1 x745;
uint32_t x746;
fiat_sm2_uint1 x747;
uint32_t x748;
fiat_sm2_uint1 x749;
uint32_t x750;
fiat_sm2_uint1 x751;
uint32_t x752;
fiat_sm2_uint1 x753;
uint32_t x754;
fiat_sm2_uint1 x755;
uint32_t x756;
fiat_sm2_uint1 x757;
uint32_t x758;
fiat_sm2_uint1 x759;
uint32_t x760;
uint32_t x761;
uint32_t x762;
uint32_t x763;
uint32_t x764;
uint32_t x765;
uint32_t x766;
uint32_t x767;
x1 = (arg1[1]);
x2 = (arg1[2]);
x3 = (arg1[3]);
x4 = (arg1[4]);
x5 = (arg1[5]);
x6 = (arg1[6]);
x7 = (arg1[7]);
x8 = (arg1[0]);
fiat_sm2_mulx_u32(&x9, &x10, x8, (arg2[7]));
fiat_sm2_mulx_u32(&x11, &x12, x8, (arg2[6]));
fiat_sm2_mulx_u32(&x13, &x14, x8, (arg2[5]));
fiat_sm2_mulx_u32(&x15, &x16, x8, (arg2[4]));
fiat_sm2_mulx_u32(&x17, &x18, x8, (arg2[3]));
fiat_sm2_mulx_u32(&x19, &x20, x8, (arg2[2]));
fiat_sm2_mulx_u32(&x21, &x22, x8, (arg2[1]));
fiat_sm2_mulx_u32(&x23, &x24, x8, (arg2[0]));
fiat_sm2_addcarryx_u32(&x25, &x26, 0x0, x24, x21);
fiat_sm2_addcarryx_u32(&x27, &x28, x26, x22, x19);
fiat_sm2_addcarryx_u32(&x29, &x30, x28, x20, x17);
fiat_sm2_addcarryx_u32(&x31, &x32, x30, x18, x15);
fiat_sm2_addcarryx_u32(&x33, &x34, x32, x16, x13);
fiat_sm2_addcarryx_u32(&x35, &x36, x34, x14, x11);
fiat_sm2_addcarryx_u32(&x37, &x38, x36, x12, x9);
x39 = (x38 + x10);
fiat_sm2_mulx_u32(&x40, &x41, x23, UINT32_C(0xfffffffe));
fiat_sm2_mulx_u32(&x42, &x43, x23, UINT32_C(0xffffffff));
fiat_sm2_mulx_u32(&x44, &x45, x23, UINT32_C(0xffffffff));
fiat_sm2_mulx_u32(&x46, &x47, x23, UINT32_C(0xffffffff));
fiat_sm2_mulx_u32(&x48, &x49, x23, UINT32_C(0xffffffff));
fiat_sm2_mulx_u32(&x50, &x51, x23, UINT32_C(0xffffffff));
fiat_sm2_mulx_u32(&x52, &x53, x23, UINT32_C(0xffffffff));
fiat_sm2_addcarryx_u32(&x54, &x55, 0x0, x53, x50);
x56 = (x55 + x51);
fiat_sm2_addcarryx_u32(&x57, &x58, 0x0, x49, x46);
fiat_sm2_addcarryx_u32(&x59, &x60, x58, x47, x44);
fiat_sm2_addcarryx_u32(&x61, &x62, x60, x45, x42);
fiat_sm2_addcarryx_u32(&x63, &x64, x62, x43, x40);
x65 = (x64 + x41);
fiat_sm2_addcarryx_u32(&x66, &x67, 0x0, x23, x52);
fiat_sm2_addcarryx_u32(&x68, &x69, x67, x25, x54);
fiat_sm2_addcarryx_u32(&x70, &x71, x69, x27, x56);
fiat_sm2_addcarryx_u32(&x72, &x73, x71, x29, x48);
fiat_sm2_addcarryx_u32(&x74, &x75, x73, x31, x57);
fiat_sm2_addcarryx_u32(&x76, &x77, x75, x33, x59);
fiat_sm2_addcarryx_u32(&x78, &x79, x77, x35, x61);
fiat_sm2_addcarryx_u32(&x80, &x81, x79, x37, x63);
fiat_sm2_addcarryx_u32(&x82, &x83, x81, x39, x65);
fiat_sm2_mulx_u32(&x84, &x85, x1, (arg2[7]));
fiat_sm2_mulx_u32(&x86, &x87, x1, (arg2[6]));
fiat_sm2_mulx_u32(&x88, &x89, x1, (arg2[5]));
fiat_sm2_mulx_u32(&x90, &x91, x1, (arg2[4]));
fiat_sm2_mulx_u32(&x92, &x93, x1, (arg2[3]));
fiat_sm2_mulx_u32(&x94, &x95, x1, (arg2[2]));
fiat_sm2_mulx_u32(&x96, &x97, x1, (arg2[1]));
fiat_sm2_mulx_u32(&x98, &x99, x1, (arg2[0]));
fiat_sm2_addcarryx_u32(&x100, &x101, 0x0, x99, x96);
fiat_sm2_addcarryx_u32(&x102, &x103, x101, x97, x94);
fiat_sm2_addcarryx_u32(&x104, &x105, x103, x95, x92);
fiat_sm2_addcarryx_u32(&x106, &x107, x105, x93, x90);
fiat_sm2_addcarryx_u32(&x108, &x109, x107, x91, x88);
fiat_sm2_addcarryx_u32(&x110, &x111, x109, x89, x86);
fiat_sm2_addcarryx_u32(&x112, &x113, x111, x87, x84);
x114 = (x113 + x85);
fiat_sm2_addcarryx_u32(&x115, &x116, 0x0, x68, x98);
fiat_sm2_addcarryx_u32(&x117, &x118, x116, x70, x100);
fiat_sm2_addcarryx_u32(&x119, &x120, x118, x72, x102);
fiat_sm2_addcarryx_u32(&x121, &x122, x120, x74, x104);
fiat_sm2_addcarryx_u32(&x123, &x124, x122, x76, x106);
fiat_sm2_addcarryx_u32(&x125, &x126, x124, x78, x108);
fiat_sm2_addcarryx_u32(&x127, &x128, x126, x80, x110);
fiat_sm2_addcarryx_u32(&x129, &x130, x128, x82, x112);