+ const struct lzx_sequence *seq = sequences;
+ u32 ones_if_aligned = 0 - (block_type == LZX_BLOCKTYPE_ALIGNED);
+
+ for (;;) {
+ /* Output the next sequence. */
+
+ unsigned litrunlen = seq->litrunlen;
+ unsigned match_hdr;
+ unsigned main_symbol;
+ unsigned adjusted_length;
+ u32 adjusted_offset;
+ unsigned offset_slot;
+ unsigned num_extra_bits;
+ u32 extra_bits;
+
+ /* Output the literal run of the sequence. */
+
+ if (litrunlen) { /* Is the literal run nonempty? */
+
+ /* Verify optimization is enabled on 64-bit */
+ STATIC_ASSERT(sizeof(machine_word_t) < 8 ||
+ CAN_BUFFER(4 * MAIN_CODEWORD_LIMIT));
+
+ if (CAN_BUFFER(4 * MAIN_CODEWORD_LIMIT)) {
+
+ /* 64-bit: write 4 literals at a time. */
+ while (litrunlen >= 4) {
+ unsigned lit0 = block_data[0];
+ unsigned lit1 = block_data[1];
+ unsigned lit2 = block_data[2];
+ unsigned lit3 = block_data[3];
+ lzx_add_bits(os, codes->codewords.main[lit0],
+ codes->lens.main[lit0]);
+ lzx_add_bits(os, codes->codewords.main[lit1],
+ codes->lens.main[lit1]);
+ lzx_add_bits(os, codes->codewords.main[lit2],
+ codes->lens.main[lit2]);
+ lzx_add_bits(os, codes->codewords.main[lit3],
+ codes->lens.main[lit3]);
+ lzx_flush_bits(os, 4 * MAIN_CODEWORD_LIMIT);
+ block_data += 4;
+ litrunlen -= 4;
+ }
+ if (litrunlen--) {
+ unsigned lit = *block_data++;
+ lzx_add_bits(os, codes->codewords.main[lit],
+ codes->lens.main[lit]);
+ if (litrunlen--) {
+ unsigned lit = *block_data++;
+ lzx_add_bits(os, codes->codewords.main[lit],
+ codes->lens.main[lit]);
+ if (litrunlen--) {
+ unsigned lit = *block_data++;
+ lzx_add_bits(os, codes->codewords.main[lit],
+ codes->lens.main[lit]);
+ lzx_flush_bits(os, 3 * MAIN_CODEWORD_LIMIT);
+ } else {
+ lzx_flush_bits(os, 2 * MAIN_CODEWORD_LIMIT);
+ }
+ } else {
+ lzx_flush_bits(os, 1 * MAIN_CODEWORD_LIMIT);
+ }
+ }
+ } else {
+ /* 32-bit: write 1 literal at a time. */
+ do {
+ unsigned lit = *block_data++;
+ lzx_add_bits(os, codes->codewords.main[lit],
+ codes->lens.main[lit]);
+ lzx_flush_bits(os, MAIN_CODEWORD_LIMIT);
+ } while (--litrunlen);
+ }
+ }
+
+ /* Was this the last literal run? */
+ if (seq->adjusted_offset_and_match_hdr & 0x80000000)
+ return;
+
+ /* Nope; output the match. */
+
+ match_hdr = seq->adjusted_offset_and_match_hdr & 0x1FF;
+ main_symbol = LZX_NUM_CHARS + match_hdr;
+ adjusted_length = seq->adjusted_length;
+
+ block_data += adjusted_length + LZX_MIN_MATCH_LEN;
+
+ offset_slot = match_hdr / LZX_NUM_LEN_HEADERS;
+ adjusted_offset = seq->adjusted_offset_and_match_hdr >> 9;