#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
char *ascii2char(const char *string, size_t len) {
  static char buffer[4096];
  unsigned int idx, bufIdx = 0;
  for (idx = 0; idx < len; ++idx) {
    if (string[idx] == '\r') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'r';
    } else if (string[idx] == '\n') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'n';
    } else if (string[idx] == '\t') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 't';
    } else if (string[idx] < 32) {
      int ascii = string[idx];
      buffer[bufIdx++] = '\\';
      if (ascii > 9) {
        buffer[bufIdx++] = (ascii % 10) + 48;
        ascii -= (ascii % 10) * 10;
      }
      buffer[bufIdx++] = ascii + 48;
    } else
      buffer[bufIdx++] = string[idx];
    if (bufIdx > (sizeof(buffer) - 20))
      break;
  }
  buffer[bufIdx] = '\0';
  return buffer;
}


x86 assembly (clang, -O0):
<ascii2char>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%rax
jae    1310 <ascii2char+0x210>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    1174 <ascii2char+0x74>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2edf(%rip),%rax
movb   $0x5c,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2ec5(%rip),%rax
movb   $0x72,(%rax,%rcx,1)
jmp    12e9 <ascii2char+0x1e9>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11c1 <ascii2char+0xc1>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2e92(%rip),%rax
movb   $0x5c,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2e78(%rip),%rax
movb   $0x6e,(%rax,%rcx,1)
jmp    12e4 <ascii2char+0x1e4>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    120e <ascii2char+0x10e>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2e45(%rip),%rax
movb   $0x5c,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2e2b(%rip),%rax
movb   $0x74,(%rax,%rcx,1)
jmp    12df <ascii2char+0x1df>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    12b7 <ascii2char+0x1b7>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2dea(%rip),%rax
movb   $0x5c,(%rax,%rcx,1)
cmpl   $0x9,-0x1c(%rbp)
jle    1291 <ascii2char+0x191>
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2db8(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0xa,%edx,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2d81(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    12da <ascii2char+0x1da>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2d59(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    12df <ascii2char+0x1df>
jmp    12e4 <ascii2char+0x1e4>
jmp    12e9 <ascii2char+0x1e9>
mov    -0x18(%rbp),%eax
cmp    $0xfec,%rax
jbe    12fd <ascii2char+0x1fd>
jmp    1310 <ascii2char+0x210>
jmp    1302 <ascii2char+0x202>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    111a <ascii2char+0x1a>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
lea    0x2d14(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2d09(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ascii2char>:
xor    %ecx,%ecx
test   %rsi,%rsi
je     11f0 <ascii2char+0xf0>
lea    0x2f1e(%rip),%r8
xor    %r10d,%r10d
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rdi,%r10,1),%r11d
cmp    $0x9,%r11b
je     1150 <ascii2char+0x50>
cmp    $0xa,%r11b
je     1160 <ascii2char+0x60>
cmp    $0xd,%r11b
jne    1170 <ascii2char+0x70>
mov    %ecx,%eax
add    $0x1,%ecx
movb   $0x5c,(%rax,%r8,1)
mov    $0x72,%r11b
jmp    11d0 <ascii2char+0xd0>
nopl   0x0(%rax)
mov    %ecx,%eax
add    $0x1,%ecx
movb   $0x5c,(%rax,%r8,1)
mov    $0x74,%r11b
jmp    11d0 <ascii2char+0xd0>
nop
mov    %ecx,%eax
add    $0x1,%ecx
movb   $0x5c,(%rax,%r8,1)
mov    $0x6e,%r11b
jmp    11d0 <ascii2char+0xd0>
nop
cmp    $0x1f,%r11b
jg     11d0 <ascii2char+0xd0>
mov    %ecx,%r9d
movb   $0x5c,(%r9,%r8,1)
add    $0x1,%r9
cmp    $0xa,%r11b
jl     11bf <ascii2char+0xbf>
movzbl %r11b,%edx
imul   $0xcd,%edx,%edx
shr    $0xa,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%edx
mov    %r11d,%eax
sub    %dl,%al
movzbl %al,%eax
mov    %eax,%edx
or     $0x30,%dl
add    $0x2,%ecx
mov    %dl,(%r9,%r8,1)
add    %eax,%eax
lea    (%rax,%rax,4),%eax
neg    %eax
add    %r11b,%al
mov    %ecx,%r9d
mov    %eax,%r11d
add    $0x30,%r11b
mov    %r9d,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%eax
mov    %r11b,(%rax,%r8,1)
add    $0x1,%ecx
cmp    $0xfed,%ecx
jae    11ee <ascii2char+0xee>
add    $0x1,%r10d
cmp    %rsi,%r10
jb     1120 <ascii2char+0x20>
mov    %ecx,%ecx
lea    0x2e39(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
ret

LLVM IR (-O0):
@ascii2char.buffer = internal global [4096 x i8] zeroinitializer
define i8* @ascii2char(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 0, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %126, %2
%9 = load i32, i32* %5
%10 = zext i32 %9 to i64
%11 = load i64, i64* %4
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %129
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 13
br i1 %20, label %21, label %30
21: ; preds = %13
%22 = load i32, i32* %6
%23 = add i32 %22, 1
store i32 %23, i32* %6
%24 = zext i32 %22 to i64
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %24
store i8 92, i8* %25
%26 = load i32, i32* %6
%27 = add i32 %26, 1
store i32 %27, i32* %6
%28 = zext i32 %26 to i64
%29 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %28
store i8 114, i8* %29
br label %120
30: ; preds = %13
%31 = load i8*, i8** %3
%32 = load i32, i32* %5
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %47
38: ; preds = %30
%39 = load i32, i32* %6
%40 = add i32 %39, 1
store i32 %40, i32* %6
%41 = zext i32 %39 to i64
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %41
store i8 92, i8* %42
%43 = load i32, i32* %6
%44 = add i32 %43, 1
store i32 %44, i32* %6
%45 = zext i32 %43 to i64
%46 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %45
store i8 110, i8* %46
br label %119
47: ; preds = %30
%48 = load i8*, i8** %3
%49 = load i32, i32* %5
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 9
br i1 %54, label %55, label %64
55: ; preds = %47
%56 = load i32, i32* %6
%57 = add i32 %56, 1
store i32 %57, i32* %6
%58 = zext i32 %56 to i64
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %58
store i8 92, i8* %59
%60 = load i32, i32* %6
%61 = add i32 %60, 1
store i32 %61, i32* %6
%62 = zext i32 %60 to i64
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %62
store i8 116, i8* %63
br label %118
64: ; preds = %47
%65 = load i8*, i8** %3
%66 = load i32, i32* %5
%67 = zext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp slt i32 %70, 32
br i1 %71, label %72, label %107
72: ; preds = %64
%73 = load i8*, i8** %3
%74 = load i32, i32* %5
%75 = zext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
store i32 %78, i32* %7
%79 = load i32, i32* %6
%80 = add i32 %79, 1
store i32 %80, i32* %6
%81 = zext i32 %79 to i64
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %81
store i8 92, i8* %82
%83 = load i32, i32* %7
%84 = icmp sgt i32 %83, 9
br i1 %84, label %85, label %99
85: ; preds = %72
%86 = load i32, i32* %7
%87 = srem i32 %86, 10
%88 = add nsw i32 %87, 48
%89 = trunc i32 %88 to i8
%90 = load i32, i32* %6
%91 = add i32 %90, 1
store i32 %91, i32* %6
%92 = zext i32 %90 to i64
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %92
store i8 %89, i8* %93
%94 = load i32, i32* %7
%95 = srem i32 %94, 10
%96 = mul nsw i32 %95, 10
%97 = load i32, i32* %7
%98 = sub nsw i32 %97, %96
store i32 %98, i32* %7
br label %99
99: ; preds = %85, %72
%100 = load i32, i32* %7
%101 = add nsw i32 %100, 48
%102 = trunc i32 %101 to i8
%103 = load i32, i32* %6
%104 = add i32 %103, 1
store i32 %104, i32* %6
%105 = zext i32 %103 to i64
%106 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %105
store i8 %102, i8* %106
br label %117
107: ; preds = %64
%108 = load i8*, i8** %3
%109 = load i32, i32* %5
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %108, i64 %110
%112 = load i8, i8* %111
%113 = load i32, i32* %6
%114 = add i32 %113, 1
store i32 %114, i32* %6
%115 = zext i32 %113 to i64
%116 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %115
store i8 %112, i8* %116
br label %117
117: ; preds = %107, %99
br label %118
118: ; preds = %117, %55
br label %119
119: ; preds = %118, %38
br label %120
120: ; preds = %119, %21
%121 = load i32, i32* %6
%122 = zext i32 %121 to i64
%123 = icmp ugt i64 %122, 4076
br i1 %123, label %124, label %125
124: ; preds = %120
br label %129
125: ; preds = %120
br label %126
126: ; preds = %125
%127 = load i32, i32* %5
%128 = add i32 %127, 1
store i32 %128, i32* %5
br label %8
129: ; preds = %124, %8
%130 = load i32, i32* %6
%131 = zext i32 %130 to i64
%132 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %131
store i8 0, i8* %132
ret i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@ascii2char.buffer = internal global [4096 x i8] zeroinitializer
define i8* @ascii2char(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %53, label %8
4: ; preds = %44
%5 = add nuw nsw i64 %9, 1
%6 = and i64 %5, 4294967295
%7 = icmp ult i64 %6, %1
br i1 %7, label %8, label %51
8: ; preds = %2, %4
%9 = phi i64 [ %6, %4 ], [ 0, %2 ]
%10 = phi i32 [ %49, %4 ], [ 0, %2 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = load i8, i8* %11
switch i8 %12, label %25 [
i8 13, label %13
i8 10, label %17
i8 9, label %21
]
13: ; preds = %8
%14 = add nuw nsw i32 %10, 1
%15 = zext i32 %10 to i64
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %15
store i8 92, i8* %16
br label %44
17: ; preds = %8
%18 = add nuw nsw i32 %10, 1
%19 = zext i32 %10 to i64
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %19
store i8 92, i8* %20
br label %44
21: ; preds = %8
%22 = add nuw nsw i32 %10, 1
%23 = zext i32 %10 to i64
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %23
store i8 92, i8* %24
br label %44
25: ; preds = %8
%26 = icmp slt i8 %12, 32
br i1 %26, label %27, label %44
27: ; preds = %25
%28 = add nuw nsw i32 %10, 1
%29 = zext i32 %10 to i64
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %29
store i8 92, i8* %30
%31 = icmp sgt i8 %12, 9
br i1 %31, label %32, label %40
32: ; preds = %27
%33 = urem i8 %12, 10
%34 = or i8 %33, 48
%35 = add nuw nsw i32 %10, 2
%36 = zext i32 %28 to i64
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %36
store i8 %34, i8* %37
%38 = mul nsw i8 %33, -10
%39 = add nsw i8 %38, %12
br label %40
40: ; preds = %32, %27
%41 = phi i32 [ %35, %32 ], [ %28, %27 ]
%42 = phi i8 [ %39, %32 ], [ %12, %27 ]
%43 = add nsw i8 %42, 48
br label %44
44: ; preds = %25, %17, %40, %21, %13
%45 = phi i32 [ %18, %17 ], [ %41, %40 ], [ %22, %21 ], [ %14, %13 ], [ %10, %25 ]
%46 = phi i8 [ 110, %17 ], [ %43, %40 ], [ 116, %21 ], [ 114, %13 ], [ %12, %25 ]
%47 = zext i32 %45 to i64
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %47
store i8 %46, i8* %48
%49 = add i32 %45, 1
%50 = icmp ugt i32 %49, 4076
br i1 %50, label %51, label %4
51: ; preds = %44, %4
%52 = zext i32 %49 to i64
br label %53
53: ; preds = %51, %2
%54 = phi i64 [ 0, %2 ], [ %52, %51 ]
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 %54
store i8 0, i8* %55
ret i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii2char.buffer, i64 0, i64 0)
}