#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 */

/* Variables and functions */
int input_bit(unsigned char *);
int input_nbits(unsigned char *, int);
int input_huffman(unsigned char *infile) {
  int c;
  c = input_nbits(infile, 3);
  if (c < 4) {
    return (1 << c);
  }
  c = input_bit(infile) | (c << 1);
  if (c < 13) {
    switch (c) {
    case 8:
      return (3);
    case 9:
      return (5);
    case 10:
      return (10);
    case 11:
      return (12);
    case 12:
      return (15);
    }
  }
  c = input_bit(infile) | (c << 1);
  if (c < 31) {
    switch (c) {
    case 26:
      return (6);
    case 27:
      return (7);
    case 28:
      return (9);
    case 29:
      return (11);
    case 30:
      return (13);
    }
  }
  c = input_bit(infile) | (c << 1);
  if (c == 62) {
    return (0);
  } else {
    return (14);
  }
}


x86 assembly (clang, -O0):
<input_huffman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1040 <input_nbits@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1159 <input_huffman+0x39>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
mov    -0x10(%rbp),%rdi
call   1030 <input_bit@plt>
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xd,-0x14(%rbp)
jge    11e1 <input_huffman+0xc1>
mov    -0x14(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     11dc <input_huffman+0xbc>
mov    -0x20(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x3,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0x5,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0xa,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0xc,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0xf,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
jmp    11e1 <input_huffman+0xc1>
mov    -0x10(%rbp),%rdi
call   1030 <input_bit@plt>
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1f,-0x14(%rbp)
jge    1269 <input_huffman+0x149>
mov    -0x14(%rbp),%eax
add    $0xffffffe6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     1264 <input_huffman+0x144>
mov    -0x28(%rbp),%rax
lea    0xdf5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x6,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0x7,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0x9,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0xb,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0xd,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
jmp    1269 <input_huffman+0x149>
mov    -0x10(%rbp),%rdi
call   1030 <input_bit@plt>
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3e,-0x14(%rbp)
jne    1293 <input_huffman+0x173>
movl   $0x0,-0x4(%rbp)
jmp    129a <input_huffman+0x17a>
movl   $0xe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_huffman>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x3,%esi
call   1040 <input_nbits@plt>
mov    %eax,%ebx
cmp    $0x3,%eax
jg     1143 <input_huffman+0x23>
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
jmp    11a7 <input_huffman+0x87>
mov    %r14,%rdi
call   1030 <input_bit@plt>
add    %ebx,%ebx
or     %eax,%ebx
cmp    $0xc,%ebx
jg     1167 <input_huffman+0x47>
lea    -0x8(%rbx),%eax
cmp    $0x5,%eax
jae    1167 <input_huffman+0x47>
cltq
lea    0xe9b(%rip),%rcx
jmp    1189 <input_huffman+0x69>
mov    %r14,%rdi
call   1030 <input_bit@plt>
add    %ebx,%ebx
or     %eax,%ebx
cmp    $0x1e,%ebx
jg     118e <input_huffman+0x6e>
lea    -0x1a(%rbx),%eax
cmp    $0x5,%eax
jae    118e <input_huffman+0x6e>
cltq
lea    0xe8b(%rip),%rcx
mov    (%rcx,%rax,4),%eax
jmp    11a7 <input_huffman+0x87>
mov    %r14,%rdi
call   1030 <input_bit@plt>
add    %ebx,%ebx
or     %eax,%ebx
xor    %ecx,%ecx
cmp    $0x3e,%ebx
mov    $0xe,%eax
cmove  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @input_huffman(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @input_nbits(i8* %5, i32 3)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %4
%11 = shl i32 1, %10
store i32 %11, i32* %2
br label %54
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @input_bit(i8* %13)
%15 = load i32, i32* %4
%16 = shl i32 %15, 1
%17 = or i32 %14, %16
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 13
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i32, i32* %4
switch i32 %21, label %27 [
i32 8, label %22
i32 9, label %23
i32 10, label %24
i32 11, label %25
i32 12, label %26
]
22: ; preds = %20
store i32 3, i32* %2
br label %54
23: ; preds = %20
store i32 5, i32* %2
br label %54
24: ; preds = %20
store i32 10, i32* %2
br label %54
25: ; preds = %20
store i32 12, i32* %2
br label %54
26: ; preds = %20
store i32 15, i32* %2
br label %54
27: ; preds = %20
br label %28
28: ; preds = %27, %12
%29 = load i8*, i8** %3
%30 = call i32 @input_bit(i8* %29)
%31 = load i32, i32* %4
%32 = shl i32 %31, 1
%33 = or i32 %30, %32
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 31
br i1 %35, label %36, label %44
36: ; preds = %28
%37 = load i32, i32* %4
switch i32 %37, label %43 [
i32 26, label %38
i32 27, label %39
i32 28, label %40
i32 29, label %41
i32 30, label %42
]
38: ; preds = %36
store i32 6, i32* %2
br label %54
39: ; preds = %36
store i32 7, i32* %2
br label %54
40: ; preds = %36
store i32 9, i32* %2
br label %54
41: ; preds = %36
store i32 11, i32* %2
br label %54
42: ; preds = %36
store i32 13, i32* %2
br label %54
43: ; preds = %36
br label %44
44: ; preds = %43, %28
%45 = load i8*, i8** %3
%46 = call i32 @input_bit(i8* %45)
%47 = load i32, i32* %4
%48 = shl i32 %47, 1
%49 = or i32 %46, %48
store i32 %49, i32* %4
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 62
br i1 %51, label %52, label %53
52: ; preds = %44
store i32 0, i32* %2
br label %54
53: ; preds = %44
store i32 14, i32* %2
br label %54
54: ; preds = %53, %52, %42, %41, %40, %39, %38, %26, %25, %24, %23, %22, %9
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@switch.table.input_huffman = [5 x i32] [i32 3, i32 5, i32 10, i32 12, i32 15]
@switch.table.input_huffman.1 = [5 x i32] [i32 6, i32 7, i32 9, i32 11, i32 13]
define i32 @input_huffman(i8* %0) {
%2 = tail call i32 @input_nbits(i8* %0, i32 3)
%3 = icmp slt i32 %2, 4
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = shl nuw nsw i32 1, %2
br label %36
6: ; preds = %1
%7 = tail call i32 @input_bit(i8* %0)
%8 = shl nuw i32 %2, 1
%9 = or i32 %7, %8
%10 = icmp slt i32 %9, 13
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = add i32 %9, -8
%13 = icmp ult i32 %12, 5
br i1 %13, label %28, label %14
14: ; preds = %11, %6
%15 = tail call i32 @input_bit(i8* %0)
%16 = shl i32 %9, 1
%17 = or i32 %15, %16
%18 = icmp slt i32 %17, 31
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = add i32 %17, -26
%21 = icmp ult i32 %20, 5
br i1 %21, label %32, label %22
22: ; preds = %19, %14
%23 = tail call i32 @input_bit(i8* %0)
%24 = shl i32 %17, 1
%25 = or i32 %23, %24
%26 = icmp eq i32 %25, 62
%27 = select i1 %26, i32 0, i32 14
br label %36
28: ; preds = %11
%29 = sext i32 %12 to i64
%30 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.input_huffman, i64 0, i64 %29
%31 = load i32, i32* %30
br label %36
32: ; preds = %19
%33 = sext i32 %20 to i64
%34 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.input_huffman.1, i64 0, i64 %33
%35 = load i32, i32* %34
br label %36
36: ; preds = %32, %28, %22, %4
%37 = phi i32 [ %5, %4 ], [ %27, %22 ], [ %31, %28 ], [ %35, %32 ]
ret i32 %37
}