#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*/ sprintf(char *, char *, ...);
void OutStringFromChar(char achar, char *out) {
  if (achar >= 'A' && achar <= 'M') {
    int c = 0x627 + (achar - 'A');
    sprintf(out, "&#x%x;", c);
  } else if (achar >= 'N' && achar <= 'Z') {
    int c = 0x5D0 + (achar - 'N');
    sprintf(out, "&#x%x;", c);
  } else if (achar >= '5' && achar <= '9') {
    int c = 0x660 + (achar - '5');
    sprintf(out, "&#x%x;", c);
  } else {
    switch (achar) {
    case ' ':
      sprintf(out, "&nbsp;");
      break;
    case '<':
    case '>':
    case '{':
    case '}':
    case '[':
    case ']':
    case '^':
      *out = 0;
      break;
    default:
      sprintf(out, "%c", achar);
    }
  }
}


x86 assembly (clang, -O0):
<OutStringFromChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x41,%eax
jl     1165 <OutStringFromChar+0x55>
movsbl -0x1(%rbp),%eax
cmp    $0x4d,%eax
jg     1165 <OutStringFromChar+0x55>
movsbl -0x1(%rbp),%eax
sub    $0x41,%eax
add    $0x627,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b1 <OutStringFromChar+0x1a1>
movsbl -0x1(%rbp),%eax
cmp    $0x4e,%eax
jl     11a8 <OutStringFromChar+0x98>
movsbl -0x1(%rbp),%eax
cmp    $0x5a,%eax
jg     11a8 <OutStringFromChar+0x98>
movsbl -0x1(%rbp),%eax
sub    $0x4e,%eax
add    $0x5d0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12ac <OutStringFromChar+0x19c>
movsbl -0x1(%rbp),%eax
cmp    $0x35,%eax
jl     11eb <OutStringFromChar+0xdb>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     11eb <OutStringFromChar+0xdb>
movsbl -0x1(%rbp),%eax
sub    $0x35,%eax
add    $0x660,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a7 <OutStringFromChar+0x197>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x20,%eax
je     1269 <OutStringFromChar+0x159>
jmp    1200 <OutStringFromChar+0xf0>
mov    -0x20(%rbp),%eax
sub    $0x3c,%eax
je     1280 <OutStringFromChar+0x170>
jmp    1211 <OutStringFromChar+0x101>
mov    -0x20(%rbp),%eax
sub    $0x3e,%eax
je     1280 <OutStringFromChar+0x170>
jmp    1222 <OutStringFromChar+0x112>
mov    -0x20(%rbp),%eax
sub    $0x5b,%eax
je     1280 <OutStringFromChar+0x170>
jmp    1233 <OutStringFromChar+0x123>
mov    -0x20(%rbp),%eax
add    $0xffffffa3,%eax
sub    $0x2,%eax
jb     1280 <OutStringFromChar+0x170>
jmp    1247 <OutStringFromChar+0x137>
mov    -0x20(%rbp),%eax
sub    $0x7b,%eax
je     1280 <OutStringFromChar+0x170>
jmp    1258 <OutStringFromChar+0x148>
mov    -0x20(%rbp),%eax
sub    $0x7d,%eax
je     1280 <OutStringFromChar+0x170>
jmp    128c <OutStringFromChar+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a2 <OutStringFromChar+0x192>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    12a2 <OutStringFromChar+0x192>
mov    -0x10(%rbp),%rdi
movsbl -0x1(%rbp),%edx
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a7 <OutStringFromChar+0x197>
jmp    12ac <OutStringFromChar+0x19c>
jmp    12b1 <OutStringFromChar+0x1a1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OutStringFromChar>:
mov    %edi,%edx
lea    -0x41(%rdx),%eax
cmp    $0xc,%al
ja     1121 <OutStringFromChar+0x11>
add    $0x5e6,%edx
jmp    113d <OutStringFromChar+0x2d>
lea    -0x4e(%rdx),%eax
cmp    $0xc,%al
ja     1130 <OutStringFromChar+0x20>
add    $0x582,%edx
jmp    113d <OutStringFromChar+0x2d>
lea    -0x35(%rdx),%eax
cmp    $0x4,%al
ja     1151 <OutStringFromChar+0x41>
add    $0x62b,%edx
lea    0xfc4(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
lea    -0x3c(%rdx),%eax
cmp    $0x41,%eax
ja     116d <OutStringFromChar+0x5d>
lea    0xea0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,(%rsi)
ret
cmp    $0x20,%edx
jne    1180 <OutStringFromChar+0x70>
movl   $0x3b7073,0x3(%rsi)
movl   $0x73626e26,(%rsi)
ret
mov    %dl,(%rsi)
movb   $0x0,0x1(%rsi)
ret

LLVM IR (-O0):
@.str = [7 x i8] c"&#x%x;\00"
@.str.1 = [7 x i8] c"&nbsp;\00"
@.str.2 = [3 x i8] c"%c\00"
define void @OutStringFromChar(i8 signext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %3
store i8* %1, i8** %4
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sge i32 %9, 65
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp sle i32 %13, 77
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 65
%19 = add nsw i32 1575, %18
store i32 %19, i32* %5
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %71
23: ; preds = %11, %2
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 78
br i1 %26, label %27, label %39
27: ; preds = %23
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 90
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i8, i8* %3
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 78
%35 = add nsw i32 1488, %34
store i32 %35, i32* %6
%36 = load i8*, i8** %4
%37 = load i32, i32* %6
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %70
39: ; preds = %27, %23
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = icmp sge i32 %41, 53
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = icmp sle i32 %45, 57
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = load i8, i8* %3
%49 = sext i8 %48 to i32
%50 = sub nsw i32 %49, 53
%51 = add nsw i32 1632, %50
store i32 %51, i32* %7
%52 = load i8*, i8** %4
%53 = load i32, i32* %7
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %53)
br label %69
55: ; preds = %43, %39
%56 = load i8, i8* %3
%57 = sext i8 %56 to i32
switch i32 %57, label %63 [
i32 32, label %58
i32 60, label %61
i32 62, label %61
i32 123, label %61
i32 125, label %61
i32 91, label %61
i32 93, label %61
i32 94, label %61
]
58: ; preds = %55
%59 = load i8*, i8** %4
%60 = call i32 (i8*, i8*, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %68
61: ; preds = %55, %55, %55, %55, %55, %55, %55
%62 = load i8*, i8** %4
store i8 0, i8* %62
br label %68
63: ; preds = %55
%64 = load i8*, i8** %4
%65 = load i8, i8* %3
%66 = sext i8 %65 to i32
%67 = call i32 (i8*, i8*, ...) @sprintf(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %63, %61, %58
br label %69
69: ; preds = %68, %47
br label %70
70: ; preds = %69, %31
br label %71
71: ; preds = %70, %15
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"&#x%x;\00"
@.str.1 = [7 x i8] c"&nbsp;\00"
define void @OutStringFromChar(i8 signext %0, i8* nocapture writeonly %1) {
%3 = sext i8 %0 to i32
%4 = add i8 %0, -65
%5 = icmp ult i8 %4, 13
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = add nsw i32 %3, 1510
%8 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %26
9: ; preds = %2
%10 = add i8 %0, -78
%11 = icmp ult i8 %10, 13
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = add nsw i32 %3, 1410
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %26
15: ; preds = %9
%16 = add i8 %0, -53
%17 = icmp ult i8 %16, 5
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = add nsw i32 %3, 1579
%20 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %26
21: ; preds = %15
switch i32 %3, label %24 [
i32 32, label %22
i32 60, label %23
i32 62, label %23
i32 123, label %23
i32 125, label %23
i32 91, label %23
i32 93, label %23
i32 94, label %23
]
22: ; preds = %21
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %1, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 7, i1 false)
br label %26
23: ; preds = %21, %21, %21, %21, %21, %21, %21
store i8 0, i8* %1
br label %26
24: ; preds = %21
store i8 %0, i8* %1
%25 = getelementptr i8, i8* %1, i64 1
store i8 0, i8* %25
br label %26
26: ; preds = %12, %22, %23, %24, %18, %6
ret void
}