// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_decl.c
// Function: parseVarDeclItem
static void parseVarDeclItem(Compiler *comp)
{
    IdentName varNames[MAX_IDENTS_IN_LIST];
    bool varExported[MAX_IDENTS_IN_LIST];
    int numVars = 0;
    const Type *varType = NULL;
    parseTypedIdentList(comp, varNames, varExported, MAX_IDENTS_IN_LIST, &numVars, &varType, false);

    Ident *var[MAX_IDENTS_IN_LIST];
    for (int i = 0; i < numVars; i++)
    {
        var[i] = identAllocVar(&comp->idents, &comp->types, &comp->modules, &comp->blocks, varNames[i], varType, varExported[i]);
        doZeroVar(comp, var[i]);
    }

    // Initializer
    if (comp->lex.tok.kind == TOK_EQ)
    {
        const Type *designatorType = NULL;
        if (typeStructured(var[0]->type))
            designatorType = var[0]->type;
        else
            designatorType = typeAddPtrTo(&comp->types, &comp->blocks, var[0]->type);

        if (numVars != 1)
        {
            // Designator list (types formally encoded as structure field types - not a real structure)
            Type *designatorListType = typeAdd(&comp->types, &comp->blocks, TYPE_STRUCT);
            designatorListType->isExprList = true;

            for (int i = 0; i < numVars; i++)
                typeAddField(&comp->types, designatorListType, designatorType, NULL);

            designatorType = designatorListType;
        }

        Const varPtrConstList[MAX_IDENTS_IN_LIST] = {0};

        for (int i = 0; i < numVars; i++)
        {
            if (comp->blocks.top == 0)          // Globals are initialized with constant expressions
                varPtrConstList[i].ptrVal = var[i]->ptr;
            else                                // Locals are assigned to
                doPushVarPtr(comp, var[i]);
        }

        lexNext(&comp->lex);
        parseAssignmentStmt(comp, designatorType, (comp->blocks.top == 0) ? varPtrConstList : NULL);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x11170, %rsp          # imm = 0x11170
movq %rdi, -0x8(%rbp)
movl $0x0, -0x10114(%rbp)
movq $0x0, -0x10120(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x10010(%rbp), %rsi
leaq -0x10110(%rbp), %rdx
movl $0x100, %ecx            # imm = 0x100
leaq -0x10114(%rbp), %r8
leaq -0x10120(%rbp), %r9
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0xb7f0
movl $0x0, -0x10924(%rbp)
movl -0x10924(%rbp), %eax
cmpl -0x10114(%rbp), %eax
jge 0xc474
movq -0x8(%rbp), %rdi
addq $0x4e38, %rdi           # imm = 0x4E38
movq -0x8(%rbp), %rsi
addq $0x4e18, %rsi           # imm = 0x4E18
movq -0x8(%rbp), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x8(%rbp), %rcx
addq $0x4220, %rcx           # imm = 0x4220
movslq -0x10924(%rbp), %rax
leaq -0x10010(%rbp), %r8
shlq $0x8, %rax
addq %rax, %r8
movq -0x10120(%rbp), %r9
movslq -0x10924(%rbp), %rax
movb -0x10110(%rbp,%rax), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, (%rsp)
callq 0x1a450
movq %rax, %rcx
movslq -0x10924(%rbp), %rax
movq %rcx, -0x10920(%rbp,%rax,8)
movq -0x8(%rbp), %rdi
movslq -0x10924(%rbp), %rax
movq -0x10920(%rbp,%rax,8), %rsi
callq 0x1d5e0
movl -0x10924(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10924(%rbp)
jmp 0xc3c1
movq -0x8(%rbp), %rax
cmpl $0x31, 0x4bd0(%rax)
jne 0xc67d
movq $0x0, -0x10930(%rbp)
movq -0x10920(%rbp), %rax
movq 0x108(%rax), %rdi
callq 0xbe20
testb $0x1, %al
jne 0xc4a9
jmp 0xc4c0
movq -0x10920(%rbp), %rax
movq 0x108(%rax), %rax
movq %rax, -0x10930(%rbp)
jmp 0xc4f0
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x8(%rbp), %rsi
addq $0x4220, %rsi           # imm = 0x4220
movq -0x10920(%rbp), %rax
movq 0x108(%rax), %rdx
callq 0x21fa0
movq %rax, -0x10930(%rbp)
cmpl $0x1, -0x10114(%rbp)
je 0xc588
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x8(%rbp), %rsi
addq $0x4220, %rsi           # imm = 0x4220
movl $0x16, %edx
callq 0x21950
movq %rax, -0x10938(%rbp)
movq -0x10938(%rbp), %rax
movb $0x1, 0x14(%rax)
movl $0x0, -0x1093c(%rbp)
movl -0x1093c(%rbp), %eax
cmpl -0x10114(%rbp), %eax
jge 0xc57a
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10938(%rbp), %rsi
movq -0x10930(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x23070
movl -0x1093c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1093c(%rbp)
jmp 0xc539
movq -0x10938(%rbp), %rax
movq %rax, -0x10930(%rbp)
leaq -0x11140(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x3190
movl $0x0, -0x11144(%rbp)
movl -0x11144(%rbp), %eax
cmpl -0x10114(%rbp), %eax
jge 0xc612
movq -0x8(%rbp), %rax
cmpl $0x0, 0x4b84(%rax)
jne 0xc5e7
movslq -0x11144(%rbp), %rax
movq -0x10920(%rbp,%rax,8), %rax
movq 0x120(%rax), %rcx
movslq -0x11144(%rbp), %rax
movq %rcx, -0x11140(%rbp,%rax,8)
jmp 0xc5ff
movq -0x8(%rbp), %rdi
movslq -0x11144(%rbp), %rax
movq -0x10920(%rbp,%rax,8), %rsi
callq 0xd010
jmp 0xc601
movl -0x11144(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11144(%rbp)
jmp 0xc5a5
movq -0x8(%rbp), %rdi
addq $0x4ba8, %rdi           # imm = 0x4BA8
callq 0x1ad90
movq -0x8(%rbp), %rax
movq %rax, -0x11158(%rbp)
movq -0x10930(%rbp), %rax
movq %rax, -0x11150(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x4b84(%rax)
jne 0xc658
leaq -0x11140(%rbp), %rax
movq %rax, -0x11160(%rbp)
jmp 0xc663
xorl %eax, %eax
movq %rax, -0x11160(%rbp)
jmp 0xc663
movq -0x11150(%rbp), %rsi
movq -0x11158(%rbp), %rdi
movq -0x11160(%rbp), %rdx
callq 0x1d9c0
addq $0x11170, %rsp          # imm = 0x11170
popq %rbp
retq
nopw %cs:(%rax,%rax)