// File: lvandeve[P]base256/base256.cpp
// Function: CString::encodeChar[abi:cxx11](unsigned char, unsigned char, unsigned char)
std::string encodeChar(unsigned char c, unsigned char prev, unsigned char next) {
    size++;
    if(c == '\a') return "\\a";
    if(c == '\b') return "\\b";
    if(c == '\f') return "\\f";
    if(c == '\n') return "\\n";
    if(c == '\r') return "\\r";
    if(c == '\t') return "\\t";
    if(c == '\v') return "\\v";
    if(c == '\\') return "\\\\";
    if(c == '"') return "\\\"";
    if(c == '?' && prev == '?') return "\\?"; // prevent trigraphs
    if(c >= 32 && c < 127) {
      std::string result;
      result += c;
      return result;
    }
    // octal
    // octal is used, not hexadecimal ("\x..."), because octal is defined to end after 3 characters, while
    // hexadecimal can keep going on indefinitely (it doesn't end after 2) as long as valid hex digits follow,
    // so hexadecimal is harder to deal with if an actual 0-7 or a-f character would follow (requires ending and reopening the string literal)
    bool digitnext = (next >= '0' && next <= '7');
    int o0 = (c >> 6) & 7;
    int o1 = (c >> 3) & 7;
    int o2 = (c >> 0) & 7;
    std::string result = "\\";
    // shorten if possible, e.g. many nulls in a row will be \0\0\0\0 instead of \000\\000\000\000
    // using \0 and other less than 3 digit codes is only ok if no real octal digit after it, else the next character becomes part of the code
    if(c < 8 && !digitnext) {
      result += ('0' + o2);
    } else if (c < 64 && !digitnext) {
      result += ('0' + o1);
      result += ('0' + o2);
    } else {
      result += ('0' + o0);
      result += ('0' + o1);
      result += ('0' + o2);
    }
    return result;
  }

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0x68(%rsp)
movb %r8b, %al
movq %rdi, %r8
movq %r8, 0x70(%rsp)
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movb %dl, 0xa7(%rsp)
movb %cl, 0xa6(%rsp)
movb %al, 0xa5(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movzbl 0xa7(%rsp), %eax
cmpl $0x7, %eax
jne 0x19def
leaq 0xa4(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rdx
leaq 0x8438(%rip), %rsi      # 0x221e8
callq 0x53d0
jmp 0x19db7
leaq 0xa4(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa4(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x8, %eax
jne 0x19e5e
leaq 0x93(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x58(%rsp), %rdx
leaq 0x83cc(%rip), %rsi      # 0x221eb
callq 0x53d0
jmp 0x19e26
leaq 0x93(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x93(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0xc, %eax
jne 0x19ecd
leaq 0x92(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x50(%rsp), %rdx
leaq 0x8360(%rip), %rsi      # 0x221ee
callq 0x53d0
jmp 0x19e95
leaq 0x92(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x92(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0xa, %eax
jne 0x19f3c
leaq 0x91(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rdx
leaq 0x82f4(%rip), %rsi      # 0x221f1
callq 0x53d0
jmp 0x19f04
leaq 0x91(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x91(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0xd, %eax
jne 0x19fab
leaq 0x90(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x40(%rsp), %rdx
leaq 0x8288(%rip), %rsi      # 0x221f4
callq 0x53d0
jmp 0x19f73
leaq 0x90(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x9, %eax
jne 0x1a01a
leaq 0x8f(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x38(%rsp), %rdx
leaq 0x821c(%rip), %rsi      # 0x221f7
callq 0x53d0
jmp 0x19fe2
leaq 0x8f(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x8f(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0xb, %eax
jne 0x1a089
leaq 0x8e(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rdx
leaq 0x81b0(%rip), %rsi      # 0x221fa
callq 0x53d0
jmp 0x1a051
leaq 0x8e(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x8e(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x5c, %eax
jne 0x1a0f8
leaq 0x8d(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x28(%rsp), %rdx
leaq 0x8144(%rip), %rsi      # 0x221fd
callq 0x53d0
jmp 0x1a0c0
leaq 0x8d(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x8d(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x22, %eax
jne 0x1a167
leaq 0x8c(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0x80d8(%rip), %rsi      # 0x22200
callq 0x53d0
jmp 0x1a12f
leaq 0x8c(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x8c(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x3f, %eax
jne 0x1a1e3
movzbl 0xa6(%rsp), %eax
cmpl $0x3f, %eax
jne 0x1a1e3
leaq 0x8b(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x18(%rsp), %rdx
leaq 0x805f(%rip), %rsi      # 0x22203
callq 0x53d0
jmp 0x1a1ab
leaq 0x8b(%rsp), %rdi
callq 0x5300
jmp 0x1a42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x8b(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x20, %eax
jl 0x1a269
movzbl 0xa7(%rsp), %eax
cmpl $0x7f, %eax
jge 0x1a269
movq 0x68(%rsp), %rdi
movb $0x0, 0x8a(%rsp)
callq 0x5400
movq 0x68(%rsp), %rdi
movsbl 0xa7(%rsp), %esi
callq 0x51d0
jmp 0x1a223
movb $0x1, 0x8a(%rsp)
testb $0x1, 0x8a(%rsp)
jne 0x1a264
jmp 0x1a25a
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
callq 0x5558
jmp 0x1a438
movq 0x68(%rsp), %rdi
callq 0x5558
jmp 0x1a42b
movzbl 0xa5(%rsp), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, 0x17(%rsp)
jl 0x1a28e
movzbl 0xa5(%rsp), %eax
cmpl $0x37, %eax
setle %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
andb $0x1, %al
movb %al, 0x89(%rsp)
movzbl 0xa7(%rsp), %eax
shrl $0x6, %eax
movl %eax, 0x84(%rsp)
movzbl 0xa7(%rsp), %eax
shrl $0x3, %eax
andl $0x7, %eax
movl %eax, 0x80(%rsp)
movzbl 0xa7(%rsp), %eax
andl $0x7, %eax
movl %eax, 0x7c(%rsp)
movb $0x0, 0x7b(%rsp)
leaq 0x7a(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x54f0
movq 0x68(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x7f08(%rip), %rsi      # 0x221fe
callq 0x53d0
jmp 0x1a2fd
leaq 0x7a(%rsp), %rdi
callq 0x5300
movzbl 0xa7(%rsp), %eax
cmpl $0x8, %eax
jge 0x1a37f
testb $0x1, 0x89(%rsp)
jne 0x1a37f
movq 0x68(%rsp), %rdi
movl 0x7c(%rsp), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x51d0
jmp 0x1a334
jmp 0x1a413
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x7a(%rsp), %rdi
callq 0x5300
jmp 0x1a438
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
callq 0x5558
jmp 0x1a438
movzbl 0xa7(%rsp), %eax
cmpl $0x40, %eax
jge 0x1a3c7
testb $0x1, 0x89(%rsp)
jne 0x1a3c7
movq 0x68(%rsp), %rdi
movl 0x80(%rsp), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x51d0
jmp 0x1a3af
movq 0x68(%rsp), %rdi
movl 0x7c(%rsp), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x51d0
jmp 0x1a3c5
jmp 0x1a411
movq 0x68(%rsp), %rdi
movl 0x84(%rsp), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x51d0
jmp 0x1a3e0
movq 0x68(%rsp), %rdi
movl 0x80(%rsp), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x51d0
jmp 0x1a3f9
movq 0x68(%rsp), %rdi
movl 0x7c(%rsp), %eax
addl $0x30, %eax
movsbl %al, %esi
callq 0x51d0
jmp 0x1a40f
jmp 0x1a411
jmp 0x1a413
movb $0x1, 0x7b(%rsp)
testb $0x1, 0x7b(%rsp)
jne 0x1a429
movq 0x68(%rsp), %rdi
callq 0x5558
jmp 0x1a42b
movq 0x70(%rsp), %rax
addq $0xb8, %rsp
retq
movq 0x98(%rsp), %rdi
callq 0x54e0
nopw %cs:(%rax,%rax)
nop