| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import sys |
| 4 |
from math import floor |
| 5 |
|
| 6 |
Mlen = 761 |
| 7 |
if len(sys.argv) > 1: Mlen = int(sys.argv[1]) |
| 8 |
|
| 9 |
m0 = 4591 |
| 10 |
if len(sys.argv) > 2: m0 = int(sys.argv[2]) |
| 11 |
|
| 12 |
m1 = m0 |
| 13 |
if len(sys.argv) > 3: m1 = int(sys.argv[3]) |
| 14 |
# M is Mlen-1 copies of m0, plus 1 copy of m1 |
| 15 |
|
| 16 |
offset = m0//2 |
| 17 |
if len(sys.argv) > 4: offset = int(sys.argv[4]) |
| 18 |
|
| 19 |
div3 = False |
| 20 |
if len(sys.argv) > 5: div3 = sys.argv[5]=='True' |
| 21 |
|
| 22 |
todo = 'R0' |
| 23 |
top = 16384 |
| 24 |
|
| 25 |
print('/* auto-generated; do not edit */') |
| 26 |
print('/* 20250302 djb: port to -Wc++-compat */') |
| 27 |
print('/* 20240812 djb: more cryptoint usage */') |
| 28 |
print('') |
| 29 |
print('#include <immintrin.h>') |
| 30 |
print('#include "crypto_decode.h"') |
| 31 |
print('#include "crypto_int16.h"') |
| 32 |
print('#include "crypto_int32.h"') |
| 33 |
print('#define int16 crypto_int16') |
| 34 |
print('#define int32 crypto_int32') |
| 35 |
|
| 36 |
print(""" |
| 37 |
static inline int16 mullo(int16 x,int16 y) |
| 38 |
{ |
| 39 |
return x*y; |
| 40 |
} |
| 41 |
|
| 42 |
static inline int16 mulhi(int16 x,int16 y) |
| 43 |
{ |
| 44 |
return (x*(int32)y)>>16; |
| 45 |
} |
| 46 |
|
| 47 |
static inline __m256i add(__m256i x,__m256i y) |
| 48 |
{ |
| 49 |
return _mm256_add_epi16(x,y); |
| 50 |
} |
| 51 |
|
| 52 |
static inline __m256i sub(__m256i x,__m256i y) |
| 53 |
{ |
| 54 |
return _mm256_sub_epi16(x,y); |
| 55 |
} |
| 56 |
|
| 57 |
static inline __m256i shiftleftconst(__m256i x,int16 y) |
| 58 |
{ |
| 59 |
return _mm256_slli_epi16(x,y); |
| 60 |
} |
| 61 |
|
| 62 |
static inline __m256i signedshiftrightconst(__m256i x,int16 y) |
| 63 |
{ |
| 64 |
return _mm256_srai_epi16(x,y); |
| 65 |
} |
| 66 |
|
| 67 |
static inline __m256i subconst(__m256i x,int16 y) |
| 68 |
{ |
| 69 |
return sub(x,_mm256_set1_epi16(y)); |
| 70 |
} |
| 71 |
|
| 72 |
static inline __m256i mulloconst(__m256i x,int16 y) |
| 73 |
{ |
| 74 |
return _mm256_mullo_epi16(x,_mm256_set1_epi16(y)); |
| 75 |
} |
| 76 |
|
| 77 |
static inline __m256i mulhiconst(__m256i x,int16 y) |
| 78 |
{ |
| 79 |
return _mm256_mulhi_epi16(x,_mm256_set1_epi16(y)); |
| 80 |
} |
| 81 |
|
| 82 |
static inline __m256i ifgesubconst(__m256i x,int16 y) |
| 83 |
{ |
| 84 |
__m256i y16 = _mm256_set1_epi16(y); |
| 85 |
__m256i top16 = _mm256_set1_epi16(y-1); |
| 86 |
return sub(x,_mm256_cmpgt_epi16(x,top16) & y16); |
| 87 |
} |
| 88 |
|
| 89 |
static inline __m256i ifnegaddconst(__m256i x,int16 y) |
| 90 |
{ |
| 91 |
return add(x,signedshiftrightconst(x,15) & _mm256_set1_epi16(y)); |
| 92 |
} |
| 93 |
""") |
| 94 |
|
| 95 |
print('void crypto_decode(void *v,const unsigned char *s)') |
| 96 |
print('{') |
| 97 |
print(' int16 *%s = (int16 *) v;' % todo) |
| 98 |
|
| 99 |
tmparrays = None |
| 100 |
|
| 101 |
layer = 1 |
| 102 |
x = Mlen |
| 103 |
while x > 1: |
| 104 |
x = (x+1)//2 |
| 105 |
if tmparrays == None: |
| 106 |
tmparrays = 'int16 ' |
| 107 |
else: |
| 108 |
tmparrays += ',' |
| 109 |
tmparrays += 'R%d[%d]' % (layer,x) |
| 110 |
layer += 1 |
| 111 |
|
| 112 |
if tmparrays: |
| 113 |
print(' %s;' % tmparrays) |
| 114 |
|
| 115 |
print(' long long i;') |
| 116 |
print(' int16 a0,a1,a2;') |
| 117 |
print(' __m256i A0,A1,A2,S0,S1,B0,B1,C0,C1;') |
| 118 |
|
| 119 |
def poke(todo,pos,contents): |
| 120 |
if todo == 'R0' and div3: |
| 121 |
return '%s[%s] = 3*%s%+d;' % (todo,pos,contents,-offset) |
| 122 |
if todo == 'R0' and offset != 0: |
| 123 |
return '%s[%s] = %s%+d;' % (todo,pos,contents,-offset) |
| 124 |
return '%s[%s] = %s;' % (todo,pos,contents) |
| 125 |
|
| 126 |
def mulmoddata(c,q): |
| 127 |
y = (c<<16)%q |
| 128 |
if y*2 >= q: y -= q |
| 129 |
|
| 130 |
t = 0 |
| 131 |
u = q |
| 132 |
while not u&1: |
| 133 |
t += 1 |
| 134 |
u >>= 1 |
| 135 |
|
| 136 |
uinv = pow(u,16383,65536) |
| 137 |
if uinv>=32768: uinv -= 65536 |
| 138 |
assert (u*uinv)%65536 == 1 |
| 139 |
|
| 140 |
z = (y-(c<<16))>>t |
| 141 |
z = (z*uinv)%65536 |
| 142 |
if z >= 32768: z -= 65536 |
| 143 |
assert (z*u-((y-(c<<16))>>t))%(2**16) == 0 |
| 144 |
|
| 145 |
return y,t,u,uinv,z |
| 146 |
|
| 147 |
def inner(indent,reading,inpos,m0,m1,bytes,outpos0,outpos1): |
| 148 |
stanza = '' |
| 149 |
|
| 150 |
y,t,u,uinv,z = mulmoddata(256,m0) |
| 151 |
|
| 152 |
stanza += indent + 'a2 = a0 = %s[%s];\n' % (reading,inpos) |
| 153 |
a0lower,a0upper = 0,1<<14 |
| 154 |
|
| 155 |
for loop in range(bytes): |
| 156 |
if y > 0: |
| 157 |
a0lower,a0upper = a0lower*y,a0upper*y |
| 158 |
else: |
| 159 |
a0lower,a0upper = a0upper*y,a0lower*y |
| 160 |
a0lower,a0upper = a0lower-(m0<<15),a0upper+(m0<<15) |
| 161 |
a0lower,a0upper = a0lower>>16,a0upper>>16 |
| 162 |
stanza += indent + 'a0 = mulhi(a0,%d)-mulhi(mullo(a0,%d),%d); /* %d...%d */\n' % (y,z,m0,a0lower,a0upper) |
| 163 |
|
| 164 |
a0upper += 255 |
| 165 |
stanza += indent + 'a0 += s[%d*i+%d]; /* %d...%d */\n' % (bytes,bytes-1-loop,a0lower,a0upper) |
| 166 |
|
| 167 |
if a0upper >= 2*m0: |
| 168 |
y1,t1,u1,uinv1,z1 = mulmoddata(1,m0) |
| 169 |
if y1 > 0: |
| 170 |
a0lower,a0upper = a0lower*y1,a0upper*y1 |
| 171 |
else: |
| 172 |
a0lower,a0upper = a0upper*y1,a0lower*y1 |
| 173 |
a0lower,a0upper = a0lower-(m0<<15),a0upper+(m0<<15) |
| 174 |
a0lower,a0upper = a0lower>>16,a0upper>>16 |
| 175 |
stanza += indent + 'a0 = mulhi(a0,%d)-mulhi(mullo(a0,%d),%d); /* %d...%d */\n' % (y1,z1,m0,a0lower,a0upper) |
| 176 |
|
| 177 |
while a0upper >= m0: |
| 178 |
a0lower,a0upper = a0lower-m0,a0upper-m0 |
| 179 |
stanza += indent + 'a0 -= %d; /* %d..>%d */\n' % (m0,a0lower,a0upper) |
| 180 |
|
| 181 |
while a0lower < 0: |
| 182 |
a0lower,a0upper = min(0,a0lower+m0),max(m0-1,a0upper) |
| 183 |
stanza += indent + 'a0 += %d&crypto_int16_negative_mask(a0); /* %d...%d */\n' % (m0,a0lower,a0upper) |
| 184 |
|
| 185 |
if bytes == 0: |
| 186 |
stanza += indent + 'a1 = (a2-a0)>>%d;\n' % t |
| 187 |
|
| 188 |
elif bytes == 1: |
| 189 |
if t == 0: |
| 190 |
stanza += indent + 'a1 = (a2<<8)+s[i]-a0;\n' |
| 191 |
elif t == 8: |
| 192 |
stanza += indent + 'a1 = a2+((s[i]-a0)>>8);\n' |
| 193 |
elif t < 8: |
| 194 |
stanza += indent + 'a1 = (a2<<%d)+((s[i]-a0)>>%d);\n' % (8-t,t) |
| 195 |
else: |
| 196 |
stanza += indent + 'a1 = (a2+((s[i]-a0)>>8))>>%d;\n' % t-8 |
| 197 |
|
| 198 |
else: |
| 199 |
assert bytes == 2 |
| 200 |
if t == 0: |
| 201 |
stanza += indent + 'a1 = (s[2*i+1]<<8)+s[2*i]-a0;\n' |
| 202 |
elif t == 8: |
| 203 |
stanza += indent + 'a1 = (a2<<8)+s[2*i+1]+((s[2*i]-a0)>>8);\n' |
| 204 |
elif t < 8: |
| 205 |
stanza += indent + 'a1 = (a2<<%d)+(s[2*i+1]<<%d)+((s[2*i]-a0)>>%d);\n' % (16-t,8-t,t) |
| 206 |
else: |
| 207 |
stanza += indent + 'a1 = ((((int32)a2)<<16)+(s[2*i+1]<<8)+s[2*i]-a0)>>%d;\n' % t |
| 208 |
|
| 209 |
stanza += indent + 'a1 = mullo(a1,%d);\n' % uinv |
| 210 |
stanza += '\n' |
| 211 |
stanza += indent + '/* invalid inputs might need reduction mod %d */\n' % m1 |
| 212 |
stanza += indent + 'a1 -= %d;\n' % m1 |
| 213 |
stanza += indent + 'a1 += %d&crypto_int16_negative_mask(a1);\n' % m1 |
| 214 |
stanza += '\n' |
| 215 |
stanza += indent + '%s\n' % poke(todo,outpos0,'a0') |
| 216 |
stanza += indent + '%s\n' % poke(todo,outpos1,'a1') |
| 217 |
|
| 218 |
return stanza |
| 219 |
|
| 220 |
# XXX: caller must ensure that outpos1 is outpos0+1 |
| 221 |
def inner16(indent,reading,inpos,m0,m1,bytes,outpos0,outpos1): |
| 222 |
stanza = '' |
| 223 |
|
| 224 |
y,t,u,uinv,z = mulmoddata(256,m0) |
| 225 |
|
| 226 |
stanza += indent + 'A2 = A0 = _mm256_loadu_si256((__m256i *) &%s[%s]);\n' % (reading,inpos) |
| 227 |
a0lower,a0upper = 0,1<<14 |
| 228 |
|
| 229 |
if bytes == 1: |
| 230 |
stanza += indent + 'S0 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i *) (s+i)));\n' |
| 231 |
|
| 232 |
if bytes == 2: |
| 233 |
stanza += indent + 'S0 = _mm256_loadu_si256((__m256i *) (s+2*i));\n' |
| 234 |
stanza += indent + 'S1 = _mm256_srli_epi16(S0,8);\n' |
| 235 |
stanza += indent + 'S0 &= _mm256_set1_epi16(255);\n' |
| 236 |
|
| 237 |
for loop in reversed(range(bytes)): |
| 238 |
if y > 0: |
| 239 |
a0lower,a0upper = a0lower*y,a0upper*y |
| 240 |
else: |
| 241 |
a0lower,a0upper = a0upper*y,a0lower*y |
| 242 |
a0lower,a0upper = a0lower-(m0<<15),a0upper+(m0<<15) |
| 243 |
a0lower,a0upper = a0lower>>16,a0upper>>16 |
| 244 |
stanza += indent + 'A0 = sub(mulhiconst(A0,%d),mulhiconst(mulloconst(A0,%d),%d)); /* %d...%d */\n' % (y,z,m0,a0lower,a0upper) |
| 245 |
|
| 246 |
a0upper += 255 |
| 247 |
stanza += indent + 'A0 = add(A0,S%d); /* %d...%d */\n' % (loop,a0lower,a0upper) |
| 248 |
|
| 249 |
if a0upper >= 2*m0: |
| 250 |
y1,t1,u1,uinv1,z1 = mulmoddata(1,m0) |
| 251 |
if y1 > 0: |
| 252 |
a0lower,a0upper = a0lower*y1,a0upper*y1 |
| 253 |
else: |
| 254 |
a0lower,a0upper = a0upper*y1,a0lower*y1 |
| 255 |
a0lower,a0upper = a0lower-(m0<<15),a0upper+(m0<<15) |
| 256 |
a0lower,a0upper = a0lower>>16,a0upper>>16 |
| 257 |
stanza += indent + 'A0 = sub(mulhiconst(A0,%d),mulhiconst(mulloconst(A0,%d),%d)); /* %d...%d */\n' % (y1,z1,m0,a0lower,a0upper) |
| 258 |
|
| 259 |
while a0upper >= m0: |
| 260 |
a0lower,a0upper = a0lower-m0,a0upper-m0 |
| 261 |
stanza += indent + 'A0 = subconst(A0,%d); /* %d...%d */\n' % (m0,a0lower,a0upper) |
| 262 |
|
| 263 |
while a0lower < 0: |
| 264 |
a0lower,a0upper = min(0,a0lower+m0),max(m0-1,a0upper) |
| 265 |
stanza += indent + 'A0 = ifnegaddconst(A0,%d); /* %d...%d */\n' % (m0,a0lower,a0upper) |
| 266 |
|
| 267 |
if bytes == 0: |
| 268 |
stanza += indent + 'A1 = signedshiftrightconst(sub(A2,A0),%d);\n' % t |
| 269 |
|
| 270 |
elif bytes == 1: |
| 271 |
if t == 0: |
| 272 |
stanza += indent + 'A1 = add(shiftleftconst(A2,8),sub(S0,A0));\n' |
| 273 |
elif t == 8: |
| 274 |
stanza += indent + 'A1 = add(A2,signedshiftrightconst(sub(S0,A0),8));\n' |
| 275 |
elif t < 8: |
| 276 |
stanza += indent + 'A1 = add(shiftleftconst(A2,%d),signedshiftrightconst(sub(S0,A0),%d));\n' % (8-t,t) |
| 277 |
else: |
| 278 |
raise Exception('shift distances above 8 unimplemented') |
| 279 |
|
| 280 |
else: |
| 281 |
assert bytes == 2 |
| 282 |
if t == 0: |
| 283 |
stanza += indent + 'A1 = add(shiftleftconst(S1,8),sub(S0,A0));\n' |
| 284 |
elif t == 8: |
| 285 |
stanza += indent + 'A1 = add(add(shiftleftconst(A2,8),S1),signedshiftrightconst(sub(S0,A0),8));\n' |
| 286 |
elif t < 8: |
| 287 |
stanza += indent + 'A1 = add(add(shiftleftconst(A2,%d),shiftleftconst(S1,%d)),signedshiftrightconst(sub(S0,A0),%d));\n' % (16-t,8-t,t) |
| 288 |
else: |
| 289 |
raise Exception('shift distances above 8 unimplemented') |
| 290 |
|
| 291 |
stanza += indent + 'A1 = mulloconst(A1,%d);\n' % uinv |
| 292 |
stanza += '\n' |
| 293 |
stanza += indent + '/* invalid inputs might need reduction mod %d */\n' % m1 |
| 294 |
# stanza += indent + 'A1 = subconst(A1,%d);\n' % m1 |
| 295 |
# stanza += indent + 'A1 = ifnegaddconst(A1,%d);\n' % m1 |
| 296 |
stanza += indent + 'A1 = ifgesubconst(A1,%d);\n' % m1 |
| 297 |
stanza += '\n' |
| 298 |
|
| 299 |
if todo == 'R0' and div3: |
| 300 |
stanza += indent + 'A0 = mulloconst(A0,3);\n' |
| 301 |
stanza += indent + 'A1 = mulloconst(A1,3);\n' |
| 302 |
if todo == 'R0' and offset != 0: |
| 303 |
stanza += indent + 'A0 = subconst(A0,%d);\n' % offset |
| 304 |
stanza += indent + 'A1 = subconst(A1,%d);\n' % offset |
| 305 |
|
| 306 |
stanza += indent + '/* A0: r0r2r4r6r8r10r12r14 r16r18r20r22r24r26r28r30 */\n' |
| 307 |
stanza += indent + '/* A1: r1r3r5r7r9r11r13r15 r17r19r21r23r25r27r29r31 */\n' |
| 308 |
|
| 309 |
stanza += indent + 'B0 = _mm256_unpacklo_epi16(A0,A1);\n' |
| 310 |
stanza += indent + 'B1 = _mm256_unpackhi_epi16(A0,A1);\n' |
| 311 |
stanza += indent + '/* B0: r0r1r2r3r4r5r6r7 r16r17r18r19r20r21r22r23 */\n' |
| 312 |
stanza += indent + '/* B1: r8r9r10r11r12r13r14r15 r24r25r26r27r28r29r30r31 */\n' |
| 313 |
|
| 314 |
stanza += indent + 'C0 = _mm256_permute2x128_si256(B0,B1,0x20);\n' |
| 315 |
stanza += indent + 'C1 = _mm256_permute2x128_si256(B0,B1,0x31);\n' |
| 316 |
stanza += indent + '/* C0: r0r1r2r3r4r5r6r7 r8r9r10r11r12r13r14r15 */\n' |
| 317 |
stanza += indent + '/* C1: r16r17r18r19r20r21r22r23 r24r25r26r27r28r29r30r31 */\n' |
| 318 |
|
| 319 |
stanza += indent + '_mm256_storeu_si256((__m256i *) (&%s[%s]),C0);\n' % (todo,outpos0) |
| 320 |
stanza += indent + '_mm256_storeu_si256((__m256i *) (16+&%s[%s]),C1);\n' % (todo,outpos0) |
| 321 |
|
| 322 |
return stanza |
| 323 |
|
| 324 |
def stanzaloop(looplen,reading,todo,m0,bytes): |
| 325 |
stanza = '' |
| 326 |
stanza += ' s -= %d;\n' % (bytes*looplen) |
| 327 |
if looplen < 1: return stanza |
| 328 |
if looplen % 16 == 0: |
| 329 |
stanza += ' for (i = %d;i >= 0;i -= 16) {\n' % (looplen-16) |
| 330 |
stanza += inner16(' ',reading,'i',m0,m0,bytes,'2*i','2*i+1') |
| 331 |
stanza += ' }\n' |
| 332 |
return stanza |
| 333 |
if looplen >= 16: |
| 334 |
stanza += ' i = %d;\n' % (looplen-16) |
| 335 |
stanza += ' for (;;) {\n' |
| 336 |
stanza += inner16(' ',reading,'i',m0,m0,bytes,'2*i','2*i+1') |
| 337 |
stanza += ' if (!i) break;\n' |
| 338 |
stanza += ' i = -16-((~15)&-i);\n' |
| 339 |
stanza += ' }\n' |
| 340 |
return stanza |
| 341 |
stanza += ' for (i = %d;i >= 0;--i) {\n' % (looplen-1) |
| 342 |
stanza += inner(' ',reading,'i',m0,m0,bytes,'2*i','2*i+1') |
| 343 |
stanza += ' }\n' |
| 344 |
return stanza |
| 345 |
|
| 346 |
stanzas = [] |
| 347 |
|
| 348 |
layer = 1 |
| 349 |
reading = 'R%d' % layer |
| 350 |
while Mlen > 1: |
| 351 |
n0 = m0*m0 |
| 352 |
bytes0 = 0 |
| 353 |
while n0 >= top: |
| 354 |
bytes0 += 1 |
| 355 |
n0 = (n0+255)>>8 |
| 356 |
|
| 357 |
if Mlen&1: |
| 358 |
looplen = Mlen//2 |
| 359 |
r0 = '%s[%s]' % (reading,looplen) |
| 360 |
stanza = ' %s\n' % poke(todo,2*looplen,r0) |
| 361 |
stanza += stanzaloop(looplen,reading,todo,m0,bytes0) |
| 362 |
n1 = m1 |
| 363 |
stanzas += [stanza] |
| 364 |
|
| 365 |
else: |
| 366 |
n1 = m0*m1 |
| 367 |
bytes1 = 0 |
| 368 |
while n1 >= top: |
| 369 |
bytes1 += 1 |
| 370 |
n1 = (n1+255)>>8 |
| 371 |
|
| 372 |
if m1 == m0: |
| 373 |
looplen = (Mlen+1)//2 |
| 374 |
stanza = stanzaloop(looplen,reading,todo,m0,bytes0) |
| 375 |
else: |
| 376 |
looplen = (Mlen-1)//2 |
| 377 |
stanza = ' i = 0;\n' |
| 378 |
stanza += ' s -= %d;\n' % bytes1 |
| 379 |
stanza += inner(' ',reading,looplen,m0,m1,bytes1,2*looplen,2*looplen+1) |
| 380 |
stanza += stanzaloop(looplen,reading,todo,m0,bytes0) |
| 381 |
|
| 382 |
stanzas += [stanza] |
| 383 |
|
| 384 |
if m0 == m1: |
| 385 |
stanzas += [' /* %s ------> %s: reconstruct mod %d*[%d] */\n' % (reading,todo,Mlen,m0)] |
| 386 |
else: |
| 387 |
stanzas += [' /* %s ------> %s: reconstruct mod %d*[%d]+[%d] */\n' % (reading,todo,Mlen-1,m0,m1)] |
| 388 |
|
| 389 |
m0,m1,Mlen = n0,n1,(Mlen+1)//2 |
| 390 |
layer += 1 |
| 391 |
todo = reading |
| 392 |
reading = 'R%d' % layer |
| 393 |
|
| 394 |
stanza = '' |
| 395 |
stanza += ' s += crypto_decode_STRBYTES;\n' |
| 396 |
|
| 397 |
stanza += ' a1 = 0;\n' |
| 398 |
q = m1 |
| 399 |
y,t,u,uinv,z = mulmoddata(256,m1) |
| 400 |
a1lower = 0 |
| 401 |
a1upper = 0 |
| 402 |
|
| 403 |
while m1 > 1: |
| 404 |
if m1 != q: |
| 405 |
stanza += ' a1 = mulhi(a1,%d)-mulhi(mullo(a1,%d),%d);\n' % (y,z,q) |
| 406 |
if y > 0: |
| 407 |
a1lower,a1upper = a1lower*y,a1upper*y |
| 408 |
a1lower,a1upper = a1lower-(q<<15),a1upper+(q<<15)-1 |
| 409 |
else: |
| 410 |
a1lower,a1upper = a1upper*y,a1lower*y |
| 411 |
a1lower,a1upper = a1upper-(q<<15),a1lower+(q<<15)-1 |
| 412 |
a1lower >>= 16 |
| 413 |
a1upper >>= 16 |
| 414 |
|
| 415 |
a1upper += 255 |
| 416 |
stanza += ' a1 += *--s; /* %d...%d */\n' % (a1lower,a1upper) |
| 417 |
|
| 418 |
m1 = (m1+255)>>8 |
| 419 |
|
| 420 |
while a1upper >= q: |
| 421 |
a1lower,a1upper = a1lower-q,a1upper-q |
| 422 |
stanza += ' a1 -= %d; /* %d...%d */\n' % (q,a1lower,a1upper) |
| 423 |
|
| 424 |
while a1lower < 0: |
| 425 |
a1lower,a1upper = min(0,a1lower+q),max(a1upper,q-1) |
| 426 |
stanza += ' a1 += %d&crypto_int16_negative_mask(a1); /* %d...%d */\n' % (q,a1lower,a1upper) |
| 427 |
|
| 428 |
stanza += ' %s\n' % poke(todo,0,'a1') |
| 429 |
stanzas += [stanza] |
| 430 |
|
| 431 |
for stanza in reversed(stanzas): |
| 432 |
print(' ') |
| 433 |
sys.stdout.write(stanza) |
| 434 |
|
| 435 |
print('}') |