// File: /workspace/github_cpp_makefile_star2_O3/Fohlen[P]cubescript-standalone/command.cpp
// Function: compilelookup(vector<unsigned int>&, char const*&, int)
static void compilelookup(vector<uint> &code, const char *&p, int ltype)
{
    char *lookup = NULL;
    int lookuplen = 0;
    switch(*++p)
    {
        case '(':
        case '[':
            if(!compileword(code, p, VAL_STR, lookup, lookuplen)) goto invalid;
            break;
        case '$':
            compilelookup(code, p, VAL_STR);
            break;
        case '\"':
            lookup = cutstring(p, lookuplen);
            goto lookupid;
        default:
        {
            lookup = cutword(p, lookuplen);
            if(!lookup) goto invalid;
        lookupid:
            ident *id = newident(lookup, IDF_UNKNOWN);
            if(id) switch(id->type)
            {
                case ID_VAR: code.add(CODE_IVAR|((ltype >= VAL_ANY ? VAL_INT : ltype)<<CODE_RET)|(id->index<<8)); goto done;
                case ID_FVAR: code.add(CODE_FVAR|((ltype >= VAL_ANY ? VAL_FLOAT : ltype)<<CODE_RET)|(id->index<<8)); goto done;
                case ID_SVAR: code.add(CODE_SVAR|((ltype >= VAL_ANY ? VAL_STR : ltype)<<CODE_RET)|(id->index<<8)); goto done;
                case ID_ALIAS: code.add((id->index < MAXARGS ? CODE_LOOKUPARG : CODE_LOOKUP)|((ltype >= VAL_ANY ? VAL_STR : ltype)<<CODE_RET)|(id->index<<8)); goto done;
                case ID_COMMAND:
                {
                    int comtype = CODE_COM, numargs = 0;
                    code.add(CODE_ENTER);
                    for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt)
                    {
                        case 's': compilestr(code, NULL, 0, true); numargs++; break;
                        case 'i': compileint(code); numargs++; break;         
                        case 'b': compileint(code, INT_MIN); numargs++; break;
                        case 'f': compilefloat(code); numargs++; break;
                        case 't': compilenull(code); numargs++; break;
                        case 'e': compileblock(code); numargs++; break;
                        case 'r': compileident(code); numargs++; break;
                        case '$': compileident(code, id); numargs++; break;
                        case 'N': compileint(code, -1); numargs++; break;
                        case 'C': comtype = CODE_COMC; numargs = 1; goto endfmt;
                        case 'V': comtype = CODE_COMV; numargs = 2; goto endfmt;
                        case '1': case '2': case '3': case '4': break; 
                    }
                endfmt:
                    code.add(comtype|(ltype < VAL_ANY ? ltype<<CODE_RET : 0)|(id->index<<8));
                    code.add(CODE_EXIT|(ltype < VAL_ANY ? ltype<<CODE_RET : 0));
                    goto done;
                }
                default: goto invalid;
            }
            compilestr(code, lookup, lookuplen, true);
            break;
        }
    }
    code.add(CODE_LOOKUPU|((ltype < VAL_ANY ? ltype<<CODE_RET : 0)));
done:
    delete[] lookup;
    switch(ltype)
    {
        case VAL_CODE: code.add(CODE_COMPILE); break;
        case VAL_IDENT: code.add(CODE_IDENTU); break;
    }
    return;
