// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
incq 0x8(%rsi)
movl %edx, %r14d
movq %rdi, %rbx
leal -0x7(%r14), %eax
cmpl $0x6, %eax
ja 0xafba
leaq 0x2064(%rip), %rcx      # 0xd004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x36a4(%rip), %rsi      # 0xe654
leaq 0xf(%rsp), %rdx
jmp 0xb04e
cmpl $0x22, %r14d
je 0xaff0
cmpl $0x5c, %r14d
jne 0xb036
leaq 0x369c(%rip), %rsi      # 0xe669
leaq 0x8(%rsp), %rdx
jmp 0xb04e
leaq 0x368b(%rip), %rsi      # 0xe666
leaq 0x9(%rsp), %rdx
jmp 0xb04e
leaq 0x367a(%rip), %rsi      # 0xe663
leaq 0xa(%rsp), %rdx
jmp 0xb04e
leaq 0x3675(%rip), %rsi      # 0xe66c
leaq 0x7(%rsp), %rdx
jmp 0xb04e
leaq 0x3658(%rip), %rsi      # 0xe65d
leaq 0xc(%rsp), %rdx
jmp 0xb04e
leaq 0x3644(%rip), %rsi      # 0xe657
leaq 0xe(%rsp), %rdx
jmp 0xb04e
leaq 0x3639(%rip), %rsi      # 0xe65a
leaq 0xd(%rsp), %rdx
jmp 0xb04e
leaq 0x3631(%rip), %rsi      # 0xe660
leaq 0xb(%rsp), %rdx
jmp 0xb04e
movl %r14d, %eax
xorb $0x3f, %al
xorb $0x3f, %cl
orb %al, %cl
jne 0xb066
leaq 0x3626(%rip), %rsi      # 0xe66f
leaq 0x6(%rsp), %rdx
movq %rbx, %rdi
callq 0x40c0
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leal -0x20(%r14), %eax
cmpb $0x5e, %al
ja 0xb08c
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x41a0
jmp 0xb056
movl %r8d, %ebp
andb $-0x8, %bpl
cmpb $0x30, %bpl
sete %r15b
leaq 0x35c8(%rip), %rsi      # 0xe66a
leaq 0x5(%rsp), %rdx
movq %rbx, %rdi
callq 0x40c0
cmpb $0x8, %r14b
setae %al
orb %r15b, %al
je 0xb118
movl %r14d, %r12d
shrl $0x3, %r12d
movl %r14d, %r15d
andl $0x7, %r15d
cmpb $0x30, %bpl
sete %al
cmpb $0x40, %r14b
setae %cl
orb %al, %cl
je 0xb105
shrb $0x6, %r14b
orb $0x30, %r14b
movzbl %r14b, %esi
movq %rbx, %rdi
callq 0x41a0
andb $0x7, %r12b
orb $0x30, %r12b
movzbl %r12b, %esi
movq %rbx, %rdi
callq 0x41a0
jmp 0xb115
orb $0x30, %r12b
movzbl %r12b, %esi
movq %rbx, %rdi
callq 0x41a0
movl %r15d, %r14d
orb $0x30, %r14b
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x41a0
jmp 0xb056
jmp 0xb12f
movq %rax, %r14
movq %rbx, %rdi
callq 0x4408
movq %r14, %rdi
callq 0x43a0