forked from MinaProtocol/c-reference-signer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pasta_fq.c
2070 lines (2039 loc) · 69 KB
/
pasta_fq.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 pasta_fq 64 '2^254 + 45560315531506369815346746415080538113' */
/* curve description: pasta_fq */
/* machine_wordsize = 64 (from "64") */
/* requested operations: (all) */
/* m = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001 (from "2^254 + 45560315531506369815346746415080538113") */
/* */
/* 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] << 64) + (z[2] << 128) + (z[3] << 192) */
/* 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) */
#include <stdint.h>
#include <inttypes.h>
typedef unsigned char fiat_pasta_fq_uint1;
typedef signed char fiat_pasta_fq_int1;
#if (-1 & 3) != 3
#error "This code only works on a two's complement system"
#endif
/*
* The function fiat_pasta_fq_addcarryx_u64 is an addition with carry.
* Postconditions:
* out1 = (arg1 + arg2 + arg3) mod 2^64
* out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffffffffffff]
* arg3: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
* out2: [0x0 ~> 0x1]
*/
void fiat_pasta_fq_addcarryx_u64(uint64_t* out1, fiat_pasta_fq_uint1* out2, fiat_pasta_fq_uint1 arg1, uint64_t arg2, uint64_t arg3) {
uint64_t tmp = arg3 + arg1;
*out1 = arg2 + tmp;
*out2 = (arg2 > *out1) | (arg3 > tmp);
}
/*
* The function fiat_pasta_fq_subborrowx_u64 is a subtraction with borrow.
* Postconditions:
* out1 = (-arg1 + arg2 + -arg3) mod 2^64
* out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffffffffffff]
* arg3: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
* out2: [0x0 ~> 0x1]
*/
void fiat_pasta_fq_subborrowx_u64(uint64_t* out1, fiat_pasta_fq_uint1* out2, fiat_pasta_fq_uint1 arg1, uint64_t arg2, uint64_t arg3) {
uint64_t tmp = arg3 + arg1;
*out1 = arg2 - tmp;
*out2 = (arg2 < *out1) | (arg3 > tmp);
}
/*
* The function fiat_pasta_fq_mulx_u64 is a multiplication, returning the full double-width result.
* Postconditions:
* out1 = (arg1 * arg2) mod 2^64
* out2 = ⌊arg1 * arg2 / 2^64⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0xffffffffffffffff]
* arg2: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
* out2: [0x0 ~> 0xffffffffffffffff]
*/
void fiat_pasta_fq_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t a, uint64_t b) {
uint64_t a_lo = (uint32_t)a;
uint64_t a_hi = a >> 32;
uint64_t b_lo = (uint32_t)b;
uint64_t b_hi = b >> 32;
uint64_t a_x_b_hi = a_hi * b_hi;
uint64_t a_x_b_mid = a_hi * b_lo;
uint64_t b_x_a_mid = b_hi * a_lo;
uint64_t a_x_b_lo = a_lo * b_lo;
uint64_t carry_bit = ((uint64_t)(uint32_t)a_x_b_mid +
(uint64_t)(uint32_t)b_x_a_mid +
(a_x_b_lo >> 32) ) >> 32;
uint64_t multhi = a_x_b_hi +
(a_x_b_mid >> 32) + (b_x_a_mid >> 32) +
carry_bit;
*out2 = multhi;
// TODO: This multiplication could be avoided.
*out1 = a * b;
}
/*
* The function fiat_pasta_fq_cmovznz_u64 is a single-word conditional move.
* Postconditions:
* out1 = (if arg1 = 0 then arg2 else arg3)
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffffffffffff]
* arg3: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
*/
void fiat_pasta_fq_cmovznz_u64(uint64_t* out1, fiat_pasta_fq_uint1 arg1, uint64_t arg2, uint64_t arg3) {
fiat_pasta_fq_uint1 x1;
uint64_t x2;
uint64_t x3;
x1 = (!(!arg1));
x2 = ((fiat_pasta_fq_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff));
x3 = ((x2 & arg3) | ((~x2) & arg2));
*out1 = x3;
}
/*
* The function fiat_pasta_fq_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
*
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* Output Bounds:
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
*/
void fiat_pasta_fq_mul(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) {
uint64_t x1;
uint64_t x2;
uint64_t x3;
uint64_t x4;
uint64_t x5;
uint64_t x6;
uint64_t x7;
uint64_t x8;
uint64_t x9;
uint64_t x10;
uint64_t x11;
uint64_t x12;
uint64_t x13;
fiat_pasta_fq_uint1 x14;
uint64_t x15;
fiat_pasta_fq_uint1 x16;
uint64_t x17;
fiat_pasta_fq_uint1 x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
uint64_t x23;
uint64_t x24;
uint64_t x25;
uint64_t x26;
uint64_t x27;
uint64_t x28;
fiat_pasta_fq_uint1 x29;
uint64_t x30;
uint64_t x31;
fiat_pasta_fq_uint1 x32;
uint64_t x33;
fiat_pasta_fq_uint1 x34;
uint64_t x35;
fiat_pasta_fq_uint1 x36;
uint64_t x37;
fiat_pasta_fq_uint1 x38;
uint64_t x39;
fiat_pasta_fq_uint1 x40;
uint64_t x41;
uint64_t x42;
uint64_t x43;
uint64_t x44;
uint64_t x45;
uint64_t x46;
uint64_t x47;
uint64_t x48;
uint64_t x49;
fiat_pasta_fq_uint1 x50;
uint64_t x51;
fiat_pasta_fq_uint1 x52;
uint64_t x53;
fiat_pasta_fq_uint1 x54;
uint64_t x55;
uint64_t x56;
fiat_pasta_fq_uint1 x57;
uint64_t x58;
fiat_pasta_fq_uint1 x59;
uint64_t x60;
fiat_pasta_fq_uint1 x61;
uint64_t x62;
fiat_pasta_fq_uint1 x63;
uint64_t x64;
fiat_pasta_fq_uint1 x65;
uint64_t x66;
uint64_t x67;
uint64_t x68;
uint64_t x69;
uint64_t x70;
uint64_t x71;
uint64_t x72;
uint64_t x73;
uint64_t x74;
fiat_pasta_fq_uint1 x75;
uint64_t x76;
uint64_t x77;
fiat_pasta_fq_uint1 x78;
uint64_t x79;
fiat_pasta_fq_uint1 x80;
uint64_t x81;
fiat_pasta_fq_uint1 x82;
uint64_t x83;
fiat_pasta_fq_uint1 x84;
uint64_t x85;
fiat_pasta_fq_uint1 x86;
uint64_t x87;
uint64_t x88;
uint64_t x89;
uint64_t x90;
uint64_t x91;
uint64_t x92;
uint64_t x93;
uint64_t x94;
uint64_t x95;
uint64_t x96;
fiat_pasta_fq_uint1 x97;
uint64_t x98;
fiat_pasta_fq_uint1 x99;
uint64_t x100;
fiat_pasta_fq_uint1 x101;
uint64_t x102;
uint64_t x103;
fiat_pasta_fq_uint1 x104;
uint64_t x105;
fiat_pasta_fq_uint1 x106;
uint64_t x107;
fiat_pasta_fq_uint1 x108;
uint64_t x109;
fiat_pasta_fq_uint1 x110;
uint64_t x111;
fiat_pasta_fq_uint1 x112;
uint64_t x113;
uint64_t x114;
uint64_t x115;
uint64_t x116;
uint64_t x117;
uint64_t x118;
uint64_t x119;
uint64_t x120;
uint64_t x121;
fiat_pasta_fq_uint1 x122;
uint64_t x123;
uint64_t x124;
fiat_pasta_fq_uint1 x125;
uint64_t x126;
fiat_pasta_fq_uint1 x127;
uint64_t x128;
fiat_pasta_fq_uint1 x129;
uint64_t x130;
fiat_pasta_fq_uint1 x131;
uint64_t x132;
fiat_pasta_fq_uint1 x133;
uint64_t x134;
uint64_t x135;
uint64_t x136;
uint64_t x137;
uint64_t x138;
uint64_t x139;
uint64_t x140;
uint64_t x141;
uint64_t x142;
uint64_t x143;
fiat_pasta_fq_uint1 x144;
uint64_t x145;
fiat_pasta_fq_uint1 x146;
uint64_t x147;
fiat_pasta_fq_uint1 x148;
uint64_t x149;
uint64_t x150;
fiat_pasta_fq_uint1 x151;
uint64_t x152;
fiat_pasta_fq_uint1 x153;
uint64_t x154;
fiat_pasta_fq_uint1 x155;
uint64_t x156;
fiat_pasta_fq_uint1 x157;
uint64_t x158;
fiat_pasta_fq_uint1 x159;
uint64_t x160;
uint64_t x161;
uint64_t x162;
uint64_t x163;
uint64_t x164;
uint64_t x165;
uint64_t x166;
uint64_t x167;
uint64_t x168;
fiat_pasta_fq_uint1 x169;
uint64_t x170;
uint64_t x171;
fiat_pasta_fq_uint1 x172;
uint64_t x173;
fiat_pasta_fq_uint1 x174;
uint64_t x175;
fiat_pasta_fq_uint1 x176;
uint64_t x177;
fiat_pasta_fq_uint1 x178;
uint64_t x179;
fiat_pasta_fq_uint1 x180;
uint64_t x181;
uint64_t x182;
fiat_pasta_fq_uint1 x183;
uint64_t x184;
fiat_pasta_fq_uint1 x185;
uint64_t x186;
fiat_pasta_fq_uint1 x187;
uint64_t x188;
fiat_pasta_fq_uint1 x189;
uint64_t x190;
fiat_pasta_fq_uint1 x191;
uint64_t x192;
uint64_t x193;
uint64_t x194;
uint64_t x195;
x1 = (arg1[1]);
x2 = (arg1[2]);
x3 = (arg1[3]);
x4 = (arg1[0]);
fiat_pasta_fq_mulx_u64(&x5, &x6, x4, (arg2[3]));
fiat_pasta_fq_mulx_u64(&x7, &x8, x4, (arg2[2]));
fiat_pasta_fq_mulx_u64(&x9, &x10, x4, (arg2[1]));
fiat_pasta_fq_mulx_u64(&x11, &x12, x4, (arg2[0]));
fiat_pasta_fq_addcarryx_u64(&x13, &x14, 0x0, x12, x9);
fiat_pasta_fq_addcarryx_u64(&x15, &x16, x14, x10, x7);
fiat_pasta_fq_addcarryx_u64(&x17, &x18, x16, x8, x5);
x19 = (x18 + x6);
fiat_pasta_fq_mulx_u64(&x20, &x21, x11, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x22, &x23, x20, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x24, &x25, x20, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x26, &x27, x20, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x28, &x29, 0x0, x27, x24);
x30 = (x29 + x25);
fiat_pasta_fq_addcarryx_u64(&x31, &x32, 0x0, x11, x26);
fiat_pasta_fq_addcarryx_u64(&x33, &x34, x32, x13, x28);
fiat_pasta_fq_addcarryx_u64(&x35, &x36, x34, x15, x30);
fiat_pasta_fq_addcarryx_u64(&x37, &x38, x36, x17, x22);
fiat_pasta_fq_addcarryx_u64(&x39, &x40, x38, x19, x23);
fiat_pasta_fq_mulx_u64(&x41, &x42, x1, (arg2[3]));
fiat_pasta_fq_mulx_u64(&x43, &x44, x1, (arg2[2]));
fiat_pasta_fq_mulx_u64(&x45, &x46, x1, (arg2[1]));
fiat_pasta_fq_mulx_u64(&x47, &x48, x1, (arg2[0]));
fiat_pasta_fq_addcarryx_u64(&x49, &x50, 0x0, x48, x45);
fiat_pasta_fq_addcarryx_u64(&x51, &x52, x50, x46, x43);
fiat_pasta_fq_addcarryx_u64(&x53, &x54, x52, x44, x41);
x55 = (x54 + x42);
fiat_pasta_fq_addcarryx_u64(&x56, &x57, 0x0, x33, x47);
fiat_pasta_fq_addcarryx_u64(&x58, &x59, x57, x35, x49);
fiat_pasta_fq_addcarryx_u64(&x60, &x61, x59, x37, x51);
fiat_pasta_fq_addcarryx_u64(&x62, &x63, x61, x39, x53);
fiat_pasta_fq_addcarryx_u64(&x64, &x65, x63, x40, x55);
fiat_pasta_fq_mulx_u64(&x66, &x67, x56, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x68, &x69, x66, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x70, &x71, x66, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x72, &x73, x66, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x74, &x75, 0x0, x73, x70);
x76 = (x75 + x71);
fiat_pasta_fq_addcarryx_u64(&x77, &x78, 0x0, x56, x72);
fiat_pasta_fq_addcarryx_u64(&x79, &x80, x78, x58, x74);
fiat_pasta_fq_addcarryx_u64(&x81, &x82, x80, x60, x76);
fiat_pasta_fq_addcarryx_u64(&x83, &x84, x82, x62, x68);
fiat_pasta_fq_addcarryx_u64(&x85, &x86, x84, x64, x69);
x87 = ((uint64_t)x86 + x65);
fiat_pasta_fq_mulx_u64(&x88, &x89, x2, (arg2[3]));
fiat_pasta_fq_mulx_u64(&x90, &x91, x2, (arg2[2]));
fiat_pasta_fq_mulx_u64(&x92, &x93, x2, (arg2[1]));
fiat_pasta_fq_mulx_u64(&x94, &x95, x2, (arg2[0]));
fiat_pasta_fq_addcarryx_u64(&x96, &x97, 0x0, x95, x92);
fiat_pasta_fq_addcarryx_u64(&x98, &x99, x97, x93, x90);
fiat_pasta_fq_addcarryx_u64(&x100, &x101, x99, x91, x88);
x102 = (x101 + x89);
fiat_pasta_fq_addcarryx_u64(&x103, &x104, 0x0, x79, x94);
fiat_pasta_fq_addcarryx_u64(&x105, &x106, x104, x81, x96);
fiat_pasta_fq_addcarryx_u64(&x107, &x108, x106, x83, x98);
fiat_pasta_fq_addcarryx_u64(&x109, &x110, x108, x85, x100);
fiat_pasta_fq_addcarryx_u64(&x111, &x112, x110, x87, x102);
fiat_pasta_fq_mulx_u64(&x113, &x114, x103, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x115, &x116, x113, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x117, &x118, x113, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x119, &x120, x113, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x121, &x122, 0x0, x120, x117);
x123 = (x122 + x118);
fiat_pasta_fq_addcarryx_u64(&x124, &x125, 0x0, x103, x119);
fiat_pasta_fq_addcarryx_u64(&x126, &x127, x125, x105, x121);
fiat_pasta_fq_addcarryx_u64(&x128, &x129, x127, x107, x123);
fiat_pasta_fq_addcarryx_u64(&x130, &x131, x129, x109, x115);
fiat_pasta_fq_addcarryx_u64(&x132, &x133, x131, x111, x116);
x134 = ((uint64_t)x133 + x112);
fiat_pasta_fq_mulx_u64(&x135, &x136, x3, (arg2[3]));
fiat_pasta_fq_mulx_u64(&x137, &x138, x3, (arg2[2]));
fiat_pasta_fq_mulx_u64(&x139, &x140, x3, (arg2[1]));
fiat_pasta_fq_mulx_u64(&x141, &x142, x3, (arg2[0]));
fiat_pasta_fq_addcarryx_u64(&x143, &x144, 0x0, x142, x139);
fiat_pasta_fq_addcarryx_u64(&x145, &x146, x144, x140, x137);
fiat_pasta_fq_addcarryx_u64(&x147, &x148, x146, x138, x135);
x149 = (x148 + x136);
fiat_pasta_fq_addcarryx_u64(&x150, &x151, 0x0, x126, x141);
fiat_pasta_fq_addcarryx_u64(&x152, &x153, x151, x128, x143);
fiat_pasta_fq_addcarryx_u64(&x154, &x155, x153, x130, x145);
fiat_pasta_fq_addcarryx_u64(&x156, &x157, x155, x132, x147);
fiat_pasta_fq_addcarryx_u64(&x158, &x159, x157, x134, x149);
fiat_pasta_fq_mulx_u64(&x160, &x161, x150, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x162, &x163, x160, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x164, &x165, x160, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x166, &x167, x160, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x168, &x169, 0x0, x167, x164);
x170 = (x169 + x165);
fiat_pasta_fq_addcarryx_u64(&x171, &x172, 0x0, x150, x166);
fiat_pasta_fq_addcarryx_u64(&x173, &x174, x172, x152, x168);
fiat_pasta_fq_addcarryx_u64(&x175, &x176, x174, x154, x170);
fiat_pasta_fq_addcarryx_u64(&x177, &x178, x176, x156, x162);
fiat_pasta_fq_addcarryx_u64(&x179, &x180, x178, x158, x163);
x181 = ((uint64_t)x180 + x159);
fiat_pasta_fq_subborrowx_u64(&x182, &x183, 0x0, x173, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_subborrowx_u64(&x184, &x185, x183, x175, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_subborrowx_u64(&x186, &x187, x185, x177, 0x0);
fiat_pasta_fq_subborrowx_u64(&x188, &x189, x187, x179, UINT64_C(0x4000000000000000));
fiat_pasta_fq_subborrowx_u64(&x190, &x191, x189, x181, 0x0);
fiat_pasta_fq_cmovznz_u64(&x192, x191, x182, x173);
fiat_pasta_fq_cmovznz_u64(&x193, x191, x184, x175);
fiat_pasta_fq_cmovznz_u64(&x194, x191, x186, x177);
fiat_pasta_fq_cmovznz_u64(&x195, x191, x188, x179);
out1[0] = x192;
out1[1] = x193;
out1[2] = x194;
out1[3] = x195;
}
/*
* The function fiat_pasta_fq_square squares a field element in the Montgomery domain.
* Preconditions:
* 0 ≤ eval arg1 < m
* Postconditions:
* eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m
* 0 ≤ eval out1 < m
*
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* Output Bounds:
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
*/
void fiat_pasta_fq_square(uint64_t out1[4], const uint64_t arg1[4]) {
uint64_t x1;
uint64_t x2;
uint64_t x3;
uint64_t x4;
uint64_t x5;
uint64_t x6;
uint64_t x7;
uint64_t x8;
uint64_t x9;
uint64_t x10;
uint64_t x11;
uint64_t x12;
uint64_t x13;
fiat_pasta_fq_uint1 x14;
uint64_t x15;
fiat_pasta_fq_uint1 x16;
uint64_t x17;
fiat_pasta_fq_uint1 x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
uint64_t x23;
uint64_t x24;
uint64_t x25;
uint64_t x26;
uint64_t x27;
uint64_t x28;
fiat_pasta_fq_uint1 x29;
uint64_t x30;
uint64_t x31;
fiat_pasta_fq_uint1 x32;
uint64_t x33;
fiat_pasta_fq_uint1 x34;
uint64_t x35;
fiat_pasta_fq_uint1 x36;
uint64_t x37;
fiat_pasta_fq_uint1 x38;
uint64_t x39;
fiat_pasta_fq_uint1 x40;
uint64_t x41;
uint64_t x42;
uint64_t x43;
uint64_t x44;
uint64_t x45;
uint64_t x46;
uint64_t x47;
uint64_t x48;
uint64_t x49;
fiat_pasta_fq_uint1 x50;
uint64_t x51;
fiat_pasta_fq_uint1 x52;
uint64_t x53;
fiat_pasta_fq_uint1 x54;
uint64_t x55;
uint64_t x56;
fiat_pasta_fq_uint1 x57;
uint64_t x58;
fiat_pasta_fq_uint1 x59;
uint64_t x60;
fiat_pasta_fq_uint1 x61;
uint64_t x62;
fiat_pasta_fq_uint1 x63;
uint64_t x64;
fiat_pasta_fq_uint1 x65;
uint64_t x66;
uint64_t x67;
uint64_t x68;
uint64_t x69;
uint64_t x70;
uint64_t x71;
uint64_t x72;
uint64_t x73;
uint64_t x74;
fiat_pasta_fq_uint1 x75;
uint64_t x76;
uint64_t x77;
fiat_pasta_fq_uint1 x78;
uint64_t x79;
fiat_pasta_fq_uint1 x80;
uint64_t x81;
fiat_pasta_fq_uint1 x82;
uint64_t x83;
fiat_pasta_fq_uint1 x84;
uint64_t x85;
fiat_pasta_fq_uint1 x86;
uint64_t x87;
uint64_t x88;
uint64_t x89;
uint64_t x90;
uint64_t x91;
uint64_t x92;
uint64_t x93;
uint64_t x94;
uint64_t x95;
uint64_t x96;
fiat_pasta_fq_uint1 x97;
uint64_t x98;
fiat_pasta_fq_uint1 x99;
uint64_t x100;
fiat_pasta_fq_uint1 x101;
uint64_t x102;
uint64_t x103;
fiat_pasta_fq_uint1 x104;
uint64_t x105;
fiat_pasta_fq_uint1 x106;
uint64_t x107;
fiat_pasta_fq_uint1 x108;
uint64_t x109;
fiat_pasta_fq_uint1 x110;
uint64_t x111;
fiat_pasta_fq_uint1 x112;
uint64_t x113;
uint64_t x114;
uint64_t x115;
uint64_t x116;
uint64_t x117;
uint64_t x118;
uint64_t x119;
uint64_t x120;
uint64_t x121;
fiat_pasta_fq_uint1 x122;
uint64_t x123;
uint64_t x124;
fiat_pasta_fq_uint1 x125;
uint64_t x126;
fiat_pasta_fq_uint1 x127;
uint64_t x128;
fiat_pasta_fq_uint1 x129;
uint64_t x130;
fiat_pasta_fq_uint1 x131;
uint64_t x132;
fiat_pasta_fq_uint1 x133;
uint64_t x134;
uint64_t x135;
uint64_t x136;
uint64_t x137;
uint64_t x138;
uint64_t x139;
uint64_t x140;
uint64_t x141;
uint64_t x142;
uint64_t x143;
fiat_pasta_fq_uint1 x144;
uint64_t x145;
fiat_pasta_fq_uint1 x146;
uint64_t x147;
fiat_pasta_fq_uint1 x148;
uint64_t x149;
uint64_t x150;
fiat_pasta_fq_uint1 x151;
uint64_t x152;
fiat_pasta_fq_uint1 x153;
uint64_t x154;
fiat_pasta_fq_uint1 x155;
uint64_t x156;
fiat_pasta_fq_uint1 x157;
uint64_t x158;
fiat_pasta_fq_uint1 x159;
uint64_t x160;
uint64_t x161;
uint64_t x162;
uint64_t x163;
uint64_t x164;
uint64_t x165;
uint64_t x166;
uint64_t x167;
uint64_t x168;
fiat_pasta_fq_uint1 x169;
uint64_t x170;
uint64_t x171;
fiat_pasta_fq_uint1 x172;
uint64_t x173;
fiat_pasta_fq_uint1 x174;
uint64_t x175;
fiat_pasta_fq_uint1 x176;
uint64_t x177;
fiat_pasta_fq_uint1 x178;
uint64_t x179;
fiat_pasta_fq_uint1 x180;
uint64_t x181;
uint64_t x182;
fiat_pasta_fq_uint1 x183;
uint64_t x184;
fiat_pasta_fq_uint1 x185;
uint64_t x186;
fiat_pasta_fq_uint1 x187;
uint64_t x188;
fiat_pasta_fq_uint1 x189;
uint64_t x190;
fiat_pasta_fq_uint1 x191;
uint64_t x192;
uint64_t x193;
uint64_t x194;
uint64_t x195;
x1 = (arg1[1]);
x2 = (arg1[2]);
x3 = (arg1[3]);
x4 = (arg1[0]);
fiat_pasta_fq_mulx_u64(&x5, &x6, x4, (arg1[3]));
fiat_pasta_fq_mulx_u64(&x7, &x8, x4, (arg1[2]));
fiat_pasta_fq_mulx_u64(&x9, &x10, x4, (arg1[1]));
fiat_pasta_fq_mulx_u64(&x11, &x12, x4, (arg1[0]));
fiat_pasta_fq_addcarryx_u64(&x13, &x14, 0x0, x12, x9);
fiat_pasta_fq_addcarryx_u64(&x15, &x16, x14, x10, x7);
fiat_pasta_fq_addcarryx_u64(&x17, &x18, x16, x8, x5);
x19 = (x18 + x6);
fiat_pasta_fq_mulx_u64(&x20, &x21, x11, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x22, &x23, x20, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x24, &x25, x20, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x26, &x27, x20, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x28, &x29, 0x0, x27, x24);
x30 = (x29 + x25);
fiat_pasta_fq_addcarryx_u64(&x31, &x32, 0x0, x11, x26);
fiat_pasta_fq_addcarryx_u64(&x33, &x34, x32, x13, x28);
fiat_pasta_fq_addcarryx_u64(&x35, &x36, x34, x15, x30);
fiat_pasta_fq_addcarryx_u64(&x37, &x38, x36, x17, x22);
fiat_pasta_fq_addcarryx_u64(&x39, &x40, x38, x19, x23);
fiat_pasta_fq_mulx_u64(&x41, &x42, x1, (arg1[3]));
fiat_pasta_fq_mulx_u64(&x43, &x44, x1, (arg1[2]));
fiat_pasta_fq_mulx_u64(&x45, &x46, x1, (arg1[1]));
fiat_pasta_fq_mulx_u64(&x47, &x48, x1, (arg1[0]));
fiat_pasta_fq_addcarryx_u64(&x49, &x50, 0x0, x48, x45);
fiat_pasta_fq_addcarryx_u64(&x51, &x52, x50, x46, x43);
fiat_pasta_fq_addcarryx_u64(&x53, &x54, x52, x44, x41);
x55 = (x54 + x42);
fiat_pasta_fq_addcarryx_u64(&x56, &x57, 0x0, x33, x47);
fiat_pasta_fq_addcarryx_u64(&x58, &x59, x57, x35, x49);
fiat_pasta_fq_addcarryx_u64(&x60, &x61, x59, x37, x51);
fiat_pasta_fq_addcarryx_u64(&x62, &x63, x61, x39, x53);
fiat_pasta_fq_addcarryx_u64(&x64, &x65, x63, x40, x55);
fiat_pasta_fq_mulx_u64(&x66, &x67, x56, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x68, &x69, x66, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x70, &x71, x66, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x72, &x73, x66, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x74, &x75, 0x0, x73, x70);
x76 = (x75 + x71);
fiat_pasta_fq_addcarryx_u64(&x77, &x78, 0x0, x56, x72);
fiat_pasta_fq_addcarryx_u64(&x79, &x80, x78, x58, x74);
fiat_pasta_fq_addcarryx_u64(&x81, &x82, x80, x60, x76);
fiat_pasta_fq_addcarryx_u64(&x83, &x84, x82, x62, x68);
fiat_pasta_fq_addcarryx_u64(&x85, &x86, x84, x64, x69);
x87 = ((uint64_t)x86 + x65);
fiat_pasta_fq_mulx_u64(&x88, &x89, x2, (arg1[3]));
fiat_pasta_fq_mulx_u64(&x90, &x91, x2, (arg1[2]));
fiat_pasta_fq_mulx_u64(&x92, &x93, x2, (arg1[1]));
fiat_pasta_fq_mulx_u64(&x94, &x95, x2, (arg1[0]));
fiat_pasta_fq_addcarryx_u64(&x96, &x97, 0x0, x95, x92);
fiat_pasta_fq_addcarryx_u64(&x98, &x99, x97, x93, x90);
fiat_pasta_fq_addcarryx_u64(&x100, &x101, x99, x91, x88);
x102 = (x101 + x89);
fiat_pasta_fq_addcarryx_u64(&x103, &x104, 0x0, x79, x94);
fiat_pasta_fq_addcarryx_u64(&x105, &x106, x104, x81, x96);
fiat_pasta_fq_addcarryx_u64(&x107, &x108, x106, x83, x98);
fiat_pasta_fq_addcarryx_u64(&x109, &x110, x108, x85, x100);
fiat_pasta_fq_addcarryx_u64(&x111, &x112, x110, x87, x102);
fiat_pasta_fq_mulx_u64(&x113, &x114, x103, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x115, &x116, x113, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x117, &x118, x113, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x119, &x120, x113, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x121, &x122, 0x0, x120, x117);
x123 = (x122 + x118);
fiat_pasta_fq_addcarryx_u64(&x124, &x125, 0x0, x103, x119);
fiat_pasta_fq_addcarryx_u64(&x126, &x127, x125, x105, x121);
fiat_pasta_fq_addcarryx_u64(&x128, &x129, x127, x107, x123);
fiat_pasta_fq_addcarryx_u64(&x130, &x131, x129, x109, x115);
fiat_pasta_fq_addcarryx_u64(&x132, &x133, x131, x111, x116);
x134 = ((uint64_t)x133 + x112);
fiat_pasta_fq_mulx_u64(&x135, &x136, x3, (arg1[3]));
fiat_pasta_fq_mulx_u64(&x137, &x138, x3, (arg1[2]));
fiat_pasta_fq_mulx_u64(&x139, &x140, x3, (arg1[1]));
fiat_pasta_fq_mulx_u64(&x141, &x142, x3, (arg1[0]));
fiat_pasta_fq_addcarryx_u64(&x143, &x144, 0x0, x142, x139);
fiat_pasta_fq_addcarryx_u64(&x145, &x146, x144, x140, x137);
fiat_pasta_fq_addcarryx_u64(&x147, &x148, x146, x138, x135);
x149 = (x148 + x136);
fiat_pasta_fq_addcarryx_u64(&x150, &x151, 0x0, x126, x141);
fiat_pasta_fq_addcarryx_u64(&x152, &x153, x151, x128, x143);
fiat_pasta_fq_addcarryx_u64(&x154, &x155, x153, x130, x145);
fiat_pasta_fq_addcarryx_u64(&x156, &x157, x155, x132, x147);
fiat_pasta_fq_addcarryx_u64(&x158, &x159, x157, x134, x149);
fiat_pasta_fq_mulx_u64(&x160, &x161, x150, UINT64_C(0x8c46eb20ffffffff));
fiat_pasta_fq_mulx_u64(&x162, &x163, x160, UINT64_C(0x4000000000000000));
fiat_pasta_fq_mulx_u64(&x164, &x165, x160, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_mulx_u64(&x166, &x167, x160, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_addcarryx_u64(&x168, &x169, 0x0, x167, x164);
x170 = (x169 + x165);
fiat_pasta_fq_addcarryx_u64(&x171, &x172, 0x0, x150, x166);
fiat_pasta_fq_addcarryx_u64(&x173, &x174, x172, x152, x168);
fiat_pasta_fq_addcarryx_u64(&x175, &x176, x174, x154, x170);
fiat_pasta_fq_addcarryx_u64(&x177, &x178, x176, x156, x162);
fiat_pasta_fq_addcarryx_u64(&x179, &x180, x178, x158, x163);
x181 = ((uint64_t)x180 + x159);
fiat_pasta_fq_subborrowx_u64(&x182, &x183, 0x0, x173, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_subborrowx_u64(&x184, &x185, x183, x175, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_subborrowx_u64(&x186, &x187, x185, x177, 0x0);
fiat_pasta_fq_subborrowx_u64(&x188, &x189, x187, x179, UINT64_C(0x4000000000000000));
fiat_pasta_fq_subborrowx_u64(&x190, &x191, x189, x181, 0x0);
fiat_pasta_fq_cmovznz_u64(&x192, x191, x182, x173);
fiat_pasta_fq_cmovznz_u64(&x193, x191, x184, x175);
fiat_pasta_fq_cmovznz_u64(&x194, x191, x186, x177);
fiat_pasta_fq_cmovznz_u64(&x195, x191, x188, x179);
out1[0] = x192;
out1[1] = x193;
out1[2] = x194;
out1[3] = x195;
}
/*
* The function fiat_pasta_fq_add adds 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
*
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* Output Bounds:
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
*/
void fiat_pasta_fq_add(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) {
uint64_t x1;
fiat_pasta_fq_uint1 x2;
uint64_t x3;
fiat_pasta_fq_uint1 x4;
uint64_t x5;
fiat_pasta_fq_uint1 x6;
uint64_t x7;
fiat_pasta_fq_uint1 x8;
uint64_t x9;
fiat_pasta_fq_uint1 x10;
uint64_t x11;
fiat_pasta_fq_uint1 x12;
uint64_t x13;
fiat_pasta_fq_uint1 x14;
uint64_t x15;
fiat_pasta_fq_uint1 x16;
uint64_t x17;
fiat_pasta_fq_uint1 x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
fiat_pasta_fq_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0]));
fiat_pasta_fq_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1]));
fiat_pasta_fq_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2]));
fiat_pasta_fq_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3]));
fiat_pasta_fq_subborrowx_u64(&x9, &x10, 0x0, x1, UINT64_C(0x8c46eb2100000001));
fiat_pasta_fq_subborrowx_u64(&x11, &x12, x10, x3, UINT64_C(0x224698fc0994a8dd));
fiat_pasta_fq_subborrowx_u64(&x13, &x14, x12, x5, 0x0);
fiat_pasta_fq_subborrowx_u64(&x15, &x16, x14, x7, UINT64_C(0x4000000000000000));
fiat_pasta_fq_subborrowx_u64(&x17, &x18, x16, x8, 0x0);
fiat_pasta_fq_cmovznz_u64(&x19, x18, x9, x1);
fiat_pasta_fq_cmovznz_u64(&x20, x18, x11, x3);
fiat_pasta_fq_cmovznz_u64(&x21, x18, x13, x5);
fiat_pasta_fq_cmovznz_u64(&x22, x18, x15, x7);
out1[0] = x19;
out1[1] = x20;
out1[2] = x21;
out1[3] = x22;
}
/*
* The function fiat_pasta_fq_sub subtracts 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
*
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* Output Bounds:
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
*/
void fiat_pasta_fq_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) {
uint64_t x1;
fiat_pasta_fq_uint1 x2;
uint64_t x3;
fiat_pasta_fq_uint1 x4;
uint64_t x5;
fiat_pasta_fq_uint1 x6;
uint64_t x7;
fiat_pasta_fq_uint1 x8;
uint64_t x9;
uint64_t x10;
fiat_pasta_fq_uint1 x11;
uint64_t x12;
fiat_pasta_fq_uint1 x13;
uint64_t x14;
fiat_pasta_fq_uint1 x15;
uint64_t x16;
fiat_pasta_fq_uint1 x17;
fiat_pasta_fq_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0]));
fiat_pasta_fq_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1]));
fiat_pasta_fq_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2]));
fiat_pasta_fq_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3]));
fiat_pasta_fq_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff));
fiat_pasta_fq_addcarryx_u64(&x10, &x11, 0x0, x1, (x9 & UINT64_C(0x8c46eb2100000001)));
fiat_pasta_fq_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT64_C(0x224698fc0994a8dd)));
fiat_pasta_fq_addcarryx_u64(&x14, &x15, x13, x5, 0x0);
fiat_pasta_fq_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0x4000000000000000)));
out1[0] = x10;
out1[1] = x12;
out1[2] = x14;
out1[3] = x16;
}
/*
* The function fiat_pasta_fq_opp negates a field element in the Montgomery domain.
* Preconditions:
* 0 ≤ eval arg1 < m
* Postconditions:
* eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m
* 0 ≤ eval out1 < m
*
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* Output Bounds:
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
*/
void fiat_pasta_fq_opp(uint64_t out1[4], const uint64_t arg1[4]) {
uint64_t x1;
fiat_pasta_fq_uint1 x2;
uint64_t x3;
fiat_pasta_fq_uint1 x4;
uint64_t x5;
fiat_pasta_fq_uint1 x6;
uint64_t x7;
fiat_pasta_fq_uint1 x8;
uint64_t x9;
uint64_t x10;
fiat_pasta_fq_uint1 x11;
uint64_t x12;
fiat_pasta_fq_uint1 x13;
uint64_t x14;
fiat_pasta_fq_uint1 x15;
uint64_t x16;
fiat_pasta_fq_uint1 x17;
fiat_pasta_fq_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0]));
fiat_pasta_fq_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1]));
fiat_pasta_fq_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2]));
fiat_pasta_fq_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3]));
fiat_pasta_fq_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff));
fiat_pasta_fq_addcarryx_u64(&x10, &x11, 0x0, x1, (x9 & UINT64_C(0x8c46eb2100000001)));
fiat_pasta_fq_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT64_C(0x224698fc0994a8dd)));
fiat_pasta_fq_addcarryx_u64(&x14, &x15, x13, x5, 0x0);
fiat_pasta_fq_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0x4000000000000000)));
out1[0] = x10;
out1[1] = x12;
out1[2] = x14;
out1[3] = x16;
}
/*
* The function fiat_pasta_fq_from_montgomery translates a field element out of the Montgomery domain.
* Preconditions:
* 0 ≤ eval arg1 < m
* Postconditions:
* eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^4) mod m
* 0 ≤ eval out1 < m
*
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
* Output Bounds:
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
*/
void fiat_pasta_fq_from_montgomery(uint64_t out1[4], const uint64_t arg1[4]) {
uint64_t x1;
uint64_t x2;
uint64_t x3;
uint64_t x4;
uint64_t x5;
uint64_t x6;
uint64_t x7;
uint64_t x8;
uint64_t x9;
uint64_t x10;
fiat_pasta_fq_uint1 x11;
uint64_t x12;
fiat_pasta_fq_uint1 x13;
uint64_t x14;
fiat_pasta_fq_uint1 x15;
uint64_t x16;
fiat_pasta_fq_uint1 x17;
uint64_t x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
uint64_t x23;
uint64_t x24;
uint64_t x25;
uint64_t x26;
fiat_pasta_fq_uint1 x27;
uint64_t x28;
fiat_pasta_fq_uint1 x29;
uint64_t x30;
fiat_pasta_fq_uint1 x31;
uint64_t x32;
fiat_pasta_fq_uint1 x33;
uint64_t x34;
fiat_pasta_fq_uint1 x35;
uint64_t x36;
fiat_pasta_fq_uint1 x37;
uint64_t x38;
fiat_pasta_fq_uint1 x39;
uint64_t x40;
fiat_pasta_fq_uint1 x41;
uint64_t x42;
uint64_t x43;
uint64_t x44;
uint64_t x45;
uint64_t x46;
uint64_t x47;
uint64_t x48;
uint64_t x49;
uint64_t x50;
fiat_pasta_fq_uint1 x51;
uint64_t x52;
fiat_pasta_fq_uint1 x53;
uint64_t x54;
fiat_pasta_fq_uint1 x55;
uint64_t x56;
fiat_pasta_fq_uint1 x57;
uint64_t x58;
fiat_pasta_fq_uint1 x59;
uint64_t x60;
fiat_pasta_fq_uint1 x61;
uint64_t x62;
fiat_pasta_fq_uint1 x63;