// File: Fohlen[P]cubescript-standalone/command.cpp
// Function: compileblockstr(vector<unsigned int>&, char const*, char const*, bool)
static bool compileblockstr(vector<uint> &code, const char *str, const char *end, bool macro)
{
    int start = code.length();
    code.add(macro ? CODE_MACRO : CODE_VAL|RET_STR); 
    char *buf = (char *)code.reserve((end-str)/sizeof(uint)+1).buf;
    int len = 0;
    while(str < end)
    {
        int n = strcspn(str, "\r/\"@]\0");
        memcpy(&buf[len], str, n);
        len += n;
        str += n;
        switch(*str)
        {
            case '\r': str++; break;
            case '\"':
            {
                const char *start = str; 
                str = parsestring(str+1);
                if(*str=='\"') str++;
                memcpy(&buf[len], start, str-start);
                len += str-start;
                break;
            }
            case '/': 
                if(str[1] == '/') str += strcspn(str, "\n\0");
                else buf[len++] = *str++;
                break;
            case '@':
            case ']':
                if(str < end) { buf[len++] = *str++; break; }
            case '\0': goto done;
        }
    }
done:
    memset(&buf[len], '\0', sizeof(uint)-len%sizeof(uint));
    code.advance(len/sizeof(uint)+1);
    code[start] |= len<<8;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rdi
callq 0x15e00
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movb -0x19(%rbp), %dl
movl $0xc5, %eax
movl $0x7, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x24(%rbp)
leaq -0x24(%rbp), %rsi
callq 0x16f60
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
shrq $0x2, %rax
addq $0x1, %rax
movl %eax, %edx
leaq -0x48(%rbp), %rdi
callq 0x15d90
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x12068
movq -0x10(%rbp), %rdi
leaq 0xbedf(%rip), %rsi      # 0x1ddb3
callq 0x2040
movl %eax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x4c(%rbp), %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movslq -0x50(%rbp), %rdx
callq 0x2170
movl -0x50(%rbp), %ecx
movl -0x4c(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movslq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x5c(%rbp)
testl %eax, %eax
je 0x12061
jmp 0x11f22
movl -0x5c(%rbp), %eax
subl $0xd, %eax
je 0x11f63
jmp 0x11f2c
movl -0x5c(%rbp), %eax
subl $0x22, %eax
je 0x11f74
jmp 0x11f36
movl -0x5c(%rbp), %eax
subl $0x2f, %eax
je 0x11fde
jmp 0x11f44
movl -0x5c(%rbp), %eax
subl $0x40, %eax
je 0x1202d
jmp 0x11f52
movl -0x5c(%rbp), %eax
subl $0x5d, %eax
je 0x1202d
jmp 0x12063
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x12063
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1, %rdi
callq 0x6280
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x11fa5
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x4c(%rbp), %rax
addq %rax, %rdi
movq -0x58(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x58(%rbp), %rax
subq %rax, %rdx
callq 0x2170
movq -0x10(%rbp), %rcx
movq -0x58(%rbp), %rax
subq %rax, %rcx
movslq -0x4c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x4c(%rbp)
jmp 0x12063
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2f, %eax
jne 0x12005
movq -0x10(%rbp), %rdi
leaq 0xbdb3(%rip), %rsi      # 0x1dda9
callq 0x2040
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x1202b
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %dl
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4c(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x12063
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x1205f
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %dl
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4c(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x12063
jmp 0x12061
jmp 0x1206a
jmp 0x11ebb
jmp 0x1206a
movq -0x30(%rbp), %rdi
movslq -0x4c(%rbp), %rax
addq %rax, %rdi
movslq -0x4c(%rbp), %rax
andq $0x3, %rax
movl $0x4, %edx
subq %rax, %rdx
xorl %esi, %esi
callq 0x20e0
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rax
shrq $0x2, %rax
addq $0x1, %rax
movl %eax, %esi
callq 0x170d0
movl -0x4c(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x15ea0
movl -0x60(%rbp), %ecx
orl (%rax), %ecx
movl %ecx, (%rax)
movb $0x1, %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)