#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 /*<<< orphan*/ LZRFillBuffer(unsigned int *, unsigned int *, unsigned int *,
                                 unsigned char **);
char LZRNextBit(unsigned char *, int *, unsigned int *, unsigned int *,
                unsigned int *, unsigned char **);
int LZRGetNumber(signed char n_bits, unsigned char *buf_ptr, char inc,
                 char *flag, unsigned int *mask, unsigned int *buffer,
                 unsigned char **next_in) {
  int number = 1;
  if (n_bits >= 3) {
    LZRNextBit(buf_ptr + 3 * inc, &number, mask, mask, buffer, next_in);
    if (n_bits >= 4) {
      LZRNextBit(buf_ptr + 3 * inc, &number, mask, mask, buffer, next_in);
      if (n_bits >= 5) {
        LZRFillBuffer(mask, mask, buffer, next_in);
        for (; n_bits >= 5; n_bits--) {
          number <<= 1;
          (*mask) >>= 1;
          if (*buffer < *mask)
            number++;
          else
            (*buffer) -= *mask;
        }
      }
    }
  }
  *flag = LZRNextBit(buf_ptr, &number, mask, mask, buffer, next_in);
  if (n_bits >= 1) {
    LZRNextBit(buf_ptr + inc, &number, mask, mask, buffer, next_in);
    if (n_bits >= 2) {
      LZRNextBit(buf_ptr + 2 * inc, &number, mask, mask, buffer, next_in);
    }
  }
  return number;
}


