#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 nbits(int *, int);
int /*<<< orphan*/ refill(int *);
int fun_B(int *bitfill) {
  static int tab1[] = {0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11,
                       12, 13, 14, 15, 31, 31, 31, 31, 31, 31, 31, 31,
                       31, 31, 31, 31, 31, 31, 31, 31, 31, 16, 17, 18,
                       19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
  static int tab[] = {4,   5,   6,   7,   8,   9,   10,  11,  12, 13, 14,
                      15,  16,  17,  18,  19,  -5,  -6,  -7,  -8, -9, -10,
                      -11, -12, -13, -14, -15, -16, -17, -18, -19};
  unsigned int tmp;
  tmp = nbits(bitfill, 7) - 68;
  refill(bitfill);
  if (tmp > 47)
    return 0xff;
  return tab[tab1[tmp]];
}


x86 assembly (clang, -O0):
<fun_B>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x7,%esi
call   1030 <nbits@plt>
sub    $0x44,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <refill@plt>
cmpl   $0x2f,-0x14(%rbp)
jbe    115f <fun_B+0x3f>
movl   $0xff,-0x4(%rbp)
jmp    117c <fun_B+0x5c>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2ed5(%rip),%rax
movslq (%rax,%rcx,4),%rcx
lea    0x2f8a(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun_B>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x7,%esi
call   1030 <nbits@plt>
mov    %eax,%ebx
add    $0xffffffbc,%ebx
mov    %r14,%rdi
call   1040 <refill@plt>
mov    $0xff,%eax
cmp    $0x2f,%ebx
ja     115f <fun_B+0x3f>
mov    %ebx,%eax
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
lea    0xf64(%rip),%rcx
mov    (%rcx,%rax,4),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@fun_B.tab1 = internal global [48 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30]
@fun_B.tab = internal global [31 x i32] [i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 -5, i32 -6, i32 -7, i32 -8, i32 -9, i32 -10, i32 -11, i32 -12, i32 -13, i32 -14, i32 -15, i32 -16, i32 -17, i32 -18, i32 -19]
define i32 @fun_B(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 @nbits(i32* %5, i32 7)
%7 = sub nsw i32 %6, 68
store i32 %7, i32* %4
%8 = load i32*, i32** %3
%9 = call i32 @refill(i32* %8)
%10 = load i32, i32* %4
%11 = icmp ugt i32 %10, 47
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 255, i32* %2
br label %21
13: ; preds = %1
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [48 x i32], [48 x i32]* @fun_B.tab1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [31 x i32], [31 x i32]* @fun_B.tab, i64 0, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %2
br label %21
21: ; preds = %13, %12
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@fun_B.tab1 = internal unnamed_addr constant [48 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30]
@fun_B.tab = internal unnamed_addr constant [31 x i32] [i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 -5, i32 -6, i32 -7, i32 -8, i32 -9, i32 -10, i32 -11, i32 -12, i32 -13, i32 -14, i32 -15, i32 -16, i32 -17, i32 -18, i32 -19]
define i32 @fun_B(i32* %0) {
%2 = tail call i32 @nbits(i32* %0, i32 7)
%3 = add nsw i32 %2, -68
%4 = tail call i32 @refill(i32* %0)
%5 = icmp ugt i32 %3, 47
br i1 %5, label %13, label %6
6: ; preds = %1
%7 = zext i32 %3 to i64
%8 = getelementptr inbounds [48 x i32], [48 x i32]* @fun_B.tab1, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [31 x i32], [31 x i32]* @fun_B.tab, i64 0, i64 %10
%12 = load i32, i32* %11
br label %13
13: ; preds = %1, %6
%14 = phi i32 [ %12, %6 ], [ 255, %1 ]
ret i32 %14
}