3 uint64_t *radixSort(uint64_t *array
, uint32_t size
) {
5 memset(&counts
, 0, 256 * 8 * sizeof(uint32_t));
6 uint64_t *cpy
= (uint64_t *)calloc(size
* sizeof(uint64_t), sizeof(uint8_t));
7 uint32_t o8
= 0, o7
= 0, o6
= 0, o5
= 0, o4
= 0, o3
= 0, o2
= 0, o1
= 0;
8 uint32_t t8
, t7
, t6
, t5
, t4
, t3
, t2
, t1
;
11 for (x
= 0; x
< size
; ++x
) {
13 t7
= (array
[x
] >> 8) & 0xff;
14 t6
= (array
[x
] >> 16) & 0xff;
15 t5
= (array
[x
] >> 24) & 0xff;
16 t4
= (array
[x
] >> 32) & 0xff;
17 t3
= (array
[x
] >> 40) & 0xff;
18 t2
= (array
[x
] >> 48) & 0xff;
19 t1
= (array
[x
] >> 56) & 0xff;
29 // convert counts to offsets
30 for (x
= 0; x
< 256; ++x
) {
31 t8
= o8
+ counts
.c8
[x
];
32 t7
= o7
+ counts
.c7
[x
];
33 t6
= o6
+ counts
.c6
[x
];
34 t5
= o5
+ counts
.c5
[x
];
35 t4
= o4
+ counts
.c4
[x
];
36 t3
= o3
+ counts
.c3
[x
];
37 t2
= o2
+ counts
.c2
[x
];
38 t1
= o1
+ counts
.c1
[x
];
57 for (x
= 0; x
< size
; ++x
) {
59 cpy
[counts
.c8
[t8
]] = array
[x
];
62 for (x
= 0; x
< size
; ++x
) {
63 t7
= (cpy
[x
] >> 8) & 0xff;
64 array
[counts
.c7
[t7
]] = cpy
[x
];
67 for (x
= 0; x
< size
; ++x
) {
68 t6
= (array
[x
] >> 16) & 0xff;
69 cpy
[counts
.c6
[t6
]] = array
[x
];
72 for (x
= 0; x
< size
; ++x
) {
73 t5
= (cpy
[x
] >> 24) & 0xff;
74 array
[counts
.c5
[t5
]] = cpy
[x
];
77 for (x
= 0; x
< size
; ++x
) {
78 t4
= (array
[x
] >> 32) & 0xff;
79 cpy
[counts
.c4
[t4
]] = array
[x
];
82 for (x
= 0; x
< size
; ++x
) {
83 t3
= (cpy
[x
] >> 40) & 0xff;
84 array
[counts
.c3
[t3
]] = cpy
[x
];
87 for (x
= 0; x
< size
; ++x
) {
88 t2
= (array
[x
] >> 48) & 0xff;
89 cpy
[counts
.c2
[t2
]] = array
[x
];
92 for (x
= 0; x
< size
; ++x
) {
93 t1
= (cpy
[x
] >> 56) & 0xff;
94 array
[counts
.c1
[t1
]] = cpy
[x
];