#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 uint8_t;
typedef int const int32_t;

/* Variables and functions */
int const bcf_dec_typed_int1(int const *, int **);
int32_t bcf_dec_size(const uint8_t *p, uint8_t **q, int *type) {
  *type = *p & 0xf;
  if (*p >> 4 != 15) {
    *q = (uint8_t *)p + 1;
    return *p >> 4;
  } else
    return bcf_dec_typed_int1(p + 1, q);
}


x86 assembly (clang, -O0):
<bcf_dec_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0xf,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x4,%eax
cmp    $0xf,%eax
je     1165 <bcf_dec_size+0x55>
mov    -0x10(%rbp),%rcx
add    $0x4,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    1179 <bcf_dec_size+0x69>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <bcf_dec_typed_int1@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcf_dec_size>:
mov    (%rdi),%eax
and    $0xf,%eax
mov    %eax,(%rdx)
mov    (%rdi),%eax
mov    %eax,%ecx
and    $0xfffffff0,%ecx
add    $0x4,%rdi
cmp    $0xf0,%ecx
jne    112f <bcf_dec_size+0x1f>
jmp    1030 <bcf_dec_typed_int1@plt>
mov    %rdi,(%rsi)
sar    $0x4,%eax
ret

LLVM IR (-O0):
define i32 @bcf_dec_size(i32* %0, i32** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32**
%7 = alloca i32*
store i32* %0, i32** %5
store i32** %1, i32*** %6
store i32* %2, i32** %7
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = and i32 %9, 15
%11 = load i32*, i32** %7
store i32 %10, i32* %11
%12 = load i32*, i32** %5
%13 = load i32, i32* %12
%14 = ashr i32 %13, 4
%15 = icmp ne i32 %14, 15
br i1 %15, label %16, label %23
16: ; preds = %3
%17 = load i32*, i32** %5
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = load i32**, i32*** %6
store i32* %18, i32** %19
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = ashr i32 %21, 4
store i32 %22, i32* %4
br label %28
23: ; preds = %3
%24 = load i32*, i32** %5
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32**, i32*** %6
%27 = call i32 @bcf_dec_typed_int1(i32* %25, i32** %26)
store i32 %27, i32* %4
br label %28
28: ; preds = %23, %16
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @bcf_dec_size(i32* %0, i32** %1, i32* nocapture writeonly %2) {
%4 = load i32, i32* %0
%5 = and i32 %4, 15
store i32 %5, i32* %2
%6 = load i32, i32* %0
%7 = and i32 %6, -16
%8 = icmp eq i32 %7, 240
%9 = getelementptr inbounds i32, i32* %0, i64 1
br i1 %8, label %12, label %10
10: ; preds = %3
store i32* %9, i32** %1
%11 = ashr i32 %6, 4
br label %14
12: ; preds = %3
%13 = tail call i32 @bcf_dec_typed_int1(i32* %9, i32** %1)
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ]
ret i32 %15
}