#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 */
unsigned int unicode_code_point_byte_requirement_utf8(uint32_t code_point) {
  if (code_point <= 0x7F)
    return 1;
  else if (code_point <= 0x7FF)
    return 2;
  else if (code_point <= 0xFFFF)
    return 3;
  else if (code_point <= 0x10FFFF)
    return 4;
  else
    return 0;
}


x86 assembly (clang, -O0):
<unicode_code_point_byte_requirement_utf8>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x7f,-0x8(%rbp)
jg     111d <unicode_code_point_byte_requirement_utf8+0x1d>
movl   $0x1,-0x4(%rbp)
jmp    116f <unicode_code_point_byte_requirement_utf8+0x6f>
cmpl   $0x7ff,-0x8(%rbp)
jg     1136 <unicode_code_point_byte_requirement_utf8+0x36>
movl   $0x2,-0x4(%rbp)
jmp    116f <unicode_code_point_byte_requirement_utf8+0x6f>
cmpl   $0xffff,-0x8(%rbp)
jg     114f <unicode_code_point_byte_requirement_utf8+0x4f>
movl   $0x3,-0x4(%rbp)
jmp    116f <unicode_code_point_byte_requirement_utf8+0x6f>
cmpl   $0x10ffff,-0x8(%rbp)
jg     1168 <unicode_code_point_byte_requirement_utf8+0x68>
movl   $0x4,-0x4(%rbp)
jmp    116f <unicode_code_point_byte_requirement_utf8+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unicode_code_point_byte_requirement_utf8>:
mov    $0x1,%eax
cmp    $0x80,%edi
jl     1135 <unicode_code_point_byte_requirement_utf8+0x35>
mov    $0x2,%eax
cmp    $0x800,%edi
jb     1135 <unicode_code_point_byte_requirement_utf8+0x35>
mov    $0x3,%eax
cmp    $0x10000,%edi
jb     1135 <unicode_code_point_byte_requirement_utf8+0x35>
xor    %eax,%eax
cmp    $0x110000,%edi
setb   %al
shl    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @unicode_code_point_byte_requirement_utf8(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sle i32 %4, 127
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %20
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 2047
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* %2
br label %20
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 65535
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 3, i32* %2
br label %20
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 1114111
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 4, i32* %2
br label %20
19: ; preds = %15
store i32 0, i32* %2
br label %20
20: ; preds = %19, %18, %14, %10, %6
%21 = load i32, i32* %2
ret i32 %21
}

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