// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_expr.c
// Function: parseBuiltinLenCall
static void parseBuiltinLenCall(Compiler *comp, const Type **type, Const *constant)
{
    *type = NULL;
    parseExpr(comp, type, constant);

    switch ((*type)->kind)
    {
        case TYPE_ARRAY:
        {
            if (constant)
                constant->intVal = (*type)->numItems;
            else
            {
                genPop(&comp->gen);
                genPushIntConst(&comp->gen, (*type)->numItems);
            }
            break;
        }
        case TYPE_DYNARRAY:
        {
            if (constant)
                comp->error.handler(comp->error.context, "Function is not allowed in constant expressions");

            genCallBuiltin(&comp->gen, TYPE_DYNARRAY, BUILTIN_LEN);
            break;
        }
        case TYPE_STR:
        {
            if (constant)
                constCallBuiltin(&comp->consts, constant, NULL, TYPE_STR, BUILTIN_LEN);
            else
                genCallBuiltin(&comp->gen, TYPE_STR, BUILTIN_LEN);
            break;
        }
        case TYPE_MAP:
        {
            if (constant)
                comp->error.handler(comp->error.context, "Function is not allowed in constant expressions");

            genCallBuiltin(&comp->gen, TYPE_MAP, BUILTIN_LEN);
            break;
        }
        default:
        {
            typeAssertCompatibleBuiltin(&comp->types, *type, BUILTIN_LEN, false);
            return;
        }
    }

    *type = comp->intType;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xe8c0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
addl $-0x12, %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x3, %eax
ja 0x1274d
movq -0x20(%rbp), %rax
leaq 0x1c60fa(%rip), %rcx    # 0x1d8720
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x18(%rbp)
je 0x1264a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x12675
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
callq 0x16d30
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x10(%rax), %rsi
callq 0x16850
jmp 0x1276d
cmpq $0x0, -0x18(%rbp)
je 0x126a2
movq -0x8(%rbp), %rax
movq 0x50f8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x5118(%rax), %rdi
leaq 0x1c663d(%rip), %rsi    # 0x1d8cdb
movb $0x0, %al
callq *%rcx
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movl $0x13, %esi
movl $0x22, %edx
callq 0x18040
jmp 0x1276d
cmpq $0x0, -0x18(%rbp)
je 0x126ed
movq -0x8(%rbp), %rdi
addq $0x4e68, %rdi           # imm = 0x4E68
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x14, %ecx
movl $0x22, %r8d
callq 0x9390
jmp 0x12707
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movl $0x14, %esi
movl $0x22, %edx
callq 0x18040
jmp 0x1276d
cmpq $0x0, -0x18(%rbp)
je 0x12731
movq -0x8(%rbp), %rax
movq 0x50f8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x5118(%rax), %rdi
leaq 0x1c65ae(%rip), %rsi    # 0x1d8cdb
movb $0x0, %al
callq *%rcx
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movl $0x15, %esi
movl $0x22, %edx
callq 0x18040
jmp 0x1276d
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0x22, %edx
xorl %ecx, %ecx
callq 0x229e0
jmp 0x1277f
movq -0x8(%rbp), %rax
movq 0x5240(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)