7
7
#define idx_2 (LUT , i1 , i0 ) (idx_1(LUT, i0) + (LUT)[1][i1])
8
8
#define min (x , y ) (((x) > (y)) ? (y) : (x))
9
9
#define unlikely (x ) __builtin_expect(!!(x), 0)
10
- #define PUSH_SOLUTION (current_solution ) \
11
- { \
12
- packVectors_of_solution[current_solution_index] = current_solution; \
13
- current_solution_index++; \
14
- if (current_solution_index == 1) { \
15
- if (testSolution(wrapper_state_ptr , current_solution_index, packVectors_of_solution)) { \
16
- return; \
17
- } \
18
- current_solution_index = 0; \
19
- } \
10
+ #define PUSH_SOLUTION (current_solution ) \
11
+ { \
12
+ packVectors_of_solution[current_solution_index] = current_solution; \
13
+ current_solution_index++; \
14
+ if (current_solution_index == 1) { \
15
+ if (testSolution(States , current_solution_index, packVectors_of_solution)) { \
16
+ return; \
17
+ } \
18
+ current_solution_index = 0; \
19
+ } \
20
20
}
21
21
#define CHECK_SOLUTIONS () \
22
22
{ \
@@ -105,7 +105,7 @@ static PackedVectors packVectors(int n, const Vector v);
105
105
static uint64_t encodeToGray (uint64_t i );
106
106
static int selectOneBit (uint64_t startPointHigh , uint64_t startPointLow , int index );
107
107
static void freeEqs (int * * * Eqs , int i , int j );
108
- static int initEqs (int n , int e , int * * * * EqsPtr );
108
+ static int initEqs (int n , int e , int * * * * Eqs );
109
109
static void convert1DTo3D (int n , int e , const uint8_t * coefficientsMatrix , int * * * Eqs );
110
110
static void mergeSolution (Settings * p , uint64_t count , uint64_t * Sol );
111
111
static TableWithSize * initTable (int n );
@@ -114,9 +114,9 @@ static void freeTable(const TableWithSize *tab);
114
114
static void * exfesCalloc (size_t num , size_t size , size_t max_num_retries );
115
115
static void computeNextSet (int n , int d , int * set );
116
116
static int convert3DToPackedVectors (const int n , int from , int to , int * * * coeffs , TableWithSize * idx_LUT , PackedVectors * F );
117
- static int testSolution (States * wrapper_state_ptr , uint64_t size , uint64_t * n_solutions );
117
+ static int testSolution (States * States , uint64_t size , uint64_t * n_solutions );
118
118
static int fes (const int n , int n_eqs , int * * * coeffs , Settings * settings );
119
- static void primarySearch (Table LUT , int n , PackedVectors * F , States * wrapper_state_ptr );
119
+ static void primarySearch (Table LUT , int n , PackedVectors * F , States * States );
120
120
121
121
int exfes (uint32_t numFixedVariables , uint32_t numVariables , uint32_t numEquations , uint64_t startPointHigh , uint64_t startPointLow , const uint8_t * coefficientsMatrix , bool (* shouldAbortNow )(void ), uint64_t * solutionHigh , uint64_t * solutionLow )
122
122
{
@@ -305,22 +305,22 @@ static void freeEqs(int ***Eqs, int i, int j)
305
305
free (Eqs );
306
306
}
307
307
308
- static int initEqs (int n , int e , int * * * * EqsPtr )
308
+ static int initEqs (int n , int e , int * * * * Eqs )
309
309
{
310
- EqsPtr [0 ] = (int * * * )exfesCalloc (e , sizeof (int * * ), 10 );
311
- if (!EqsPtr [0 ]) {
310
+ Eqs [0 ] = (int * * * )exfesCalloc (e , sizeof (int * * ), 10 );
311
+ if (!Eqs [0 ]) {
312
312
return -4 ;
313
313
}
314
314
for (int i = 0 ; i < e ; i ++ ) {
315
- EqsPtr [0 ][i ] = (int * * )exfesCalloc (3 , sizeof (int * ), 10 );
316
- if (!EqsPtr [0 ][i ]) {
317
- freeEqs (EqsPtr [0 ], i , -1 );
315
+ Eqs [0 ][i ] = (int * * )exfesCalloc (3 , sizeof (int * ), 10 );
316
+ if (!Eqs [0 ][i ]) {
317
+ freeEqs (Eqs [0 ], i , -1 );
318
318
return -4 ;
319
319
}
320
320
for (int j = 0 ; j < 3 ; j ++ ) {
321
- EqsPtr [0 ][i ][j ] = (int * )exfesCalloc (binomials [n ][j ], sizeof (int ), 10 );
322
- if (!EqsPtr [0 ][i ][j ]) {
323
- freeEqs (EqsPtr [0 ], i , j );
321
+ Eqs [0 ][i ][j ] = (int * )exfesCalloc (binomials [n ][j ], sizeof (int ), 10 );
322
+ if (!Eqs [0 ][i ][j ]) {
323
+ freeEqs (Eqs [0 ], i , j );
324
324
return -4 ;
325
325
}
326
326
}
@@ -505,14 +505,14 @@ static int convert3DToPackedVectors(const int n, int from, int to, int ***coeffs
505
505
return 0 ;
506
506
}
507
507
508
- static int testSolution (States * wrapper_state_ptr , uint64_t size , uint64_t * n_solutions )
508
+ static int testSolution (States * States , uint64_t size , uint64_t * n_solutions )
509
509
{
510
510
for (uint64_t i = 0 ; i < size ; i ++ ) {
511
511
uint64_t current_solution = n_solutions [i ];
512
512
int is_correct = 1 ;
513
513
int j = 0 ;
514
- while (is_correct && j < wrapper_state_ptr -> numBatches ) {
515
- if (secondaryEvaluation (wrapper_state_ptr -> tableWithSize -> table , wrapper_state_ptr -> numVariables , wrapper_state_ptr -> packedVectors2D [j ], current_solution ) != 0 ) {
514
+ while (is_correct && j < States -> numBatches ) {
515
+ if (secondaryEvaluation (States -> tableWithSize -> table , States -> numVariables , States -> packedVectors2D [j ], current_solution ) != 0 ) {
516
516
is_correct = 0 ;
517
517
}
518
518
j ++ ;
@@ -521,7 +521,7 @@ static int testSolution(States *wrapper_state_ptr, uint64_t size, uint64_t *n_so
521
521
int num_correct_solutions = 1 ;
522
522
uint64_t corrects_solutions [1 ];
523
523
corrects_solutions [0 ] = current_solution ;
524
- mergeSolution (wrapper_state_ptr -> settings , num_correct_solutions , corrects_solutions );
524
+ mergeSolution (States -> settings , num_correct_solutions , corrects_solutions );
525
525
return 1 ;
526
526
}
527
527
}
@@ -579,13 +579,13 @@ static int fes(const int n, int n_eqs, int ***coeffs, Settings *settings)
579
579
freeTable (idx_LUT );
580
580
return -4 ;
581
581
}
582
- States wrapper_state ;
583
- wrapper_state .numVariables = n ;
584
- wrapper_state .numBatches = numBatches - 1 ;
585
- wrapper_state .packedVectors2D = G ;
586
- wrapper_state .tableWithSize = idx_LUT ;
587
- wrapper_state .settings = settings ;
588
- primarySearch (idx_LUT -> table , n , F , & wrapper_state );
582
+ States States ;
583
+ States .numVariables = n ;
584
+ States .numBatches = numBatches - 1 ;
585
+ States .packedVectors2D = G ;
586
+ States .tableWithSize = idx_LUT ;
587
+ States .settings = settings ;
588
+ primarySearch (idx_LUT -> table , n , F , & States );
589
589
for (int i = numBatches - 1 ; i >= 1 ; i -- ) {
590
590
free (G [i - 1 ]);
591
591
}
@@ -595,9 +595,9 @@ static int fes(const int n, int n_eqs, int ***coeffs, Settings *settings)
595
595
return 0 ;
596
596
}
597
597
598
- static void primarySearch (Table LUT , int n , PackedVectors * F , States * wrapper_state_ptr )
598
+ static void primarySearch (Table LUT , int n , PackedVectors * F , States * States )
599
599
{
600
- Settings * ctx = wrapper_state_ptr -> settings ;
600
+ Settings * ctx = States -> settings ;
601
601
for (int i0 = 1 ; i0 < n ; i0 ++ ) {
602
602
if (i0 != 0 ) {
603
603
F [idx_1 (LUT , i0 )] ^= F [idx_2 (LUT , i0 - 1 , i0 )];
@@ -1168,5 +1168,5 @@ static void primarySearch(Table LUT, int n, PackedVectors *F, States *wrapper_st
1168
1168
CHECK_SOLUTIONS ();
1169
1169
}
1170
1170
}
1171
- testSolution (wrapper_state_ptr , current_solution_index , packVectors_of_solution );
1171
+ testSolution (States , current_solution_index , packVectors_of_solution );
1172
1172
}
0 commit comments