// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %rdi, %rbx
movq $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movq (%rsi), %r12
leaq 0x1(%r12), %rax
movq %rax, (%rsi)
movzbl 0x1(%r12), %eax
cmpl $0x27, %eax
jg 0x103fc
cmpl $0x22, %eax
je 0x10445
cmpl $0x24, %eax
jne 0x1042b
movq %rbx, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq 0x1039e
jmp 0x10789
cmpl $0x5b, %eax
je 0x10406
cmpl $0x28, %eax
jne 0x1042b
leaq -0x40(%rbp), %rcx
leaq -0x34(%rbp), %r8
movq %rbx, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq 0xf7e6
testb %al, %al
jne 0x10789
jmp 0x107d2
leaq -0x34(%rbp), %rsi
movq %r15, %rdi
callq 0x1088e
movq %rax, -0x40(%rbp)
testq %rax, %rax
jne 0x1049c
jmp 0x107d2
movl %r14d, -0x30(%rbp)
addq $0x2, %r12
movq %r12, (%r15)
movq %r12, %rdi
callq 0x4f5c
movq %rax, %r13
movq %rax, %rdi
subq %r12, %rdi
incq %rdi
callq 0x152b1
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4f95
movl %eax, -0x34(%rbp)
cltq
movb $0x0, (%r14,%rax)
movq %r13, (%r15)
cmpb $0x22, (%r13)
jne 0x10494
incq %r13
movq %r13, (%r15)
movq %r14, -0x40(%rbp)
movl -0x30(%rbp), %r14d
movq -0x40(%rbp), %r12
movq %r12, %rdi
movl $0x20, %esi
callq 0x3e2e
testq %rax, %rax
je 0x104e8
movq %rax, %r15
movl (%rax), %eax
cmpq $0x4, %rax
ja 0x10819
leaq 0x6458(%rip), %rcx      # 0x16920
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 0x1075b
movslq -0x34(%rbp), %r15
movl %r15d, %eax
shll $0x8, %eax
orl $0x7, %eax
movl %r14d, %r13d
leaq -0x2c(%rbp), %r14
movl %eax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12c34
movl %r15d, %edx
sarl $0x2, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12cf0
movl %r15d, %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 0x12c34
movl $0x2, %eax
jmp 0x1077a
movl 0x3c(%r15), %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 0x10767
cmpl $0x3, %r14d
movl $0x3, %eax
cmovll %r14d, %eax
shll $0x6, %eax
movl 0x3c(%r15), %ecx
shll $0x8, %ecx
orl %eax, %ecx
orl $0x18, %ecx
leaq -0x2c(%rbp), %rsi
movl %ecx, (%rsi)
jmp 0x1076d
movl %r14d, -0x30(%rbp)
leaq -0x2c(%rbp), %r12
movl $0x3, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
movq 0x20(%r15), %r14
leaq 0x636a(%rip), %r13      # 0x16934
movq %r15, -0x48(%rbp)
movzbl (%r14), %eax
cmpl $0x71, %eax
jg 0x10610
cmpl $0x4d, %eax
jle 0x10651
leal -0x62(%rax), %ecx
cmpl $0x7, %ecx
ja 0x1068f
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movl $0x45, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
movl $0x80000000, -0x2c(%rbp) # imm = 0x80000000
jmp 0x10710
cmpl $0x72, %eax
je 0x10660
cmpl $0x74, %eax
je 0x10683
cmpl $0x73, %eax
jne 0x1071b
movl $0x7, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
movl 0xc(%rbx), %esi
cmpl 0x8(%rbx), %esi
jle 0x10645
movq %rbx, %rdi
callq 0x12c74
movl $0x0, -0x2c(%rbp)
jmp 0x10710
cmpl $0x24, %eax
jne 0x10723
movl 0x3c(%r15), %eax
jmp 0x1066a
movq 0xe029(%rip), %rax      # 0x1e690
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 0x10710
movl $0x6, -0x2c(%rbp)
jmp 0x10710
cmpl $0x4e, %eax
jne 0x10735
movl $0xffffff46, -0x2c(%rbp) # imm = 0xFFFFFF46
jmp 0x10710
movl $0x86, -0x2c(%rbp)
jmp 0x10710
movq %r13, %r15
movslq 0xc(%rbx), %r13
movl $0x9, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
movl %r13d, %eax
shll $0x8, %eax
addl $0x201, %eax            # imm = 0x201
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
movl $0x4, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
movl %r13d, %eax
notl %eax
addl 0xc(%rbx), %eax
shll $0x8, %eax
movq (%rbx), %rcx
orl %eax, (%rcx,%r13,4)
movq %r15, %r13
movq -0x48(%rbp), %r15
jmp 0x1071b
movl $0x46, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12c34
incq %r14
jmp 0x105ce
testl %eax, %eax
je 0x1082f
cmpl $0x43, %eax
jne 0x1071b
jmp 0x10823
cmpl $0x56, %eax
jne 0x1071b
movl $0xb, %eax
movl $0x13, %ecx
jmp 0x10839
movl %r14d, %eax
shll $0x6, %eax
orl $0x1e, %eax
cmpl $0x4, %r14d
movl $0x9e, %ecx
cmovll %eax, %ecx
movl 0x3c(%r15), %eax
shll $0x8, %eax
orl %ecx, %eax
leaq -0x2c(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x12c34
movl $0x6, %eax
cmpl $0x6, %eax
je 0x107ac
cmpl $0x3, %eax
je 0x107d2
cmpl $0x2, %eax
jne 0x107f9
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 0x12c34
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x107ba
callq 0x152d7
cmpl $0x7, %r14d
je 0x107e7
cmpl $0x5, %r14d
jne 0x107f9
leaq -0x2c(%rbp), %rsi
movl $0xa, (%rsi)
jmp 0x107f1
testl $0xfffffffb, %r14d      # imm = 0xFFFFFFFB
jne 0x10808
leaq -0x2c(%rbp), %rsi
movl $0x6, (%rsi)
jmp 0x107f1
leaq -0x2c(%rbp), %rsi
movl $0xe, (%rsi)
movq %rbx, %rdi
callq 0x12c34
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x109d3
jmp 0x107f9
movl $0x3, %eax
jmp 0x1077a
movl $0xb, %eax
movl $0x12, %ecx
jmp 0x10839
movl $0x7, %eax
movl $0x10, %ecx
cmpl $0xb, %eax
movl -0x30(%rbp), %r14d
je 0x1084b
cmpl $0x7, %eax
jne 0x1077a
movl %r14d, %eax
shll $0x6, %eax
xorl %r12d, %r12d
cmpl $0x4, %r14d
cmovll %eax, %r12d
movl 0x3c(%r15), %eax
shll $0x8, %eax
orl %ecx, %eax
orl %r12d, %eax
leaq -0x2c(%rbp), %r14
movl %eax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12c34
orl $0x4, %r12d
movl %r12d, (%r14)
movl -0x30(%rbp), %r14d
leaq -0x2c(%rbp), %rsi
jmp 0x1076d