#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 *, unsigned char, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void CharToText(char *array, unsigned char value) {
  if (value < ' ') {
    static const char *names[32] = {
        "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
        "\\b", "\\t", "\\n", "\\v", "ff",  "cr",  "so",  "si",
        "dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
        "can", "em",  "sub", "esc", "fs",  "gs",  "rs",  "us"};
    sprintf(array, "0x%02x (%s)", value, names[value]);
  } else if (value < 0x7f) {
    sprintf(array, "'%c'", value);
  } else if (value == 0x7f) {
    strcpy(array, "0x7f (del)");
  } else {
    sprintf(array, "0x%x", value);
  }
}


x86 assembly (clang, -O0):
<CharToText>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jge    116d <CharToText+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
movzbl -0x9(%rbp),%ecx
mov    %ecx,%edx
lea    0x2eed(%rip),%rcx
mov    (%rcx,%rdx,8),%rcx
lea    0xf15(%rip),%rsi
movzbl %al,%edx
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11d7 <CharToText+0xb7>
movzbl -0x9(%rbp),%eax
cmp    $0x7f,%eax
jge    1195 <CharToText+0x75>
mov    -0x8(%rbp),%rdi
lea    0xefa(%rip),%rsi
movzbl -0x9(%rbp),%edx
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11d2 <CharToText+0xb2>
movzbl -0x9(%rbp),%eax
cmp    $0x7f,%eax
jne    11b7 <CharToText+0x97>
mov    -0x8(%rbp),%rdi
lea    0xed7(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11cd <CharToText+0xad>
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
movzbl -0x9(%rbp),%edx
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11d2 <CharToText+0xb2>
jmp    11d7 <CharToText+0xb7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CharToText>:
cmp    $0x1f,%sil
ja     1146 <CharToText+0x26>
movzbl %sil,%edx
lea    0xecf(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
lea    0xfb4(%rip),%rsi
xor    %eax,%eax
jmp    1040 <sprintf@plt>
cmp    $0x7e,%sil
ja     115e <CharToText+0x3e>
movzbl %sil,%edx
lea    0xfa8(%rip),%rsi
xor    %eax,%eax
jmp    1040 <sprintf@plt>
cmp    $0x7f,%sil
jne    1170 <CharToText+0x50>
lea    0xf99(%rip),%rsi
jmp    1030 <strcpy@plt>
movzbl %sil,%edx
lea    0xf94(%rip),%rsi
xor    %eax,%eax
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@CharToText.names = internal global [32 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.31, i32 0, i32 0)]
@.str = [4 x i8] c"nul\00"
@.str.1 = [4 x i8] c"soh\00"
@.str.2 = [4 x i8] c"stx\00"
@.str.3 = [4 x i8] c"etx\00"
@.str.4 = [4 x i8] c"eot\00"
@.str.5 = [4 x i8] c"enq\00"
@.str.6 = [4 x i8] c"ack\00"
@.str.7 = [4 x i8] c"bel\00"
@.str.8 = [3 x i8] c"\\b\00"
@.str.9 = [3 x i8] c"\\t\00"
@.str.10 = [3 x i8] c"\\n\00"
@.str.11 = [3 x i8] c"\\v\00"
@.str.12 = [3 x i8] c"ff\00"
@.str.13 = [3 x i8] c"cr\00"
@.str.14 = [3 x i8] c"so\00"
@.str.15 = [3 x i8] c"si\00"
@.str.16 = [4 x i8] c"dle\00"
@.str.17 = [4 x i8] c"dc1\00"
@.str.18 = [4 x i8] c"dc2\00"
@.str.19 = [4 x i8] c"dc3\00"
@.str.20 = [4 x i8] c"dc4\00"
@.str.21 = [4 x i8] c"nak\00"
@.str.22 = [4 x i8] c"syn\00"
@.str.23 = [4 x i8] c"etb\00"
@.str.24 = [4 x i8] c"can\00"
@.str.25 = [3 x i8] c"em\00"
@.str.26 = [4 x i8] c"sub\00"
@.str.27 = [4 x i8] c"esc\00"
@.str.28 = [3 x i8] c"fs\00"
@.str.29 = [3 x i8] c"gs\00"
@.str.30 = [3 x i8] c"rs\00"
@.str.31 = [3 x i8] c"us\00"
@.str.32 = [12 x i8] c"0x%02x (%s)\00"
@.str.33 = [5 x i8] c"'%c'\00"
@.str.34 = [11 x i8] c"0x7f (del)\00"
@.str.35 = [5 x i8] c"0x%x\00"
define void @CharToText(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
store i8 %1, i8* %4
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = icmp slt i32 %6, 32
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %4
%11 = load i8, i8* %4
%12 = zext i8 %11 to i64
%13 = getelementptr inbounds [32 x i8*], [32 x i8*]* @CharToText.names, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.32, i64 0, i64 0), i8 zeroext %10, i8* %14)
br label %37
16: ; preds = %2
%17 = load i8, i8* %4
%18 = zext i8 %17 to i32
%19 = icmp slt i32 %18, 127
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i8, i8* %4
%23 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.33, i64 0, i64 0), i8 zeroext %22)
br label %36
24: ; preds = %16
%25 = load i8, i8* %4
%26 = zext i8 %25 to i32
%27 = icmp eq i32 %26, 127
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %35
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = load i8, i8* %4
%34 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.35, i64 0, i64 0), i8 zeroext %33)
br label %35
35: ; preds = %31, %28
br label %36
36: ; preds = %35, %20
br label %37
37: ; preds = %36, %8
ret void
}

