#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 sprintf(char *, char *, unsigned char);
char *char2string(unsigned char value) {
  static unsigned index = 0;
  static char buffer[60];
  char *text = buffer + (index * 6);
  index = (index + 1) % 10;
  switch (value) {
  case '\a':
    return "\\a";
  case '\b':
    return "\\b";
  case '\e':
    return "\\e";
  case '\f':
    return "\\f";
  case '\n':
    return "\\n";
  case '\r':
    return "\\r";
  case '\t':
    return "\\t";
  case '\v':
    return "\\v";
  case '\'':
    return "\\'";
  case '\"':
    return "\\\"";
  case '\\':
    return "\\\\";
  default:
    if (value < 32) {
      int len = sprintf(text, "\\%03o", value);
      text[len] = 0;
      return text;
    }
    if (126 < value) {
      int len = sprintf(text, "\\%03o", value);
      text[len] = 0;
      return text;
    }
    break;
  }
  text[0] = (char)value;
  text[1] = 0;
  return text;
}


x86 assembly (clang, -O0):
<char2string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    0x2f1c(%rip),%ecx
add    %ecx,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %eax,%ecx
lea    0x2f1c(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    0x2eff(%rip),%edx
mov    %edx,%ecx
add    $0x1,%ecx
mov    %edx,%eax
mov    $0xcccccccd,%edx
imul   %rdx,%rcx
shr    $0x23,%rcx
mov    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
neg    %edx
mov    %edx,%ecx
lea    0x1(%rax,%rcx,1),%eax
mov    %eax,0x2ed4(%rip)
movzbl -0x9(%rbp),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x55,%eax
ja     1246 <char2string+0x136>
mov    -0x28(%rbp),%rax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfbb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xfae(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xfa1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf94(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf87(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf7a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf6d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf53(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf46(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
lea    0xf39(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
movzbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jge    1283 <char2string+0x173>
mov    -0x18(%rbp),%rdi
lea    0xf1b(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
movzbl -0x9(%rbp),%ecx
mov    $0x7e,%eax
cmp    %ecx,%eax
jge    12c4 <char2string+0x1b4>
mov    -0x18(%rbp),%rdi
lea    0xeda(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e2 <char2string+0x1d2>
jmp    12c9 <char2string+0x1b9>
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char2string>:
push   %rbx
mov    0x2f29(%rip),%eax
lea    0x1(%rax),%ecx
mov    $0xcccccccd,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%ecx
neg    %ecx
add    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2f07(%rip)
lea    -0x7(%rdi),%ecx
cmp    $0x55,%cl
ja     11bb <char2string+0xab>
lea    0x1010(%rip),%rbx
movzbl %cl,%ecx
lea    0xeae(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xff9(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xffc(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfea(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfea(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfd5(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfd2(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfc0(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfcc(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfc0(%rip),%rbx
jmp    11f8 <char2string+0xe8>
lea    0xfbd(%rip),%rbx
jmp    11f8 <char2string+0xe8>
add    %eax,%eax
lea    (%rax,%rax,2),%eax
lea    0x2e89(%rip),%rbx
add    %rax,%rbx
cmp    $0x1f,%dil
jbe    11d6 <char2string+0xc6>
cmp    $0x7f,%dil
jb     11f1 <char2string+0xe1>
movzbl %dil,%edx
lea    0xf98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
cltq
movb   $0x0,(%rbx,%rax,1)
jmp    11f8 <char2string+0xe8>
mov    %dil,(%rbx)
movb   $0x0,0x1(%rbx)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@char2string.index = internal global i32 0
@char2string.buffer = internal global [60 x i8] zeroinitializer
@.str = [3 x i8] c"\\a\00"
@.str.1 = [3 x i8] c"\\b\00"
@.str.2 = [3 x i8] c"\\e\00"
@.str.3 = [3 x i8] c"\\f\00"
@.str.4 = [3 x i8] c"\\n\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\t\00"
@.str.7 = [3 x i8] c"\\v\00"
@.str.8 = [3 x i8] c"\\'\00"
@.str.9 = [3 x i8] c"\\\22\00"
@.str.10 = [3 x i8] c"\\\\\00"
@.str.11 = [6 x i8] c"\\%03o\00"
define i8* @char2string(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %3
%7 = load i32, i32* @char2string.index
%8 = mul i32 %7, 6
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @char2string.buffer, i64 0, i64 0), i64 %9
store i8* %10, i8** %4
%11 = load i32, i32* @char2string.index
%12 = add i32 %11, 1
%13 = urem i32 %12, 10
store i32 %13, i32* @char2string.index
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
switch i32 %15, label %27 [
i32 7, label %16
i32 8, label %17
i32 27, label %18
i32 12, label %19
i32 10, label %20
i32 13, label %21
i32 9, label %22
i32 11, label %23
i32 39, label %24
i32 34, label %25
i32 92, label %26
]
16: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %61
17: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %61
18: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %61
19: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %61
20: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %61
21: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %61
22: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %61
23: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %61
24: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %61
25: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %61
26: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %61
27: ; preds = %1
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = icmp slt i32 %29, 32
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = load i8, i8* %3
%34 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8 zeroext %33)
store i32 %34, i32* %5
%35 = load i8*, i8** %4
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %4
store i8* %39, i8** %2
br label %61
40: ; preds = %27
%41 = load i8, i8* %3
%42 = zext i8 %41 to i32
%43 = icmp slt i32 126, %42
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = load i8*, i8** %4
%46 = load i8, i8* %3
%47 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8 zeroext %46)
store i32 %47, i32* %6
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 0, i8* %51
%52 = load i8*, i8** %4
store i8* %52, i8** %2
br label %61
53: ; preds = %40
br label %54
54: ; preds = %53
%55 = load i8, i8* %3
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i64 0
store i8 %55, i8* %57
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8 0, i8* %59
%60 = load i8*, i8** %4
store i8* %60, i8** %2
br label %61
61: ; preds = %54, %44, %31, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16
%62 = load i8*, i8** %2
ret i8* %62
}

LLVM IR (-O2):
@char2string.index = internal unnamed_addr global i32 0
@char2string.buffer = internal global [60 x i8] zeroinitializer
@.str = [3 x i8] c"\\a\00"
@.str.1 = [3 x i8] c"\\b\00"
@.str.2 = [3 x i8] c"\\e\00"
@.str.3 = [3 x i8] c"\\f\00"
@.str.4 = [3 x i8] c"\\n\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\t\00"
@.str.7 = [3 x i8] c"\\v\00"
@.str.8 = [3 x i8] c"\\'\00"
@.str.9 = [3 x i8] c"\\\22\00"
@.str.10 = [3 x i8] c"\\\\\00"
@.str.11 = [6 x i8] c"\\%03o\00"
define i8* @char2string(i8 zeroext %0) {
%2 = load i32, i32* @char2string.index
%3 = mul i32 %2, 6
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds [60 x i8], [60 x i8]* @char2string.buffer, i64 0, i64 %4
%6 = add i32 %2, 1
%7 = urem i32 %6, 10
store i32 %7, i32* @char2string.index
switch i8 %0, label %18 [
i8 7, label %32
i8 8, label %8
i8 27, label %9
i8 12, label %10
i8 10, label %11
i8 13, label %12
i8 9, label %13
i8 11, label %14
i8 39, label %15
i8 34, label %16
i8 92, label %17
]
8: ; preds = %1
br label %32
9: ; preds = %1
br label %32
10: ; preds = %1
br label %32
11: ; preds = %1
br label %32
12: ; preds = %1
br label %32
13: ; preds = %1
br label %32
14: ; preds = %1
br label %32
15: ; preds = %1
br label %32
16: ; preds = %1
br label %32
17: ; preds = %1
br label %32
18: ; preds = %1
%19 = icmp ult i8 %0, 32
br i1 %19, label %20, label %24
20: ; preds = %18
%21 = tail call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8 zeroext %0)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %5, i64 %22
store i8 0, i8* %23
br label %32
24: ; preds = %18
%25 = icmp ugt i8 %0, 126
br i1 %25, label %26, label %30
26: ; preds = %24
%27 = tail call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8 zeroext %0)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %5, i64 %28
store i8 0, i8* %29
br label %32
30: ; preds = %24
store i8 %0, i8* %5
%31 = getelementptr inbounds i8, i8* %5, i64 1
store i8 0, i8* %31
br label %32
32: ; preds = %1, %30, %26, %20, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8
%33 = phi i8* [ %5, %20 ], [ %5, %26 ], [ %5, %30 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), %17 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), %16 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), %15 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %13 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %10 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %33
}