x86 assembly (clang, -O0):
<LZRGetNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %dil,%dl
mov    0x10(%rbp),%rdi
mov    %dl,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jl     124e <LZRGetNumber+0x12e>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%eax
imul   $0x3,%eax,%eax
cltq
add    %rax,%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
lea    -0x34(%rbp),%rsi
call   1040 <LZRNextBit@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x4,%eax
jl     1249 <LZRGetNumber+0x129>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%eax
imul   $0x3,%eax,%eax
cltq
add    %rax,%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
lea    -0x34(%rbp),%rsi
call   1040 <LZRNextBit@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x5,%eax
jl     1244 <LZRGetNumber+0x124>
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    0x10(%rbp),%rcx
call   1030 <LZRFillBuffer@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x5,%eax
jl     123f <LZRGetNumber+0x11f>
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
shr    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jae    121d <LZRGetNumber+0xfd>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    122d <LZRGetNumber+0x10d>
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    1232 <LZRGetNumber+0x112>
mov    -0x1(%rbp),%al
add    $0xff,%al
mov    %al,-0x1(%rbp)
jmp    11dc <LZRGetNumber+0xbc>
jmp    1244 <LZRGetNumber+0x124>
jmp    1249 <LZRGetNumber+0x129>
jmp    124e <LZRGetNumber+0x12e>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
lea    -0x34(%rbp),%rsi
call   1040 <LZRNextBit@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
movsbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jl     12e1 <LZRGetNumber+0x1c1>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
lea    -0x34(%rbp),%rsi
call   1040 <LZRNextBit@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jl     12dc <LZRGetNumber+0x1bc>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
lea    -0x34(%rbp),%rsi
call   1040 <LZRNextBit@plt>
jmp    12e1 <LZRGetNumber+0x1c1>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LZRGetNumber>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r14
mov    %r8,%rbx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %edi,%r15d
mov    0x50(%rsp),%r13
movl   $0x1,0x4(%rsp)
cmp    $0x3,%r15b
jl     1205 <LZRGetNumber+0xe5>
mov    %rcx,0x10(%rsp)
mov    %r13,%r9
mov    %ebp,0x8(%rsp)
movsbq %bpl,%r13
lea    0x0(,%r13,2),%rbp
add    %r13,%rbp
add    %r12,%rbp
lea    0x4(%rsp),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1040 <LZRNextBit@plt>
cmp    $0x3,%r15b
je     1264 <LZRGetNumber+0x144>
lea    0x4(%rsp),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    0x50(%rsp),%r9
call   1040 <LZRNextBit@plt>
cmp    $0x5,%r15b
jb     1264 <LZRGetNumber+0x144>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    0x50(%rsp),%rcx
mov    %rcx,%rbp
call   1030 <LZRFillBuffer@plt>
mov    0x4(%rsp),%eax
add    $0x1,%r15b
jmp    11f1 <LZRGetNumber+0xd1>
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,(%r14)
add    $0xff,%r15b
cmp    $0x5,%r15b
jle    12ab <LZRGetNumber+0x18b>
add    %eax,%eax
mov    (%rbx),%edx
shr    %edx
mov    %edx,(%rbx)
mov    (%r14),%ecx
sub    %edx,%ecx
jae    11e0 <LZRGetNumber+0xc0>
or     $0x1,%eax
jmp    11e3 <LZRGetNumber+0xc3>
lea    0x4(%rsp),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r12,0x8(%rsp)
mov    %rcx,%r12
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r13,%r9
call   1040 <LZRNextBit@plt>
mov    %al,(%r12)
mov    0x8(%rsp),%r12
test   %r15b,%r15b
jle    1317 <LZRGetNumber+0x1f7>
movsbq %bpl,%rdi
add    %r12,%rdi
lea    0x4(%rsp),%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r13,%r9
call   1040 <LZRNextBit@plt>
cmp    $0x1,%r15b
jne    12f3 <LZRGetNumber+0x1d3>
jmp    1317 <LZRGetNumber+0x1f7>
lea    0x4(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    0x50(%rsp),%rbp
mov    %rbp,%r9
call   1040 <LZRNextBit@plt>
mov    0x10(%rsp),%rcx
mov    %al,(%rcx)
add    %r12,%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %rbp,%r9
call   1040 <LZRNextBit@plt>
mov    %rbp,%r13
jmp    12ef <LZRGetNumber+0x1cf>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %rbp,%r9
call   1040 <LZRNextBit@plt>
mov    0x10(%rsp),%rcx
mov    %al,(%rcx)
add    %r12,%r13
mov    %r13,%rdi
mov    %rbp,%r13
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %rbp,%r9
call   1040 <LZRNextBit@plt>
mov    0x8(%rsp),%ebp
movsbl %bpl,%eax
add    %eax,%eax
cltq
add    %rax,%r12
lea    0x4(%rsp),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r13,%r9
call   1040 <LZRNextBit@plt>
mov    0x4(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @LZRGetNumber(i8 signext %0, i8* %1, i8 signext %2, i8* %3, i32* %4, i32* %5, i8** %6) {
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i8**
%15 = alloca i32
store i8 %0, i8* %8
store i8* %1, i8** %9
store i8 %2, i8* %10
store i8* %3, i8** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i8** %6, i8*** %14
store i32 1, i32* %15
%16 = load i8, i8* %8
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 3
br i1 %18, label %19, label %86
19: ; preds = %7
%20 = load i8*, i8** %9
%21 = load i8, i8* %10
%22 = sext i8 %21 to i32
%23 = mul nsw i32 3, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
%26 = load i32*, i32** %12
%27 = load i32*, i32** %12
%28 = load i32*, i32** %13
%29 = load i8**, i8*** %14
%30 = call signext i8 @LZRNextBit(i8* %25, i32* %15, i32* %26, i32* %27, i32* %28, i8** %29)
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp sge i32 %32, 4
br i1 %33, label %34, label %85
34: ; preds = %19
%35 = load i8*, i8** %9
%36 = load i8, i8* %10
%37 = sext i8 %36 to i32
%38 = mul nsw i32 3, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %35, i64 %39
%41 = load i32*, i32** %12
%42 = load i32*, i32** %12
%43 = load i32*, i32** %13
%44 = load i8**, i8*** %14
%45 = call signext i8 @LZRNextBit(i8* %40, i32* %15, i32* %41, i32* %42, i32* %43, i8** %44)
%46 = load i8, i8* %8
%47 = sext i8 %46 to i32
%48 = icmp sge i32 %47, 5
br i1 %48, label %49, label %84
49: ; preds = %34
%50 = load i32*, i32** %12
%51 = load i32*, i32** %12
%52 = load i32*, i32** %13
%53 = load i8**, i8*** %14
%54 = call i32 @LZRFillBuffer(i32* %50, i32* %51, i32* %52, i8** %53)
br label %55
55: ; preds = %80, %49
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = icmp sge i32 %57, 5
br i1 %58, label %59, label %83
59: ; preds = %55
%60 = load i32, i32* %15
%61 = shl i32 %60, 1
store i32 %61, i32* %15
%62 = load i32*, i32** %12
%63 = load i32, i32* %62
%64 = lshr i32 %63, 1
store i32 %64, i32* %62
%65 = load i32*, i32** %13
%66 = load i32, i32* %65
%67 = load i32*, i32** %12
%68 = load i32, i32* %67
%69 = icmp ult i32 %66, %68
br i1 %69, label %70, label %73
70: ; preds = %59
%71 = load i32, i32* %15
%72 = add nsw i32 %71, 1
store i32 %72, i32* %15
br label %79
73: ; preds = %59
%74 = load i32*, i32** %12
%75 = load i32, i32* %74
%76 = load i32*, i32** %13
%77 = load i32, i32* %76
%78 = sub i32 %77, %75
store i32 %78, i32* %76
br label %79
79: ; preds = %73, %70
br label %80
80: ; preds = %79
%81 = load i8, i8* %8
%82 = add i8 %81, -1
store i8 %82, i8* %8
br label %55
83: ; preds = %55
br label %84
84: ; preds = %83, %34
br label %85
85: ; preds = %84, %19
br label %86
86: ; preds = %85, %7
%87 = load i8*, i8** %9
%88 = load i32*, i32** %12
%89 = load i32*, i32** %12
%90 = load i32*, i32** %13
%91 = load i8**, i8*** %14
%92 = call signext i8 @LZRNextBit(i8* %87, i32* %15, i32* %88, i32* %89, i32* %90, i8** %91)
%93 = load i8*, i8** %11
store i8 %92, i8* %93
%94 = load i8, i8* %8
%95 = sext i8 %94 to i32
%96 = icmp sge i32 %95, 1
br i1 %96, label %97, label %124
97: ; preds = %86
%98 = load i8*, i8** %9
%99 = load i8, i8* %10
%100 = sext i8 %99 to i32
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %98, i64 %101
%103 = load i32*, i32** %12
%104 = load i32*, i32** %12
%105 = load i32*, i32** %13
%106 = load i8**, i8*** %14
%107 = call signext i8 @LZRNextBit(i8* %102, i32* %15, i32* %103, i32* %104, i32* %105, i8** %106)
%108 = load i8, i8* %8
%109 = sext i8 %108 to i32
%110 = icmp sge i32 %109, 2
br i1 %110, label %111, label %123
111: ; preds = %97
%112 = load i8*, i8** %9
%113 = load i8, i8* %10
%114 = sext i8 %113 to i32
%115 = mul nsw i32 2, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %112, i64 %116
%118 = load i32*, i32** %12
%119 = load i32*, i32** %12
%120 = load i32*, i32** %13
%121 = load i8**, i8*** %14
%122 = call signext i8 @LZRNextBit(i8* %117, i32* %15, i32* %118, i32* %119, i32* %120, i8** %121)
br label %123
123: ; preds = %111, %97
br label %124
124: ; preds = %123, %86
%125 = load i32, i32* %15
ret i32 %125
}

LLVM IR (-O2):
define i32 @LZRGetNumber(i8 signext %0, i8* %1, i8 signext %2, i8* nocapture writeonly %3, i32* %4, i32* %5, i8** %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%10 = icmp sgt i8 %0, 2
br i1 %10, label %11, label %48
11: ; preds = %7
%12 = sext i8 %2 to i64
%13 = mul nsw i64 %12, 3
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = call signext i8 @LZRNextBit(i8* %14, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
%16 = icmp eq i8 %0, 3
br i1 %16, label %39, label %17
17: ; preds = %11
%18 = call signext i8 @LZRNextBit(i8* %14, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
%19 = icmp ugt i8 %0, 4
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = call i32 @LZRFillBuffer(i32* %4, i32* %4, i32* %5, i8** %6)
%22 = load i32, i32* %8
br label %23
23: ; preds = %20, %35
%24 = phi i8 [ %37, %35 ], [ %0, %20 ]
%25 = phi i32 [ %36, %35 ], [ %22, %20 ]
%26 = shl i32 %25, 1
%27 = load i32, i32* %4
%28 = lshr i32 %27, 1
store i32 %28, i32* %4
%29 = load i32, i32* %5
%30 = icmp ult i32 %29, %28
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = or i32 %26, 1
br label %35
33: ; preds = %23
%34 = sub i32 %29, %28
store i32 %34, i32* %5
br label %35
35: ; preds = %31, %33
%36 = phi i32 [ %32, %31 ], [ %26, %33 ]
%37 = add nsw i8 %24, -1
%38 = icmp sgt i8 %24, 5
br i1 %38, label %23, label %43
39: ; preds = %11, %17
%40 = call signext i8 @LZRNextBit(i8* %1, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
store i8 %40, i8* %3
%41 = getelementptr inbounds i8, i8* %1, i64 %12
%42 = call signext i8 @LZRNextBit(i8* %41, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
br label %56
43: ; preds = %35
store i32 %36, i32* %8
%44 = call signext i8 @LZRNextBit(i8* %1, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
store i8 %44, i8* %3
%45 = sext i8 %2 to i64
%46 = getelementptr inbounds i8, i8* %1, i64 %45
%47 = call signext i8 @LZRNextBit(i8* %46, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
br label %56
48: ; preds = %7
%49 = call signext i8 @LZRNextBit(i8* %1, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
store i8 %49, i8* %3
%50 = icmp sgt i8 %0, 0
br i1 %50, label %51, label %62
51: ; preds = %48
%52 = sext i8 %2 to i64
%53 = getelementptr inbounds i8, i8* %1, i64 %52
%54 = call signext i8 @LZRNextBit(i8* %53, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
%55 = icmp eq i8 %0, 1
br i1 %55, label %62, label %56
56: ; preds = %43, %39, %51
%57 = sext i8 %2 to i32
%58 = shl nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %1, i64 %59
%61 = call signext i8 @LZRNextBit(i8* %60, i32* %8, i32* %4, i32* %4, i32* %5, i8** %6)
br label %62
62: ; preds = %51, %56, %48
%63 = load i32, i32* %8
ret i32 %63
}