My Project
count_last_flip_carry_32.c
Go to the documentation of this file.
1
34#define LODWORD(l) ((unsigned int)(l))
35#define HIDWORD(l) ((unsigned int)((l)>>32))
36
38static const char COUNT_FLIP_R[128] = {
39 0, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
40 8, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
41 10, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
42 8, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
43 12, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
44 8, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
45 10, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0,
46 8, 0, 2, 0, 4, 0, 2, 0, 6, 0, 2, 0, 4, 0, 2, 0
47};
48
49static const char COUNT_FLIP_2[256] = {
50 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 2, 4, 2, 2, 2, 4, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0,
51 4, 6, 4, 4, 4, 6, 4, 4, 0, 2, 0, 0, 0, 2, 0, 0, 2, 4, 2, 2, 2, 4, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0,
52 6, 8, 6, 6, 6, 8, 6, 6, 0, 2, 0, 0, 0, 2, 0, 0, 2, 4, 2, 2, 2, 4, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0,
53 4, 6, 4, 4, 4, 6, 4, 4, 0, 2, 0, 0, 0, 2, 0, 0, 2, 4, 2, 2, 2, 4, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0,
54 8, 10, 8, 8, 8, 10, 8, 8, 0, 2, 0, 0, 0, 2, 0, 0, 2, 4, 2, 2, 2, 4, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0,
55 4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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
98};
99
106static int count_last_flip_A1(const unsigned long long P)
107{
108 int n_flipped;
109
110 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x01010100u) + ((HIDWORD(P) & 0x01010101u) << 4)) * 0x01020408u) >> 25];
111 n_flipped += COUNT_FLIP_R[(LODWORD(P) >> 1) & 0x7f];
112 n_flipped += COUNT_FLIP_R[(((LODWORD(P) & 0x08040200u) + (HIDWORD(P) & 0x80402010u)) * 0x01010101u) >> 25];
113
114 return n_flipped;
115}
116
123static int count_last_flip_B1(const unsigned long long P)
124{
125 int n_flipped;
126
127 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x02020200u) + ((HIDWORD(P) & 0x02020202u) << 4)) * 0x00810204u) >> 25];
128 n_flipped += COUNT_FLIP_R[(LODWORD(P) >> 2) & 0x3f];
129 n_flipped += COUNT_FLIP_R[(((LODWORD(P) & 0x10080400u) + (HIDWORD(P) & 0x00804020u)) * 0x01010101u) >> 26];
130
131 return n_flipped;
132}
133
140static int count_last_flip_C1(const unsigned long long P)
141{
142 int n_flipped;
143
144 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x04040400u) + ((HIDWORD(P) & 0x04040404u) << 4)) * 0x00408102u) >> 25];
145 n_flipped += COUNT_FLIP_2[LODWORD(P) & 0xff];
146 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x20110A04u) + (HIDWORD(P) & 0x00008040u)) * 0x01010101u) >> 24];
147
148 return n_flipped;
149}
150
157static int count_last_flip_D1(const unsigned long long P)
158{
159 int n_flipped;
160
161 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x08080800u) + ((HIDWORD(P) & 0x08080808u) << 4)) * 0x00204081u) >> 25];
162 n_flipped += COUNT_FLIP_3[LODWORD(P) & 0xff];
163 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x41221408u) + (HIDWORD(P) & 0x00000080u)) * 0x01010101u) >> 24];
164
165 return n_flipped;
166}
167
174static int count_last_flip_E1(const unsigned long long P)
175{
176 int n_flipped;
177
178 n_flipped = COUNT_FLIP_R[((((LODWORD(P) & 0x10101000u) >> 4) + (HIDWORD(P) & 0x10101010u)) * 0x01020408u) >> 25];
179 n_flipped += COUNT_FLIP_4[LODWORD(P) & 0xff];
180 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x82442810u) + (HIDWORD(P) & 0x00000001u)) * 0x01010101u) >> 24];
181
182 return n_flipped;
183}
184
191static int count_last_flip_F1(const unsigned long long P)
192{
193 int n_flipped;
194
195 n_flipped = COUNT_FLIP_R[(((HIDWORD(P) & 0x20202020u) + ((LODWORD(P) >> 4) & 0x02020200u)) * 0x00810204u) >> 25];
196 n_flipped += COUNT_FLIP_5[LODWORD(P) & 0xff];
197 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x04885020u) + (HIDWORD(P) & 0x00000102u)) * 0x01010101u) >> 24];
198
199 return n_flipped;
200}
201
208static int count_last_flip_G1(const unsigned long long P)
209{
210 int n_flipped;
211
212 n_flipped = COUNT_FLIP_R[((((LODWORD(P) & 0x40404000u) >> 4) + (HIDWORD(P) & 0x40404040u)) * 0x00408102u) >> 25];
213 n_flipped += COUNT_FLIP_L[(LODWORD(P) << 1) & 0x7e];
214 n_flipped += COUNT_FLIP_L[(((LODWORD(P) & 0x08102000u) + (HIDWORD(P) & 0x00010204u)) * 0x02020202u) >> 24];
215
216 return n_flipped;
217}
218
225static int count_last_flip_H1(const unsigned long long P)
226{
227 int n_flipped;
228
229 n_flipped = COUNT_FLIP_R[((((LODWORD(P) & 0x80808000u) >> 4) + (HIDWORD(P) & 0x80808080u)) * 0x00204081u) >> 25];
230 n_flipped += COUNT_FLIP_L[LODWORD(P) & 0x7f];
231 n_flipped += COUNT_FLIP_L[(((LODWORD(P) & 0x10204000u) + (HIDWORD(P) & 0x01020408u)) * 0x01010101u) >> 24];
232
233 return n_flipped;
234}
235
242static int count_last_flip_A2(const unsigned long long P)
243{
244 int n_flipped;
245
246 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x01010000u) + ((HIDWORD(P) & 0x01010101u) << 4)) * 0x01020408u) >> 26];
247 n_flipped += COUNT_FLIP_R[(LODWORD(P) >> 9) & 0x7f];
248 n_flipped += COUNT_FLIP_R[(((LODWORD(P) & 0x04020000u) + (HIDWORD(P) & 0x40201008u)) * 0x01010101u) >> 25];
249
250 return n_flipped;
251}
252
259static int count_last_flip_B2(const unsigned long long P)
260{
261 int n_flipped;
262
263 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x02020000u) + ((HIDWORD(P) & 0x02020202u) << 4)) * 0x00810204u) >> 26];
264 n_flipped += COUNT_FLIP_R[(LODWORD(P) >> 10) & 0x3f];
265 n_flipped += COUNT_FLIP_R[(((LODWORD(P) & 0x08040000u) + (HIDWORD(P) & 0x80402010u)) * 0x01010101u) >> 26];
266
267 return n_flipped;
268}
269
276static int count_last_flip_C2(const unsigned long long P)
277{
278 int n_flipped;
279
280 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x04040000u) + ((HIDWORD(P) & 0x04040404u) << 4)) * 0x00408102u) >> 26];
281 n_flipped += COUNT_FLIP_2[(LODWORD(P) >> 8) & 0xff];
282 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x110A0400u) + (HIDWORD(P) & 0x00804020u)) * 0x01010101u) >> 24];
283
284 return n_flipped;
285}
286
293static int count_last_flip_D2(const unsigned long long P)
294{
295 int n_flipped;
296
297 n_flipped = COUNT_FLIP_R[(((LODWORD(P) & 0x08080000u) + ((HIDWORD(P) & 0x08080808u) << 4)) * 0x00204081u) >> 26];
298 n_flipped += COUNT_FLIP_3[(LODWORD(P) >> 8) & 0xff];
299 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x22140800u) + (HIDWORD(P) & 0x00008041u)) * 0x01010101u) >> 24];
300
301 return n_flipped;
302}
303
310static int count_last_flip_E2(const unsigned long long P)
311{
312 int n_flipped;
313
314 n_flipped = COUNT_FLIP_R[((((LODWORD(P) & 0x10100000u) >> 4) + (HIDWORD(P) & 0x10101010u)) * 0x01020408u) >> 26];
315 n_flipped += COUNT_FLIP_4[(LODWORD(P) >> 8) & 0xff];
316 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x44281000u) + (HIDWORD(P) & 0x00000182u)) * 0x01010101u) >> 24];
317
318 return n_flipped;
319}
320
327static int count_last_flip_F2(const unsigned long long P)
328{
329 int n_flipped;
330
331 n_flipped = COUNT_FLIP_R[(((HIDWORD(P) & 0x20202020u) + ((LODWORD(P) & 0x20200000u) >> 4)) * 0x00810204u) >> 26];
332 n_flipped += COUNT_FLIP_5[(LODWORD(P) >> 8) & 0xff];
333 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x88502000u) + (HIDWORD(P) & 0x00010204u)) * 0x01010101u) >> 24];
334
335 return n_flipped;
336}
337
344static int count_last_flip_G2(const unsigned long long P)
345{
346 int n_flipped;
347
348 n_flipped = COUNT_FLIP_R[((((LODWORD(P) & 0x40400000u) >> 4) + (HIDWORD(P) & 0x40404040u)) * 0x00408102u) >> 26];
349 n_flipped += COUNT_FLIP_L[(LODWORD(P) >> 7) & 0x7e];
350 n_flipped += COUNT_FLIP_L[(((LODWORD(P) & 0x10200000u) + (HIDWORD(P) & 0x01020408u)) * 0x02020202u) >> 24];
351
352 return n_flipped;
353}
354
361static int count_last_flip_H2(const unsigned long long P)
362{
363 int n_flipped;
364
365 n_flipped = COUNT_FLIP_R[((((LODWORD(P) & 0x80800000u) >> 4) + (HIDWORD(P) & 0x80808080u)) * 0x00204081u) >> 26];
366 n_flipped += COUNT_FLIP_L[(LODWORD(P) >> 8) & 0x7f];
367 n_flipped += COUNT_FLIP_L[(((LODWORD(P) & 0x20400000u) + (HIDWORD(P) & 0x02040810u)) * 0x01010101u) >> 24];
368
369 return n_flipped;
370}
371
378static int count_last_flip_A3(const unsigned long long P)
379{
380 int n_flipped;
381
382 n_flipped = COUNT_FLIP_2[((LODWORD(P) & 0x02010101u) * 0x01020404u + (HIDWORD(P) & 0x20100804u) * 0x04040404u) >> 24]; // A1A3F8
383 n_flipped += COUNT_FLIP_R[(LODWORD(P) >> 17) & 0x7f];
384 n_flipped += COUNT_FLIP_5[((LODWORD(P) & 0x01010204u) * 0x20202010u + (HIDWORD(P) & 0x01010101u) * 0x08040201u) >> 24]; // C1A3A8
385
386 return n_flipped;
387}
388
395static int count_last_flip_B3(const unsigned long long P)
396{
397 int n_flipped;
398
399 n_flipped = COUNT_FLIP_2[((LODWORD(P) & 0x04020202u) * 0x00810202u + (HIDWORD(P) & 0x40201008u) * 0x02020202u) >> 24]; // B1B3G8
400 n_flipped += COUNT_FLIP_R[(LODWORD(P) >> 18) & 0x3f];
401 n_flipped += COUNT_FLIP_5[((LODWORD(P) & 0x02020408u) * 0x10101008u + ((HIDWORD(P) & 0x02020202u) >> 1) * 0x08040201u) >> 24]; // D1B3B8
402
403 return n_flipped;
404}
405
412static int count_last_flip_C3(const unsigned long long P)
413{
414 int n_flipped;
415
416 n_flipped = COUNT_FLIP_2[(((LODWORD(P) & 0x04040404u) + ((HIDWORD(P) & 0x04040404u) << 4)) * 0x00408102u) >> 24];
417 n_flipped += COUNT_FLIP_2[(LODWORD(P) >> 16) & 0xff];
418 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x02040810u) + (HIDWORD(P) & 0x00000001u)) * 0x01010101u) >> 24];
419 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x08040201u) + (HIDWORD(P) & 0x80402010u)) * 0x01010101u) >> 24];
420
421 return n_flipped;
422}
423
430static int count_last_flip_D3(const unsigned long long P)
431{
432 int n_flipped;
433
434 n_flipped = COUNT_FLIP_2[(((LODWORD(P) & 0x08080808u) + ((HIDWORD(P) & 0x08080808u) << 4)) * 0x00204081u) >> 24];
435 n_flipped += COUNT_FLIP_3[(LODWORD(P) >> 16) & 0xff];
436 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x04081020u) + (HIDWORD(P) & 0x00000102u)) * 0x01010101u) >> 24];
437 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x10080402u) + (HIDWORD(P) & 0x00804020u)) * 0x01010101u) >> 24];
438
439 return n_flipped;
440}
441
448static int count_last_flip_E3(const unsigned long long P)
449{
450 int n_flipped;
451
452 n_flipped = COUNT_FLIP_2[((((LODWORD(P) & 0x10101010u) >> 4) + (HIDWORD(P) & 0x10101010u)) * 0x01020408u) >> 24];
453 n_flipped += COUNT_FLIP_4[(LODWORD(P) >> 16) & 0xff];
454 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x08102040u) + (HIDWORD(P) & 0x00010204u)) * 0x01010101u) >> 24];
455 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x20100804u) + (HIDWORD(P) & 0x00008040u)) * 0x01010101u) >> 24];
456
457 return n_flipped;
458}
459
466static int count_last_flip_F3(const unsigned long long P)
467{
468 int n_flipped;
469
470 n_flipped = COUNT_FLIP_2[(((HIDWORD(P) & 0x20202020u) + ((LODWORD(P) & 0x20202020u) >> 4)) * 0x00810204u) >> 24];
471 n_flipped += COUNT_FLIP_5[(LODWORD(P) >> 16) & 0xff];
472 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x10204080u) + (HIDWORD(P) & 0x01020408u)) * 0x01010101u) >> 24];
473 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x40201008u) + (HIDWORD(P) & 0x00000080u)) * 0x01010101u) >> 24];
474
475 return n_flipped;
476}
477
484static int count_last_flip_G3(const unsigned long long P)
485{
486 int n_flipped;
487
488 n_flipped = COUNT_FLIP_2[(((LODWORD(P) & 0x40402010u) >> 4) * 0x01010102u + (HIDWORD(P) & 0x40404040u) * 0x00408102u) >> 24]; // E1G3G8
489 n_flipped += COUNT_FLIP_L[(LODWORD(P) >> 15) & 0x7e];
490 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x20404040u) >> 1) * 0x04020101u + ((HIDWORD(P) & 0x02040810u) >> 1) * 0x01010101u) >> 24]; // G1G3B8
491
492 return n_flipped;
493}
494
501static int count_last_flip_H3(const unsigned long long P)
502{
503 int n_flipped;
504
505 n_flipped = COUNT_FLIP_2[(((LODWORD(P) & 0x80804020u) >> 4) * 0x00808081u + (HIDWORD(P) & 0x80808080u) * 0x00204081u) >> 24]; // F1H3H8
506 n_flipped += COUNT_FLIP_L[(LODWORD(P) >> 16) & 0x7f];
507 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x40808080u) >> 2) * 0x04020101u + ((HIDWORD(P) & 0x04081020u) >> 2) * 0x01010101u) >> 24]; // H1H3C8
508
509 return n_flipped;
510}
511
518static int count_last_flip_A4(const unsigned long long P)
519{
520 int n_flipped;
521
522 n_flipped = COUNT_FLIP_3[((LODWORD(P) & 0x01010101u) * 0x01020408u + (HIDWORD(P) & 0x10080402u) * 0x08080808u) >> 24]; // A1A4E8
523 n_flipped += COUNT_FLIP_R[LODWORD(P) >> 25];
524 n_flipped += COUNT_FLIP_4[((LODWORD(P) & 0x01020408u) * 0x10101010u + (HIDWORD(P) & 0x01010101u) * 0x08040201u) >> 24]; // D1A4A8
525
526 return n_flipped;
527}
528
535static int count_last_flip_B4(const unsigned long long P)
536{
537 int n_flipped;
538
539 n_flipped = COUNT_FLIP_3[((LODWORD(P) & 0x02020202u) * 0x00810204u + (HIDWORD(P) & 0x20100804u) * 0x04040404u) >> 24]; // B1B4F8
540 n_flipped += COUNT_FLIP_R[LODWORD(P) >> 26];
541 n_flipped += COUNT_FLIP_4[((LODWORD(P) & 0x02040810u) * 0x08080808u + ((HIDWORD(P) & 0x02020202u) >> 1) * 0x08040201u) >> 24]; // E1B4B8
542
543 return n_flipped;
544}
545
552static int count_last_flip_C4(const unsigned long long P)
553{
554 int n_flipped;
555
556 n_flipped = COUNT_FLIP_3[(((LODWORD(P) & 0x04040404u) + ((HIDWORD(P) & 0x04040404u) << 4)) * 0x00408102u) >> 24];
557 n_flipped += COUNT_FLIP_2[LODWORD(P) >> 24];
558 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x04081020u) + (HIDWORD(P) & 0x00000102u)) * 0x01010101u) >> 24];
559 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x04020100u) + (HIDWORD(P) & 0x40201008u)) * 0x01010101u) >> 24];
560
561 return n_flipped;
562}
563
570static int count_last_flip_D4(const unsigned long long P)
571{
572 int n_flipped;
573
574 n_flipped = COUNT_FLIP_3[(((LODWORD(P) & 0x08080808u) + ((HIDWORD(P) & 0x08080808u) << 4)) * 0x00204081u) >> 24];
575 n_flipped += COUNT_FLIP_3[LODWORD(P) >> 24];
576 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x08102040u) + (HIDWORD(P) & 0x00010204u)) * 0x01010101u) >> 24];
577 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x08040201u) + (HIDWORD(P) & 0x80402010u)) * 0x01010101u) >> 24];
578
579 return n_flipped;
580}
581
588static int count_last_flip_E4(const unsigned long long P)
589{
590 int n_flipped;
591
592 n_flipped = COUNT_FLIP_3[((((LODWORD(P) & 0x10101010u) >> 4) + (HIDWORD(P) & 0x10101010u)) * 0x01020408u) >> 24];
593 n_flipped += COUNT_FLIP_4[LODWORD(P) >> 24];
594 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x10204080u) + (HIDWORD(P) & 0x01020408u)) * 0x01010101u) >> 24];
595 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x10080402u) + (HIDWORD(P) & 0x00804020u)) * 0x01010101u) >> 24];
596
597 return n_flipped;
598}
599
606static int count_last_flip_F4(const unsigned long long P)
607{
608 int n_flipped;
609
610 n_flipped = COUNT_FLIP_3[(((HIDWORD(P) & 0x20202020u) + ((LODWORD(P) & 0x20202020u) >> 4)) * 0x00810204u) >> 24];
611 n_flipped += COUNT_FLIP_5[LODWORD(P) >> 24];
612 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x20408000u) + (HIDWORD(P) & 0x02040810u)) * 0x01010101u) >> 24];
613 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x20100804u) + (HIDWORD(P) & 0x00008040u)) * 0x01010101u) >> 24];
614
615 return n_flipped;
616}
617
624static int count_last_flip_G4(const unsigned long long P)
625{
626 int n_flipped;
627
628 n_flipped = COUNT_FLIP_3[(((LODWORD(P) & 0x40201008u) >> 3) * 0x01010101u + (HIDWORD(P) & 0x40404040u) * 0x00408102u) >> 24]; // D1G4G8
629 n_flipped += COUNT_FLIP_L[(LODWORD(P) >> 23) & 0x7e];
630 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x40404040u) >> 2) * 0x08040201u + ((HIDWORD(P) & 0x04081020u) >> 2) * 0x01010101u) >> 24]; // G1G4C8
631
632 return n_flipped;
633}
634
641static int count_last_flip_H4(const unsigned long long P)
642{
643 int n_flipped;
644
645 n_flipped = COUNT_FLIP_3[(((LODWORD(P) & 0x80402010u) >> 4) * 0x01010101u + (HIDWORD(P) & 0x80808080u) * 0x00204081u) >> 24]; // E1H4H8
646 n_flipped += COUNT_FLIP_L[(LODWORD(P) >> 24) & 0x7f];
647 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x80808080u) >> 3) * 0x08040201u + ((HIDWORD(P) & 0x08102040u) >> 3) * 0x01010101u) >> 24]; // H1H4D8
648
649 return n_flipped;
650}
651
658static int count_last_flip_A5(const unsigned long long P)
659{
660 int n_flipped;
661
662 n_flipped = COUNT_FLIP_4[((LODWORD(P) & 0x01010101u) * 0x01020408u + (HIDWORD(P) & 0x08040201u) * 0x10101010u) >> 24]; // A1A5D8
663 n_flipped += COUNT_FLIP_R[(HIDWORD(P) >> 1) & 0x7f];
664 n_flipped += COUNT_FLIP_3[((LODWORD(P) & 0x02040810u) * 0x08080808u + (HIDWORD(P) & 0x01010101u) * 0x08040201u) >> 24]; // E1A5A8
665
666 return n_flipped;
667}
668
675static int count_last_flip_B5(const unsigned long long P)
676{
677 int n_flipped;
678
679 n_flipped = COUNT_FLIP_4[((LODWORD(P) & 0x02020202u) * 0x00810204u + (HIDWORD(P) & 0x10080402u) * 0x08080808u) >> 24]; // B1B5E8
680 n_flipped += COUNT_FLIP_R[(HIDWORD(P) >> 2) & 0x3f];
681 n_flipped += COUNT_FLIP_3[((LODWORD(P) & 0x04081020u) * 0x04040404u + ((HIDWORD(P) & 0x02020202u) >> 1) * 0x08040201u) >> 24]; // F1B5B8
682
683 return n_flipped;
684}
685
692static int count_last_flip_C5(const unsigned long long P)
693{
694 int n_flipped;
695
696 n_flipped = COUNT_FLIP_4[(((LODWORD(P) & 0x04040404u) + ((HIDWORD(P) & 0x04040404u) << 4)) * 0x00408102u) >> 24];
697 n_flipped += COUNT_FLIP_2[HIDWORD(P) & 0xff];
698 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x08102040u) + (HIDWORD(P) & 0x00010204u)) * 0x01010101u) >> 24];
699 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x02010000u) + (HIDWORD(P) & 0x20100804u)) * 0x01010101u) >> 24];
700
701 return n_flipped;
702}
703
710static int count_last_flip_D5(const unsigned long long P)
711{
712 int n_flipped;
713
714 n_flipped = COUNT_FLIP_4[(((LODWORD(P) & 0x08080808u) + ((HIDWORD(P) & 0x08080808u) << 4)) * 0x00204081u) >> 24];
715 n_flipped += COUNT_FLIP_3[HIDWORD(P) & 0xff];
716 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x10204080u) + (HIDWORD(P) & 0x01020408u)) * 0x01010101u) >> 24];
717 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x04020100u) + (HIDWORD(P) & 0x40201008u)) * 0x01010101u) >> 24];
718
719 return n_flipped;
720}
721
728static int count_last_flip_E5(const unsigned long long P)
729{
730 int n_flipped;
731
732 n_flipped = COUNT_FLIP_4[((((LODWORD(P) & 0x10101010u) >> 4) + (HIDWORD(P) & 0x10101010u)) * 0x01020408u) >> 24];
733 n_flipped += COUNT_FLIP_4[HIDWORD(P) & 0xff];
734 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x20408000u) + (HIDWORD(P) & 0x02040810u)) * 0x01010101u) >> 24];
735 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x08040201u) + (HIDWORD(P) & 0x80402010u)) * 0x01010101u) >> 24];
736
737 return n_flipped;
738}
739
746static int count_last_flip_F5(const unsigned long long P)
747{
748 int n_flipped;
749
750 n_flipped = COUNT_FLIP_4[(((HIDWORD(P) & 0x20202020u) + ((LODWORD(P) & 0x20202020u) >> 4)) * 0x00810204u) >> 24];
751 n_flipped += COUNT_FLIP_5[HIDWORD(P) & 0xff];
752 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x40800000u) + (HIDWORD(P) & 0x04081020u)) * 0x01010101u) >> 24];
753 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x10080402u) + (HIDWORD(P) & 0x00804020u)) * 0x01010101u) >> 24];
754
755 return n_flipped;
756}
757
764static int count_last_flip_G5(const unsigned long long P)
765{
766 int n_flipped;
767
768 n_flipped = COUNT_FLIP_4[(((LODWORD(P) & 0x20100804u) >> 2) * 0x01010101u + (HIDWORD(P) & 0x40404040u) * 0x00408102u) >> 24]; // C1G5G8
769 n_flipped += COUNT_FLIP_L[(HIDWORD(P) << 1) & 0x7e];
770 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x40404040u) >> 3) * 0x10080402u + ((HIDWORD(P) & 0x08102040u) >> 3) * 0x01010101u) >> 24]; // G1G5D8
771
772 return n_flipped;
773}
774
781static int count_last_flip_H5(const unsigned long long P)
782{
783 int n_flipped;
784
785 n_flipped = COUNT_FLIP_4[(((LODWORD(P) & 0x40201008u) >> 3) * 0x01010101u + (HIDWORD(P) & 0x80808080u) * 0x00204081u) >> 24]; // D1H5H8
786 n_flipped += COUNT_FLIP_L[HIDWORD(P) & 0x7f];
787 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x80808080u) >> 4) * 0x10080402u + ((HIDWORD(P) & 0x10204080u) >> 4) * 0x01010101u) >> 24]; // H1H5E8
788
789 return n_flipped;
790}
791
798static int count_last_flip_A6(const unsigned long long P)
799{
800 int n_flipped;
801
802 n_flipped = COUNT_FLIP_5[((LODWORD(P) & 0x01010101u) * 0x01020408u + (HIDWORD(P) & 0x04020101u) * 0x10202020u) >> 24]; // A1A6C8
803 n_flipped += COUNT_FLIP_R[(HIDWORD(P) >> 9) & 0x7f];
804 n_flipped += COUNT_FLIP_2[((LODWORD(P) & 0x04081020u) * 0x04040404u + (HIDWORD(P) & 0x01010102u) * 0x04040201u) >> 24]; // F1A6A8
805
806 return n_flipped;
807}
808
815static int count_last_flip_B6(const unsigned long long P)
816{
817 int n_flipped;
818
819 n_flipped = COUNT_FLIP_5[((LODWORD(P) & 0x02020202u) * 0x00810204u + (HIDWORD(P) & 0x08040202u) * 0x08101010u) >> 24]; // B1B6D8
820 n_flipped += COUNT_FLIP_R[(HIDWORD(P) >> 10) & 0x3f];
821 n_flipped += COUNT_FLIP_2[((LODWORD(P) & 0x08102040u) * 0x02020202u + ((HIDWORD(P) & 0x02020204u) >> 1) * 0x04040201u) >> 24]; // G1B6B8
822
823 return n_flipped;
824}
825
832static int count_last_flip_C6(const unsigned long long P)
833{
834 int n_flipped;
835
836 n_flipped = COUNT_FLIP_5[(((LODWORD(P) & 0x04040404u) + ((HIDWORD(P) & 0x04040404u) << 4)) * 0x00408102u) >> 24];
837 n_flipped += COUNT_FLIP_2[(HIDWORD(P) >> 8) & 0xff];
838 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x10204080u) + (HIDWORD(P) & 0x01020408u)) * 0x01010101u) >> 24];
839 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x01000000u) + (HIDWORD(P) & 0x10080402u)) * 0x01010101u) >> 24];
840
841 return n_flipped;
842}
843
850static int count_last_flip_D6(const unsigned long long P)
851{
852 int n_flipped;
853
854 n_flipped = COUNT_FLIP_5[(((LODWORD(P) & 0x08080808u) + ((HIDWORD(P) & 0x08080808u) << 4)) * 0x00204081u) >> 24];
855 n_flipped += COUNT_FLIP_3[(HIDWORD(P) >> 8) & 0xff];
856 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x20408000u) + (HIDWORD(P) & 0x02040810u)) * 0x01010101u) >> 24];
857 n_flipped += COUNT_FLIP_3[(((LODWORD(P) & 0x02010000u) + (HIDWORD(P) & 0x20100804u)) * 0x01010101u) >> 24];
858
859 return n_flipped;
860}
861
868static int count_last_flip_E6(const unsigned long long P)
869{
870 int n_flipped;
871
872 n_flipped = COUNT_FLIP_5[((((LODWORD(P) & 0x10101010u) >> 4) + (HIDWORD(P) & 0x10101010u)) * 0x01020408u) >> 24];
873 n_flipped += COUNT_FLIP_4[(HIDWORD(P) >> 8) & 0xff];
874 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x40800000u) + (HIDWORD(P) & 0x04081020u)) * 0x01010101u) >> 24];
875 n_flipped += COUNT_FLIP_4[(((LODWORD(P) & 0x04020100u) + (HIDWORD(P) & 0x40201008u)) * 0x01010101u) >> 24];
876
877 return n_flipped;
878}
879
886static int count_last_flip_F6(const unsigned long long P)
887{
888 int n_flipped;
889
890 n_flipped = COUNT_FLIP_5[(((HIDWORD(P) & 0x20202020u) + ((LODWORD(P) & 0x20202020u) >> 4)) * 0x00810204u) >> 24];
891 n_flipped += COUNT_FLIP_5[(HIDWORD(P) >> 8) & 0xff];
892 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x80000000u) + (HIDWORD(P) & 0x08102040u)) * 0x01010101u) >> 24];
893 n_flipped += COUNT_FLIP_5[(((LODWORD(P) & 0x08040201u) + (HIDWORD(P) & 0x80402010u)) * 0x01010101u) >> 24];
894
895 return n_flipped;
896}
897
904static int count_last_flip_G6(const unsigned long long P)
905{
906 int n_flipped;
907
908 n_flipped = COUNT_FLIP_5[(((LODWORD(P) & 0x10080402u) >> 1) * 0x01010101u + (HIDWORD(P) & 0x40404020u) * 0x00808102u) >> 24]; // B1G6G8
909 n_flipped += COUNT_FLIP_L[(HIDWORD(P) >> 7) & 0x7e];
910 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x40404040u) >> 4) * 0x20100804u + ((HIDWORD(P) & 0x10204040u) >> 4 ) * 0x02010101u) >> 24]; // G1G6E8
911
912 return n_flipped;
913}
914
921static int count_last_flip_H6(const unsigned long long P)
922{
923 int n_flipped;
924
925 n_flipped = COUNT_FLIP_5[(((LODWORD(P) & 0x20100804u) >> 2) * 0x01010101u + (HIDWORD(P) & 0x80808040u) * 0x00404081u) >> 24]; // C1H6H8
926 n_flipped += COUNT_FLIP_L[(HIDWORD(P) >> 8) & 0x7f];
927 n_flipped += COUNT_FLIP_2[(((LODWORD(P) & 0x80808080u) >> 5) * 0x20100804u + ((HIDWORD(P) & 0x20408080u) >> 5) * 0x02010101u) >> 24]; // H1H6F8
928
929 return n_flipped;
930}
931
938static int count_last_flip_A7(const unsigned long long P)
939{
940 int n_flipped;
941
942 n_flipped = COUNT_FLIP_L[((((HIDWORD(P) & 0x00000101u) << 4) + (LODWORD(P) & 0x01010101u)) * 0x02040810u) >> 24];
943 n_flipped += COUNT_FLIP_R[(HIDWORD(P) >> 17) & 0x7f];
944 n_flipped += COUNT_FLIP_R[(((HIDWORD(P) & 0x00000204u) + (LODWORD(P) & 0x08102040u)) * 0x01010101u) >> 25];
945
946 return n_flipped;
947}
948
955static int count_last_flip_B7(const unsigned long long P)
956{
957 int n_flipped;
958
959 n_flipped = COUNT_FLIP_L[((((HIDWORD(P) & 0x00000202u) << 4) + (LODWORD(P) & 0x02020202u)) * 0x01020408u) >> 24];
960 n_flipped += COUNT_FLIP_R[(HIDWORD(P) >> 18) & 0x3f];
961 n_flipped += COUNT_FLIP_R[(((HIDWORD(P) & 0x00000408u) + (LODWORD(P) & 0x10204080u)) * 0x01010101u) >> 26];
962
963 return n_flipped;
964}
965
972static int count_last_flip_C7(const unsigned long long P)
973{
974 int n_flipped;
975
976 n_flipped = COUNT_FLIP_L[(((LODWORD(P) & 0x04040404u) + ((HIDWORD(P) & 0x00000404u) << 4)) * 0x00810204u) >> 24];
977 n_flipped += COUNT_FLIP_2[(HIDWORD(P) >> 16) & 0xff];
978 n_flipped += COUNT_FLIP_2[(((HIDWORD(P) & 0x00040A11u) + (LODWORD(P) & 0x20408000u)) * 0x01010101u) >> 24];
979
980 return n_flipped;
981}
982
989static int count_last_flip_D7(const unsigned long long P)
990{
991 int n_flipped;
992
993 n_flipped = COUNT_FLIP_L[((((HIDWORD(P) & 0x00000808u) << 4) + (LODWORD(P) & 0x08080808u)) * 0x00408102u) >> 24];
994 n_flipped += COUNT_FLIP_3[(HIDWORD(P) >> 16) & 0xff];
995 n_flipped += COUNT_FLIP_3[(((HIDWORD(P) & 0x00081422u) + (LODWORD(P) & 0x41800000u)) * 0x01010101u) >> 24];
996
997 return n_flipped;
998}
999
1006static int count_last_flip_E7(const unsigned long long P)
1007{
1008 int n_flipped;
1009
1010 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00001010u) + ((LODWORD(P) & 0x10101010u) >> 4)) * 0x02040810u) >> 24];
1011 n_flipped += COUNT_FLIP_4[(HIDWORD(P) >> 16) & 0xff];
1012 n_flipped += COUNT_FLIP_4[(((HIDWORD(P) & 0x00102844u) + (LODWORD(P) & 0x82010000u)) * 0x01010101u) >> 24];
1013
1014 return n_flipped;
1015}
1016
1023static int count_last_flip_F7(const unsigned long long P)
1024{
1025 int n_flipped;
1026
1027 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00002020u) + ((LODWORD(P) & 0x20202020u) >> 4)) * 0x01020408u) >> 24];
1028 n_flipped += COUNT_FLIP_5[(HIDWORD(P) >> 16) & 0xff];
1029 n_flipped += COUNT_FLIP_5[(((HIDWORD(P) & 0x00205088u) + (LODWORD(P) & 0x04020100u)) * 0x01010101u) >> 24];
1030
1031 return n_flipped;
1032}
1033
1040static int count_last_flip_G7(const unsigned long long P)
1041{
1042 int n_flipped;
1043
1044 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00004040u) + ((LODWORD(P) & 0x40404040u) >> 4)) * 0x00810204u) >> 24];
1045 n_flipped += COUNT_FLIP_L[(HIDWORD(P) >> 15) & 0x7e];
1046 n_flipped += COUNT_FLIP_L[(((HIDWORD(P) & 0x00002010u) + (LODWORD(P) & 0x08040201u)) * 0x02020202u) >> 24];
1047
1048 return n_flipped;
1049}
1050
1057static int count_last_flip_H7(const unsigned long long P)
1058{
1059 int n_flipped;
1060
1061 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00008080u) + ((LODWORD(P) & 0x80808080u) >> 4)) * 0x00408102u) >> 24];
1062 n_flipped += COUNT_FLIP_L[(HIDWORD(P) >> 16) & 0x7f];
1063 n_flipped += COUNT_FLIP_L[(((HIDWORD(P) & 0x00004020u) + (LODWORD(P) & 0x10080402u)) * 0x01010101u) >> 24];
1064
1065 return n_flipped;
1066}
1067
1074static int count_last_flip_A8(const unsigned long long P)
1075{
1076 int n_flipped;
1077
1078 n_flipped = COUNT_FLIP_L[((((HIDWORD(P) & 0x00010101u) << 4) + (LODWORD(P) & 0x01010101u)) * 0x01020408u) >> 24];
1079 n_flipped += COUNT_FLIP_R[HIDWORD(P) >> 25];
1080 n_flipped += COUNT_FLIP_R[(((HIDWORD(P) & 0x00020408u) + (LODWORD(P) & 0x10204080u)) * 0x01010101u) >> 25];
1081
1082 return n_flipped;
1083}
1084
1091static int count_last_flip_B8(const unsigned long long P)
1092{
1093 int n_flipped;
1094
1095 n_flipped = COUNT_FLIP_L[((((HIDWORD(P) & 0x00020202u) << 4) + (LODWORD(P) & 0x02020202u)) * 0x00810204u) >> 24];
1096 n_flipped += COUNT_FLIP_R[HIDWORD(P) >> 26];
1097 n_flipped += COUNT_FLIP_R[(((HIDWORD(P) & 0x00040810u) + (LODWORD(P) & 0x20408000u)) * 0x01010101u) >> 26];
1098
1099 return n_flipped;
1100}
1101
1108static int count_last_flip_C8(const unsigned long long P)
1109{
1110 int n_flipped;
1111
1112 n_flipped = COUNT_FLIP_L[(((LODWORD(P) & 0x04040404u) + ((HIDWORD(P) & 0x00040404u) << 4)) * 0x00408102u) >> 24];
1113 n_flipped += COUNT_FLIP_2[HIDWORD(P) >> 24];
1114 n_flipped += COUNT_FLIP_2[(((HIDWORD(P) & 0x040A1120u) + (LODWORD(P) & 0x40800000u)) * 0x01010101u) >> 24];
1115
1116 return n_flipped;
1117}
1118
1125static int count_last_flip_D8(const unsigned long long P)
1126{
1127 int n_flipped;
1128
1129 n_flipped = COUNT_FLIP_L[((((HIDWORD(P) & 0x00080808u) << 4) + (LODWORD(P) & 0x08080808u)) * 0x00204081u) >> 24];
1130 n_flipped += COUNT_FLIP_3[HIDWORD(P) >> 24];
1131 n_flipped += COUNT_FLIP_3[(((HIDWORD(P) & 0x08142241u) + (LODWORD(P) & 0x80000000u)) * 0x01010101u) >> 24];
1132
1133 return n_flipped;
1134}
1135
1142static int count_last_flip_E8(const unsigned long long P)
1143{
1144 int n_flipped;
1145
1146 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00101010u) + ((LODWORD(P) & 0x10101010u) >> 4)) * 0x01020408u) >> 24];
1147 n_flipped += COUNT_FLIP_4[HIDWORD(P) >> 24];
1148 n_flipped += COUNT_FLIP_4[(((HIDWORD(P) & 0x10284482u) + (LODWORD(P) & 0x01000000u)) * 0x01010101u) >> 24];
1149
1150 return n_flipped;
1151}
1152
1159static int count_last_flip_F8(const unsigned long long P)
1160{
1161 int n_flipped;
1162
1163 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00202020u) + ((LODWORD(P) & 0x20202020u) >> 4)) * 0x00810204u) >> 24];
1164 n_flipped += COUNT_FLIP_5[HIDWORD(P) >> 24];
1165 n_flipped += COUNT_FLIP_5[(((HIDWORD(P) & 0x00508804u) + (LODWORD(P) & 0x02010000u)) * 0x01010101u) >> 24];
1166
1167 return n_flipped;
1168}
1169
1176static int count_last_flip_G8(const unsigned long long P)
1177{
1178 int n_flipped;
1179
1180 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00404040u) + ((LODWORD(P) & 0x40404040u) >> 4)) * 0x00408102u) >> 24];
1181 n_flipped += COUNT_FLIP_L[(HIDWORD(P) >> 23) & 0x7e];
1182 n_flipped += COUNT_FLIP_L[(((HIDWORD(P) & 0x00201008u) + (LODWORD(P) & 0x04020100u)) * 0x02020202u) >> 24];
1183
1184 return n_flipped;
1185}
1186
1193static int count_last_flip_H8(const unsigned long long P)
1194{
1195 int n_flipped;
1196
1197 n_flipped = COUNT_FLIP_L[(((HIDWORD(P) & 0x00808080u) + ((LODWORD(P) & 0x80808080) >> 4)) * 0x00204081u) >> 24];
1198 n_flipped += COUNT_FLIP_L[(HIDWORD(P) >> 24) & 0x7f];
1199 n_flipped += COUNT_FLIP_L[(((HIDWORD(P) & 0x00402010u) + (LODWORD(P) & 0x08040201u)) * 0x01010101u) >> 24];
1200
1201 return n_flipped;
1202}
1203
1210static int count_last_flip_pass(const unsigned long long P)
1211{
1212 (void) P; // useless code to shut-up compiler warning
1213 return 0;
1214}
1215
1236
1237int count_last_flip(const int x, const unsigned long long P)
1238{
1239 return COUNT_LAST_FLIP[x](P);
1240}
1241
int(* count_last_flip[])(const unsigned long long)
Definition count_flip.c:1234
static int count_last_flip_G3(const unsigned long long P)
Definition count_last_flip_carry_32.c:484
static int count_last_flip_E1(const unsigned long long P)
Definition count_last_flip_carry_32.c:174
static int count_last_flip_D6(const unsigned long long P)
Definition count_last_flip_carry_32.c:850
static int count_last_flip_A4(const unsigned long long P)
Definition count_last_flip_carry_32.c:518
static int count_last_flip_F3(const unsigned long long P)
Definition count_last_flip_carry_32.c:466
static int count_last_flip_C3(const unsigned long long P)
Definition count_last_flip_carry_32.c:412
static const char COUNT_FLIP_2[256]
Definition count_last_flip_carry_32.c:49
static int count_last_flip_G1(const unsigned long long P)
Definition count_last_flip_carry_32.c:208
static int count_last_flip_H1(const unsigned long long P)
Definition count_last_flip_carry_32.c:225
static int count_last_flip_D5(const unsigned long long P)
Definition count_last_flip_carry_32.c:710
static int count_last_flip_B8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1091
static int count_last_flip_G5(const unsigned long long P)
Definition count_last_flip_carry_32.c:764
static int count_last_flip_H3(const unsigned long long P)
Definition count_last_flip_carry_32.c:501
static const char COUNT_FLIP_5[256]
Definition count_last_flip_carry_32.c:82
static int count_last_flip_F4(const unsigned long long P)
Definition count_last_flip_carry_32.c:606
static int count_last_flip_A5(const unsigned long long P)
Definition count_last_flip_carry_32.c:658
static int count_last_flip_A8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1074
static int count_last_flip_F1(const unsigned long long P)
Definition count_last_flip_carry_32.c:191
static int count_last_flip_C6(const unsigned long long P)
Definition count_last_flip_carry_32.c:832
static int count_last_flip_A1(const unsigned long long P)
Definition count_last_flip_carry_32.c:106
static int count_last_flip_H2(const unsigned long long P)
Definition count_last_flip_carry_32.c:361
static int count_last_flip_C4(const unsigned long long P)
Definition count_last_flip_carry_32.c:552
static int count_last_flip_H5(const unsigned long long P)
Definition count_last_flip_carry_32.c:781
static int count_last_flip_B5(const unsigned long long P)
Definition count_last_flip_carry_32.c:675
static int count_last_flip_C1(const unsigned long long P)
Definition count_last_flip_carry_32.c:140
static int count_last_flip_E8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1142
static int count_last_flip_B1(const unsigned long long P)
Definition count_last_flip_carry_32.c:123
static int count_last_flip_C5(const unsigned long long P)
Definition count_last_flip_carry_32.c:692
static int count_last_flip_G7(const unsigned long long P)
Definition count_last_flip_carry_32.c:1040
static int count_last_flip_D8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1125
static int count_last_flip_E6(const unsigned long long P)
Definition count_last_flip_carry_32.c:868
static int count_last_flip_H6(const unsigned long long P)
Definition count_last_flip_carry_32.c:921
static int count_last_flip_B2(const unsigned long long P)
Definition count_last_flip_carry_32.c:259
static int count_last_flip_pass(const unsigned long long P)
Definition count_last_flip_carry_32.c:1210
static int count_last_flip_E5(const unsigned long long P)
Definition count_last_flip_carry_32.c:728
static int count_last_flip_A7(const unsigned long long P)
Definition count_last_flip_carry_32.c:938
static int count_last_flip_H7(const unsigned long long P)
Definition count_last_flip_carry_32.c:1057
static int count_last_flip_D7(const unsigned long long P)
Definition count_last_flip_carry_32.c:989
static int count_last_flip_B3(const unsigned long long P)
Definition count_last_flip_carry_32.c:395
static int count_last_flip_C7(const unsigned long long P)
Definition count_last_flip_carry_32.c:972
#define LODWORD(l)
Definition count_last_flip_carry_32.c:34
static int count_last_flip_D2(const unsigned long long P)
Definition count_last_flip_carry_32.c:293
static const char COUNT_FLIP_3[256]
Definition count_last_flip_carry_32.c:60
static int count_last_flip_E7(const unsigned long long P)
Definition count_last_flip_carry_32.c:1006
static int count_last_flip_A3(const unsigned long long P)
Definition count_last_flip_carry_32.c:378
static int count_last_flip_G8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1176
static int count_last_flip_F6(const unsigned long long P)
Definition count_last_flip_carry_32.c:886
static int count_last_flip_E3(const unsigned long long P)
Definition count_last_flip_carry_32.c:448
static int count_last_flip_G4(const unsigned long long P)
Definition count_last_flip_carry_32.c:624
int(* COUNT_LAST_FLIP[])(const unsigned long long)
Definition count_last_flip_carry_32.c:1217
static int count_last_flip_F5(const unsigned long long P)
Definition count_last_flip_carry_32.c:746
static int count_last_flip_E4(const unsigned long long P)
Definition count_last_flip_carry_32.c:588
static const char COUNT_FLIP_L[128]
Definition count_last_flip_carry_32.c:93
static int count_last_flip_B4(const unsigned long long P)
Definition count_last_flip_carry_32.c:535
#define HIDWORD(l)
Definition count_last_flip_carry_32.c:35
static int count_last_flip_F8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1159
static int count_last_flip_H4(const unsigned long long P)
Definition count_last_flip_carry_32.c:641
static int count_last_flip_A6(const unsigned long long P)
Definition count_last_flip_carry_32.c:798
static int count_last_flip_F2(const unsigned long long P)
Definition count_last_flip_carry_32.c:327
static int count_last_flip_D4(const unsigned long long P)
Definition count_last_flip_carry_32.c:570
static int count_last_flip_D1(const unsigned long long P)
Definition count_last_flip_carry_32.c:157
static int count_last_flip_F7(const unsigned long long P)
Definition count_last_flip_carry_32.c:1023
static int count_last_flip_B7(const unsigned long long P)
Definition count_last_flip_carry_32.c:955
static int count_last_flip_G6(const unsigned long long P)
Definition count_last_flip_carry_32.c:904
static int count_last_flip_E2(const unsigned long long P)
Definition count_last_flip_carry_32.c:310
static int count_last_flip_H8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1193
static int count_last_flip_G2(const unsigned long long P)
Definition count_last_flip_carry_32.c:344
static int count_last_flip_C8(const unsigned long long P)
Definition count_last_flip_carry_32.c:1108
static int count_last_flip_A2(const unsigned long long P)
Definition count_last_flip_carry_32.c:242
static int count_last_flip_B6(const unsigned long long P)
Definition count_last_flip_carry_32.c:815
static const char COUNT_FLIP_4[256]
Definition count_last_flip_carry_32.c:71
static const char COUNT_FLIP_R[128]
Definition count_last_flip_carry_32.c:38
static int count_last_flip_D3(const unsigned long long P)
Definition count_last_flip_carry_32.c:430
static int count_last_flip_C2(const unsigned long long P)
Definition count_last_flip_carry_32.c:276
uint64 P(uint64 mask, const uint64 flat)
Definition generate_flip.c:176