// File: /workspace/github_cpp_makefile_star2_O3/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 0xdcc8
leaq 0x335f(%rip), %rcx      # 0x11004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x49c2(%rip), %rsi      # 0x1267e
leaq 0x49bd(%rip), %rdx      # 0x12680
jmp 0xddba
cmpl $0x22, %r14d
je 0xdd26
cmpl $0x5c, %r14d
jne 0xdd99
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x49ad(%rip), %rsi      # 0x12693
leaq 0x49a8(%rip), %rdx      # 0x12695
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4990(%rip), %rsi      # 0x12690
leaq 0x498b(%rip), %rdx      # 0x12692
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4973(%rip), %rsi      # 0x1268d
leaq 0x496e(%rip), %rdx      # 0x1268f
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x4962(%rip), %rsi      # 0x12696
leaq 0x495d(%rip), %rdx      # 0x12698
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x493c(%rip), %rsi      # 0x12687
leaq 0x4937(%rip), %rdx      # 0x12689
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x491f(%rip), %rsi      # 0x12681
leaq 0x491a(%rip), %rdx      # 0x12683
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x490b(%rip), %rsi      # 0x12684
leaq 0x4906(%rip), %rdx      # 0x12686
jmp 0xddba
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x48fa(%rip), %rsi      # 0x1268a
leaq 0x48f5(%rip), %rdx      # 0x1268c
jmp 0xddba
movl %r14d, %eax
xorb $0x3f, %al
xorb $0x3f, %cl
orb %al, %cl
jne 0xddd4
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x48e6(%rip), %rsi      # 0x12699
leaq 0x48e1(%rip), %rdx      # 0x1269b
movq %rbx, %rdi
callq 0xbfd2
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 0xddfd
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x51f0
jmp 0xddc2
movl %r8d, %ebp
andb $-0x8, %bpl
cmpb $0x30, %bpl
sete %r12b
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
leaq 0x487a(%rip), %rsi      # 0x12694
leaq 0x4874(%rip), %rdx      # 0x12695
movq %rbx, %rdi
callq 0xbfd2
cmpb $0x8, %r14b
setae %al
orb %r12b, %al
je 0xde92
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 0xde7f
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 0xde8f
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 0xddc2
jmp 0xdea9
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0xdeb9
callq 0x5210
movq %r14, %rdi
callq 0x53e0
nop