#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 uint32_t;

/* Variables and functions */
__attribute__((visibility("default"))) int fcitx_ucs4_char_len(uint32_t c) {
  if (c < 0x00080) {
    return 1;
  } else if (c < 0x00800) {
    return 2;
  } else if (c < 0x10000) {
    return 3;
  } else if (c < 0x200000) {
    return 4;
  } else if (c < 0x8000000) {
    return 5;
  } else {
    return 6;
  }
}


x86 assembly (clang, -O0):
<fcitx_ucs4_char_len>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x80,-0x8(%rbp)
jge    1120 <fcitx_ucs4_char_len+0x20>
movl   $0x1,-0x4(%rbp)
jmp    118b <fcitx_ucs4_char_len+0x8b>
cmpl   $0x800,-0x8(%rbp)
jge    1139 <fcitx_ucs4_char_len+0x39>
movl   $0x2,-0x4(%rbp)
jmp    118b <fcitx_ucs4_char_len+0x8b>
cmpl   $0x10000,-0x8(%rbp)
jge    1152 <fcitx_ucs4_char_len+0x52>
movl   $0x3,-0x4(%rbp)
jmp    118b <fcitx_ucs4_char_len+0x8b>
cmpl   $0x200000,-0x8(%rbp)
jge    116b <fcitx_ucs4_char_len+0x6b>
movl   $0x4,-0x4(%rbp)
jmp    118b <fcitx_ucs4_char_len+0x8b>
cmpl   $0x8000000,-0x8(%rbp)
jge    1184 <fcitx_ucs4_char_len+0x84>
movl   $0x5,-0x4(%rbp)
jmp    118b <fcitx_ucs4_char_len+0x8b>
movl   $0x6,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcitx_ucs4_char_len>:
mov    $0x1,%eax
cmp    $0x80,%edi
jl     1142 <fcitx_ucs4_char_len+0x42>
mov    $0x2,%eax
cmp    $0x800,%edi
jb     1142 <fcitx_ucs4_char_len+0x42>
mov    $0x3,%eax
cmp    $0x10000,%edi
jb     1142 <fcitx_ucs4_char_len+0x42>
mov    $0x4,%eax
cmp    $0x200000,%edi
jb     1142 <fcitx_ucs4_char_len+0x42>
cmp    $0x8000000,%edi
mov    $0x6,%eax
sbb    $0x0,%eax
ret

LLVM IR (-O0):
define i32 @fcitx_ucs4_char_len(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 128
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %24
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2048
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* %2
br label %24
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 65536
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 3, i32* %2
br label %24
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 2097152
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 4, i32* %2
br label %24
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 134217728
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 5, i32* %2
br label %24
23: ; preds = %19
store i32 6, i32* %2
br label %24
24: ; preds = %23, %22, %18, %14, %10, %6
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @fcitx_ucs4_char_len(i32 %0) {
%2 = icmp slt i32 %0, 128
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 2048
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 65536
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 2097152
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 134217728
%11 = select i1 %10, i32 5, i32 6
br label %12
12: ; preds = %9, %7, %5, %3, %1
%13 = phi i32 [ 1, %1 ], [ 2, %3 ], [ 3, %5 ], [ 4, %7 ], [ %11, %9 ]
ret i32 %13
}