#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*/ _nbits(int *, int);
int nbits(int *, int);
int fun_D(int *bitfill, int gkw) {
  if (gkw == 0xfd) {
    if (nbits(bitfill, 1) == 0)
      return 12;
    else
      return -13;
  }
  if (gkw == 0xfc) {
    if (nbits(bitfill, 1) == 0)
      return 13;
    else
      return -14;
  }
  if (gkw == 0xfe) {
    switch (nbits(bitfill, 2)) {
    case 0:
      return 14;
    case 1:
      return -15;
    case 2:
      return 15;
    case 3:
      return -16;
    }
  }
  if (gkw == 0xff) {
    switch (nbits(bitfill, 3)) {
    case 4:
      return 16;
    case 5:
      return -17;
    case 6:
      return 17;
    case 7:
      return -18;
    case 2:
      return _nbits(bitfill, 1) ? 0xed : 0x12;
    case 3:
      (*bitfill)--;
      return 18;
    }
    return 0xff;
  }
  return gkw;
}


x86 assembly (clang, -O0):
<fun_D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0xfd,-0x14(%rbp)
jne    116b <fun_D+0x4b>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <nbits@plt>
cmp    $0x0,%eax
jne    115f <fun_D+0x3f>
movl   $0xc,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xfffffff3,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
cmpl   $0xfc,-0x14(%rbp)
jne    11a7 <fun_D+0x87>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <nbits@plt>
cmp    $0x0,%eax
jne    119b <fun_D+0x7b>
movl   $0xd,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xfffffff2,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
cmpl   $0xfe,-0x14(%rbp)
jne    121a <fun_D+0xfa>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1040 <nbits@plt>
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1215 <fun_D+0xf5>
mov    -0x20(%rbp),%rax
lea    0xe24(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xe,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xfffffff1,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xf,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xfffffff0,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
jmp    121a <fun_D+0xfa>
cmpl   $0xff,-0x14(%rbp)
jne    12d6 <fun_D+0x1b6>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1040 <nbits@plt>
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     12ca <fun_D+0x1aa>
mov    -0x28(%rbp),%rax
lea    0xdbe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x10,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xffffffef,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0x11,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xffffffee,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <_nbits@plt>
mov    %eax,%edx
mov    $0x12,%eax
mov    $0xed,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
movl   $0x12,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
movl   $0xff,-0x4(%rbp)
jmp    12dc <fun_D+0x1bc>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun_D>:
push   %rbx
mov    %esi,%eax
lea    -0xfc(%rax),%ecx
cmp    $0x3,%ecx
ja     1178 <fun_D+0x58>
mov    %rdi,%rbx
lea    0xec8(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <nbits@plt>
test   %eax,%eax
mov    $0xd,%ecx
mov    $0xfffffff2,%eax
jmp    1175 <fun_D+0x55>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <nbits@plt>
test   %eax,%eax
mov    $0xc,%ecx
mov    $0xfffffff3,%eax
cmove  %ecx,%eax
pop    %rbx
ret
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <nbits@plt>
mov    %eax,%ecx
mov    $0xfe,%eax
cmp    $0x4,%ecx
jae    1178 <fun_D+0x58>
movslq %ecx,%rax
lea    0xe8b(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rbx
ret
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <nbits@plt>
mov    %eax,%ecx
add    $0xfffffffe,%ecx
cmp    $0x5,%ecx
ja     11e9 <fun_D+0xc9>
mov    $0x10,%eax
lea    0xe4b(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <_nbits@plt>
test   %eax,%eax
mov    $0x12,%ecx
mov    $0xed,%eax
jmp    1175 <fun_D+0x55>
mov    $0xff,%eax
pop    %rbx
ret
addl   $0xffffffff,(%rbx)
mov    $0x12,%eax
pop    %rbx
ret
mov    $0xffffffef,%eax
pop    %rbx
ret
mov    $0x11,%eax
pop    %rbx
ret
mov    $0xffffffee,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @fun_D(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 253
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = call i32 @nbits(i32* %9, i32 1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 12, i32* %3
br label %57
13: ; preds = %8
store i32 -13, i32* %3
br label %57
14: ; preds = %2
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 252
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32*, i32** %4
%19 = call i32 @nbits(i32* %18, i32 1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 13, i32* %3
br label %57
22: ; preds = %17
store i32 -14, i32* %3
br label %57
23: ; preds = %14
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 254
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = call i32 @nbits(i32* %27, i32 2)
switch i32 %28, label %33 [
i32 0, label %29
i32 1, label %30
i32 2, label %31
i32 3, label %32
]
29: ; preds = %26
store i32 14, i32* %3
br label %57
30: ; preds = %26
store i32 -15, i32* %3
br label %57
31: ; preds = %26
store i32 15, i32* %3
br label %57
32: ; preds = %26
store i32 -16, i32* %3
br label %57
33: ; preds = %26
br label %34
34: ; preds = %33, %23
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 255
br i1 %36, label %37, label %55
37: ; preds = %34
%38 = load i32*, i32** %4
%39 = call i32 @nbits(i32* %38, i32 3)
switch i32 %39, label %54 [
i32 4, label %40
i32 5, label %41
i32 6, label %42
i32 7, label %43
i32 2, label %44
i32 3, label %50
]
40: ; preds = %37
store i32 16, i32* %3
br label %57
41: ; preds = %37
store i32 -17, i32* %3
br label %57
42: ; preds = %37
store i32 17, i32* %3
br label %57
43: ; preds = %37
store i32 -18, i32* %3
br label %57
44: ; preds = %37
%45 = load i32*, i32** %4
%46 = call i32 @_nbits(i32* %45, i32 1)
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 237, i32 18
store i32 %49, i32* %3
br label %57
50: ; preds = %37
%51 = load i32*, i32** %4
%52 = load i32, i32* %51
%53 = add nsw i32 %52, -1
store i32 %53, i32* %51
store i32 18, i32* %3
br label %57
54: ; preds = %37
store i32 255, i32* %3
br label %57
55: ; preds = %34
%56 = load i32, i32* %5
store i32 %56, i32* %3
br label %57
57: ; preds = %55, %54, %50, %44, %43, %42, %41, %40, %32, %31, %30, %29, %22, %21, %13, %12
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@switch.table.fun_D = [4 x i32] [i32 14, i32 -15, i32 15, i32 -16]
define i32 @fun_D(i32* %0, i32 %1) {
switch i32 %1, label %31 [
i32 253, label %3
i32 252, label %7
i32 254, label %11
i32 255, label %14
]
3: ; preds = %2
%4 = tail call i32 @nbits(i32* %0, i32 1)
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i32 12, i32 -13
br label %31
7: ; preds = %2
%8 = tail call i32 @nbits(i32* %0, i32 1)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 13, i32 -14
br label %31
11: ; preds = %2
%12 = tail call i32 @nbits(i32* %0, i32 2)
%13 = icmp ult i32 %12, 4
br i1 %13, label %27, label %31
14: ; preds = %2
%15 = tail call i32 @nbits(i32* %0, i32 3)
switch i32 %15, label %26 [
i32 4, label %31
i32 5, label %16
i32 6, label %17
i32 7, label %18
i32 2, label %19
i32 3, label %23
]
16: ; preds = %14
br label %31
17: ; preds = %14
br label %31
18: ; preds = %14
br label %31
19: ; preds = %14
%20 = tail call i32 @_nbits(i32* %0, i32 1)
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 18, i32 237
br label %31
23: ; preds = %14
%24 = load i32, i32* %0
%25 = add nsw i32 %24, -1
store i32 %25, i32* %0
br label %31
26: ; preds = %14
br label %31
27: ; preds = %11
%28 = sext i32 %12 to i64
%29 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.fun_D, i64 0, i64 %28
%30 = load i32, i32* %29
br label %31
31: ; preds = %11, %27, %2, %14, %7, %3, %26, %23, %19, %18, %17, %16
%32 = phi i32 [ 255, %26 ], [ 18, %23 ], [ %22, %19 ], [ -18, %18 ], [ 17, %17 ], [ -17, %16 ], [ %6, %3 ], [ %10, %7 ], [ 16, %14 ], [ %1, %2 ], [ %30, %27 ], [ 254, %11 ]
ret i32 %32
}