#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint_fast32_t;
typedef unsigned int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ errno;
int hpack_decode_byte_huffman(const uint8_t *restrict end,
                              int *restrict bit_offset) {
  static const unsigned char tab[256] = {
      48,  49,  50,  97,  99,  101, 105, 111, 115, 116, 32,  37,  45,  46,  47,
      51,  52,  53,  54,  55,  56,  57,  61,  65,  95,  98,  100, 102, 103, 104,
      108, 109, 110, 112, 114, 117, 58,  66,  67,  68,  69,  70,  71,  72,  73,
      74,  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  89,
      106, 107, 113, 118, 119, 120, 121, 122, 38,  42,  44,  59,  88,  90,  33,
      34,  40,  41,  63,  39,  43,  124, 35,  62,  0,   36,  64,  91,  93,  126,
      94,  125, 60,  96,  123, 92,  195, 208, 128, 130, 131, 162, 184, 194, 224,
      226, 153, 161, 167, 172, 176, 177, 179, 209, 216, 217, 227, 229, 230, 129,
      132, 133, 134, 136, 146, 154, 156, 160, 163, 164, 169, 170, 173, 178, 181,
      185, 186, 187, 189, 190, 196, 198, 228, 232, 233, 1,   135, 137, 138, 139,
      140, 141, 143, 147, 149, 150, 151, 152, 155, 157, 158, 165, 166, 168, 174,
      175, 180, 182, 183, 188, 191, 197, 231, 239, 9,   142, 144, 145, 148, 159,
      171, 206, 215, 225, 236, 237, 199, 207, 234, 235, 192, 193, 200, 201, 202,
      205, 210, 213, 218, 219, 238, 240, 242, 243, 255, 203, 204, 211, 212, 214,
      221, 222, 223, 241, 244, 245, 246, 247, 248, 250, 251, 252, 253, 254, 2,
      3,   4,   5,   6,   7,   8,   11,  12,  14,  15,  16,  17,  18,  19,  20,
      21,  23,  24,  25,  26,  27,  28,  29,  30,  31,  127, 220, 249, 10,  13,
      22,
  };
  static const unsigned char values[30] = {
      0, 0, 0, 0, 10, 26, 32, 6,  0,  5, 3,  2,  6,  2, 3,
      0, 0, 0, 3, 8,  13, 26, 29, 12, 4, 15, 19, 29, 0, 3};
  const unsigned char *p = tab;
  uint_fast32_t code = 0, offset = 0;
  unsigned shift = -*bit_offset;
  for (unsigned i = 0; i < 30; i++) {
    code <<= 1;
    if (*bit_offset) {
      shift = (shift - 1) & 7;
      code |= (end[*bit_offset >> 3] >> shift) & 1;
      (*bit_offset)++;
    } else
      code |= 1;
    assert(code >= offset);
    if ((code - offset) < values[i])
      return p[code - offset];
    p += values[i];
    offset = (offset + values[i]) * 2;
  }
  assert(p - tab == 256);
  if (code == 0x3fffffff)
    return 256;
  errno = EINVAL;
  return -1;
}


