// File: Fohlen[P]cubescript-standalone/command.cpp
// Function: escapestring(char const*)
const char *escapestring(const char *s)
{
    static vector<char> strbuf[3];
    static int stridx = 0;
    stridx = (stridx + 1)%3;
    vector<char> &buf = strbuf[stridx];
    buf.setsize(0);
    buf.add('"');
    for(; *s; s++) switch(*s)
    {
        case '\n': buf.put("^n", 2); break;
        case '\t': buf.put("^t", 2); break;
        case '\f': buf.put("^f", 2); break;
        case '"': buf.put("^\"", 2); break;
        case '^': buf.put("^^", 2); break;
        default: buf.add(*s); break;
    }
    buf.put("\"\0", 2);
    return buf.getbuf();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
cmpb $0x0, 0x1c49d(%rip)     # 0x27750
jne 0xb321
leaq 0x1c494(%rip), %rdi     # 0x27750
callq 0x23f0
cmpl $0x0, %eax
je 0xb321
leaq 0x1c453(%rip), %rax     # 0x27720
movq %rax, -0x30(%rbp)
jmp 0xb2d3
movq -0x30(%rbp), %rdi
movq %rdi, -0x38(%rbp)
callq 0x43a0
jmp 0xb2e2
movq -0x38(%rbp), %rax
addq $0x10, %rax
leaq 0x1c42f(%rip), %rcx     # 0x27720
addq $0x30, %rcx
cmpq %rcx, %rax
movq %rax, -0x30(%rbp)
jne 0xb2d3
leaq -0x8b65(%rip), %rdi     # 0x27a0
xorl %eax, %eax
movl %eax, %esi
leaq 0x1bf10(%rip), %rdx     # 0x27220
callq 0x21a0
leaq 0x1c434(%rip), %rdi     # 0x27750
callq 0x2130
movl 0x1c431(%rip), %eax     # 0x27758
addl $0x1, %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %edx, 0x1c420(%rip)     # 0x27758
movslq 0x1c419(%rip), %rcx     # 0x27758
leaq 0x1c3da(%rip), %rax     # 0x27720
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x15f90
movq -0x20(%rbp), %rdi
movb $0x22, -0x21(%rbp)
leaq -0x21(%rbp), %rsi
callq 0x15fc0
movq -0x8(%rbp), %rax
cmpb $0x0, (%rax)
je 0xb4b4
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x3c(%rbp)
subl $0x9, %eax
je 0xb438
jmp 0xb38f
movl -0x3c(%rbp), %eax
subl $0xa, %eax
je 0xb421
jmp 0xb39d
movl -0x3c(%rbp), %eax
subl $0xc, %eax
je 0xb44f
jmp 0xb3ab
movl -0x3c(%rbp), %eax
subl $0x22, %eax
je 0xb466
jmp 0xb3b9
movl -0x3c(%rbp), %eax
subl $0x5e, %eax
je 0xb47d
jmp 0xb494
movq %rdx, %rcx
movq %rax, %rdx
movq -0x38(%rbp), %rax
movq %rdx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
leaq 0x1c33e(%rip), %rcx     # 0x27720
cmpq %rax, %rcx
movq %rax, -0x48(%rbp)
je 0xb410
movq -0x48(%rbp), %rdi
addq $-0x10, %rdi
movq %rdi, -0x50(%rbp)
callq 0x43d0
movq -0x50(%rbp), %rax
leaq 0x1c319(%rip), %rcx     # 0x27720
cmpq %rcx, %rax
movq %rax, -0x48(%rbp)
jne 0xb3eb
leaq 0x1c339(%rip), %rdi     # 0x27750
callq 0x2120
jmp 0xb4d8
movq -0x20(%rbp), %rdi
leaq 0x12beb(%rip), %rsi     # 0x1e017
movl $0x2, %edx
callq 0x16020
jmp 0xb4a1
movq -0x20(%rbp), %rdi
leaq 0x12bd7(%rip), %rsi     # 0x1e01a
movl $0x2, %edx
callq 0x16020
jmp 0xb4a1
movq -0x20(%rbp), %rdi
leaq 0x12bc3(%rip), %rsi     # 0x1e01d
movl $0x2, %edx
callq 0x16020
jmp 0xb4a1
movq -0x20(%rbp), %rdi
leaq 0x12baf(%rip), %rsi     # 0x1e020
movl $0x2, %edx
callq 0x16020
jmp 0xb4a1
movq -0x20(%rbp), %rdi
leaq 0x12b9b(%rip), %rsi     # 0x1e023
movl $0x2, %edx
callq 0x16020
jmp 0xb4a1
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15fc0
jmp 0xb4a3
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xb36d
movq -0x20(%rbp), %rdi
leaq 0x128d1(%rip), %rsi     # 0x1dd90
movl $0x2, %edx
callq 0x16020
movq -0x20(%rbp), %rdi
callq 0x16070
addq $0x50, %rsp
popq %rbp
retq
movq -0x10(%rbp), %rdi
callq 0x23e0
nopw %cs:(%rax,%rax)