// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_expr.c
// Function: parseBuiltinNewCall
static void parseBuiltinNewCall(Compiler *comp, const Type **type, Const *constant)
{
    if (constant)
        comp->error.handler(comp->error.context, "Function is not allowed in constant expressions");

    // Type
    *type = parseType(comp, NULL);
    typeAssertCompatibleBuiltin(&comp->types, *type, BUILTIN_NEW, (*type)->kind != TYPE_VOID && (*type)->kind != TYPE_NULL);

    genPushIntConst(&comp->gen, typeSize(&comp->types, *type));
    genCallTypedBuiltin(&comp->gen, *type, BUILTIN_NEW);

    // Initializer expression
    if (comp->lex.tok.kind == TOK_COMMA)
    {
        lexNext(&comp->lex);
        genDup(&comp->gen);

        const Type *exprType = *type;
        parseExpr(comp, &exprType, NULL);
        doAssertImplicitTypeConv(comp, *type, &exprType, NULL);

        genChangeRefCntAssign(&comp->gen, *type);
    }

    *type = typeAddPtrTo(&comp->types, &comp->blocks, *type);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1151c
movq -0x8(%rbp), %rax
movq 0x50f8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x5118(%rax), %rdi
leaq 0x1c77c3(%rip), %rsi    # 0x1d8cdb
movb $0x0, %al
callq *%rcx
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9b80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
addq $0x4e18, %rax           # imm = 0x4E18
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x21(%rbp)
je 0x1156d
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x3, (%rax)
setne %al
movb %al, -0x21(%rbp)
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
movb -0x21(%rbp), %al
movzbl %al, %ecx
andl $0x1, %ecx
movl $0x15, %edx
callq 0x229e0
movq -0x8(%rbp), %rax
addq $0x4e70, %rax           # imm = 0x4E70
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x21fe0
movq -0x40(%rbp), %rdi
movslq %eax, %rsi
callq 0x16850
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0x15, %edx
callq 0x182e0
movq -0x8(%rbp), %rax
cmpl $0x3f, 0x4bd0(%rax)
jne 0x1164d
movq -0x8(%rbp), %rdi
addq $0x4ba8, %rdi           # imm = 0x4BA8
callq 0x1ad90
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
callq 0x16eb0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xe8c0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0xd6e0
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x17470
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x8(%rbp), %rsi
addq $0x4220, %rsi           # imm = 0x4220
movq -0x10(%rbp), %rax
movq (%rax), %rdx
callq 0x21fa0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nop