Debian Codegraph @

fiat-bedrock2/src/poly1305_64.c

raw symbols SCIP
1 /* Autogenerated: 'src/ExtractionOCaml/bedrock2_unsaturated_solinas' --lang bedrock2 --static --no-wide-int --widen-carry --widen-bytes --split-multiret --no-select --no-field-element-typedefs poly1305 64 3 '2^130 - 5' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax */
2 /* curve description: poly1305 */
3 /* machine_wordsize = 64 (from "64") */
4 /* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax */
5 /* n = 3 (from "3") */
6 /* s-c = 2^130 - [(1, 5)] (from "2^130 - 5") */
7 /* tight_bounds_multiplier = 1 (from "") */
8 /* */
9 /* Computed values: */
10 /* carry_chain = [0, 1, 2, 0, 1] */
11 /* eval z = z[0] + (z[1] << 44) + (z[2] << 87) */
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) */
13 /* balance = [0x1ffffffffff6, 0xffffffffffe, 0xffffffffffe] */
14
15 // Generated from Bedrock code. Avoid editing directly.
16 #include <stdint.h>
17 #include <string.h>
18 #include <assert.h>
19
20 #define BR_WORD_MAX UINTPTR_MAX
21 typedef uintptr_t br_word_t;
22 typedef intptr_t br_signed_t;
23
24 static_assert(sizeof(br_word_t) == sizeof(br_signed_t), "signed size");
25 static_assert(UINTPTR_MAX <= BR_WORD_MAX, "pointer fits in int");
26 static_assert(~(br_signed_t)0 == -(br_signed_t)1, "two's complement");
27
28 #if __STDC_VERSION__ >= 202311L && __has_include(<stdbit.h>)
29 #include <stdbit.h>
30 static_assert(__STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_LITTLE__, "little-endian");
31 #elif defined(__GNUC__) && defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
32 static_assert(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__, "little-endian");
33 #elif defined(_MSC_VER) && !defined(__clang__) && \
34 (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64))
35 // these MSVC targets are little-endian
36 #else
37 #error "failed to confirm that target is little-endian"
38 #endif
39
40 // "An object shall have its stored value accessed only ... a character type."
41 static inline br_word_t _br_load1(br_word_t a) {
42 return *((uint8_t *)a);
43 }
44
45 static inline br_word_t _br_load2(br_word_t a) {
46 uint16_t r = 0;
47 memcpy(&r, (void *)a, sizeof(r));
48 return r;
49 }
50
51 static inline br_word_t _br_load4(br_word_t a) {
52 uint32_t r = 0;
53 memcpy(&r, (void *)a, sizeof(r));
54 return r;
55 }
56
57 static inline br_word_t _br_load(br_word_t a) {
58 br_word_t r = 0;
59 memcpy(&r, (void *)a, sizeof(r));
60 return r;
61 }
62
63 static inline void _br_store1(br_word_t a, uint8_t v) {
64 *((uint8_t *)a) = v;
65 }
66
67 static inline void _br_store2(br_word_t a, uint16_t v) {
68 memcpy((void *)a, &v, sizeof(v));
69 }
70
71 static inline void _br_store4(br_word_t a, uint32_t v) {
72 memcpy((void *)a, &v, sizeof(v));
73 }
74
75 static inline void _br_store(br_word_t a, br_word_t v) {
76 memcpy((void *)a, &v, sizeof(v));
77 }
78
79 static inline br_word_t _br_mulhuu(br_word_t a, br_word_t b) {
80 #if BR_WORD_MAX == UINT32_MAX
81 return ((uint64_t)a * b) >> 32;
82 #elif BR_WORD_MAX == UINT64_MAX && (defined(__GNUC__) || defined(__clang__))
83 return ((unsigned __int128)a * b) >> 64;
84 #elif defined(_M_X64)
85 uint64_t hi;
86 _umul128(a, b, &hi);
87 return hi;
88 #elif defined(_M_ARM64)
89 return __umulh(a, b);
90 #else
91 // See full_mul.v
92 br_word_t hh, lh, hl, low, second_halfword_w_oflow, n, ll, M;
93 n = ((((0u-(br_word_t)0x1)>>27)&0x3f)+0x1)>>1;
94 M = ((br_word_t)0x1<<n)-0x1;
95 ll = (a&M)*(b&M);
96 lh = (a&M)*(b>>n);
97 hl = (a>>n)*(b&M);
98 hh = (a>>n)*(b>>n);
99 second_halfword_w_oflow = ((ll>>n)+(lh&M))+(hl&M);
100 return ((hh+(lh>>n))+(hl>>n))+(second_halfword_w_oflow>>n);
101 #endif
102 }
103
104 static inline br_word_t _br_divu(br_word_t a, br_word_t b) {
105 if (!b) return -1;
106 return a/b;
107 }
108
109 static inline br_word_t _br_remu(br_word_t a, br_word_t b) {
110 if (!b) return a;
111 return a%b;
112 }
113
114
115 /*
116 * Input Bounds:
117 * in0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
118 * in1: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
119 * Output Bounds:
120 * out0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
121 */
122 static
123 void internal_fiat_poly1305_carry_mul(br_word_t out0, br_word_t in0, br_word_t in1) {
124 br_word_t x2, x1, x5, x4, x0, x3, x8, x10, x25, x11, x26, x9, x24, x22, x29, x23, x30, x27, x31, x28, x12, x14, x35, x15, x36, x13, x34, x18, x39, x19, x40, x37, x6, x16, x43, x17, x44, x7, x42, x20, x47, x21, x48, x45, x46, x32, x51, x49, x52, x50, x38, x53, x56, x41, x57, x55, x58, x33, x60, x61, x62, x54, x64, x65, x59, x63, x66, x67, x68, x69, x70;
125 x0 = _br_load(in0+0);
126 x1 = _br_load(in0+8);
127 x2 = _br_load(in0+16);
128 /*skip*/
129 x3 = _br_load(in1+0);
130 x4 = _br_load(in1+8);
131 x5 = _br_load(in1+16);
132 /*skip*/
133 /*skip*/
134 x6 = x2*(x5*5);
135 x7 = _br_mulhuu(x2, (x5*5));
136 x8 = x2*(x4*10);
137 x9 = _br_mulhuu(x2, (x4*10));
138 x10 = x1*(x5*10);
139 x11 = _br_mulhuu(x1, (x5*10));
140 x12 = x2*x3;
141 x13 = _br_mulhuu(x2, x3);
142 x14 = x1*(x4*2);
143 x15 = _br_mulhuu(x1, (x4*2));
144 x16 = x1*x3;
145 x17 = _br_mulhuu(x1, x3);
146 x18 = x0*x5;
147 x19 = _br_mulhuu(x0, x5);
148 x20 = x0*x4;
149 x21 = _br_mulhuu(x0, x4);
150 x22 = x0*x3;
151 x23 = _br_mulhuu(x0, x3);
152 x24 = x10+x8;
153 x25 = (br_word_t)(x24<x10);
154 x26 = x25+x11;
155 x27 = x26+x9;
156 x28 = x22+x24;
157 x29 = (br_word_t)(x28<x22);
158 x30 = x29+x23;
159 x31 = x30+x27;
160 x32 = (x28>>((br_word_t)44&(sizeof(br_word_t)*8-1)))|(x31<<20);
161 x33 = x28&0xfffffffffff;
162 x34 = x14+x12;
163 x35 = (br_word_t)(x34<x14);
164 x36 = x35+x15;
165 x37 = x36+x13;
166 x38 = x18+x34;
167 x39 = (br_word_t)(x38<x18);
168 x40 = x39+x19;
169 x41 = x40+x37;
170 x42 = x16+x6;
171 x43 = (br_word_t)(x42<x16);
172 x44 = x43+x17;
173 x45 = x44+x7;
174 x46 = x20+x42;
175 x47 = (br_word_t)(x46<x20);
176 x48 = x47+x21;
177 x49 = x48+x45;
178 x50 = x32+x46;
179 x51 = (br_word_t)(x50<x32);
180 x52 = x51+x49;
181 x53 = (x50>>((br_word_t)43&(sizeof(br_word_t)*8-1)))|(x52<<21);
182 x54 = x50&0x7ffffffffff;
183 x55 = x53+x38;
184 x56 = (br_word_t)(x55<x53);
185 x57 = x56+x41;
186 x58 = (x55>>((br_word_t)43&(sizeof(br_word_t)*8-1)))|(x57<<21);
187 x59 = x55&0x7ffffffffff;
188 x60 = x58*5;
189 x61 = x33+x60;
190 x62 = x61>>((br_word_t)44&(sizeof(br_word_t)*8-1));
191 x63 = x61&0xfffffffffff;
192 x64 = x62+x54;
193 x65 = x64>>((br_word_t)43&(sizeof(br_word_t)*8-1));
194 x66 = x64&0x7ffffffffff;
195 x67 = x65+x59;
196 x68 = x63;
197 x69 = x66;
198 x70 = x67;
199 /*skip*/
200 _br_store(out0+0, x68);
201 _br_store(out0+8, x69);
202 _br_store(out0+16, x70);
203 /*skip*/
204 }
205
206 /* NOTE: The following wrapper function is not covered by Coq proofs */
207 static void fiat_poly1305_carry_mul(uint64_t out1[3], const uint64_t arg1[3], const uint64_t arg2[3]) {
208 internal_fiat_poly1305_carry_mul((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2);
209 }
210
211
212 /*
213 * Input Bounds:
214 * in0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
215 * Output Bounds:
216 * out0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
217 */
218 static
219 void internal_fiat_poly1305_carry_square(br_word_t out0, br_word_t in0) {
220 br_word_t x2, x3, x4, x1, x5, x6, x0, x9, x17, x20, x18, x21, x10, x22, x19, x11, x13, x26, x14, x27, x12, x7, x15, x30, x16, x31, x8, x29, x23, x34, x32, x35, x33, x25, x36, x39, x28, x40, x38, x41, x24, x43, x44, x45, x37, x47, x48, x42, x46, x49, x50, x51, x52, x53;
221 x0 = _br_load(in0+0);
222 x1 = _br_load(in0+8);
223 x2 = _br_load(in0+16);
224 /*skip*/
225 /*skip*/
226 x3 = x2*5;
227 x4 = x3*2;
228 x5 = x2*2;
229 x6 = x1*2;
230 x7 = x2*x3;
231 x8 = _br_mulhuu(x2, x3);
232 x9 = x1*(x4*2);
233 x10 = _br_mulhuu(x1, (x4*2));
234 x11 = x1*(x1*2);
235 x12 = _br_mulhuu(x1, (x1*2));
236 x13 = x0*x5;
237 x14 = _br_mulhuu(x0, x5);
238 x15 = x0*x6;
239 x16 = _br_mulhuu(x0, x6);
240 x17 = x0*x0;
241 x18 = _br_mulhuu(x0, x0);
242 x19 = x17+x9;
243 x20 = (br_word_t)(x19<x17);
244 x21 = x20+x18;
245 x22 = x21+x10;
246 x23 = (x19>>((br_word_t)44&(sizeof(br_word_t)*8-1)))|(x22<<20);
247 x24 = x19&0xfffffffffff;
248 x25 = x13+x11;
249 x26 = (br_word_t)(x25<x13);
250 x27 = x26+x14;
251 x28 = x27+x12;
252 x29 = x15+x7;
253 x30 = (br_word_t)(x29<x15);
254 x31 = x30+x16;
255 x32 = x31+x8;
256 x33 = x23+x29;
257 x34 = (br_word_t)(x33<x23);
258 x35 = x34+x32;
259 x36 = (x33>>((br_word_t)43&(sizeof(br_word_t)*8-1)))|(x35<<21);
260 x37 = x33&0x7ffffffffff;
261 x38 = x36+x25;
262 x39 = (br_word_t)(x38<x36);
263 x40 = x39+x28;
264 x41 = (x38>>((br_word_t)43&(sizeof(br_word_t)*8-1)))|(x40<<21);
265 x42 = x38&0x7ffffffffff;
266 x43 = x41*5;
267 x44 = x24+x43;
268 x45 = x44>>((br_word_t)44&(sizeof(br_word_t)*8-1));
269 x46 = x44&0xfffffffffff;
270 x47 = x45+x37;
271 x48 = x47>>((br_word_t)43&(sizeof(br_word_t)*8-1));
272 x49 = x47&0x7ffffffffff;
273 x50 = x48+x42;
274 x51 = x46;
275 x52 = x49;
276 x53 = x50;
277 /*skip*/
278 _br_store(out0+0, x51);
279 _br_store(out0+8, x52);
280 _br_store(out0+16, x53);
281 /*skip*/
282 }
283
284 /* NOTE: The following wrapper function is not covered by Coq proofs */
285 static void fiat_poly1305_carry_square(uint64_t out1[3], const uint64_t arg1[3]) {
286 internal_fiat_poly1305_carry_square((uintptr_t)out1, (uintptr_t)arg1);
287 }
288
289
290 /*
291 * Input Bounds:
292 * in0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
293 * Output Bounds:
294 * out0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
295 */
296 static
297 void internal_fiat_poly1305_carry(br_word_t out0, br_word_t in0) {
298 br_word_t x0, x1, x2, x3, x4, x6, x7, x5, x8, x9, x10, x11, x12, x13;
299 x0 = _br_load(in0+0);
300 x1 = _br_load(in0+8);
301 x2 = _br_load(in0+16);
302 /*skip*/
303 /*skip*/
304 x3 = x0;
305 x4 = (x3>>((br_word_t)44&(sizeof(br_word_t)*8-1)))+x1;
306 x5 = (x4>>((br_word_t)43&(sizeof(br_word_t)*8-1)))+x2;
307 x6 = (x3&0xfffffffffff)+((x5>>((br_word_t)43&(sizeof(br_word_t)*8-1)))*5);
308 x7 = (x6>>((br_word_t)44&(sizeof(br_word_t)*8-1)))+(x4&0x7ffffffffff);
309 x8 = x6&0xfffffffffff;
310 x9 = x7&0x7ffffffffff;
311 x10 = (x7>>((br_word_t)43&(sizeof(br_word_t)*8-1)))+(x5&0x7ffffffffff);
312 x11 = x8;
313 x12 = x9;
314 x13 = x10;
315 /*skip*/
316 _br_store(out0+0, x11);
317 _br_store(out0+8, x12);
318 _br_store(out0+16, x13);
319 /*skip*/
320 }
321
322 /* NOTE: The following wrapper function is not covered by Coq proofs */
323 static void fiat_poly1305_carry(uint64_t out1[3], const uint64_t arg1[3]) {
324 internal_fiat_poly1305_carry((uintptr_t)out1, (uintptr_t)arg1);
325 }
326
327
328 /*
329 * Input Bounds:
330 * in0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
331 * in1: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
332 * Output Bounds:
333 * out0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
334 */
335 static
336 void internal_fiat_poly1305_add(br_word_t out0, br_word_t in0, br_word_t in1) {
337 br_word_t x0, x3, x1, x4, x2, x5, x6, x7, x8, x9, x10, x11;
338 x0 = _br_load(in0+0);
339 x1 = _br_load(in0+8);
340 x2 = _br_load(in0+16);
341 /*skip*/
342 x3 = _br_load(in1+0);
343 x4 = _br_load(in1+8);
344 x5 = _br_load(in1+16);
345 /*skip*/
346 /*skip*/
347 x6 = x0+x3;
348 x7 = x1+x4;
349 x8 = x2+x5;
350 x9 = x6;
351 x10 = x7;
352 x11 = x8;
353 /*skip*/
354 _br_store(out0+0, x9);
355 _br_store(out0+8, x10);
356 _br_store(out0+16, x11);
357 /*skip*/
358 }
359
360 /* NOTE: The following wrapper function is not covered by Coq proofs */
361 static void fiat_poly1305_add(uint64_t out1[3], const uint64_t arg1[3], const uint64_t arg2[3]) {
362 internal_fiat_poly1305_add((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2);
363 }
364
365
366 /*
367 * Input Bounds:
368 * in0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
369 * in1: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
370 * Output Bounds:
371 * out0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
372 */
373 static
374 void internal_fiat_poly1305_sub(br_word_t out0, br_word_t in0, br_word_t in1) {
375 br_word_t x0, x3, x1, x4, x2, x5, x6, x7, x8, x9, x10, x11;
376 x0 = _br_load(in0+0);
377 x1 = _br_load(in0+8);
378 x2 = _br_load(in0+16);
379 /*skip*/
380 x3 = _br_load(in1+0);
381 x4 = _br_load(in1+8);
382 x5 = _br_load(in1+16);
383 /*skip*/
384 /*skip*/
385 x6 = ((br_word_t)0x1ffffffffff6+x0)-x3;
386 x7 = ((br_word_t)0xffffffffffe +x1)-x4;
387 x8 = ((br_word_t)0xffffffffffe +x2)-x5;
388 x9 = x6;
389 x10 = x7;
390 x11 = x8;
391 /*skip*/
392 _br_store(out0+0, x9);
393 _br_store(out0+8, x10);
394 _br_store(out0+16, x11);
395 /*skip*/
396 }
397
398 /* NOTE: The following wrapper function is not covered by Coq proofs */
399 static void fiat_poly1305_sub(uint64_t out1[3], const uint64_t arg1[3], const uint64_t arg2[3]) {
400 internal_fiat_poly1305_sub((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2);
401 }
402
403
404 /*
405 * Input Bounds:
406 * in0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
407 * Output Bounds:
408 * out0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
409 */
410 static
411 void internal_fiat_poly1305_opp(br_word_t out0, br_word_t in0) {
412 br_word_t x0, x1, x2, x3, x4, x5, x6, x7, x8;
413 x0 = _br_load(in0+0);
414 x1 = _br_load(in0+8);
415 x2 = _br_load(in0+16);
416 /*skip*/
417 /*skip*/
418 x3 = (br_word_t)0x1ffffffffff6-x0;
419 x4 = (br_word_t)0xffffffffffe -x1;
420 x5 = (br_word_t)0xffffffffffe -x2;
421 x6 = x3;
422 x7 = x4;
423 x8 = x5;
424 /*skip*/
425 _br_store(out0+0, x6);
426 _br_store(out0+8, x7);
427 _br_store(out0+16, x8);
428 /*skip*/
429 }
430
431 /* NOTE: The following wrapper function is not covered by Coq proofs */
432 static void fiat_poly1305_opp(uint64_t out1[3], const uint64_t arg1[3]) {
433 internal_fiat_poly1305_opp((uintptr_t)out1, (uintptr_t)arg1);
434 }
435
436
437 /*
438 * Input Bounds:
439 * in0: [0x0 ~> 0x1]
440 * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
441 * in2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
442 * Output Bounds:
443 * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
444 */
445 static
446 void internal_fiat_poly1305_selectznz(br_word_t out0, br_word_t in0, br_word_t in1, br_word_t in2) {
447 br_word_t x3, x6, x0, x7, x4, x9, x1, x10, x5, x12, x2, x13, x8, x11, x14, x15, x16, x17;
448 /*skip*/
449 x0 = _br_load(in1+0);
450 x1 = _br_load(in1+8);
451 x2 = _br_load(in1+16);
452 /*skip*/
453 x3 = _br_load(in2+0);
454 x4 = _br_load(in2+8);
455 x5 = _br_load(in2+16);
456 /*skip*/
457 /*skip*/
458 x6 = (0u-(br_word_t)1)+((br_word_t)(in0==(br_word_t)0));
459 x7 = x6^0xffffffffffffffff;
460 x8 = (x3&x6)|(x0&x7);
461 x9 = (0u-(br_word_t)1)+((br_word_t)(in0==(br_word_t)0));
462 x10 = x9^0xffffffffffffffff;
463 x11 = (x4&x9)|(x1&x10);
464 x12 = (0u-(br_word_t)1)+((br_word_t)(in0==(br_word_t)0));
465 x13 = x12^0xffffffffffffffff;
466 x14 = (x5&x12)|(x2&x13);
467 x15 = x8;
468 x16 = x11;
469 x17 = x14;
470 /*skip*/
471 _br_store(out0+0, x15);
472 _br_store(out0+8, x16);
473 _br_store(out0+16, x17);
474 /*skip*/
475 }
476
477 /* NOTE: The following wrapper function is not covered by Coq proofs */
478 static void fiat_poly1305_selectznz(uint64_t out1[3], uint8_t arg1, const uint64_t arg2[3], const uint64_t arg3[3]) {
479 internal_fiat_poly1305_selectznz((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2, (uintptr_t)arg3);
480 }
481
482
483 /*
484 * Input Bounds:
485 * in0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
486 * Output Bounds:
487 * out0: [[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 ~> 0x3]]
488 */
489 static
490 void internal_fiat_poly1305_to_bytes(br_word_t out0, br_word_t in0) {
491 br_word_t x0, x4, x3, x1, x6, x7, x8, x10, x11, x9, x2, x13, x14, x15, x17, x18, x16, x20, x5, x22, x23, x25, x12, x26, x27, x29, x28, x30, x32, x19, x33, x21, x34, x35, x31, x24, x39, x41, x43, x45, x37, x47, x48, x50, x52, x54, x56, x36, x58, x59, x61, x63, x65, x67, x69, x38, x40, x42, x44, x46, x49, x51, x53, x55, x57, x60, x62, x64, x66, x68, x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x80, x81, x82, x83, x84, x85, x86, x87, x88;
492 x0 = _br_load(in0+0);
493 x1 = _br_load(in0+8);
494 x2 = _br_load(in0+16);
495 /*skip*/
496 /*skip*/
497 x3 = x0-0xffffffffffb;
498 x4 = (br_word_t)(x0<x3);
499 x5 = x3&0xfffffffffff;
500 x6 = (x4<<20)-(x3>>((br_word_t)44&(sizeof(br_word_t)*8-1)));
501 x7 = x1-0x7ffffffffff;
502 x8 = (br_word_t)(x1<x7);
503 x9 = x7-x6;
504 x10 = (br_word_t)(x7<x9);
505 x11 = x8+x10;
506 x12 = x9&0x7ffffffffff;
507 x13 = (x11<<21)-(x9>>((br_word_t)43&(sizeof(br_word_t)*8-1)));
508 x14 = x2-0x7ffffffffff;
509 x15 = (br_word_t)(x2<x14);
510 x16 = x14-x13;
511 x17 = (br_word_t)(x14<x16);
512 x18 = x15+x17;
513 x19 = x16&0x7ffffffffff;
514 x20 = (x18<<21)-(x16>>((br_word_t)43&(sizeof(br_word_t)*8-1)));
515 x21 = (0u-(br_word_t)1)+((br_word_t)(x20==(br_word_t)0));
516 x22 = x5+(x21&0xffffffffffb);
517 x23 = (br_word_t)(x22<x5);
518 x24 = x22&0xfffffffffff;
519 x25 = (x22>>((br_word_t)44&(sizeof(br_word_t)*8-1)))+(x23<<20);
520 x26 = x25+x12;
521 x27 = (br_word_t)(x26<x12);
522 x28 = x26+(x21&0x7ffffffffff);
523 x29 = (br_word_t)(x28<(x21&0x7ffffffffff));
524 x30 = x27+x29;
525 x31 = x28&0x7ffffffffff;
526 x32 = (x28>>((br_word_t)43&(sizeof(br_word_t)*8-1)))+(x30<<21);
527 x33 = x32+x19;
528 x34 = x33+(x21&0x7ffffffffff);
529 x35 = x34&0x7ffffffffff;
530 x36 = x35<<7;
531 x37 = x31<<4;
532 x38 = x24&0xff;
533 x39 = x24>>8;
534 x40 = x39&0xff;
535 x41 = x39>>8;
536 x42 = x41&0xff;
537 x43 = x41>>8;
538 x44 = x43&0xff;
539 x45 = x43>>8;
540 x46 = x45&0xff;
541 x47 = x45>>8;
542 x48 = x37+x47;
543 x49 = x48&0xff;
544 x50 = x48>>8;
545 x51 = x50&0xff;
546 x52 = x50>>8;
547 x53 = x52&0xff;
548 x54 = x52>>8;
549 x55 = x54&0xff;
550 x56 = x54>>8;
551 x57 = x56&0xff;
552 x58 = x56>>8;
553 x59 = x36+x58;
554 x60 = x59&0xff;
555 x61 = x59>>8;
556 x62 = x61&0xff;
557 x63 = x61>>8;
558 x64 = x63&0xff;
559 x65 = x63>>8;
560 x66 = x65&0xff;
561 x67 = x65>>8;
562 x68 = x67&0xff;
563 x69 = x67>>8;
564 x70 = x69&0xff;
565 x71 = x69>>8;
566 x72 = x38;
567 x73 = x40;
568 x74 = x42;
569 x75 = x44;
570 x76 = x46;
571 x77 = x49;
572 x78 = x51;
573 x79 = x53;
574 x80 = x55;
575 x81 = x57;
576 x82 = x60;
577 x83 = x62;
578 x84 = x64;
579 x85 = x66;
580 x86 = x68;
581 x87 = x70;
582 x88 = x71;
583 /*skip*/
584 _br_store1(out0+0, x72);
585 _br_store1(out0+1, x73);
586 _br_store1(out0+2, x74);
587 _br_store1(out0+3, x75);
588 _br_store1(out0+4, x76);
589 _br_store1(out0+5, x77);
590 _br_store1(out0+6, x78);
591 _br_store1(out0+7, x79);
592 _br_store1(out0+8, x80);
593 _br_store1(out0+9, x81);
594 _br_store1(out0+10, x82);
595 _br_store1(out0+11, x83);
596 _br_store1(out0+12, x84);
597 _br_store1(out0+13, x85);
598 _br_store1(out0+14, x86);
599 _br_store1(out0+15, x87);
600 _br_store1(out0+16, x88);
601 /*skip*/
602 }
603
604 /* NOTE: The following wrapper function is not covered by Coq proofs */
605 static void fiat_poly1305_to_bytes(uint8_t out1[17], const uint64_t arg1[3]) {
606 internal_fiat_poly1305_to_bytes((uintptr_t)out1, (uintptr_t)arg1);
607 }
608
609
610 /*
611 * Input Bounds:
612 * in0: [[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 ~> 0x3]]
613 * Output Bounds:
614 * out0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
615 */
616 static
617 void internal_fiat_poly1305_from_bytes(br_word_t out0, br_word_t in0) {
618 br_word_t x16, x15, x14, x13, x12, x11, x10, x9, x8, x7, x6, x5, x4, x3, x2, x1, x0, x32, x33, x31, x34, x30, x35, x29, x36, x28, x37, x38, x27, x40, x26, x41, x25, x42, x24, x43, x23, x44, x45, x22, x47, x21, x48, x20, x49, x19, x50, x18, x51, x17, x52, x39, x46, x53, x54, x55, x56;
619 x0 = _br_load1(in0+0);
620 x1 = _br_load1(in0+1);
621 x2 = _br_load1(in0+2);
622 x3 = _br_load1(in0+3);
623 x4 = _br_load1(in0+4);
624 x5 = _br_load1(in0+5);
625 x6 = _br_load1(in0+6);
626 x7 = _br_load1(in0+7);
627 x8 = _br_load1(in0+8);
628 x9 = _br_load1(in0+9);
629 x10 = _br_load1(in0+10);
630 x11 = _br_load1(in0+11);
631 x12 = _br_load1(in0+12);
632 x13 = _br_load1(in0+13);
633 x14 = _br_load1(in0+14);
634 x15 = _br_load1(in0+15);
635 x16 = _br_load1(in0+16);
636 /*skip*/
637 /*skip*/
638 x17 = x16<<((br_word_t)41&(sizeof(br_word_t)*8-1));
639 x18 = x15<<((br_word_t)33&(sizeof(br_word_t)*8-1));
640 x19 = x14<<25;
641 x20 = x13<<17;
642 x21 = x12<<9;
643 x22 = x11*2;
644 x23 = x10<<((br_word_t)36&(sizeof(br_word_t)*8-1));
645 x24 = x9<<28;
646 x25 = x8<<20;
647 x26 = x7<<12;
648 x27 = x6<<4;
649 x28 = x5<<((br_word_t)40&(sizeof(br_word_t)*8-1));
650 x29 = x4<<((br_word_t)32&(sizeof(br_word_t)*8-1));
651 x30 = x3<<24;
652 x31 = x2<<16;
653 x32 = x1<<8;
654 x33 = x0;
655 x34 = x32+x33;
656 x35 = x31+x34;
657 x36 = x30+x35;
658 x37 = x29+x36;
659 x38 = x28+x37;
660 x39 = x38&0xfffffffffff;
661 x40 = x38>>((br_word_t)44&(sizeof(br_word_t)*8-1));
662 x41 = x27+x40;
663 x42 = x26+x41;
664 x43 = x25+x42;
665 x44 = x24+x43;
666 x45 = x23+x44;
667 x46 = x45&0x7ffffffffff;
668 x47 = x45>>((br_word_t)43&(sizeof(br_word_t)*8-1));
669 x48 = x22+x47;
670 x49 = x21+x48;
671 x50 = x20+x49;
672 x51 = x19+x50;
673 x52 = x18+x51;
674 x53 = x17+x52;
675 x54 = x39;
676 x55 = x46;
677 x56 = x53;
678 /*skip*/
679 _br_store(out0+0, x54);
680 _br_store(out0+8, x55);
681 _br_store(out0+16, x56);
682 /*skip*/
683 }
684
685 /* NOTE: The following wrapper function is not covered by Coq proofs */
686 static void fiat_poly1305_from_bytes(uint64_t out1[3], const uint8_t arg1[17]) {
687 internal_fiat_poly1305_from_bytes((uintptr_t)out1, (uintptr_t)arg1);
688 }
689
690
691 /*
692 * Input Bounds:
693 * in0: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
694 * Output Bounds:
695 * out0: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
696 */
697 static
698 void internal_fiat_poly1305_relax(br_word_t out0, br_word_t in0) {
699 br_word_t x0, x1, x2, x3, x4, x5, x6, x7, x8;
700 x0 = _br_load(in0+0);
701 x1 = _br_load(in0+8);
702 x2 = _br_load(in0+16);
703 /*skip*/
704 /*skip*/
705 x3 = x0;
706 x4 = x1;
707 x5 = x2;
708 x6 = x3;
709 x7 = x4;
710 x8 = x5;
711 /*skip*/
712 _br_store(out0+0, x6);
713 _br_store(out0+8, x7);
714 _br_store(out0+16, x8);
715 /*skip*/
716 }
717
718 /* NOTE: The following wrapper function is not covered by Coq proofs */
719 static void fiat_poly1305_relax(uint64_t out1[3], const uint64_t arg1[3]) {
720 internal_fiat_poly1305_relax((uintptr_t)out1, (uintptr_t)arg1);
721 }