#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*/ memset(unsigned char *, int /*<<< orphan*/, int);
unsigned char *mpm_clone_maxpath_str();
unsigned char *latin1ToUtf8(unsigned char c) {
  unsigned char *utf8 = mpm_clone_maxpath_str();
  memset(utf8, 0, 4);
  if (c < 128)
    utf8[0] = c;
  else if (c < 192) {
    utf8[0] = 194;
    utf8[1] = c;
  } else {
    utf8[0] = 195;
    utf8[1] = c - 64;
  }
  return utf8;
}


x86 assembly (clang, -O0):
<latin1ToUtf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1030 <mpm_clone_maxpath_str@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x80,%eax
jge    1166 <latin1ToUtf8+0x46>
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    11a7 <latin1ToUtf8+0x87>
movzbl -0x1(%rbp),%eax
cmp    $0xc0,%eax
jge    118b <latin1ToUtf8+0x6b>
mov    -0x10(%rbp),%rax
movb   $0xc2,(%rax)
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
jmp    11a2 <latin1ToUtf8+0x82>
mov    -0x10(%rbp),%rax
movb   $0xc3,(%rax)
movzbl -0x1(%rbp),%eax
sub    $0x40,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
jmp    11a7 <latin1ToUtf8+0x87>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latin1ToUtf8>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <mpm_clone_maxpath_str@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
test   %bpl,%bpl
js     1148 <latin1ToUtf8+0x28>
mov    %bpl,(%rbx)
jmp    115e <latin1ToUtf8+0x3e>
cmp    $0xbf,%bpl
ja     1153 <latin1ToUtf8+0x33>
movb   $0xc2,(%rbx)
jmp    115a <latin1ToUtf8+0x3a>
movb   $0xc3,(%rbx)
add    $0xc0,%bpl
mov    %bpl,0x1(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @latin1ToUtf8(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8*
store i8 %0, i8* %2
%4 = call i8* (...) @mpm_clone_maxpath_str()
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @memset(i8* %5, i32 0, i32 4)
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
%9 = icmp slt i32 %8, 128
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8, i8* %2
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %13
br label %34
14: ; preds = %1
%15 = load i8, i8* %2
%16 = zext i8 %15 to i32
%17 = icmp slt i32 %16, 192
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 0
store i8 -62, i8* %20
%21 = load i8, i8* %2
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %21, i8* %23
br label %33
24: ; preds = %14
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 0
store i8 -61, i8* %26
%27 = load i8, i8* %2
%28 = zext i8 %27 to i32
%29 = sub nsw i32 %28, 64
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8 %30, i8* %32
br label %33
33: ; preds = %24, %18
br label %34
34: ; preds = %33, %10
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
define i8* @latin1ToUtf8(i8 zeroext %0) {
%2 = tail call i8* (...) @mpm_clone_maxpath_str()
%3 = tail call i32 @memset(i8* %2, i32 0, i32 4)
%4 = icmp sgt i8 %0, -1
br i1 %4, label %5, label %6
5: ; preds = %1
store i8 %0, i8* %2
br label %13
6: ; preds = %1
%7 = icmp ult i8 %0, -64
br i1 %7, label %8, label %10
8: ; preds = %6
store i8 -62, i8* %2
%9 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %0, i8* %9
br label %13
10: ; preds = %6
store i8 -61, i8* %2
%11 = add nsw i8 %0, -64
%12 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %11, i8* %12
br label %13
13: ; preds = %8, %10, %5
ret i8* %2
}