#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*/ BASM_Parse_EmitChar(char **, int);
int BASM_Parse_ParseChar(char **);
int /*<<< orphan*/ sprintf(char *, char *, int);
char *BASM_PP_EmitCharString(char *t, char *s) {
  int i;
  *t++ = '\'';
  while (*s) {
    i = BASM_Parse_ParseChar(&s);
    if ((i < ' ') || (i >= '~')) {
      if (i > 0xFF) {
        sprintf(t, "\\u%04X", i);
        t += 6;
        continue;
      }
      switch (i) {
      case '\r':
        *t++ = '\\';
        *t++ = 'r';
        break;
      case '\n':
        *t++ = '\\';
        *t++ = 'n';
        break;
      case '\t':
        *t++ = '\\';
        *t++ = 't';
        break;
      case '\x1B':
        *t++ = '\\';
        *t++ = 'e';
        break;
      default:
        sprintf(t, "\\x%02X", i);
        t += 4;
        break;
      }
      continue;
    }
    if (i == '\"')
      *t++ = '\\';
    if (i == '\'')
      *t++ = '\\';
    if (i == '\\')
      *t++ = '\\';
    BASM_Parse_EmitChar(&t, i);
  }
  *t++ = '\'';
  *t = 0;
  return (t);
}


x86 assembly (clang, -O0):
<BASM_PP_EmitCharString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x27,(%rax)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1306 <BASM_PP_EmitCharString+0x1d6>
lea    -0x10(%rbp),%rdi
call   1050 <BASM_Parse_ParseChar@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jl     117f <BASM_PP_EmitCharString+0x4f>
cmpl   $0x7e,-0x14(%rbp)
jl     12a1 <BASM_PP_EmitCharString+0x171>
cmpl   $0xff,-0x14(%rbp)
jle    11b0 <BASM_PP_EmitCharString+0x80>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xeb2(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
jmp    1152 <BASM_PP_EmitCharString+0x22>
mov    -0x14(%rbp),%eax
add    $0xfffffff7,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x12,%eax
ja     127d <BASM_PP_EmitCharString+0x14d>
mov    -0x20(%rbp),%rax
lea    0xe30(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x72,(%rax)
jmp    129c <BASM_PP_EmitCharString+0x16c>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x6e,(%rax)
jmp    129c <BASM_PP_EmitCharString+0x16c>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x74,(%rax)
jmp    129c <BASM_PP_EmitCharString+0x16c>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x65,(%rax)
jmp    129c <BASM_PP_EmitCharString+0x16c>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdc8(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1152 <BASM_PP_EmitCharString+0x22>
cmpl   $0x22,-0x14(%rbp)
jne    12bd <BASM_PP_EmitCharString+0x18d>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
cmpl   $0x27,-0x14(%rbp)
jne    12d9 <BASM_PP_EmitCharString+0x1a9>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
cmpl   $0x5c,-0x14(%rbp)
jne    12f5 <BASM_PP_EmitCharString+0x1c5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x14(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1030 <BASM_Parse_EmitChar@plt>
jmp    1152 <BASM_PP_EmitCharString+0x22>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x27,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BASM_PP_EmitCharString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,0x8(%rsp)
lea    0x1(%rdi),%rax
mov    %rax,(%rsp)
movb   $0x27,(%rdi)
cmpb   $0x0,(%rsi)
je     12a2 <BASM_PP_EmitCharString+0x172>
lea    0x8(%rsp),%rbx
lea    0xeea(%rip),%r14
lea    0xeea(%rip),%r15
lea    0xe90(%rip),%r13
mov    %rsp,%r12
jmp    11a1 <BASM_PP_EmitCharString+0x71>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <sprintf@plt>
addq   $0x6,(%rsp)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     129e <BASM_PP_EmitCharString+0x16e>
mov    %rbx,%rdi
call   1050 <BASM_Parse_ParseChar@plt>
lea    -0x7e(%rax),%ecx
cmp    $0xffffffa1,%ecx
ja     11f0 <BASM_PP_EmitCharString+0xc0>
cmp    $0x100,%eax
jge    1180 <BASM_PP_EmitCharString+0x50>
mov    %eax,%ecx
add    $0xfffffff7,%ecx
cmp    $0x12,%ecx
ja     1240 <BASM_PP_EmitCharString+0x110>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x5c,(%rax)
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x74,(%rax)
jmp    1193 <BASM_PP_EmitCharString+0x63>
nopl   0x0(%rax)
cmp    $0x5c,%eax
je     11ff <BASM_PP_EmitCharString+0xcf>
cmp    $0x27,%eax
je     11ff <BASM_PP_EmitCharString+0xcf>
cmp    $0x22,%eax
jne    120e <BASM_PP_EmitCharString+0xde>
mov    (%rsp),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%rsp)
movb   $0x5c,(%rcx)
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <BASM_Parse_EmitChar@plt>
jmp    1193 <BASM_PP_EmitCharString+0x63>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x5c,(%rax)
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x6e,(%rax)
jmp    1193 <BASM_PP_EmitCharString+0x63>
mov    (%rsp),%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <sprintf@plt>
addq   $0x4,(%rsp)
jmp    1193 <BASM_PP_EmitCharString+0x63>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x5c,(%rax)
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x72,(%rax)
jmp    1193 <BASM_PP_EmitCharString+0x63>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x5c,(%rax)
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x65,(%rax)
jmp    1193 <BASM_PP_EmitCharString+0x63>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x27,(%rax)
mov    (%rsp),%rax
movb   $0x0,(%rax)
mov    (%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\\u%04X\00"
@.str.1 = [7 x i8] c"\\x%02X\00"
define i8* @BASM_PP_EmitCharString(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %3
store i8 39, i8* %6
br label %8
8: ; preds = %75, %56, %22, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %78
12: ; preds = %8
%13 = call i32 @BASM_Parse_ParseChar(i8** %4)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 32
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp sge i32 %17, 126
br i1 %18, label %19, label %57
19: ; preds = %16, %12
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 255
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 6
store i8* %27, i8** %3
br label %8
28: ; preds = %19
%29 = load i32, i32* %5
switch i32 %29, label %50 [
i32 13, label %30
i32 10, label %35
i32 9, label %40
i32 27, label %45
]
30: ; preds = %28
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
store i8 92, i8* %31
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
store i8 114, i8* %33
br label %56
35: ; preds = %28
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %3
store i8 92, i8* %36
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
store i8 110, i8* %38
br label %56
40: ; preds = %28
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
store i8 92, i8* %41
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %3
store i8 116, i8* %43
br label %56
45: ; preds = %28
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
store i8 92, i8* %46
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %3
store i8 101, i8* %48
br label %56
50: ; preds = %28
%51 = load i8*, i8** %3
%52 = load i32, i32* %5
%53 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i64 4
store i8* %55, i8** %3
br label %56
56: ; preds = %50, %45, %40, %35, %30
br label %8
57: ; preds = %16
%58 = load i32, i32* %5
%59 = icmp eq i32 %58, 34
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %3
store i8 92, i8* %61
br label %63
63: ; preds = %60, %57
%64 = load i32, i32* %5
%65 = icmp eq i32 %64, 39
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i8*, i8** %3
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %3
store i8 92, i8* %67
br label %69
69: ; preds = %66, %63
%70 = load i32, i32* %5
%71 = icmp eq i32 %70, 92
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i8*, i8** %3
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %3
store i8 92, i8* %73
br label %75
75: ; preds = %72, %69
%76 = load i32, i32* %5
%77 = call i32 @BASM_Parse_EmitChar(i8** %3, i32 %76)
br label %8
78: ; preds = %8
%79 = load i8*, i8** %3
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %3
store i8 39, i8* %79
%81 = load i8*, i8** %3
store i8 0, i8* %81
%82 = load i8*, i8** %3
ret i8* %82
}

LLVM IR (-O2):
@.str = [7 x i8] c"\\u%04X\00"
@.str.1 = [7 x i8] c"\\x%02X\00"
define i8* @BASM_PP_EmitCharString(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %1, i8** %4
%5 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %5, i8** %3
store i8 39, i8* %0
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %65, label %8
8: ; preds = %2, %19
%9 = call i32 @BASM_Parse_ParseChar(i8** %4)
%10 = add i32 %9, -126
%11 = icmp ult i32 %10, -94
br i1 %11, label %12, label %49
12: ; preds = %8
%13 = icmp sgt i32 %9, 255
br i1 %13, label %14, label %23
14: ; preds = %12
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 6
store i8* %18, i8** %3
br label %19
19: ; preds = %24, %29, %34, %39, %44, %14, %61
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %63, label %8
23: ; preds = %12
switch i32 %9, label %44 [
i32 13, label %24
i32 10, label %29
i32 9, label %34
i32 27, label %39
]
24: ; preds = %23
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %3
store i8 92, i8* %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %3
store i8 114, i8* %27
br label %19
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %3
store i8 92, i8* %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8* %33, i8** %3
store i8 110, i8* %32
br label %19
34: ; preds = %23
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %3
store i8 92, i8* %35
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 1
store i8* %38, i8** %3
store i8 116, i8* %37
br label %19
39: ; preds = %23
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i64 1
store i8* %41, i8** %3
store i8 92, i8* %40
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 1
store i8* %43, i8** %3
store i8 101, i8* %42
br label %19
44: ; preds = %23
%45 = load i8*, i8** %3
%46 = call i32 @sprintf(i8* dereferenceable(1) %45, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 4
store i8* %48, i8** %3
br label %19
49: ; preds = %8
switch i32 %9, label %61 [
i32 34, label %50
i32 39, label %53
i32 92, label %56
]
50: ; preds = %49
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i64 1
store i8* %52, i8** %3
br label %59
53: ; preds = %49
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** %3
br label %59
56: ; preds = %49
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i64 1
store i8* %58, i8** %3
br label %59
59: ; preds = %56, %50, %53
%60 = phi i8* [ %54, %53 ], [ %51, %50 ], [ %57, %56 ]
store i8 92, i8* %60
br label %61
61: ; preds = %59, %49
%62 = call i32 @BASM_Parse_EmitChar(i8** %3, i32 %9)
br label %19
63: ; preds = %19
%64 = load i8*, i8** %3
br label %65
65: ; preds = %63, %2
%66 = phi i8* [ %64, %63 ], [ %5, %2 ]
%67 = getelementptr inbounds i8, i8* %66, i64 1
store i8* %67, i8** %3
store i8 39, i8* %66
%68 = load i8*, i8** %3
store i8 0, i8* %68
%69 = load i8*, i8** %3
ret i8* %69
}