#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 */
void abstract_text___Char_u8char_tos___impl(uint32_t self, char *r, long len) {
  r[len] = '\0';
  switch (len) {
  case 1:
    r[0] = self;
    break;
  case 2:
    r[0] = 0xC0 | ((self & 0x7C0) >> 6);
    r[1] = 0x80 | (self & 0x3F);
    break;
  case 3:
    r[0] = 0xE0 | ((self & 0xF000) >> 12);
    r[1] = 0x80 | ((self & 0xFC0) >> 6);
    r[2] = 0x80 | (self & 0x3F);
    break;
  case 4:
    r[0] = 0xF0 | ((self & 0x1C0000) >> 18);
    r[1] = 0x80 | ((self & 0x3F000) >> 12);
    r[2] = 0x80 | ((self & 0xFC0) >> 6);
    r[3] = 0x80 | (self & 0x3F);
    break;
  }
}


x86 assembly (clang, -O0):
<abstract_text___Char_u8char_tos___impl>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     122e <abstract_text___Char_u8char_tos___impl+0x12e>
mov    -0x20(%rbp),%rax
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    122e <abstract_text___Char_u8char_tos___impl+0x12e>
mov    -0x4(%rbp),%eax
and    $0x7c0,%eax
sar    $0x6,%eax
or     $0xc0,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
jmp    122e <abstract_text___Char_u8char_tos___impl+0x12e>
mov    -0x4(%rbp),%eax
and    $0xf000,%eax
sar    $0xc,%eax
or     $0xe0,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
and    $0xfc0,%eax
sar    $0x6,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
jmp    122e <abstract_text___Char_u8char_tos___impl+0x12e>
mov    -0x4(%rbp),%eax
and    $0x1c0000,%eax
sar    $0x12,%eax
or     $0xf0,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
and    $0x3f000,%eax
sar    $0xc,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%eax
and    $0xfc0,%eax
sar    $0x6,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<abstract_text___Char_u8char_tos___impl>:
movb   $0x0,(%rsi,%rdx,1)
add    $0xffffffffffffffff,%rdx
cmp    $0x3,%rdx
ja     118d <abstract_text___Char_u8char_tos___impl+0x8d>
lea    0xeeb(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %dil,(%rsi)
ret
mov    %edi,%eax
shr    $0x6,%eax
and    $0x1f,%al
or     $0xc0,%al
mov    %al,(%rsi)
and    $0x3f,%dil
or     $0x80,%dil
mov    %dil,0x1(%rsi)
ret
mov    %edi,%eax
shr    $0xc,%eax
and    $0xf,%al
or     $0xe0,%al
mov    %al,(%rsi)
mov    %edi,%eax
shr    $0x6,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x1(%rsi)
and    $0x3f,%dil
or     $0x80,%dil
mov    %dil,0x2(%rsi)
ret
mov    %edi,%eax
shr    $0x12,%eax
and    $0x7,%al
or     $0xf0,%al
mov    %al,(%rsi)
mov    %edi,%eax
shr    $0xc,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x1(%rsi)
mov    %edi,%eax
shr    $0x6,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x2(%rsi)
and    $0x3f,%dil
or     $0x80,%dil
mov    %dil,0x3(%rsi)
ret

LLVM IR (-O0):
define void @abstract_text___Char_u8char_tos___impl(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %5
%8 = load i64, i64* %6
%9 = getelementptr inbounds i8, i8* %7, i64 %8
store i8 0, i8* %9
%10 = load i64, i64* %6
switch i64 %10, label %79 [
i64 1, label %11
i64 2, label %16
i64 3, label %30
i64 4, label %51
]
11: ; preds = %3
%12 = load i32, i32* %4
%13 = trunc i32 %12 to i8
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 %13, i8* %15
br label %79
16: ; preds = %3
%17 = load i32, i32* %4
%18 = and i32 %17, 1984
%19 = ashr i32 %18, 6
%20 = or i32 192, %19
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 0
store i8 %21, i8* %23
%24 = load i32, i32* %4
%25 = and i32 %24, 63
%26 = or i32 128, %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8 %27, i8* %29
br label %79
30: ; preds = %3
%31 = load i32, i32* %4
%32 = and i32 %31, 61440
%33 = ashr i32 %32, 12
%34 = or i32 224, %33
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 0
store i8 %35, i8* %37
%38 = load i32, i32* %4
%39 = and i32 %38, 4032
%40 = ashr i32 %39, 6
%41 = or i32 128, %40
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 1
store i8 %42, i8* %44
%45 = load i32, i32* %4
%46 = and i32 %45, 63
%47 = or i32 128, %46
%48 = trunc i32 %47 to i8
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i64 2
store i8 %48, i8* %50
br label %79
51: ; preds = %3
%52 = load i32, i32* %4
%53 = and i32 %52, 1835008
%54 = ashr i32 %53, 18
%55 = or i32 240, %54
%56 = trunc i32 %55 to i8
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i64 0
store i8 %56, i8* %58
%59 = load i32, i32* %4
%60 = and i32 %59, 258048
%61 = ashr i32 %60, 12
%62 = or i32 128, %61
%63 = trunc i32 %62 to i8
%64 = load i8*, i8** %5
%65 = getelementptr inbounds i8, i8* %64, i64 1
store i8 %63, i8* %65
%66 = load i32, i32* %4
%67 = and i32 %66, 4032
%68 = ashr i32 %67, 6
%69 = or i32 128, %68
%70 = trunc i32 %69 to i8
%71 = load i8*, i8** %5
%72 = getelementptr inbounds i8, i8* %71, i64 2
store i8 %70, i8* %72
%73 = load i32, i32* %4
%74 = and i32 %73, 63
%75 = or i32 128, %74
%76 = trunc i32 %75 to i8
%77 = load i8*, i8** %5
%78 = getelementptr inbounds i8, i8* %77, i64 3
store i8 %76, i8* %78
br label %79
79: ; preds = %3, %51, %30, %16, %11
ret void
}

LLVM IR (-O2):
define void @abstract_text___Char_u8char_tos___impl(i32 %0, i8* nocapture writeonly %1, i64 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 %2
store i8 0, i8* %4
switch i64 %2, label %49 [
i64 1, label %5
i64 2, label %7
i64 3, label %16
i64 4, label %30
]
5: ; preds = %3
%6 = trunc i32 %0 to i8
store i8 %6, i8* %1
br label %49
7: ; preds = %3
%8 = lshr i32 %0, 6
%9 = trunc i32 %8 to i8
%10 = and i8 %9, 31
%11 = or i8 %10, -64
store i8 %11, i8* %1
%12 = trunc i32 %0 to i8
%13 = and i8 %12, 63
%14 = or i8 %13, -128
%15 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %14, i8* %15
br label %49
16: ; preds = %3
%17 = lshr i32 %0, 12
%18 = trunc i32 %17 to i8
%19 = and i8 %18, 15
%20 = or i8 %19, -32
store i8 %20, i8* %1
%21 = lshr i32 %0, 6
%22 = trunc i32 %21 to i8
%23 = and i8 %22, 63
%24 = or i8 %23, -128
%25 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %24, i8* %25
%26 = trunc i32 %0 to i8
%27 = and i8 %26, 63
%28 = or i8 %27, -128
%29 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %28, i8* %29
br label %49
30: ; preds = %3
%31 = lshr i32 %0, 18
%32 = trunc i32 %31 to i8
%33 = and i8 %32, 7
%34 = or i8 %33, -16
store i8 %34, i8* %1
%35 = lshr i32 %0, 12
%36 = trunc i32 %35 to i8
%37 = and i8 %36, 63
%38 = or i8 %37, -128
%39 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %38, i8* %39
%40 = lshr i32 %0, 6
%41 = trunc i32 %40 to i8
%42 = and i8 %41, 63
%43 = or i8 %42, -128
%44 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %43, i8* %44
%45 = trunc i32 %0 to i8
%46 = and i8 %45, 63
%47 = or i8 %46, -128
%48 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %47, i8* %48
br label %49
49: ; preds = %3, %30, %16, %7, %5
ret void
}