#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 lem_encode(unsigned int c, char size) {
  if (size <= (11))
    return (((c << 21) >> 27) | ((c << 26) >> 18) | (0x80C0));
  else if (size <= (16))
    return (((c << 16) >> 28) | (((c >> 6) << 26) >> 18) | ((c << 26) >> 10) |
            (0x8080E0));
  else if (size <= (21))
    return (((c << 11) >> 29) | (((c >> 12) << 26) >> 18) |
            (((c >> 6) << 26) >> 10) | ((c << 26) >> 2) | (0x808080F0));
  else
    return ((0x1A));
}


x86 assembly (clang, -O0):
<lem_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     113b <lem_encode+0x3b>
mov    -0x8(%rbp),%eax
shl    $0x15,%eax
shr    $0x1b,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1a,%ecx
shr    $0x12,%ecx
or     %ecx,%eax
or     $0x80c0,%eax
mov    %eax,-0x4(%rbp)
jmp    11c8 <lem_encode+0xc8>
movsbl -0x9(%rbp),%eax
cmp    $0x10,%eax
jg     1177 <lem_encode+0x77>
mov    -0x8(%rbp),%eax
shl    $0x10,%eax
shr    $0x1c,%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    $0xa,%ecx
or     %ecx,%eax
or     $0x8080e0,%eax
mov    %eax,-0x4(%rbp)
jmp    11c8 <lem_encode+0xc8>
movsbl -0x9(%rbp),%eax
cmp    $0x15,%eax
jg     11c1 <lem_encode+0xc1>
mov    -0x8(%rbp),%eax
shl    $0xb,%eax
shr    $0x1d,%eax
mov    -0x8(%rbp),%ecx
shr    $0xc,%ecx
shl    $0x1a,%ecx
shr    $0x12,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
shr    $0x6,%ecx
shl    $0x1a,%ecx
shr    $0xa,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1a,%ecx
shr    $0x2,%ecx
or     %ecx,%eax
or     $0x808080f0,%eax
mov    %eax,-0x4(%rbp)
jmp    11c8 <lem_encode+0xc8>
movl   $0x1a,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<lem_encode>:
cmp    $0xb,%sil
jg     111c <lem_encode+0x1c>
mov    %edi,%eax
shr    $0x6,%eax
and    $0x1f,%eax
and    $0x3f,%edi
shl    $0x8,%edi
add    %edi,%eax
add    $0x80c0,%eax
ret
cmp    $0x10,%sil
ja     1143 <lem_encode+0x43>
mov    %edi,%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %edi,%ecx
and    $0xfc0,%ecx
and    $0x3f,%edi
shl    $0x10,%edi
lea    (%rax,%rcx,4),%eax
add    %edi,%eax
add    $0x8080e0,%eax
ret
mov    $0x1a,%eax
cmp    $0x15,%sil
ja     117c <lem_encode+0x7c>
mov    %edi,%eax
shr    $0x12,%eax
and    $0x7,%eax
mov    %edi,%ecx
shr    $0x4,%ecx
and    $0x3f00,%ecx
or     %eax,%ecx
mov    %edi,%eax
shl    $0xa,%eax
and    $0x3f0000,%eax
or     %ecx,%eax
and    $0x3f,%edi
shl    $0x18,%edi
add    %edi,%eax
add    $0x808080f0,%eax
ret

LLVM IR (-O0):
define i32 @lem_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 %18
9: ; preds = %2
%10 = load i32, i32* %4
%11 = shl i32 %10, 21
%12 = lshr i32 %11, 27
%13 = load i32, i32* %4
%14 = shl i32 %13, 26
%15 = lshr i32 %14, 18
%16 = or i32 %12, %15
%17 = or i32 %16, 32960
store i32 %17, i32* %3
br label %60
18: ; preds = %2
%19 = load i8, i8* %5
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 16
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32, i32* %4
%24 = shl i32 %23, 16
%25 = lshr i32 %24, 28
%26 = load i32, i32* %4
%27 = lshr i32 %26, 6
%28 = shl i32 %27, 26
%29 = lshr i32 %28, 18
%30 = or i32 %25, %29
%31 = load i32, i32* %4
%32 = shl i32 %31, 26
%33 = lshr i32 %32, 10
%34 = or i32 %30, %33
%35 = or i32 %34, 8421600
store i32 %35, i32* %3
br label %60
36: ; preds = %18
%37 = load i8, i8* %5
%38 = sext i8 %37 to i32
%39 = icmp sle i32 %38, 21
br i1 %39, label %40, label %59
40: ; preds = %36
%41 = load i32, i32* %4
%42 = shl i32 %41, 11
%43 = lshr i32 %42, 29
%44 = load i32, i32* %4
%45 = lshr i32 %44, 12
%46 = shl i32 %45, 26
%47 = lshr i32 %46, 18
%48 = or i32 %43, %47
%49 = load i32, i32* %4
%50 = lshr i32 %49, 6
%51 = shl i32 %50, 26
%52 = lshr i32 %51, 10
%53 = or i32 %48, %52
%54 = load i32, i32* %4
%55 = shl i32 %54, 26
%56 = lshr i32 %55, 2
%57 = or i32 %53, %56
%58 = or i32 %57, -2139062032
store i32 %58, i32* %3
br label %60
59: ; preds = %36
store i32 26, i32* %3
br label %60
60: ; preds = %59, %40, %22, %9
%61 = load i32, i32* %3
ret i32 %61
}

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