// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
incq 0x8(%rsi)
movl %edx, %r14d
movq %rdi, %rbx
leal -0x7(%r14), %eax
cmpl $0x6, %eax
ja 0xdf92
leaq 0x3095(%rip), %rcx      # 0x11004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x46f8(%rip), %rsi      # 0x1267e
leaq 0x46f3(%rip), %rdx      # 0x12680
jmp 0xe084
cmpl $0x22, %r14d
je 0xdff0
cmpl $0x5c, %r14d
jne 0xe063
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x46e3(%rip), %rsi      # 0x12693
leaq 0x46de(%rip), %rdx      # 0x12695
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x46c6(%rip), %rsi      # 0x12690
leaq 0x46c1(%rip), %rdx      # 0x12692
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x46a9(%rip), %rsi      # 0x1268d
leaq 0x46a4(%rip), %rdx      # 0x1268f
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4698(%rip), %rsi      # 0x12696
leaq 0x4693(%rip), %rdx      # 0x12698
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4672(%rip), %rsi      # 0x12687
leaq 0x466d(%rip), %rdx      # 0x12689
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4655(%rip), %rsi      # 0x12681
leaq 0x4650(%rip), %rdx      # 0x12683
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4641(%rip), %rsi      # 0x12684
leaq 0x463c(%rip), %rdx      # 0x12686
jmp 0xe084
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4630(%rip), %rsi      # 0x1268a
leaq 0x462b(%rip), %rdx      # 0x1268c
jmp 0xe084
movl %r14d, %eax
xorb $0x3f, %al
xorb $0x3f, %cl
orb %al, %cl
jne 0xe09e
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x461c(%rip), %rsi      # 0x12699
leaq 0x4617(%rip), %rdx      # 0x1269b
movq %rbx, %rdi
callq 0xc264
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal -0x20(%r14), %eax
cmpb $0x5e, %al
ja 0xe0c7
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x51f0
jmp 0xe08c
movl %r8d, %ebp
andb $-0x8, %bpl
cmpb $0x30, %bpl
sete %r12b
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
leaq 0x45b0(%rip), %rsi      # 0x12694
leaq 0x45aa(%rip), %rdx      # 0x12695
movq %rbx, %rdi
callq 0xc264
cmpb $0x8, %r14b
setae %al
orb %r12b, %al
je 0xe15c
movl %r14d, %r13d
shrl $0x3, %r13d
movl %r14d, %r12d
andl $0x7, %r12d
cmpb $0x30, %bpl
sete %al
cmpb $0x40, %r14b
setae %cl
orb %al, %cl
je 0xe149
shrb $0x6, %r14b
orb $0x30, %r14b
movzbl %r14b, %esi
movq %rbx, %rdi
callq 0x51f0
andb $0x7, %r13b
orb $0x30, %r13b
movzbl %r13b, %esi
movq %rbx, %rdi
callq 0x51f0
jmp 0xe159
orb $0x30, %r13b
movzbl %r13b, %esi
movq %rbx, %rdi
callq 0x51f0
movl %r12d, %r14d
orb $0x30, %r14b
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x51f0
jmp 0xe08c
jmp 0xe173
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0xe183
callq 0x5210
movq %r14, %rdi
callq 0x53e0
nop