// File: Fohlen[P]cubescript-standalone/command.cpp
// Function: compileblocksub(vector<unsigned int>&, char const*&)
static bool compileblocksub(vector<uint> &code, const char *&p)
{
    char *lookup = NULL;
    int lookuplen = 0;
    switch(*p)
    {
        case '(':
            if(!compilearg(code, p, VAL_STR)) return false;
            break;
        case '[':
            if(!compilearg(code, p, VAL_STR)) return false;
            code.add(CODE_LOOKUPU|RET_STR);
            break;
        case '\"':
            lookup = cutstring(p, lookuplen);
            goto lookupid;
        default:
        {
            {
                const char *start = p;
                while(iscubealnum(*p) || *p=='_') p++;
                lookuplen = p-start;
                if(!lookuplen) return false;
                lookup = newstring(start, lookuplen);
            }
        lookupid:
            ident *id = newident(lookup, IDF_UNKNOWN);
            if(id) switch(id->type)
            {
            case ID_VAR: code.add(CODE_IVAR|RET_STR|(id->index<<8)); goto done;
            case ID_FVAR: code.add(CODE_FVAR|RET_STR|(id->index<<8)); goto done;
            case ID_SVAR: code.add(CODE_SVAR|RET_STR|(id->index<<8)); goto done;
            case ID_ALIAS: code.add((id->index < MAXARGS ? CODE_LOOKUPARG : CODE_LOOKUP)|RET_STR|(id->index<<8)); goto done;
            }
            compilestr(code, lookup, lookuplen, true);
            code.add(CODE_LOOKUPU|RET_STR);
        done:
            delete[] lookup;
            break;
        }
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
movl %eax, -0x50(%rbp)
subl $0x22, %eax
je 0x12173
jmp 0x12103
movl -0x50(%rbp), %eax
subl $0x28, %eax
je 0x12117
jmp 0x1210d
movl -0x50(%rbp), %eax
subl $0x5b, %eax
je 0x1213b
jmp 0x12189
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x3, %edx
callq 0x10c10
testb $0x1, %al
jne 0x12136
movb $0x0, -0x1(%rbp)
jmp 0x1233c
jmp 0x12338
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x3, %edx
callq 0x10c10
testb $0x1, %al
jne 0x1215a
movb $0x0, -0x1(%rbp)
jmp 0x1233c
movq -0x10(%rbp), %rdi
movl $0xe1, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x16f60
jmp 0x12338
movq -0x18(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x11040
movq %rax, -0x20(%rbp)
jmp 0x1220c
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movzbl (%rax), %edi
callq 0x12350
movl %eax, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x51(%rbp)
jne 0x121c2
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
sete %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x121cb
jmp 0x121db
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x12194
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x121fb
movb $0x0, -0x1(%rbp)
jmp 0x1233c
movq -0x30(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x16150
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x20, %esi
callq 0x4e50
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x122f6
movq -0x38(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x60(%rbp)
subq $0x4, %rax
ja 0x122f4
movq -0x60(%rbp), %rax
leaq 0xb6f0(%rip), %rcx      # 0x1d938
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x3c(%rax), %eax
shll $0x8, %eax
orl $0xda, %eax
movl %eax, -0x3c(%rbp)
leaq -0x3c(%rbp), %rsi
callq 0x16f60
jmp 0x1231f
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x3c(%rax), %eax
shll $0x8, %eax
orl $0xde, %eax
movl %eax, -0x40(%rbp)
leaq -0x40(%rbp), %rsi
callq 0x16f60
jmp 0x1231f
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x3c(%rax), %eax
shll $0x8, %eax
orl $0xd8, %eax
movl %eax, -0x44(%rbp)
leaq -0x44(%rbp), %rsi
callq 0x16f60
jmp 0x1231f
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x3c(%rax), %edx
movl $0x20, %eax
movl $0x22, %ecx
cmpl $0x19, %edx
cmovll %ecx, %eax
orl $0xc0, %eax
movq -0x38(%rbp), %rcx
movl 0x3c(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movl %eax, -0x48(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x16f60
jmp 0x1231f
jmp 0x122f6
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
movl $0x1, %ecx
callq 0x10b10
movq -0x10(%rbp), %rdi
movl $0xe1, -0x4c(%rbp)
leaq -0x4c(%rbp), %rsi
callq 0x16f60
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x12336
movq -0x68(%rbp), %rdi
callq 0x1b110
jmp 0x12338
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)