| 1 | /* |
| 2 | * sais.c for sais-lite |
| 3 | * Copyright (c) 2008-2010 Yuta Mori All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person |
| 6 | * obtaining a copy of this software and associated documentation |
| 7 | * files (the "Software"), to deal in the Software without |
| 8 | * restriction, including without limitation the rights to use, |
| 9 | * copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following |
| 12 | * conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be |
| 15 | * included in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 24 | * OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | #include <assert.h> |
| 28 | #include <string.h> |
| 29 | #include <stdio.h> |
| 30 | #include <stdlib.h> |
| 31 | #include <time.h> |
| 32 | #include "sais.h"cxx . . $ `<file>/contrib/sais-lite-lcp/sais.h`/ |
| 33 | |
| 34 | #ifndef UCHAR_SIZE |
| 35 | # define UCHAR_SIZEcxx . . $ `contrib/sais-lite-lcp/sais.c:35:10`! 256 |
| 36 | #endif |
| 37 | #ifndef MINBUCKETSIZE |
| 38 | # define MINBUCKETSIZEcxx . . $ `contrib/sais-lite-lcp/sais.c:38:10`! 256 |
| 39 | #endif |
| 40 | |
| 41 | #define sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! int |
| 42 | #define sais_bool_typecxx . . $ `contrib/sais-lite-lcp/sais.c:42:9`! int |
| 43 | #define SAIS_LMSSORT2_LIMITcxx . . $ `contrib/sais-lite-lcp/sais.c:43:9`! 0x3fffffff |
| 44 | |
| 45 | #define SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(_num, _type) ((_type *)malloc((_num) * sizeof(_type))) |
| 46 | #define SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(_ptr, _num, _type) free((_ptr)) |
| 47 | #define chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(_a) (cs == sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!) ? ((sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *)T)[(_a)] : ((unsigned char *)T)[(_a)]) |
| 48 | |
| 49 | /* qsort int comparison function */ |
| 50 | int int_cmpcxx . . $ int_cmp(9148c8c3ff42c9d8).(const void *a, const void *b) |
| 51 | { |
| 52 | const int *ia = (const int *)a; /* casting pointer types */ |
| 53 | const int *ib = (const int *)b; |
| 54 | return *ia - *ib; |
| 55 | } |
| 56 | |
| 57 | /* find the start or end of each bucket */ |
| 58 | static |
| 59 | void |
| 60 | getCountscxx . . $ getCounts(210643f1ab60349f).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs) { |
| 61 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i; |
| 62 | for(i = 0; i < k; ++i) { C[i] = 0; } |
| 63 | for(i = 0; i < n; ++i) { ++C[chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)]; } |
| 64 | } |
| 65 | static |
| 66 | void |
| 67 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(const sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *B, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, sais_bool_typecxx . . $ `contrib/sais-lite-lcp/sais.c:42:9`! end) { |
| 68 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i, sum = 0; |
| 69 | if(end) { for(i = 0; i < k; ++i) { sum += C[i]; B[i] = sum; } } |
| 70 | else { for(i = 0; i < k; ++i) { sum += C[i]; B[i] = sum - C[i]; } } |
| 71 | } |
| 72 | |
| 73 | /* sort all type LMS suffixes */ |
| 74 | static |
| 75 | void |
| 76 | LMSsort1cxx . . $ LMSsort1(e1de81619e7ca8a1).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 77 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *B, |
| 78 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs) { |
| 79 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! bb, i, j; |
| 80 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; |
| 81 | |
| 82 | /* compute SAl */ |
| 83 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 84 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 0); /* find starts of buckets */ |
| 85 | j = n - 1; |
| 86 | bb = B[c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)]; |
| 87 | --j; |
| 88 | SA[bb++] = (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) < c1) ? ~j : j; |
| 89 | for(i = 0; i < n; ++i) { |
| 90 | if(0 < (j = SA[i])) { |
| 91 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) >= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 92 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { B[c1] = bb; bb = B[c1 = c0]; } |
| 93 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < bb); |
| 94 | --j; |
| 95 | SA[bb] = (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) < c1) ? ~j : j; |
| 96 | ++bb; |
| 97 | SA[i] = 0; |
| 98 | } else if(j < 0) { |
| 99 | SA[i] = ~j; |
| 100 | } |
| 101 | } |
| 102 | /* compute SAs */ |
| 103 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 104 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 105 | for(i = n - 1, bb = B[c1 = 0]; 0 <= i; --i) { |
| 106 | if(0 < (j = SA[i])) { |
| 107 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) <= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 108 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { B[c1] = bb; bb = B[c1 = c0]; } |
| 109 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((bb) <= i); |
| 110 | --j; |
| 111 | SA[--bb] = (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) > c1) ? ~(j + 1) : j; |
| 112 | SA[i] = 0; |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | static |
| 117 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! |
| 118 | LMSpostproc1cxx . . $ LMSpostproc1(b4f87ad3855b455b).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 119 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! m, int cs) { |
| 120 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i, j, p, q, plen, qlen, name; |
| 121 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; |
| 122 | sais_bool_typecxx . . $ `contrib/sais-lite-lcp/sais.c:42:9`! diff; |
| 123 | |
| 124 | /* compact all the sorted substrings into the first m items of SA |
| 125 | 2*m must be not larger than n (proveable) */ |
| 126 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 < n); |
| 127 | for(i = 0; (p = SA[i]) < 0; ++i) { SA[i] = ~p; assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((i + 1) < n); } |
| 128 | if(i < m) { |
| 129 | for(j = i, ++i;; ++i) { |
| 130 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < n); |
| 131 | if((p = SA[i]) < 0) { |
| 132 | SA[j++] = ~p; SA[i] = 0; |
| 133 | if(j == m) { break; } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /* store the length of all substrings */ |
| 139 | i = n - 1; j = n - 1; c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(n - 1); |
| 140 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) >= c1)); |
| 141 | for(; 0 <= i;) { |
| 142 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) <= c1)); |
| 143 | if(0 <= i) { |
| 144 | SA[m + ((i + 1) >> 1)] = j - i; j = i + 1; |
| 145 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) >= c1)); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /* find the lexicographic names of all substrings */ |
| 150 | for(i = 0, name = 0, q = n, qlen = 0; i < m; ++i) { |
| 151 | p = SA[i], plen = SA[m + (p >> 1)], diff = 1; |
| 152 | if((plen == qlen) && ((q + plen) < n)) { |
| 153 | for(j = 0; (j < plen) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(p + j) == chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(q + j)); ++j) { } |
| 154 | if(j == plen) { diff = 0; } |
| 155 | } |
| 156 | if(diff != 0) { ++name, q = p, qlen = plen; } |
| 157 | SA[m + (p >> 1)] = name; |
| 158 | } |
| 159 | |
| 160 | return name; |
| 161 | } |
| 162 | static |
| 163 | void |
| 164 | LMSsort2cxx . . $ LMSsort2(f8af3e29b49b9639).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 165 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *B, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *D, |
| 166 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs) { |
| 167 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *b, i, j, t, d; |
| 168 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; |
| 169 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(C != B); |
| 170 | |
| 171 | /* compute SAl */ |
| 172 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 0); /* find starts of buckets */ |
| 173 | j = n - 1; |
| 174 | b = SA + B[c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)]; |
| 175 | --j; |
| 176 | t = (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) < c1); |
| 177 | j += n; |
| 178 | *b++ = (t & 1) ? ~j : j; |
| 179 | for(i = 0, d = 0; i < n; ++i) { |
| 180 | if(0 < (j = SA[i])) { |
| 181 | if(n <= j) { d += 1; j -= n; } |
| 182 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) >= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 183 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { B[c1] = b - SA; b = SA + B[c1 = c0]; } |
| 184 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < (b - SA)); |
| 185 | --j; |
| 186 | t = c0; t = (t << 1) | (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) < c1); |
| 187 | if(D[t] != d) { j += n; D[t] = d; } |
| 188 | *b++ = (t & 1) ? ~j : j; |
| 189 | SA[i] = 0; |
| 190 | } else if(j < 0) { |
| 191 | SA[i] = ~j; |
| 192 | } |
| 193 | } |
| 194 | for(i = n - 1; 0 <= i; --i) { |
| 195 | if(0 < SA[i]) { |
| 196 | if(SA[i] < n) { |
| 197 | SA[i] += n; |
| 198 | for(j = i - 1; SA[j] < n; --j) { } |
| 199 | SA[j] -= n; |
| 200 | i = j; |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /* compute SAs */ |
| 206 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 207 | for(i = n - 1, d += 1, b = SA + B[c1 = 0]; 0 <= i; --i) { |
| 208 | if(0 < (j = SA[i])) { |
| 209 | if(n <= j) { d += 1; j -= n; } |
| 210 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) <= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 211 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { B[c1] = b - SA; b = SA + B[c1 = c0]; } |
| 212 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((b - SA) <= i); |
| 213 | --j; |
| 214 | t = c0; t = (t << 1) | (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) > c1); |
| 215 | if(D[t] != d) { j += n; D[t] = d; } |
| 216 | *--b = (t & 1) ? ~(j + 1) : j; |
| 217 | SA[i] = 0; |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | static |
| 222 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! |
| 223 | LMSpostproc2cxx . . $ LMSpostproc2(f6a32f5afd6954c).(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! m) { |
| 224 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i, j, d, name; |
| 225 | |
| 226 | /* compact all the sorted LMS substrings into the first m items of SA */ |
| 227 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 < n); |
| 228 | for(i = 0, name = 0; (j = SA[i]) < 0; ++i) { |
| 229 | j = ~j; |
| 230 | if(n <= j) { name += 1; } |
| 231 | SA[i] = j; |
| 232 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((i + 1) < n); |
| 233 | } |
| 234 | if(i < m) { |
| 235 | for(d = i, ++i;; ++i) { |
| 236 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < n); |
| 237 | if((j = SA[i]) < 0) { |
| 238 | j = ~j; |
| 239 | if(n <= j) { name += 1; } |
| 240 | SA[d++] = j; SA[i] = 0; |
| 241 | if(d == m) { break; } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | if(name < m) { |
| 246 | /* store the lexicographic names */ |
| 247 | for(i = m - 1, d = name + 1; 0 <= i; --i) { |
| 248 | if(n <= (j = SA[i])) { j -= n; --d; } |
| 249 | SA[m + (j >> 1)] = d; |
| 250 | } |
| 251 | } else { |
| 252 | /* unset flags */ |
| 253 | for(i = 0; i < m; ++i) { |
| 254 | if(n <= (j = SA[i])) { j -= n; SA[i] = j; } |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return name; |
| 259 | } |
| 260 | |
| 261 | /* compute SA and BWT */ |
| 262 | static void induceSAcxx . . $ induceSA(e1de81619e7ca8a1).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 263 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *B, |
| 264 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs) { |
| 265 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i, j; |
| 266 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! bb; |
| 267 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; |
| 268 | /* compute SAl */ |
| 269 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 270 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 0); /* find starts of buckets */ |
| 271 | j = n - 1; |
| 272 | bb = B[c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)]; |
| 273 | SA[bb++] = ((0 < j) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) < c1)) ? ~j : j; |
| 274 | for(i = 0; i < n; ++i) { |
| 275 | j = SA[i], SA[i] = ~j; |
| 276 | if(0 < j) { |
| 277 | --j; |
| 278 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) >= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 279 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { B[c1] = bb; bb = B[c1 = c0]; } |
| 280 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < bb); |
| 281 | SA[bb] = ((0 < j) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) < c1)) ? ~j : j; |
| 282 | ++bb; |
| 283 | } |
| 284 | } |
| 285 | /* compute SAs */ |
| 286 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 287 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 288 | for(i = n - 1, bb = B[c1 = 0]; 0 <= i; --i) { |
| 289 | if(0 < (j = SA[i])) { |
| 290 | --j; |
| 291 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) <= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 292 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { B[c1] = bb; bb = B[c1 = c0]; } |
| 293 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(bb <= i); |
| 294 | SA[--bb] = ((j == 0) || (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) > c1)) ? ~j : j; |
| 295 | } else { |
| 296 | SA[i] = ~j; |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | static void induceSAandLCPcxx . . $ induceSAandLCP(f8af3e29b49b9639).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 302 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *LCP, |
| 303 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *B, |
| 304 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs) { |
| 305 | /* |
| 306 | When entering this procedure, we are in the following situation: |
| 307 | all S*-suffixes have been sorted and put at the end of their |
| 308 | corresponding buckets in SA. Further, all their LCP-values have been |
| 309 | computed (in LCP). A value of -1 in LCP means that "this is the first |
| 310 | S*-suffix in its bucket." As in in the inducing step an L-suffix |
| 311 | can be placed before the leftmost S*-suffix, this means that the actual |
| 312 | LCP-value at this "L/S-seam" has to be recomputed. All other uncomputed |
| 313 | LCP-entries are marked -2. |
| 314 | */ |
| 315 | |
| 316 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i, bb; /* indices in SA/LCP (origin/target) */ |
| 317 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! j; /* position in text */ |
| 318 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; /* characters (new/last) */ |
| 319 | |
| 320 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! lcp; /* LCP-value */ |
| 321 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! l; /* for finding LCP at L/S-seam */ |
| 322 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! start, end, stack_end; /* for inducing the LCP-values */ |
| 323 | |
| 324 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *D; /* store beginnings of buckets (not CURRENT beginnings!) */ |
| 325 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *LastW; /* store last written L or S-suffix for every bucket */ |
| 326 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! sigma; /* (true) alphabet size */ |
| 327 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *TranslateSigma; /* general to effective alphabet ([0..k-1] |--> [0..sigma-1]) */ |
| 328 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *LastOcc; /* store last occurrences of characters */ |
| 329 | const sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! stack_extra_space = 1024; /* this is the same Min-Stack as in Gog's sdsl */ |
| 330 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! stack_size; |
| 331 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *MinStack; /* Min-Stack */ |
| 332 | |
| 333 | if ((D = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } /* TODO: check if D is necessary!!! (first write to bucket=>0) */ |
| 334 | if ((LastW = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } |
| 335 | for (i = 0; i < k; ++i) LastW[i] = n-1; /* point to $ */ |
| 336 | /* todo: move memory management to sais_main */ |
| 337 | |
| 338 | /* compute SAl and LCPl*/ |
| 339 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } /* re-calculate character counts */ |
| 340 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 0); /* find starts of buckets */ |
| 341 | memcpycxx . . $ memcpy(cc817cb175f282d).(D,B,k*sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)); /* store starts of buckets */ |
| 342 | j = n - 1; /* go to last character $ */ |
| 343 | bb = B[c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)]; /* bb = position in induced bucket */ |
| 344 | LCP[bb] = 0; /* set LCP-value of $ (first value in bucket => 0) */ |
| 345 | SA[bb++] = (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) < c1) ? ~j : j; /* put last character $ into its bucket */ |
| 346 | /* negative values mean "don't induce from here anymore" */ |
| 347 | |
| 348 | /* in case LCP[0], which is always 0, hadn't been set yet */ |
| 349 | LCP[0] = 0; |
| 350 | |
| 351 | /* Variant 3: stack */ |
| 352 | sigma = 0; /* (true) alphabet size */ |
| 353 | if ((TranslateSigma = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } |
| 354 | for (i = 0; i < k; ++i) { /* calculate effective alphabet size */ |
| 355 | TranslateSigma[i] = sigma; /* (also stores values for unused characters) */ |
| 356 | if (C[i] > 0) ++sigma; /* count characters */ |
| 357 | } |
| 358 | if ((LastOcc = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(sigma, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } |
| 359 | for (i = 0; i < sigma; ++i) LastOcc[i] = -1; /* init with impossible values */ |
| 360 | |
| 361 | stack_size = 2 * (stack_extra_space + sigma + 4); |
| 362 | if ((MinStack = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(stack_size+4, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } |
| 363 | MinStack[0] = -1; MinStack[1] = -1; /* (pos, LCP-value) */ |
| 364 | stack_end = 1; |
| 365 | |
| 366 | for(i = 0; i < n; ++i) { |
| 367 | j = SA[i], SA[i] = ~j; |
| 368 | if(0 < j) { /* otherwise don't induce anymore from j */ |
| 369 | lcp = LCP[i]; |
| 370 | if (lcp == -1) { |
| 371 | /* here we are at the seam between L and S in the same bucket */ |
| 372 | c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j); /* i's bucket */ |
| 373 | lcp = 0; |
| 374 | while (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j+lcp) == chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(LastW[c0]+lcp)) lcp++; /* naive LCP-computation (overall linear!) */ |
| 375 | /* no need to store LCP[i]=lcp (will be re-calculated in right-to-left scan!) */ |
| 376 | } |
| 377 | --j; /* move to suffix T[SA[i]-1] */ |
| 378 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) >= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); /* induced suffix must be type L */ |
| 379 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { /* induced SA-value in new bucket c0 */ |
| 380 | B[c1] = bb; /* store current end in old bucket */ |
| 381 | bb = B[c1 = c0]; /* go to position in new bucket */ |
| 382 | } |
| 383 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < bb); /* can only induce to the right */ |
| 384 | LastW[c0] = j; /* store last written L-suffix for every bucket */ |
| 385 | SA[bb] = ((0 < j) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) < c0)) ? ~j : j; |
| 386 | |
| 387 | /* Variant 3: use stack: */ |
| 388 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(lcp >= 0); /* lcp already computed */ |
| 389 | while (lcp <= MinStack[stack_end]) stack_end -= 2; /* pop from stack */ |
| 390 | MinStack[++stack_end] = i; /* push position on stack */ |
| 391 | MinStack[++stack_end] = lcp; /* push lcp-value */ |
| 392 | |
| 393 | start = LastOcc[TranslateSigma[c0]] + 1; /* start of query */ |
| 394 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(stack_end-3 >= 0); /* stopper (-1) and last (i) are on stack */ |
| 395 | end = stack_end - 3; |
| 396 | while (start <= MinStack[end]) end -= 2; /* search until smaller element found */ |
| 397 | if (bb == D[c0]) LCP[bb] = 0; /* store 0 at bucket beginnings */ |
| 398 | else LCP[bb] = MinStack[end+3] + 1; /* induce LCP-value! */ |
| 399 | |
| 400 | LastOcc[TranslateSigma[c0]] = i; /* store origin of last occurrence of c0 */ |
| 401 | ++bb; /* advance in bucket */ |
| 402 | } |
| 403 | else { /* don't induce, but update stack with LCP[i] */ |
| 404 | lcp = LCP[i]; /* get current LCP-value */ |
| 405 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(lcp != -1); /* -1 only for S*, but we induce from S* */ |
| 406 | if (lcp >= 0) { /* check if already computed */ |
| 407 | while (lcp <= MinStack[stack_end]) stack_end -= 2; /* pop from stack */ |
| 408 | MinStack[++stack_end] = i; /* push position on stack */ |
| 409 | MinStack[++stack_end] = lcp; /* push lcp-value */ |
| 410 | } |
| 411 | } |
| 412 | if (stack_end > stack_size) { /* re-adjust stack: */ |
| 413 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *LastOccCopy; /* Copy of LastOcc */ |
| 414 | if ((LastOccCopy = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(sigma, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } |
| 415 | memcpycxx . . $ memcpy(cc817cb175f282d).(LastOccCopy, LastOcc, sigma*sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)); |
| 416 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(LastOccCopy, sigma, sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!), int_cmpcxx . . $ int_cmp(9148c8c3ff42c9d8).); |
| 417 | |
| 418 | end = 1; |
| 419 | for (j = 0, l=2; j < sigma; ++j) { |
| 420 | start = LastOccCopy[j] + 1; /* start of next largest query */ |
| 421 | if (start > MinStack[end-1]) { /* otherwise correct element already taken */ |
| 422 | while (l < stack_end && start > MinStack[l]) l += 2; |
| 423 | if (l > stack_end) break; |
| 424 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(l < stack_end); |
| 425 | MinStack[++end] = MinStack[l]; /* take first element >= start */ |
| 426 | MinStack[++end] = MinStack[l+1]; |
| 427 | } |
| 428 | } |
| 429 | stack_end = end; |
| 430 | freecxx . . $ free(5d22bdacc48458e8).(LastOccCopy); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /* compute SAs and LCPl */ |
| 435 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 436 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 437 | for (i = 0; i < sigma; ++i) LastOcc[i] = n-1; /* init with impossible values */ |
| 438 | MinStack[0] = n; MinStack[1] = -1; /* (pos, LCP-value) */ |
| 439 | stack_end = 1; |
| 440 | |
| 441 | for(i = n - 1, bb = B[c1 = 0]; 0 <= i; --i) { |
| 442 | lcp = LCP[i]; |
| 443 | if (0 < i && lcp < 0 && LCP[i-1] >= 0) { /* calculate LCP at L/S-seam */ |
| 444 | j = SA[i]; /* go to suffix */ |
| 445 | if (j < 0) j = ~j; /* entry in SA could be negative => adjust */ |
| 446 | l = SA[i-1]; /* go to lex. previous suffix */ |
| 447 | if (l < 0) l = ~l; /* entry in SA could be negative => adjust */ |
| 448 | lcp = 0; |
| 449 | while (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j+lcp) == chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(l+lcp)) lcp++; /* naive LCP-computation (overall linear!) */ |
| 450 | LCP[i] = lcp; /* this time set LCP-value at seam */ |
| 451 | } |
| 452 | if(0 < (j = SA[i])) { /* induce SA and LCP */ |
| 453 | --j; /* go to suffix T[SA[i]-1] (to be induced) */ |
| 454 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) <= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); /* must be type S */ |
| 455 | if((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)) != c1) { |
| 456 | B[c1] = bb; bb = B[c1 = c0]; /* switch bucket */ |
| 457 | } |
| 458 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(bb <= i); /* induced suffix must be placed to the left of i */ |
| 459 | SA[--bb] = ((j == 0) || (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) > c0)) ? ~j : j; /* continue if type L */ |
| 460 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(c0+1<k); /* we cannot induce into the last bucket */ |
| 461 | |
| 462 | /* search MinStack: */ |
| 463 | start = LastOcc[TranslateSigma[c0]]; /* end of query */ |
| 464 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(stack_end-1 >= 0); /* stopper (-1) is on stack */ |
| 465 | end = stack_end - 1; |
| 466 | while (start >= MinStack[end]) end -= 2; /* search until smaller element found */ |
| 467 | if (bb+1 == D[c0+1]) LCP[bb+1] = 0; /* store 0 at bucket beginnings */ |
| 468 | else LCP[bb+1] = MinStack[end+3] + 1; /* induce LCP-value! */ |
| 469 | if (bb+1 == i) lcp = LCP[i]; /* update if inducing changed my LCP-value */ |
| 470 | LastOcc[TranslateSigma[c0]] = i; /* store origin of last occurrence of c0 */ |
| 471 | } else { /* don't induce */ |
| 472 | SA[i] = ~j; |
| 473 | } |
| 474 | /* update MinStack: */ |
| 475 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(lcp >= 0); /* LCP must already have been computed */ |
| 476 | while ((lcp <= MinStack[stack_end]) && (stack_end >= 0)) stack_end -= 2; /* pop from stack */ |
| 477 | MinStack[++stack_end] = i; /* push position on stack */ |
| 478 | MinStack[++stack_end] = lcp; /* push lcp-value */ |
| 479 | |
| 480 | if (stack_end > stack_size) { /* re-adjust stack: */ |
| 481 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *LastOccCopy; /* Copy of LastOcc */ |
| 482 | if ((LastOccCopy = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(sigma, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { exitcxx . . $ exit(3ca292c338df9bb3).(-1); } |
| 483 | memcpycxx . . $ memcpy(cc817cb175f282d).(LastOccCopy, LastOcc, sigma*sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)); |
| 484 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(LastOccCopy, sigma, sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!), int_cmpcxx . . $ int_cmp(9148c8c3ff42c9d8).); |
| 485 | |
| 486 | end = 1; |
| 487 | for (j = sigma-1, l=2; j >= 0; --j) { |
| 488 | start = LastOccCopy[j]; /* start of next largest query */ |
| 489 | if (start < MinStack[end-1]) { /* otherwise correct element already taken */ |
| 490 | while (l < stack_end && start < MinStack[l]) l += 2; |
| 491 | if (l > stack_end) break; |
| 492 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(l < stack_end); |
| 493 | MinStack[++end] = MinStack[l]; /* take first element >= start */ |
| 494 | MinStack[++end] = MinStack[l+1]; |
| 495 | } |
| 496 | } |
| 497 | stack_end = end; |
| 498 | freecxx . . $ free(5d22bdacc48458e8).(LastOccCopy); |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | freecxx . . $ free(5d22bdacc48458e8).(D); |
| 503 | freecxx . . $ free(5d22bdacc48458e8).(LastOcc); |
| 504 | freecxx . . $ free(5d22bdacc48458e8).(MinStack); |
| 505 | freecxx . . $ free(5d22bdacc48458e8).(TranslateSigma); |
| 506 | freecxx . . $ free(5d22bdacc48458e8).(LastW); |
| 507 | } |
| 508 | |
| 509 | static |
| 510 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! |
| 511 | computeBWTcxx . . $ computeBWT(9c8b733cfa8750ae).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 512 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *B, |
| 513 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs) { |
| 514 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *b, i, j, pidx = -1; |
| 515 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; |
| 516 | /* compute SAl */ |
| 517 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 518 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 0); /* find starts of buckets */ |
| 519 | j = n - 1; |
| 520 | b = SA + B[c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)]; |
| 521 | *b++ = ((0 < j) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) < c1)) ? ~j : j; |
| 522 | for(i = 0; i < n; ++i) { |
| 523 | if(0 < (j = SA[i])) { |
| 524 | --j; |
| 525 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) >= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 526 | SA[i] = ~((sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)(c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j))); |
| 527 | if(c0 != c1) { B[c1] = b - SA; b = SA + B[c1 = c0]; } |
| 528 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < (b - SA)); |
| 529 | *b++ = ((0 < j) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) < c1)) ? ~j : j; |
| 530 | } else if(j != 0) { |
| 531 | SA[i] = ~j; |
| 532 | } |
| 533 | } |
| 534 | /* compute SAs */ |
| 535 | if(C == B) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 536 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 537 | for(i = n - 1, b = SA + B[c1 = 0]; 0 <= i; --i) { |
| 538 | if(0 < (j = SA[i])) { |
| 539 | --j; |
| 540 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j) <= chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)); |
| 541 | SA[i] = (c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j)); |
| 542 | if(c0 != c1) { B[c1] = b - SA; b = SA + B[c1 = c0]; } |
| 543 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((b - SA) <= i); |
| 544 | *--b = ((0 < j) && (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1) > c1)) ? ~((sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j - 1)) : j; |
| 545 | } else if(j != 0) { |
| 546 | SA[i] = ~j; |
| 547 | } else { |
| 548 | pidx = i; |
| 549 | } |
| 550 | } |
| 551 | return pidx; |
| 552 | } |
| 553 | |
| 554 | /* find the suffix array SA of T[0..n-1] in {0..255}^n */ |
| 555 | static sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! sais_maincxx . . $ sais_main(f8a80243c14ed8a7).(const void *T, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *SA, |
| 556 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *LCP, |
| 557 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! fs, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! n, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! k, int cs, |
| 558 | sais_bool_typecxx . . $ `contrib/sais-lite-lcp/sais.c:42:9`! isbwt, |
| 559 | sais_bool_typecxx . . $ `contrib/sais-lite-lcp/sais.c:42:9`! level0) { /* level0 = 1 iff recursion depth is 0 */ |
| 560 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! *C, *B, *D, *RA, *PLCP, *PHI, *DELTA, *b; |
| 561 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! i, j, m, /* m: number of S*-suffixes */ |
| 562 | p, q, t, name, pidx = 0, newfs; |
| 563 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! c0, c1; |
| 564 | unsigned int flags; |
| 565 | |
| 566 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((T != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (SA != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 567 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((0 <= fs) && (0 < n) && (1 <= k)); |
| 568 | |
| 569 | if(k <= MINBUCKETSIZEcxx . . $ `contrib/sais-lite-lcp/sais.c:38:10`!) { |
| 570 | if((C = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { return -2; } |
| 571 | if(k <= fs) { |
| 572 | B = SA + (n + fs - k); |
| 573 | flags = 1; |
| 574 | } else { |
| 575 | if((B = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(C, k, sais_index_type); return -2; } |
| 576 | flags = 3; |
| 577 | } |
| 578 | } else if(k <= fs) { |
| 579 | C = SA + (n + fs - k); |
| 580 | if(k <= (fs - k)) { |
| 581 | B = C - k; |
| 582 | flags = 0; |
| 583 | } else if(k <= (MINBUCKETSIZEcxx . . $ `contrib/sais-lite-lcp/sais.c:38:10`! * 4)) { |
| 584 | if((B = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { return -2; } |
| 585 | flags = 2; |
| 586 | } else { |
| 587 | B = C; |
| 588 | flags = 8; |
| 589 | } |
| 590 | } else { |
| 591 | if((C = B = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { return -2; } |
| 592 | flags = 4 | 8; |
| 593 | } |
| 594 | if((n <= SAIS_LMSSORT2_LIMITcxx . . $ `contrib/sais-lite-lcp/sais.c:43:9`!) && (2 <= (n / k))) { |
| 595 | if(flags & 1) { flags |= ((k * 2) <= (fs - k)) ? 32 : 16; } |
| 596 | else if((flags == 0) && ((k * 2) <= (fs - k * 2))) { flags |= 32; } |
| 597 | } |
| 598 | |
| 599 | /* stage 1: reduce the problem by at least 1/2 |
| 600 | sort all the LMS-substrings */ |
| 601 | getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 602 | |
| 603 | for(i = 0; i < n; ++i) { SA[i] = 0; } |
| 604 | b = &t; i = n - 1; j = n; m = 0; c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(n - 1); |
| 605 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) >= c1)); |
| 606 | for(; 0 <= i;) { |
| 607 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) <= c1)); |
| 608 | if(0 <= i) { |
| 609 | *b = j; |
| 610 | b = SA + --B[c1]; j = i; ++m; |
| 611 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) >= c1)); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | if(1 < m) { |
| 616 | if(flags & (16 | 32)) { |
| 617 | if(flags & 16) { |
| 618 | if((D = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k * 2, sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 619 | if(flags & (1 | 4)) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(C, k, sais_index_type); } |
| 620 | if(flags & 2) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(B, k, sais_index_type); } |
| 621 | return -2; |
| 622 | } |
| 623 | } else { |
| 624 | D = B - k * 2; |
| 625 | } |
| 626 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((j + 1) < n); |
| 627 | ++B[chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j + 1)]; |
| 628 | for(i = 0, j = 0; i < k; ++i) { |
| 629 | j += C[i]; |
| 630 | if(B[i] != j) { assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(SA[B[i]] != 0); SA[B[i]] += n; } |
| 631 | D[i] = D[i + k] = 0; |
| 632 | } |
| 633 | LMSsort2cxx . . $ LMSsort2(f8af3e29b49b9639).(T, SA, C, B, D, n, k, cs); |
| 634 | name = LMSpostproc2cxx . . $ LMSpostproc2(f6a32f5afd6954c).(SA, n, m); |
| 635 | if(flags & 16) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(D, k * 2, sais_index_type); } |
| 636 | } else { |
| 637 | LMSsort1cxx . . $ LMSsort1(e1de81619e7ca8a1).(T, SA, C, B, n, k, cs); |
| 638 | name = LMSpostproc1cxx . . $ LMSpostproc1(b4f87ad3855b455b).(T, SA, n, m, cs); |
| 639 | } |
| 640 | } else if (m == 1) { /* only one S*-suffix => set immediately */ |
| 641 | *b = j + 1; /* set entry in SA */ |
| 642 | if (level0) { LCP[b-SA] = -1; } /* mark first (=only) S*-suffix in bucket */ |
| 643 | name = 1; |
| 644 | } else { |
| 645 | name = 0; |
| 646 | } |
| 647 | |
| 648 | /* stage 2: solve the reduced problem |
| 649 | recurse if names are not yet unique */ |
| 650 | if(name < m) { |
| 651 | if(flags & 4) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(C, k, sais_index_type); } |
| 652 | if(flags & 2) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(B, k, sais_index_type); } |
| 653 | newfs = (n + fs) - (m * 2); |
| 654 | if((flags & (1 | 4 | 8)) == 0) { |
| 655 | if((k + name) <= newfs) { newfs -= k; } |
| 656 | else { flags |= 8; } |
| 657 | } |
| 658 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((n >> 1) <= (newfs + m)); |
| 659 | RA = SA + m + newfs; |
| 660 | for(i = m + (n >> 1) - 1, j = m - 1; m <= i; --i) { |
| 661 | if(SA[i] != 0) { |
| 662 | RA[j--] = SA[i] - 1; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | if(sais_maincxx . . $ sais_main(f8a80243c14ed8a7).(RA, SA, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, newfs, m, name, sizeof(sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`!), 0, 0) != 0) { |
| 667 | if(flags & 1) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(C, k, sais_index_type); } |
| 668 | return -2; |
| 669 | } |
| 670 | |
| 671 | /* (re)compute starting positions of S*-suffixes (stored in RA): */ |
| 672 | i = n - 1; j = m - 1; c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(n - 1); |
| 673 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) >= c1)); |
| 674 | for(; 0 <= i;) { |
| 675 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) <= c1)); |
| 676 | if(0 <= i) { |
| 677 | RA[j--] = i + 1; |
| 678 | do { c1 = c0; } while((0 <= --i) && ((c0 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i)) >= c1)); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | /* construct LCP for S*-suffixes: */ |
| 683 | /* PHI: "to whom I want to be compared" (pos. in T) */ |
| 684 | /* DELTA: "distance (in T) to next S*" (in PHI-order) */ |
| 685 | if (level0) { |
| 686 | if (m < n/3) { /* hence we can store PHI and DELTA interleaved */ |
| 687 | PHI = LCP+m; /* use space in LCP-array for PHI and DELTA */ |
| 688 | RA[m] = n; /* stopper */ |
| 689 | j = SA[0]; /* j stores SA[i-1] in the following loop */ |
| 690 | PHI[j<<1] = n-1; /* set PHI[SA[0]] to $ (causes mismatch in char. comp.) */ |
| 691 | PHI[(j<<1)+1] = 0; /* set DELTA */ |
| 692 | for (i = 1; i < m; ++i) { |
| 693 | q = SA[i]; /* text position */ |
| 694 | p = q<<1; /* for interleaving */ |
| 695 | PHI[p]=RA[j]; /* set PHI-array */ |
| 696 | PHI[p+1]=RA[j+1]-RA[j]; /* set DELTA */ |
| 697 | j = q; /* store for next loop iteration */ |
| 698 | } |
| 699 | |
| 700 | PLCP = PHI; /* overwrite DELTA in following loop */ |
| 701 | p = 0; /* guaranteed LCP-value */ |
| 702 | j = 0; /* position in PLCP and RA */ |
| 703 | for (i = 0; i < n; ++i) { |
| 704 | if (i == RA[j]) { |
| 705 | sais_index_typecxx . . $ `contrib/sais-lite-lcp/sais.c:41:9`! twoj = j << 1; |
| 706 | if (p < 0) p = 0; |
| 707 | while (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i+p) == chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(PHI[twoj]+p)) ++p; |
| 708 | t = PHI[twoj+1]; /* accesses DELTA-value */ |
| 709 | q = RA[j+1]-RA[j]; /* length difference */ |
| 710 | PLCP[twoj] = p; /* overwrite PHI with PLCP */ |
| 711 | ++j; |
| 712 | p -= (t > q) ? t : q; /* decrease p by larger of t and q */ |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | /* translate PLCP-values to SA-order: */ |
| 717 | for (j = 0; j < m; ++j) LCP[j] = PLCP[SA[j]<<1]; |
| 718 | } |
| 719 | else { /* non-interleaved */ |
| 720 | PHI = LCP; /* use space in LCP-array for PHI */ |
| 721 | DELTA = LCP+m; /* because we compute only m < n/2 values, this is valid */ |
| 722 | RA[m] = n; /* stopper */ |
| 723 | j = SA[0]; /* j stores SA[i-1] in the following loop */ |
| 724 | PHI[j] = n-1; /* set PHI[SA[0]] to $ (causes mismatch in char. comp.) */ |
| 725 | DELTA[j] = 0; |
| 726 | for (i = 1; i < m; ++i) { |
| 727 | q = SA[i]; /* text position */ |
| 728 | PHI[q]=RA[j]; /* set PHI-array */ |
| 729 | DELTA[q]=RA[j+1]-RA[j]; /* set DELTA */ |
| 730 | j = q; /* store for next loop iteration */ |
| 731 | } |
| 732 | |
| 733 | PLCP = DELTA; /* overwrite DELTA in following loop */ |
| 734 | p = 0; /* guaranteed LCP-value */ |
| 735 | j = 0; /* position in PLCP and RA */ |
| 736 | for (i = 0; i < n; ++i) { |
| 737 | if (i == RA[j]) { |
| 738 | if (p < 0) p = 0; |
| 739 | while (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(i+p) == chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(PHI[j]+p)) ++p; |
| 740 | t = PLCP[j]; /* accesses DELTA-value */ |
| 741 | q = RA[j+1]-RA[j]; /* length difference */ |
| 742 | PLCP[j++] = p; |
| 743 | p -= (t > q) ? t : q; /* decrease p by larger of t and q */ |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | /* translate PLCP-values to SA-order: */ |
| 748 | for (j = 0; j < m; ++j) LCP[j] = PLCP[SA[j]]; |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /* translate indices in RA to indices in T: */ |
| 753 | for(i = 0; i < m; ++i) SA[i] = RA[SA[i]]; |
| 754 | |
| 755 | if(flags & 4) { |
| 756 | if((C = B = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, int)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { return -2; } |
| 757 | } |
| 758 | if(flags & 2) { |
| 759 | if((B = SAIS_MYMALLOCcxx . . $ `contrib/sais-lite-lcp/sais.c:45:9`!(k, int)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 760 | if(flags & 1) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(C, k, sais_index_type); } |
| 761 | return -2; |
| 762 | } |
| 763 | } |
| 764 | } /* endif (name < m) */ |
| 765 | else if (level0) { /* this should only occur for small or pathetic inputs */ |
| 766 | /* all names unique => computing LCP for *S naively takes linear time */ |
| 767 | /*printf("*** computing LCP naively..."); */ |
| 768 | j = SA[0]; /* j = SA[i-1] in the following loop */ |
| 769 | for (i = 1; i < m; ++i) { |
| 770 | p = 0; |
| 771 | while (chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(SA[i]+p) == chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(j+p)) p++; |
| 772 | LCP[i] = p; |
| 773 | j = SA[i]; |
| 774 | } |
| 775 | /*printf("done.\n"); */ |
| 776 | } |
| 777 | |
| 778 | /* stage 3: induce the result for the original problem */ |
| 779 | if(flags & 8) { getCountscxx . . $ getCounts(210643f1ab60349f).(T, C, n, k, cs); } |
| 780 | /* put all S*-suffixes (and their LCP-values) into their buckets */ |
| 781 | if(1 < m) { /* otherwise SA (and LCP) is already correct */ |
| 782 | getBucketscxx . . $ getBuckets(d6479f6d0506030a).(C, B, k, 1); /* find ends of buckets */ |
| 783 | i = m - 1, j = n, p = SA[m - 1], c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(p); |
| 784 | if (level0) { |
| 785 | newfs = LCP[m-1]; /* newfs stores LCP[i] in the following loop */ |
| 786 | do { |
| 787 | q = B[c0 = c1]; |
| 788 | while(q < j) { |
| 789 | SA[--j] = 0; LCP[j] = -2; /* set remaining entries in old bucket to 0/-2 */ |
| 790 | } |
| 791 | |
| 792 | do { /* step through bucket c0 and write S*-suffixes to SA: */ |
| 793 | SA[--j] = p; LCP[j] = newfs; |
| 794 | if(--i < 0) break; |
| 795 | newfs = LCP[i]; p = SA[i]; |
| 796 | } while((c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(p)) == c0); |
| 797 | /*assert(LCP[j]==0); *//* first S*-suffix in bucket must have LCP-value 0 */ |
| 798 | LCP[j] = -1; /* mark first S*-suffix in every bucket */ |
| 799 | } while(0 <= i); |
| 800 | while(0 < j) { |
| 801 | SA[--j] = 0; LCP[j] = -2; /* set remaining entries in smallest buckets to 0/-2 */ |
| 802 | } |
| 803 | } |
| 804 | else { |
| 805 | do { |
| 806 | q = B[c0 = c1]; |
| 807 | while(q < j) SA[--j] = 0; /* set remaining entries in old bucket to 0 */ |
| 808 | do { /* step through bucket c0 */ |
| 809 | SA[--j] = p; |
| 810 | if(--i < 0) break; |
| 811 | p = SA[i]; |
| 812 | } while((c1 = chrcxx . . $ `contrib/sais-lite-lcp/sais.c:47:9`!(p)) == c0); |
| 813 | } while(0 <= i); |
| 814 | while(0 < j) SA[--j] = 0; /* set remaining entries in 1st bucket to 0 */ |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | if(isbwt == 0) { |
| 819 | if (level0) induceSAandLCPcxx . . $ induceSAandLCP(f8af3e29b49b9639).(T, SA, LCP, C, B, n, k, cs); |
| 820 | else induceSAcxx . . $ induceSA(e1de81619e7ca8a1).(T, SA, C, B, n, k, cs); |
| 821 | } |
| 822 | else { pidx = computeBWTcxx . . $ computeBWT(9c8b733cfa8750ae).(T, SA, C, B, n, k, cs); } |
| 823 | if(flags & (1 | 4)) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(C, k, sais_index_type); } |
| 824 | if(flags & 2) { SAIS_MYFREEcxx . . $ `contrib/sais-lite-lcp/sais.c:46:9`!(B, k, sais_index_type); } |
| 825 | |
| 826 | return pidx; |
| 827 | } |
| 828 | |
| 829 | /*---------------------------------------------------------------------------*/ |
| 830 | |
| 831 | int |
| 832 | saiscxx . . $ sais(108333d6121efdd0).(const unsigned char *T, int *SA, int* LCP, int n) { |
| 833 | if((T == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (SA == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (LCP == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n < 0)) { return -1; } |
| 834 | if(n <= 1) { if(n == 1) { SA[0] = 0; LCP[0] = 0; } return 0; } |
| 835 | return sais_maincxx . . $ sais_main(f8a80243c14ed8a7).(T, SA, LCP, 0, n, UCHAR_SIZEcxx . . $ `contrib/sais-lite-lcp/sais.c:35:10`!, sizeof(unsigned char), 0,1); |
| 836 | } |
| 837 | |
| 838 | int |
| 839 | sais_intcxx . . $ sais_int(e09f29e6c15f18ae).(const int *T, int *SA, int n, int k) { |
| 840 | if((T == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (SA == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n < 0) || (k <= 0)) { return -1; } |
| 841 | if(n <= 1) { if(n == 1) { SA[0] = 0; } return 0; } |
| 842 | return sais_maincxx . . $ sais_main(f8a80243c14ed8a7).(T, SA, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, n, k, sizeof(int), 0, 1); |
| 843 | } |
| 844 | |
| 845 | int |
| 846 | sais_bwtcxx . . $ sais_bwt(1435117beca81d1a).(const unsigned char *T, unsigned char *U, int *A, int n) { |
| 847 | int i, pidx; |
| 848 | if((T == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (U == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (A == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n < 0)) { return -1; } |
| 849 | if(n <= 1) { if(n == 1) { U[0] = T[0]; } return n; } |
| 850 | pidx = sais_maincxx . . $ sais_main(f8a80243c14ed8a7).(T, A, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, n, UCHAR_SIZEcxx . . $ `contrib/sais-lite-lcp/sais.c:35:10`!, sizeof(unsigned char), 1,1); |
| 851 | if(pidx < 0) { return pidx; } |
| 852 | U[0] = T[n - 1]; |
| 853 | for(i = 0; i < pidx; ++i) { U[i + 1] = (unsigned char)A[i]; } |
| 854 | for(i += 1; i < n; ++i) { U[i] = (unsigned char)A[i]; } |
| 855 | pidx += 1; |
| 856 | return pidx; |
| 857 | } |
| 858 | |
| 859 | int |
| 860 | sais_int_bwtcxx . . $ sais_int_bwt(59e8fc5fef160b3f).(const int *T, int *U, int *A, int n, int k) { |
| 861 | int i, pidx; |
| 862 | if((T == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (U == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (A == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n < 0) || (k <= 0)) { return -1; } |
| 863 | if(n <= 1) { if(n == 1) { U[0] = T[0]; } return n; } |
| 864 | pidx = sais_maincxx . . $ sais_main(f8a80243c14ed8a7).(T, A, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, n, k, sizeof(int), 1,1); |
| 865 | if(pidx < 0) { return pidx; } |
| 866 | U[0] = T[n - 1]; |
| 867 | for(i = 0; i < pidx; ++i) { U[i + 1] = A[i]; } |
| 868 | for(i += 1; i < n; ++i) { U[i] = A[i]; } |
| 869 | pidx += 1; |
| 870 | return pidx; |
| 871 | } |