invalid:
    switch(ltype)
    {
        case VAL_NULL: case VAL_ANY: compilenull(code); break;
        default: compileval(code, ltype, NULL, 0); break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r14d
movq %rsi, %r12
movq %rdi, %rbx
movq $0x0, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movq (%rsi), %r13
leaq 0x1(%r13), %rax
movq %rax, (%rsi)
movzbl 0x1(%r13), %eax
cmpl $0x27, %eax
jg 0x1095a
cmpl $0x22, %eax
je 0x109aa
cmpl $0x24, %eax
jne 0x1098d
movq %rbx, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq 0x108fb
xorl %r15d, %r15d
jmp 0x10ac2
cmpl $0x5b, %eax
je 0x10964
cmpl $0x28, %eax
jne 0x1098d
leaq -0x40(%rbp), %rcx
leaq -0x30(%rbp), %r8
movq %rbx, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq 0xfdb6
testb %al, %al
je 0x10a47
movq -0x40(%rbp), %r15
jmp 0x10ac2
leaq -0x30(%rbp), %rsi
movq %r12, %rdi
callq 0x10dc1
movq %rax, %r15
movq %rax, -0x40(%rbp)
testq %rax, %rax
jne 0x10a03
jmp 0x10a47
movl %r14d, -0x34(%rbp)
addq $0x2, %r13
movq %r13, (%r12)
movq %r13, %rdi
callq 0x4f49
movq %rax, %r14
movq %rax, %rdi
subq %r13, %rdi
incq %rdi
callq 0x15705
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x4f82
movl %eax, -0x30(%rbp)
cltq
movb $0x0, (%r15,%rax)
movq %r14, (%r12)
cmpb $0x22, (%r14)
jne 0x109fb
incq %r14
movq %r14, (%r12)
movq %r15, -0x40(%rbp)
movl -0x34(%rbp), %r14d
movq %r15, %rdi
movl $0x20, %esi
callq 0x3e12
testq %rax, %rax
je 0x10a63
movq %rax, %r12
movl (%rax), %eax
cmpq $0x4, %rax
ja 0x10a47
leaq 0x7059(%rip), %rcx      # 0x17a80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r14d, %eax
shll $0x6, %eax
orl $0x1a, %eax
cmpl $0x4, %r14d
movl $0x5a, %ecx
jmp 0x10d11
testl $0xfffffffb, %r14d      # imm = 0xFFFFFFFB
jne 0x10af3
leaq -0x2c(%rbp), %rsi
movl $0x6, (%rsi)
jmp 0x10daa
movslq -0x30(%rbp), %r12
movl %r12d, %eax
shll $0x8, %eax
orl $0x7, %eax
movl %r14d, %r13d
leaq -0x2c(%rbp), %r14
movl %eax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13178
movl %r12d, %edx
sarl $0x2, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x13236
movl %r12d, %edx
andl $0x3, %edx
movl $0x0, (%r14)
addq %r15, %r12
subq %rdx, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2130
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %r14d
callq 0x13178
movl %r14d, %eax
shll $0x6, %eax
orl $0x21, %eax
cmpl $0x4, %r14d
movl $0x21, %ecx
cmovll %eax, %ecx
leaq -0x2c(%rbp), %rsi
movl %ecx, (%rsi)
movq %rbx, %rdi
callq 0x13178
testq %r15, %r15
jne 0x10d80
jmp 0x10d88
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f06
movl 0x3c(%r12), %eax
xorl %ecx, %ecx
cmpl $0x19, %eax
setl %cl
cmpl $0x3, %r14d
movl $0x3, %edx
cmovll %r14d, %edx
shll $0x6, %edx
leal (%rdx,%rcx,2), %ecx
shll $0x8, %eax
orl %ecx, %eax
orl $0x20, %eax
jmp 0x10d1e
cmpl $0x3, %r14d
movl $0x3, %eax
cmovll %r14d, %eax
shll $0x6, %eax
movl 0x3c(%r12), %ecx
shll $0x8, %ecx
orl %eax, %ecx
orl $0x18, %ecx
leaq -0x2c(%rbp), %rsi
movl %ecx, (%rsi)
jmp 0x10d78
movl %r14d, -0x34(%rbp)
leaq -0x2c(%rbp), %r13
movl $0x3, (%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
movq 0x20(%r12), %r14
movq %r15, -0x48(%rbp)
movzbl (%r14), %eax
cmpl $0x71, %eax
jg 0x10bd1
cmpl $0x4d, %eax
jle 0x10c12
leal -0x62(%rax), %ecx
cmpl $0x7, %ecx
ja 0x10c51
leaq 0x6eea(%rip), %rdx      # 0x17a94
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x45, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
movl $0x80000000, -0x2c(%rbp) # imm = 0x80000000
jmp 0x10cd2
cmpl $0x72, %eax
je 0x10c22
cmpl $0x74, %eax
je 0x10c45
cmpl $0x73, %eax
jne 0x10cdd
movl $0x7, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
movl 0xc(%rbx), %esi
cmpl 0x8(%rbx), %esi
jle 0x10c06
movq %rbx, %rdi
callq 0x131ba
movl $0x0, -0x2c(%rbp)
jmp 0x10cd2
cmpl $0x24, %eax
jne 0x10ce5
movl 0x3c(%r12), %eax
jmp 0x10c2c
movq 0xea67(%rip), %rax      # 0x1f690
movl 0x3c(%rax), %eax
xorl %ecx, %ecx
cmpl $0x19, %eax
setl %cl
shll $0x8, %eax
leal (%rax,%rcx,2), %eax
addl $0xd, %eax
movl %eax, -0x2c(%rbp)
jmp 0x10cd2
movl $0x6, -0x2c(%rbp)
jmp 0x10cd2
cmpl $0x4e, %eax
jne 0x10cf0
movl $0xffffff46, -0x2c(%rbp) # imm = 0xFFFFFF46
jmp 0x10cd2
movl $0x86, -0x2c(%rbp)
jmp 0x10cd2
movq %r12, %r15
movslq 0xc(%rbx), %r12
movl $0x9, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
movl %r12d, %eax
shll $0x8, %eax
addl $0x201, %eax            # imm = 0x201
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
movl $0x4, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
movl %r12d, %eax
notl %eax
addl 0xc(%rbx), %eax
shll $0x8, %eax
movq (%rbx), %rcx
orl %eax, (%rcx,%r12,4)
movq %r15, %r12
movq -0x48(%rbp), %r15
jmp 0x10cdd
movl $0x46, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13178
incq %r14
jmp 0x10b89
testl %eax, %eax
je 0x10d30
cmpl $0x43, %eax
jne 0x10cdd
jmp 0x10d26
cmpl $0x56, %eax
jne 0x10cdd
movq %r12, %rdx
movl $0x13, %eax
jmp 0x10d38
movl %r14d, %eax
shll $0x6, %eax
orl $0x1e, %eax
cmpl $0x4, %r14d
movl $0x9e, %ecx
cmovll %eax, %ecx
movl 0x3c(%r12), %eax
shll $0x8, %eax
orl %ecx, %eax
leaq -0x2c(%rbp), %rsi
movl %eax, (%rsi)
jmp 0x10d78
movq %r12, %rdx
movl $0x12, %eax
jmp 0x10d38
movq %r12, %rdx
movl $0x10, %eax
movl -0x34(%rbp), %r13d
movl %r13d, %ecx
shll $0x6, %ecx
xorl %r12d, %r12d
cmpl $0x4, %r13d
cmovll %ecx, %r12d
movl 0x3c(%rdx), %ecx
shll $0x8, %ecx
orl %eax, %ecx
orl %r12d, %ecx
leaq -0x2c(%rbp), %r14
movl %ecx, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13178
orl $0x4, %r12d
movl %r12d, (%r14)
movl %r13d, %r14d
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x13178
movq %r15, %rdi
callq 0x1572b
cmpl $0x7, %r14d
je 0x10da0
cmpl $0x5, %r14d
jne 0x10db2
leaq -0x2c(%rbp), %rsi
movl $0xa, (%rsi)
jmp 0x10daa
leaq -0x2c(%rbp), %rsi
movl $0xe, (%rsi)
movq %rbx, %rdi
callq 0x13178
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq