#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 EOF;
int convertUtf8ToWchar(char const **, size_t *);
void convertUtf8ToWchars(const char **utf8, unsigned char **characters,
                         size_t count) {
  while (**utf8 && (count > 1)) {
    size_t utfs = (((32) < 8) ? 1 : (((32) + 3) / 5));
    int character = convertUtf8ToWchar(utf8, &utfs);
    if (character == EOF)
      break;
    *(*characters)++ = character;
    count -= 1;
  }
  if (count)
    **characters = 0;
}


x86 assembly (clang, -O0):
<convertUtf8ToWchars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
je     1147 <convertUtf8ToWchars+0x37>
cmpq   $0x1,-0x18(%rbp)
seta   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1157 <convertUtf8ToWchars+0x47>
jmp    11af <convertUtf8ToWchars+0x9f>
movq   $0x7,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <convertUtf8ToWchar@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%eax
jne    1186 <convertUtf8ToWchars+0x76>
jmp    11af <convertUtf8ToWchars+0x9f>
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <convertUtf8ToWchars+0x14>
cmpq   $0x0,-0x18(%rbp)
je     11c4 <convertUtf8ToWchars+0xb4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertUtf8ToWchars>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    (%rdi),%rax
cmpb   $0x0,(%rax)
je     1178 <convertUtf8ToWchars+0x68>
cmp    $0x2,%rbx
jb     1178 <convertUtf8ToWchars+0x68>
mov    %rdi,%r15
lea    0x8(%rsp),%r12
mov    0x2ea8(%rip),%r13
movq   $0x7,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <convertUtf8ToWchar@plt>
cmp    0x0(%r13),%eax
je     117d <convertUtf8ToWchars+0x6d>
mov    (%r14),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%r14)
mov    %al,(%rcx)
add    $0xffffffffffffffff,%rbx
mov    (%r15),%rax
cmpb   $0x0,(%rax)
je     1178 <convertUtf8ToWchars+0x68>
cmp    $0x1,%rbx
ja     1140 <convertUtf8ToWchars+0x30>
test   %rbx,%rbx
je     1183 <convertUtf8ToWchars+0x73>
mov    (%r14),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @convertUtf8ToWchars(i8** %0, i8** %1, i64 %2) {
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i8** %0, i8*** %4
store i8** %1, i8*** %5
store i64 %2, i64* %6
br label %9
9: ; preds = %27, %3
%10 = load i8**, i8*** %4
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i64, i64* %6
%17 = icmp ugt i64 %16, 1
br label %18
18: ; preds = %15, %9
%19 = phi i1 [ false, %9 ], [ %17, %15 ]
br i1 %19, label %20, label %35
20: ; preds = %18
store i64 7, i64* %7
%21 = load i8**, i8*** %4
%22 = call i32 @convertUtf8ToWchar(i8** %21, i64* %7)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %20
br label %35
27: ; preds = %20
%28 = load i32, i32* %8
%29 = trunc i32 %28 to i8
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %30
store i8 %29, i8* %31
%33 = load i64, i64* %6
%34 = sub i64 %33, 1
store i64 %34, i64* %6
br label %9
35: ; preds = %26, %18
%36 = load i64, i64* %6
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = load i8*, i8** %39
store i8 0, i8* %40
br label %41
41: ; preds = %38, %35
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @convertUtf8ToWchars(i8** %0, i8** nocapture %1, i64 %2) {
%4 = alloca i64
%5 = load i8*, i8** %0
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
%8 = icmp ugt i64 %2, 1
%9 = and i1 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %3
%11 = bitcast i64* %4 to i8*
br label %12
12: ; preds = %10, %18
%13 = phi i64 [ %2, %10 ], [ %22, %18 ]
store i64 7, i64* %4
%14 = call i32 @convertUtf8ToWchar(i8** %0, i64* %4)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %12
br label %31
18: ; preds = %12
%19 = trunc i32 %14 to i8
%20 = load i8*, i8** %1
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8* %21, i8** %1
store i8 %19, i8* %20
%22 = add i64 %13, -1
%23 = load i8*, i8** %0
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
%26 = icmp ugt i64 %22, 1
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %12, label %28
28: ; preds = %18, %3
%29 = phi i64 [ %2, %3 ], [ %22, %18 ]
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %17, %28
%32 = load i8*, i8** %1
store i8 0, i8* %32
br label %33
33: ; preds = %31, %28
ret void
}