common.h (1714B)
1 STATIC_INLINE int popcount_u32(uint32_t); 2 3 STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]); 4 STATIC_INLINE bool equal(cube_t, cube_t); 5 STATIC_INLINE cube_t invertco(cube_t); 6 STATIC_INLINE cube_t compose_edges(cube_t, cube_t); 7 STATIC_INLINE cube_t compose_corners(cube_t, cube_t); 8 STATIC_INLINE cube_t compose(cube_t, cube_t); 9 STATIC_INLINE cube_t inverse(cube_t); 10 11 STATIC_INLINE int64_t coord_co(cube_t); 12 STATIC_INLINE cube_t invcoord_co(int64_t); 13 STATIC_INLINE int64_t coord_csep(cube_t); 14 STATIC_INLINE int64_t coord_cocsep(cube_t); 15 STATIC_INLINE int64_t coord_eo(cube_t); 16 STATIC_INLINE int64_t coord_esep(cube_t); 17 STATIC_INLINE cube_t invcoord_esep(int64_t); 18 19 STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); 20 STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); 21 STATIC_INLINE void set_eo(cube_t [static 1], int64_t); 22 23 STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); 24 STATIC_INLINE cube_t invcoord_eoesep(int64_t); 25 26 STATIC_INLINE void 27 invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) 28 { 29 int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; 30 uint8_t slice[3] = {0}; 31 32 for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) 33 { 34 v = binomial[11 - i][k]; 35 jj = j < 8; 36 w = jj * binomial[7 - (j * jj)][l]; 37 bit2 = set2 >= v; 38 bit1 = set1 >= w; 39 is1 = (1 - bit2) * bit1; 40 41 set2 -= bit2 * v; 42 k -= bit2; 43 set1 -= is1 * w; 44 l -= is1; 45 j += (1 - bit2); 46 s = 2 * bit2 + (1 - bit2) * bit1; 47 48 mem[i] = (slice[s]++) | (uint8_t)(s << 2); 49 } 50 } 51 52 STATIC_INLINE cube_t 53 invcoord_eoesep(int64_t i) 54 { 55 cube_t c; 56 int64_t esep, eo; 57 58 esep = i >> INT64_C(11); 59 eo = i % POW_2_11; 60 c = invcoord_esep(esep); 61 set_eo(&c, eo); 62 63 return c; 64 }