// Copyright 2023 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This file is autogenerated: see
// tools/codegen/core/gen_huffman_decompressor.cc

#ifndef GRPC_TEST_CPP_MICROBENCHMARKS_HUFFMAN_GEOMETRIES_DECODE_HUFF_8_13_9_H
#define GRPC_TEST_CPP_MICROBENCHMARKS_HUFFMAN_GEOMETRIES_DECODE_HUFF_8_13_9_H
#include <grpc/support/port_platform.h>

#include <cstddef>
#include <cstdint>
namespace grpc_core {
namespace geometry_8_13_9 {
class HuffDecoderCommon {
 protected:
  static inline uint64_t GetOp2(size_t i) { return table2_0_ops_[i]; }
  static inline uint64_t GetEmit2(size_t, size_t emit) {
    return table2_0_emit_[emit];
  }
  static inline uint64_t GetOp3(size_t i) { return table3_0_ops_[i]; }
  static inline uint64_t GetEmit3(size_t, size_t emit) {
    return table3_0_emit_[emit];
  }
  static inline uint64_t GetOp4(size_t i) {
    return table4_ops_[i >> 6][i & 0x3f];
  }
  static inline uint64_t GetEmit4(size_t i, size_t emit) {
    return table4_emit_[i >> 6][emit];
  }
  static inline uint64_t GetOp1(size_t i) {
    return table1_0_inner_[table1_0_outer_[i]];
  }
  static inline uint64_t GetEmit1(size_t, size_t emit) {
    return table1_0_emit_[emit];
  }
  static inline uint64_t GetOp5(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit5(size_t, size_t emit) {
    return (emit < 2 ? (emit + 33) : ((emit - 2) + 40));
  }
  static inline uint64_t GetOp7(size_t i) {
    return (i < 2 ? (i) : ((i - 2) + 1));
  }
  static inline uint64_t GetEmit7(size_t, size_t emit) {
    return ((void)emit, 63);
  }
  static inline uint64_t GetOp8(size_t i) {
    return table8_0_inner_[table8_0_outer_[i]];
  }
  static inline uint64_t GetEmit8(size_t, size_t emit) {
    return (emit < 2 ? (emit ? 39 : 63) : ((emit - 2) ? 124 : 43));
  }
  static inline uint64_t GetOp9(size_t i) {
    return table9_0_inner_[table9_0_outer_[i]];
  }
  static inline uint64_t GetEmit9(size_t, size_t emit) {
    return table9_0_emit_[emit];
  }
  static inline uint64_t GetOp10(size_t i) { return table10_0_ops_[i]; }
  static inline uint64_t GetEmit10(size_t, size_t emit) {
    return table10_0_emit_[emit];
  }
  static inline uint64_t GetOp11(size_t i) { return table11_0_ops_[i]; }
  static inline uint64_t GetEmit11(size_t, size_t emit) {
    return table11_0_emit_[emit];
  }
  static inline uint64_t GetOp12(size_t i) { return table12_0_ops_[i]; }
  static inline uint64_t GetEmit12(size_t, size_t emit) {
    return table12_0_emit_[emit];
  }
  static inline uint64_t GetOp13(size_t i) {
    return table13_ops_[i >> 5][i & 0x1f];
  }
  static inline uint64_t GetEmit13(size_t i, size_t emit) {
    return table13_emit_[i >> 5][emit];
  }
  static inline uint64_t GetOp14(size_t i) {
    return table14_ops_[i >> 5][i & 0x1f];
  }
  static inline uint64_t GetEmit14(size_t i, size_t emit) {
    return table14_emit_[i >> 5][emit];
  }
  static inline uint64_t GetOp15(size_t i) {
    return table15_ops_[i >> 6][i & 0x3f];
  }
  static inline uint64_t GetEmit15(size_t i, size_t emit) {
    return table15_emit_[i >> 6][emit];
  }
  static inline uint64_t GetOp16(size_t i) {
    return table16_ops_[i >> 6][i & 0x3f];
  }
  static inline uint64_t GetEmit16(size_t i, size_t emit) {
    return table16_emit_[i >> 6][emit];
  }
  static inline uint64_t GetOp17(size_t i) {
    return table17_ops_[i >> 6][i & 0x3f];
  }
  static inline uint64_t GetEmit17(size_t i, size_t emit) {
    return table17_emit_[i >> 6][emit];
  }
  static inline uint64_t GetOp6(size_t i) {
    return table6_ops_[i >> 7][i & 0x7f];
  }
  static inline uint64_t GetEmit6(size_t i, size_t emit) {
    return table6_emit_[i >> 7][emit];
  }
  static inline uint64_t GetOp18(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit18(size_t, size_t emit) {
    return emit ? 132 : 129;
  }
  static inline uint64_t GetOp19(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit19(size_t, size_t emit) { return emit + 133; }
  static inline uint64_t GetOp20(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit20(size_t, size_t emit) {
    return emit ? 146 : 136;
  }
  static inline uint64_t GetOp21(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit21(size_t, size_t emit) {
    return emit ? 156 : 154;
  }
  static inline uint64_t GetOp22(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit22(size_t, size_t emit) {
    return emit ? 163 : 160;
  }
  static inline uint64_t GetOp23(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit23(size_t, size_t emit) {
    return emit ? 169 : 164;
  }
  static inline uint64_t GetOp24(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit24(size_t, size_t emit) {
    return emit ? 173 : 170;
  }
  static inline uint64_t GetOp25(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit25(size_t, size_t emit) {
    return emit ? 181 : 178;
  }
  static inline uint64_t GetOp26(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit26(size_t, size_t emit) { return emit + 185; }
  static inline uint64_t GetOp27(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit27(size_t, size_t emit) {
    return emit ? 189 : 187;
  }
  static inline uint64_t GetOp28(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit28(size_t, size_t emit) {
    return emit ? 196 : 190;
  }
  static inline uint64_t GetOp29(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit29(size_t, size_t emit) {
    return emit ? 228 : 198;
  }
  static inline uint64_t GetOp30(size_t i) { return i ? 3 : 1; }
  static inline uint64_t GetEmit30(size_t, size_t emit) { return emit + 232; }
  static inline uint64_t GetOp31(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit31(size_t, size_t emit) {
    return (emit < 2 ? (emit ? 135 : 1) : ((emit - 2) + 137));
  }
  static inline uint64_t GetOp32(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit32(size_t, size_t emit) {
    return (emit < 2 ? (emit + 139) : ((emit - 2) ? 143 : 141));
  }
  static inline uint64_t GetOp33(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit33(size_t, size_t emit) {
    return (emit < 1 ? (((void)emit, 147)) : ((emit - 1) + 149));
  }
  static inline uint64_t GetOp34(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit34(size_t, size_t emit) {
    return (emit < 2 ? (emit ? 155 : 152) : ((emit - 2) + 157));
  }
  static inline uint64_t GetOp35(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit35(size_t, size_t emit) {
    return (emit < 2 ? (emit + 165) : ((emit - 2) ? 174 : 168));
  }
  static inline uint64_t GetOp36(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit36(size_t, size_t emit) {
    return (emit < 2 ? (emit ? 180 : 175) : ((emit - 2) + 182));
  }
  static inline uint64_t GetOp37(size_t i) {
    return (i < 2 ? (i ? 6 : 2) : ((i - 2) ? 14 : 10));
  }
  static inline uint64_t GetEmit37(size_t, size_t emit) {
    return (emit < 2 ? (emit ? 191 : 188) : ((emit - 2) ? 231 : 197));
  }
  static inline uint64_t GetOp39(size_t i) {
    return table39_0_inner_[(i < 6 ? (i) : (((void)(i - 6), 6)))];
  }
  static inline uint64_t GetEmit39(size_t, size_t emit) {
    return table39_0_emit_[emit];
  }
  static inline uint64_t GetOp38(size_t i) {
    return table38_0_inner_[(i < 11 ? (i / 2 + 0) : ((i - 11) + 5))];
  }
  static inline uint64_t GetEmit38(size_t, size_t emit) {
    return table38_0_emit_[emit];
  }
  static inline uint64_t GetOp41(size_t i) {
    return (i < 1 ? (((void)i, 0)) : (((void)(i - 1), 1)));
  }
  static inline uint64_t GetEmit41(size_t, size_t emit) {
    return ((void)emit, 239);
  }
  static inline uint64_t GetOp40(size_t i) {
    return table40_0_inner_[(i < 1 ? (((void)i, 0)) : ((i - 1)))];
  }
  static inline uint64_t GetEmit40(size_t, size_t emit) {
    return table40_0_emit_[emit];
  }
  static inline uint64_t GetOp43(size_t i) { return table43_0_ops_[i]; }
  static inline uint64_t GetEmit43(size_t, size_t emit) {
    return table43_0_emit_[emit];
  }
  static inline uint64_t GetOp44(size_t i) { return table44_0_ops_[i]; }
  static inline uint64_t GetEmit44(size_t, size_t emit) {
    return table44_0_emit_[emit];
  }
  static inline uint64_t GetOp45(size_t i) { return table45_0_ops_[i]; }
  static inline uint64_t GetEmit45(size_t, size_t emit) {
    return table45_0_emit_[emit];
  }
  static inline uint64_t GetOp46(size_t i) { return table46_0_ops_[i]; }
  static inline uint64_t GetEmit46(size_t, size_t emit) {
    return table45_0_emit_[emit];
  }
  static inline uint64_t GetOp42(size_t i) {
    return table42_ops_[i >> 5][i & 0x1f];
  }
  static inline uint64_t GetEmit42(size_t i, size_t emit) {
    return table42_emit_[i >> 5][emit];
  }

 private:
  static const uint8_t table2_0_emit_[10];
  static const uint8_t table2_0_ops_[32];
  static const uint8_t table3_0_emit_[36];
  static const uint8_t table3_0_ops_[64];
  static const uint8_t table4_0_emit_[22];
  static const uint8_t table4_0_ops_[64];
  static const uint8_t table4_1_emit_[46];
  static const uint8_t table4_1_ops_[64];
  static const uint8_t* const table4_emit_[2];
  static const uint8_t* const table4_ops_[2];
  static const uint8_t table1_0_emit_[74];
  static const uint16_t table1_0_inner_[76];
  static const uint8_t table1_0_outer_[256];
  static const uint8_t table8_0_inner_[6];
  static const uint8_t table8_0_outer_[8];
  static const uint8_t table9_0_emit_[6];
  static const uint8_t table9_0_inner_[8];
  static const uint8_t table9_0_outer_[16];
  static const uint8_t table10_0_emit_[12];
  static const uint8_t table10_0_ops_[32];
  static const uint8_t table11_0_emit_[14];
  static const uint8_t table11_0_ops_[64];
  static const uint8_t table12_0_emit_[36];
  static const uint8_t table12_0_ops_[128];
  static const uint8_t table13_0_emit_[44];
  static const uint8_t table13_0_ops_[32];
  static const uint8_t table13_1_emit_[28];
  static const uint8_t table13_1_ops_[32];
  static const uint8_t table13_2_emit_[20];
  static const uint8_t table13_2_ops_[32];
  static const uint8_t table13_3_emit_[20];
  static const uint8_t table13_4_emit_[20];
  static const uint8_t table13_5_emit_[2];
  static const uint8_t table13_5_ops_[32];
  static const uint8_t table13_6_emit_[4];
  static const uint8_t table13_6_ops_[32];
  static const uint8_t table13_7_emit_[7];
  static const uint8_t table13_7_ops_[32];
  static const uint8_t* const table13_emit_[8];
  static const uint8_t* const table13_ops_[8];
  static const uint8_t table14_0_emit_[16];
  static const uint8_t table14_0_ops_[32];
  static const uint8_t table14_1_emit_[28];
  static const uint8_t table14_1_ops_[32];
  static const uint8_t table14_2_emit_[36];
  static const uint8_t table14_2_ops_[32];
  static const uint8_t table14_3_emit_[56];
  static const uint8_t table14_3_ops_[32];
  static const uint8_t table14_4_emit_[44];
  static const uint8_t table14_5_emit_[28];
  static const uint8_t table14_6_emit_[44];
  static const uint8_t table14_7_emit_[28];
  static const uint8_t table14_8_emit_[44];
  static const uint8_t table14_9_emit_[28];
  static const uint8_t table14_10_emit_[20];
  static const uint8_t table14_11_emit_[20];
  static const uint8_t table14_12_emit_[2];
  static const uint8_t table14_13_emit_[2];
  static const uint8_t table14_14_emit_[2];
  static const uint8_t table14_15_emit_[5];
  static const uint8_t table14_15_ops_[32];
  static const uint8_t* const table14_emit_[16];
  static const uint8_t* const table14_ops_[16];
  static const uint16_t table15_0_ops_[64];
  static const uint16_t table15_1_ops_[64];
  static const uint16_t table15_2_ops_[64];
  static const uint8_t table15_3_emit_[68];
  static const uint16_t table15_3_ops_[64];
  static const uint16_t table15_4_ops_[64];
  static const uint8_t table15_5_emit_[92];
  static const uint16_t table15_5_ops_[64];
  static const uint8_t table15_7_emit_[92];
  static const uint8_t table15_9_emit_[92];
  static const uint8_t table15_10_emit_[72];
  static const uint16_t table15_10_ops_[64];
  static const uint8_t table15_11_emit_[72];
  static const uint8_t table15_12_emit_[40];
  static const uint16_t table15_12_ops_[64];
  static const uint8_t table15_13_emit_[40];
  static const uint8_t table15_14_emit_[40];
  static const uint16_t table15_15_ops_[64];
  static const uint8_t* const table15_emit_[16];
  static const uint16_t* const table15_ops_[16];
  static const uint8_t table16_0_emit_[8];
  static const uint16_t table16_0_ops_[64];
  static const uint8_t table16_1_emit_[8];
  static const uint8_t table16_2_emit_[12];
  static const uint16_t table16_2_ops_[64];
  static const uint8_t table16_3_emit_[16];
  static const uint8_t table16_4_emit_[16];
  static const uint8_t table16_5_emit_[20];
  static const uint16_t table16_5_ops_[64];
  static const uint8_t table16_6_emit_[32];
  static const uint16_t table16_6_ops_[64];
  static const uint8_t table16_7_emit_[36];
  static const uint16_t table16_7_ops_[64];
  static const uint8_t table16_8_emit_[16];
  static const uint8_t table16_9_emit_[28];
  static const uint8_t table16_10_emit_[36];
  static const uint8_t table16_11_emit_[68];
  static const uint8_t table16_12_emit_[16];
  static const uint8_t table16_13_emit_[28];
  static const uint8_t table16_14_emit_[36];
  static const uint8_t table16_15_emit_[68];
  static const uint8_t table16_16_emit_[16];
  static const uint8_t table16_17_emit_[28];
  static const uint8_t table16_18_emit_[36];
  static const uint8_t table16_19_emit_[68];
  static const uint8_t table16_20_emit_[44];
  static const uint8_t table16_21_emit_[92];
  static const uint8_t table16_22_emit_[44];
  static const uint8_t table16_23_emit_[92];
  static const uint8_t table16_24_emit_[72];
  static const uint8_t table16_25_emit_[72];
  static const uint8_t table16_26_emit_[72];
  static const uint8_t table16_27_emit_[72];
  static const uint8_t table16_28_emit_[72];
  static const uint8_t table16_29_emit_[72];
  static const uint8_t table16_30_emit_[40];
  static const uint8_t table16_31_emit_[6];
  static const uint16_t table16_31_ops_[64];
  static const uint8_t* const table16_emit_[32];
  static const uint16_t* const table16_ops_[32];
  static const uint8_t table17_0_emit_[60];
  static const uint16_t table17_0_ops_[64];
  static const uint8_t table17_1_emit_[60];
  static const uint8_t table17_2_emit_[60];
  static const uint8_t table17_3_emit_[60];
  static const uint8_t table17_4_emit_[60];
  static const uint8_t table17_5_emit_[8];
  static const uint16_t table17_5_ops_[64];
  static const uint8_t table17_6_emit_[8];
  static const uint8_t table17_7_emit_[8];
  static const uint8_t table17_8_emit_[8];
  static const uint8_t table17_9_emit_[8];
  static const uint8_t table17_10_emit_[8];
  static const uint8_t table17_11_emit_[12];
  static const uint16_t table17_11_ops_[64];
  static const uint8_t table17_12_emit_[16];
  static const uint16_t table17_12_ops_[64];
  static const uint8_t table17_13_emit_[16];
  static const uint8_t table17_14_emit_[16];
  static const uint8_t table17_15_emit_[30];
  static const uint16_t table17_15_ops_[64];
  static const uint8_t table17_16_emit_[8];
  static const uint8_t table17_17_emit_[8];
  static const uint8_t table17_18_emit_[12];
  static const uint8_t table17_19_emit_[16];
  static const uint8_t table17_20_emit_[16];
  static const uint8_t table17_21_emit_[20];
  static const uint16_t table17_21_ops_[64];
  static const uint8_t table17_22_emit_[32];
  static const uint16_t table17_22_ops_[64];
  static const uint8_t table17_23_emit_[36];
  static const uint16_t table17_23_ops_[64];
  static const uint8_t table17_24_emit_[8];
  static const uint8_t table17_25_emit_[8];
  static const uint8_t table17_26_emit_[12];
  static const uint8_t table17_27_emit_[16];
  static const uint8_t table17_28_emit_[16];
  static const uint8_t table17_29_emit_[20];
  static const uint8_t table17_30_emit_[32];
  static const uint8_t table17_31_emit_[36];
  static const uint8_t table17_32_emit_[8];
  static const uint8_t table17_33_emit_[8];
  static const uint8_t table17_34_emit_[12];
  static const uint8_t table17_35_emit_[16];
  static const uint8_t table17_36_emit_[16];
  static const uint8_t table17_37_emit_[20];
  static const uint8_t table17_38_emit_[32];
  static const uint8_t table17_39_emit_[36];
  static const uint8_t table17_40_emit_[16];
  static const uint8_t table17_41_emit_[28];
  static const uint16_t table17_41_ops_[64];
  static const uint8_t table17_42_emit_[36];
  static const uint16_t table17_42_ops_[64];
  static const uint8_t table17_43_emit_[68];
  static const uint16_t table17_43_ops_[64];
  static const uint8_t table17_44_emit_[16];
  static const uint8_t table17_45_emit_[28];
  static const uint8_t table17_46_emit_[36];
  static const uint8_t table17_47_emit_[68];
  static const uint8_t table17_48_emit_[44];
  static const uint16_t table17_48_ops_[64];
  static const uint8_t table17_49_emit_[92];
  static const uint16_t table17_49_ops_[64];
  static const uint8_t table17_50_emit_[44];
  static const uint8_t table17_51_emit_[92];
  static const uint8_t table17_52_emit_[44];
  static const uint8_t table17_53_emit_[92];
  static const uint8_t table17_54_emit_[44];
  static const uint8_t table17_55_emit_[92];
  static const uint8_t table17_56_emit_[44];
  static const uint8_t table17_57_emit_[92];
  static const uint8_t table17_58_emit_[44];
  static const uint8_t table17_59_emit_[92];
  static const uint8_t table17_60_emit_[72];
  static const uint16_t table17_60_ops_[64];
  static const uint8_t table17_61_emit_[72];
  static const uint8_t table17_62_emit_[40];
  static const uint16_t table17_62_ops_[64];
  static const uint8_t table17_63_emit_[31];
  static const uint16_t table17_63_ops_[64];
  static const uint8_t* const table17_emit_[64];
  static const uint16_t* const table17_ops_[64];
  static const uint8_t table6_0_emit_[1];
  static const uint16_t table6_0_ops_[128];
  static const uint8_t table6_16_emit_[1];
  static const uint16_t table6_16_ops_[128];
  static const uint8_t table6_24_emit_[1];
  static const uint8_t table6_32_emit_[1];
  static const uint8_t table6_40_emit_[1];
  static const uint16_t table6_40_ops_[128];
  static const uint8_t table6_44_emit_[1];
  static const uint8_t table6_48_emit_[1];
  static const uint16_t table6_48_ops_[128];
  static const uint8_t table6_50_emit_[1];
  static const uint8_t table6_52_emit_[1];
  static const uint8_t table6_54_emit_[1];
  static const uint8_t table6_56_emit_[1];
  static const uint8_t table6_58_emit_[1];
  static const uint8_t table6_60_emit_[1];
  static const uint16_t table6_60_ops_[128];
  static const uint8_t table6_61_emit_[1];
  static const uint8_t table6_62_emit_[2];
  static const uint16_t table6_62_ops_[128];
  static const uint8_t table6_63_emit_[25];
  static const uint16_t table6_63_ops_[128];
  static const uint8_t* const table6_emit_[64];
  static const uint16_t* const table6_ops_[64];
  static const uint8_t table39_0_emit_[6];
  static const uint8_t table39_0_inner_[7];
  static const uint8_t table38_0_emit_[10];
  static const uint8_t table38_0_inner_[10];
  static const uint8_t table40_0_emit_[7];
  static const uint8_t table40_0_inner_[7];
  static const uint8_t table43_0_emit_[15];
  static const uint8_t table43_0_ops_[32];
  static const uint8_t table44_0_emit_[34];
  static const uint8_t table44_0_ops_[64];
  static const uint8_t table45_0_emit_[63];
  static const uint8_t table45_0_ops_[128];
  static const uint8_t table46_0_ops_[256];
  static const uint8_t table42_0_emit_[2];
  static const uint16_t table42_0_ops_[32];
  static const uint8_t table42_1_emit_[2];
  static const uint8_t table42_2_emit_[2];
  static const uint8_t table42_3_emit_[2];
  static const uint8_t table42_4_emit_[2];
  static const uint8_t table42_5_emit_[2];
  static const uint8_t table42_6_emit_[2];
  static const uint8_t table42_7_emit_[3];
  static const uint16_t table42_7_ops_[32];
  static const uint8_t table42_8_emit_[4];
  static const uint16_t table42_8_ops_[32];
  static const uint8_t table42_9_emit_[4];
  static const uint8_t table42_10_emit_[4];
  static const uint8_t table42_11_emit_[4];
  static const uint8_t table42_12_emit_[7];
  static const uint16_t table42_12_ops_[32];
  static const uint8_t table42_13_emit_[8];
  static const uint16_t table42_13_ops_[32];
  static const uint8_t table42_14_emit_[8];
  static const uint8_t table42_15_emit_[10];
  static const uint16_t table42_15_ops_[32];
  static const uint8_t* const table42_emit_[16];
  static const uint16_t* const table42_ops_[16];
};
template <typename F>
class HuffDecoder : public HuffDecoderCommon {
 public:
  HuffDecoder(F sink, const uint8_t* begin, const uint8_t* end)
      : sink_(sink), begin_(begin), end_(end) {}
  bool Run() {
    while (!done_) {
      if (!RefillTo8()) {
        Done0();
        break;
      }
      const auto index = (buffer_ >> (buffer_len_ - 8)) & 0xff;
      const auto op = GetOp1(index);
      const int consumed = op & 15;
      buffer_len_ -= consumed;
      const auto emit_ofs = op >> 6;
      switch ((op >> 4) & 3) {
        case 0: {
          sink_(GetEmit1(index, emit_ofs + 0));
          break;
        }
        case 1: {
          DecodeStep0();
          break;
        }
        case 2: {
          DecodeStep1();
          break;
        }
      }
    }
    return ok_;
  }

 private:
  bool RefillTo8() {
    switch (buffer_len_) {
      case 0: {
        return Read1to8Bytes();
      }
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7: {
        return Read1to7Bytes();
      }
    }
    return true;
  }
  bool Read1to8Bytes() {
    switch (end_ - begin_) {
      case 0: {
        return false;
      }
      case 1: {
        Fill1();
        return true;
      }
      case 2: {
        Fill2();
        return true;
      }
      case 3: {
        Fill3();
        return true;
      }
      case 4: {
        Fill4();
        return true;
      }
      case 5: {
        Fill5();
        return true;
      }
      case 6: {
        Fill6();
        return true;
      }
      case 7: {
        Fill7();
        return true;
      }
      default: {
        Fill8();
        return true;
      }
    }
  }
  void Fill1() {
    buffer_ = (buffer_ << 8) | (static_cast<uint64_t>(begin_[0]) << 0);
    begin_ += 1;
    buffer_len_ += 8;
  }
  void Fill2() {
    buffer_ = (buffer_ << 16) | (static_cast<uint64_t>(begin_[0]) << 8) |
              (static_cast<uint64_t>(begin_[1]) << 0);
    begin_ += 2;
    buffer_len_ += 16;
  }
  void Fill3() {
    buffer_ = (buffer_ << 24) | (static_cast<uint64_t>(begin_[0]) << 16) |
              (static_cast<uint64_t>(begin_[1]) << 8) |
              (static_cast<uint64_t>(begin_[2]) << 0);
    begin_ += 3;
    buffer_len_ += 24;
  }
  void Fill4() {
    buffer_ = (buffer_ << 32) | (static_cast<uint64_t>(begin_[0]) << 24) |
              (static_cast<uint64_t>(begin_[1]) << 16) |
              (static_cast<uint64_t>(begin_[2]) << 8) |
              (static_cast<uint64_t>(begin_[3]) << 0);
    begin_ += 4;
    buffer_len_ += 32;
  }
  void Fill5() {
    buffer_ = (buffer_ << 40) | (static_cast<uint64_t>(begin_[0]) << 32) |
              (static_cast<uint64_t>(begin_[1]) << 24) |
              (static_cast<uint64_t>(begin_[2]) << 16) |
              (static_cast<uint64_t>(begin_[3]) << 8) |
              (static_cast<uint64_t>(begin_[4]) << 0);
    begin_ += 5;
    buffer_len_ += 40;
  }
  void Fill6() {
    buffer_ = (buffer_ << 48) | (static_cast<uint64_t>(begin_[0]) << 40) |
              (static_cast<uint64_t>(begin_[1]) << 32) |
              (static_cast<uint64_t>(begin_[2]) << 24) |
              (static_cast<uint64_t>(begin_[3]) << 16) |
              (static_cast<uint64_t>(begin_[4]) << 8) |
              (static_cast<uint64_t>(begin_[5]) << 0);
    begin_ += 6;
    buffer_len_ += 48;
  }
  void Fill7() {
    buffer_ = (buffer_ << 56) | (static_cast<uint64_t>(begin_[0]) << 48) |
              (static_cast<uint64_t>(begin_[1]) << 40) |
              (static_cast<uint64_t>(begin_[2]) << 32) |
              (static_cast<uint64_t>(begin_[3]) << 24) |
              (static_cast<uint64_t>(begin_[4]) << 16) |
              (static_cast<uint64_t>(begin_[5]) << 8) |
              (static_cast<uint64_t>(begin_[6]) << 0);
    begin_ += 7;
    buffer_len_ += 56;
  }
  void Fill8() {
    buffer_ = 0 | (static_cast<uint64_t>(begin_[0]) << 56) |
              (static_cast<uint64_t>(begin_[1]) << 48) |
              (static_cast<uint64_t>(begin_[2]) << 40) |
              (static_cast<uint64_t>(begin_[3]) << 32) |
              (static_cast<uint64_t>(begin_[4]) << 24) |
              (static_cast<uint64_t>(begin_[5]) << 16) |
              (static_cast<uint64_t>(begin_[6]) << 8) |
              (static_cast<uint64_t>(begin_[7]) << 0);
    begin_ += 8;
    buffer_len_ += 64;
  }
  bool Read1to7Bytes() {
    switch (end_ - begin_) {
      case 0: {
        return false;
      }
      case 1: {
        Fill1();
        return true;
      }
      case 2: {
        Fill2();
        return true;
      }
      case 3: {
        Fill3();
        return true;
      }
      case 4: {
        Fill4();
        return true;
      }
      case 5: {
        Fill5();
        return true;
      }
      case 6: {
        Fill6();
        return true;
      }
      default: {
        Fill7();
        return true;
      }
    }
  }
  void Done0() {
    done_ = true;
    switch (end_ - begin_) {}
    switch (buffer_len_) {
      case 1:
      case 2:
      case 3:
      case 4: {
        ok_ = (buffer_ & ((1 << buffer_len_) - 1)) == (1 << buffer_len_) - 1;
        return;
      }
      case 5: {
        const auto index = buffer_ & 31;
        const auto op = GetOp2(index);
        switch (op & 3) {
          case 0: {
            sink_(GetEmit2(index, (op >> 2) + 0));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
        }
        return;
      }
      case 6: {
        const auto index = buffer_ & 63;
        const auto op = GetOp3(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit3(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 7: {
        const auto index = buffer_ & 127;
        const auto op = GetOp4(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit4(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 0: {
        return;
      }
    }
  }
  void DecodeStep0() {
    if (!RefillTo2()) {
      Done1();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp5(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit5(index, emit_ofs + 0));
  }
  bool RefillTo2() {
    switch (buffer_len_) {
      case 0: {
        return Read1to8Bytes();
      }
      case 1: {
        return Read1to7Bytes();
      }
    }
    return true;
  }
  void Done1() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep1() {
    if (!RefillTo13()) {
      Done2();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 13)) & 0x1fff;
    const auto op = GetOp6(index);
    const int consumed = op & 15;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 9;
    switch ((op >> 4) & 31) {
      case 0: {
        sink_(GetEmit6(index, emit_ofs + 0));
        break;
      }
      case 1: {
        DecodeStep2();
        break;
      }
      case 2: {
        DecodeStep3();
        break;
      }
      case 3: {
        DecodeStep4();
        break;
      }
      case 4: {
        DecodeStep5();
        break;
      }
      case 5: {
        DecodeStep6();
        break;
      }
      case 6: {
        DecodeStep7();
        break;
      }
      case 7: {
        DecodeStep8();
        break;
      }
      case 8: {
        DecodeStep9();
        break;
      }
      case 9: {
        DecodeStep10();
        break;
      }
      case 10: {
        DecodeStep11();
        break;
      }
      case 11: {
        DecodeStep12();
        break;
      }
      case 12: {
        DecodeStep13();
        break;
      }
      case 13: {
        DecodeStep14();
        break;
      }
      case 14: {
        DecodeStep15();
        break;
      }
      case 15: {
        DecodeStep16();
        break;
      }
      case 16: {
        DecodeStep17();
        break;
      }
      case 17: {
        DecodeStep18();
        break;
      }
      case 18: {
        DecodeStep19();
        break;
      }
      case 19: {
        DecodeStep20();
        break;
      }
      case 20: {
        DecodeStep21();
        break;
      }
      case 21: {
        DecodeStep23();
        break;
      }
      case 22: {
        DecodeStep22();
        break;
      }
      case 23: {
        DecodeStep24();
        break;
      }
    }
  }
  bool RefillTo13() {
    switch (buffer_len_) {
      case 0: {
        return Read2to8Bytes();
      }
      case 1:
      case 2:
      case 3:
      case 4: {
        return Read2to7Bytes();
      }
      case 5:
      case 6:
      case 7:
      case 8: {
        return Read1to7Bytes();
      }
      case 9:
      case 10:
      case 11:
      case 12: {
        return Read1to6Bytes();
      }
    }
    return true;
  }
  bool Read2to8Bytes() {
    switch (end_ - begin_) {
      case 0:
      case 1: {
        return false;
      }
      case 2: {
        Fill2();
        return true;
      }
      case 3: {
        Fill3();
        return true;
      }
      case 4: {
        Fill4();
        return true;
      }
      case 5: {
        Fill5();
        return true;
      }
      case 6: {
        Fill6();
        return true;
      }
      case 7: {
        Fill7();
        return true;
      }
      default: {
        Fill8();
        return true;
      }
    }
  }
  bool Read2to7Bytes() {
    switch (end_ - begin_) {
      case 0:
      case 1: {
        return false;
      }
      case 2: {
        Fill2();
        return true;
      }
      case 3: {
        Fill3();
        return true;
      }
      case 4: {
        Fill4();
        return true;
      }
      case 5: {
        Fill5();
        return true;
      }
      case 6: {
        Fill6();
        return true;
      }
      default: {
        Fill7();
        return true;
      }
    }
  }
  bool Read1to6Bytes() {
    switch (end_ - begin_) {
      case 0: {
        return false;
      }
      case 1: {
        Fill1();
        return true;
      }
      case 2: {
        Fill2();
        return true;
      }
      case 3: {
        Fill3();
        return true;
      }
      case 4: {
        Fill4();
        return true;
      }
      case 5: {
        Fill5();
        return true;
      }
      default: {
        Fill6();
        return true;
      }
    }
  }
  void Done2() {
    done_ = true;
    switch (end_ - begin_) {
      case 1: {
        Fill1();
        break;
      }
    }
    switch (buffer_len_) {
      case 1: {
        ok_ = (buffer_ & ((1 << buffer_len_) - 1)) == (1 << buffer_len_) - 1;
        return;
      }
      case 2: {
        const auto index = buffer_ & 3;
        const auto op = GetOp7(index);
        switch (op & 3) {
          case 0: {
            sink_(GetEmit7(index, (op >> 2) + 0));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
        }
        return;
      }
      case 3: {
        const auto index = buffer_ & 7;
        const auto op = GetOp8(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit8(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 4: {
        const auto index = buffer_ & 15;
        const auto op = GetOp9(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit9(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 5: {
        const auto index = buffer_ & 31;
        const auto op = GetOp10(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit10(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 6: {
        const auto index = buffer_ & 63;
        const auto op = GetOp11(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit11(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 7: {
        const auto index = buffer_ & 127;
        const auto op = GetOp12(index);
        switch (op & 3) {
          case 0: {
            sink_(GetEmit12(index, (op >> 2) + 0));
            sink_(GetEmit12(index, (op >> 2) + 1));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
          case 2: {
            sink_(GetEmit12(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 8: {
        const auto index = buffer_ & 255;
        const auto op = GetOp13(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit13(index, (op >> 2) + 0));
            sink_(GetEmit13(index, (op >> 2) + 1));
            break;
          }
          case 2: {
            sink_(GetEmit13(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 9: {
        const auto index = buffer_ & 511;
        const auto op = GetOp14(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit14(index, (op >> 2) + 0));
            sink_(GetEmit14(index, (op >> 2) + 1));
            break;
          }
          case 2: {
            sink_(GetEmit14(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 10: {
        const auto index = buffer_ & 1023;
        const auto op = GetOp15(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit15(index, (op >> 2) + 0));
            sink_(GetEmit15(index, (op >> 2) + 1));
            break;
          }
          case 2: {
            sink_(GetEmit15(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 11: {
        const auto index = buffer_ & 2047;
        const auto op = GetOp16(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit16(index, (op >> 2) + 0));
            sink_(GetEmit16(index, (op >> 2) + 1));
            break;
          }
          case 2: {
            sink_(GetEmit16(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 12: {
        const auto index = buffer_ & 4095;
        const auto op = GetOp17(index);
        switch (op & 7) {
          case 0: {
            sink_(GetEmit17(index, (op >> 3) + 0));
            sink_(GetEmit17(index, (op >> 3) + 1));
            sink_(GetEmit17(index, (op >> 3) + 2));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
          case 2: {
            sink_(GetEmit17(index, (op >> 3) + 0));
            sink_(GetEmit17(index, (op >> 3) + 1));
            break;
          }
          case 3: {
            sink_(GetEmit17(index, (op >> 3) + 0));
            break;
          }
        }
        return;
      }
      case 0: {
        return;
      }
    }
  }
  void DecodeStep2() {
    if (!RefillTo1()) {
      Done3();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp18(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit18(index, emit_ofs + 0));
  }
  bool RefillTo1() {
    switch (buffer_len_) {
      case 0: {
        return Read1to8Bytes();
      }
    }
    return true;
  }
  void Done3() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep3() {
    if (!RefillTo1()) {
      Done4();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp19(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit19(index, emit_ofs + 0));
  }
  void Done4() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep4() {
    if (!RefillTo1()) {
      Done5();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp20(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit20(index, emit_ofs + 0));
  }
  void Done5() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep5() {
    if (!RefillTo1()) {
      Done6();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp21(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit21(index, emit_ofs + 0));
  }
  void Done6() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep6() {
    if (!RefillTo1()) {
      Done7();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp22(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit22(index, emit_ofs + 0));
  }
  void Done7() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep7() {
    if (!RefillTo1()) {
      Done8();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp23(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit23(index, emit_ofs + 0));
  }
  void Done8() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep8() {
    if (!RefillTo1()) {
      Done9();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp24(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit24(index, emit_ofs + 0));
  }
  void Done9() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep9() {
    if (!RefillTo1()) {
      Done10();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp25(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit25(index, emit_ofs + 0));
  }
  void Done10() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep10() {
    if (!RefillTo1()) {
      Done11();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp26(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit26(index, emit_ofs + 0));
  }
  void Done11() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep11() {
    if (!RefillTo1()) {
      Done12();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp27(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit27(index, emit_ofs + 0));
  }
  void Done12() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep12() {
    if (!RefillTo1()) {
      Done13();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp28(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit28(index, emit_ofs + 0));
  }
  void Done13() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep13() {
    if (!RefillTo1()) {
      Done14();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp29(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit29(index, emit_ofs + 0));
  }
  void Done14() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep14() {
    if (!RefillTo1()) {
      Done15();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 1)) & 0x1;
    const auto op = GetOp30(index);
    const int consumed = op & 1;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 1;
    sink_(GetEmit30(index, emit_ofs + 0));
  }
  void Done15() {
    done_ = true;
    ok_ = false;
  }
  void DecodeStep15() {
    if (!RefillTo2()) {
      Done16();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp31(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit31(index, emit_ofs + 0));
  }
  void Done16() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep16() {
    if (!RefillTo2()) {
      Done17();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp32(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit32(index, emit_ofs + 0));
  }
  void Done17() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep17() {
    if (!RefillTo2()) {
      Done18();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp33(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit33(index, emit_ofs + 0));
  }
  void Done18() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep18() {
    if (!RefillTo2()) {
      Done19();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp34(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit34(index, emit_ofs + 0));
  }
  void Done19() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep19() {
    if (!RefillTo2()) {
      Done20();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp35(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit35(index, emit_ofs + 0));
  }
  void Done20() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep20() {
    if (!RefillTo2()) {
      Done21();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp36(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit36(index, emit_ofs + 0));
  }
  void Done21() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep21() {
    if (!RefillTo2()) {
      Done22();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 2)) & 0x3;
    const auto op = GetOp37(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit37(index, emit_ofs + 0));
  }
  void Done22() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
    }
  }
  void DecodeStep22() {
    if (!RefillTo4()) {
      Done23();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 4)) & 0xf;
    const auto op = GetOp38(index);
    const int consumed = op & 7;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 3;
    sink_(GetEmit38(index, emit_ofs + 0));
  }
  bool RefillTo4() {
    switch (buffer_len_) {
      case 0: {
        return Read1to8Bytes();
      }
      case 1:
      case 2:
      case 3: {
        return Read1to7Bytes();
      }
    }
    return true;
  }
  void Done23() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 2:
      case 0: {
        ok_ = false;
        return;
      }
      case 3: {
        const auto index = buffer_ & 7;
        const auto op = GetOp39(index);
        switch (op & 1) {
          case 0: {
            sink_(GetEmit39(index, (op >> 1) + 0));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
        }
        return;
      }
    }
  }
  void DecodeStep23() {
    if (!RefillTo3()) {
      Done24();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 3)) & 0x7;
    const auto op = GetOp40(index);
    const int consumed = op & 3;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 2;
    sink_(GetEmit40(index, emit_ofs + 0));
  }
  bool RefillTo3() {
    switch (buffer_len_) {
      case 0: {
        return Read1to8Bytes();
      }
      case 1:
      case 2: {
        return Read1to7Bytes();
      }
    }
    return true;
  }
  void Done24() {
    done_ = true;
    switch (buffer_len_) {
      case 1:
      case 0: {
        ok_ = false;
        return;
      }
      case 2: {
        const auto index = buffer_ & 3;
        const auto op = GetOp41(index);
        switch (op & 1) {
          case 0: {
            sink_(GetEmit41(index, (op >> 1) + 0));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
        }
        return;
      }
    }
  }
  void DecodeStep24() {
    if (!RefillTo9()) {
      Done25();
      return;
    }
    const auto index = (buffer_ >> (buffer_len_ - 9)) & 0x1ff;
    const auto op = GetOp42(index);
    const int consumed = op & 15;
    buffer_len_ -= consumed;
    const auto emit_ofs = op >> 5;
    switch ((op >> 4) & 1) {
      case 0: {
        sink_(GetEmit42(index, emit_ofs + 0));
        break;
      }
      case 1: {
        begin_ = end_;
        buffer_len_ = 0;
        break;
      }
    }
  }
  bool RefillTo9() {
    switch (buffer_len_) {
      case 0: {
        return Read2to8Bytes();
      }
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 8: {
        return Read1to7Bytes();
      }
    }
    return true;
  }
  void Done25() {
    done_ = true;
    switch (end_ - begin_) {
      case 1: {
        Fill1();
        break;
      }
    }
    switch (buffer_len_) {
      case 1:
      case 2:
      case 3:
      case 4: {
        ok_ = (buffer_ & ((1 << buffer_len_) - 1)) == (1 << buffer_len_) - 1;
        return;
      }
      case 5: {
        const auto index = buffer_ & 31;
        const auto op = GetOp43(index);
        switch (op & 3) {
          case 0: {
            sink_(GetEmit43(index, (op >> 2) + 0));
            break;
          }
          case 1: {
            ok_ = false;
            break;
          }
        }
        return;
      }
      case 6: {
        const auto index = buffer_ & 63;
        const auto op = GetOp44(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit44(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 7: {
        const auto index = buffer_ & 127;
        const auto op = GetOp45(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit45(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 8: {
        const auto index = buffer_ & 255;
        const auto op = GetOp46(index);
        switch (op & 3) {
          case 0: {
            ok_ = false;
            break;
          }
          case 1: {
            sink_(GetEmit46(index, (op >> 2) + 0));
            break;
          }
        }
        return;
      }
      case 0: {
        return;
      }
    }
  }
  F sink_;
  const uint8_t* begin_;
  const uint8_t* const end_;
  uint64_t buffer_ = 0;
  int buffer_len_ = 0;
  bool ok_ = true;
  bool done_ = false;
};
}  // namespace geometry_8_13_9
}  // namespace grpc_core
#endif  // GRPC_TEST_CPP_MICROBENCHMARKS_HUFFMAN_GEOMETRIES_DECODE_HUFF_8_13_9_H