LLVM IR (-O2):
@reltable.CharToText = internal unnamed_addr constant [32 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.9 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.10 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.11 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.12 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.13 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.14 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.15 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.16 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.18 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.19 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.20 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.21 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.22 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.23 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.24 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.25 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.26 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.27 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.28 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.29 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.30 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.31 to i64), i64 ptrtoint ([32 x i32]* @reltable.CharToText to i64)) to i32)]
@.str = [4 x i8] c"nul\00"
@.str.1 = [4 x i8] c"soh\00"
@.str.2 = [4 x i8] c"stx\00"
@.str.3 = [4 x i8] c"etx\00"
@.str.4 = [4 x i8] c"eot\00"
@.str.5 = [4 x i8] c"enq\00"
@.str.6 = [4 x i8] c"ack\00"
@.str.7 = [4 x i8] c"bel\00"
@.str.8 = [3 x i8] c"\\b\00"
@.str.9 = [3 x i8] c"\\t\00"
@.str.10 = [3 x i8] c"\\n\00"
@.str.11 = [3 x i8] c"\\v\00"
@.str.12 = [3 x i8] c"ff\00"
@.str.13 = [3 x i8] c"cr\00"
@.str.14 = [3 x i8] c"so\00"
@.str.15 = [3 x i8] c"si\00"
@.str.16 = [4 x i8] c"dle\00"
@.str.17 = [4 x i8] c"dc1\00"
@.str.18 = [4 x i8] c"dc2\00"
@.str.19 = [4 x i8] c"dc3\00"
@.str.20 = [4 x i8] c"dc4\00"
@.str.21 = [4 x i8] c"nak\00"
@.str.22 = [4 x i8] c"syn\00"
@.str.23 = [4 x i8] c"etb\00"
@.str.24 = [4 x i8] c"can\00"
@.str.25 = [3 x i8] c"em\00"
@.str.26 = [4 x i8] c"sub\00"
@.str.27 = [4 x i8] c"esc\00"
@.str.28 = [3 x i8] c"fs\00"
@.str.29 = [3 x i8] c"gs\00"
@.str.30 = [3 x i8] c"rs\00"
@.str.31 = [3 x i8] c"us\00"
@.str.32 = [12 x i8] c"0x%02x (%s)\00"
@.str.33 = [5 x i8] c"'%c'\00"
@.str.34 = [11 x i8] c"0x7f (del)\00"
@.str.35 = [5 x i8] c"0x%x\00"
define void @CharToText(i8* %0, i8 zeroext %1) {
%3 = icmp ult i8 %1, 32
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = zext i8 %1 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([32 x i32]* @reltable.CharToText to i8*), i64 %6)
%8 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.32, i64 0, i64 0), i8 zeroext %1, i8* %7)
br label %19
9: ; preds = %2
%10 = icmp ult i8 %1, 127
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.33, i64 0, i64 0), i8 zeroext %1)
br label %19
13: ; preds = %9
%14 = icmp eq i8 %1, 127
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %19
17: ; preds = %13
%18 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.35, i64 0, i64 0), i8 zeroext %1)
br label %19
19: ; preds = %11, %17, %15, %4
ret void
}