#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 unsigned int wchar_t;

/* Variables and functions */
wchar_t bem_encode(unsigned int c, char size) {
  if (size <= (11))
    return ((((c >> 6) << 27) >> 19) | ((c << 26) >> 26) | (0xC080));
  else if (size <= (16))
    return ((((c >> 12) << 28) >> 12) | (((c >> 6) << 26) >> 18) |
            ((c << 26) >> 26) | (0xE08080));
  else if (size <= (21))
    return ((((c >> 18) << 29) >> 5) | (((c >> 12) << 26) >> 10) |
            (((c >> 6) << 26) >> 18) | ((c << 26) >> 26) | (0xF0808080));
  else
    return ((0x1A));
}


x86 assembly (clang, -O0):
<bem_encode>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xb,%eax
jg     113e <bem_encode+0x3e>
mov    -0x8(%rbp),%eax
shr    $0x6,%eax
shl    $0x1b,%eax
shr    $0x13,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1a,%ecx
shr    $0x1a,%ecx
or     %ecx,%eax
or     $0xc080,%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <bem_encode+0xd1>
movsbl -0x9(%rbp),%eax
cmp    $0x10,%eax
jg     117d <bem_encode+0x7d>
mov    -0x8(%rbp),%eax
shr    $0xc,%eax
shl    $0x1c,%eax
shr    $0xc,%eax
mov    -0x8(%rbp),%ecx
shr    $0x6,%ecx
shl    $0x1a,%ecx
shr    $0x12,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1a,%ecx
shr    $0x1a,%ecx
or     %ecx,%eax
or     $0xe08080,%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <bem_encode+0xd1>
movsbl -0x9(%rbp),%eax
cmp    $0x15,%eax
jg     11ca <bem_encode+0xca>
mov    -0x8(%rbp),%eax
shr    $0x12,%eax
shl    $0x1d,%eax
shr    $0x5,%eax
mov    -0x8(%rbp),%ecx
shr    $0xc,%ecx
shl    $0x1a,%ecx
shr    $0xa,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
shr    $0x6,%ecx
shl    $0x1a,%ecx
shr    $0x12,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1a,%ecx
shr    $0x1a,%ecx
or     %ecx,%eax
or     $0xf0808080,%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <bem_encode+0xd1>
movl   $0x1a,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bem_encode>:
cmp    $0xb,%sil
jg     1119 <bem_encode+0x19>
mov    %edi,%eax
and    $0x7c0,%eax
and    $0x3f,%edi
lea    (%rdi,%rax,4),%eax
add    $0xc080,%eax
ret
cmp    $0x10,%sil
ja     113f <bem_encode+0x3f>
mov    %edi,%eax
shl    $0x4,%eax
and    $0xf0000,%eax
mov    %edi,%ecx
and    $0xfc0,%ecx
and    $0x3f,%edi
lea    (%rdi,%rcx,4),%ecx
add    %ecx,%eax
add    $0xe08080,%eax
ret
mov    $0x1a,%eax
cmp    $0x15,%sil
ja     1176 <bem_encode+0x76>
mov    %edi,%eax
shl    $0x6,%eax
and    $0x7000000,%eax
mov    %edi,%ecx
shl    $0x4,%ecx
and    $0x3f0000,%ecx
mov    %edi,%edx
and    $0xfc0,%edx
and    $0x3f,%edi
or     %ecx,%edi
or     %eax,%edi
lea    (%rdi,%rdx,4),%eax
add    $0xf0808080,%eax
ret

LLVM IR (-O0):
define i32 @bem_encode(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp sle i32 %7, 11
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i32, i32* %4
%11 = lshr i32 %10, 6
%12 = shl i32 %11, 27
%13 = lshr i32 %12, 19
%14 = load i32, i32* %4
%15 = shl i32 %14, 26
%16 = lshr i32 %15, 26
%17 = or i32 %13, %16
%18 = or i32 %17, 49280
store i32 %18, i32* %3
br label %63
19: ; preds = %2
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 16
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load i32, i32* %4
%25 = lshr i32 %24, 12
%26 = shl i32 %25, 28
%27 = lshr i32 %26, 12
%28 = load i32, i32* %4
%29 = lshr i32 %28, 6
%30 = shl i32 %29, 26
%31 = lshr i32 %30, 18
%32 = or i32 %27, %31
%33 = load i32, i32* %4
%34 = shl i32 %33, 26
%35 = lshr i32 %34, 26
%36 = or i32 %32, %35
%37 = or i32 %36, 14712960
store i32 %37, i32* %3
br label %63
38: ; preds = %19
%39 = load i8, i8* %5
%40 = sext i8 %39 to i32
%41 = icmp sle i32 %40, 21
br i1 %41, label %42, label %62
42: ; preds = %38
%43 = load i32, i32* %4
%44 = lshr i32 %43, 18
%45 = shl i32 %44, 29
%46 = lshr i32 %45, 5
%47 = load i32, i32* %4
%48 = lshr i32 %47, 12
%49 = shl i32 %48, 26
%50 = lshr i32 %49, 10
%51 = or i32 %46, %50
%52 = load i32, i32* %4
%53 = lshr i32 %52, 6
%54 = shl i32 %53, 26
%55 = lshr i32 %54, 18
%56 = or i32 %51, %55
%57 = load i32, i32* %4
%58 = shl i32 %57, 26
%59 = lshr i32 %58, 26
%60 = or i32 %56, %59
%61 = or i32 %60, -260013952
store i32 %61, i32* %3
br label %63
62: ; preds = %38
store i32 26, i32* %3
br label %63
63: ; preds = %62, %42, %23, %9
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
define i32 @bem_encode(i32 %0, i8 signext %1) {
%3 = icmp slt i8 %1, 12
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = shl i32 %0, 2
%6 = and i32 %5, 7936
%7 = and i32 %0, 63
%8 = or i32 %7, %6
%9 = or i32 %8, 49280
br label %35
10: ; preds = %2
%11 = icmp ult i8 %1, 17
br i1 %11, label %12, label %21
12: ; preds = %10
%13 = shl i32 %0, 4
%14 = and i32 %13, 983040
%15 = shl i32 %0, 2
%16 = and i32 %15, 16128
%17 = and i32 %0, 63
%18 = or i32 %17, %16
%19 = or i32 %18, %14
%20 = or i32 %19, 14712960
br label %35
21: ; preds = %10
%22 = icmp ult i8 %1, 22
br i1 %22, label %23, label %35
23: ; preds = %21
%24 = shl i32 %0, 6
%25 = and i32 %24, 117440512
%26 = shl i32 %0, 4
%27 = and i32 %26, 4128768
%28 = shl i32 %0, 2
%29 = and i32 %28, 16128
%30 = and i32 %0, 63
%31 = or i32 %30, %27
%32 = or i32 %31, %25
%33 = or i32 %32, %29
%34 = or i32 %33, -260013952
br label %35
35: ; preds = %21, %23, %12, %4
%36 = phi i32 [ %9, %4 ], [ %20, %12 ], [ %34, %23 ], [ 26, %21 ]
ret i32 %36
}