// File: /workspace/github_cpp_makefile_star2_O3/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 0xa660
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
cmpl $0x5c, %ebp
je 0xa686
testl %ebp, %ebp
jne 0xa72c
jmp 0xa98a
leaq 0x2(%rax), %r12
movb 0x1(%rax), %bpl
movzbl %bpl, %ecx
cmpl $0x60, %ecx
jg 0xa6b9
leal -0x30(%rcx), %edx
cmpl $0x8, %edx
jae 0xa740
movb %bpl, 0xc(%rsp)
movb (%r12), %cl
movb %cl, 0xd(%rsp)
testb %cl, %cl
je 0xa6ff
movb 0x3(%rax), %al
jmp 0xa701
cmpl $0x6d, %ecx
jle 0xa6df
addl $-0x6e, %ecx
cmpl $0xa, %ecx
ja 0xa7b8
leaq 0x16cfb(%rip), %rdx     # 0x213cc
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movb $0xa, %bpl
jmp 0xa729
cmpl $0x61, %ecx
je 0xa7a8
cmpl $0x62, %ecx
je 0xa7b0
cmpl $0x66, %ecx
jne 0xa7b8
movb $0xc, %bpl
jmp 0xa729
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
movsbl %bpl, %esi
movq %rbx, %rdi
callq 0x5390
movq %r13, %rax
jmp 0xa66d
testl %ecx, %ecx
jne 0xa7b8
movb $0x5c, %bpl
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa72c
movq 0x8(%rdi), %rdx
movl $0x2b, %r8d
xorl %esi, %esi
leaq 0x16cbf(%rip), %rcx     # 0x21423
callq 0x5630
jmp 0xa72c
movb $0xb, %bpl
jmp 0xa729
movb $0x9, %bpl
jmp 0xa729
movsbl (%r12), %edi
callq 0x5090
testl %eax, %eax
je 0xa849
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
movl $0x10, %edx
callq 0x5120
movq %rax, %rbp
movq 0x18(%rsp), %r13
jmp 0xa72c
movb $0xd, %bpl
jmp 0xa729
movb $0x7, %bpl
jmp 0xa729
movb $0x8, %bpl
jmp 0xa729
movq %rbx, %rdi
movl $0x5c, %esi
callq 0x5390
cmpq $0x0, 0x10(%rsp)
je 0xa729
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 0xa49f
movl $0x1d, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x16c4d(%rip), %rcx     # 0x21469
callq 0x5490
leaq 0x38(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xa887
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0xa88d
movq %rbx, %rdi
movl $0x5c, %esi
callq 0x5390
movb $0x78, %bpl
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa729
movq 0x8(%rdi), %rdx
movl $0x19, %r8d
xorl %esi, %esi
leaq 0x16bd5(%rip), %rcx     # 0x2144f
callq 0x5630
movq %r12, %r13
jmp 0xa72c
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rdi
leaq 0x168bc(%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 0xa8de
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0xa8e6
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 0xa924
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xa940
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa965
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa729
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0xa729
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0xa9ca
jmp 0xaa0d
movq %rax, %r14
jmp 0xa9ef
movq %rax, %r14
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xa9ca
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa9ef
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xaa10
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0xaa10
movq %rax, %r14
movq (%rbx), %rdi
cmpq 0x20(%rsp), %rdi
je 0xaa2a
movq 0x20(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x5410
movq %r14, %rdi
callq 0x5720