Skip to main content

p521/arithmetic/field/
p521_64.rs

1//! Autogenerated: fiat-crypto unsaturated-solinas --lang Rust --inline p521 64 '(auto)' '2^521 - 1' carry_add carry_sub carry_opp carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax
2//! curve description: p521
3//! machine_wordsize = 64 (from "64")
4//! requested operations: carry_add, carry_sub, carry_opp, carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax
5//! n = 9 (from "(auto)")
6//! s-c = 2^521 - [(1, 1)] (from "2^521 - 1")
7//! tight_bounds_multiplier = 1 (from "")
8//!
9//! Computed values:
10//!   carry_chain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1]
11//!   eval z = z[0] + (z[1] << 58) + (z[2] << 116) + (z[3] << 174) + (z[4] << 232) + (z[5] << 0x122) + (z[6] << 0x15c) + (z[7] << 0x196) + (z[8] << 0x1d0)
12//!   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) + (z[32] << 256) + (z[33] << 0x108) + (z[34] << 0x110) + (z[35] << 0x118) + (z[36] << 0x120) + (z[37] << 0x128) + (z[38] << 0x130) + (z[39] << 0x138) + (z[40] << 0x140) + (z[41] << 0x148) + (z[42] << 0x150) + (z[43] << 0x158) + (z[44] << 0x160) + (z[45] << 0x168) + (z[46] << 0x170) + (z[47] << 0x178) + (z[48] << 0x180) + (z[49] << 0x188) + (z[50] << 0x190) + (z[51] << 0x198) + (z[52] << 0x1a0) + (z[53] << 0x1a8) + (z[54] << 0x1b0) + (z[55] << 0x1b8) + (z[56] << 0x1c0) + (z[57] << 0x1c8) + (z[58] << 0x1d0) + (z[59] << 0x1d8) + (z[60] << 0x1e0) + (z[61] << 0x1e8) + (z[62] << 0x1f0) + (z[63] << 0x1f8) + (z[64] << 2^9) + (z[65] << 0x208)
13//!   balance = [0x7fffffffffffffe, 0x7fffffffffffffe, 0x7fffffffffffffe, 0x7fffffffffffffe, 0x7fffffffffffffe, 0x7fffffffffffffe, 0x7fffffffffffffe, 0x7fffffffffffffe, 0x3fffffffffffffe]
14
15#![allow(unused_parens)]
16#![allow(non_camel_case_types)]
17
18/// Since `Index` and `IndexMut` aren't callable in `const` contexts yet, this helper type helps unify
19/// arrays and user-defined array-wrapper types into a single type which can be indexed in `const`
20/// contexts. Once `const trait`s are stabilized this type can go away
21struct IndexConst<T: ?Sized>(T);
22
23impl<'a, T, const N: usize> IndexConst<&'a [T; N]> {
24    #[inline(always)]
25    #[allow(unused)]
26    const fn index(self, i: usize) -> &'a T {
27        &self.0[i]
28    }
29}
30impl<'a, 'b, T, const N: usize> IndexConst<&'a mut &'b mut [T; N]> {
31    #[inline(always)]
32    #[allow(unused)]
33    const fn index_mut(self, i: usize) -> &'a mut T {
34        &mut self.0[i]
35    }
36}
37
38/** fiat_p521_u1 represents values of 1 bits, stored in one byte. */
39pub type fiat_p521_u1 = u8;
40/** fiat_p521_i1 represents values of 1 bits, stored in one byte. */
41pub type fiat_p521_i1 = i8;
42/** fiat_p521_u2 represents values of 2 bits, stored in one byte. */
43pub type fiat_p521_u2 = u8;
44/** fiat_p521_i2 represents values of 2 bits, stored in one byte. */
45pub type fiat_p521_i2 = i8;
46
47/** The type fiat_p521_tight_field_element is a field element with tight bounds. */
48/** Bounds: [[0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x400000000000000], [0x0 ~> 0x200000000000000]] */
49#[derive(Clone, Copy)]
50pub struct fiat_p521_tight_field_element(pub [u64; 9]);
51
52impl core::ops::Index<usize> for fiat_p521_tight_field_element {
53    type Output = u64;
54    #[inline]
55    fn index(&self, index: usize) -> &Self::Output {
56        &self.0[index]
57    }
58}
59
60impl core::ops::IndexMut<usize> for fiat_p521_tight_field_element {
61    #[inline]
62    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
63        &mut self.0[index]
64    }
65}
66
67impl<'a> IndexConst<&'a fiat_p521_tight_field_element> {
68    #[allow(unused)]
69    #[inline(always)]
70    const fn index(self, i: usize) -> &'a u64 {
71        &self.0.0[i]
72    }
73}
74
75impl<'a, 'b> IndexConst<&'a mut &'b mut fiat_p521_tight_field_element> {
76    #[allow(unused)]
77    #[inline(always)]
78    const fn index_mut(self, i: usize) -> &'a mut u64 {
79        &mut self.0.0[i]
80    }
81}
82
83/** The type fiat_p521_loose_field_element is a field element with loose bounds. */
84/** Bounds: [[0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0xc00000000000000], [0x0 ~> 0x600000000000000]] */
85#[derive(Clone, Copy)]
86pub struct fiat_p521_loose_field_element(pub [u64; 9]);
87
88impl core::ops::Index<usize> for fiat_p521_loose_field_element {
89    type Output = u64;
90    #[inline]
91    fn index(&self, index: usize) -> &Self::Output {
92        &self.0[index]
93    }
94}
95
96impl core::ops::IndexMut<usize> for fiat_p521_loose_field_element {
97    #[inline]
98    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
99        &mut self.0[index]
100    }
101}
102
103impl<'a> IndexConst<&'a fiat_p521_loose_field_element> {
104    #[allow(unused)]
105    #[inline(always)]
106    const fn index(self, i: usize) -> &'a u64 {
107        &self.0.0[i]
108    }
109}
110
111impl<'a, 'b> IndexConst<&'a mut &'b mut fiat_p521_loose_field_element> {
112    #[allow(unused)]
113    #[inline(always)]
114    const fn index_mut(self, i: usize) -> &'a mut u64 {
115        &mut self.0.0[i]
116    }
117}
118
119
120/// The function fiat_p521_addcarryx_u58 is an addition with carry.
121///
122/// Postconditions:
123///   out1 = (arg1 + arg2 + arg3) mod 2^58
124///   out2 = ⌊(arg1 + arg2 + arg3) / 2^58⌋
125///
126/// Input Bounds:
127///   arg1: [0x0 ~> 0x1]
128///   arg2: [0x0 ~> 0x3ffffffffffffff]
129///   arg3: [0x0 ~> 0x3ffffffffffffff]
130/// Output Bounds:
131///   out1: [0x0 ~> 0x3ffffffffffffff]
132///   out2: [0x0 ~> 0x1]
133#[inline]
134pub const fn fiat_p521_addcarryx_u58(out1: &mut u64, out2: &mut fiat_p521_u1, arg1: fiat_p521_u1, arg2: u64, arg3: u64) {
135  let x1: u64 = (((arg1 as u64) + arg2) + arg3);
136  let x2: u64 = (x1 & 0x3ffffffffffffff);
137  let x3: fiat_p521_u1 = ((x1 >> 58) as fiat_p521_u1);
138  *out1 = x2;
139  *out2 = x3;
140}
141
142/// The function fiat_p521_subborrowx_u58 is a subtraction with borrow.
143///
144/// Postconditions:
145///   out1 = (-arg1 + arg2 + -arg3) mod 2^58
146///   out2 = -⌊(-arg1 + arg2 + -arg3) / 2^58⌋
147///
148/// Input Bounds:
149///   arg1: [0x0 ~> 0x1]
150///   arg2: [0x0 ~> 0x3ffffffffffffff]
151///   arg3: [0x0 ~> 0x3ffffffffffffff]
152/// Output Bounds:
153///   out1: [0x0 ~> 0x3ffffffffffffff]
154///   out2: [0x0 ~> 0x1]
155#[inline]
156pub const fn fiat_p521_subborrowx_u58(out1: &mut u64, out2: &mut fiat_p521_u1, arg1: fiat_p521_u1, arg2: u64, arg3: u64) {
157  let x1: i64 = ((((((arg2 as i128) - (arg1 as i128)) as i64) as i128) - (arg3 as i128)) as i64);
158  let x2: fiat_p521_i1 = ((x1 >> 58) as fiat_p521_i1);
159  let x3: u64 = (((x1 as i128) & (0x3ffffffffffffff as i128)) as u64);
160  *out1 = x3;
161  *out2 = (((0x0 as fiat_p521_i2) - (x2 as fiat_p521_i2)) as fiat_p521_u1);
162}
163
164/// The function fiat_p521_addcarryx_u57 is an addition with carry.
165///
166/// Postconditions:
167///   out1 = (arg1 + arg2 + arg3) mod 2^57
168///   out2 = ⌊(arg1 + arg2 + arg3) / 2^57⌋
169///
170/// Input Bounds:
171///   arg1: [0x0 ~> 0x1]
172///   arg2: [0x0 ~> 0x1ffffffffffffff]
173///   arg3: [0x0 ~> 0x1ffffffffffffff]
174/// Output Bounds:
175///   out1: [0x0 ~> 0x1ffffffffffffff]
176///   out2: [0x0 ~> 0x1]
177#[inline]
178pub const fn fiat_p521_addcarryx_u57(out1: &mut u64, out2: &mut fiat_p521_u1, arg1: fiat_p521_u1, arg2: u64, arg3: u64) {
179  let x1: u64 = (((arg1 as u64) + arg2) + arg3);
180  let x2: u64 = (x1 & 0x1ffffffffffffff);
181  let x3: fiat_p521_u1 = ((x1 >> 57) as fiat_p521_u1);
182  *out1 = x2;
183  *out2 = x3;
184}
185
186/// The function fiat_p521_subborrowx_u57 is a subtraction with borrow.
187///
188/// Postconditions:
189///   out1 = (-arg1 + arg2 + -arg3) mod 2^57
190///   out2 = -⌊(-arg1 + arg2 + -arg3) / 2^57⌋
191///
192/// Input Bounds:
193///   arg1: [0x0 ~> 0x1]
194///   arg2: [0x0 ~> 0x1ffffffffffffff]
195///   arg3: [0x0 ~> 0x1ffffffffffffff]
196/// Output Bounds:
197///   out1: [0x0 ~> 0x1ffffffffffffff]
198///   out2: [0x0 ~> 0x1]
199#[inline]
200pub const fn fiat_p521_subborrowx_u57(out1: &mut u64, out2: &mut fiat_p521_u1, arg1: fiat_p521_u1, arg2: u64, arg3: u64) {
201  let x1: i64 = ((((((arg2 as i128) - (arg1 as i128)) as i64) as i128) - (arg3 as i128)) as i64);
202  let x2: fiat_p521_i1 = ((x1 >> 57) as fiat_p521_i1);
203  let x3: u64 = (((x1 as i128) & (0x1ffffffffffffff as i128)) as u64);
204  *out1 = x3;
205  *out2 = (((0x0 as fiat_p521_i2) - (x2 as fiat_p521_i2)) as fiat_p521_u1);
206}
207
208/// The function fiat_p521_cmovznz_u64 is a single-word conditional move.
209///
210/// Postconditions:
211///   out1 = (if arg1 = 0 then arg2 else arg3)
212///
213/// Input Bounds:
214///   arg1: [0x0 ~> 0x1]
215///   arg2: [0x0 ~> 0xffffffffffffffff]
216///   arg3: [0x0 ~> 0xffffffffffffffff]
217/// Output Bounds:
218///   out1: [0x0 ~> 0xffffffffffffffff]
219#[inline]
220pub const fn fiat_p521_cmovznz_u64(out1: &mut u64, arg1: fiat_p521_u1, arg2: u64, arg3: u64) {
221  let x1: fiat_p521_u1 = (!(!arg1));
222  let x2: u64 = ((((((0x0 as fiat_p521_i2) - (x1 as fiat_p521_i2)) as fiat_p521_i1) as i128) & (0xffffffffffffffff as i128)) as u64);
223  let x3: u64 = ((x2 & arg3) | ((!x2) & arg2));
224  *out1 = x3;
225}
226
227/// The function fiat_p521_carry_add adds two field elements.
228///
229/// Postconditions:
230///   eval out1 mod m = (eval arg1 + eval arg2) mod m
231///
232#[inline]
233pub const fn fiat_p521_carry_add(mut out1: &mut fiat_p521_tight_field_element, arg1: &fiat_p521_tight_field_element, arg2: &fiat_p521_tight_field_element) {
234  let x1: u64 = ((*IndexConst(arg1).index(0)) + (*IndexConst(arg2).index(0)));
235  let x2: u64 = ((x1 >> 58) + ((*IndexConst(arg1).index(1)) + (*IndexConst(arg2).index(1))));
236  let x3: u64 = ((x2 >> 58) + ((*IndexConst(arg1).index(2)) + (*IndexConst(arg2).index(2))));
237  let x4: u64 = ((x3 >> 58) + ((*IndexConst(arg1).index(3)) + (*IndexConst(arg2).index(3))));
238  let x5: u64 = ((x4 >> 58) + ((*IndexConst(arg1).index(4)) + (*IndexConst(arg2).index(4))));
239  let x6: u64 = ((x5 >> 58) + ((*IndexConst(arg1).index(5)) + (*IndexConst(arg2).index(5))));
240  let x7: u64 = ((x6 >> 58) + ((*IndexConst(arg1).index(6)) + (*IndexConst(arg2).index(6))));
241  let x8: u64 = ((x7 >> 58) + ((*IndexConst(arg1).index(7)) + (*IndexConst(arg2).index(7))));
242  let x9: u64 = ((x8 >> 58) + ((*IndexConst(arg1).index(8)) + (*IndexConst(arg2).index(8))));
243  let x10: u64 = ((x1 & 0x3ffffffffffffff) + (x9 >> 57));
244  let x11: u64 = ((((x10 >> 58) as fiat_p521_u1) as u64) + (x2 & 0x3ffffffffffffff));
245  let x12: u64 = (x10 & 0x3ffffffffffffff);
246  let x13: u64 = (x11 & 0x3ffffffffffffff);
247  let x14: u64 = ((((x11 >> 58) as fiat_p521_u1) as u64) + (x3 & 0x3ffffffffffffff));
248  let x15: u64 = (x4 & 0x3ffffffffffffff);
249  let x16: u64 = (x5 & 0x3ffffffffffffff);
250  let x17: u64 = (x6 & 0x3ffffffffffffff);
251  let x18: u64 = (x7 & 0x3ffffffffffffff);
252  let x19: u64 = (x8 & 0x3ffffffffffffff);
253  let x20: u64 = (x9 & 0x1ffffffffffffff);
254  *IndexConst(&mut out1).index_mut(0) = x12;
255  *IndexConst(&mut out1).index_mut(1) = x13;
256  *IndexConst(&mut out1).index_mut(2) = x14;
257  *IndexConst(&mut out1).index_mut(3) = x15;
258  *IndexConst(&mut out1).index_mut(4) = x16;
259  *IndexConst(&mut out1).index_mut(5) = x17;
260  *IndexConst(&mut out1).index_mut(6) = x18;
261  *IndexConst(&mut out1).index_mut(7) = x19;
262  *IndexConst(&mut out1).index_mut(8) = x20;
263}
264
265/// The function fiat_p521_carry_sub subtracts two field elements.
266///
267/// Postconditions:
268///   eval out1 mod m = (eval arg1 - eval arg2) mod m
269///
270#[inline]
271pub const fn fiat_p521_carry_sub(mut out1: &mut fiat_p521_tight_field_element, arg1: &fiat_p521_tight_field_element, arg2: &fiat_p521_tight_field_element) {
272  let x1: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(0))) - (*IndexConst(arg2).index(0)));
273  let x2: u64 = ((x1 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(1))) - (*IndexConst(arg2).index(1))));
274  let x3: u64 = ((x2 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(2))) - (*IndexConst(arg2).index(2))));
275  let x4: u64 = ((x3 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(3))) - (*IndexConst(arg2).index(3))));
276  let x5: u64 = ((x4 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(4))) - (*IndexConst(arg2).index(4))));
277  let x6: u64 = ((x5 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(5))) - (*IndexConst(arg2).index(5))));
278  let x7: u64 = ((x6 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(6))) - (*IndexConst(arg2).index(6))));
279  let x8: u64 = ((x7 >> 58) + ((0x7fffffffffffffe + (*IndexConst(arg1).index(7))) - (*IndexConst(arg2).index(7))));
280  let x9: u64 = ((x8 >> 58) + ((0x3fffffffffffffe + (*IndexConst(arg1).index(8))) - (*IndexConst(arg2).index(8))));
281  let x10: u64 = ((x1 & 0x3ffffffffffffff) + (x9 >> 57));
282  let x11: u64 = ((((x10 >> 58) as fiat_p521_u1) as u64) + (x2 & 0x3ffffffffffffff));
283  let x12: u64 = (x10 & 0x3ffffffffffffff);
284  let x13: u64 = (x11 & 0x3ffffffffffffff);
285  let x14: u64 = ((((x11 >> 58) as fiat_p521_u1) as u64) + (x3 & 0x3ffffffffffffff));
286  let x15: u64 = (x4 & 0x3ffffffffffffff);
287  let x16: u64 = (x5 & 0x3ffffffffffffff);
288  let x17: u64 = (x6 & 0x3ffffffffffffff);
289  let x18: u64 = (x7 & 0x3ffffffffffffff);
290  let x19: u64 = (x8 & 0x3ffffffffffffff);
291  let x20: u64 = (x9 & 0x1ffffffffffffff);
292  *IndexConst(&mut out1).index_mut(0) = x12;
293  *IndexConst(&mut out1).index_mut(1) = x13;
294  *IndexConst(&mut out1).index_mut(2) = x14;
295  *IndexConst(&mut out1).index_mut(3) = x15;
296  *IndexConst(&mut out1).index_mut(4) = x16;
297  *IndexConst(&mut out1).index_mut(5) = x17;
298  *IndexConst(&mut out1).index_mut(6) = x18;
299  *IndexConst(&mut out1).index_mut(7) = x19;
300  *IndexConst(&mut out1).index_mut(8) = x20;
301}
302
303/// The function fiat_p521_carry_opp negates a field element.
304///
305/// Postconditions:
306///   eval out1 mod m = -eval arg1 mod m
307///
308#[inline]
309pub const fn fiat_p521_carry_opp(mut out1: &mut fiat_p521_tight_field_element, arg1: &fiat_p521_tight_field_element) {
310  let x1: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(0)));
311  let x2: u64 = ((((x1 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(1))));
312  let x3: u64 = ((((x2 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(2))));
313  let x4: u64 = ((((x3 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(3))));
314  let x5: u64 = ((((x4 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(4))));
315  let x6: u64 = ((((x5 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(5))));
316  let x7: u64 = ((((x6 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(6))));
317  let x8: u64 = ((((x7 >> 58) as fiat_p521_u1) as u64) + (0x7fffffffffffffe - (*IndexConst(arg1).index(7))));
318  let x9: u64 = ((((x8 >> 58) as fiat_p521_u1) as u64) + (0x3fffffffffffffe - (*IndexConst(arg1).index(8))));
319  let x10: u64 = ((x1 & 0x3ffffffffffffff) + (((x9 >> 57) as fiat_p521_u1) as u64));
320  let x11: u64 = ((((x10 >> 58) as fiat_p521_u1) as u64) + (x2 & 0x3ffffffffffffff));
321  let x12: u64 = (x10 & 0x3ffffffffffffff);
322  let x13: u64 = (x11 & 0x3ffffffffffffff);
323  let x14: u64 = ((((x11 >> 58) as fiat_p521_u1) as u64) + (x3 & 0x3ffffffffffffff));
324  let x15: u64 = (x4 & 0x3ffffffffffffff);
325  let x16: u64 = (x5 & 0x3ffffffffffffff);
326  let x17: u64 = (x6 & 0x3ffffffffffffff);
327  let x18: u64 = (x7 & 0x3ffffffffffffff);
328  let x19: u64 = (x8 & 0x3ffffffffffffff);
329  let x20: u64 = (x9 & 0x1ffffffffffffff);
330  *IndexConst(&mut out1).index_mut(0) = x12;
331  *IndexConst(&mut out1).index_mut(1) = x13;
332  *IndexConst(&mut out1).index_mut(2) = x14;
333  *IndexConst(&mut out1).index_mut(3) = x15;
334  *IndexConst(&mut out1).index_mut(4) = x16;
335  *IndexConst(&mut out1).index_mut(5) = x17;
336  *IndexConst(&mut out1).index_mut(6) = x18;
337  *IndexConst(&mut out1).index_mut(7) = x19;
338  *IndexConst(&mut out1).index_mut(8) = x20;
339}
340
341/// The function fiat_p521_carry_mul multiplies two field elements and reduces the result.
342///
343/// Postconditions:
344///   eval out1 mod m = (eval arg1 * eval arg2) mod m
345///
346#[inline]
347pub const fn fiat_p521_carry_mul(mut out1: &mut fiat_p521_tight_field_element, arg1: &fiat_p521_loose_field_element, arg2: &fiat_p521_loose_field_element) {
348  let x1: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
349  let x2: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
350  let x3: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(6)) * 0x2) as u128));
351  let x4: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(5)) * 0x2) as u128));
352  let x5: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(4)) * 0x2) as u128));
353  let x6: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(3)) * 0x2) as u128));
354  let x7: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(2)) * 0x2) as u128));
355  let x8: u128 = (((*IndexConst(arg1).index(8)) as u128) * (((*IndexConst(arg2).index(1)) * 0x2) as u128));
356  let x9: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
357  let x10: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
358  let x11: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(6)) * 0x2) as u128));
359  let x12: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(5)) * 0x2) as u128));
360  let x13: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(4)) * 0x2) as u128));
361  let x14: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(3)) * 0x2) as u128));
362  let x15: u128 = (((*IndexConst(arg1).index(7)) as u128) * (((*IndexConst(arg2).index(2)) * 0x2) as u128));
363  let x16: u128 = (((*IndexConst(arg1).index(6)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
364  let x17: u128 = (((*IndexConst(arg1).index(6)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
365  let x18: u128 = (((*IndexConst(arg1).index(6)) as u128) * (((*IndexConst(arg2).index(6)) * 0x2) as u128));
366  let x19: u128 = (((*IndexConst(arg1).index(6)) as u128) * (((*IndexConst(arg2).index(5)) * 0x2) as u128));
367  let x20: u128 = (((*IndexConst(arg1).index(6)) as u128) * (((*IndexConst(arg2).index(4)) * 0x2) as u128));
368  let x21: u128 = (((*IndexConst(arg1).index(6)) as u128) * (((*IndexConst(arg2).index(3)) * 0x2) as u128));
369  let x22: u128 = (((*IndexConst(arg1).index(5)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
370  let x23: u128 = (((*IndexConst(arg1).index(5)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
371  let x24: u128 = (((*IndexConst(arg1).index(5)) as u128) * (((*IndexConst(arg2).index(6)) * 0x2) as u128));
372  let x25: u128 = (((*IndexConst(arg1).index(5)) as u128) * (((*IndexConst(arg2).index(5)) * 0x2) as u128));
373  let x26: u128 = (((*IndexConst(arg1).index(5)) as u128) * (((*IndexConst(arg2).index(4)) * 0x2) as u128));
374  let x27: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
375  let x28: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
376  let x29: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(6)) * 0x2) as u128));
377  let x30: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(5)) * 0x2) as u128));
378  let x31: u128 = (((*IndexConst(arg1).index(3)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
379  let x32: u128 = (((*IndexConst(arg1).index(3)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
380  let x33: u128 = (((*IndexConst(arg1).index(3)) as u128) * (((*IndexConst(arg2).index(6)) * 0x2) as u128));
381  let x34: u128 = (((*IndexConst(arg1).index(2)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
382  let x35: u128 = (((*IndexConst(arg1).index(2)) as u128) * (((*IndexConst(arg2).index(7)) * 0x2) as u128));
383  let x36: u128 = (((*IndexConst(arg1).index(1)) as u128) * (((*IndexConst(arg2).index(8)) * 0x2) as u128));
384  let x37: u128 = (((*IndexConst(arg1).index(8)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
385  let x38: u128 = (((*IndexConst(arg1).index(7)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
386  let x39: u128 = (((*IndexConst(arg1).index(7)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
387  let x40: u128 = (((*IndexConst(arg1).index(6)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
388  let x41: u128 = (((*IndexConst(arg1).index(6)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
389  let x42: u128 = (((*IndexConst(arg1).index(6)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
390  let x43: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((*IndexConst(arg2).index(3)) as u128));
391  let x44: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
392  let x45: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
393  let x46: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
394  let x47: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(4)) as u128));
395  let x48: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(3)) as u128));
396  let x49: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
397  let x50: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
398  let x51: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
399  let x52: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(5)) as u128));
400  let x53: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(4)) as u128));
401  let x54: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(3)) as u128));
402  let x55: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
403  let x56: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
404  let x57: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
405  let x58: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(6)) as u128));
406  let x59: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(5)) as u128));
407  let x60: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(4)) as u128));
408  let x61: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(3)) as u128));
409  let x62: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
410  let x63: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
411  let x64: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
412  let x65: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(7)) as u128));
413  let x66: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(6)) as u128));
414  let x67: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(5)) as u128));
415  let x68: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(4)) as u128));
416  let x69: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(3)) as u128));
417  let x70: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
418  let x71: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
419  let x72: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
420  let x73: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(8)) as u128));
421  let x74: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(7)) as u128));
422  let x75: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(6)) as u128));
423  let x76: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(5)) as u128));
424  let x77: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(4)) as u128));
425  let x78: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(3)) as u128));
426  let x79: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(2)) as u128));
427  let x80: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(1)) as u128));
428  let x81: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(0)) as u128));
429  let x82: u128 = (x81 + (x36 + (x35 + (x33 + (x30 + (x26 + (x21 + (x15 + x8))))))));
430  let x83: u128 = (x82 >> 58);
431  let x84: u64 = ((x82 & (0x3ffffffffffffff as u128)) as u64);
432  let x85: u128 = (x73 + (x65 + (x58 + (x52 + (x47 + (x43 + (x40 + (x38 + x37))))))));
433  let x86: u128 = (x74 + (x66 + (x59 + (x53 + (x48 + (x44 + (x41 + (x39 + x1))))))));
434  let x87: u128 = (x75 + (x67 + (x60 + (x54 + (x49 + (x45 + (x42 + (x9 + x2))))))));
435  let x88: u128 = (x76 + (x68 + (x61 + (x55 + (x50 + (x46 + (x16 + (x10 + x3))))))));
436  let x89: u128 = (x77 + (x69 + (x62 + (x56 + (x51 + (x22 + (x17 + (x11 + x4))))))));
437  let x90: u128 = (x78 + (x70 + (x63 + (x57 + (x27 + (x23 + (x18 + (x12 + x5))))))));
438  let x91: u128 = (x79 + (x71 + (x64 + (x31 + (x28 + (x24 + (x19 + (x13 + x6))))))));
439  let x92: u128 = (x80 + (x72 + (x34 + (x32 + (x29 + (x25 + (x20 + (x14 + x7))))))));
440  let x93: u128 = (x83 + x92);
441  let x94: u128 = (x93 >> 58);
442  let x95: u64 = ((x93 & (0x3ffffffffffffff as u128)) as u64);
443  let x96: u128 = (x94 + x91);
444  let x97: u128 = (x96 >> 58);
445  let x98: u64 = ((x96 & (0x3ffffffffffffff as u128)) as u64);
446  let x99: u128 = (x97 + x90);
447  let x100: u128 = (x99 >> 58);
448  let x101: u64 = ((x99 & (0x3ffffffffffffff as u128)) as u64);
449  let x102: u128 = (x100 + x89);
450  let x103: u128 = (x102 >> 58);
451  let x104: u64 = ((x102 & (0x3ffffffffffffff as u128)) as u64);
452  let x105: u128 = (x103 + x88);
453  let x106: u128 = (x105 >> 58);
454  let x107: u64 = ((x105 & (0x3ffffffffffffff as u128)) as u64);
455  let x108: u128 = (x106 + x87);
456  let x109: u128 = (x108 >> 58);
457  let x110: u64 = ((x108 & (0x3ffffffffffffff as u128)) as u64);
458  let x111: u128 = (x109 + x86);
459  let x112: u128 = (x111 >> 58);
460  let x113: u64 = ((x111 & (0x3ffffffffffffff as u128)) as u64);
461  let x114: u128 = (x112 + x85);
462  let x115: u128 = (x114 >> 57);
463  let x116: u64 = ((x114 & (0x1ffffffffffffff as u128)) as u64);
464  let x117: u128 = ((x84 as u128) + x115);
465  let x118: u64 = ((x117 >> 58) as u64);
466  let x119: u64 = ((x117 & (0x3ffffffffffffff as u128)) as u64);
467  let x120: u64 = (x118 + x95);
468  let x121: fiat_p521_u1 = ((x120 >> 58) as fiat_p521_u1);
469  let x122: u64 = (x120 & 0x3ffffffffffffff);
470  let x123: u64 = ((x121 as u64) + x98);
471  *IndexConst(&mut out1).index_mut(0) = x119;
472  *IndexConst(&mut out1).index_mut(1) = x122;
473  *IndexConst(&mut out1).index_mut(2) = x123;
474  *IndexConst(&mut out1).index_mut(3) = x101;
475  *IndexConst(&mut out1).index_mut(4) = x104;
476  *IndexConst(&mut out1).index_mut(5) = x107;
477  *IndexConst(&mut out1).index_mut(6) = x110;
478  *IndexConst(&mut out1).index_mut(7) = x113;
479  *IndexConst(&mut out1).index_mut(8) = x116;
480}
481
482/// The function fiat_p521_carry_square squares a field element and reduces the result.
483///
484/// Postconditions:
485///   eval out1 mod m = (eval arg1 * eval arg1) mod m
486///
487#[inline]
488pub const fn fiat_p521_carry_square(mut out1: &mut fiat_p521_tight_field_element, arg1: &fiat_p521_loose_field_element) {
489  let x1: u64 = (*IndexConst(arg1).index(8));
490  let x2: u64 = (x1 * 0x2);
491  let x3: u64 = ((*IndexConst(arg1).index(8)) * 0x2);
492  let x4: u64 = (*IndexConst(arg1).index(7));
493  let x5: u64 = (x4 * 0x2);
494  let x6: u64 = ((*IndexConst(arg1).index(7)) * 0x2);
495  let x7: u64 = (*IndexConst(arg1).index(6));
496  let x8: u64 = (x7 * 0x2);
497  let x9: u64 = ((*IndexConst(arg1).index(6)) * 0x2);
498  let x10: u64 = (*IndexConst(arg1).index(5));
499  let x11: u64 = (x10 * 0x2);
500  let x12: u64 = ((*IndexConst(arg1).index(5)) * 0x2);
501  let x13: u64 = ((*IndexConst(arg1).index(4)) * 0x2);
502  let x14: u64 = ((*IndexConst(arg1).index(3)) * 0x2);
503  let x15: u64 = ((*IndexConst(arg1).index(2)) * 0x2);
504  let x16: u64 = ((*IndexConst(arg1).index(1)) * 0x2);
505  let x17: u128 = (((*IndexConst(arg1).index(8)) as u128) * ((x1 * 0x2) as u128));
506  let x18: u128 = (((*IndexConst(arg1).index(7)) as u128) * ((x2 * 0x2) as u128));
507  let x19: u128 = (((*IndexConst(arg1).index(7)) as u128) * ((x4 * 0x2) as u128));
508  let x20: u128 = (((*IndexConst(arg1).index(6)) as u128) * ((x2 * 0x2) as u128));
509  let x21: u128 = (((*IndexConst(arg1).index(6)) as u128) * ((x5 * 0x2) as u128));
510  let x22: u128 = (((*IndexConst(arg1).index(6)) as u128) * ((x7 * 0x2) as u128));
511  let x23: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((x2 * 0x2) as u128));
512  let x24: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((x5 * 0x2) as u128));
513  let x25: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((x8 * 0x2) as u128));
514  let x26: u128 = (((*IndexConst(arg1).index(5)) as u128) * ((x10 * 0x2) as u128));
515  let x27: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((x2 * 0x2) as u128));
516  let x28: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((x5 * 0x2) as u128));
517  let x29: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((x8 * 0x2) as u128));
518  let x30: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((x11 * 0x2) as u128));
519  let x31: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg1).index(4)) as u128));
520  let x32: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((x2 * 0x2) as u128));
521  let x33: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((x5 * 0x2) as u128));
522  let x34: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((x8 * 0x2) as u128));
523  let x35: u128 = (((*IndexConst(arg1).index(3)) as u128) * (x12 as u128));
524  let x36: u128 = (((*IndexConst(arg1).index(3)) as u128) * (x13 as u128));
525  let x37: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg1).index(3)) as u128));
526  let x38: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((x2 * 0x2) as u128));
527  let x39: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((x5 * 0x2) as u128));
528  let x40: u128 = (((*IndexConst(arg1).index(2)) as u128) * (x9 as u128));
529  let x41: u128 = (((*IndexConst(arg1).index(2)) as u128) * (x12 as u128));
530  let x42: u128 = (((*IndexConst(arg1).index(2)) as u128) * (x13 as u128));
531  let x43: u128 = (((*IndexConst(arg1).index(2)) as u128) * (x14 as u128));
532  let x44: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg1).index(2)) as u128));
533  let x45: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((x2 * 0x2) as u128));
534  let x46: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x6 as u128));
535  let x47: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x9 as u128));
536  let x48: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x12 as u128));
537  let x49: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x13 as u128));
538  let x50: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x14 as u128));
539  let x51: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x15 as u128));
540  let x52: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg1).index(1)) as u128));
541  let x53: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x3 as u128));
542  let x54: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x6 as u128));
543  let x55: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x9 as u128));
544  let x56: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x12 as u128));
545  let x57: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x13 as u128));
546  let x58: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x14 as u128));
547  let x59: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x15 as u128));
548  let x60: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x16 as u128));
549  let x61: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg1).index(0)) as u128));
550  let x62: u128 = (x61 + (x45 + (x39 + (x34 + x30))));
551  let x63: u128 = (x62 >> 58);
552  let x64: u64 = ((x62 & (0x3ffffffffffffff as u128)) as u64);
553  let x65: u128 = (x53 + (x46 + (x40 + (x35 + x31))));
554  let x66: u128 = (x54 + (x47 + (x41 + (x36 + x17))));
555  let x67: u128 = (x55 + (x48 + (x42 + (x37 + x18))));
556  let x68: u128 = (x56 + (x49 + (x43 + (x20 + x19))));
557  let x69: u128 = (x57 + (x50 + (x44 + (x23 + x21))));
558  let x70: u128 = (x58 + (x51 + (x27 + (x24 + x22))));
559  let x71: u128 = (x59 + (x52 + (x32 + (x28 + x25))));
560  let x72: u128 = (x60 + (x38 + (x33 + (x29 + x26))));
561  let x73: u128 = (x63 + x72);
562  let x74: u128 = (x73 >> 58);
563  let x75: u64 = ((x73 & (0x3ffffffffffffff as u128)) as u64);
564  let x76: u128 = (x74 + x71);
565  let x77: u128 = (x76 >> 58);
566  let x78: u64 = ((x76 & (0x3ffffffffffffff as u128)) as u64);
567  let x79: u128 = (x77 + x70);
568  let x80: u128 = (x79 >> 58);
569  let x81: u64 = ((x79 & (0x3ffffffffffffff as u128)) as u64);
570  let x82: u128 = (x80 + x69);
571  let x83: u128 = (x82 >> 58);
572  let x84: u64 = ((x82 & (0x3ffffffffffffff as u128)) as u64);
573  let x85: u128 = (x83 + x68);
574  let x86: u128 = (x85 >> 58);
575  let x87: u64 = ((x85 & (0x3ffffffffffffff as u128)) as u64);
576  let x88: u128 = (x86 + x67);
577  let x89: u128 = (x88 >> 58);
578  let x90: u64 = ((x88 & (0x3ffffffffffffff as u128)) as u64);
579  let x91: u128 = (x89 + x66);
580  let x92: u128 = (x91 >> 58);
581  let x93: u64 = ((x91 & (0x3ffffffffffffff as u128)) as u64);
582  let x94: u128 = (x92 + x65);
583  let x95: u128 = (x94 >> 57);
584  let x96: u64 = ((x94 & (0x1ffffffffffffff as u128)) as u64);
585  let x97: u128 = ((x64 as u128) + x95);
586  let x98: u64 = ((x97 >> 58) as u64);
587  let x99: u64 = ((x97 & (0x3ffffffffffffff as u128)) as u64);
588  let x100: u64 = (x98 + x75);
589  let x101: fiat_p521_u1 = ((x100 >> 58) as fiat_p521_u1);
590  let x102: u64 = (x100 & 0x3ffffffffffffff);
591  let x103: u64 = ((x101 as u64) + x78);
592  *IndexConst(&mut out1).index_mut(0) = x99;
593  *IndexConst(&mut out1).index_mut(1) = x102;
594  *IndexConst(&mut out1).index_mut(2) = x103;
595  *IndexConst(&mut out1).index_mut(3) = x81;
596  *IndexConst(&mut out1).index_mut(4) = x84;
597  *IndexConst(&mut out1).index_mut(5) = x87;
598  *IndexConst(&mut out1).index_mut(6) = x90;
599  *IndexConst(&mut out1).index_mut(7) = x93;
600  *IndexConst(&mut out1).index_mut(8) = x96;
601}
602
603/// The function fiat_p521_carry reduces a field element.
604///
605/// Postconditions:
606///   eval out1 mod m = eval arg1 mod m
607///
608#[inline]
609pub const fn fiat_p521_carry(mut out1: &mut fiat_p521_tight_field_element, arg1: &fiat_p521_loose_field_element) {
610  let x1: u64 = (*IndexConst(arg1).index(0));
611  let x2: u64 = ((x1 >> 58) + (*IndexConst(arg1).index(1)));
612  let x3: u64 = ((x2 >> 58) + (*IndexConst(arg1).index(2)));
613  let x4: u64 = ((x3 >> 58) + (*IndexConst(arg1).index(3)));
614  let x5: u64 = ((x4 >> 58) + (*IndexConst(arg1).index(4)));
615  let x6: u64 = ((x5 >> 58) + (*IndexConst(arg1).index(5)));
616  let x7: u64 = ((x6 >> 58) + (*IndexConst(arg1).index(6)));
617  let x8: u64 = ((x7 >> 58) + (*IndexConst(arg1).index(7)));
618  let x9: u64 = ((x8 >> 58) + (*IndexConst(arg1).index(8)));
619  let x10: u64 = ((x1 & 0x3ffffffffffffff) + (x9 >> 57));
620  let x11: u64 = ((((x10 >> 58) as fiat_p521_u1) as u64) + (x2 & 0x3ffffffffffffff));
621  let x12: u64 = (x10 & 0x3ffffffffffffff);
622  let x13: u64 = (x11 & 0x3ffffffffffffff);
623  let x14: u64 = ((((x11 >> 58) as fiat_p521_u1) as u64) + (x3 & 0x3ffffffffffffff));
624  let x15: u64 = (x4 & 0x3ffffffffffffff);
625  let x16: u64 = (x5 & 0x3ffffffffffffff);
626  let x17: u64 = (x6 & 0x3ffffffffffffff);
627  let x18: u64 = (x7 & 0x3ffffffffffffff);
628  let x19: u64 = (x8 & 0x3ffffffffffffff);
629  let x20: u64 = (x9 & 0x1ffffffffffffff);
630  *IndexConst(&mut out1).index_mut(0) = x12;
631  *IndexConst(&mut out1).index_mut(1) = x13;
632  *IndexConst(&mut out1).index_mut(2) = x14;
633  *IndexConst(&mut out1).index_mut(3) = x15;
634  *IndexConst(&mut out1).index_mut(4) = x16;
635  *IndexConst(&mut out1).index_mut(5) = x17;
636  *IndexConst(&mut out1).index_mut(6) = x18;
637  *IndexConst(&mut out1).index_mut(7) = x19;
638  *IndexConst(&mut out1).index_mut(8) = x20;
639}
640
641/// The function fiat_p521_add adds two field elements.
642///
643/// Postconditions:
644///   eval out1 mod m = (eval arg1 + eval arg2) mod m
645///
646#[inline]
647pub const fn fiat_p521_add(mut out1: &mut fiat_p521_loose_field_element, arg1: &fiat_p521_tight_field_element, arg2: &fiat_p521_tight_field_element) {
648  let x1: u64 = ((*IndexConst(arg1).index(0)) + (*IndexConst(arg2).index(0)));
649  let x2: u64 = ((*IndexConst(arg1).index(1)) + (*IndexConst(arg2).index(1)));
650  let x3: u64 = ((*IndexConst(arg1).index(2)) + (*IndexConst(arg2).index(2)));
651  let x4: u64 = ((*IndexConst(arg1).index(3)) + (*IndexConst(arg2).index(3)));
652  let x5: u64 = ((*IndexConst(arg1).index(4)) + (*IndexConst(arg2).index(4)));
653  let x6: u64 = ((*IndexConst(arg1).index(5)) + (*IndexConst(arg2).index(5)));
654  let x7: u64 = ((*IndexConst(arg1).index(6)) + (*IndexConst(arg2).index(6)));
655  let x8: u64 = ((*IndexConst(arg1).index(7)) + (*IndexConst(arg2).index(7)));
656  let x9: u64 = ((*IndexConst(arg1).index(8)) + (*IndexConst(arg2).index(8)));
657  *IndexConst(&mut out1).index_mut(0) = x1;
658  *IndexConst(&mut out1).index_mut(1) = x2;
659  *IndexConst(&mut out1).index_mut(2) = x3;
660  *IndexConst(&mut out1).index_mut(3) = x4;
661  *IndexConst(&mut out1).index_mut(4) = x5;
662  *IndexConst(&mut out1).index_mut(5) = x6;
663  *IndexConst(&mut out1).index_mut(6) = x7;
664  *IndexConst(&mut out1).index_mut(7) = x8;
665  *IndexConst(&mut out1).index_mut(8) = x9;
666}
667
668/// The function fiat_p521_sub subtracts two field elements.
669///
670/// Postconditions:
671///   eval out1 mod m = (eval arg1 - eval arg2) mod m
672///
673#[inline]
674pub const fn fiat_p521_sub(mut out1: &mut fiat_p521_loose_field_element, arg1: &fiat_p521_tight_field_element, arg2: &fiat_p521_tight_field_element) {
675  let x1: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(0))) - (*IndexConst(arg2).index(0)));
676  let x2: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(1))) - (*IndexConst(arg2).index(1)));
677  let x3: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(2))) - (*IndexConst(arg2).index(2)));
678  let x4: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(3))) - (*IndexConst(arg2).index(3)));
679  let x5: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(4))) - (*IndexConst(arg2).index(4)));
680  let x6: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(5))) - (*IndexConst(arg2).index(5)));
681  let x7: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(6))) - (*IndexConst(arg2).index(6)));
682  let x8: u64 = ((0x7fffffffffffffe + (*IndexConst(arg1).index(7))) - (*IndexConst(arg2).index(7)));
683  let x9: u64 = ((0x3fffffffffffffe + (*IndexConst(arg1).index(8))) - (*IndexConst(arg2).index(8)));
684  *IndexConst(&mut out1).index_mut(0) = x1;
685  *IndexConst(&mut out1).index_mut(1) = x2;
686  *IndexConst(&mut out1).index_mut(2) = x3;
687  *IndexConst(&mut out1).index_mut(3) = x4;
688  *IndexConst(&mut out1).index_mut(4) = x5;
689  *IndexConst(&mut out1).index_mut(5) = x6;
690  *IndexConst(&mut out1).index_mut(6) = x7;
691  *IndexConst(&mut out1).index_mut(7) = x8;
692  *IndexConst(&mut out1).index_mut(8) = x9;
693}
694
695/// The function fiat_p521_opp negates a field element.
696///
697/// Postconditions:
698///   eval out1 mod m = -eval arg1 mod m
699///
700#[inline]
701pub const fn fiat_p521_opp(mut out1: &mut fiat_p521_loose_field_element, arg1: &fiat_p521_tight_field_element) {
702  let x1: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(0)));
703  let x2: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(1)));
704  let x3: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(2)));
705  let x4: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(3)));
706  let x5: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(4)));
707  let x6: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(5)));
708  let x7: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(6)));
709  let x8: u64 = (0x7fffffffffffffe - (*IndexConst(arg1).index(7)));
710  let x9: u64 = (0x3fffffffffffffe - (*IndexConst(arg1).index(8)));
711  *IndexConst(&mut out1).index_mut(0) = x1;
712  *IndexConst(&mut out1).index_mut(1) = x2;
713  *IndexConst(&mut out1).index_mut(2) = x3;
714  *IndexConst(&mut out1).index_mut(3) = x4;
715  *IndexConst(&mut out1).index_mut(4) = x5;
716  *IndexConst(&mut out1).index_mut(5) = x6;
717  *IndexConst(&mut out1).index_mut(6) = x7;
718  *IndexConst(&mut out1).index_mut(7) = x8;
719  *IndexConst(&mut out1).index_mut(8) = x9;
720}
721
722/// The function fiat_p521_selectznz is a multi-limb conditional select.
723///
724/// Postconditions:
725///   out1 = (if arg1 = 0 then arg2 else arg3)
726///
727/// Input Bounds:
728///   arg1: [0x0 ~> 0x1]
729///   arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
730///   arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
731/// Output Bounds:
732///   out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
733#[inline]
734pub const fn fiat_p521_selectznz(mut out1: &mut [u64; 9], arg1: fiat_p521_u1, arg2: &[u64; 9], arg3: &[u64; 9]) {
735  let mut x1: u64 = 0;
736  fiat_p521_cmovznz_u64(&mut x1, arg1, (*IndexConst(arg2).index(0)), (*IndexConst(arg3).index(0)));
737  let mut x2: u64 = 0;
738  fiat_p521_cmovznz_u64(&mut x2, arg1, (*IndexConst(arg2).index(1)), (*IndexConst(arg3).index(1)));
739  let mut x3: u64 = 0;
740  fiat_p521_cmovznz_u64(&mut x3, arg1, (*IndexConst(arg2).index(2)), (*IndexConst(arg3).index(2)));
741  let mut x4: u64 = 0;
742  fiat_p521_cmovznz_u64(&mut x4, arg1, (*IndexConst(arg2).index(3)), (*IndexConst(arg3).index(3)));
743  let mut x5: u64 = 0;
744  fiat_p521_cmovznz_u64(&mut x5, arg1, (*IndexConst(arg2).index(4)), (*IndexConst(arg3).index(4)));
745  let mut x6: u64 = 0;
746  fiat_p521_cmovznz_u64(&mut x6, arg1, (*IndexConst(arg2).index(5)), (*IndexConst(arg3).index(5)));
747  let mut x7: u64 = 0;
748  fiat_p521_cmovznz_u64(&mut x7, arg1, (*IndexConst(arg2).index(6)), (*IndexConst(arg3).index(6)));
749  let mut x8: u64 = 0;
750  fiat_p521_cmovznz_u64(&mut x8, arg1, (*IndexConst(arg2).index(7)), (*IndexConst(arg3).index(7)));
751  let mut x9: u64 = 0;
752  fiat_p521_cmovznz_u64(&mut x9, arg1, (*IndexConst(arg2).index(8)), (*IndexConst(arg3).index(8)));
753  *IndexConst(&mut out1).index_mut(0) = x1;
754  *IndexConst(&mut out1).index_mut(1) = x2;
755  *IndexConst(&mut out1).index_mut(2) = x3;
756  *IndexConst(&mut out1).index_mut(3) = x4;
757  *IndexConst(&mut out1).index_mut(4) = x5;
758  *IndexConst(&mut out1).index_mut(5) = x6;
759  *IndexConst(&mut out1).index_mut(6) = x7;
760  *IndexConst(&mut out1).index_mut(7) = x8;
761  *IndexConst(&mut out1).index_mut(8) = x9;
762}
763
764/// The function fiat_p521_to_bytes serializes a field element to bytes in little-endian order.
765///
766/// Postconditions:
767///   out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..65]
768///
769/// Output Bounds:
770///   out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x1]]
771#[inline]
772pub const fn fiat_p521_to_bytes(mut out1: &mut [u8; 66], arg1: &fiat_p521_tight_field_element) {
773  let mut x1: u64 = 0;
774  let mut x2: fiat_p521_u1 = 0;
775  fiat_p521_subborrowx_u58(&mut x1, &mut x2, 0x0, (*IndexConst(arg1).index(0)), 0x3ffffffffffffff);
776  let mut x3: u64 = 0;
777  let mut x4: fiat_p521_u1 = 0;
778  fiat_p521_subborrowx_u58(&mut x3, &mut x4, x2, (*IndexConst(arg1).index(1)), 0x3ffffffffffffff);
779  let mut x5: u64 = 0;
780  let mut x6: fiat_p521_u1 = 0;
781  fiat_p521_subborrowx_u58(&mut x5, &mut x6, x4, (*IndexConst(arg1).index(2)), 0x3ffffffffffffff);
782  let mut x7: u64 = 0;
783  let mut x8: fiat_p521_u1 = 0;
784  fiat_p521_subborrowx_u58(&mut x7, &mut x8, x6, (*IndexConst(arg1).index(3)), 0x3ffffffffffffff);
785  let mut x9: u64 = 0;
786  let mut x10: fiat_p521_u1 = 0;
787  fiat_p521_subborrowx_u58(&mut x9, &mut x10, x8, (*IndexConst(arg1).index(4)), 0x3ffffffffffffff);
788  let mut x11: u64 = 0;
789  let mut x12: fiat_p521_u1 = 0;
790  fiat_p521_subborrowx_u58(&mut x11, &mut x12, x10, (*IndexConst(arg1).index(5)), 0x3ffffffffffffff);
791  let mut x13: u64 = 0;
792  let mut x14: fiat_p521_u1 = 0;
793  fiat_p521_subborrowx_u58(&mut x13, &mut x14, x12, (*IndexConst(arg1).index(6)), 0x3ffffffffffffff);
794  let mut x15: u64 = 0;
795  let mut x16: fiat_p521_u1 = 0;
796  fiat_p521_subborrowx_u58(&mut x15, &mut x16, x14, (*IndexConst(arg1).index(7)), 0x3ffffffffffffff);
797  let mut x17: u64 = 0;
798  let mut x18: fiat_p521_u1 = 0;
799  fiat_p521_subborrowx_u57(&mut x17, &mut x18, x16, (*IndexConst(arg1).index(8)), 0x1ffffffffffffff);
800  let mut x19: u64 = 0;
801  fiat_p521_cmovznz_u64(&mut x19, x18, (0x0 as u64), 0xffffffffffffffff);
802  let mut x20: u64 = 0;
803  let mut x21: fiat_p521_u1 = 0;
804  fiat_p521_addcarryx_u58(&mut x20, &mut x21, 0x0, x1, (x19 & 0x3ffffffffffffff));
805  let mut x22: u64 = 0;
806  let mut x23: fiat_p521_u1 = 0;
807  fiat_p521_addcarryx_u58(&mut x22, &mut x23, x21, x3, (x19 & 0x3ffffffffffffff));
808  let mut x24: u64 = 0;
809  let mut x25: fiat_p521_u1 = 0;
810  fiat_p521_addcarryx_u58(&mut x24, &mut x25, x23, x5, (x19 & 0x3ffffffffffffff));
811  let mut x26: u64 = 0;
812  let mut x27: fiat_p521_u1 = 0;
813  fiat_p521_addcarryx_u58(&mut x26, &mut x27, x25, x7, (x19 & 0x3ffffffffffffff));
814  let mut x28: u64 = 0;
815  let mut x29: fiat_p521_u1 = 0;
816  fiat_p521_addcarryx_u58(&mut x28, &mut x29, x27, x9, (x19 & 0x3ffffffffffffff));
817  let mut x30: u64 = 0;
818  let mut x31: fiat_p521_u1 = 0;
819  fiat_p521_addcarryx_u58(&mut x30, &mut x31, x29, x11, (x19 & 0x3ffffffffffffff));
820  let mut x32: u64 = 0;
821  let mut x33: fiat_p521_u1 = 0;
822  fiat_p521_addcarryx_u58(&mut x32, &mut x33, x31, x13, (x19 & 0x3ffffffffffffff));
823  let mut x34: u64 = 0;
824  let mut x35: fiat_p521_u1 = 0;
825  fiat_p521_addcarryx_u58(&mut x34, &mut x35, x33, x15, (x19 & 0x3ffffffffffffff));
826  let mut x36: u64 = 0;
827  let mut x37: fiat_p521_u1 = 0;
828  fiat_p521_addcarryx_u57(&mut x36, &mut x37, x35, x17, (x19 & 0x1ffffffffffffff));
829  let x38: u64 = (x34 << 6);
830  let x39: u64 = (x32 << 4);
831  let x40: u64 = (x30 << 2);
832  let x41: u64 = (x26 << 6);
833  let x42: u64 = (x24 << 4);
834  let x43: u64 = (x22 << 2);
835  let x44: u8 = ((x20 & (0xff as u64)) as u8);
836  let x45: u64 = (x20 >> 8);
837  let x46: u8 = ((x45 & (0xff as u64)) as u8);
838  let x47: u64 = (x45 >> 8);
839  let x48: u8 = ((x47 & (0xff as u64)) as u8);
840  let x49: u64 = (x47 >> 8);
841  let x50: u8 = ((x49 & (0xff as u64)) as u8);
842  let x51: u64 = (x49 >> 8);
843  let x52: u8 = ((x51 & (0xff as u64)) as u8);
844  let x53: u64 = (x51 >> 8);
845  let x54: u8 = ((x53 & (0xff as u64)) as u8);
846  let x55: u64 = (x53 >> 8);
847  let x56: u8 = ((x55 & (0xff as u64)) as u8);
848  let x57: u8 = ((x55 >> 8) as u8);
849  let x58: u64 = (x43 + (x57 as u64));
850  let x59: u8 = ((x58 & (0xff as u64)) as u8);
851  let x60: u64 = (x58 >> 8);
852  let x61: u8 = ((x60 & (0xff as u64)) as u8);
853  let x62: u64 = (x60 >> 8);
854  let x63: u8 = ((x62 & (0xff as u64)) as u8);
855  let x64: u64 = (x62 >> 8);
856  let x65: u8 = ((x64 & (0xff as u64)) as u8);
857  let x66: u64 = (x64 >> 8);
858  let x67: u8 = ((x66 & (0xff as u64)) as u8);
859  let x68: u64 = (x66 >> 8);
860  let x69: u8 = ((x68 & (0xff as u64)) as u8);
861  let x70: u64 = (x68 >> 8);
862  let x71: u8 = ((x70 & (0xff as u64)) as u8);
863  let x72: u8 = ((x70 >> 8) as u8);
864  let x73: u64 = (x42 + (x72 as u64));
865  let x74: u8 = ((x73 & (0xff as u64)) as u8);
866  let x75: u64 = (x73 >> 8);
867  let x76: u8 = ((x75 & (0xff as u64)) as u8);
868  let x77: u64 = (x75 >> 8);
869  let x78: u8 = ((x77 & (0xff as u64)) as u8);
870  let x79: u64 = (x77 >> 8);
871  let x80: u8 = ((x79 & (0xff as u64)) as u8);
872  let x81: u64 = (x79 >> 8);
873  let x82: u8 = ((x81 & (0xff as u64)) as u8);
874  let x83: u64 = (x81 >> 8);
875  let x84: u8 = ((x83 & (0xff as u64)) as u8);
876  let x85: u64 = (x83 >> 8);
877  let x86: u8 = ((x85 & (0xff as u64)) as u8);
878  let x87: u8 = ((x85 >> 8) as u8);
879  let x88: u64 = (x41 + (x87 as u64));
880  let x89: u8 = ((x88 & (0xff as u64)) as u8);
881  let x90: u64 = (x88 >> 8);
882  let x91: u8 = ((x90 & (0xff as u64)) as u8);
883  let x92: u64 = (x90 >> 8);
884  let x93: u8 = ((x92 & (0xff as u64)) as u8);
885  let x94: u64 = (x92 >> 8);
886  let x95: u8 = ((x94 & (0xff as u64)) as u8);
887  let x96: u64 = (x94 >> 8);
888  let x97: u8 = ((x96 & (0xff as u64)) as u8);
889  let x98: u64 = (x96 >> 8);
890  let x99: u8 = ((x98 & (0xff as u64)) as u8);
891  let x100: u64 = (x98 >> 8);
892  let x101: u8 = ((x100 & (0xff as u64)) as u8);
893  let x102: u8 = ((x100 >> 8) as u8);
894  let x103: u8 = ((x28 & (0xff as u64)) as u8);
895  let x104: u64 = (x28 >> 8);
896  let x105: u8 = ((x104 & (0xff as u64)) as u8);
897  let x106: u64 = (x104 >> 8);
898  let x107: u8 = ((x106 & (0xff as u64)) as u8);
899  let x108: u64 = (x106 >> 8);
900  let x109: u8 = ((x108 & (0xff as u64)) as u8);
901  let x110: u64 = (x108 >> 8);
902  let x111: u8 = ((x110 & (0xff as u64)) as u8);
903  let x112: u64 = (x110 >> 8);
904  let x113: u8 = ((x112 & (0xff as u64)) as u8);
905  let x114: u64 = (x112 >> 8);
906  let x115: u8 = ((x114 & (0xff as u64)) as u8);
907  let x116: u8 = ((x114 >> 8) as u8);
908  let x117: u64 = (x40 + (x116 as u64));
909  let x118: u8 = ((x117 & (0xff as u64)) as u8);
910  let x119: u64 = (x117 >> 8);
911  let x120: u8 = ((x119 & (0xff as u64)) as u8);
912  let x121: u64 = (x119 >> 8);
913  let x122: u8 = ((x121 & (0xff as u64)) as u8);
914  let x123: u64 = (x121 >> 8);
915  let x124: u8 = ((x123 & (0xff as u64)) as u8);
916  let x125: u64 = (x123 >> 8);
917  let x126: u8 = ((x125 & (0xff as u64)) as u8);
918  let x127: u64 = (x125 >> 8);
919  let x128: u8 = ((x127 & (0xff as u64)) as u8);
920  let x129: u64 = (x127 >> 8);
921  let x130: u8 = ((x129 & (0xff as u64)) as u8);
922  let x131: u8 = ((x129 >> 8) as u8);
923  let x132: u64 = (x39 + (x131 as u64));
924  let x133: u8 = ((x132 & (0xff as u64)) as u8);
925  let x134: u64 = (x132 >> 8);
926  let x135: u8 = ((x134 & (0xff as u64)) as u8);
927  let x136: u64 = (x134 >> 8);
928  let x137: u8 = ((x136 & (0xff as u64)) as u8);
929  let x138: u64 = (x136 >> 8);
930  let x139: u8 = ((x138 & (0xff as u64)) as u8);
931  let x140: u64 = (x138 >> 8);
932  let x141: u8 = ((x140 & (0xff as u64)) as u8);
933  let x142: u64 = (x140 >> 8);
934  let x143: u8 = ((x142 & (0xff as u64)) as u8);
935  let x144: u64 = (x142 >> 8);
936  let x145: u8 = ((x144 & (0xff as u64)) as u8);
937  let x146: u8 = ((x144 >> 8) as u8);
938  let x147: u64 = (x38 + (x146 as u64));
939  let x148: u8 = ((x147 & (0xff as u64)) as u8);
940  let x149: u64 = (x147 >> 8);
941  let x150: u8 = ((x149 & (0xff as u64)) as u8);
942  let x151: u64 = (x149 >> 8);
943  let x152: u8 = ((x151 & (0xff as u64)) as u8);
944  let x153: u64 = (x151 >> 8);
945  let x154: u8 = ((x153 & (0xff as u64)) as u8);
946  let x155: u64 = (x153 >> 8);
947  let x156: u8 = ((x155 & (0xff as u64)) as u8);
948  let x157: u64 = (x155 >> 8);
949  let x158: u8 = ((x157 & (0xff as u64)) as u8);
950  let x159: u64 = (x157 >> 8);
951  let x160: u8 = ((x159 & (0xff as u64)) as u8);
952  let x161: u8 = ((x159 >> 8) as u8);
953  let x162: u8 = ((x36 & (0xff as u64)) as u8);
954  let x163: u64 = (x36 >> 8);
955  let x164: u8 = ((x163 & (0xff as u64)) as u8);
956  let x165: u64 = (x163 >> 8);
957  let x166: u8 = ((x165 & (0xff as u64)) as u8);
958  let x167: u64 = (x165 >> 8);
959  let x168: u8 = ((x167 & (0xff as u64)) as u8);
960  let x169: u64 = (x167 >> 8);
961  let x170: u8 = ((x169 & (0xff as u64)) as u8);
962  let x171: u64 = (x169 >> 8);
963  let x172: u8 = ((x171 & (0xff as u64)) as u8);
964  let x173: u64 = (x171 >> 8);
965  let x174: u8 = ((x173 & (0xff as u64)) as u8);
966  let x175: fiat_p521_u1 = ((x173 >> 8) as fiat_p521_u1);
967  *IndexConst(&mut out1).index_mut(0) = x44;
968  *IndexConst(&mut out1).index_mut(1) = x46;
969  *IndexConst(&mut out1).index_mut(2) = x48;
970  *IndexConst(&mut out1).index_mut(3) = x50;
971  *IndexConst(&mut out1).index_mut(4) = x52;
972  *IndexConst(&mut out1).index_mut(5) = x54;
973  *IndexConst(&mut out1).index_mut(6) = x56;
974  *IndexConst(&mut out1).index_mut(7) = x59;
975  *IndexConst(&mut out1).index_mut(8) = x61;
976  *IndexConst(&mut out1).index_mut(9) = x63;
977  *IndexConst(&mut out1).index_mut(10) = x65;
978  *IndexConst(&mut out1).index_mut(11) = x67;
979  *IndexConst(&mut out1).index_mut(12) = x69;
980  *IndexConst(&mut out1).index_mut(13) = x71;
981  *IndexConst(&mut out1).index_mut(14) = x74;
982  *IndexConst(&mut out1).index_mut(15) = x76;
983  *IndexConst(&mut out1).index_mut(16) = x78;
984  *IndexConst(&mut out1).index_mut(17) = x80;
985  *IndexConst(&mut out1).index_mut(18) = x82;
986  *IndexConst(&mut out1).index_mut(19) = x84;
987  *IndexConst(&mut out1).index_mut(20) = x86;
988  *IndexConst(&mut out1).index_mut(21) = x89;
989  *IndexConst(&mut out1).index_mut(22) = x91;
990  *IndexConst(&mut out1).index_mut(23) = x93;
991  *IndexConst(&mut out1).index_mut(24) = x95;
992  *IndexConst(&mut out1).index_mut(25) = x97;
993  *IndexConst(&mut out1).index_mut(26) = x99;
994  *IndexConst(&mut out1).index_mut(27) = x101;
995  *IndexConst(&mut out1).index_mut(28) = x102;
996  *IndexConst(&mut out1).index_mut(29) = x103;
997  *IndexConst(&mut out1).index_mut(30) = x105;
998  *IndexConst(&mut out1).index_mut(31) = x107;
999  *IndexConst(&mut out1).index_mut(32) = x109;
1000  *IndexConst(&mut out1).index_mut(33) = x111;
1001  *IndexConst(&mut out1).index_mut(34) = x113;
1002  *IndexConst(&mut out1).index_mut(35) = x115;
1003  *IndexConst(&mut out1).index_mut(36) = x118;
1004  *IndexConst(&mut out1).index_mut(37) = x120;
1005  *IndexConst(&mut out1).index_mut(38) = x122;
1006  *IndexConst(&mut out1).index_mut(39) = x124;
1007  *IndexConst(&mut out1).index_mut(40) = x126;
1008  *IndexConst(&mut out1).index_mut(41) = x128;
1009  *IndexConst(&mut out1).index_mut(42) = x130;
1010  *IndexConst(&mut out1).index_mut(43) = x133;
1011  *IndexConst(&mut out1).index_mut(44) = x135;
1012  *IndexConst(&mut out1).index_mut(45) = x137;
1013  *IndexConst(&mut out1).index_mut(46) = x139;
1014  *IndexConst(&mut out1).index_mut(47) = x141;
1015  *IndexConst(&mut out1).index_mut(48) = x143;
1016  *IndexConst(&mut out1).index_mut(49) = x145;
1017  *IndexConst(&mut out1).index_mut(50) = x148;
1018  *IndexConst(&mut out1).index_mut(51) = x150;
1019  *IndexConst(&mut out1).index_mut(52) = x152;
1020  *IndexConst(&mut out1).index_mut(53) = x154;
1021  *IndexConst(&mut out1).index_mut(54) = x156;
1022  *IndexConst(&mut out1).index_mut(55) = x158;
1023  *IndexConst(&mut out1).index_mut(56) = x160;
1024  *IndexConst(&mut out1).index_mut(57) = x161;
1025  *IndexConst(&mut out1).index_mut(58) = x162;
1026  *IndexConst(&mut out1).index_mut(59) = x164;
1027  *IndexConst(&mut out1).index_mut(60) = x166;
1028  *IndexConst(&mut out1).index_mut(61) = x168;
1029  *IndexConst(&mut out1).index_mut(62) = x170;
1030  *IndexConst(&mut out1).index_mut(63) = x172;
1031  *IndexConst(&mut out1).index_mut(64) = x174;
1032  *IndexConst(&mut out1).index_mut(65) = (x175 as u8);
1033}
1034
1035/// The function fiat_p521_from_bytes deserializes a field element from bytes in little-endian order.
1036///
1037/// Postconditions:
1038///   eval out1 mod m = bytes_eval arg1 mod m
1039///
1040/// Input Bounds:
1041///   arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x1]]
1042#[inline]
1043pub const fn fiat_p521_from_bytes(mut out1: &mut fiat_p521_tight_field_element, arg1: &[u8; 66]) {
1044  let x1: u64 = ((((*IndexConst(arg1).index(65)) as fiat_p521_u1) as u64) << 56);
1045  let x2: u64 = (((*IndexConst(arg1).index(64)) as u64) << 48);
1046  let x3: u64 = (((*IndexConst(arg1).index(63)) as u64) << 40);
1047  let x4: u64 = (((*IndexConst(arg1).index(62)) as u64) << 32);
1048  let x5: u64 = (((*IndexConst(arg1).index(61)) as u64) << 24);
1049  let x6: u64 = (((*IndexConst(arg1).index(60)) as u64) << 16);
1050  let x7: u64 = (((*IndexConst(arg1).index(59)) as u64) << 8);
1051  let x8: u8 = (*IndexConst(arg1).index(58));
1052  let x9: u64 = (((*IndexConst(arg1).index(57)) as u64) << 50);
1053  let x10: u64 = (((*IndexConst(arg1).index(56)) as u64) << 42);
1054  let x11: u64 = (((*IndexConst(arg1).index(55)) as u64) << 34);
1055  let x12: u64 = (((*IndexConst(arg1).index(54)) as u64) << 26);
1056  let x13: u64 = (((*IndexConst(arg1).index(53)) as u64) << 18);
1057  let x14: u64 = (((*IndexConst(arg1).index(52)) as u64) << 10);
1058  let x15: u64 = (((*IndexConst(arg1).index(51)) as u64) << 2);
1059  let x16: u64 = (((*IndexConst(arg1).index(50)) as u64) << 52);
1060  let x17: u64 = (((*IndexConst(arg1).index(49)) as u64) << 44);
1061  let x18: u64 = (((*IndexConst(arg1).index(48)) as u64) << 36);
1062  let x19: u64 = (((*IndexConst(arg1).index(47)) as u64) << 28);
1063  let x20: u64 = (((*IndexConst(arg1).index(46)) as u64) << 20);
1064  let x21: u64 = (((*IndexConst(arg1).index(45)) as u64) << 12);
1065  let x22: u64 = (((*IndexConst(arg1).index(44)) as u64) << 4);
1066  let x23: u64 = (((*IndexConst(arg1).index(43)) as u64) << 54);
1067  let x24: u64 = (((*IndexConst(arg1).index(42)) as u64) << 46);
1068  let x25: u64 = (((*IndexConst(arg1).index(41)) as u64) << 38);
1069  let x26: u64 = (((*IndexConst(arg1).index(40)) as u64) << 30);
1070  let x27: u64 = (((*IndexConst(arg1).index(39)) as u64) << 22);
1071  let x28: u64 = (((*IndexConst(arg1).index(38)) as u64) << 14);
1072  let x29: u64 = (((*IndexConst(arg1).index(37)) as u64) << 6);
1073  let x30: u64 = (((*IndexConst(arg1).index(36)) as u64) << 56);
1074  let x31: u64 = (((*IndexConst(arg1).index(35)) as u64) << 48);
1075  let x32: u64 = (((*IndexConst(arg1).index(34)) as u64) << 40);
1076  let x33: u64 = (((*IndexConst(arg1).index(33)) as u64) << 32);
1077  let x34: u64 = (((*IndexConst(arg1).index(32)) as u64) << 24);
1078  let x35: u64 = (((*IndexConst(arg1).index(31)) as u64) << 16);
1079  let x36: u64 = (((*IndexConst(arg1).index(30)) as u64) << 8);
1080  let x37: u8 = (*IndexConst(arg1).index(29));
1081  let x38: u64 = (((*IndexConst(arg1).index(28)) as u64) << 50);
1082  let x39: u64 = (((*IndexConst(arg1).index(27)) as u64) << 42);
1083  let x40: u64 = (((*IndexConst(arg1).index(26)) as u64) << 34);
1084  let x41: u64 = (((*IndexConst(arg1).index(25)) as u64) << 26);
1085  let x42: u64 = (((*IndexConst(arg1).index(24)) as u64) << 18);
1086  let x43: u64 = (((*IndexConst(arg1).index(23)) as u64) << 10);
1087  let x44: u64 = (((*IndexConst(arg1).index(22)) as u64) << 2);
1088  let x45: u64 = (((*IndexConst(arg1).index(21)) as u64) << 52);
1089  let x46: u64 = (((*IndexConst(arg1).index(20)) as u64) << 44);
1090  let x47: u64 = (((*IndexConst(arg1).index(19)) as u64) << 36);
1091  let x48: u64 = (((*IndexConst(arg1).index(18)) as u64) << 28);
1092  let x49: u64 = (((*IndexConst(arg1).index(17)) as u64) << 20);
1093  let x50: u64 = (((*IndexConst(arg1).index(16)) as u64) << 12);
1094  let x51: u64 = (((*IndexConst(arg1).index(15)) as u64) << 4);
1095  let x52: u64 = (((*IndexConst(arg1).index(14)) as u64) << 54);
1096  let x53: u64 = (((*IndexConst(arg1).index(13)) as u64) << 46);
1097  let x54: u64 = (((*IndexConst(arg1).index(12)) as u64) << 38);
1098  let x55: u64 = (((*IndexConst(arg1).index(11)) as u64) << 30);
1099  let x56: u64 = (((*IndexConst(arg1).index(10)) as u64) << 22);
1100  let x57: u64 = (((*IndexConst(arg1).index(9)) as u64) << 14);
1101  let x58: u64 = (((*IndexConst(arg1).index(8)) as u64) << 6);
1102  let x59: u64 = (((*IndexConst(arg1).index(7)) as u64) << 56);
1103  let x60: u64 = (((*IndexConst(arg1).index(6)) as u64) << 48);
1104  let x61: u64 = (((*IndexConst(arg1).index(5)) as u64) << 40);
1105  let x62: u64 = (((*IndexConst(arg1).index(4)) as u64) << 32);
1106  let x63: u64 = (((*IndexConst(arg1).index(3)) as u64) << 24);
1107  let x64: u64 = (((*IndexConst(arg1).index(2)) as u64) << 16);
1108  let x65: u64 = (((*IndexConst(arg1).index(1)) as u64) << 8);
1109  let x66: u8 = (*IndexConst(arg1).index(0));
1110  let x67: u64 = (x65 + (x66 as u64));
1111  let x68: u64 = (x64 + x67);
1112  let x69: u64 = (x63 + x68);
1113  let x70: u64 = (x62 + x69);
1114  let x71: u64 = (x61 + x70);
1115  let x72: u64 = (x60 + x71);
1116  let x73: u64 = (x59 + x72);
1117  let x74: u64 = (x73 & 0x3ffffffffffffff);
1118  let x75: u8 = ((x73 >> 58) as u8);
1119  let x76: u64 = (x58 + (x75 as u64));
1120  let x77: u64 = (x57 + x76);
1121  let x78: u64 = (x56 + x77);
1122  let x79: u64 = (x55 + x78);
1123  let x80: u64 = (x54 + x79);
1124  let x81: u64 = (x53 + x80);
1125  let x82: u64 = (x52 + x81);
1126  let x83: u64 = (x82 & 0x3ffffffffffffff);
1127  let x84: u8 = ((x82 >> 58) as u8);
1128  let x85: u64 = (x51 + (x84 as u64));
1129  let x86: u64 = (x50 + x85);
1130  let x87: u64 = (x49 + x86);
1131  let x88: u64 = (x48 + x87);
1132  let x89: u64 = (x47 + x88);
1133  let x90: u64 = (x46 + x89);
1134  let x91: u64 = (x45 + x90);
1135  let x92: u64 = (x91 & 0x3ffffffffffffff);
1136  let x93: u8 = ((x91 >> 58) as u8);
1137  let x94: u64 = (x44 + (x93 as u64));
1138  let x95: u64 = (x43 + x94);
1139  let x96: u64 = (x42 + x95);
1140  let x97: u64 = (x41 + x96);
1141  let x98: u64 = (x40 + x97);
1142  let x99: u64 = (x39 + x98);
1143  let x100: u64 = (x38 + x99);
1144  let x101: u64 = (x36 + (x37 as u64));
1145  let x102: u64 = (x35 + x101);
1146  let x103: u64 = (x34 + x102);
1147  let x104: u64 = (x33 + x103);
1148  let x105: u64 = (x32 + x104);
1149  let x106: u64 = (x31 + x105);
1150  let x107: u64 = (x30 + x106);
1151  let x108: u64 = (x107 & 0x3ffffffffffffff);
1152  let x109: u8 = ((x107 >> 58) as u8);
1153  let x110: u64 = (x29 + (x109 as u64));
1154  let x111: u64 = (x28 + x110);
1155  let x112: u64 = (x27 + x111);
1156  let x113: u64 = (x26 + x112);
1157  let x114: u64 = (x25 + x113);
1158  let x115: u64 = (x24 + x114);
1159  let x116: u64 = (x23 + x115);
1160  let x117: u64 = (x116 & 0x3ffffffffffffff);
1161  let x118: u8 = ((x116 >> 58) as u8);
1162  let x119: u64 = (x22 + (x118 as u64));
1163  let x120: u64 = (x21 + x119);
1164  let x121: u64 = (x20 + x120);
1165  let x122: u64 = (x19 + x121);
1166  let x123: u64 = (x18 + x122);
1167  let x124: u64 = (x17 + x123);
1168  let x125: u64 = (x16 + x124);
1169  let x126: u64 = (x125 & 0x3ffffffffffffff);
1170  let x127: u8 = ((x125 >> 58) as u8);
1171  let x128: u64 = (x15 + (x127 as u64));
1172  let x129: u64 = (x14 + x128);
1173  let x130: u64 = (x13 + x129);
1174  let x131: u64 = (x12 + x130);
1175  let x132: u64 = (x11 + x131);
1176  let x133: u64 = (x10 + x132);
1177  let x134: u64 = (x9 + x133);
1178  let x135: u64 = (x7 + (x8 as u64));
1179  let x136: u64 = (x6 + x135);
1180  let x137: u64 = (x5 + x136);
1181  let x138: u64 = (x4 + x137);
1182  let x139: u64 = (x3 + x138);
1183  let x140: u64 = (x2 + x139);
1184  let x141: u64 = (x1 + x140);
1185  *IndexConst(&mut out1).index_mut(0) = x74;
1186  *IndexConst(&mut out1).index_mut(1) = x83;
1187  *IndexConst(&mut out1).index_mut(2) = x92;
1188  *IndexConst(&mut out1).index_mut(3) = x100;
1189  *IndexConst(&mut out1).index_mut(4) = x108;
1190  *IndexConst(&mut out1).index_mut(5) = x117;
1191  *IndexConst(&mut out1).index_mut(6) = x126;
1192  *IndexConst(&mut out1).index_mut(7) = x134;
1193  *IndexConst(&mut out1).index_mut(8) = x141;
1194}
1195
1196/// The function fiat_p521_relax is the identity function converting from tight field elements to loose field elements.
1197///
1198/// Postconditions:
1199///   out1 = arg1
1200///
1201#[inline]
1202pub const fn fiat_p521_relax(mut out1: &mut fiat_p521_loose_field_element, arg1: &fiat_p521_tight_field_element) {
1203  let x1: u64 = (*IndexConst(arg1).index(0));
1204  let x2: u64 = (*IndexConst(arg1).index(1));
1205  let x3: u64 = (*IndexConst(arg1).index(2));
1206  let x4: u64 = (*IndexConst(arg1).index(3));
1207  let x5: u64 = (*IndexConst(arg1).index(4));
1208  let x6: u64 = (*IndexConst(arg1).index(5));
1209  let x7: u64 = (*IndexConst(arg1).index(6));
1210  let x8: u64 = (*IndexConst(arg1).index(7));
1211  let x9: u64 = (*IndexConst(arg1).index(8));
1212  *IndexConst(&mut out1).index_mut(0) = x1;
1213  *IndexConst(&mut out1).index_mut(1) = x2;
1214  *IndexConst(&mut out1).index_mut(2) = x3;
1215  *IndexConst(&mut out1).index_mut(3) = x4;
1216  *IndexConst(&mut out1).index_mut(4) = x5;
1217  *IndexConst(&mut out1).index_mut(5) = x6;
1218  *IndexConst(&mut out1).index_mut(6) = x7;
1219  *IndexConst(&mut out1).index_mut(7) = x8;
1220  *IndexConst(&mut out1).index_mut(8) = x9;
1221}