#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned long long *, char *, int);
void utf_char_to_code(char *str, unsigned long long *ret_code,
                      int *ret_byte_length) {
  unsigned char first_char = str[0];
  if (first_char >= 252)
    *ret_byte_length = 6;
  else if (first_char >= 248)
    *ret_byte_length = 5;
  else if (first_char >= 240)
    *ret_byte_length = 4;
  else if (first_char >= 224)
    *ret_byte_length = 3;
  else if (first_char >= 192)
    *ret_byte_length = 2;
  else
    *ret_byte_length = 1;
  *ret_code = 0;
  memcpy(ret_code, str, *ret_byte_length);
}


x86 assembly (clang, -O0):
<utf_char_to_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0xfc,%eax
jl     114b <utf_char_to_code+0x3b>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    11e1 <utf_char_to_code+0xd1>
movzbl -0x19(%rbp),%eax
cmp    $0xf8,%eax
jl     1169 <utf_char_to_code+0x59>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    11dc <utf_char_to_code+0xcc>
movzbl -0x19(%rbp),%eax
cmp    $0xf0,%eax
jl     1187 <utf_char_to_code+0x77>
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
jmp    11d7 <utf_char_to_code+0xc7>
movzbl -0x19(%rbp),%eax
cmp    $0xe0,%eax
jl     11a5 <utf_char_to_code+0x95>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    11d2 <utf_char_to_code+0xc2>
movzbl -0x19(%rbp),%eax
cmp    $0xc0,%eax
jl     11c3 <utf_char_to_code+0xb3>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    11cd <utf_char_to_code+0xbd>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11d2 <utf_char_to_code+0xc2>
jmp    11d7 <utf_char_to_code+0xc7>
jmp    11dc <utf_char_to_code+0xcc>
jmp    11e1 <utf_char_to_code+0xd1>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf_char_to_code>:
mov    %rsi,%r8
mov    %rdi,%rsi
mov    (%rdi),%al
mov    $0x6,%ecx
cmp    $0xfb,%al
ja     1146 <utf_char_to_code+0x36>
mov    $0x5,%ecx
cmp    $0xf7,%al
ja     1146 <utf_char_to_code+0x36>
mov    $0x4,%ecx
cmp    $0xef,%al
ja     1146 <utf_char_to_code+0x36>
mov    $0x3,%ecx
cmp    $0xdf,%al
ja     1146 <utf_char_to_code+0x36>
cmp    $0xc0,%al
mov    $0x1,%ecx
sbb    $0xffffffff,%ecx
mov    %ecx,(%rdx)
movq   $0x0,(%r8)
mov    %r8,%rdi
mov    %ecx,%edx
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
define void @utf_char_to_code(i8* %0, i64* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i32*
%7 = alloca i8
store i8* %0, i8** %4
store i64* %1, i64** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
store i8 %10, i8* %7
%11 = load i8, i8* %7
%12 = zext i8 %11 to i32
%13 = icmp sge i32 %12, 252
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i32*, i32** %6
store i32 6, i32* %15
br label %46
16: ; preds = %3
%17 = load i8, i8* %7
%18 = zext i8 %17 to i32
%19 = icmp sge i32 %18, 248
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i32*, i32** %6
store i32 5, i32* %21
br label %45
22: ; preds = %16
%23 = load i8, i8* %7
%24 = zext i8 %23 to i32
%25 = icmp sge i32 %24, 240
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32*, i32** %6
store i32 4, i32* %27
br label %44
28: ; preds = %22
%29 = load i8, i8* %7
%30 = zext i8 %29 to i32
%31 = icmp sge i32 %30, 224
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32*, i32** %6
store i32 3, i32* %33
br label %43
34: ; preds = %28
%35 = load i8, i8* %7
%36 = zext i8 %35 to i32
%37 = icmp sge i32 %36, 192
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = load i32*, i32** %6
store i32 2, i32* %39
br label %42
40: ; preds = %34
%41 = load i32*, i32** %6
store i32 1, i32* %41
br label %42
42: ; preds = %40, %38
br label %43
43: ; preds = %42, %32
br label %44
44: ; preds = %43, %26
br label %45
45: ; preds = %44, %20
br label %46
46: ; preds = %45, %14
%47 = load i64*, i64** %5
store i64 0, i64* %47
%48 = load i64*, i64** %5
%49 = load i8*, i8** %4
%50 = load i32*, i32** %6
%51 = load i32, i32* %50
%52 = call i32 @memcpy(i64* %48, i8* %49, i32 %51)
ret void
}

LLVM IR (-O2):
define void @utf_char_to_code(i8* %0, i64* %1, i32* nocapture %2) {
%4 = load i8, i8* %0
%5 = icmp ugt i8 %4, -5
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = icmp ugt i8 %4, -9
br i1 %7, label %15, label %8
8: ; preds = %6
%9 = icmp ugt i8 %4, -17
br i1 %9, label %15, label %10
10: ; preds = %8
%11 = icmp ugt i8 %4, -33
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = icmp ugt i8 %4, -65
%14 = select i1 %13, i32 2, i32 1
br label %15
15: ; preds = %12, %10, %8, %6, %3
%16 = phi i32 [ 6, %3 ], [ 5, %6 ], [ 4, %8 ], [ 3, %10 ], [ %14, %12 ]
store i32 %16, i32* %2
store i64 0, i64* %1
%17 = tail call i32 @memcpy(i64* %1, i8* %0, i32 %16)
ret void
}