void solve( int lo, int hi ) { if( lo + 1 == hi ) { a[lo] = modpow2( a[lo] ); return; } int mid = ( lo + hi ) >> 1; for( int i = lo; i < mid; ++i ) a[mid + i - lo] += a[i]; solve( lo, mid ); solve( mid, hi ); for( int i = lo; i < mid; ++i ) { a[mid + i - lo] -= a[i]; if( a[mid + i - lo] < 0 ) a[mid + i - lo] += mod; } }
size_t cbuf_space_avail(cbuf_t *cbuf) { uint consumed = modpow2((uint)(cbuf->head - cbuf->tail), cbuf->len_pow2); return valpow2(cbuf->len_pow2) - consumed - 1; }
static inline uint inc_pointer(const cbuf_t* cbuf, uint ptr, uint inc) { return modpow2(ptr + inc, cbuf->len_pow2); }