x86 assembly (clang, -O0):
<hpack_decode_byte_huffman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x1e,-0x30(%rbp)
jae    1242 <hpack_decode_byte_huffman+0x132>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     11a8 <hpack_decode_byte_huffman+0x98>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
and    $0x7,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x2c(%rbp),%ecx
shr    %cl,%eax
and    $0x1,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11b1 <hpack_decode_byte_huffman+0xa1>
mov    -0x24(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    -0x30(%rbp),%ecx
mov    %ecx,%edx
lea    0xf2a(%rip),%rcx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jge    11fb <hpack_decode_byte_huffman+0xeb>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x4(%rbp)
jmp    1295 <hpack_decode_byte_huffman+0x185>
mov    -0x30(%rbp),%eax
mov    %eax,%ecx
lea    0xef9(%rip),%rax
movzbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x30(%rbp),%ecx
mov    %ecx,%edx
lea    0xed8(%rip),%rcx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    114b <hpack_decode_byte_huffman+0x3b>
mov    -0x20(%rbp),%rax
lea    0xdb3(%rip),%rcx
sub    %rcx,%rax
cmp    $0x100,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x3fffffff,-0x24(%rbp)
jne    127c <hpack_decode_byte_huffman+0x16c>
movl   $0x100,-0x4(%rbp)
jmp    1295 <hpack_decode_byte_huffman+0x185>
mov    0x2d55(%rip),%rax
mov    (%rax),%ecx
mov    0x2d54(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpack_decode_byte_huffman>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
mov    %rsi,0x10(%rsp)
mov    (%rsi),%r13d
mov    %r13d,%eax
neg    %eax
mov    %eax,0x4(%rsp)
lea    0xec5(%rip),%rbx
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%eax
add    %r12d,%eax
test   %r13d,%r13d
je     1190 <hpack_decode_byte_huffman+0x80>
mov    0x4(%rsp),%ecx
add    $0xffffffff,%ecx
and    $0x7,%ecx
mov    %r13d,%edx
sar    $0x3,%edx
movslq %edx,%rsi
mov    0x8(%rsp),%rdx
mov    (%rdx,%rsi,4),%r12d
mov    %ecx,0x4(%rsp)
shr    %cl,%r12d
and    $0x1,%r12d
add    $0x1,%r13d
mov    0x10(%rsp),%rcx
mov    %r13d,(%rcx)
jmp    1199 <hpack_decode_byte_huffman+0x89>
mov    $0x1,%r12d
xor    %r13d,%r13d
or     %eax,%r12d
xor    %edi,%edi
mov    %r12d,%r15d
sub    %r14d,%r15d
setge  %dil
call   1030 <assert@plt>
lea    0xf4c(%rip),%rax
movzbl 0x0(%rbp,%rax,1),%eax
cmp    %eax,%r15d
jl     121a <hpack_decode_byte_huffman+0x10a>
mov    %eax,%ecx
add    %rcx,%rbx
add    %eax,%r14d
add    %r14d,%r14d
add    $0x1,%rbp
cmp    $0x1e,%rbp
jne    1150 <hpack_decode_byte_huffman+0x40>
lea    0xe22(%rip),%rax
sub    %rax,%rbx
xor    %edi,%edi
cmp    $0x100,%rbx
sete   %dil
call   1030 <assert@plt>
mov    $0x100,%eax
cmp    $0x3fffffff,%r12d
je     1221 <hpack_decode_byte_huffman+0x111>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    0x2dcf(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
jmp    1221 <hpack_decode_byte_huffman+0x111>
movslq %r15d,%rax
movzbl (%rbx,%rax,1),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@hpack_decode_byte_huffman.tab = internal constant [256 x i8] c"012aceiost %-./3456789=A_bdfghlmnpru:BCDEFGHIJKLMNOPQRSTUVWYjkqvwxyz&*,;XZ!\22()?'+|#>\00$@[]~^}<`{\\\C3\D0\80\82\83\A2\B8\C2\E0\E2\99\A1\A7\AC\B0\B1\B3\D1\D8\D9\E3\E5\E6\81\84\85\86\88\92\9A\9C\A0\A3\A4\A9\AA\AD\B2\B5\B9\BA\BB\BD\BE\C4\C6\E4\E8\E9\01\87\89\8A\8B\8C\8D\8F\93\95\96\97\98\9B\9D\9E\A5\A6\A8\AE\AF\B4\B6\B7\BC\BF\C5\E7\EF\09\8E\90\91\94\9F\AB\CE\D7\E1\EC\ED\C7\CF\EA\EB\C0\C1\C8\C9\CA\CD\D2\D5\DA\DB\EE\F0\F2\F3\FF\CB\CC\D3\D4\D6\DD\DE\DF\F1\F4\F5\F6\F7\F8\FA\FB\FC\FD\FE\02\03\04\05\06\07\08\0B\0C\0E\0F\10\11\12\13\14\15\17\18\19\1A\1B\1C\1D\1E\1F\7F\DC\F9\0A\0D\16"
@hpack_decode_byte_huffman.values = internal constant [30 x i8] c"\00\00\00\00\0A\1A \06\00\05\03\02\06\02\03\00\00\00\03\08\0D\1A\1D\0C\04\0F\13\1D\00\03"
@EINVAL = global i32 0
@errno = global i32 0
define i32 @hpack_decode_byte_huffman(i32* noalias %0, i32* noalias %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @hpack_decode_byte_huffman.tab, i64 0, i64 0), i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = sub nsw i32 0, %12
store i32 %13, i32* %9
store i32 0, i32* %10
br label %14
14: ; preds = %86, %2
%15 = load i32, i32* %10
%16 = icmp ult i32 %15, 30
br i1 %16, label %17, label %89
17: ; preds = %14
%18 = load i32, i32* %7
%19 = shl i32 %18, 1
store i32 %19, i32* %7
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %42
23: ; preds = %17
%24 = load i32, i32* %9
%25 = sub i32 %24, 1
%26 = and i32 %25, 7
store i32 %26, i32* %9
%27 = load i32*, i32** %4
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = ashr i32 %29, 3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %9
%35 = lshr i32 %33, %34
%36 = and i32 %35, 1
%37 = load i32, i32* %7
%38 = or i32 %37, %36
store i32 %38, i32* %7
%39 = load i32*, i32** %5
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
br label %45
42: ; preds = %17
%43 = load i32, i32* %7
%44 = or i32 %43, 1
store i32 %44, i32* %7
br label %45
45: ; preds = %42, %23
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = icmp sge i32 %46, %47
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = sub nsw i32 %51, %52
%54 = load i32, i32* %10
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds [30 x i8], [30 x i8]* @hpack_decode_byte_huffman.values, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = icmp slt i32 %53, %58
br i1 %59, label %60, label %69
60: ; preds = %45
%61 = load i8*, i8** %6
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = sub nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %61, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
store i32 %68, i32* %3
br label %101
69: ; preds = %45
%70 = load i32, i32* %10
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds [30 x i8], [30 x i8]* @hpack_decode_byte_huffman.values, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = load i8*, i8** %6
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8* %77, i8** %6
%78 = load i32, i32* %8
%79 = load i32, i32* %10
%80 = zext i32 %79 to i64
%81 = getelementptr inbounds [30 x i8], [30 x i8]* @hpack_decode_byte_huffman.values, i64 0, i64 %80
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = add nsw i32 %78, %83
%85 = mul nsw i32 %84, 2
store i32 %85, i32* %8
br label %86
86: ; preds = %69
%87 = load i32, i32* %10
%88 = add i32 %87, 1
store i32 %88, i32* %10
br label %14
89: ; preds = %14
%90 = load i8*, i8** %6
%91 = ptrtoint i8* %90 to i64
%92 = sub i64 %91, ptrtoint ([256 x i8]* @hpack_decode_byte_huffman.tab to i64)
%93 = icmp eq i64 %92, 256
%94 = zext i1 %93 to i32
%95 = call i32 @assert(i32 %94)
%96 = load i32, i32* %7
%97 = icmp eq i32 %96, 1073741823
br i1 %97, label %98, label %99
98: ; preds = %89
store i32 256, i32* %3
br label %101
99: ; preds = %89
%100 = load i32, i32* @EINVAL
store i32 %100, i32* @errno
store i32 -1, i32* %3
br label %101
101: ; preds = %99, %98, %60
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
@hpack_decode_byte_huffman.tab = internal constant [256 x i8] c"012aceiost %-./3456789=A_bdfghlmnpru:BCDEFGHIJKLMNOPQRSTUVWYjkqvwxyz&*,;XZ!\22()?'+|#>\00$@[]~^}<`{\\\C3\D0\80\82\83\A2\B8\C2\E0\E2\99\A1\A7\AC\B0\B1\B3\D1\D8\D9\E3\E5\E6\81\84\85\86\88\92\9A\9C\A0\A3\A4\A9\AA\AD\B2\B5\B9\BA\BB\BD\BE\C4\C6\E4\E8\E9\01\87\89\8A\8B\8C\8D\8F\93\95\96\97\98\9B\9D\9E\A5\A6\A8\AE\AF\B4\B6\B7\BC\BF\C5\E7\EF\09\8E\90\91\94\9F\AB\CE\D7\E1\EC\ED\C7\CF\EA\EB\C0\C1\C8\C9\CA\CD\D2\D5\DA\DB\EE\F0\F2\F3\FF\CB\CC\D3\D4\D6\DD\DE\DF\F1\F4\F5\F6\F7\F8\FA\FB\FC\FD\FE\02\03\04\05\06\07\08\0B\0C\0E\0F\10\11\12\13\14\15\17\18\19\1A\1B\1C\1D\1E\1F\7F\DC\F9\0A\0D\16"
@hpack_decode_byte_huffman.values = internal unnamed_addr constant [30 x i8] c"\00\00\00\00\0A\1A \06\00\05\03\02\06\02\03\00\00\00\03\08\0D\1A\1D\0C\04\0F\13\1D\00\03"
@EINVAL = global i32 0
@errno = global i32 0
define i32 @hpack_decode_byte_huffman(i32* noalias nocapture %0, i32* noalias nocapture %1) {
%3 = load i32, i32* %1
%4 = sub nsw i32 0, %3
br label %5
5: ; preds = %2, %42
%6 = phi i32 [ %3, %2 ], [ %25, %42 ]
%7 = phi i64 [ 0, %2 ], [ %47, %42 ]
%8 = phi i32 [ %4, %2 ], [ %27, %42 ]
%9 = phi i32 [ 0, %2 ], [ %46, %42 ]
%10 = phi i32 [ 0, %2 ], [ %28, %42 ]
%11 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @hpack_decode_byte_huffman.tab, i64 0, i64 0), %2 ], [ %44, %42 ]
%12 = shl i32 %10, 1
%13 = icmp eq i32 %6, 0
br i1 %13, label %24, label %14
14: ; preds = %5
%15 = add i32 %8, 7
%16 = and i32 %15, 7
%17 = ashr i32 %6, 3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %0, i64 %18
%20 = load i32, i32* %19
%21 = lshr i32 %20, %16
%22 = and i32 %21, 1
%23 = add nsw i32 %6, 1
store i32 %23, i32* %1
br label %24
24: ; preds = %5, %14
%25 = phi i32 [ %23, %14 ], [ 0, %5 ]
%26 = phi i32 [ %22, %14 ], [ 1, %5 ]
%27 = phi i32 [ %16, %14 ], [ %8, %5 ]
%28 = or i32 %26, %12
%29 = icmp sge i32 %28, %9
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
%32 = sub nsw i32 %28, %9
%33 = getelementptr inbounds [30 x i8], [30 x i8]* @hpack_decode_byte_huffman.values, i64 0, i64 %7
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %42
37: ; preds = %24
%38 = sext i32 %32 to i64
%39 = getelementptr inbounds i8, i8* %11, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
br label %58
42: ; preds = %24
%43 = zext i8 %34 to i64
%44 = getelementptr inbounds i8, i8* %11, i64 %43
%45 = add nsw i32 %9, %35
%46 = shl nsw i32 %45, 1
%47 = add nuw nsw i64 %7, 1
%48 = icmp eq i64 %47, 30
br i1 %48, label %49, label %5
49: ; preds = %42
%50 = ptrtoint i8* %44 to i64
%51 = sub i64 %50, ptrtoint ([256 x i8]* @hpack_decode_byte_huffman.tab to i64)
%52 = icmp eq i64 %51, 256
%53 = zext i1 %52 to i32
%54 = tail call i32 @assert(i32 %53)
%55 = icmp eq i32 %28, 1073741823
br i1 %55, label %58, label %56
56: ; preds = %49
%57 = load i32, i32* @EINVAL
store i32 %57, i32* @errno
br label %58
58: ; preds = %37, %49, %56
%59 = phi i32 [ -1, %56 ], [ 256, %49 ], [ %41, %37 ]
ret i32 %59
}