int main(void) {
  printf("test unicode module\n");
  long est = 0;
  est = test_time();
  printf(" Cyrillic chars\n");
  test_utf8dec((unsigned char[]){0xD0, 0x90, 0x00}, 0x0410);
  test_utf8dec((unsigned char[]){0xD0, 0xB9, 0x00}, 0x0439);
  test_utf8dec((unsigned char[]){0xD0, 0xBA, 0x00}, 0x043A);
  test_utf8dec((unsigned char[]){0xD0, 0xB0, 0x00}, 0x0430);
  printf(" Latin chars\n");
  test_utf8dec((unsigned char[]){0x41, 0x00}, 0x0041);
  test_utf8dec((unsigned char[]){0x6D, 0x00}, 0x006D);
  test_utf8dec((unsigned char[]){0x76, 0x00}, 0x0076);
  est = test_time() - est;
  printf("[\033[1;32mpassed\033[0m] total %lu ms\n", est);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <test_time@plt>
cltq
mov    %rax,-0x10(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0xd0,-0x13(%rbp)
movb   $0x90,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
lea    -0x13(%rbp),%rdi
mov    $0x410,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
movb   $0xd0,-0x16(%rbp)
movb   $0xb9,-0x15(%rbp)
movb   $0x0,-0x14(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0x439,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
movb   $0xd0,-0x19(%rbp)
movb   $0xba,-0x18(%rbp)
movb   $0x0,-0x17(%rbp)
lea    -0x19(%rbp),%rdi
mov    $0x43a,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
movb   $0xd0,-0x1c(%rbp)
movb   $0xb0,-0x1b(%rbp)
movb   $0x0,-0x1a(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x430,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x41,-0x1e(%rbp)
movb   $0x0,-0x1d(%rbp)
lea    -0x1e(%rbp),%rdi
mov    $0x41,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
movb   $0x6d,-0x20(%rbp)
movb   $0x0,-0x1f(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x6d,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
movb   $0x76,-0x22(%rbp)
movb   $0x0,-0x21(%rbp)
lea    -0x22(%rbp),%rdi
mov    $0x76,%esi
mov    $0x0,%al
call   1050 <test_utf8dec@plt>
mov    $0x0,%al
call   1040 <test_time@plt>
cltq
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <test_time@plt>
movslq %eax,%rbx
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
movw   $0x90d0,0x1d(%rsp)
movb   $0x0,0x1f(%rsp)
lea    0x1d(%rsp),%rdi
mov    $0x410,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
movw   $0xb9d0,0x1a(%rsp)
movb   $0x0,0x1c(%rsp)
lea    0x1a(%rsp),%rdi
mov    $0x439,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
movw   $0xbad0,0x17(%rsp)
movb   $0x0,0x19(%rsp)
lea    0x17(%rsp),%rdi
mov    $0x43a,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
movw   $0xb0d0,0x14(%rsp)
movb   $0x0,0x16(%rsp)
lea    0x14(%rsp),%rdi
mov    $0x430,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
movw   $0x41,0x12(%rsp)
lea    0x12(%rsp),%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
movw   $0x6d,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x6d,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
movw   $0x76,0xe(%rsp)
lea    0xe(%rsp),%rdi
mov    $0x76,%esi
xor    %eax,%eax
call   1060 <test_utf8dec@plt>
xor    %eax,%eax
call   1050 <test_time@plt>
movslq %eax,%rsi
sub    %rbx,%rsi
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"test unicode module\0A\00"
@.str.1 = [17 x i8] c" Cyrillic chars\0A\00"
@.str.2 = [14 x i8] c" Latin chars\0A\00"
@.str.3 = [34 x i8] c"[\1B[1;32mpassed\1B[0m] total %lu ms\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = alloca [3 x i8]
%6 = alloca [3 x i8]
%7 = alloca [2 x i8]
%8 = alloca [2 x i8]
%9 = alloca [2 x i8]
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %2
%11 = call i32 (...) @test_time()
%12 = sext i32 %11 to i64
store i64 %12, i64* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 -48, i8* %14
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 -112, i8* %15
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 0, i8* %16
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%18 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %17, i32 1040)
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i8 -48, i8* %19
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 -71, i8* %20
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8 0, i8* %21
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %22, i32 1081)
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
store i8 -48, i8* %24
%25 = getelementptr inbounds i8, i8* %24, i64 1
store i8 -70, i8* %25
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8 0, i8* %26
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%28 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %27, i32 1082)
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
store i8 -48, i8* %29
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 -80, i8* %30
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8 0, i8* %31
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%33 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %32, i32 1072)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 65, i8* %35
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8 0, i8* %36
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %37, i32 65)
%39 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 109, i8* %39
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8 0, i8* %40
%41 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%42 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %41, i32 109)
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
store i8 118, i8* %43
%44 = getelementptr inbounds i8, i8* %43, i64 1
store i8 0, i8* %44
%45 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%46 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %45, i32 118)
%47 = call i32 (...) @test_time()
%48 = sext i32 %47 to i64
%49 = load i64, i64* %2
%50 = sub nsw i64 %48, %49
store i64 %50, i64* %2
%51 = load i64, i64* %2
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %51)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [34 x i8] c"[\1B[1;32mpassed\1B[0m] total %lu ms\0A\00"
@str = [20 x i8] c"test unicode module\00"
@str.4 = [16 x i8] c" Cyrillic chars\00"
@str.5 = [13 x i8] c" Latin chars\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = alloca [3 x i8]
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = alloca [2 x i8]
%6 = alloca [2 x i8]
%7 = alloca [2 x i8]
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (...) @test_time()
%10 = sext i32 %9 to i64
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
store i8 -48, i8* %12
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 1
store i8 -112, i8* %13
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 2
store i8 0, i8* %14
%15 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %12, i32 1040)
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
store i8 -48, i8* %16
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 -71, i8* %17
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 0, i8* %18
%19 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %16, i32 1081)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 -48, i8* %20
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 -70, i8* %21
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %22
%23 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %20, i32 1082)
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i8 -48, i8* %24
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 -80, i8* %25
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %26
%27 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %24, i32 1072)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
%29 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
store i8 65, i8* %29
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 0, i8* %30
%31 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %29, i32 65)
%32 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
store i8 109, i8* %32
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
store i8 0, i8* %33
%34 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %32, i32 109)
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 118, i8* %35
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
store i8 0, i8* %36
%37 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @test_utf8dec to i32 (i8*, i32, ...)*)(i8* %35, i32 118)
%38 = call i32 (...) @test_time()
%39 = sext i32 %38 to i64
%40 = sub nsw i64 %39, %10
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %40)
ret i32 0
}