// File: /workspace/github_cpp_makefile_star2_O1/jovermann[P]streplace/src/MiscUtils.cpp
// Function: ut1::compileCString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
std::string compileCString(const std::string& s, std::string* errorMessageOut)
{
    std::string r;
    const char* p = s.c_str();
    const char* end;
    char        buf[4];

    if (errorMessageOut)
    {
        errorMessageOut->clear();
    }
    for (;;)
    {
        char c = *(p++);
        if (c == 0)
        {
            break;
        }
        if (c == '\\')
        {
            // Escape sequence.
            c = *(p++);
            switch (c)
            {
                // End of string in escape sequence: Emit verbatim backslash.
            case 0:
                c = '\\';
                p--;
                if (errorMessageOut)
                {
                    *errorMessageOut = "unexpected end of string in escape sequence";
                }
                break;

                // Named control chars.
            case 'a': c = '\a'; break;
            case 'b': c = '\b'; break;
            case 'f': c = '\f'; break;
            case 'n': c = '\n'; break;
            case 'r': c = '\r'; break;
            case 't': c = '\t'; break;
            case 'v':
                c = '\v';
                break;

                // Hex.
            case 'x':
                if (std::isxdigit(unsigned(p[0])))
                {
                    c = char(std::strtoul(p, const_cast<char**>(&end), 16));
                    p = end;
                }
                else
                {
                    r += '\\';
                    if (errorMessageOut)
                    {
                        *errorMessageOut = "non hex char following \\x";
                    }
                }
                break;

                // Octal.
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
                // Copy octal number.
                buf[0] = c;
                buf[1] = p[0];
                buf[2] = p[0] ? p[1] : 0;
                buf[3] = 0;
                c      = char(std::strtoul(buf, const_cast<char**>(&end), 8));
                p += end - buf - 1;
                break;

                // Known backslash sequence: Leave escape sequence intact.
            default:
                r += '\\';
                if (errorMessageOut)
                {
                    *errorMessageOut = "unknown backslash sequence '\\" + expandUnprintable(std::string(1, c)) + "'";
                }
                break;
            }
        }
        r += c;
    }
    return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, 0x20(%rsp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
movq (%rsi), %rax
testq %rdx, %rdx
je 0xa665
movq $0x0, 0x8(%rdx)
movq (%rdx), %rcx
movb $0x0, (%rcx)
movq %rdx, 0x10(%rsp)
leaq 0xc(%rsp), %r15
notq %r15
leaq 0x1(%rax), %r13
movzbl (%rax), %ebp
testl %ebp, %ebp
je 0xa6b9
cmpl $0x5c, %ebp
jne 0xa734
leaq 0x2(%rax), %r12
movb 0x1(%rax), %bpl
movzbl %bpl, %ecx
cmpl $0x60, %ecx
jg 0xa6c1
leal -0x30(%rcx), %edx
cmpl $0x8, %edx
jae 0xa754
movb %bpl, 0xc(%rsp)
movb (%r12), %cl
movb %cl, 0xd(%rsp)
testb %cl, %cl
je 0xa707
movb 0x3(%rax), %al
jmp 0xa709
xorl %r12d, %r12d
jmp 0xa743
cmpl $0x6d, %ecx
jle 0xa6e7
addl $-0x6e, %ecx
cmpl $0xa, %ecx
ja 0xa7d2
leaq 0x16cf3(%rip), %rdx     # 0x213cc
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movb $0xa, %bpl
jmp 0xa731
cmpl $0x61, %ecx
je 0xa7c2
cmpl $0x62, %ecx
je 0xa7ca
cmpl $0x66, %ecx
jne 0xa7d2
movb $0xc, %bpl
jmp 0xa731
xorl %eax, %eax
movb %al, 0xe(%rsp)
movb $0x0, 0xf(%rsp)
leaq 0xc(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x8, %edx
callq 0x5120
movq %rax, %rbp
addq %r15, %r12
addq 0x18(%rsp), %r12
movq %r12, %r13
movb $0x1, %r12b
movsbl %bpl, %esi
movq %rbx, %rdi
callq 0x5390
movq %r13, %rax
testb %r12b, %r12b
jne 0xa672
jmp 0xa9a1
testl %ecx, %ecx
jne 0xa7d2
movb $0x5c, %bpl
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa734
movq 0x8(%rdi), %rdx
movl $0x2b, %r8d
xorl %esi, %esi
leaq 0x16cab(%rip), %rcx     # 0x21423
callq 0x5630
jmp 0xa734
movb $0xb, %bpl
jmp 0xa731
movb $0x9, %bpl
jmp 0xa731
movsbl (%r12), %edi
callq 0x5090
testl %eax, %eax
je 0xa863
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
movl $0x10, %edx
callq 0x5120
movq %rax, %rbp
movq 0x18(%rsp), %r13
jmp 0xa734
movb $0xd, %bpl
jmp 0xa731
movb $0x7, %bpl
jmp 0xa731
movb $0x8, %bpl
jmp 0xa731
movq %rbx, %rdi
movl $0x5c, %esi
callq 0x5390
cmpq $0x0, 0x10(%rsp)
je 0xa731
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movsbl %bpl, %edx
movl $0x1, %esi
leaq 0x48(%rsp), %r13
movq %r13, %rdi
callq 0x54e0
leaq 0x88(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xa4a5
leaq 0x38(%rsp), %r13
movl $0x1d, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x16c2e(%rip), %rcx     # 0x21469
callq 0x5490
movq %r13, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xa89e
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0xa8a6
movq %rbx, %rdi
movl $0x5c, %esi
callq 0x5390
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa731
movq 0x8(%rdi), %rdx
movl $0x19, %r8d
xorl %esi, %esi
leaq 0x16bbe(%rip), %rcx     # 0x2144f
callq 0x5630
movq %r12, %r13
jmp 0xa734
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %r13, %r14
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rdi
leaq 0x168a0(%rip), %rsi     # 0x2116d
callq 0x57c0
leaq 0x78(%rsp), %r13
movq %r13, 0x68(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xa8fa
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0xa902
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x5500
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0xa940
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0xa957
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa97c
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa731
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0xa731
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0xa9d5
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0xa9d5
movq %rax, %r15
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa9ff
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0xa9ff
movq %rax, %r15
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xaa22
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0xaa22
jmp 0xaa1f
movq %rax, %r15
movq (%rbx), %rdi
cmpq 0x20(%rsp), %rdi
je 0xaa3c
movq 0x20(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x5410
movq %r15, %rdi
callq 0x5720